]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.9.8-201306272057.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.9.8-201306272057.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..79768fb 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,9 +75,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 +TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56 @@ -80,6 +88,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60 +ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64 @@ -92,19 +101,24 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68 +builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74 +clut_vga16.c
75 +common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82 +config.c
83 config.mak
84 config.mak.autogen
85 +config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 @@ -115,9 +129,11 @@ devlist.h*
90 dnotify_test
91 docproc
92 dslm
93 +dtc-lexer.lex.c
94 elf2ecoff
95 elfconfig.h*
96 evergreen_reg_safe.h
97 +exception_policy.conf
98 fixdep
99 flask.h
100 fore200e_mkfirm
101 @@ -125,12 +141,15 @@ fore200e_pca_fw.c*
102 gconf
103 gconf.glade.h
104 gen-devlist
105 +gen-kdb_cmds.c
106 gen_crc32table
107 gen_init_cpio
108 generated
109 genheaders
110 genksyms
111 *_gray256.c
112 +hash
113 +hid-example
114 hpet_example
115 hugepage-mmap
116 hugepage-shm
117 @@ -145,14 +164,14 @@ int32.c
118 int4.c
119 int8.c
120 kallsyms
121 -kconfig
122 +kern_constants.h
123 keywords.c
124 ksym.c*
125 ksym.h*
126 kxgettext
127 lex.c
128 lex.*.c
129 -linux
130 +lib1funcs.S
131 logo_*.c
132 logo_*_clut224.c
133 logo_*_mono.c
134 @@ -162,14 +181,15 @@ mach-types.h
135 machtypes.h
136 map
137 map_hugetlb
138 -media
139 mconf
140 +mdp
141 miboot*
142 mk_elfconfig
143 mkboot
144 mkbugboot
145 mkcpustr
146 mkdep
147 +mkpiggy
148 mkprep
149 mkregtable
150 mktables
151 @@ -185,6 +205,8 @@ oui.c*
152 page-types
153 parse.c
154 parse.h
155 +parse-events*
156 +pasyms.h
157 patches*
158 pca200e.bin
159 pca200e_ecd.bin2
160 @@ -194,6 +216,7 @@ perf-archive
161 piggyback
162 piggy.gzip
163 piggy.S
164 +pmu-*
165 pnmtologo
166 ppc_defs.h*
167 pss_boot.h
168 @@ -203,7 +226,10 @@ r200_reg_safe.h
169 r300_reg_safe.h
170 r420_reg_safe.h
171 r600_reg_safe.h
172 +realmode.lds
173 +realmode.relocs
174 recordmcount
175 +regdb.c
176 relocs
177 rlim_names.h
178 rn50_reg_safe.h
179 @@ -213,8 +239,12 @@ series
180 setup
181 setup.bin
182 setup.elf
183 +signing_key*
184 +size_overflow_hash.h
185 sImage
186 +slabinfo
187 sm_tbl*
188 +sortextable
189 split-include
190 syscalltab.h
191 tables.c
192 @@ -224,6 +254,7 @@ tftpboot.img
193 timeconst.h
194 times.h*
195 trix_boot.h
196 +user_constants.h
197 utsrelease.h*
198 vdso-syms.lds
199 vdso.lds
200 @@ -235,13 +266,17 @@ vdso32.lds
201 vdso32.so.dbg
202 vdso64.lds
203 vdso64.so.dbg
204 +vdsox32.lds
205 +vdsox32-syms.lds
206 version.h*
207 vmImage
208 vmlinux
209 vmlinux-*
210 vmlinux.aout
211 vmlinux.bin.all
212 +vmlinux.bin.bz2
213 vmlinux.lds
214 +vmlinux.relocs
215 vmlinuz
216 voffset.h
217 vsyscall.lds
218 @@ -249,9 +284,12 @@ vsyscall_32.lds
219 wanxlfw.inc
220 uImage
221 unifdef
222 +utsrelease.h
223 wakeup.bin
224 wakeup.elf
225 wakeup.lds
226 +x509*
227 zImage*
228 zconf.hash.c
229 +zconf.lex.c
230 zoffset.h
231 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
232 index 8ccbf27..afffeb4 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -948,6 +948,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
236 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
237 Default: 1024
238
239 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
240 + ignore grsecurity's /proc restrictions
241 +
242 +
243 hashdist= [KNL,NUMA] Large hashes allocated during boot
244 are distributed across NUMA nodes. Defaults on
245 for 64-bit NUMA, off otherwise.
246 @@ -2147,6 +2151,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 the specified number of seconds. This is to be used if
248 your oopses keep scrolling off the screen.
249
250 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
251 + virtualization environments that don't cope well with the
252 + expand down segment used by UDEREF on X86-32 or the frequent
253 + page table updates on X86-64.
254 +
255 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
256 +
257 + pax_extra_latent_entropy
258 + Enable a very simple form of latent entropy extraction
259 + from the first 4GB of memory as the bootmem allocator
260 + passes the memory pages to the buddy allocator.
261 +
262 pcbit= [HW,ISDN]
263
264 pcd. [PARIDE]
265 diff --git a/Makefile b/Makefile
266 index b013cbe..4ca639b 100644
267 --- a/Makefile
268 +++ b/Makefile
269 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
270
271 HOSTCC = gcc
272 HOSTCXX = g++
273 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
274 -HOSTCXXFLAGS = -O2
275 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
276 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
277 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
278
279 # Decide whether to build built-in, modular, or both.
280 # Normally, just do built-in.
281 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
282 # Rules shared between *config targets and build targets
283
284 # Basic helpers built in scripts/
285 -PHONY += scripts_basic
286 -scripts_basic:
287 +PHONY += scripts_basic gcc-plugins
288 +scripts_basic: gcc-plugins
289 $(Q)$(MAKE) $(build)=scripts/basic
290 $(Q)rm -f .tmp_quiet_recordmcount
291
292 @@ -576,6 +577,65 @@ else
293 KBUILD_CFLAGS += -O2
294 endif
295
296 +ifndef DISABLE_PAX_PLUGINS
297 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
298 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
299 +else
300 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
301 +endif
302 +ifneq ($(PLUGINCC),)
303 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
304 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
305 +endif
306 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
307 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
308 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
309 +endif
310 +ifdef CONFIG_KALLOCSTAT_PLUGIN
311 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
312 +endif
313 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
314 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
315 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
316 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
317 +endif
318 +ifdef CONFIG_CHECKER_PLUGIN
319 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
320 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
321 +endif
322 +endif
323 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
324 +ifdef CONFIG_PAX_SIZE_OVERFLOW
325 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
326 +endif
327 +ifdef CONFIG_PAX_LATENT_ENTROPY
328 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
329 +endif
330 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
331 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
332 +endif
333 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
334 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
335 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
336 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
337 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
338 +ifeq ($(KBUILD_EXTMOD),)
339 +gcc-plugins:
340 + $(Q)$(MAKE) $(build)=tools/gcc
341 +else
342 +gcc-plugins: ;
343 +endif
344 +else
345 +gcc-plugins:
346 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
347 + $(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.))
348 +else
349 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
350 +endif
351 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
352 +endif
353 +endif
354 +
355 include $(srctree)/arch/$(SRCARCH)/Makefile
356
357 ifdef CONFIG_READABLE_ASM
358 @@ -733,7 +793,7 @@ export mod_sign_cmd
359
360
361 ifeq ($(KBUILD_EXTMOD),)
362 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
363 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
364
365 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
366 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
367 @@ -780,6 +840,8 @@ endif
368
369 # The actual objects are generated when descending,
370 # make sure no implicit rule kicks in
371 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
372 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
373 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
374
375 # Handle descending into subdirectories listed in $(vmlinux-dirs)
376 @@ -789,7 +851,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
377 # Error messages still appears in the original language
378
379 PHONY += $(vmlinux-dirs)
380 -$(vmlinux-dirs): prepare scripts
381 +$(vmlinux-dirs): gcc-plugins prepare scripts
382 $(Q)$(MAKE) $(build)=$@
383
384 # Store (new) KERNELRELASE string in include/config/kernel.release
385 @@ -833,6 +895,7 @@ prepare0: archprepare FORCE
386 $(Q)$(MAKE) $(build)=.
387
388 # All the preparing..
389 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
390 prepare: prepare0
391
392 # Generate some files
393 @@ -940,6 +1003,8 @@ all: modules
394 # using awk while concatenating to the final file.
395
396 PHONY += modules
397 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
398 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
399 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
400 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
401 @$(kecho) ' Building modules, stage 2.';
402 @@ -955,7 +1020,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
403
404 # Target to prepare building external modules
405 PHONY += modules_prepare
406 -modules_prepare: prepare scripts
407 +modules_prepare: gcc-plugins prepare scripts
408
409 # Target to install modules
410 PHONY += modules_install
411 @@ -1021,7 +1086,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
412 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
413 signing_key.priv signing_key.x509 x509.genkey \
414 extra_certificates signing_key.x509.keyid \
415 - signing_key.x509.signer
416 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
417
418 # clean - Delete most, but leave enough to build external modules
419 #
420 @@ -1061,6 +1126,7 @@ distclean: mrproper
421 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
422 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
423 -o -name '.*.rej' \
424 + -o -name '.*.rej' -o -name '*.so' \
425 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
426 -type f -print | xargs rm -f
427
428 @@ -1221,6 +1287,8 @@ PHONY += $(module-dirs) modules
429 $(module-dirs): crmodverdir $(objtree)/Module.symvers
430 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
431
432 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
433 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
434 modules: $(module-dirs)
435 @$(kecho) ' Building modules, stage 2.';
436 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
437 @@ -1357,17 +1425,21 @@ else
438 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
439 endif
440
441 -%.s: %.c prepare scripts FORCE
442 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
443 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
444 +%.s: %.c gcc-plugins prepare scripts FORCE
445 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
446 %.i: %.c prepare scripts FORCE
447 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
448 -%.o: %.c prepare scripts FORCE
449 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
450 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
451 +%.o: %.c gcc-plugins prepare scripts FORCE
452 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
453 %.lst: %.c prepare scripts FORCE
454 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
455 -%.s: %.S prepare scripts FORCE
456 +%.s: %.S gcc-plugins prepare scripts FORCE
457 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
458 -%.o: %.S prepare scripts FORCE
459 +%.o: %.S gcc-plugins prepare scripts FORCE
460 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
461 %.symtypes: %.c prepare scripts FORCE
462 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
463 @@ -1377,11 +1449,15 @@ endif
464 $(cmd_crmodverdir)
465 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
466 $(build)=$(build-dir)
467 -%/: prepare scripts FORCE
468 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
469 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
470 +%/: gcc-plugins prepare scripts FORCE
471 $(cmd_crmodverdir)
472 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
473 $(build)=$(build-dir)
474 -%.ko: prepare scripts FORCE
475 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
476 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
477 +%.ko: gcc-plugins prepare scripts FORCE
478 $(cmd_crmodverdir)
479 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
480 $(build)=$(build-dir) $(@:.ko=.o)
481 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
482 index c2cbe4f..f7264b4 100644
483 --- a/arch/alpha/include/asm/atomic.h
484 +++ b/arch/alpha/include/asm/atomic.h
485 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
486 #define atomic_dec(v) atomic_sub(1,(v))
487 #define atomic64_dec(v) atomic64_sub(1,(v))
488
489 +#define atomic64_read_unchecked(v) atomic64_read(v)
490 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
491 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
492 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
493 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
494 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
495 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
496 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
497 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
498 +
499 #define smp_mb__before_atomic_dec() smp_mb()
500 #define smp_mb__after_atomic_dec() smp_mb()
501 #define smp_mb__before_atomic_inc() smp_mb()
502 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
503 index ad368a9..fbe0f25 100644
504 --- a/arch/alpha/include/asm/cache.h
505 +++ b/arch/alpha/include/asm/cache.h
506 @@ -4,19 +4,19 @@
507 #ifndef __ARCH_ALPHA_CACHE_H
508 #define __ARCH_ALPHA_CACHE_H
509
510 +#include <linux/const.h>
511
512 /* Bytes per L1 (data) cache line. */
513 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
514 -# define L1_CACHE_BYTES 64
515 # define L1_CACHE_SHIFT 6
516 #else
517 /* Both EV4 and EV5 are write-through, read-allocate,
518 direct-mapped, physical.
519 */
520 -# define L1_CACHE_BYTES 32
521 # define L1_CACHE_SHIFT 5
522 #endif
523
524 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
525 #define SMP_CACHE_BYTES L1_CACHE_BYTES
526
527 #endif
528 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
529 index 968d999..d36b2df 100644
530 --- a/arch/alpha/include/asm/elf.h
531 +++ b/arch/alpha/include/asm/elf.h
532 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
533
534 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
535
536 +#ifdef CONFIG_PAX_ASLR
537 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
538 +
539 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
540 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
541 +#endif
542 +
543 /* $0 is set by ld.so to a pointer to a function which might be
544 registered using atexit. This provides a mean for the dynamic
545 linker to call DT_FINI functions for shared libraries that have
546 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
547 index bc2a0da..8ad11ee 100644
548 --- a/arch/alpha/include/asm/pgalloc.h
549 +++ b/arch/alpha/include/asm/pgalloc.h
550 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
551 pgd_set(pgd, pmd);
552 }
553
554 +static inline void
555 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
556 +{
557 + pgd_populate(mm, pgd, pmd);
558 +}
559 +
560 extern pgd_t *pgd_alloc(struct mm_struct *mm);
561
562 static inline void
563 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
564 index 81a4342..348b927 100644
565 --- a/arch/alpha/include/asm/pgtable.h
566 +++ b/arch/alpha/include/asm/pgtable.h
567 @@ -102,6 +102,17 @@ struct vm_area_struct;
568 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
569 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
570 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
571 +
572 +#ifdef CONFIG_PAX_PAGEEXEC
573 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
574 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
575 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
576 +#else
577 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
578 +# define PAGE_COPY_NOEXEC PAGE_COPY
579 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
580 +#endif
581 +
582 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
583
584 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
585 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
586 index 2fd00b7..cfd5069 100644
587 --- a/arch/alpha/kernel/module.c
588 +++ b/arch/alpha/kernel/module.c
589 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
590
591 /* The small sections were sorted to the end of the segment.
592 The following should definitely cover them. */
593 - gp = (u64)me->module_core + me->core_size - 0x8000;
594 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
595 got = sechdrs[me->arch.gotsecindex].sh_addr;
596
597 for (i = 0; i < n; i++) {
598 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
599 index b9e37ad..44c24e7 100644
600 --- a/arch/alpha/kernel/osf_sys.c
601 +++ b/arch/alpha/kernel/osf_sys.c
602 @@ -1297,10 +1297,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
603 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
604
605 static unsigned long
606 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
607 - unsigned long limit)
608 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
609 + unsigned long limit, unsigned long flags)
610 {
611 struct vm_unmapped_area_info info;
612 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
613
614 info.flags = 0;
615 info.length = len;
616 @@ -1308,6 +1309,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
617 info.high_limit = limit;
618 info.align_mask = 0;
619 info.align_offset = 0;
620 + info.threadstack_offset = offset;
621 return vm_unmapped_area(&info);
622 }
623
624 @@ -1340,20 +1342,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
625 merely specific addresses, but regions of memory -- perhaps
626 this feature should be incorporated into all ports? */
627
628 +#ifdef CONFIG_PAX_RANDMMAP
629 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
630 +#endif
631 +
632 if (addr) {
633 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
634 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
635 if (addr != (unsigned long) -ENOMEM)
636 return addr;
637 }
638
639 /* Next, try allocating at TASK_UNMAPPED_BASE. */
640 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
641 - len, limit);
642 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
643 +
644 if (addr != (unsigned long) -ENOMEM)
645 return addr;
646
647 /* Finally, try allocating in low memory. */
648 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
649 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
650
651 return addr;
652 }
653 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
654 index 0c4132d..88f0d53 100644
655 --- a/arch/alpha/mm/fault.c
656 +++ b/arch/alpha/mm/fault.c
657 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
658 __reload_thread(pcb);
659 }
660
661 +#ifdef CONFIG_PAX_PAGEEXEC
662 +/*
663 + * PaX: decide what to do with offenders (regs->pc = fault address)
664 + *
665 + * returns 1 when task should be killed
666 + * 2 when patched PLT trampoline was detected
667 + * 3 when unpatched PLT trampoline was detected
668 + */
669 +static int pax_handle_fetch_fault(struct pt_regs *regs)
670 +{
671 +
672 +#ifdef CONFIG_PAX_EMUPLT
673 + int err;
674 +
675 + do { /* PaX: patched PLT emulation #1 */
676 + unsigned int ldah, ldq, jmp;
677 +
678 + err = get_user(ldah, (unsigned int *)regs->pc);
679 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
680 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
681 +
682 + if (err)
683 + break;
684 +
685 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
686 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
687 + jmp == 0x6BFB0000U)
688 + {
689 + unsigned long r27, addr;
690 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
691 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
692 +
693 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
694 + err = get_user(r27, (unsigned long *)addr);
695 + if (err)
696 + break;
697 +
698 + regs->r27 = r27;
699 + regs->pc = r27;
700 + return 2;
701 + }
702 + } while (0);
703 +
704 + do { /* PaX: patched PLT emulation #2 */
705 + unsigned int ldah, lda, br;
706 +
707 + err = get_user(ldah, (unsigned int *)regs->pc);
708 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
709 + err |= get_user(br, (unsigned int *)(regs->pc+8));
710 +
711 + if (err)
712 + break;
713 +
714 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
715 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
716 + (br & 0xFFE00000U) == 0xC3E00000U)
717 + {
718 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
719 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
720 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
721 +
722 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
723 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
724 + return 2;
725 + }
726 + } while (0);
727 +
728 + do { /* PaX: unpatched PLT emulation */
729 + unsigned int br;
730 +
731 + err = get_user(br, (unsigned int *)regs->pc);
732 +
733 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
734 + unsigned int br2, ldq, nop, jmp;
735 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
736 +
737 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
738 + err = get_user(br2, (unsigned int *)addr);
739 + err |= get_user(ldq, (unsigned int *)(addr+4));
740 + err |= get_user(nop, (unsigned int *)(addr+8));
741 + err |= get_user(jmp, (unsigned int *)(addr+12));
742 + err |= get_user(resolver, (unsigned long *)(addr+16));
743 +
744 + if (err)
745 + break;
746 +
747 + if (br2 == 0xC3600000U &&
748 + ldq == 0xA77B000CU &&
749 + nop == 0x47FF041FU &&
750 + jmp == 0x6B7B0000U)
751 + {
752 + regs->r28 = regs->pc+4;
753 + regs->r27 = addr+16;
754 + regs->pc = resolver;
755 + return 3;
756 + }
757 + }
758 + } while (0);
759 +#endif
760 +
761 + return 1;
762 +}
763 +
764 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
765 +{
766 + unsigned long i;
767 +
768 + printk(KERN_ERR "PAX: bytes at PC: ");
769 + for (i = 0; i < 5; i++) {
770 + unsigned int c;
771 + if (get_user(c, (unsigned int *)pc+i))
772 + printk(KERN_CONT "???????? ");
773 + else
774 + printk(KERN_CONT "%08x ", c);
775 + }
776 + printk("\n");
777 +}
778 +#endif
779
780 /*
781 * This routine handles page faults. It determines the address,
782 @@ -133,8 +251,29 @@ retry:
783 good_area:
784 si_code = SEGV_ACCERR;
785 if (cause < 0) {
786 - if (!(vma->vm_flags & VM_EXEC))
787 + if (!(vma->vm_flags & VM_EXEC)) {
788 +
789 +#ifdef CONFIG_PAX_PAGEEXEC
790 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
791 + goto bad_area;
792 +
793 + up_read(&mm->mmap_sem);
794 + switch (pax_handle_fetch_fault(regs)) {
795 +
796 +#ifdef CONFIG_PAX_EMUPLT
797 + case 2:
798 + case 3:
799 + return;
800 +#endif
801 +
802 + }
803 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
804 + do_group_exit(SIGKILL);
805 +#else
806 goto bad_area;
807 +#endif
808 +
809 + }
810 } else if (!cause) {
811 /* Allow reads even for write-only mappings */
812 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
813 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
814 index 70cd012..71b82cd 100644
815 --- a/arch/arm/Kconfig
816 +++ b/arch/arm/Kconfig
817 @@ -1860,7 +1860,7 @@ config ALIGNMENT_TRAP
818
819 config UACCESS_WITH_MEMCPY
820 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
821 - depends on MMU
822 + depends on MMU && !PAX_MEMORY_UDEREF
823 default y if CPU_FEROCEON
824 help
825 Implement faster copy_to_user and clear_user methods for CPU
826 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
827 index c79f61f..9ac0642 100644
828 --- a/arch/arm/include/asm/atomic.h
829 +++ b/arch/arm/include/asm/atomic.h
830 @@ -17,17 +17,35 @@
831 #include <asm/barrier.h>
832 #include <asm/cmpxchg.h>
833
834 +#ifdef CONFIG_GENERIC_ATOMIC64
835 +#include <asm-generic/atomic64.h>
836 +#endif
837 +
838 #define ATOMIC_INIT(i) { (i) }
839
840 #ifdef __KERNEL__
841
842 +#define _ASM_EXTABLE(from, to) \
843 +" .pushsection __ex_table,\"a\"\n"\
844 +" .align 3\n" \
845 +" .long " #from ", " #to"\n" \
846 +" .popsection"
847 +
848 /*
849 * On ARM, ordinary assignment (str instruction) doesn't clear the local
850 * strex/ldrex monitor on some implementations. The reason we can use it for
851 * atomic_set() is the clrex or dummy strex done on every exception return.
852 */
853 #define atomic_read(v) (*(volatile int *)&(v)->counter)
854 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
855 +{
856 + return v->counter;
857 +}
858 #define atomic_set(v,i) (((v)->counter) = (i))
859 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
860 +{
861 + v->counter = i;
862 +}
863
864 #if __LINUX_ARM_ARCH__ >= 6
865
866 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
867 int result;
868
869 __asm__ __volatile__("@ atomic_add\n"
870 +"1: ldrex %1, [%3]\n"
871 +" adds %0, %1, %4\n"
872 +
873 +#ifdef CONFIG_PAX_REFCOUNT
874 +" bvc 3f\n"
875 +"2: bkpt 0xf103\n"
876 +"3:\n"
877 +#endif
878 +
879 +" strex %1, %0, [%3]\n"
880 +" teq %1, #0\n"
881 +" bne 1b"
882 +
883 +#ifdef CONFIG_PAX_REFCOUNT
884 +"\n4:\n"
885 + _ASM_EXTABLE(2b, 4b)
886 +#endif
887 +
888 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
889 + : "r" (&v->counter), "Ir" (i)
890 + : "cc");
891 +}
892 +
893 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
894 +{
895 + unsigned long tmp;
896 + int result;
897 +
898 + __asm__ __volatile__("@ atomic_add_unchecked\n"
899 "1: ldrex %0, [%3]\n"
900 " add %0, %0, %4\n"
901 " strex %1, %0, [%3]\n"
902 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
903 smp_mb();
904
905 __asm__ __volatile__("@ atomic_add_return\n"
906 +"1: ldrex %1, [%3]\n"
907 +" adds %0, %1, %4\n"
908 +
909 +#ifdef CONFIG_PAX_REFCOUNT
910 +" bvc 3f\n"
911 +" mov %0, %1\n"
912 +"2: bkpt 0xf103\n"
913 +"3:\n"
914 +#endif
915 +
916 +" strex %1, %0, [%3]\n"
917 +" teq %1, #0\n"
918 +" bne 1b"
919 +
920 +#ifdef CONFIG_PAX_REFCOUNT
921 +"\n4:\n"
922 + _ASM_EXTABLE(2b, 4b)
923 +#endif
924 +
925 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
926 + : "r" (&v->counter), "Ir" (i)
927 + : "cc");
928 +
929 + smp_mb();
930 +
931 + return result;
932 +}
933 +
934 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
935 +{
936 + unsigned long tmp;
937 + int result;
938 +
939 + smp_mb();
940 +
941 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
942 "1: ldrex %0, [%3]\n"
943 " add %0, %0, %4\n"
944 " strex %1, %0, [%3]\n"
945 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
946 int result;
947
948 __asm__ __volatile__("@ atomic_sub\n"
949 +"1: ldrex %1, [%3]\n"
950 +" subs %0, %1, %4\n"
951 +
952 +#ifdef CONFIG_PAX_REFCOUNT
953 +" bvc 3f\n"
954 +"2: bkpt 0xf103\n"
955 +"3:\n"
956 +#endif
957 +
958 +" strex %1, %0, [%3]\n"
959 +" teq %1, #0\n"
960 +" bne 1b"
961 +
962 +#ifdef CONFIG_PAX_REFCOUNT
963 +"\n4:\n"
964 + _ASM_EXTABLE(2b, 4b)
965 +#endif
966 +
967 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
968 + : "r" (&v->counter), "Ir" (i)
969 + : "cc");
970 +}
971 +
972 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
973 +{
974 + unsigned long tmp;
975 + int result;
976 +
977 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
978 "1: ldrex %0, [%3]\n"
979 " sub %0, %0, %4\n"
980 " strex %1, %0, [%3]\n"
981 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
982 smp_mb();
983
984 __asm__ __volatile__("@ atomic_sub_return\n"
985 -"1: ldrex %0, [%3]\n"
986 -" sub %0, %0, %4\n"
987 +"1: ldrex %1, [%3]\n"
988 +" subs %0, %1, %4\n"
989 +
990 +#ifdef CONFIG_PAX_REFCOUNT
991 +" bvc 3f\n"
992 +" mov %0, %1\n"
993 +"2: bkpt 0xf103\n"
994 +"3:\n"
995 +#endif
996 +
997 " strex %1, %0, [%3]\n"
998 " teq %1, #0\n"
999 " bne 1b"
1000 +
1001 +#ifdef CONFIG_PAX_REFCOUNT
1002 +"\n4:\n"
1003 + _ASM_EXTABLE(2b, 4b)
1004 +#endif
1005 +
1006 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1007 : "r" (&v->counter), "Ir" (i)
1008 : "cc");
1009 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1010 return oldval;
1011 }
1012
1013 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1014 +{
1015 + unsigned long oldval, res;
1016 +
1017 + smp_mb();
1018 +
1019 + do {
1020 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1021 + "ldrex %1, [%3]\n"
1022 + "mov %0, #0\n"
1023 + "teq %1, %4\n"
1024 + "strexeq %0, %5, [%3]\n"
1025 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1026 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1027 + : "cc");
1028 + } while (res);
1029 +
1030 + smp_mb();
1031 +
1032 + return oldval;
1033 +}
1034 +
1035 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1036 {
1037 unsigned long tmp, tmp2;
1038 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1039
1040 return val;
1041 }
1042 +
1043 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1044 +{
1045 + return atomic_add_return(i, v);
1046 +}
1047 +
1048 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1049 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1050 +{
1051 + (void) atomic_add_return(i, v);
1052 +}
1053
1054 static inline int atomic_sub_return(int i, atomic_t *v)
1055 {
1056 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1057 return val;
1058 }
1059 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1060 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1061 +{
1062 + (void) atomic_sub_return(i, v);
1063 +}
1064
1065 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1066 {
1067 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1068 return ret;
1069 }
1070
1071 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1072 +{
1073 + return atomic_cmpxchg(v, old, new);
1074 +}
1075 +
1076 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1077 {
1078 unsigned long flags;
1079 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1080 #endif /* __LINUX_ARM_ARCH__ */
1081
1082 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1083 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1084 +{
1085 + return xchg(&v->counter, new);
1086 +}
1087
1088 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1089 {
1090 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1091 }
1092
1093 #define atomic_inc(v) atomic_add(1, v)
1094 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1095 +{
1096 + atomic_add_unchecked(1, v);
1097 +}
1098 #define atomic_dec(v) atomic_sub(1, v)
1099 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1100 +{
1101 + atomic_sub_unchecked(1, v);
1102 +}
1103
1104 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1105 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1106 +{
1107 + return atomic_add_return_unchecked(1, v) == 0;
1108 +}
1109 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1110 #define atomic_inc_return(v) (atomic_add_return(1, v))
1111 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1112 +{
1113 + return atomic_add_return_unchecked(1, v);
1114 +}
1115 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1116 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1117
1118 @@ -241,6 +428,14 @@ typedef struct {
1119 u64 __aligned(8) counter;
1120 } atomic64_t;
1121
1122 +#ifdef CONFIG_PAX_REFCOUNT
1123 +typedef struct {
1124 + u64 __aligned(8) counter;
1125 +} atomic64_unchecked_t;
1126 +#else
1127 +typedef atomic64_t atomic64_unchecked_t;
1128 +#endif
1129 +
1130 #define ATOMIC64_INIT(i) { (i) }
1131
1132 static inline u64 atomic64_read(const atomic64_t *v)
1133 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1134 return result;
1135 }
1136
1137 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1138 +{
1139 + u64 result;
1140 +
1141 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1142 +" ldrexd %0, %H0, [%1]"
1143 + : "=&r" (result)
1144 + : "r" (&v->counter), "Qo" (v->counter)
1145 + );
1146 +
1147 + return result;
1148 +}
1149 +
1150 static inline void atomic64_set(atomic64_t *v, u64 i)
1151 {
1152 u64 tmp;
1153 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1154 : "cc");
1155 }
1156
1157 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1158 +{
1159 + u64 tmp;
1160 +
1161 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1162 +"1: ldrexd %0, %H0, [%2]\n"
1163 +" strexd %0, %3, %H3, [%2]\n"
1164 +" teq %0, #0\n"
1165 +" bne 1b"
1166 + : "=&r" (tmp), "=Qo" (v->counter)
1167 + : "r" (&v->counter), "r" (i)
1168 + : "cc");
1169 +}
1170 +
1171 static inline void atomic64_add(u64 i, atomic64_t *v)
1172 {
1173 u64 result;
1174 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1175 __asm__ __volatile__("@ atomic64_add\n"
1176 "1: ldrexd %0, %H0, [%3]\n"
1177 " adds %0, %0, %4\n"
1178 +" adcs %H0, %H0, %H4\n"
1179 +
1180 +#ifdef CONFIG_PAX_REFCOUNT
1181 +" bvc 3f\n"
1182 +"2: bkpt 0xf103\n"
1183 +"3:\n"
1184 +#endif
1185 +
1186 +" strexd %1, %0, %H0, [%3]\n"
1187 +" teq %1, #0\n"
1188 +" bne 1b"
1189 +
1190 +#ifdef CONFIG_PAX_REFCOUNT
1191 +"\n4:\n"
1192 + _ASM_EXTABLE(2b, 4b)
1193 +#endif
1194 +
1195 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1196 + : "r" (&v->counter), "r" (i)
1197 + : "cc");
1198 +}
1199 +
1200 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1201 +{
1202 + u64 result;
1203 + unsigned long tmp;
1204 +
1205 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1206 +"1: ldrexd %0, %H0, [%3]\n"
1207 +" adds %0, %0, %4\n"
1208 " adc %H0, %H0, %H4\n"
1209 " strexd %1, %0, %H0, [%3]\n"
1210 " teq %1, #0\n"
1211 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1212
1213 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1214 {
1215 - u64 result;
1216 - unsigned long tmp;
1217 + u64 result, tmp;
1218
1219 smp_mb();
1220
1221 __asm__ __volatile__("@ atomic64_add_return\n"
1222 +"1: ldrexd %1, %H1, [%3]\n"
1223 +" adds %0, %1, %4\n"
1224 +" adcs %H0, %H1, %H4\n"
1225 +
1226 +#ifdef CONFIG_PAX_REFCOUNT
1227 +" bvc 3f\n"
1228 +" mov %0, %1\n"
1229 +" mov %H0, %H1\n"
1230 +"2: bkpt 0xf103\n"
1231 +"3:\n"
1232 +#endif
1233 +
1234 +" strexd %1, %0, %H0, [%3]\n"
1235 +" teq %1, #0\n"
1236 +" bne 1b"
1237 +
1238 +#ifdef CONFIG_PAX_REFCOUNT
1239 +"\n4:\n"
1240 + _ASM_EXTABLE(2b, 4b)
1241 +#endif
1242 +
1243 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1244 + : "r" (&v->counter), "r" (i)
1245 + : "cc");
1246 +
1247 + smp_mb();
1248 +
1249 + return result;
1250 +}
1251 +
1252 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1253 +{
1254 + u64 result;
1255 + unsigned long tmp;
1256 +
1257 + smp_mb();
1258 +
1259 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1260 "1: ldrexd %0, %H0, [%3]\n"
1261 " adds %0, %0, %4\n"
1262 " adc %H0, %H0, %H4\n"
1263 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1264 __asm__ __volatile__("@ atomic64_sub\n"
1265 "1: ldrexd %0, %H0, [%3]\n"
1266 " subs %0, %0, %4\n"
1267 +" sbcs %H0, %H0, %H4\n"
1268 +
1269 +#ifdef CONFIG_PAX_REFCOUNT
1270 +" bvc 3f\n"
1271 +"2: bkpt 0xf103\n"
1272 +"3:\n"
1273 +#endif
1274 +
1275 +" strexd %1, %0, %H0, [%3]\n"
1276 +" teq %1, #0\n"
1277 +" bne 1b"
1278 +
1279 +#ifdef CONFIG_PAX_REFCOUNT
1280 +"\n4:\n"
1281 + _ASM_EXTABLE(2b, 4b)
1282 +#endif
1283 +
1284 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1285 + : "r" (&v->counter), "r" (i)
1286 + : "cc");
1287 +}
1288 +
1289 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1290 +{
1291 + u64 result;
1292 + unsigned long tmp;
1293 +
1294 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1295 +"1: ldrexd %0, %H0, [%3]\n"
1296 +" subs %0, %0, %4\n"
1297 " sbc %H0, %H0, %H4\n"
1298 " strexd %1, %0, %H0, [%3]\n"
1299 " teq %1, #0\n"
1300 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1301
1302 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1303 {
1304 - u64 result;
1305 - unsigned long tmp;
1306 + u64 result, tmp;
1307
1308 smp_mb();
1309
1310 __asm__ __volatile__("@ atomic64_sub_return\n"
1311 -"1: ldrexd %0, %H0, [%3]\n"
1312 -" subs %0, %0, %4\n"
1313 -" sbc %H0, %H0, %H4\n"
1314 +"1: ldrexd %1, %H1, [%3]\n"
1315 +" subs %0, %1, %4\n"
1316 +" sbcs %H0, %H1, %H4\n"
1317 +
1318 +#ifdef CONFIG_PAX_REFCOUNT
1319 +" bvc 3f\n"
1320 +" mov %0, %1\n"
1321 +" mov %H0, %H1\n"
1322 +"2: bkpt 0xf103\n"
1323 +"3:\n"
1324 +#endif
1325 +
1326 " strexd %1, %0, %H0, [%3]\n"
1327 " teq %1, #0\n"
1328 " bne 1b"
1329 +
1330 +#ifdef CONFIG_PAX_REFCOUNT
1331 +"\n4:\n"
1332 + _ASM_EXTABLE(2b, 4b)
1333 +#endif
1334 +
1335 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1336 : "r" (&v->counter), "r" (i)
1337 : "cc");
1338 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1339 return oldval;
1340 }
1341
1342 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1343 +{
1344 + u64 oldval;
1345 + unsigned long res;
1346 +
1347 + smp_mb();
1348 +
1349 + do {
1350 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1351 + "ldrexd %1, %H1, [%3]\n"
1352 + "mov %0, #0\n"
1353 + "teq %1, %4\n"
1354 + "teqeq %H1, %H4\n"
1355 + "strexdeq %0, %5, %H5, [%3]"
1356 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1357 + : "r" (&ptr->counter), "r" (old), "r" (new)
1358 + : "cc");
1359 + } while (res);
1360 +
1361 + smp_mb();
1362 +
1363 + return oldval;
1364 +}
1365 +
1366 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1367 {
1368 u64 result;
1369 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1370
1371 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1372 {
1373 - u64 result;
1374 - unsigned long tmp;
1375 + u64 result, tmp;
1376
1377 smp_mb();
1378
1379 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1380 -"1: ldrexd %0, %H0, [%3]\n"
1381 -" subs %0, %0, #1\n"
1382 -" sbc %H0, %H0, #0\n"
1383 +"1: ldrexd %1, %H1, [%3]\n"
1384 +" subs %0, %1, #1\n"
1385 +" sbcs %H0, %H1, #0\n"
1386 +
1387 +#ifdef CONFIG_PAX_REFCOUNT
1388 +" bvc 3f\n"
1389 +" mov %0, %1\n"
1390 +" mov %H0, %H1\n"
1391 +"2: bkpt 0xf103\n"
1392 +"3:\n"
1393 +#endif
1394 +
1395 " teq %H0, #0\n"
1396 -" bmi 2f\n"
1397 +" bmi 4f\n"
1398 " strexd %1, %0, %H0, [%3]\n"
1399 " teq %1, #0\n"
1400 " bne 1b\n"
1401 -"2:"
1402 +"4:\n"
1403 +
1404 +#ifdef CONFIG_PAX_REFCOUNT
1405 + _ASM_EXTABLE(2b, 4b)
1406 +#endif
1407 +
1408 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1409 : "r" (&v->counter)
1410 : "cc");
1411 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1412 " teq %0, %5\n"
1413 " teqeq %H0, %H5\n"
1414 " moveq %1, #0\n"
1415 -" beq 2f\n"
1416 +" beq 4f\n"
1417 " adds %0, %0, %6\n"
1418 -" adc %H0, %H0, %H6\n"
1419 +" adcs %H0, %H0, %H6\n"
1420 +
1421 +#ifdef CONFIG_PAX_REFCOUNT
1422 +" bvc 3f\n"
1423 +"2: bkpt 0xf103\n"
1424 +"3:\n"
1425 +#endif
1426 +
1427 " strexd %2, %0, %H0, [%4]\n"
1428 " teq %2, #0\n"
1429 " bne 1b\n"
1430 -"2:"
1431 +"4:\n"
1432 +
1433 +#ifdef CONFIG_PAX_REFCOUNT
1434 + _ASM_EXTABLE(2b, 4b)
1435 +#endif
1436 +
1437 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1438 : "r" (&v->counter), "r" (u), "r" (a)
1439 : "cc");
1440 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1441
1442 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1443 #define atomic64_inc(v) atomic64_add(1LL, (v))
1444 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1445 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1446 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1447 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1448 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1449 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1450 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1451 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1452 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1453 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1454 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1455 index 75fe66b..ba3dee4 100644
1456 --- a/arch/arm/include/asm/cache.h
1457 +++ b/arch/arm/include/asm/cache.h
1458 @@ -4,8 +4,10 @@
1459 #ifndef __ASMARM_CACHE_H
1460 #define __ASMARM_CACHE_H
1461
1462 +#include <linux/const.h>
1463 +
1464 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1465 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1466 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1467
1468 /*
1469 * Memory returned by kmalloc() may be used for DMA, so we must make
1470 @@ -24,5 +26,6 @@
1471 #endif
1472
1473 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1474 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1475
1476 #endif
1477 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1478 index e1489c5..d418304 100644
1479 --- a/arch/arm/include/asm/cacheflush.h
1480 +++ b/arch/arm/include/asm/cacheflush.h
1481 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1482 void (*dma_unmap_area)(const void *, size_t, int);
1483
1484 void (*dma_flush_range)(const void *, const void *);
1485 -};
1486 +} __no_const;
1487
1488 /*
1489 * Select the calling method
1490 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1491 index 6dcc164..b14d917 100644
1492 --- a/arch/arm/include/asm/checksum.h
1493 +++ b/arch/arm/include/asm/checksum.h
1494 @@ -37,7 +37,19 @@ __wsum
1495 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1496
1497 __wsum
1498 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1499 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1500 +
1501 +static inline __wsum
1502 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1503 +{
1504 + __wsum ret;
1505 + pax_open_userland();
1506 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1507 + pax_close_userland();
1508 + return ret;
1509 +}
1510 +
1511 +
1512
1513 /*
1514 * Fold a partial checksum without adding pseudo headers
1515 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1516 index 4f009c1..466c59b 100644
1517 --- a/arch/arm/include/asm/cmpxchg.h
1518 +++ b/arch/arm/include/asm/cmpxchg.h
1519 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1520
1521 #define xchg(ptr,x) \
1522 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1523 +#define xchg_unchecked(ptr,x) \
1524 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1525
1526 #include <asm-generic/cmpxchg-local.h>
1527
1528 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1529 index 6ddbe44..b5e38b1 100644
1530 --- a/arch/arm/include/asm/domain.h
1531 +++ b/arch/arm/include/asm/domain.h
1532 @@ -48,18 +48,37 @@
1533 * Domain types
1534 */
1535 #define DOMAIN_NOACCESS 0
1536 -#define DOMAIN_CLIENT 1
1537 #ifdef CONFIG_CPU_USE_DOMAINS
1538 +#define DOMAIN_USERCLIENT 1
1539 +#define DOMAIN_KERNELCLIENT 1
1540 #define DOMAIN_MANAGER 3
1541 +#define DOMAIN_VECTORS DOMAIN_USER
1542 #else
1543 +
1544 +#ifdef CONFIG_PAX_KERNEXEC
1545 #define DOMAIN_MANAGER 1
1546 +#define DOMAIN_KERNEXEC 3
1547 +#else
1548 +#define DOMAIN_MANAGER 1
1549 +#endif
1550 +
1551 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1552 +#define DOMAIN_USERCLIENT 0
1553 +#define DOMAIN_UDEREF 1
1554 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1555 +#else
1556 +#define DOMAIN_USERCLIENT 1
1557 +#define DOMAIN_VECTORS DOMAIN_USER
1558 +#endif
1559 +#define DOMAIN_KERNELCLIENT 1
1560 +
1561 #endif
1562
1563 #define domain_val(dom,type) ((type) << (2*(dom)))
1564
1565 #ifndef __ASSEMBLY__
1566
1567 -#ifdef CONFIG_CPU_USE_DOMAINS
1568 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1569 static inline void set_domain(unsigned val)
1570 {
1571 asm volatile(
1572 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1573 isb();
1574 }
1575
1576 -#define modify_domain(dom,type) \
1577 - do { \
1578 - struct thread_info *thread = current_thread_info(); \
1579 - unsigned int domain = thread->cpu_domain; \
1580 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1581 - thread->cpu_domain = domain | domain_val(dom, type); \
1582 - set_domain(thread->cpu_domain); \
1583 - } while (0)
1584 -
1585 +extern void modify_domain(unsigned int dom, unsigned int type);
1586 #else
1587 static inline void set_domain(unsigned val) { }
1588 static inline void modify_domain(unsigned dom, unsigned type) { }
1589 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1590 index 38050b1..9d90e8b 100644
1591 --- a/arch/arm/include/asm/elf.h
1592 +++ b/arch/arm/include/asm/elf.h
1593 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1594 the loader. We need to make sure that it is out of the way of the program
1595 that it will "exec", and that there is sufficient room for the brk. */
1596
1597 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1598 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1599 +
1600 +#ifdef CONFIG_PAX_ASLR
1601 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1602 +
1603 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1604 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1605 +#endif
1606
1607 /* When the program starts, a1 contains a pointer to a function to be
1608 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1609 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1610 extern void elf_set_personality(const struct elf32_hdr *);
1611 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1612
1613 -struct mm_struct;
1614 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1615 -#define arch_randomize_brk arch_randomize_brk
1616 -
1617 #endif
1618 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1619 index de53547..52b9a28 100644
1620 --- a/arch/arm/include/asm/fncpy.h
1621 +++ b/arch/arm/include/asm/fncpy.h
1622 @@ -81,7 +81,9 @@
1623 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1624 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1625 \
1626 + pax_open_kernel(); \
1627 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1628 + pax_close_kernel(); \
1629 flush_icache_range((unsigned long)(dest_buf), \
1630 (unsigned long)(dest_buf) + (size)); \
1631 \
1632 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1633 index e42cf59..7b94b8f 100644
1634 --- a/arch/arm/include/asm/futex.h
1635 +++ b/arch/arm/include/asm/futex.h
1636 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1637 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1638 return -EFAULT;
1639
1640 + pax_open_userland();
1641 +
1642 smp_mb();
1643 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1644 "1: ldrex %1, [%4]\n"
1645 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1646 : "cc", "memory");
1647 smp_mb();
1648
1649 + pax_close_userland();
1650 +
1651 *uval = val;
1652 return ret;
1653 }
1654 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1655 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1656 return -EFAULT;
1657
1658 + pax_open_userland();
1659 +
1660 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1661 "1: " TUSER(ldr) " %1, [%4]\n"
1662 " teq %1, %2\n"
1663 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1664 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1665 : "cc", "memory");
1666
1667 + pax_close_userland();
1668 +
1669 *uval = val;
1670 return ret;
1671 }
1672 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1673 return -EFAULT;
1674
1675 pagefault_disable(); /* implies preempt_disable() */
1676 + pax_open_userland();
1677
1678 switch (op) {
1679 case FUTEX_OP_SET:
1680 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1681 ret = -ENOSYS;
1682 }
1683
1684 + pax_close_userland();
1685 pagefault_enable(); /* subsumes preempt_enable() */
1686
1687 if (!ret) {
1688 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1689 index 83eb2f7..ed77159 100644
1690 --- a/arch/arm/include/asm/kmap_types.h
1691 +++ b/arch/arm/include/asm/kmap_types.h
1692 @@ -4,6 +4,6 @@
1693 /*
1694 * This is the "bare minimum". AIO seems to require this.
1695 */
1696 -#define KM_TYPE_NR 16
1697 +#define KM_TYPE_NR 17
1698
1699 #endif
1700 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1701 index 9e614a1..3302cca 100644
1702 --- a/arch/arm/include/asm/mach/dma.h
1703 +++ b/arch/arm/include/asm/mach/dma.h
1704 @@ -22,7 +22,7 @@ struct dma_ops {
1705 int (*residue)(unsigned int, dma_t *); /* optional */
1706 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1707 const char *type;
1708 -};
1709 +} __do_const;
1710
1711 struct dma_struct {
1712 void *addr; /* single DMA address */
1713 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1714 index 2fe141f..192dc01 100644
1715 --- a/arch/arm/include/asm/mach/map.h
1716 +++ b/arch/arm/include/asm/mach/map.h
1717 @@ -27,13 +27,16 @@ struct map_desc {
1718 #define MT_MINICLEAN 6
1719 #define MT_LOW_VECTORS 7
1720 #define MT_HIGH_VECTORS 8
1721 -#define MT_MEMORY 9
1722 +#define MT_MEMORY_RWX 9
1723 #define MT_ROM 10
1724 -#define MT_MEMORY_NONCACHED 11
1725 +#define MT_MEMORY_NONCACHED_RX 11
1726 #define MT_MEMORY_DTCM 12
1727 #define MT_MEMORY_ITCM 13
1728 #define MT_MEMORY_SO 14
1729 #define MT_MEMORY_DMA_READY 15
1730 +#define MT_MEMORY_RW 16
1731 +#define MT_MEMORY_RX 17
1732 +#define MT_MEMORY_NONCACHED_RW 18
1733
1734 #ifdef CONFIG_MMU
1735 extern void iotable_init(struct map_desc *, int);
1736 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1737 index 12f71a1..04e063c 100644
1738 --- a/arch/arm/include/asm/outercache.h
1739 +++ b/arch/arm/include/asm/outercache.h
1740 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1741 #endif
1742 void (*set_debug)(unsigned long);
1743 void (*resume)(void);
1744 -};
1745 +} __no_const;
1746
1747 #ifdef CONFIG_OUTER_CACHE
1748
1749 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1750 index 812a494..71fc0b6 100644
1751 --- a/arch/arm/include/asm/page.h
1752 +++ b/arch/arm/include/asm/page.h
1753 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1754 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1755 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1756 unsigned long vaddr, struct vm_area_struct *vma);
1757 -};
1758 +} __no_const;
1759
1760 #ifdef MULTI_USER
1761 extern struct cpu_user_fns cpu_user;
1762 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1763 index 943504f..c37a730 100644
1764 --- a/arch/arm/include/asm/pgalloc.h
1765 +++ b/arch/arm/include/asm/pgalloc.h
1766 @@ -17,6 +17,7 @@
1767 #include <asm/processor.h>
1768 #include <asm/cacheflush.h>
1769 #include <asm/tlbflush.h>
1770 +#include <asm/system_info.h>
1771
1772 #define check_pgt_cache() do { } while (0)
1773
1774 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1775 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1776 }
1777
1778 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1779 +{
1780 + pud_populate(mm, pud, pmd);
1781 +}
1782 +
1783 #else /* !CONFIG_ARM_LPAE */
1784
1785 /*
1786 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1787 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1788 #define pmd_free(mm, pmd) do { } while (0)
1789 #define pud_populate(mm,pmd,pte) BUG()
1790 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1791
1792 #endif /* CONFIG_ARM_LPAE */
1793
1794 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1795 __free_page(pte);
1796 }
1797
1798 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1799 +{
1800 +#ifdef CONFIG_ARM_LPAE
1801 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1802 +#else
1803 + if (addr & SECTION_SIZE)
1804 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1805 + else
1806 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1807 +#endif
1808 + flush_pmd_entry(pmdp);
1809 +}
1810 +
1811 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1812 pmdval_t prot)
1813 {
1814 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1815 static inline void
1816 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1817 {
1818 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1819 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1820 }
1821 #define pmd_pgtable(pmd) pmd_page(pmd)
1822
1823 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1824 index 5cfba15..f415e1a 100644
1825 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1826 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1827 @@ -20,12 +20,15 @@
1828 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1829 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1830 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1831 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1832 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1833 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1834 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1835 +
1836 /*
1837 * - section
1838 */
1839 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1840 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1841 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1842 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1843 @@ -37,6 +40,7 @@
1844 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1845 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1846 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1847 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1848
1849 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1850 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1851 @@ -66,6 +70,7 @@
1852 * - extended small page/tiny page
1853 */
1854 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1855 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1856 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1857 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1858 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1859 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1860 index f97ee02..07f1be5 100644
1861 --- a/arch/arm/include/asm/pgtable-2level.h
1862 +++ b/arch/arm/include/asm/pgtable-2level.h
1863 @@ -125,6 +125,7 @@
1864 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1865 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1866 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1867 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1868
1869 /*
1870 * These are the memory types, defined to be compatible with
1871 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1872 index 18f5cef..25b8f43 100644
1873 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1874 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1875 @@ -41,6 +41,7 @@
1876 */
1877 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1878 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1879 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1880 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1881 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1882 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1883 @@ -71,6 +72,7 @@
1884 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1885 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1886 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1887 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1888 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1889
1890 /*
1891 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1892 index 86b8fe3..e25f975 100644
1893 --- a/arch/arm/include/asm/pgtable-3level.h
1894 +++ b/arch/arm/include/asm/pgtable-3level.h
1895 @@ -74,6 +74,7 @@
1896 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1897 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1898 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1899 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1900 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1901 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1902 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1903 @@ -82,6 +83,7 @@
1904 /*
1905 * To be used in assembly code with the upper page attributes.
1906 */
1907 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1908 #define L_PTE_XN_HIGH (1 << (54 - 32))
1909 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1910
1911 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1912 index 9bcd262..fba731c 100644
1913 --- a/arch/arm/include/asm/pgtable.h
1914 +++ b/arch/arm/include/asm/pgtable.h
1915 @@ -30,6 +30,9 @@
1916 #include <asm/pgtable-2level.h>
1917 #endif
1918
1919 +#define ktla_ktva(addr) (addr)
1920 +#define ktva_ktla(addr) (addr)
1921 +
1922 /*
1923 * Just any arbitrary offset to the start of the vmalloc VM area: the
1924 * current 8MB value just means that there will be a 8MB "hole" after the
1925 @@ -45,6 +48,9 @@
1926 #define LIBRARY_TEXT_START 0x0c000000
1927
1928 #ifndef __ASSEMBLY__
1929 +extern pteval_t __supported_pte_mask;
1930 +extern pmdval_t __supported_pmd_mask;
1931 +
1932 extern void __pte_error(const char *file, int line, pte_t);
1933 extern void __pmd_error(const char *file, int line, pmd_t);
1934 extern void __pgd_error(const char *file, int line, pgd_t);
1935 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1936 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1937 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1938
1939 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1940 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1941 +
1942 +#ifdef CONFIG_PAX_KERNEXEC
1943 +#include <asm/domain.h>
1944 +#include <linux/thread_info.h>
1945 +#include <linux/preempt.h>
1946 +#endif
1947 +
1948 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1949 +static inline int test_domain(int domain, int domaintype)
1950 +{
1951 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
1952 +}
1953 +#endif
1954 +
1955 +#ifdef CONFIG_PAX_KERNEXEC
1956 +static inline unsigned long pax_open_kernel(void) {
1957 +#ifdef CONFIG_ARM_LPAE
1958 + /* TODO */
1959 +#else
1960 + preempt_disable();
1961 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
1962 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
1963 +#endif
1964 + return 0;
1965 +}
1966 +
1967 +static inline unsigned long pax_close_kernel(void) {
1968 +#ifdef CONFIG_ARM_LPAE
1969 + /* TODO */
1970 +#else
1971 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
1972 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
1973 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
1974 + preempt_enable_no_resched();
1975 +#endif
1976 + return 0;
1977 +}
1978 +#else
1979 +static inline unsigned long pax_open_kernel(void) { return 0; }
1980 +static inline unsigned long pax_close_kernel(void) { return 0; }
1981 +#endif
1982 +
1983 /*
1984 * This is the lowest virtual address we can permit any user space
1985 * mapping to be mapped at. This is particularly important for
1986 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1987 /*
1988 * The pgprot_* and protection_map entries will be fixed up in runtime
1989 * to include the cachable and bufferable bits based on memory policy,
1990 - * as well as any architecture dependent bits like global/ASID and SMP
1991 - * shared mapping bits.
1992 + * as well as any architecture dependent bits like global/ASID, PXN,
1993 + * and SMP shared mapping bits.
1994 */
1995 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
1996
1997 @@ -257,7 +307,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
1998 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
1999 {
2000 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2001 - L_PTE_NONE | L_PTE_VALID;
2002 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2003 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2004 return pte;
2005 }
2006 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2007 index f3628fb..a0672dd 100644
2008 --- a/arch/arm/include/asm/proc-fns.h
2009 +++ b/arch/arm/include/asm/proc-fns.h
2010 @@ -75,7 +75,7 @@ extern struct processor {
2011 unsigned int suspend_size;
2012 void (*do_suspend)(void *);
2013 void (*do_resume)(void *);
2014 -} processor;
2015 +} __do_const processor;
2016
2017 #ifndef MULTI_CPU
2018 extern void cpu_proc_init(void);
2019 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2020 index 06e7d50..8a8e251 100644
2021 --- a/arch/arm/include/asm/processor.h
2022 +++ b/arch/arm/include/asm/processor.h
2023 @@ -65,9 +65,8 @@ struct thread_struct {
2024 regs->ARM_cpsr |= PSR_ENDSTATE; \
2025 regs->ARM_pc = pc & ~1; /* pc */ \
2026 regs->ARM_sp = sp; /* sp */ \
2027 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2028 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2029 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2030 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2031 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2032 nommu_start_thread(regs); \
2033 })
2034
2035 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2036 index ce0dbe7..c085b6f 100644
2037 --- a/arch/arm/include/asm/psci.h
2038 +++ b/arch/arm/include/asm/psci.h
2039 @@ -29,7 +29,7 @@ struct psci_operations {
2040 int (*cpu_off)(struct psci_power_state state);
2041 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2042 int (*migrate)(unsigned long cpuid);
2043 -};
2044 +} __no_const;
2045
2046 extern struct psci_operations psci_ops;
2047
2048 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2049 index d3a22be..3a69ad5 100644
2050 --- a/arch/arm/include/asm/smp.h
2051 +++ b/arch/arm/include/asm/smp.h
2052 @@ -107,7 +107,7 @@ struct smp_operations {
2053 int (*cpu_disable)(unsigned int cpu);
2054 #endif
2055 #endif
2056 -};
2057 +} __no_const;
2058
2059 /*
2060 * set platform specific SMP operations
2061 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2062 index cddda1f..ff357f7 100644
2063 --- a/arch/arm/include/asm/thread_info.h
2064 +++ b/arch/arm/include/asm/thread_info.h
2065 @@ -77,9 +77,9 @@ struct thread_info {
2066 .flags = 0, \
2067 .preempt_count = INIT_PREEMPT_COUNT, \
2068 .addr_limit = KERNEL_DS, \
2069 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2070 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2071 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2072 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2073 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2074 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2075 .restart_block = { \
2076 .fn = do_no_restart_syscall, \
2077 }, \
2078 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2079 #define TIF_SYSCALL_AUDIT 9
2080 #define TIF_SYSCALL_TRACEPOINT 10
2081 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2082 +
2083 +/* within 8 bits of TIF_SYSCALL_TRACE
2084 + * to meet flexible second operand requirements
2085 + */
2086 +#define TIF_GRSEC_SETXID 12
2087 +
2088 #define TIF_USING_IWMMXT 17
2089 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2090 #define TIF_RESTORE_SIGMASK 20
2091 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2092 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2093 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2094 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2095 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2096
2097 /* Checks for any syscall work in entry-common.S */
2098 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2099 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2100 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2101
2102 /*
2103 * Change these and you break ASM code in entry-common.S
2104 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2105 index 7e1f760..752fcb7 100644
2106 --- a/arch/arm/include/asm/uaccess.h
2107 +++ b/arch/arm/include/asm/uaccess.h
2108 @@ -18,6 +18,7 @@
2109 #include <asm/domain.h>
2110 #include <asm/unified.h>
2111 #include <asm/compiler.h>
2112 +#include <asm/pgtable.h>
2113
2114 #define VERIFY_READ 0
2115 #define VERIFY_WRITE 1
2116 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2117 #define USER_DS TASK_SIZE
2118 #define get_fs() (current_thread_info()->addr_limit)
2119
2120 +static inline void pax_open_userland(void)
2121 +{
2122 +
2123 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2124 + if (get_fs() == USER_DS) {
2125 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2126 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2127 + }
2128 +#endif
2129 +
2130 +}
2131 +
2132 +static inline void pax_close_userland(void)
2133 +{
2134 +
2135 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2136 + if (get_fs() == USER_DS) {
2137 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2138 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2139 + }
2140 +#endif
2141 +
2142 +}
2143 +
2144 static inline void set_fs(mm_segment_t fs)
2145 {
2146 current_thread_info()->addr_limit = fs;
2147 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2148 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2149 }
2150
2151 #define segment_eq(a,b) ((a) == (b))
2152 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2153
2154 #define get_user(x,p) \
2155 ({ \
2156 + int __e; \
2157 might_fault(); \
2158 - __get_user_check(x,p); \
2159 + pax_open_userland(); \
2160 + __e = __get_user_check(x,p); \
2161 + pax_close_userland(); \
2162 + __e; \
2163 })
2164
2165 extern int __put_user_1(void *, unsigned int);
2166 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2167
2168 #define put_user(x,p) \
2169 ({ \
2170 + int __e; \
2171 might_fault(); \
2172 - __put_user_check(x,p); \
2173 + pax_open_userland(); \
2174 + __e = __put_user_check(x,p); \
2175 + pax_close_userland(); \
2176 + __e; \
2177 })
2178
2179 #else /* CONFIG_MMU */
2180 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2181 #define __get_user(x,ptr) \
2182 ({ \
2183 long __gu_err = 0; \
2184 + pax_open_userland(); \
2185 __get_user_err((x),(ptr),__gu_err); \
2186 + pax_close_userland(); \
2187 __gu_err; \
2188 })
2189
2190 #define __get_user_error(x,ptr,err) \
2191 ({ \
2192 + pax_open_userland(); \
2193 __get_user_err((x),(ptr),err); \
2194 + pax_close_userland(); \
2195 (void) 0; \
2196 })
2197
2198 @@ -312,13 +349,17 @@ do { \
2199 #define __put_user(x,ptr) \
2200 ({ \
2201 long __pu_err = 0; \
2202 + pax_open_userland(); \
2203 __put_user_err((x),(ptr),__pu_err); \
2204 + pax_close_userland(); \
2205 __pu_err; \
2206 })
2207
2208 #define __put_user_error(x,ptr,err) \
2209 ({ \
2210 + pax_open_userland(); \
2211 __put_user_err((x),(ptr),err); \
2212 + pax_close_userland(); \
2213 (void) 0; \
2214 })
2215
2216 @@ -418,11 +459,44 @@ do { \
2217
2218
2219 #ifdef CONFIG_MMU
2220 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2221 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2222 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2223 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2224 +
2225 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2226 +{
2227 + unsigned long ret;
2228 +
2229 + check_object_size(to, n, false);
2230 + pax_open_userland();
2231 + ret = ___copy_from_user(to, from, n);
2232 + pax_close_userland();
2233 + return ret;
2234 +}
2235 +
2236 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2237 +{
2238 + unsigned long ret;
2239 +
2240 + check_object_size(from, n, true);
2241 + pax_open_userland();
2242 + ret = ___copy_to_user(to, from, n);
2243 + pax_close_userland();
2244 + return ret;
2245 +}
2246 +
2247 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2248 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2249 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2250 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2251 +
2252 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2253 +{
2254 + unsigned long ret;
2255 + pax_open_userland();
2256 + ret = ___clear_user(addr, n);
2257 + pax_close_userland();
2258 + return ret;
2259 +}
2260 +
2261 #else
2262 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2263 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2264 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2265
2266 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2267 {
2268 + if ((long)n < 0)
2269 + return n;
2270 +
2271 if (access_ok(VERIFY_READ, from, n))
2272 n = __copy_from_user(to, from, n);
2273 else /* security hole - plug it */
2274 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2275
2276 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2277 {
2278 + if ((long)n < 0)
2279 + return n;
2280 +
2281 if (access_ok(VERIFY_WRITE, to, n))
2282 n = __copy_to_user(to, from, n);
2283 return n;
2284 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2285 index 96ee092..37f1844 100644
2286 --- a/arch/arm/include/uapi/asm/ptrace.h
2287 +++ b/arch/arm/include/uapi/asm/ptrace.h
2288 @@ -73,7 +73,7 @@
2289 * ARMv7 groups of PSR bits
2290 */
2291 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2292 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2293 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2294 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2295 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2296
2297 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2298 index 60d3b73..d27ee09 100644
2299 --- a/arch/arm/kernel/armksyms.c
2300 +++ b/arch/arm/kernel/armksyms.c
2301 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2302 #ifdef CONFIG_MMU
2303 EXPORT_SYMBOL(copy_page);
2304
2305 -EXPORT_SYMBOL(__copy_from_user);
2306 -EXPORT_SYMBOL(__copy_to_user);
2307 -EXPORT_SYMBOL(__clear_user);
2308 +EXPORT_SYMBOL(___copy_from_user);
2309 +EXPORT_SYMBOL(___copy_to_user);
2310 +EXPORT_SYMBOL(___clear_user);
2311
2312 EXPORT_SYMBOL(__get_user_1);
2313 EXPORT_SYMBOL(__get_user_2);
2314 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2315 index 0f82098..3dbd3ee 100644
2316 --- a/arch/arm/kernel/entry-armv.S
2317 +++ b/arch/arm/kernel/entry-armv.S
2318 @@ -47,6 +47,87 @@
2319 9997:
2320 .endm
2321
2322 + .macro pax_enter_kernel
2323 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2324 + @ make aligned space for saved DACR
2325 + sub sp, sp, #8
2326 + @ save regs
2327 + stmdb sp!, {r1, r2}
2328 + @ read DACR from cpu_domain into r1
2329 + mov r2, sp
2330 + @ assume 8K pages, since we have to split the immediate in two
2331 + bic r2, r2, #(0x1fc0)
2332 + bic r2, r2, #(0x3f)
2333 + ldr r1, [r2, #TI_CPU_DOMAIN]
2334 + @ store old DACR on stack
2335 + str r1, [sp, #8]
2336 +#ifdef CONFIG_PAX_KERNEXEC
2337 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2338 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2339 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2340 +#endif
2341 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2342 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2343 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2344 +#endif
2345 + @ write r1 to current_thread_info()->cpu_domain
2346 + str r1, [r2, #TI_CPU_DOMAIN]
2347 + @ write r1 to DACR
2348 + mcr p15, 0, r1, c3, c0, 0
2349 + @ instruction sync
2350 + instr_sync
2351 + @ restore regs
2352 + ldmia sp!, {r1, r2}
2353 +#endif
2354 + .endm
2355 +
2356 + .macro pax_open_userland
2357 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2358 + @ save regs
2359 + stmdb sp!, {r0, r1}
2360 + @ read DACR from cpu_domain into r1
2361 + mov r0, sp
2362 + @ assume 8K pages, since we have to split the immediate in two
2363 + bic r0, r0, #(0x1fc0)
2364 + bic r0, r0, #(0x3f)
2365 + ldr r1, [r0, #TI_CPU_DOMAIN]
2366 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2367 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2368 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2369 + @ write r1 to current_thread_info()->cpu_domain
2370 + str r1, [r0, #TI_CPU_DOMAIN]
2371 + @ write r1 to DACR
2372 + mcr p15, 0, r1, c3, c0, 0
2373 + @ instruction sync
2374 + instr_sync
2375 + @ restore regs
2376 + ldmia sp!, {r0, r1}
2377 +#endif
2378 + .endm
2379 +
2380 + .macro pax_close_userland
2381 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2382 + @ save regs
2383 + stmdb sp!, {r0, r1}
2384 + @ read DACR from cpu_domain into r1
2385 + mov r0, sp
2386 + @ assume 8K pages, since we have to split the immediate in two
2387 + bic r0, r0, #(0x1fc0)
2388 + bic r0, r0, #(0x3f)
2389 + ldr r1, [r0, #TI_CPU_DOMAIN]
2390 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2391 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2392 + @ write r1 to current_thread_info()->cpu_domain
2393 + str r1, [r0, #TI_CPU_DOMAIN]
2394 + @ write r1 to DACR
2395 + mcr p15, 0, r1, c3, c0, 0
2396 + @ instruction sync
2397 + instr_sync
2398 + @ restore regs
2399 + ldmia sp!, {r0, r1}
2400 +#endif
2401 + .endm
2402 +
2403 .macro pabt_helper
2404 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2405 #ifdef MULTI_PABORT
2406 @@ -89,11 +170,15 @@
2407 * Invalid mode handlers
2408 */
2409 .macro inv_entry, reason
2410 +
2411 + pax_enter_kernel
2412 +
2413 sub sp, sp, #S_FRAME_SIZE
2414 ARM( stmib sp, {r1 - lr} )
2415 THUMB( stmia sp, {r0 - r12} )
2416 THUMB( str sp, [sp, #S_SP] )
2417 THUMB( str lr, [sp, #S_LR] )
2418 +
2419 mov r1, #\reason
2420 .endm
2421
2422 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2423 .macro svc_entry, stack_hole=0
2424 UNWIND(.fnstart )
2425 UNWIND(.save {r0 - pc} )
2426 +
2427 + pax_enter_kernel
2428 +
2429 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2430 +
2431 #ifdef CONFIG_THUMB2_KERNEL
2432 SPFIX( str r0, [sp] ) @ temporarily saved
2433 SPFIX( mov r0, sp )
2434 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2435 ldmia r0, {r3 - r5}
2436 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2437 mov r6, #-1 @ "" "" "" ""
2438 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2439 + @ offset sp by 8 as done in pax_enter_kernel
2440 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2441 +#else
2442 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2443 +#endif
2444 SPFIX( addeq r2, r2, #4 )
2445 str r3, [sp, #-4]! @ save the "real" r0 copied
2446 @ from the exception stack
2447 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2448 .macro usr_entry
2449 UNWIND(.fnstart )
2450 UNWIND(.cantunwind ) @ don't unwind the user space
2451 +
2452 + pax_enter_kernel_user
2453 +
2454 sub sp, sp, #S_FRAME_SIZE
2455 ARM( stmib sp, {r1 - r12} )
2456 THUMB( stmia sp, {r0 - r12} )
2457 @@ -456,7 +553,9 @@ __und_usr:
2458 tst r3, #PSR_T_BIT @ Thumb mode?
2459 bne __und_usr_thumb
2460 sub r4, r2, #4 @ ARM instr at LR - 4
2461 + pax_open_userland
2462 1: ldrt r0, [r4]
2463 + pax_close_userland
2464 #ifdef CONFIG_CPU_ENDIAN_BE8
2465 rev r0, r0 @ little endian instruction
2466 #endif
2467 @@ -491,10 +590,14 @@ __und_usr_thumb:
2468 */
2469 .arch armv6t2
2470 #endif
2471 + pax_open_userland
2472 2: ldrht r5, [r4]
2473 + pax_close_userland
2474 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2475 blo __und_usr_fault_16 @ 16bit undefined instruction
2476 + pax_open_userland
2477 3: ldrht r0, [r2]
2478 + pax_close_userland
2479 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2480 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2481 orr r0, r0, r5, lsl #16
2482 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2483 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2484 THUMB( str sp, [ip], #4 )
2485 THUMB( str lr, [ip], #4 )
2486 -#ifdef CONFIG_CPU_USE_DOMAINS
2487 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2488 ldr r6, [r2, #TI_CPU_DOMAIN]
2489 #endif
2490 set_tls r3, r4, r5
2491 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2492 ldr r8, =__stack_chk_guard
2493 ldr r7, [r7, #TSK_STACK_CANARY]
2494 #endif
2495 -#ifdef CONFIG_CPU_USE_DOMAINS
2496 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2497 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2498 #endif
2499 mov r5, r0
2500 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2501 index fefd7f9..e6f250e 100644
2502 --- a/arch/arm/kernel/entry-common.S
2503 +++ b/arch/arm/kernel/entry-common.S
2504 @@ -10,18 +10,46 @@
2505
2506 #include <asm/unistd.h>
2507 #include <asm/ftrace.h>
2508 +#include <asm/domain.h>
2509 #include <asm/unwind.h>
2510
2511 +#include "entry-header.S"
2512 +
2513 #ifdef CONFIG_NEED_RET_TO_USER
2514 #include <mach/entry-macro.S>
2515 #else
2516 .macro arch_ret_to_user, tmp1, tmp2
2517 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2518 + @ save regs
2519 + stmdb sp!, {r1, r2}
2520 + @ read DACR from cpu_domain into r1
2521 + mov r2, sp
2522 + @ assume 8K pages, since we have to split the immediate in two
2523 + bic r2, r2, #(0x1fc0)
2524 + bic r2, r2, #(0x3f)
2525 + ldr r1, [r2, #TI_CPU_DOMAIN]
2526 +#ifdef CONFIG_PAX_KERNEXEC
2527 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2528 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2529 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2530 +#endif
2531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2532 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2533 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2534 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2535 +#endif
2536 + @ write r1 to current_thread_info()->cpu_domain
2537 + str r1, [r2, #TI_CPU_DOMAIN]
2538 + @ write r1 to DACR
2539 + mcr p15, 0, r1, c3, c0, 0
2540 + @ instruction sync
2541 + instr_sync
2542 + @ restore regs
2543 + ldmia sp!, {r1, r2}
2544 +#endif
2545 .endm
2546 #endif
2547
2548 -#include "entry-header.S"
2549 -
2550 -
2551 .align 5
2552 /*
2553 * This is the fast syscall return path. We do as little as
2554 @@ -351,6 +379,7 @@ ENDPROC(ftrace_stub)
2555
2556 .align 5
2557 ENTRY(vector_swi)
2558 +
2559 sub sp, sp, #S_FRAME_SIZE
2560 stmia sp, {r0 - r12} @ Calling r0 - r12
2561 ARM( add r8, sp, #S_PC )
2562 @@ -400,6 +429,12 @@ ENTRY(vector_swi)
2563 ldr scno, [lr, #-4] @ get SWI instruction
2564 #endif
2565
2566 + /*
2567 + * do this here to avoid a performance hit of wrapping the code above
2568 + * that directly dereferences userland to parse the SWI instruction
2569 + */
2570 + pax_enter_kernel_user
2571 +
2572 #ifdef CONFIG_ALIGNMENT_TRAP
2573 ldr ip, __cr_alignment
2574 ldr ip, [ip]
2575 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2576 index 9a8531e..812e287 100644
2577 --- a/arch/arm/kernel/entry-header.S
2578 +++ b/arch/arm/kernel/entry-header.S
2579 @@ -73,9 +73,66 @@
2580 msr cpsr_c, \rtemp @ switch back to the SVC mode
2581 .endm
2582
2583 + .macro pax_enter_kernel_user
2584 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2585 + @ save regs
2586 + stmdb sp!, {r0, r1}
2587 + @ read DACR from cpu_domain into r1
2588 + mov r0, sp
2589 + @ assume 8K pages, since we have to split the immediate in two
2590 + bic r0, r0, #(0x1fc0)
2591 + bic r0, r0, #(0x3f)
2592 + ldr r1, [r0, #TI_CPU_DOMAIN]
2593 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2594 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2595 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2596 +#endif
2597 +#ifdef CONFIG_PAX_KERNEXEC
2598 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2599 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2600 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2601 +#endif
2602 + @ write r1 to current_thread_info()->cpu_domain
2603 + str r1, [r0, #TI_CPU_DOMAIN]
2604 + @ write r1 to DACR
2605 + mcr p15, 0, r1, c3, c0, 0
2606 + @ instruction sync
2607 + instr_sync
2608 + @ restore regs
2609 + ldmia sp!, {r0, r1}
2610 +#endif
2611 + .endm
2612 +
2613 + .macro pax_exit_kernel
2614 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2615 + @ save regs
2616 + stmdb sp!, {r0, r1}
2617 + @ read old DACR from stack into r1
2618 + ldr r1, [sp, #(8 + S_SP)]
2619 + sub r1, r1, #8
2620 + ldr r1, [r1]
2621 +
2622 + @ write r1 to current_thread_info()->cpu_domain
2623 + mov r0, sp
2624 + @ assume 8K pages, since we have to split the immediate in two
2625 + bic r0, r0, #(0x1fc0)
2626 + bic r0, r0, #(0x3f)
2627 + str r1, [r0, #TI_CPU_DOMAIN]
2628 + @ write r1 to DACR
2629 + mcr p15, 0, r1, c3, c0, 0
2630 + @ instruction sync
2631 + instr_sync
2632 + @ restore regs
2633 + ldmia sp!, {r0, r1}
2634 +#endif
2635 + .endm
2636 +
2637 #ifndef CONFIG_THUMB2_KERNEL
2638 .macro svc_exit, rpsr
2639 msr spsr_cxsf, \rpsr
2640 +
2641 + pax_exit_kernel
2642 +
2643 #if defined(CONFIG_CPU_V6)
2644 ldr r0, [sp]
2645 strex r1, r2, [sp] @ clear the exclusive monitor
2646 @@ -121,6 +178,9 @@
2647 .endm
2648 #else /* CONFIG_THUMB2_KERNEL */
2649 .macro svc_exit, rpsr
2650 +
2651 + pax_exit_kernel
2652 +
2653 ldr lr, [sp, #S_SP] @ top of the stack
2654 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2655 clrex @ clear the exclusive monitor
2656 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2657 index 2adda11..7fbe958 100644
2658 --- a/arch/arm/kernel/fiq.c
2659 +++ b/arch/arm/kernel/fiq.c
2660 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2661 #if defined(CONFIG_CPU_USE_DOMAINS)
2662 memcpy((void *)0xffff001c, start, length);
2663 #else
2664 + pax_open_kernel();
2665 memcpy(vectors_page + 0x1c, start, length);
2666 + pax_close_kernel();
2667 #endif
2668 flush_icache_range(0xffff001c, 0xffff001c + length);
2669 if (!vectors_high())
2670 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2671 index 8bac553..caee108 100644
2672 --- a/arch/arm/kernel/head.S
2673 +++ b/arch/arm/kernel/head.S
2674 @@ -52,7 +52,9 @@
2675 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2676
2677 .macro pgtbl, rd, phys
2678 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2679 + mov \rd, #TEXT_OFFSET
2680 + sub \rd, #PG_DIR_SIZE
2681 + add \rd, \rd, \phys
2682 .endm
2683
2684 /*
2685 @@ -434,7 +436,7 @@ __enable_mmu:
2686 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2687 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2688 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2689 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2690 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2691 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2692 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2693 #endif
2694 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2695 index 1fd749e..47adb08 100644
2696 --- a/arch/arm/kernel/hw_breakpoint.c
2697 +++ b/arch/arm/kernel/hw_breakpoint.c
2698 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2699 return NOTIFY_OK;
2700 }
2701
2702 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2703 +static struct notifier_block dbg_reset_nb = {
2704 .notifier_call = dbg_reset_notify,
2705 };
2706
2707 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2708 index 1e9be5d..03edbc2 100644
2709 --- a/arch/arm/kernel/module.c
2710 +++ b/arch/arm/kernel/module.c
2711 @@ -37,12 +37,37 @@
2712 #endif
2713
2714 #ifdef CONFIG_MMU
2715 -void *module_alloc(unsigned long size)
2716 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2717 {
2718 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2719 + return NULL;
2720 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2721 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2722 + GFP_KERNEL, prot, -1,
2723 __builtin_return_address(0));
2724 }
2725 +
2726 +void *module_alloc(unsigned long size)
2727 +{
2728 +
2729 +#ifdef CONFIG_PAX_KERNEXEC
2730 + return __module_alloc(size, PAGE_KERNEL);
2731 +#else
2732 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2733 +#endif
2734 +
2735 +}
2736 +
2737 +#ifdef CONFIG_PAX_KERNEXEC
2738 +void module_free_exec(struct module *mod, void *module_region)
2739 +{
2740 + module_free(mod, module_region);
2741 +}
2742 +
2743 +void *module_alloc_exec(unsigned long size)
2744 +{
2745 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2746 +}
2747 +#endif
2748 #endif
2749
2750 int
2751 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2752 index 07314af..c46655c 100644
2753 --- a/arch/arm/kernel/patch.c
2754 +++ b/arch/arm/kernel/patch.c
2755 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2756 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2757 int size;
2758
2759 + pax_open_kernel();
2760 if (thumb2 && __opcode_is_thumb16(insn)) {
2761 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2762 size = sizeof(u16);
2763 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2764 *(u32 *)addr = insn;
2765 size = sizeof(u32);
2766 }
2767 + pax_close_kernel();
2768
2769 flush_icache_range((uintptr_t)(addr),
2770 (uintptr_t)(addr) + size);
2771 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2772 index 1f2740e..b36e225 100644
2773 --- a/arch/arm/kernel/perf_event_cpu.c
2774 +++ b/arch/arm/kernel/perf_event_cpu.c
2775 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2776 return NOTIFY_OK;
2777 }
2778
2779 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2780 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2781 .notifier_call = cpu_pmu_notify,
2782 };
2783
2784 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2785 index 047d3e4..7e96107 100644
2786 --- a/arch/arm/kernel/process.c
2787 +++ b/arch/arm/kernel/process.c
2788 @@ -28,7 +28,6 @@
2789 #include <linux/tick.h>
2790 #include <linux/utsname.h>
2791 #include <linux/uaccess.h>
2792 -#include <linux/random.h>
2793 #include <linux/hw_breakpoint.h>
2794 #include <linux/cpuidle.h>
2795 #include <linux/leds.h>
2796 @@ -251,9 +250,10 @@ void machine_power_off(void)
2797 machine_shutdown();
2798 if (pm_power_off)
2799 pm_power_off();
2800 + BUG();
2801 }
2802
2803 -void machine_restart(char *cmd)
2804 +__noreturn void machine_restart(char *cmd)
2805 {
2806 machine_shutdown();
2807
2808 @@ -278,8 +278,8 @@ void __show_regs(struct pt_regs *regs)
2809 init_utsname()->release,
2810 (int)strcspn(init_utsname()->version, " "),
2811 init_utsname()->version);
2812 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2813 - print_symbol("LR is at %s\n", regs->ARM_lr);
2814 + printk("PC is at %pA\n", instruction_pointer(regs));
2815 + printk("LR is at %pA\n", regs->ARM_lr);
2816 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2817 "sp : %08lx ip : %08lx fp : %08lx\n",
2818 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2819 @@ -447,12 +447,6 @@ unsigned long get_wchan(struct task_struct *p)
2820 return 0;
2821 }
2822
2823 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2824 -{
2825 - unsigned long range_end = mm->brk + 0x02000000;
2826 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2827 -}
2828 -
2829 #ifdef CONFIG_MMU
2830 /*
2831 * The vectors page is always readable from user space for the
2832 @@ -465,9 +459,8 @@ static int __init gate_vma_init(void)
2833 {
2834 gate_vma.vm_start = 0xffff0000;
2835 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2836 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2837 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2838 - VM_MAYREAD | VM_MAYEXEC;
2839 + gate_vma.vm_flags = VM_NONE;
2840 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2841 return 0;
2842 }
2843 arch_initcall(gate_vma_init);
2844 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2845 index 3653164..d83e55d 100644
2846 --- a/arch/arm/kernel/psci.c
2847 +++ b/arch/arm/kernel/psci.c
2848 @@ -24,7 +24,7 @@
2849 #include <asm/opcodes-virt.h>
2850 #include <asm/psci.h>
2851
2852 -struct psci_operations psci_ops;
2853 +struct psci_operations psci_ops __read_only;
2854
2855 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2856
2857 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2858 index 03deeff..741ce88 100644
2859 --- a/arch/arm/kernel/ptrace.c
2860 +++ b/arch/arm/kernel/ptrace.c
2861 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2862 return current_thread_info()->syscall;
2863 }
2864
2865 +#ifdef CONFIG_GRKERNSEC_SETXID
2866 +extern void gr_delayed_cred_worker(void);
2867 +#endif
2868 +
2869 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2870 {
2871 current_thread_info()->syscall = scno;
2872
2873 +#ifdef CONFIG_GRKERNSEC_SETXID
2874 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2875 + gr_delayed_cred_worker();
2876 +#endif
2877 +
2878 /* Do the secure computing check first; failures should be fast. */
2879 if (secure_computing(scno) == -1)
2880 return -1;
2881 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2882 index 234e339..81264a1 100644
2883 --- a/arch/arm/kernel/setup.c
2884 +++ b/arch/arm/kernel/setup.c
2885 @@ -96,21 +96,23 @@ EXPORT_SYMBOL(system_serial_high);
2886 unsigned int elf_hwcap __read_mostly;
2887 EXPORT_SYMBOL(elf_hwcap);
2888
2889 +pteval_t __supported_pte_mask __read_only;
2890 +pmdval_t __supported_pmd_mask __read_only;
2891
2892 #ifdef MULTI_CPU
2893 -struct processor processor __read_mostly;
2894 +struct processor processor;
2895 #endif
2896 #ifdef MULTI_TLB
2897 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2898 +struct cpu_tlb_fns cpu_tlb __read_only;
2899 #endif
2900 #ifdef MULTI_USER
2901 -struct cpu_user_fns cpu_user __read_mostly;
2902 +struct cpu_user_fns cpu_user __read_only;
2903 #endif
2904 #ifdef MULTI_CACHE
2905 -struct cpu_cache_fns cpu_cache __read_mostly;
2906 +struct cpu_cache_fns cpu_cache __read_only;
2907 #endif
2908 #ifdef CONFIG_OUTER_CACHE
2909 -struct outer_cache_fns outer_cache __read_mostly;
2910 +struct outer_cache_fns outer_cache __read_only;
2911 EXPORT_SYMBOL(outer_cache);
2912 #endif
2913
2914 @@ -235,9 +237,13 @@ static int __get_cpu_architecture(void)
2915 asm("mrc p15, 0, %0, c0, c1, 4"
2916 : "=r" (mmfr0));
2917 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2918 - (mmfr0 & 0x000000f0) >= 0x00000030)
2919 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2920 cpu_arch = CPU_ARCH_ARMv7;
2921 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2922 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2923 + __supported_pte_mask |= L_PTE_PXN;
2924 + __supported_pmd_mask |= PMD_PXNTABLE;
2925 + }
2926 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2927 (mmfr0 & 0x000000f0) == 0x00000020)
2928 cpu_arch = CPU_ARCH_ARMv6;
2929 else
2930 @@ -478,7 +484,7 @@ static void __init setup_processor(void)
2931 __cpu_architecture = __get_cpu_architecture();
2932
2933 #ifdef MULTI_CPU
2934 - processor = *list->proc;
2935 + memcpy((void *)&processor, list->proc, sizeof processor);
2936 #endif
2937 #ifdef MULTI_TLB
2938 cpu_tlb = *list->tlb;
2939 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
2940 index 296786b..a8d4dd5 100644
2941 --- a/arch/arm/kernel/signal.c
2942 +++ b/arch/arm/kernel/signal.c
2943 @@ -396,22 +396,14 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
2944 __put_user(sigreturn_codes[idx+1], rc+1))
2945 return 1;
2946
2947 - if (cpsr & MODE32_BIT) {
2948 - /*
2949 - * 32-bit code can use the new high-page
2950 - * signal return code support.
2951 - */
2952 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
2953 - } else {
2954 - /*
2955 - * Ensure that the instruction cache sees
2956 - * the return code written onto the stack.
2957 - */
2958 - flush_icache_range((unsigned long)rc,
2959 - (unsigned long)(rc + 2));
2960 + /*
2961 + * Ensure that the instruction cache sees
2962 + * the return code written onto the stack.
2963 + */
2964 + flush_icache_range((unsigned long)rc,
2965 + (unsigned long)(rc + 2));
2966
2967 - retcode = ((unsigned long)rc) + thumb;
2968 - }
2969 + retcode = ((unsigned long)rc) + thumb;
2970 }
2971
2972 regs->ARM_r0 = map_sig(ksig->sig);
2973 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
2974 index 1f2cccc..f40c02e 100644
2975 --- a/arch/arm/kernel/smp.c
2976 +++ b/arch/arm/kernel/smp.c
2977 @@ -70,7 +70,7 @@ enum ipi_msg_type {
2978
2979 static DECLARE_COMPLETION(cpu_running);
2980
2981 -static struct smp_operations smp_ops;
2982 +static struct smp_operations smp_ops __read_only;
2983
2984 void __init smp_set_ops(struct smp_operations *ops)
2985 {
2986 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
2987 index 1c08911..264f009 100644
2988 --- a/arch/arm/kernel/traps.c
2989 +++ b/arch/arm/kernel/traps.c
2990 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
2991 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
2992 {
2993 #ifdef CONFIG_KALLSYMS
2994 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
2995 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
2996 #else
2997 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
2998 #endif
2999 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3000 static int die_owner = -1;
3001 static unsigned int die_nest_count;
3002
3003 +extern void gr_handle_kernel_exploit(void);
3004 +
3005 static unsigned long oops_begin(void)
3006 {
3007 int cpu;
3008 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3009 panic("Fatal exception in interrupt");
3010 if (panic_on_oops)
3011 panic("Fatal exception");
3012 +
3013 + gr_handle_kernel_exploit();
3014 +
3015 if (signr)
3016 do_exit(signr);
3017 }
3018 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3019 * The user helper at 0xffff0fe0 must be used instead.
3020 * (see entry-armv.S for details)
3021 */
3022 + pax_open_kernel();
3023 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3024 + pax_close_kernel();
3025 }
3026 return 0;
3027
3028 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3029 */
3030 kuser_get_tls_init(vectors);
3031
3032 - /*
3033 - * Copy signal return handlers into the vector page, and
3034 - * set sigreturn to be a pointer to these.
3035 - */
3036 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3037 - sigreturn_codes, sizeof(sigreturn_codes));
3038 -
3039 flush_icache_range(vectors, vectors + PAGE_SIZE);
3040 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3041 +
3042 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3043 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3044 +#endif
3045 +
3046 }
3047 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3048 index b571484..4b2fc9b 100644
3049 --- a/arch/arm/kernel/vmlinux.lds.S
3050 +++ b/arch/arm/kernel/vmlinux.lds.S
3051 @@ -8,7 +8,11 @@
3052 #include <asm/thread_info.h>
3053 #include <asm/memory.h>
3054 #include <asm/page.h>
3055 -
3056 +
3057 +#ifdef CONFIG_PAX_KERNEXEC
3058 +#include <asm/pgtable.h>
3059 +#endif
3060 +
3061 #define PROC_INFO \
3062 . = ALIGN(4); \
3063 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3064 @@ -94,6 +98,11 @@ SECTIONS
3065 _text = .;
3066 HEAD_TEXT
3067 }
3068 +
3069 +#ifdef CONFIG_PAX_KERNEXEC
3070 + . = ALIGN(1<<SECTION_SHIFT);
3071 +#endif
3072 +
3073 .text : { /* Real text segment */
3074 _stext = .; /* Text and read-only data */
3075 __exception_text_start = .;
3076 @@ -116,6 +125,8 @@ SECTIONS
3077 ARM_CPU_KEEP(PROC_INFO)
3078 }
3079
3080 + _etext = .; /* End of text section */
3081 +
3082 RO_DATA(PAGE_SIZE)
3083
3084 . = ALIGN(4);
3085 @@ -146,7 +157,9 @@ SECTIONS
3086
3087 NOTES
3088
3089 - _etext = .; /* End of text and rodata section */
3090 +#ifdef CONFIG_PAX_KERNEXEC
3091 + . = ALIGN(1<<SECTION_SHIFT);
3092 +#endif
3093
3094 #ifndef CONFIG_XIP_KERNEL
3095 . = ALIGN(PAGE_SIZE);
3096 @@ -207,6 +220,11 @@ SECTIONS
3097 . = PAGE_OFFSET + TEXT_OFFSET;
3098 #else
3099 __init_end = .;
3100 +
3101 +#ifdef CONFIG_PAX_KERNEXEC
3102 + . = ALIGN(1<<SECTION_SHIFT);
3103 +#endif
3104 +
3105 . = ALIGN(THREAD_SIZE);
3106 __data_loc = .;
3107 #endif
3108 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3109 index 14a0d98..7771a7d 100644
3110 --- a/arch/arm/lib/clear_user.S
3111 +++ b/arch/arm/lib/clear_user.S
3112 @@ -12,14 +12,14 @@
3113
3114 .text
3115
3116 -/* Prototype: int __clear_user(void *addr, size_t sz)
3117 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3118 * Purpose : clear some user memory
3119 * Params : addr - user memory address to clear
3120 * : sz - number of bytes to clear
3121 * Returns : number of bytes NOT cleared
3122 */
3123 ENTRY(__clear_user_std)
3124 -WEAK(__clear_user)
3125 +WEAK(___clear_user)
3126 stmfd sp!, {r1, lr}
3127 mov r2, #0
3128 cmp r1, #4
3129 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3130 USER( strnebt r2, [r0])
3131 mov r0, #0
3132 ldmfd sp!, {r1, pc}
3133 -ENDPROC(__clear_user)
3134 +ENDPROC(___clear_user)
3135 ENDPROC(__clear_user_std)
3136
3137 .pushsection .fixup,"ax"
3138 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3139 index 66a477a..bee61d3 100644
3140 --- a/arch/arm/lib/copy_from_user.S
3141 +++ b/arch/arm/lib/copy_from_user.S
3142 @@ -16,7 +16,7 @@
3143 /*
3144 * Prototype:
3145 *
3146 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3147 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3148 *
3149 * Purpose:
3150 *
3151 @@ -84,11 +84,11 @@
3152
3153 .text
3154
3155 -ENTRY(__copy_from_user)
3156 +ENTRY(___copy_from_user)
3157
3158 #include "copy_template.S"
3159
3160 -ENDPROC(__copy_from_user)
3161 +ENDPROC(___copy_from_user)
3162
3163 .pushsection .fixup,"ax"
3164 .align 0
3165 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3166 index 6ee2f67..d1cce76 100644
3167 --- a/arch/arm/lib/copy_page.S
3168 +++ b/arch/arm/lib/copy_page.S
3169 @@ -10,6 +10,7 @@
3170 * ASM optimised string functions
3171 */
3172 #include <linux/linkage.h>
3173 +#include <linux/const.h>
3174 #include <asm/assembler.h>
3175 #include <asm/asm-offsets.h>
3176 #include <asm/cache.h>
3177 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3178 index d066df6..df28194 100644
3179 --- a/arch/arm/lib/copy_to_user.S
3180 +++ b/arch/arm/lib/copy_to_user.S
3181 @@ -16,7 +16,7 @@
3182 /*
3183 * Prototype:
3184 *
3185 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3186 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3187 *
3188 * Purpose:
3189 *
3190 @@ -88,11 +88,11 @@
3191 .text
3192
3193 ENTRY(__copy_to_user_std)
3194 -WEAK(__copy_to_user)
3195 +WEAK(___copy_to_user)
3196
3197 #include "copy_template.S"
3198
3199 -ENDPROC(__copy_to_user)
3200 +ENDPROC(___copy_to_user)
3201 ENDPROC(__copy_to_user_std)
3202
3203 .pushsection .fixup,"ax"
3204 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3205 index 7d08b43..f7ca7ea 100644
3206 --- a/arch/arm/lib/csumpartialcopyuser.S
3207 +++ b/arch/arm/lib/csumpartialcopyuser.S
3208 @@ -57,8 +57,8 @@
3209 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3210 */
3211
3212 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3213 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3214 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3215 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3216
3217 #include "csumpartialcopygeneric.S"
3218
3219 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3220 index 64dbfa5..84a3fd9 100644
3221 --- a/arch/arm/lib/delay.c
3222 +++ b/arch/arm/lib/delay.c
3223 @@ -28,7 +28,7 @@
3224 /*
3225 * Default to the loop-based delay implementation.
3226 */
3227 -struct arm_delay_ops arm_delay_ops = {
3228 +struct arm_delay_ops arm_delay_ops __read_only = {
3229 .delay = __loop_delay,
3230 .const_udelay = __loop_const_udelay,
3231 .udelay = __loop_udelay,
3232 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3233 index 025f742..8432b08 100644
3234 --- a/arch/arm/lib/uaccess_with_memcpy.c
3235 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3236 @@ -104,7 +104,7 @@ out:
3237 }
3238
3239 unsigned long
3240 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3241 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3242 {
3243 /*
3244 * This test is stubbed out of the main function above to keep
3245 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3246 index 49792a0..f192052 100644
3247 --- a/arch/arm/mach-kirkwood/common.c
3248 +++ b/arch/arm/mach-kirkwood/common.c
3249 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3250 clk_gate_ops.disable(hw);
3251 }
3252
3253 -static struct clk_ops clk_gate_fn_ops;
3254 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3255 +{
3256 + return clk_gate_ops.is_enabled(hw);
3257 +}
3258 +
3259 +static struct clk_ops clk_gate_fn_ops = {
3260 + .enable = clk_gate_fn_enable,
3261 + .disable = clk_gate_fn_disable,
3262 + .is_enabled = clk_gate_fn_is_enabled,
3263 +};
3264
3265 static struct clk __init *clk_register_gate_fn(struct device *dev,
3266 const char *name,
3267 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3268 gate_fn->fn_en = fn_en;
3269 gate_fn->fn_dis = fn_dis;
3270
3271 - /* ops is the gate ops, but with our enable/disable functions */
3272 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3273 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3274 - clk_gate_fn_ops = clk_gate_ops;
3275 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3276 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3277 - }
3278 -
3279 clk = clk_register(dev, &gate_fn->gate.hw);
3280
3281 if (IS_ERR(clk))
3282 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3283 index f6eeb87..cc90868 100644
3284 --- a/arch/arm/mach-omap2/board-n8x0.c
3285 +++ b/arch/arm/mach-omap2/board-n8x0.c
3286 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3287 }
3288 #endif
3289
3290 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3291 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3292 .late_init = n8x0_menelaus_late_init,
3293 };
3294
3295 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3296 index 410e1ba..1d2dd59 100644
3297 --- a/arch/arm/mach-omap2/gpmc.c
3298 +++ b/arch/arm/mach-omap2/gpmc.c
3299 @@ -145,7 +145,6 @@ struct omap3_gpmc_regs {
3300 };
3301
3302 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3303 -static struct irq_chip gpmc_irq_chip;
3304 static unsigned gpmc_irq_start;
3305
3306 static struct resource gpmc_mem_root;
3307 @@ -707,6 +706,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3308
3309 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3310
3311 +static struct irq_chip gpmc_irq_chip = {
3312 + .name = "gpmc",
3313 + .irq_startup = gpmc_irq_noop_ret,
3314 + .irq_enable = gpmc_irq_enable,
3315 + .irq_disable = gpmc_irq_disable,
3316 + .irq_shutdown = gpmc_irq_noop,
3317 + .irq_ack = gpmc_irq_noop,
3318 + .irq_mask = gpmc_irq_noop,
3319 + .irq_unmask = gpmc_irq_noop,
3320 +
3321 +};
3322 +
3323 static int gpmc_setup_irq(void)
3324 {
3325 int i;
3326 @@ -721,15 +732,6 @@ static int gpmc_setup_irq(void)
3327 return gpmc_irq_start;
3328 }
3329
3330 - gpmc_irq_chip.name = "gpmc";
3331 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3332 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3333 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3334 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3335 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3336 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3337 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3338 -
3339 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3340 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3341
3342 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3343 index f8bb3b9..831e7b8 100644
3344 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3345 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3346 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3347 return NOTIFY_OK;
3348 }
3349
3350 -static struct notifier_block __refdata irq_hotplug_notifier = {
3351 +static struct notifier_block irq_hotplug_notifier = {
3352 .notifier_call = irq_cpu_hotplug_notify,
3353 };
3354
3355 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3356 index 381be7a..89b9c7e 100644
3357 --- a/arch/arm/mach-omap2/omap_device.c
3358 +++ b/arch/arm/mach-omap2/omap_device.c
3359 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3360 struct platform_device __init *omap_device_build(const char *pdev_name,
3361 int pdev_id,
3362 struct omap_hwmod *oh,
3363 - void *pdata, int pdata_len)
3364 + const void *pdata, int pdata_len)
3365 {
3366 struct omap_hwmod *ohs[] = { oh };
3367
3368 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3369 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3370 int pdev_id,
3371 struct omap_hwmod **ohs,
3372 - int oh_cnt, void *pdata,
3373 + int oh_cnt, const void *pdata,
3374 int pdata_len)
3375 {
3376 int ret = -ENOMEM;
3377 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3378 index 044c31d..2ee0861 100644
3379 --- a/arch/arm/mach-omap2/omap_device.h
3380 +++ b/arch/arm/mach-omap2/omap_device.h
3381 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3382 /* Core code interface */
3383
3384 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3385 - struct omap_hwmod *oh, void *pdata,
3386 + struct omap_hwmod *oh, const void *pdata,
3387 int pdata_len);
3388
3389 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3390 struct omap_hwmod **oh, int oh_cnt,
3391 - void *pdata, int pdata_len);
3392 + const void *pdata, int pdata_len);
3393
3394 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3395 struct omap_hwmod **ohs, int oh_cnt);
3396 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3397 index 3a750de..4c9b88f 100644
3398 --- a/arch/arm/mach-omap2/omap_hwmod.c
3399 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3400 @@ -191,10 +191,10 @@ struct omap_hwmod_soc_ops {
3401 int (*init_clkdm)(struct omap_hwmod *oh);
3402 void (*update_context_lost)(struct omap_hwmod *oh);
3403 int (*get_context_lost)(struct omap_hwmod *oh);
3404 -};
3405 +} __no_const;
3406
3407 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3408 -static struct omap_hwmod_soc_ops soc_ops;
3409 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3410
3411 /* omap_hwmod_list contains all registered struct omap_hwmods */
3412 static LIST_HEAD(omap_hwmod_list);
3413 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3414 index d15c7bb..b2d1f0c 100644
3415 --- a/arch/arm/mach-omap2/wd_timer.c
3416 +++ b/arch/arm/mach-omap2/wd_timer.c
3417 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3418 struct omap_hwmod *oh;
3419 char *oh_name = "wd_timer2";
3420 char *dev_name = "omap_wdt";
3421 - struct omap_wd_timer_platform_data pdata;
3422 + static struct omap_wd_timer_platform_data pdata = {
3423 + .read_reset_sources = prm_read_reset_sources
3424 + };
3425
3426 if (!cpu_class_is_omap2() || of_have_populated_dt())
3427 return 0;
3428 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3429 return -EINVAL;
3430 }
3431
3432 - pdata.read_reset_sources = prm_read_reset_sources;
3433 -
3434 pdev = omap_device_build(dev_name, id, oh, &pdata,
3435 sizeof(struct omap_wd_timer_platform_data));
3436 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3437 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3438 index bddce2b..3eb04e2 100644
3439 --- a/arch/arm/mach-ux500/include/mach/setup.h
3440 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3441 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3442 .type = MT_DEVICE, \
3443 }
3444
3445 -#define __MEM_DEV_DESC(x, sz) { \
3446 - .virtual = IO_ADDRESS(x), \
3447 - .pfn = __phys_to_pfn(x), \
3448 - .length = sz, \
3449 - .type = MT_MEMORY, \
3450 -}
3451 -
3452 extern struct smp_operations ux500_smp_ops;
3453 extern void ux500_cpu_die(unsigned int cpu);
3454
3455 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3456 index 4045c49..4e26c79 100644
3457 --- a/arch/arm/mm/Kconfig
3458 +++ b/arch/arm/mm/Kconfig
3459 @@ -425,7 +425,7 @@ config CPU_32v5
3460
3461 config CPU_32v6
3462 bool
3463 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3464 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3465 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3466
3467 config CPU_32v6K
3468 @@ -574,6 +574,7 @@ config CPU_CP15_MPU
3469
3470 config CPU_USE_DOMAINS
3471 bool
3472 + depends on !ARM_LPAE && !PAX_KERNEXEC
3473 help
3474 This option enables or disables the use of domain switching
3475 via the set_fs() function.
3476 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3477 index db26e2e..ee44569 100644
3478 --- a/arch/arm/mm/alignment.c
3479 +++ b/arch/arm/mm/alignment.c
3480 @@ -211,10 +211,12 @@ union offset_union {
3481 #define __get16_unaligned_check(ins,val,addr) \
3482 do { \
3483 unsigned int err = 0, v, a = addr; \
3484 + pax_open_userland(); \
3485 __get8_unaligned_check(ins,v,a,err); \
3486 val = v << ((BE) ? 8 : 0); \
3487 __get8_unaligned_check(ins,v,a,err); \
3488 val |= v << ((BE) ? 0 : 8); \
3489 + pax_close_userland(); \
3490 if (err) \
3491 goto fault; \
3492 } while (0)
3493 @@ -228,6 +230,7 @@ union offset_union {
3494 #define __get32_unaligned_check(ins,val,addr) \
3495 do { \
3496 unsigned int err = 0, v, a = addr; \
3497 + pax_open_userland(); \
3498 __get8_unaligned_check(ins,v,a,err); \
3499 val = v << ((BE) ? 24 : 0); \
3500 __get8_unaligned_check(ins,v,a,err); \
3501 @@ -236,6 +239,7 @@ union offset_union {
3502 val |= v << ((BE) ? 8 : 16); \
3503 __get8_unaligned_check(ins,v,a,err); \
3504 val |= v << ((BE) ? 0 : 24); \
3505 + pax_close_userland(); \
3506 if (err) \
3507 goto fault; \
3508 } while (0)
3509 @@ -249,6 +253,7 @@ union offset_union {
3510 #define __put16_unaligned_check(ins,val,addr) \
3511 do { \
3512 unsigned int err = 0, v = val, a = addr; \
3513 + pax_open_userland(); \
3514 __asm__( FIRST_BYTE_16 \
3515 ARM( "1: "ins" %1, [%2], #1\n" ) \
3516 THUMB( "1: "ins" %1, [%2]\n" ) \
3517 @@ -268,6 +273,7 @@ union offset_union {
3518 " .popsection\n" \
3519 : "=r" (err), "=&r" (v), "=&r" (a) \
3520 : "0" (err), "1" (v), "2" (a)); \
3521 + pax_close_userland(); \
3522 if (err) \
3523 goto fault; \
3524 } while (0)
3525 @@ -281,6 +287,7 @@ union offset_union {
3526 #define __put32_unaligned_check(ins,val,addr) \
3527 do { \
3528 unsigned int err = 0, v = val, a = addr; \
3529 + pax_open_userland(); \
3530 __asm__( FIRST_BYTE_32 \
3531 ARM( "1: "ins" %1, [%2], #1\n" ) \
3532 THUMB( "1: "ins" %1, [%2]\n" ) \
3533 @@ -310,6 +317,7 @@ union offset_union {
3534 " .popsection\n" \
3535 : "=r" (err), "=&r" (v), "=&r" (a) \
3536 : "0" (err), "1" (v), "2" (a)); \
3537 + pax_close_userland(); \
3538 if (err) \
3539 goto fault; \
3540 } while (0)
3541 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3542 index 5dbf13f..1a60561 100644
3543 --- a/arch/arm/mm/fault.c
3544 +++ b/arch/arm/mm/fault.c
3545 @@ -25,6 +25,7 @@
3546 #include <asm/system_misc.h>
3547 #include <asm/system_info.h>
3548 #include <asm/tlbflush.h>
3549 +#include <asm/sections.h>
3550
3551 #include "fault.h"
3552
3553 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3554 if (fixup_exception(regs))
3555 return;
3556
3557 +#ifdef CONFIG_PAX_KERNEXEC
3558 + if ((fsr & FSR_WRITE) &&
3559 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3560 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3561 + {
3562 + if (current->signal->curr_ip)
3563 + 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),
3564 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3565 + else
3566 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3567 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3568 + }
3569 +#endif
3570 +
3571 /*
3572 * No handler, we'll have to terminate things with extreme prejudice.
3573 */
3574 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3575 }
3576 #endif
3577
3578 +#ifdef CONFIG_PAX_PAGEEXEC
3579 + if (fsr & FSR_LNX_PF) {
3580 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3581 + do_group_exit(SIGKILL);
3582 + }
3583 +#endif
3584 +
3585 tsk->thread.address = addr;
3586 tsk->thread.error_code = fsr;
3587 tsk->thread.trap_no = 14;
3588 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3589 }
3590 #endif /* CONFIG_MMU */
3591
3592 +#ifdef CONFIG_PAX_PAGEEXEC
3593 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3594 +{
3595 + long i;
3596 +
3597 + printk(KERN_ERR "PAX: bytes at PC: ");
3598 + for (i = 0; i < 20; i++) {
3599 + unsigned char c;
3600 + if (get_user(c, (__force unsigned char __user *)pc+i))
3601 + printk(KERN_CONT "?? ");
3602 + else
3603 + printk(KERN_CONT "%02x ", c);
3604 + }
3605 + printk("\n");
3606 +
3607 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3608 + for (i = -1; i < 20; i++) {
3609 + unsigned long c;
3610 + if (get_user(c, (__force unsigned long __user *)sp+i))
3611 + printk(KERN_CONT "???????? ");
3612 + else
3613 + printk(KERN_CONT "%08lx ", c);
3614 + }
3615 + printk("\n");
3616 +}
3617 +#endif
3618 +
3619 /*
3620 * First Level Translation Fault Handler
3621 *
3622 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3623 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3624 struct siginfo info;
3625
3626 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3627 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3628 + if (current->signal->curr_ip)
3629 + 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),
3630 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3631 + else
3632 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3633 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3634 + goto die;
3635 + }
3636 +#endif
3637 +
3638 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3639 return;
3640
3641 +die:
3642 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3643 inf->name, fsr, addr);
3644
3645 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3646 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3647 struct siginfo info;
3648
3649 + if (user_mode(regs)) {
3650 + if (addr == 0xffff0fe0UL) {
3651 + /*
3652 + * PaX: __kuser_get_tls emulation
3653 + */
3654 + regs->ARM_r0 = current_thread_info()->tp_value;
3655 + regs->ARM_pc = regs->ARM_lr;
3656 + return;
3657 + }
3658 + }
3659 +
3660 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3661 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3662 + if (current->signal->curr_ip)
3663 + 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),
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 + else
3667 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3668 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3669 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3670 + goto die;
3671 + }
3672 +#endif
3673 +
3674 +#ifdef CONFIG_PAX_REFCOUNT
3675 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3676 + unsigned int bkpt;
3677 +
3678 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3679 + current->thread.error_code = ifsr;
3680 + current->thread.trap_no = 0;
3681 + pax_report_refcount_overflow(regs);
3682 + fixup_exception(regs);
3683 + return;
3684 + }
3685 + }
3686 +#endif
3687 +
3688 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3689 return;
3690
3691 +die:
3692 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3693 inf->name, ifsr, addr);
3694
3695 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3696 index cf08bdf..772656c 100644
3697 --- a/arch/arm/mm/fault.h
3698 +++ b/arch/arm/mm/fault.h
3699 @@ -3,6 +3,7 @@
3700
3701 /*
3702 * Fault status register encodings. We steal bit 31 for our own purposes.
3703 + * Set when the FSR value is from an instruction fault.
3704 */
3705 #define FSR_LNX_PF (1 << 31)
3706 #define FSR_WRITE (1 << 11)
3707 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3708 }
3709 #endif
3710
3711 +/* valid for LPAE and !LPAE */
3712 +static inline int is_xn_fault(unsigned int fsr)
3713 +{
3714 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3715 +}
3716 +
3717 +static inline int is_domain_fault(unsigned int fsr)
3718 +{
3719 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3720 +}
3721 +
3722 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3723 unsigned long search_exception_table(unsigned long addr);
3724
3725 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3726 index ad722f1..763fdd3 100644
3727 --- a/arch/arm/mm/init.c
3728 +++ b/arch/arm/mm/init.c
3729 @@ -30,6 +30,8 @@
3730 #include <asm/setup.h>
3731 #include <asm/tlb.h>
3732 #include <asm/fixmap.h>
3733 +#include <asm/system_info.h>
3734 +#include <asm/cp15.h>
3735
3736 #include <asm/mach/arch.h>
3737 #include <asm/mach/map.h>
3738 @@ -736,7 +738,46 @@ void free_initmem(void)
3739 {
3740 #ifdef CONFIG_HAVE_TCM
3741 extern char __tcm_start, __tcm_end;
3742 +#endif
3743
3744 +#ifdef CONFIG_PAX_KERNEXEC
3745 + unsigned long addr;
3746 + pgd_t *pgd;
3747 + pud_t *pud;
3748 + pmd_t *pmd;
3749 + int cpu_arch = cpu_architecture();
3750 + unsigned int cr = get_cr();
3751 +
3752 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3753 + /* make pages tables, etc before .text NX */
3754 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3755 + pgd = pgd_offset_k(addr);
3756 + pud = pud_offset(pgd, addr);
3757 + pmd = pmd_offset(pud, addr);
3758 + __section_update(pmd, addr, PMD_SECT_XN);
3759 + }
3760 + /* make init NX */
3761 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3762 + pgd = pgd_offset_k(addr);
3763 + pud = pud_offset(pgd, addr);
3764 + pmd = pmd_offset(pud, addr);
3765 + __section_update(pmd, addr, PMD_SECT_XN);
3766 + }
3767 + /* make kernel code/rodata RX */
3768 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3769 + pgd = pgd_offset_k(addr);
3770 + pud = pud_offset(pgd, addr);
3771 + pmd = pmd_offset(pud, addr);
3772 +#ifdef CONFIG_ARM_LPAE
3773 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3774 +#else
3775 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3776 +#endif
3777 + }
3778 + }
3779 +#endif
3780 +
3781 +#ifdef CONFIG_HAVE_TCM
3782 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3783 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
3784 __phys_to_pfn(__pa(&__tcm_end)),
3785 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3786 index 04d9006..c547d85 100644
3787 --- a/arch/arm/mm/ioremap.c
3788 +++ b/arch/arm/mm/ioremap.c
3789 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3790 unsigned int mtype;
3791
3792 if (cached)
3793 - mtype = MT_MEMORY;
3794 + mtype = MT_MEMORY_RX;
3795 else
3796 - mtype = MT_MEMORY_NONCACHED;
3797 + mtype = MT_MEMORY_NONCACHED_RX;
3798
3799 return __arm_ioremap_caller(phys_addr, size, mtype,
3800 __builtin_return_address(0));
3801 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3802 index 10062ce..8695745 100644
3803 --- a/arch/arm/mm/mmap.c
3804 +++ b/arch/arm/mm/mmap.c
3805 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3806 struct vm_area_struct *vma;
3807 int do_align = 0;
3808 int aliasing = cache_is_vipt_aliasing();
3809 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3810 struct vm_unmapped_area_info info;
3811
3812 /*
3813 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3814 if (len > TASK_SIZE)
3815 return -ENOMEM;
3816
3817 +#ifdef CONFIG_PAX_RANDMMAP
3818 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3819 +#endif
3820 +
3821 if (addr) {
3822 if (do_align)
3823 addr = COLOUR_ALIGN(addr, pgoff);
3824 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3825 addr = PAGE_ALIGN(addr);
3826
3827 vma = find_vma(mm, addr);
3828 - if (TASK_SIZE - len >= addr &&
3829 - (!vma || addr + len <= vma->vm_start))
3830 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3831 return addr;
3832 }
3833
3834 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3835 info.high_limit = TASK_SIZE;
3836 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3837 info.align_offset = pgoff << PAGE_SHIFT;
3838 + info.threadstack_offset = offset;
3839 return vm_unmapped_area(&info);
3840 }
3841
3842 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3843 unsigned long addr = addr0;
3844 int do_align = 0;
3845 int aliasing = cache_is_vipt_aliasing();
3846 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3847 struct vm_unmapped_area_info info;
3848
3849 /*
3850 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3851 return addr;
3852 }
3853
3854 +#ifdef CONFIG_PAX_RANDMMAP
3855 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3856 +#endif
3857 +
3858 /* requesting a specific address */
3859 if (addr) {
3860 if (do_align)
3861 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3862 else
3863 addr = PAGE_ALIGN(addr);
3864 vma = find_vma(mm, addr);
3865 - if (TASK_SIZE - len >= addr &&
3866 - (!vma || addr + len <= vma->vm_start))
3867 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3868 return addr;
3869 }
3870
3871 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3872 info.high_limit = mm->mmap_base;
3873 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3874 info.align_offset = pgoff << PAGE_SHIFT;
3875 + info.threadstack_offset = offset;
3876 addr = vm_unmapped_area(&info);
3877
3878 /*
3879 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3880 {
3881 unsigned long random_factor = 0UL;
3882
3883 +#ifdef CONFIG_PAX_RANDMMAP
3884 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3885 +#endif
3886 +
3887 /* 8 bits of randomness in 20 address space bits */
3888 if ((current->flags & PF_RANDOMIZE) &&
3889 !(current->personality & ADDR_NO_RANDOMIZE))
3890 @@ -180,10 +194,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3891
3892 if (mmap_is_legacy()) {
3893 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3894 +
3895 +#ifdef CONFIG_PAX_RANDMMAP
3896 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3897 + mm->mmap_base += mm->delta_mmap;
3898 +#endif
3899 +
3900 mm->get_unmapped_area = arch_get_unmapped_area;
3901 mm->unmap_area = arch_unmap_area;
3902 } else {
3903 mm->mmap_base = mmap_base(random_factor);
3904 +
3905 +#ifdef CONFIG_PAX_RANDMMAP
3906 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3907 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3908 +#endif
3909 +
3910 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3911 mm->unmap_area = arch_unmap_area_topdown;
3912 }
3913 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
3914 index a84ff76..f221c1d 100644
3915 --- a/arch/arm/mm/mmu.c
3916 +++ b/arch/arm/mm/mmu.c
3917 @@ -36,6 +36,22 @@
3918 #include "mm.h"
3919 #include "tcm.h"
3920
3921 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3922 +void modify_domain(unsigned int dom, unsigned int type)
3923 +{
3924 + struct thread_info *thread = current_thread_info();
3925 + unsigned int domain = thread->cpu_domain;
3926 + /*
3927 + * DOMAIN_MANAGER might be defined to some other value,
3928 + * use the arch-defined constant
3929 + */
3930 + domain &= ~domain_val(dom, 3);
3931 + thread->cpu_domain = domain | domain_val(dom, type);
3932 + set_domain(thread->cpu_domain);
3933 +}
3934 +EXPORT_SYMBOL(modify_domain);
3935 +#endif
3936 +
3937 /*
3938 * empty_zero_page is a special page that is used for
3939 * zero-initialized data and COW.
3940 @@ -211,10 +227,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
3941 }
3942 #endif
3943
3944 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
3945 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
3946 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
3947
3948 -static struct mem_type mem_types[] = {
3949 +#ifdef CONFIG_PAX_KERNEXEC
3950 +#define L_PTE_KERNEXEC L_PTE_RDONLY
3951 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
3952 +#else
3953 +#define L_PTE_KERNEXEC L_PTE_DIRTY
3954 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
3955 +#endif
3956 +
3957 +static struct mem_type mem_types[] __read_only = {
3958 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
3959 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
3960 L_PTE_SHARED,
3961 @@ -243,16 +267,16 @@ static struct mem_type mem_types[] = {
3962 [MT_UNCACHED] = {
3963 .prot_pte = PROT_PTE_DEVICE,
3964 .prot_l1 = PMD_TYPE_TABLE,
3965 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
3966 + .prot_sect = PROT_SECT_DEVICE,
3967 .domain = DOMAIN_IO,
3968 },
3969 [MT_CACHECLEAN] = {
3970 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
3971 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
3972 .domain = DOMAIN_KERNEL,
3973 },
3974 #ifndef CONFIG_ARM_LPAE
3975 [MT_MINICLEAN] = {
3976 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
3977 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
3978 .domain = DOMAIN_KERNEL,
3979 },
3980 #endif
3981 @@ -260,36 +284,54 @@ static struct mem_type mem_types[] = {
3982 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
3983 L_PTE_RDONLY,
3984 .prot_l1 = PMD_TYPE_TABLE,
3985 - .domain = DOMAIN_USER,
3986 + .domain = DOMAIN_VECTORS,
3987 },
3988 [MT_HIGH_VECTORS] = {
3989 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
3990 - L_PTE_USER | L_PTE_RDONLY,
3991 + L_PTE_RDONLY,
3992 .prot_l1 = PMD_TYPE_TABLE,
3993 - .domain = DOMAIN_USER,
3994 + .domain = DOMAIN_VECTORS,
3995 },
3996 - [MT_MEMORY] = {
3997 + [MT_MEMORY_RWX] = {
3998 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
3999 .prot_l1 = PMD_TYPE_TABLE,
4000 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4001 .domain = DOMAIN_KERNEL,
4002 },
4003 + [MT_MEMORY_RW] = {
4004 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4005 + .prot_l1 = PMD_TYPE_TABLE,
4006 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4007 + .domain = DOMAIN_KERNEL,
4008 + },
4009 + [MT_MEMORY_RX] = {
4010 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4011 + .prot_l1 = PMD_TYPE_TABLE,
4012 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4013 + .domain = DOMAIN_KERNEL,
4014 + },
4015 [MT_ROM] = {
4016 - .prot_sect = PMD_TYPE_SECT,
4017 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4018 .domain = DOMAIN_KERNEL,
4019 },
4020 - [MT_MEMORY_NONCACHED] = {
4021 + [MT_MEMORY_NONCACHED_RW] = {
4022 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4023 L_PTE_MT_BUFFERABLE,
4024 .prot_l1 = PMD_TYPE_TABLE,
4025 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4026 .domain = DOMAIN_KERNEL,
4027 },
4028 + [MT_MEMORY_NONCACHED_RX] = {
4029 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4030 + L_PTE_MT_BUFFERABLE,
4031 + .prot_l1 = PMD_TYPE_TABLE,
4032 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4033 + .domain = DOMAIN_KERNEL,
4034 + },
4035 [MT_MEMORY_DTCM] = {
4036 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4037 - L_PTE_XN,
4038 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4039 .prot_l1 = PMD_TYPE_TABLE,
4040 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4041 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4042 .domain = DOMAIN_KERNEL,
4043 },
4044 [MT_MEMORY_ITCM] = {
4045 @@ -299,10 +341,10 @@ static struct mem_type mem_types[] = {
4046 },
4047 [MT_MEMORY_SO] = {
4048 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4049 - L_PTE_MT_UNCACHED | L_PTE_XN,
4050 + L_PTE_MT_UNCACHED,
4051 .prot_l1 = PMD_TYPE_TABLE,
4052 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4053 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4054 + PMD_SECT_UNCACHED,
4055 .domain = DOMAIN_KERNEL,
4056 },
4057 [MT_MEMORY_DMA_READY] = {
4058 @@ -388,9 +430,35 @@ static void __init build_mem_type_table(void)
4059 * to prevent speculative instruction fetches.
4060 */
4061 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4062 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4063 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4064 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4065 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4066 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4067 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4068 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4069 +
4070 + /* Mark other regions on ARMv6+ as execute-never */
4071 +
4072 +#ifdef CONFIG_PAX_KERNEXEC
4073 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4074 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4075 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4076 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4077 +#ifndef CONFIG_ARM_LPAE
4078 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4079 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4080 +#endif
4081 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4082 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4083 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4084 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4085 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4086 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4087 +#endif
4088 +
4089 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4090 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4091 }
4092 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4093 /*
4094 @@ -451,6 +519,9 @@ static void __init build_mem_type_table(void)
4095 * from SVC mode and no access from userspace.
4096 */
4097 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4098 +#ifdef CONFIG_PAX_KERNEXEC
4099 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4100 +#endif
4101 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4102 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4103 #endif
4104 @@ -468,11 +539,17 @@ static void __init build_mem_type_table(void)
4105 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4106 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4107 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4108 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4109 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4110 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4111 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4112 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4113 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4114 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4115 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4116 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4117 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4118 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4119 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4120 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4121 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4122 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4123 }
4124 }
4125
4126 @@ -483,15 +560,20 @@ static void __init build_mem_type_table(void)
4127 if (cpu_arch >= CPU_ARCH_ARMv6) {
4128 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4129 /* Non-cacheable Normal is XCB = 001 */
4130 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4131 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4132 + PMD_SECT_BUFFERED;
4133 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4134 PMD_SECT_BUFFERED;
4135 } else {
4136 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4137 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4138 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4139 + PMD_SECT_TEX(1);
4140 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4141 PMD_SECT_TEX(1);
4142 }
4143 } else {
4144 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4145 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4146 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4147 }
4148
4149 #ifdef CONFIG_ARM_LPAE
4150 @@ -507,6 +589,8 @@ static void __init build_mem_type_table(void)
4151 vecs_pgprot |= PTE_EXT_AF;
4152 #endif
4153
4154 + user_pgprot |= __supported_pte_mask;
4155 +
4156 for (i = 0; i < 16; i++) {
4157 pteval_t v = pgprot_val(protection_map[i]);
4158 protection_map[i] = __pgprot(v | user_pgprot);
4159 @@ -524,10 +608,15 @@ static void __init build_mem_type_table(void)
4160
4161 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4162 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4163 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4164 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4165 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4166 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4167 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4168 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4169 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4170 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4171 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4172 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4173 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4174 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4175 mem_types[MT_ROM].prot_sect |= cp->pmd;
4176
4177 switch (cp->pmd) {
4178 @@ -1147,18 +1236,15 @@ void __init arm_mm_memblock_reserve(void)
4179 * called function. This means you can't use any function or debugging
4180 * method which may touch any device, otherwise the kernel _will_ crash.
4181 */
4182 +
4183 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4184 +
4185 static void __init devicemaps_init(struct machine_desc *mdesc)
4186 {
4187 struct map_desc map;
4188 unsigned long addr;
4189 - void *vectors;
4190
4191 - /*
4192 - * Allocate the vector page early.
4193 - */
4194 - vectors = early_alloc(PAGE_SIZE);
4195 -
4196 - early_trap_init(vectors);
4197 + early_trap_init(&vectors);
4198
4199 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4200 pmd_clear(pmd_off_k(addr));
4201 @@ -1198,7 +1284,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4202 * location (0xffff0000). If we aren't using high-vectors, also
4203 * create a mapping at the low-vectors virtual address.
4204 */
4205 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4206 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4207 map.virtual = 0xffff0000;
4208 map.length = PAGE_SIZE;
4209 map.type = MT_HIGH_VECTORS;
4210 @@ -1256,8 +1342,39 @@ static void __init map_lowmem(void)
4211 map.pfn = __phys_to_pfn(start);
4212 map.virtual = __phys_to_virt(start);
4213 map.length = end - start;
4214 - map.type = MT_MEMORY;
4215
4216 +#ifdef CONFIG_PAX_KERNEXEC
4217 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4218 + struct map_desc kernel;
4219 + struct map_desc initmap;
4220 +
4221 + /* when freeing initmem we will make this RW */
4222 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4223 + initmap.virtual = (unsigned long)__init_begin;
4224 + initmap.length = _sdata - __init_begin;
4225 + initmap.type = MT_MEMORY_RWX;
4226 + create_mapping(&initmap);
4227 +
4228 + /* when freeing initmem we will make this RX */
4229 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4230 + kernel.virtual = (unsigned long)_stext;
4231 + kernel.length = __init_begin - _stext;
4232 + kernel.type = MT_MEMORY_RWX;
4233 + create_mapping(&kernel);
4234 +
4235 + if (map.virtual < (unsigned long)_stext) {
4236 + map.length = (unsigned long)_stext - map.virtual;
4237 + map.type = MT_MEMORY_RWX;
4238 + create_mapping(&map);
4239 + }
4240 +
4241 + map.pfn = __phys_to_pfn(__pa(_sdata));
4242 + map.virtual = (unsigned long)_sdata;
4243 + map.length = end - __pa(_sdata);
4244 + }
4245 +#endif
4246 +
4247 + map.type = MT_MEMORY_RW;
4248 create_mapping(&map);
4249 }
4250 }
4251 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4252 index 78f520b..31f0cb6 100644
4253 --- a/arch/arm/mm/proc-v7-2level.S
4254 +++ b/arch/arm/mm/proc-v7-2level.S
4255 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4256 tst r1, #L_PTE_XN
4257 orrne r3, r3, #PTE_EXT_XN
4258
4259 + tst r1, #L_PTE_PXN
4260 + orrne r3, r3, #PTE_EXT_PXN
4261 +
4262 tst r1, #L_PTE_YOUNG
4263 tstne r1, #L_PTE_VALID
4264 #ifndef CONFIG_CPU_USE_DOMAINS
4265 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4266 index a5bc92d..0bb4730 100644
4267 --- a/arch/arm/plat-omap/sram.c
4268 +++ b/arch/arm/plat-omap/sram.c
4269 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4270 * Looks like we need to preserve some bootloader code at the
4271 * beginning of SRAM for jumping to flash for reboot to work...
4272 */
4273 + pax_open_kernel();
4274 memset_io(omap_sram_base + omap_sram_skip, 0,
4275 omap_sram_size - omap_sram_skip);
4276 + pax_close_kernel();
4277 }
4278 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4279 index 1141782..0959d64 100644
4280 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4281 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4282 @@ -48,7 +48,7 @@ struct samsung_dma_ops {
4283 int (*started)(unsigned ch);
4284 int (*flush)(unsigned ch);
4285 int (*stop)(unsigned ch);
4286 -};
4287 +} __no_const;
4288
4289 extern void *samsung_dmadev_get_ops(void);
4290 extern void *s3c_dma_get_ops(void);
4291 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4292 index f4726dc..39ed646 100644
4293 --- a/arch/arm64/kernel/debug-monitors.c
4294 +++ b/arch/arm64/kernel/debug-monitors.c
4295 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4296 return NOTIFY_OK;
4297 }
4298
4299 -static struct notifier_block __cpuinitdata os_lock_nb = {
4300 +static struct notifier_block os_lock_nb = {
4301 .notifier_call = os_lock_notify,
4302 };
4303
4304 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4305 index 5ab825c..96aaec8 100644
4306 --- a/arch/arm64/kernel/hw_breakpoint.c
4307 +++ b/arch/arm64/kernel/hw_breakpoint.c
4308 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4309 return NOTIFY_OK;
4310 }
4311
4312 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4313 +static struct notifier_block hw_breakpoint_reset_nb = {
4314 .notifier_call = hw_breakpoint_reset_notify,
4315 };
4316
4317 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4318 index c3a58a1..78fbf54 100644
4319 --- a/arch/avr32/include/asm/cache.h
4320 +++ b/arch/avr32/include/asm/cache.h
4321 @@ -1,8 +1,10 @@
4322 #ifndef __ASM_AVR32_CACHE_H
4323 #define __ASM_AVR32_CACHE_H
4324
4325 +#include <linux/const.h>
4326 +
4327 #define L1_CACHE_SHIFT 5
4328 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4329 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4330
4331 /*
4332 * Memory returned by kmalloc() may be used for DMA, so we must make
4333 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4334 index d232888..87c8df1 100644
4335 --- a/arch/avr32/include/asm/elf.h
4336 +++ b/arch/avr32/include/asm/elf.h
4337 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4338 the loader. We need to make sure that it is out of the way of the program
4339 that it will "exec", and that there is sufficient room for the brk. */
4340
4341 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4342 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4343
4344 +#ifdef CONFIG_PAX_ASLR
4345 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4346 +
4347 +#define PAX_DELTA_MMAP_LEN 15
4348 +#define PAX_DELTA_STACK_LEN 15
4349 +#endif
4350
4351 /* This yields a mask that user programs can use to figure out what
4352 instruction set this CPU supports. This could be done in user space,
4353 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4354 index 479330b..53717a8 100644
4355 --- a/arch/avr32/include/asm/kmap_types.h
4356 +++ b/arch/avr32/include/asm/kmap_types.h
4357 @@ -2,9 +2,9 @@
4358 #define __ASM_AVR32_KMAP_TYPES_H
4359
4360 #ifdef CONFIG_DEBUG_HIGHMEM
4361 -# define KM_TYPE_NR 29
4362 +# define KM_TYPE_NR 30
4363 #else
4364 -# define KM_TYPE_NR 14
4365 +# define KM_TYPE_NR 15
4366 #endif
4367
4368 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4369 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4370 index b2f2d2d..d1c85cb 100644
4371 --- a/arch/avr32/mm/fault.c
4372 +++ b/arch/avr32/mm/fault.c
4373 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4374
4375 int exception_trace = 1;
4376
4377 +#ifdef CONFIG_PAX_PAGEEXEC
4378 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4379 +{
4380 + unsigned long i;
4381 +
4382 + printk(KERN_ERR "PAX: bytes at PC: ");
4383 + for (i = 0; i < 20; i++) {
4384 + unsigned char c;
4385 + if (get_user(c, (unsigned char *)pc+i))
4386 + printk(KERN_CONT "???????? ");
4387 + else
4388 + printk(KERN_CONT "%02x ", c);
4389 + }
4390 + printk("\n");
4391 +}
4392 +#endif
4393 +
4394 /*
4395 * This routine handles page faults. It determines the address and the
4396 * problem, and then passes it off to one of the appropriate routines.
4397 @@ -174,6 +191,16 @@ bad_area:
4398 up_read(&mm->mmap_sem);
4399
4400 if (user_mode(regs)) {
4401 +
4402 +#ifdef CONFIG_PAX_PAGEEXEC
4403 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4404 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4405 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4406 + do_group_exit(SIGKILL);
4407 + }
4408 + }
4409 +#endif
4410 +
4411 if (exception_trace && printk_ratelimit())
4412 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4413 "sp %08lx ecr %lu\n",
4414 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4415 index 568885a..f8008df 100644
4416 --- a/arch/blackfin/include/asm/cache.h
4417 +++ b/arch/blackfin/include/asm/cache.h
4418 @@ -7,6 +7,7 @@
4419 #ifndef __ARCH_BLACKFIN_CACHE_H
4420 #define __ARCH_BLACKFIN_CACHE_H
4421
4422 +#include <linux/const.h>
4423 #include <linux/linkage.h> /* for asmlinkage */
4424
4425 /*
4426 @@ -14,7 +15,7 @@
4427 * Blackfin loads 32 bytes for cache
4428 */
4429 #define L1_CACHE_SHIFT 5
4430 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4431 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4432 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4433
4434 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4435 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4436 index aea2718..3639a60 100644
4437 --- a/arch/cris/include/arch-v10/arch/cache.h
4438 +++ b/arch/cris/include/arch-v10/arch/cache.h
4439 @@ -1,8 +1,9 @@
4440 #ifndef _ASM_ARCH_CACHE_H
4441 #define _ASM_ARCH_CACHE_H
4442
4443 +#include <linux/const.h>
4444 /* Etrax 100LX have 32-byte cache-lines. */
4445 -#define L1_CACHE_BYTES 32
4446 #define L1_CACHE_SHIFT 5
4447 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4448
4449 #endif /* _ASM_ARCH_CACHE_H */
4450 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4451 index 7caf25d..ee65ac5 100644
4452 --- a/arch/cris/include/arch-v32/arch/cache.h
4453 +++ b/arch/cris/include/arch-v32/arch/cache.h
4454 @@ -1,11 +1,12 @@
4455 #ifndef _ASM_CRIS_ARCH_CACHE_H
4456 #define _ASM_CRIS_ARCH_CACHE_H
4457
4458 +#include <linux/const.h>
4459 #include <arch/hwregs/dma.h>
4460
4461 /* A cache-line is 32 bytes. */
4462 -#define L1_CACHE_BYTES 32
4463 #define L1_CACHE_SHIFT 5
4464 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4465
4466 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4467
4468 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4469 index b86329d..6709906 100644
4470 --- a/arch/frv/include/asm/atomic.h
4471 +++ b/arch/frv/include/asm/atomic.h
4472 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4473 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4474 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4475
4476 +#define atomic64_read_unchecked(v) atomic64_read(v)
4477 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4478 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4479 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4480 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4481 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4482 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4483 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4484 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4485 +
4486 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4487 {
4488 int c, old;
4489 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4490 index 2797163..c2a401d 100644
4491 --- a/arch/frv/include/asm/cache.h
4492 +++ b/arch/frv/include/asm/cache.h
4493 @@ -12,10 +12,11 @@
4494 #ifndef __ASM_CACHE_H
4495 #define __ASM_CACHE_H
4496
4497 +#include <linux/const.h>
4498
4499 /* bytes per L1 cache line */
4500 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4501 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4502 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4503
4504 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4505 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4506 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4507 index 43901f2..0d8b865 100644
4508 --- a/arch/frv/include/asm/kmap_types.h
4509 +++ b/arch/frv/include/asm/kmap_types.h
4510 @@ -2,6 +2,6 @@
4511 #ifndef _ASM_KMAP_TYPES_H
4512 #define _ASM_KMAP_TYPES_H
4513
4514 -#define KM_TYPE_NR 17
4515 +#define KM_TYPE_NR 18
4516
4517 #endif
4518 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4519 index 836f147..4cf23f5 100644
4520 --- a/arch/frv/mm/elf-fdpic.c
4521 +++ b/arch/frv/mm/elf-fdpic.c
4522 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4523 {
4524 struct vm_area_struct *vma;
4525 struct vm_unmapped_area_info info;
4526 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4527
4528 if (len > TASK_SIZE)
4529 return -ENOMEM;
4530 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4531 if (addr) {
4532 addr = PAGE_ALIGN(addr);
4533 vma = find_vma(current->mm, addr);
4534 - if (TASK_SIZE - len >= addr &&
4535 - (!vma || addr + len <= vma->vm_start))
4536 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4537 goto success;
4538 }
4539
4540 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4541 info.high_limit = (current->mm->start_stack - 0x00200000);
4542 info.align_mask = 0;
4543 info.align_offset = 0;
4544 + info.threadstack_offset = offset;
4545 addr = vm_unmapped_area(&info);
4546 if (!(addr & ~PAGE_MASK))
4547 goto success;
4548 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4549 index f4ca594..adc72fd6 100644
4550 --- a/arch/hexagon/include/asm/cache.h
4551 +++ b/arch/hexagon/include/asm/cache.h
4552 @@ -21,9 +21,11 @@
4553 #ifndef __ASM_CACHE_H
4554 #define __ASM_CACHE_H
4555
4556 +#include <linux/const.h>
4557 +
4558 /* Bytes per L1 cache line */
4559 -#define L1_CACHE_SHIFT (5)
4560 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4561 +#define L1_CACHE_SHIFT 5
4562 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4563
4564 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4565 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4566 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4567 index 6e6fe18..a6ae668 100644
4568 --- a/arch/ia64/include/asm/atomic.h
4569 +++ b/arch/ia64/include/asm/atomic.h
4570 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4571 #define atomic64_inc(v) atomic64_add(1, (v))
4572 #define atomic64_dec(v) atomic64_sub(1, (v))
4573
4574 +#define atomic64_read_unchecked(v) atomic64_read(v)
4575 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4576 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4577 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4578 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4579 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4580 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4581 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4582 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4583 +
4584 /* Atomic operations are already serializing */
4585 #define smp_mb__before_atomic_dec() barrier()
4586 #define smp_mb__after_atomic_dec() barrier()
4587 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4588 index 988254a..e1ee885 100644
4589 --- a/arch/ia64/include/asm/cache.h
4590 +++ b/arch/ia64/include/asm/cache.h
4591 @@ -1,6 +1,7 @@
4592 #ifndef _ASM_IA64_CACHE_H
4593 #define _ASM_IA64_CACHE_H
4594
4595 +#include <linux/const.h>
4596
4597 /*
4598 * Copyright (C) 1998-2000 Hewlett-Packard Co
4599 @@ -9,7 +10,7 @@
4600
4601 /* Bytes per L1 (data) cache line. */
4602 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4603 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4604 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4605
4606 #ifdef CONFIG_SMP
4607 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4608 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4609 index 5a83c5c..4d7f553 100644
4610 --- a/arch/ia64/include/asm/elf.h
4611 +++ b/arch/ia64/include/asm/elf.h
4612 @@ -42,6 +42,13 @@
4613 */
4614 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4615
4616 +#ifdef CONFIG_PAX_ASLR
4617 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4618 +
4619 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4620 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4621 +#endif
4622 +
4623 #define PT_IA_64_UNWIND 0x70000001
4624
4625 /* IA-64 relocations: */
4626 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4627 index 96a8d92..617a1cf 100644
4628 --- a/arch/ia64/include/asm/pgalloc.h
4629 +++ b/arch/ia64/include/asm/pgalloc.h
4630 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4631 pgd_val(*pgd_entry) = __pa(pud);
4632 }
4633
4634 +static inline void
4635 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4636 +{
4637 + pgd_populate(mm, pgd_entry, pud);
4638 +}
4639 +
4640 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4641 {
4642 return quicklist_alloc(0, GFP_KERNEL, NULL);
4643 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4644 pud_val(*pud_entry) = __pa(pmd);
4645 }
4646
4647 +static inline void
4648 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4649 +{
4650 + pud_populate(mm, pud_entry, pmd);
4651 +}
4652 +
4653 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4654 {
4655 return quicklist_alloc(0, GFP_KERNEL, NULL);
4656 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4657 index 815810c..d60bd4c 100644
4658 --- a/arch/ia64/include/asm/pgtable.h
4659 +++ b/arch/ia64/include/asm/pgtable.h
4660 @@ -12,7 +12,7 @@
4661 * David Mosberger-Tang <davidm@hpl.hp.com>
4662 */
4663
4664 -
4665 +#include <linux/const.h>
4666 #include <asm/mman.h>
4667 #include <asm/page.h>
4668 #include <asm/processor.h>
4669 @@ -142,6 +142,17 @@
4670 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4671 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4672 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4673 +
4674 +#ifdef CONFIG_PAX_PAGEEXEC
4675 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4676 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4677 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4678 +#else
4679 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4680 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4681 +# define PAGE_COPY_NOEXEC PAGE_COPY
4682 +#endif
4683 +
4684 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4685 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4686 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4687 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4688 index 54ff557..70c88b7 100644
4689 --- a/arch/ia64/include/asm/spinlock.h
4690 +++ b/arch/ia64/include/asm/spinlock.h
4691 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4692 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4693
4694 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4695 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4696 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4697 }
4698
4699 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4700 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4701 index 449c8c0..18965fb 100644
4702 --- a/arch/ia64/include/asm/uaccess.h
4703 +++ b/arch/ia64/include/asm/uaccess.h
4704 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4705 static inline unsigned long
4706 __copy_to_user (void __user *to, const void *from, unsigned long count)
4707 {
4708 + if (count > INT_MAX)
4709 + return count;
4710 +
4711 + if (!__builtin_constant_p(count))
4712 + check_object_size(from, count, true);
4713 +
4714 return __copy_user(to, (__force void __user *) from, count);
4715 }
4716
4717 static inline unsigned long
4718 __copy_from_user (void *to, const void __user *from, unsigned long count)
4719 {
4720 + if (count > INT_MAX)
4721 + return count;
4722 +
4723 + if (!__builtin_constant_p(count))
4724 + check_object_size(to, count, false);
4725 +
4726 return __copy_user((__force void __user *) to, from, count);
4727 }
4728
4729 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4730 ({ \
4731 void __user *__cu_to = (to); \
4732 const void *__cu_from = (from); \
4733 - long __cu_len = (n); \
4734 + unsigned long __cu_len = (n); \
4735 \
4736 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4737 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4738 + if (!__builtin_constant_p(n)) \
4739 + check_object_size(__cu_from, __cu_len, true); \
4740 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4741 + } \
4742 __cu_len; \
4743 })
4744
4745 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4746 ({ \
4747 void *__cu_to = (to); \
4748 const void __user *__cu_from = (from); \
4749 - long __cu_len = (n); \
4750 + unsigned long __cu_len = (n); \
4751 \
4752 __chk_user_ptr(__cu_from); \
4753 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4754 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4755 + if (!__builtin_constant_p(n)) \
4756 + check_object_size(__cu_to, __cu_len, false); \
4757 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4758 + } \
4759 __cu_len; \
4760 })
4761
4762 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4763 index 2d67317..07d8bfa 100644
4764 --- a/arch/ia64/kernel/err_inject.c
4765 +++ b/arch/ia64/kernel/err_inject.c
4766 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4767 return NOTIFY_OK;
4768 }
4769
4770 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4771 +static struct notifier_block err_inject_cpu_notifier =
4772 {
4773 .notifier_call = err_inject_cpu_callback,
4774 };
4775 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4776 index d7396db..b33e873 100644
4777 --- a/arch/ia64/kernel/mca.c
4778 +++ b/arch/ia64/kernel/mca.c
4779 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4780 return NOTIFY_OK;
4781 }
4782
4783 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4784 +static struct notifier_block mca_cpu_notifier = {
4785 .notifier_call = mca_cpu_callback
4786 };
4787
4788 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4789 index 24603be..948052d 100644
4790 --- a/arch/ia64/kernel/module.c
4791 +++ b/arch/ia64/kernel/module.c
4792 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4793 void
4794 module_free (struct module *mod, void *module_region)
4795 {
4796 - if (mod && mod->arch.init_unw_table &&
4797 - module_region == mod->module_init) {
4798 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4799 unw_remove_unwind_table(mod->arch.init_unw_table);
4800 mod->arch.init_unw_table = NULL;
4801 }
4802 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4803 }
4804
4805 static inline int
4806 +in_init_rx (const struct module *mod, uint64_t addr)
4807 +{
4808 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4809 +}
4810 +
4811 +static inline int
4812 +in_init_rw (const struct module *mod, uint64_t addr)
4813 +{
4814 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4815 +}
4816 +
4817 +static inline int
4818 in_init (const struct module *mod, uint64_t addr)
4819 {
4820 - return addr - (uint64_t) mod->module_init < mod->init_size;
4821 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4822 +}
4823 +
4824 +static inline int
4825 +in_core_rx (const struct module *mod, uint64_t addr)
4826 +{
4827 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4828 +}
4829 +
4830 +static inline int
4831 +in_core_rw (const struct module *mod, uint64_t addr)
4832 +{
4833 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4834 }
4835
4836 static inline int
4837 in_core (const struct module *mod, uint64_t addr)
4838 {
4839 - return addr - (uint64_t) mod->module_core < mod->core_size;
4840 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4841 }
4842
4843 static inline int
4844 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4845 break;
4846
4847 case RV_BDREL:
4848 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4849 + if (in_init_rx(mod, val))
4850 + val -= (uint64_t) mod->module_init_rx;
4851 + else if (in_init_rw(mod, val))
4852 + val -= (uint64_t) mod->module_init_rw;
4853 + else if (in_core_rx(mod, val))
4854 + val -= (uint64_t) mod->module_core_rx;
4855 + else if (in_core_rw(mod, val))
4856 + val -= (uint64_t) mod->module_core_rw;
4857 break;
4858
4859 case RV_LTV:
4860 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4861 * addresses have been selected...
4862 */
4863 uint64_t gp;
4864 - if (mod->core_size > MAX_LTOFF)
4865 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4866 /*
4867 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4868 * at the end of the module.
4869 */
4870 - gp = mod->core_size - MAX_LTOFF / 2;
4871 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4872 else
4873 - gp = mod->core_size / 2;
4874 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4875 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4876 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4877 mod->arch.gp = gp;
4878 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4879 }
4880 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4881 index 79521d5..43dddff 100644
4882 --- a/arch/ia64/kernel/palinfo.c
4883 +++ b/arch/ia64/kernel/palinfo.c
4884 @@ -1006,7 +1006,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4885 return NOTIFY_OK;
4886 }
4887
4888 -static struct notifier_block __refdata palinfo_cpu_notifier =
4889 +static struct notifier_block palinfo_cpu_notifier =
4890 {
4891 .notifier_call = palinfo_cpu_callback,
4892 .priority = 0,
4893 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4894 index aa527d7..f237752 100644
4895 --- a/arch/ia64/kernel/salinfo.c
4896 +++ b/arch/ia64/kernel/salinfo.c
4897 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4898 return NOTIFY_OK;
4899 }
4900
4901 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4902 +static struct notifier_block salinfo_cpu_notifier =
4903 {
4904 .notifier_call = salinfo_cpu_callback,
4905 .priority = 0,
4906 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4907 index 41e33f8..65180b2 100644
4908 --- a/arch/ia64/kernel/sys_ia64.c
4909 +++ b/arch/ia64/kernel/sys_ia64.c
4910 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4911 unsigned long align_mask = 0;
4912 struct mm_struct *mm = current->mm;
4913 struct vm_unmapped_area_info info;
4914 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4915
4916 if (len > RGN_MAP_LIMIT)
4917 return -ENOMEM;
4918 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4919 if (REGION_NUMBER(addr) == RGN_HPAGE)
4920 addr = 0;
4921 #endif
4922 +
4923 +#ifdef CONFIG_PAX_RANDMMAP
4924 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4925 + addr = mm->free_area_cache;
4926 + else
4927 +#endif
4928 +
4929 if (!addr)
4930 addr = TASK_UNMAPPED_BASE;
4931
4932 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4933 info.high_limit = TASK_SIZE;
4934 info.align_mask = align_mask;
4935 info.align_offset = 0;
4936 + info.threadstack_offset = offset;
4937 return vm_unmapped_area(&info);
4938 }
4939
4940 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
4941 index dc00b2c..cce53c2 100644
4942 --- a/arch/ia64/kernel/topology.c
4943 +++ b/arch/ia64/kernel/topology.c
4944 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
4945 return NOTIFY_OK;
4946 }
4947
4948 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
4949 +static struct notifier_block cache_cpu_notifier =
4950 {
4951 .notifier_call = cache_cpu_callback
4952 };
4953 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
4954 index 0ccb28f..8992469 100644
4955 --- a/arch/ia64/kernel/vmlinux.lds.S
4956 +++ b/arch/ia64/kernel/vmlinux.lds.S
4957 @@ -198,7 +198,7 @@ SECTIONS {
4958 /* Per-cpu data: */
4959 . = ALIGN(PERCPU_PAGE_SIZE);
4960 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
4961 - __phys_per_cpu_start = __per_cpu_load;
4962 + __phys_per_cpu_start = per_cpu_load;
4963 /*
4964 * ensure percpu data fits
4965 * into percpu page size
4966 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
4967 index 6cf0341..d352594 100644
4968 --- a/arch/ia64/mm/fault.c
4969 +++ b/arch/ia64/mm/fault.c
4970 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
4971 return pte_present(pte);
4972 }
4973
4974 +#ifdef CONFIG_PAX_PAGEEXEC
4975 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4976 +{
4977 + unsigned long i;
4978 +
4979 + printk(KERN_ERR "PAX: bytes at PC: ");
4980 + for (i = 0; i < 8; i++) {
4981 + unsigned int c;
4982 + if (get_user(c, (unsigned int *)pc+i))
4983 + printk(KERN_CONT "???????? ");
4984 + else
4985 + printk(KERN_CONT "%08x ", c);
4986 + }
4987 + printk("\n");
4988 +}
4989 +#endif
4990 +
4991 # define VM_READ_BIT 0
4992 # define VM_WRITE_BIT 1
4993 # define VM_EXEC_BIT 2
4994 @@ -149,8 +166,21 @@ retry:
4995 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
4996 goto bad_area;
4997
4998 - if ((vma->vm_flags & mask) != mask)
4999 + if ((vma->vm_flags & mask) != mask) {
5000 +
5001 +#ifdef CONFIG_PAX_PAGEEXEC
5002 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5003 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5004 + goto bad_area;
5005 +
5006 + up_read(&mm->mmap_sem);
5007 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5008 + do_group_exit(SIGKILL);
5009 + }
5010 +#endif
5011 +
5012 goto bad_area;
5013 + }
5014
5015 /*
5016 * If for any reason at all we couldn't handle the fault, make
5017 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5018 index 76069c1..c2aa816 100644
5019 --- a/arch/ia64/mm/hugetlbpage.c
5020 +++ b/arch/ia64/mm/hugetlbpage.c
5021 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5022 unsigned long pgoff, unsigned long flags)
5023 {
5024 struct vm_unmapped_area_info info;
5025 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5026
5027 if (len > RGN_MAP_LIMIT)
5028 return -ENOMEM;
5029 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5030 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5031 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5032 info.align_offset = 0;
5033 + info.threadstack_offset = offset;
5034 return vm_unmapped_area(&info);
5035 }
5036
5037 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5038 index 20bc967..a26993e 100644
5039 --- a/arch/ia64/mm/init.c
5040 +++ b/arch/ia64/mm/init.c
5041 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5042 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5043 vma->vm_end = vma->vm_start + PAGE_SIZE;
5044 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5045 +
5046 +#ifdef CONFIG_PAX_PAGEEXEC
5047 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5048 + vma->vm_flags &= ~VM_EXEC;
5049 +
5050 +#ifdef CONFIG_PAX_MPROTECT
5051 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5052 + vma->vm_flags &= ~VM_MAYEXEC;
5053 +#endif
5054 +
5055 + }
5056 +#endif
5057 +
5058 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5059 down_write(&current->mm->mmap_sem);
5060 if (insert_vm_struct(current->mm, vma)) {
5061 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5062 index 40b3ee9..8c2c112 100644
5063 --- a/arch/m32r/include/asm/cache.h
5064 +++ b/arch/m32r/include/asm/cache.h
5065 @@ -1,8 +1,10 @@
5066 #ifndef _ASM_M32R_CACHE_H
5067 #define _ASM_M32R_CACHE_H
5068
5069 +#include <linux/const.h>
5070 +
5071 /* L1 cache line size */
5072 #define L1_CACHE_SHIFT 4
5073 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5074 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5075
5076 #endif /* _ASM_M32R_CACHE_H */
5077 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5078 index 82abd15..d95ae5d 100644
5079 --- a/arch/m32r/lib/usercopy.c
5080 +++ b/arch/m32r/lib/usercopy.c
5081 @@ -14,6 +14,9 @@
5082 unsigned long
5083 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5084 {
5085 + if ((long)n < 0)
5086 + return n;
5087 +
5088 prefetch(from);
5089 if (access_ok(VERIFY_WRITE, to, n))
5090 __copy_user(to,from,n);
5091 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5092 unsigned long
5093 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5094 {
5095 + if ((long)n < 0)
5096 + return n;
5097 +
5098 prefetchw(to);
5099 if (access_ok(VERIFY_READ, from, n))
5100 __copy_user_zeroing(to,from,n);
5101 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5102 index 0395c51..5f26031 100644
5103 --- a/arch/m68k/include/asm/cache.h
5104 +++ b/arch/m68k/include/asm/cache.h
5105 @@ -4,9 +4,11 @@
5106 #ifndef __ARCH_M68K_CACHE_H
5107 #define __ARCH_M68K_CACHE_H
5108
5109 +#include <linux/const.h>
5110 +
5111 /* bytes per L1 cache line */
5112 #define L1_CACHE_SHIFT 4
5113 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5114 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5115
5116 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5117
5118 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5119 index 3c52fa6..11b2ad8 100644
5120 --- a/arch/metag/mm/hugetlbpage.c
5121 +++ b/arch/metag/mm/hugetlbpage.c
5122 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5123 info.high_limit = TASK_SIZE;
5124 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5125 info.align_offset = 0;
5126 + info.threadstack_offset = 0;
5127 return vm_unmapped_area(&info);
5128 }
5129
5130 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5131 index 4efe96a..60e8699 100644
5132 --- a/arch/microblaze/include/asm/cache.h
5133 +++ b/arch/microblaze/include/asm/cache.h
5134 @@ -13,11 +13,12 @@
5135 #ifndef _ASM_MICROBLAZE_CACHE_H
5136 #define _ASM_MICROBLAZE_CACHE_H
5137
5138 +#include <linux/const.h>
5139 #include <asm/registers.h>
5140
5141 #define L1_CACHE_SHIFT 5
5142 /* word-granular cache in microblaze */
5143 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5144 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5145
5146 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5147
5148 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5149 index 08b6079..eb272cf 100644
5150 --- a/arch/mips/include/asm/atomic.h
5151 +++ b/arch/mips/include/asm/atomic.h
5152 @@ -21,6 +21,10 @@
5153 #include <asm/cmpxchg.h>
5154 #include <asm/war.h>
5155
5156 +#ifdef CONFIG_GENERIC_ATOMIC64
5157 +#include <asm-generic/atomic64.h>
5158 +#endif
5159 +
5160 #define ATOMIC_INIT(i) { (i) }
5161
5162 /*
5163 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5164 */
5165 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5166
5167 +#define atomic64_read_unchecked(v) atomic64_read(v)
5168 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5169 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5170 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5171 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5172 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5173 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5174 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5175 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5176 +
5177 #endif /* CONFIG_64BIT */
5178
5179 /*
5180 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5181 index b4db69f..8f3b093 100644
5182 --- a/arch/mips/include/asm/cache.h
5183 +++ b/arch/mips/include/asm/cache.h
5184 @@ -9,10 +9,11 @@
5185 #ifndef _ASM_CACHE_H
5186 #define _ASM_CACHE_H
5187
5188 +#include <linux/const.h>
5189 #include <kmalloc.h>
5190
5191 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5192 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5193 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5194
5195 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5196 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5197 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5198 index cf3ae24..238d22f 100644
5199 --- a/arch/mips/include/asm/elf.h
5200 +++ b/arch/mips/include/asm/elf.h
5201 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5202 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5203 #endif
5204
5205 +#ifdef CONFIG_PAX_ASLR
5206 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5207 +
5208 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5209 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5210 +#endif
5211 +
5212 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5213 struct linux_binprm;
5214 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5215 int uses_interp);
5216
5217 -struct mm_struct;
5218 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5219 -#define arch_randomize_brk arch_randomize_brk
5220 -
5221 #endif /* _ASM_ELF_H */
5222 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5223 index c1f6afa..38cc6e9 100644
5224 --- a/arch/mips/include/asm/exec.h
5225 +++ b/arch/mips/include/asm/exec.h
5226 @@ -12,6 +12,6 @@
5227 #ifndef _ASM_EXEC_H
5228 #define _ASM_EXEC_H
5229
5230 -extern unsigned long arch_align_stack(unsigned long sp);
5231 +#define arch_align_stack(x) ((x) & ~0xfUL)
5232
5233 #endif /* _ASM_EXEC_H */
5234 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5235 index eab99e5..607c98e 100644
5236 --- a/arch/mips/include/asm/page.h
5237 +++ b/arch/mips/include/asm/page.h
5238 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5239 #ifdef CONFIG_CPU_MIPS32
5240 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5241 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5242 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5243 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5244 #else
5245 typedef struct { unsigned long long pte; } pte_t;
5246 #define pte_val(x) ((x).pte)
5247 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5248 index 881d18b..cea38bc 100644
5249 --- a/arch/mips/include/asm/pgalloc.h
5250 +++ b/arch/mips/include/asm/pgalloc.h
5251 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5252 {
5253 set_pud(pud, __pud((unsigned long)pmd));
5254 }
5255 +
5256 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5257 +{
5258 + pud_populate(mm, pud, pmd);
5259 +}
5260 #endif
5261
5262 /*
5263 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5264 index 178f792..8ebc510 100644
5265 --- a/arch/mips/include/asm/thread_info.h
5266 +++ b/arch/mips/include/asm/thread_info.h
5267 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5268 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5269 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5270 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5271 +/* li takes a 32bit immediate */
5272 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5273 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5274
5275 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5276 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5277 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5278 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5279 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5280 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5281 +
5282 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5283
5284 /* work to do in syscall_trace_leave() */
5285 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5286 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5287
5288 /* work to do on interrupt/exception return */
5289 #define _TIF_WORK_MASK \
5290 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5291 /* work to do on any return to u-space */
5292 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5293 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5294
5295 #endif /* __KERNEL__ */
5296
5297 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5298 index e06f777..3244284 100644
5299 --- a/arch/mips/kernel/binfmt_elfn32.c
5300 +++ b/arch/mips/kernel/binfmt_elfn32.c
5301 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5302 #undef ELF_ET_DYN_BASE
5303 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5304
5305 +#ifdef CONFIG_PAX_ASLR
5306 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5307 +
5308 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5309 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5310 +#endif
5311 +
5312 #include <asm/processor.h>
5313 #include <linux/module.h>
5314 #include <linux/elfcore.h>
5315 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5316 index 556a435..b4fd2e3 100644
5317 --- a/arch/mips/kernel/binfmt_elfo32.c
5318 +++ b/arch/mips/kernel/binfmt_elfo32.c
5319 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5320 #undef ELF_ET_DYN_BASE
5321 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5322
5323 +#ifdef CONFIG_PAX_ASLR
5324 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5325 +
5326 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5327 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5328 +#endif
5329 +
5330 #include <asm/processor.h>
5331
5332 /*
5333 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5334 index 3be4405..a799827 100644
5335 --- a/arch/mips/kernel/process.c
5336 +++ b/arch/mips/kernel/process.c
5337 @@ -461,15 +461,3 @@ unsigned long get_wchan(struct task_struct *task)
5338 out:
5339 return pc;
5340 }
5341 -
5342 -/*
5343 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5344 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5345 - */
5346 -unsigned long arch_align_stack(unsigned long sp)
5347 -{
5348 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5349 - sp -= get_random_int() & ~PAGE_MASK;
5350 -
5351 - return sp & ALMASK;
5352 -}
5353 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5354 index 9c6299c..2fb4c22 100644
5355 --- a/arch/mips/kernel/ptrace.c
5356 +++ b/arch/mips/kernel/ptrace.c
5357 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5358 return arch;
5359 }
5360
5361 +#ifdef CONFIG_GRKERNSEC_SETXID
5362 +extern void gr_delayed_cred_worker(void);
5363 +#endif
5364 +
5365 /*
5366 * Notification of system call entry/exit
5367 * - triggered by current->work.syscall_trace
5368 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5369 /* do the secure computing check first */
5370 secure_computing_strict(regs->regs[2]);
5371
5372 +#ifdef CONFIG_GRKERNSEC_SETXID
5373 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5374 + gr_delayed_cred_worker();
5375 +#endif
5376 +
5377 if (!(current->ptrace & PT_PTRACED))
5378 goto out;
5379
5380 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5381 index 9ea2964..c4329c3 100644
5382 --- a/arch/mips/kernel/scall32-o32.S
5383 +++ b/arch/mips/kernel/scall32-o32.S
5384 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5385
5386 stack_done:
5387 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5388 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5389 + li t1, _TIF_SYSCALL_WORK
5390 and t0, t1
5391 bnez t0, syscall_trace_entry # -> yes
5392
5393 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5394 index 36cfd40..b1436e0 100644
5395 --- a/arch/mips/kernel/scall64-64.S
5396 +++ b/arch/mips/kernel/scall64-64.S
5397 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5398
5399 sd a3, PT_R26(sp) # save a3 for syscall restarting
5400
5401 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5402 + li t1, _TIF_SYSCALL_WORK
5403 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5404 and t0, t1, t0
5405 bnez t0, syscall_trace_entry
5406 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5407 index 693d60b..ae0ba75 100644
5408 --- a/arch/mips/kernel/scall64-n32.S
5409 +++ b/arch/mips/kernel/scall64-n32.S
5410 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5411
5412 sd a3, PT_R26(sp) # save a3 for syscall restarting
5413
5414 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5415 + li t1, _TIF_SYSCALL_WORK
5416 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5417 and t0, t1, t0
5418 bnez t0, n32_syscall_trace_entry
5419 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5420 index af8887f..611ccb6 100644
5421 --- a/arch/mips/kernel/scall64-o32.S
5422 +++ b/arch/mips/kernel/scall64-o32.S
5423 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5424 PTR 4b, bad_stack
5425 .previous
5426
5427 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5428 + li t1, _TIF_SYSCALL_WORK
5429 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5430 and t0, t1, t0
5431 bnez t0, trace_a_syscall
5432 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5433 index 0fead53..a2c0fb5 100644
5434 --- a/arch/mips/mm/fault.c
5435 +++ b/arch/mips/mm/fault.c
5436 @@ -27,6 +27,23 @@
5437 #include <asm/highmem.h> /* For VMALLOC_END */
5438 #include <linux/kdebug.h>
5439
5440 +#ifdef CONFIG_PAX_PAGEEXEC
5441 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5442 +{
5443 + unsigned long i;
5444 +
5445 + printk(KERN_ERR "PAX: bytes at PC: ");
5446 + for (i = 0; i < 5; i++) {
5447 + unsigned int c;
5448 + if (get_user(c, (unsigned int *)pc+i))
5449 + printk(KERN_CONT "???????? ");
5450 + else
5451 + printk(KERN_CONT "%08x ", c);
5452 + }
5453 + printk("\n");
5454 +}
5455 +#endif
5456 +
5457 /*
5458 * This routine handles page faults. It determines the address,
5459 * and the problem, and then passes it off to one of the appropriate
5460 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5461 index 7e5fe27..9656513 100644
5462 --- a/arch/mips/mm/mmap.c
5463 +++ b/arch/mips/mm/mmap.c
5464 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5465 struct vm_area_struct *vma;
5466 unsigned long addr = addr0;
5467 int do_color_align;
5468 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5469 struct vm_unmapped_area_info info;
5470
5471 if (unlikely(len > TASK_SIZE))
5472 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5473 do_color_align = 1;
5474
5475 /* requesting a specific address */
5476 +
5477 +#ifdef CONFIG_PAX_RANDMMAP
5478 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5479 +#endif
5480 +
5481 if (addr) {
5482 if (do_color_align)
5483 addr = COLOUR_ALIGN(addr, pgoff);
5484 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5485 addr = PAGE_ALIGN(addr);
5486
5487 vma = find_vma(mm, addr);
5488 - if (TASK_SIZE - len >= addr &&
5489 - (!vma || addr + len <= vma->vm_start))
5490 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5491 return addr;
5492 }
5493
5494 info.length = len;
5495 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5496 info.align_offset = pgoff << PAGE_SHIFT;
5497 + info.threadstack_offset = offset;
5498
5499 if (dir == DOWN) {
5500 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5501 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5502 {
5503 unsigned long random_factor = 0UL;
5504
5505 +#ifdef CONFIG_PAX_RANDMMAP
5506 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5507 +#endif
5508 +
5509 if (current->flags & PF_RANDOMIZE) {
5510 random_factor = get_random_int();
5511 random_factor = random_factor << PAGE_SHIFT;
5512 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5513
5514 if (mmap_is_legacy()) {
5515 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5516 +
5517 +#ifdef CONFIG_PAX_RANDMMAP
5518 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5519 + mm->mmap_base += mm->delta_mmap;
5520 +#endif
5521 +
5522 mm->get_unmapped_area = arch_get_unmapped_area;
5523 mm->unmap_area = arch_unmap_area;
5524 } else {
5525 mm->mmap_base = mmap_base(random_factor);
5526 +
5527 +#ifdef CONFIG_PAX_RANDMMAP
5528 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5529 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5530 +#endif
5531 +
5532 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5533 mm->unmap_area = arch_unmap_area_topdown;
5534 }
5535 }
5536
5537 -static inline unsigned long brk_rnd(void)
5538 -{
5539 - unsigned long rnd = get_random_int();
5540 -
5541 - rnd = rnd << PAGE_SHIFT;
5542 - /* 8MB for 32bit, 256MB for 64bit */
5543 - if (TASK_IS_32BIT_ADDR)
5544 - rnd = rnd & 0x7ffffful;
5545 - else
5546 - rnd = rnd & 0xffffffful;
5547 -
5548 - return rnd;
5549 -}
5550 -
5551 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5552 -{
5553 - unsigned long base = mm->brk;
5554 - unsigned long ret;
5555 -
5556 - ret = PAGE_ALIGN(base + brk_rnd());
5557 -
5558 - if (ret < mm->brk)
5559 - return mm->brk;
5560 -
5561 - return ret;
5562 -}
5563 -
5564 int __virt_addr_valid(const volatile void *kaddr)
5565 {
5566 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5567 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5568 index 967d144..db12197 100644
5569 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5570 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5571 @@ -11,12 +11,14 @@
5572 #ifndef _ASM_PROC_CACHE_H
5573 #define _ASM_PROC_CACHE_H
5574
5575 +#include <linux/const.h>
5576 +
5577 /* L1 cache */
5578
5579 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5580 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5581 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5582 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5583 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5584 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5585
5586 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5587 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5588 index bcb5df2..84fabd2 100644
5589 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5590 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5591 @@ -16,13 +16,15 @@
5592 #ifndef _ASM_PROC_CACHE_H
5593 #define _ASM_PROC_CACHE_H
5594
5595 +#include <linux/const.h>
5596 +
5597 /*
5598 * L1 cache
5599 */
5600 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5601 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5602 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5603 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5604 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5605 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5606
5607 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5608 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5609 index 4ce7a01..449202a 100644
5610 --- a/arch/openrisc/include/asm/cache.h
5611 +++ b/arch/openrisc/include/asm/cache.h
5612 @@ -19,11 +19,13 @@
5613 #ifndef __ASM_OPENRISC_CACHE_H
5614 #define __ASM_OPENRISC_CACHE_H
5615
5616 +#include <linux/const.h>
5617 +
5618 /* FIXME: How can we replace these with values from the CPU...
5619 * they shouldn't be hard-coded!
5620 */
5621
5622 -#define L1_CACHE_BYTES 16
5623 #define L1_CACHE_SHIFT 4
5624 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5625
5626 #endif /* __ASM_OPENRISC_CACHE_H */
5627 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5628 index f38e198..4179e38 100644
5629 --- a/arch/parisc/include/asm/atomic.h
5630 +++ b/arch/parisc/include/asm/atomic.h
5631 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5632
5633 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5634
5635 +#define atomic64_read_unchecked(v) atomic64_read(v)
5636 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5637 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5638 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5639 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5640 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5641 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5642 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5643 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5644 +
5645 #endif /* !CONFIG_64BIT */
5646
5647
5648 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5649 index 47f11c7..3420df2 100644
5650 --- a/arch/parisc/include/asm/cache.h
5651 +++ b/arch/parisc/include/asm/cache.h
5652 @@ -5,6 +5,7 @@
5653 #ifndef __ARCH_PARISC_CACHE_H
5654 #define __ARCH_PARISC_CACHE_H
5655
5656 +#include <linux/const.h>
5657
5658 /*
5659 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5660 @@ -15,13 +16,13 @@
5661 * just ruin performance.
5662 */
5663 #ifdef CONFIG_PA20
5664 -#define L1_CACHE_BYTES 64
5665 #define L1_CACHE_SHIFT 6
5666 #else
5667 -#define L1_CACHE_BYTES 32
5668 #define L1_CACHE_SHIFT 5
5669 #endif
5670
5671 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5672 +
5673 #ifndef __ASSEMBLY__
5674
5675 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5676 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5677 index ad2b503..bdf1651 100644
5678 --- a/arch/parisc/include/asm/elf.h
5679 +++ b/arch/parisc/include/asm/elf.h
5680 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5681
5682 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5683
5684 +#ifdef CONFIG_PAX_ASLR
5685 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5686 +
5687 +#define PAX_DELTA_MMAP_LEN 16
5688 +#define PAX_DELTA_STACK_LEN 16
5689 +#endif
5690 +
5691 /* This yields a mask that user programs can use to figure out what
5692 instruction set this CPU supports. This could be done in user space,
5693 but it's not easy, and we've already done it here. */
5694 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5695 index fc987a1..6e068ef 100644
5696 --- a/arch/parisc/include/asm/pgalloc.h
5697 +++ b/arch/parisc/include/asm/pgalloc.h
5698 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5699 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5700 }
5701
5702 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5703 +{
5704 + pgd_populate(mm, pgd, pmd);
5705 +}
5706 +
5707 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5708 {
5709 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5710 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5711 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5712 #define pmd_free(mm, x) do { } while (0)
5713 #define pgd_populate(mm, pmd, pte) BUG()
5714 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5715
5716 #endif
5717
5718 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5719 index 1e40d7f..a3eb445 100644
5720 --- a/arch/parisc/include/asm/pgtable.h
5721 +++ b/arch/parisc/include/asm/pgtable.h
5722 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5723 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5724 #define PAGE_COPY PAGE_EXECREAD
5725 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5726 +
5727 +#ifdef CONFIG_PAX_PAGEEXEC
5728 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5729 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5730 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5731 +#else
5732 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5733 +# define PAGE_COPY_NOEXEC PAGE_COPY
5734 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5735 +#endif
5736 +
5737 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5738 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5739 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5740 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5741 index e0a8235..ce2f1e1 100644
5742 --- a/arch/parisc/include/asm/uaccess.h
5743 +++ b/arch/parisc/include/asm/uaccess.h
5744 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5745 const void __user *from,
5746 unsigned long n)
5747 {
5748 - int sz = __compiletime_object_size(to);
5749 + size_t sz = __compiletime_object_size(to);
5750 int ret = -EFAULT;
5751
5752 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5753 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5754 ret = __copy_from_user(to, from, n);
5755 else
5756 copy_from_user_overflow();
5757 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5758 index 2a625fb..9908930 100644
5759 --- a/arch/parisc/kernel/module.c
5760 +++ b/arch/parisc/kernel/module.c
5761 @@ -98,16 +98,38 @@
5762
5763 /* three functions to determine where in the module core
5764 * or init pieces the location is */
5765 +static inline int in_init_rx(struct module *me, void *loc)
5766 +{
5767 + return (loc >= me->module_init_rx &&
5768 + loc < (me->module_init_rx + me->init_size_rx));
5769 +}
5770 +
5771 +static inline int in_init_rw(struct module *me, void *loc)
5772 +{
5773 + return (loc >= me->module_init_rw &&
5774 + loc < (me->module_init_rw + me->init_size_rw));
5775 +}
5776 +
5777 static inline int in_init(struct module *me, void *loc)
5778 {
5779 - return (loc >= me->module_init &&
5780 - loc <= (me->module_init + me->init_size));
5781 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5782 +}
5783 +
5784 +static inline int in_core_rx(struct module *me, void *loc)
5785 +{
5786 + return (loc >= me->module_core_rx &&
5787 + loc < (me->module_core_rx + me->core_size_rx));
5788 +}
5789 +
5790 +static inline int in_core_rw(struct module *me, void *loc)
5791 +{
5792 + return (loc >= me->module_core_rw &&
5793 + loc < (me->module_core_rw + me->core_size_rw));
5794 }
5795
5796 static inline int in_core(struct module *me, void *loc)
5797 {
5798 - return (loc >= me->module_core &&
5799 - loc <= (me->module_core + me->core_size));
5800 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5801 }
5802
5803 static inline int in_local(struct module *me, void *loc)
5804 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5805 }
5806
5807 /* align things a bit */
5808 - me->core_size = ALIGN(me->core_size, 16);
5809 - me->arch.got_offset = me->core_size;
5810 - me->core_size += gots * sizeof(struct got_entry);
5811 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5812 + me->arch.got_offset = me->core_size_rw;
5813 + me->core_size_rw += gots * sizeof(struct got_entry);
5814
5815 - me->core_size = ALIGN(me->core_size, 16);
5816 - me->arch.fdesc_offset = me->core_size;
5817 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5818 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5819 + me->arch.fdesc_offset = me->core_size_rw;
5820 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5821
5822 me->arch.got_max = gots;
5823 me->arch.fdesc_max = fdescs;
5824 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5825
5826 BUG_ON(value == 0);
5827
5828 - got = me->module_core + me->arch.got_offset;
5829 + got = me->module_core_rw + me->arch.got_offset;
5830 for (i = 0; got[i].addr; i++)
5831 if (got[i].addr == value)
5832 goto out;
5833 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5834 #ifdef CONFIG_64BIT
5835 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5836 {
5837 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5838 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5839
5840 if (!value) {
5841 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5842 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5843
5844 /* Create new one */
5845 fdesc->addr = value;
5846 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5847 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5848 return (Elf_Addr)fdesc;
5849 }
5850 #endif /* CONFIG_64BIT */
5851 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5852
5853 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5854 end = table + sechdrs[me->arch.unwind_section].sh_size;
5855 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5856 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5857
5858 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5859 me->arch.unwind_section, table, end, gp);
5860 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5861 index 5dfd248..64914ac 100644
5862 --- a/arch/parisc/kernel/sys_parisc.c
5863 +++ b/arch/parisc/kernel/sys_parisc.c
5864 @@ -33,9 +33,11 @@
5865 #include <linux/utsname.h>
5866 #include <linux/personality.h>
5867
5868 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5869 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5870 + unsigned long flags)
5871 {
5872 struct vm_unmapped_area_info info;
5873 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5874
5875 info.flags = 0;
5876 info.length = len;
5877 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5878 info.high_limit = TASK_SIZE;
5879 info.align_mask = 0;
5880 info.align_offset = 0;
5881 + info.threadstack_offset = offset;
5882 return vm_unmapped_area(&info);
5883 }
5884
5885 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5886 return (unsigned long) mapping >> 8;
5887 }
5888
5889 -static unsigned long get_shared_area(struct address_space *mapping,
5890 - unsigned long addr, unsigned long len, unsigned long pgoff)
5891 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5892 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5893 {
5894 struct vm_unmapped_area_info info;
5895 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5896
5897 info.flags = 0;
5898 info.length = len;
5899 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5900 info.high_limit = TASK_SIZE;
5901 info.align_mask = PAGE_MASK & (SHMLBA - 1);
5902 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
5903 + info.threadstack_offset = offset;
5904 return vm_unmapped_area(&info);
5905 }
5906
5907 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5908 return -EINVAL;
5909 return addr;
5910 }
5911 - if (!addr)
5912 + if (!addr) {
5913 addr = TASK_UNMAPPED_BASE;
5914
5915 +#ifdef CONFIG_PAX_RANDMMAP
5916 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
5917 + addr += current->mm->delta_mmap;
5918 +#endif
5919 +
5920 + }
5921 +
5922 if (filp) {
5923 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
5924 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
5925 } else if(flags & MAP_SHARED) {
5926 - addr = get_shared_area(NULL, addr, len, pgoff);
5927 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
5928 } else {
5929 - addr = get_unshared_area(addr, len);
5930 + addr = get_unshared_area(filp, addr, len, flags);
5931 }
5932 return addr;
5933 }
5934 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
5935 index c6ae9f5..e9c3cf4 100644
5936 --- a/arch/parisc/kernel/traps.c
5937 +++ b/arch/parisc/kernel/traps.c
5938 @@ -733,9 +733,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
5939
5940 down_read(&current->mm->mmap_sem);
5941 vma = find_vma(current->mm,regs->iaoq[0]);
5942 - if (vma && (regs->iaoq[0] >= vma->vm_start)
5943 - && (vma->vm_flags & VM_EXEC)) {
5944 -
5945 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
5946 fault_address = regs->iaoq[0];
5947 fault_space = regs->iasq[0];
5948
5949 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
5950 index f247a34..dc0f219 100644
5951 --- a/arch/parisc/mm/fault.c
5952 +++ b/arch/parisc/mm/fault.c
5953 @@ -15,6 +15,7 @@
5954 #include <linux/sched.h>
5955 #include <linux/interrupt.h>
5956 #include <linux/module.h>
5957 +#include <linux/unistd.h>
5958
5959 #include <asm/uaccess.h>
5960 #include <asm/traps.h>
5961 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
5962 static unsigned long
5963 parisc_acctyp(unsigned long code, unsigned int inst)
5964 {
5965 - if (code == 6 || code == 16)
5966 + if (code == 6 || code == 7 || code == 16)
5967 return VM_EXEC;
5968
5969 switch (inst & 0xf0000000) {
5970 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
5971 }
5972 #endif
5973
5974 +#ifdef CONFIG_PAX_PAGEEXEC
5975 +/*
5976 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
5977 + *
5978 + * returns 1 when task should be killed
5979 + * 2 when rt_sigreturn trampoline was detected
5980 + * 3 when unpatched PLT trampoline was detected
5981 + */
5982 +static int pax_handle_fetch_fault(struct pt_regs *regs)
5983 +{
5984 +
5985 +#ifdef CONFIG_PAX_EMUPLT
5986 + int err;
5987 +
5988 + do { /* PaX: unpatched PLT emulation */
5989 + unsigned int bl, depwi;
5990 +
5991 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
5992 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
5993 +
5994 + if (err)
5995 + break;
5996 +
5997 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
5998 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
5999 +
6000 + err = get_user(ldw, (unsigned int *)addr);
6001 + err |= get_user(bv, (unsigned int *)(addr+4));
6002 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6003 +
6004 + if (err)
6005 + break;
6006 +
6007 + if (ldw == 0x0E801096U &&
6008 + bv == 0xEAC0C000U &&
6009 + ldw2 == 0x0E881095U)
6010 + {
6011 + unsigned int resolver, map;
6012 +
6013 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6014 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6015 + if (err)
6016 + break;
6017 +
6018 + regs->gr[20] = instruction_pointer(regs)+8;
6019 + regs->gr[21] = map;
6020 + regs->gr[22] = resolver;
6021 + regs->iaoq[0] = resolver | 3UL;
6022 + regs->iaoq[1] = regs->iaoq[0] + 4;
6023 + return 3;
6024 + }
6025 + }
6026 + } while (0);
6027 +#endif
6028 +
6029 +#ifdef CONFIG_PAX_EMUTRAMP
6030 +
6031 +#ifndef CONFIG_PAX_EMUSIGRT
6032 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6033 + return 1;
6034 +#endif
6035 +
6036 + do { /* PaX: rt_sigreturn emulation */
6037 + unsigned int ldi1, ldi2, bel, nop;
6038 +
6039 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6040 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6041 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6042 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6043 +
6044 + if (err)
6045 + break;
6046 +
6047 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6048 + ldi2 == 0x3414015AU &&
6049 + bel == 0xE4008200U &&
6050 + nop == 0x08000240U)
6051 + {
6052 + regs->gr[25] = (ldi1 & 2) >> 1;
6053 + regs->gr[20] = __NR_rt_sigreturn;
6054 + regs->gr[31] = regs->iaoq[1] + 16;
6055 + regs->sr[0] = regs->iasq[1];
6056 + regs->iaoq[0] = 0x100UL;
6057 + regs->iaoq[1] = regs->iaoq[0] + 4;
6058 + regs->iasq[0] = regs->sr[2];
6059 + regs->iasq[1] = regs->sr[2];
6060 + return 2;
6061 + }
6062 + } while (0);
6063 +#endif
6064 +
6065 + return 1;
6066 +}
6067 +
6068 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6069 +{
6070 + unsigned long i;
6071 +
6072 + printk(KERN_ERR "PAX: bytes at PC: ");
6073 + for (i = 0; i < 5; i++) {
6074 + unsigned int c;
6075 + if (get_user(c, (unsigned int *)pc+i))
6076 + printk(KERN_CONT "???????? ");
6077 + else
6078 + printk(KERN_CONT "%08x ", c);
6079 + }
6080 + printk("\n");
6081 +}
6082 +#endif
6083 +
6084 int fixup_exception(struct pt_regs *regs)
6085 {
6086 const struct exception_table_entry *fix;
6087 @@ -194,8 +305,33 @@ good_area:
6088
6089 acc_type = parisc_acctyp(code,regs->iir);
6090
6091 - if ((vma->vm_flags & acc_type) != acc_type)
6092 + if ((vma->vm_flags & acc_type) != acc_type) {
6093 +
6094 +#ifdef CONFIG_PAX_PAGEEXEC
6095 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6096 + (address & ~3UL) == instruction_pointer(regs))
6097 + {
6098 + up_read(&mm->mmap_sem);
6099 + switch (pax_handle_fetch_fault(regs)) {
6100 +
6101 +#ifdef CONFIG_PAX_EMUPLT
6102 + case 3:
6103 + return;
6104 +#endif
6105 +
6106 +#ifdef CONFIG_PAX_EMUTRAMP
6107 + case 2:
6108 + return;
6109 +#endif
6110 +
6111 + }
6112 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6113 + do_group_exit(SIGKILL);
6114 + }
6115 +#endif
6116 +
6117 goto bad_area;
6118 + }
6119
6120 /*
6121 * If for any reason at all we couldn't handle the fault, make
6122 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6123 index e3b1d41..8e81edf 100644
6124 --- a/arch/powerpc/include/asm/atomic.h
6125 +++ b/arch/powerpc/include/asm/atomic.h
6126 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6127 return t1;
6128 }
6129
6130 +#define atomic64_read_unchecked(v) atomic64_read(v)
6131 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6132 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6133 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6134 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6135 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6136 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6137 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6138 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6139 +
6140 #endif /* __powerpc64__ */
6141
6142 #endif /* __KERNEL__ */
6143 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6144 index 9e495c9..b6878e5 100644
6145 --- a/arch/powerpc/include/asm/cache.h
6146 +++ b/arch/powerpc/include/asm/cache.h
6147 @@ -3,6 +3,7 @@
6148
6149 #ifdef __KERNEL__
6150
6151 +#include <linux/const.h>
6152
6153 /* bytes per L1 cache line */
6154 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6155 @@ -22,7 +23,7 @@
6156 #define L1_CACHE_SHIFT 7
6157 #endif
6158
6159 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6160 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6161
6162 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6163
6164 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6165 index ac9790f..6d30741 100644
6166 --- a/arch/powerpc/include/asm/elf.h
6167 +++ b/arch/powerpc/include/asm/elf.h
6168 @@ -28,8 +28,19 @@
6169 the loader. We need to make sure that it is out of the way of the program
6170 that it will "exec", and that there is sufficient room for the brk. */
6171
6172 -extern unsigned long randomize_et_dyn(unsigned long base);
6173 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6174 +#define ELF_ET_DYN_BASE (0x20000000)
6175 +
6176 +#ifdef CONFIG_PAX_ASLR
6177 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6178 +
6179 +#ifdef __powerpc64__
6180 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6181 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6182 +#else
6183 +#define PAX_DELTA_MMAP_LEN 15
6184 +#define PAX_DELTA_STACK_LEN 15
6185 +#endif
6186 +#endif
6187
6188 /*
6189 * Our registers are always unsigned longs, whether we're a 32 bit
6190 @@ -122,10 +133,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6191 (0x7ff >> (PAGE_SHIFT - 12)) : \
6192 (0x3ffff >> (PAGE_SHIFT - 12)))
6193
6194 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6195 -#define arch_randomize_brk arch_randomize_brk
6196 -
6197 -
6198 #ifdef CONFIG_SPU_BASE
6199 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6200 #define NT_SPU 1
6201 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6202 index 8196e9c..d83a9f3 100644
6203 --- a/arch/powerpc/include/asm/exec.h
6204 +++ b/arch/powerpc/include/asm/exec.h
6205 @@ -4,6 +4,6 @@
6206 #ifndef _ASM_POWERPC_EXEC_H
6207 #define _ASM_POWERPC_EXEC_H
6208
6209 -extern unsigned long arch_align_stack(unsigned long sp);
6210 +#define arch_align_stack(x) ((x) & ~0xfUL)
6211
6212 #endif /* _ASM_POWERPC_EXEC_H */
6213 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6214 index 5acabbd..7ea14fa 100644
6215 --- a/arch/powerpc/include/asm/kmap_types.h
6216 +++ b/arch/powerpc/include/asm/kmap_types.h
6217 @@ -10,7 +10,7 @@
6218 * 2 of the License, or (at your option) any later version.
6219 */
6220
6221 -#define KM_TYPE_NR 16
6222 +#define KM_TYPE_NR 17
6223
6224 #endif /* __KERNEL__ */
6225 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6226 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6227 index 8565c25..2865190 100644
6228 --- a/arch/powerpc/include/asm/mman.h
6229 +++ b/arch/powerpc/include/asm/mman.h
6230 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6231 }
6232 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6233
6234 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6235 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6236 {
6237 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6238 }
6239 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6240 index f072e97..b436dee 100644
6241 --- a/arch/powerpc/include/asm/page.h
6242 +++ b/arch/powerpc/include/asm/page.h
6243 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6244 * and needs to be executable. This means the whole heap ends
6245 * up being executable.
6246 */
6247 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6248 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6249 +#define VM_DATA_DEFAULT_FLAGS32 \
6250 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6251 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6252
6253 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6254 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6255 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6256 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6257 #endif
6258
6259 +#define ktla_ktva(addr) (addr)
6260 +#define ktva_ktla(addr) (addr)
6261 +
6262 /*
6263 * Use the top bit of the higher-level page table entries to indicate whether
6264 * the entries we point to contain hugepages. This works because we know that
6265 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6266 index cd915d6..c10cee8 100644
6267 --- a/arch/powerpc/include/asm/page_64.h
6268 +++ b/arch/powerpc/include/asm/page_64.h
6269 @@ -154,15 +154,18 @@ do { \
6270 * stack by default, so in the absence of a PT_GNU_STACK program header
6271 * we turn execute permission off.
6272 */
6273 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6274 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6275 +#define VM_STACK_DEFAULT_FLAGS32 \
6276 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6277 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6278
6279 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6280 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6281
6282 +#ifndef CONFIG_PAX_PAGEEXEC
6283 #define VM_STACK_DEFAULT_FLAGS \
6284 (is_32bit_task() ? \
6285 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6286 +#endif
6287
6288 #include <asm-generic/getorder.h>
6289
6290 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6291 index 292725c..f87ae14 100644
6292 --- a/arch/powerpc/include/asm/pgalloc-64.h
6293 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6294 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6295 #ifndef CONFIG_PPC_64K_PAGES
6296
6297 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6298 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6299
6300 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6301 {
6302 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6303 pud_set(pud, (unsigned long)pmd);
6304 }
6305
6306 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6307 +{
6308 + pud_populate(mm, pud, pmd);
6309 +}
6310 +
6311 #define pmd_populate(mm, pmd, pte_page) \
6312 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6313 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6314 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6315 #else /* CONFIG_PPC_64K_PAGES */
6316
6317 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6318 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6319
6320 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6321 pte_t *pte)
6322 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6323 index a9cbd3b..3b67efa 100644
6324 --- a/arch/powerpc/include/asm/pgtable.h
6325 +++ b/arch/powerpc/include/asm/pgtable.h
6326 @@ -2,6 +2,7 @@
6327 #define _ASM_POWERPC_PGTABLE_H
6328 #ifdef __KERNEL__
6329
6330 +#include <linux/const.h>
6331 #ifndef __ASSEMBLY__
6332 #include <asm/processor.h> /* For TASK_SIZE */
6333 #include <asm/mmu.h>
6334 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6335 index 4aad413..85d86bf 100644
6336 --- a/arch/powerpc/include/asm/pte-hash32.h
6337 +++ b/arch/powerpc/include/asm/pte-hash32.h
6338 @@ -21,6 +21,7 @@
6339 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6340 #define _PAGE_USER 0x004 /* usermode access allowed */
6341 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6342 +#define _PAGE_EXEC _PAGE_GUARDED
6343 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6344 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6345 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6346 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6347 index 3b097a8..8f8c774 100644
6348 --- a/arch/powerpc/include/asm/reg.h
6349 +++ b/arch/powerpc/include/asm/reg.h
6350 @@ -234,6 +234,7 @@
6351 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6352 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6353 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6354 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6355 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6356 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6357 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6358 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6359 index 195ce2a..ab5c614 100644
6360 --- a/arch/powerpc/include/asm/smp.h
6361 +++ b/arch/powerpc/include/asm/smp.h
6362 @@ -50,7 +50,7 @@ struct smp_ops_t {
6363 int (*cpu_disable)(void);
6364 void (*cpu_die)(unsigned int nr);
6365 int (*cpu_bootable)(unsigned int nr);
6366 -};
6367 +} __no_const;
6368
6369 extern void smp_send_debugger_break(void);
6370 extern void start_secondary_resume(void);
6371 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6372 index 406b7b9..af63426 100644
6373 --- a/arch/powerpc/include/asm/thread_info.h
6374 +++ b/arch/powerpc/include/asm/thread_info.h
6375 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6376 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6377 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6378 #define TIF_SINGLESTEP 8 /* singlestepping active */
6379 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6380 #define TIF_SECCOMP 10 /* secure computing */
6381 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6382 #define TIF_NOERROR 12 /* Force successful syscall return */
6383 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6384 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6385 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6386 for stack store? */
6387 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6388 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6389 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6390
6391 /* as above, but as bit values */
6392 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6393 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6394 #define _TIF_UPROBE (1<<TIF_UPROBE)
6395 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6396 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6397 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6398 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6399 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6400 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6401 + _TIF_GRSEC_SETXID)
6402
6403 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6404 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6405 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6406 index 4db4959..aba5c41 100644
6407 --- a/arch/powerpc/include/asm/uaccess.h
6408 +++ b/arch/powerpc/include/asm/uaccess.h
6409 @@ -318,52 +318,6 @@ do { \
6410 extern unsigned long __copy_tofrom_user(void __user *to,
6411 const void __user *from, unsigned long size);
6412
6413 -#ifndef __powerpc64__
6414 -
6415 -static inline unsigned long copy_from_user(void *to,
6416 - const void __user *from, unsigned long n)
6417 -{
6418 - unsigned long over;
6419 -
6420 - if (access_ok(VERIFY_READ, from, n))
6421 - return __copy_tofrom_user((__force void __user *)to, from, n);
6422 - if ((unsigned long)from < TASK_SIZE) {
6423 - over = (unsigned long)from + n - TASK_SIZE;
6424 - return __copy_tofrom_user((__force void __user *)to, from,
6425 - n - over) + over;
6426 - }
6427 - return n;
6428 -}
6429 -
6430 -static inline unsigned long copy_to_user(void __user *to,
6431 - const void *from, unsigned long n)
6432 -{
6433 - unsigned long over;
6434 -
6435 - if (access_ok(VERIFY_WRITE, to, n))
6436 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6437 - if ((unsigned long)to < TASK_SIZE) {
6438 - over = (unsigned long)to + n - TASK_SIZE;
6439 - return __copy_tofrom_user(to, (__force void __user *)from,
6440 - n - over) + over;
6441 - }
6442 - return n;
6443 -}
6444 -
6445 -#else /* __powerpc64__ */
6446 -
6447 -#define __copy_in_user(to, from, size) \
6448 - __copy_tofrom_user((to), (from), (size))
6449 -
6450 -extern unsigned long copy_from_user(void *to, const void __user *from,
6451 - unsigned long n);
6452 -extern unsigned long copy_to_user(void __user *to, const void *from,
6453 - unsigned long n);
6454 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6455 - unsigned long n);
6456 -
6457 -#endif /* __powerpc64__ */
6458 -
6459 static inline unsigned long __copy_from_user_inatomic(void *to,
6460 const void __user *from, unsigned long n)
6461 {
6462 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6463 if (ret == 0)
6464 return 0;
6465 }
6466 +
6467 + if (!__builtin_constant_p(n))
6468 + check_object_size(to, n, false);
6469 +
6470 return __copy_tofrom_user((__force void __user *)to, from, n);
6471 }
6472
6473 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6474 if (ret == 0)
6475 return 0;
6476 }
6477 +
6478 + if (!__builtin_constant_p(n))
6479 + check_object_size(from, n, true);
6480 +
6481 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6482 }
6483
6484 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6485 return __copy_to_user_inatomic(to, from, size);
6486 }
6487
6488 +#ifndef __powerpc64__
6489 +
6490 +static inline unsigned long __must_check copy_from_user(void *to,
6491 + const void __user *from, unsigned long n)
6492 +{
6493 + unsigned long over;
6494 +
6495 + if ((long)n < 0)
6496 + return n;
6497 +
6498 + if (access_ok(VERIFY_READ, from, n)) {
6499 + if (!__builtin_constant_p(n))
6500 + check_object_size(to, n, false);
6501 + return __copy_tofrom_user((__force void __user *)to, from, n);
6502 + }
6503 + if ((unsigned long)from < TASK_SIZE) {
6504 + over = (unsigned long)from + n - TASK_SIZE;
6505 + if (!__builtin_constant_p(n - over))
6506 + check_object_size(to, n - over, false);
6507 + return __copy_tofrom_user((__force void __user *)to, from,
6508 + n - over) + over;
6509 + }
6510 + return n;
6511 +}
6512 +
6513 +static inline unsigned long __must_check copy_to_user(void __user *to,
6514 + const void *from, unsigned long n)
6515 +{
6516 + unsigned long over;
6517 +
6518 + if ((long)n < 0)
6519 + return n;
6520 +
6521 + if (access_ok(VERIFY_WRITE, to, n)) {
6522 + if (!__builtin_constant_p(n))
6523 + check_object_size(from, n, true);
6524 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6525 + }
6526 + if ((unsigned long)to < TASK_SIZE) {
6527 + over = (unsigned long)to + n - TASK_SIZE;
6528 + if (!__builtin_constant_p(n))
6529 + check_object_size(from, n - over, true);
6530 + return __copy_tofrom_user(to, (__force void __user *)from,
6531 + n - over) + over;
6532 + }
6533 + return n;
6534 +}
6535 +
6536 +#else /* __powerpc64__ */
6537 +
6538 +#define __copy_in_user(to, from, size) \
6539 + __copy_tofrom_user((to), (from), (size))
6540 +
6541 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6542 +{
6543 + if ((long)n < 0 || n > INT_MAX)
6544 + return n;
6545 +
6546 + if (!__builtin_constant_p(n))
6547 + check_object_size(to, n, false);
6548 +
6549 + if (likely(access_ok(VERIFY_READ, from, n)))
6550 + n = __copy_from_user(to, from, n);
6551 + else
6552 + memset(to, 0, n);
6553 + return n;
6554 +}
6555 +
6556 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6557 +{
6558 + if ((long)n < 0 || n > INT_MAX)
6559 + return n;
6560 +
6561 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6562 + if (!__builtin_constant_p(n))
6563 + check_object_size(from, n, true);
6564 + n = __copy_to_user(to, from, n);
6565 + }
6566 + return n;
6567 +}
6568 +
6569 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6570 + unsigned long n);
6571 +
6572 +#endif /* __powerpc64__ */
6573 +
6574 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6575
6576 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6577 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6578 index ae54553..cf2184d 100644
6579 --- a/arch/powerpc/kernel/exceptions-64e.S
6580 +++ b/arch/powerpc/kernel/exceptions-64e.S
6581 @@ -716,6 +716,7 @@ storage_fault_common:
6582 std r14,_DAR(r1)
6583 std r15,_DSISR(r1)
6584 addi r3,r1,STACK_FRAME_OVERHEAD
6585 + bl .save_nvgprs
6586 mr r4,r14
6587 mr r5,r15
6588 ld r14,PACA_EXGEN+EX_R14(r13)
6589 @@ -724,8 +725,7 @@ storage_fault_common:
6590 cmpdi r3,0
6591 bne- 1f
6592 b .ret_from_except_lite
6593 -1: bl .save_nvgprs
6594 - mr r5,r3
6595 +1: mr r5,r3
6596 addi r3,r1,STACK_FRAME_OVERHEAD
6597 ld r4,_DAR(r1)
6598 bl .bad_page_fault
6599 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6600 index 644378e..b6f2c26 100644
6601 --- a/arch/powerpc/kernel/exceptions-64s.S
6602 +++ b/arch/powerpc/kernel/exceptions-64s.S
6603 @@ -1390,10 +1390,10 @@ handle_page_fault:
6604 11: ld r4,_DAR(r1)
6605 ld r5,_DSISR(r1)
6606 addi r3,r1,STACK_FRAME_OVERHEAD
6607 + bl .save_nvgprs
6608 bl .do_page_fault
6609 cmpdi r3,0
6610 beq+ 12f
6611 - bl .save_nvgprs
6612 mr r5,r3
6613 addi r3,r1,STACK_FRAME_OVERHEAD
6614 lwz r4,_DAR(r1)
6615 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6616 index 2e3200c..72095ce 100644
6617 --- a/arch/powerpc/kernel/module_32.c
6618 +++ b/arch/powerpc/kernel/module_32.c
6619 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6620 me->arch.core_plt_section = i;
6621 }
6622 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6623 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6624 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6625 return -ENOEXEC;
6626 }
6627
6628 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6629
6630 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6631 /* Init, or core PLT? */
6632 - if (location >= mod->module_core
6633 - && location < mod->module_core + mod->core_size)
6634 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6635 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6636 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6637 - else
6638 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6639 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6640 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6641 + else {
6642 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6643 + return ~0UL;
6644 + }
6645
6646 /* Find this entry, or if that fails, the next avail. entry */
6647 while (entry->jump[0]) {
6648 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6649 index 0d86c8a..df4c5f2 100644
6650 --- a/arch/powerpc/kernel/process.c
6651 +++ b/arch/powerpc/kernel/process.c
6652 @@ -871,8 +871,8 @@ void show_regs(struct pt_regs * regs)
6653 * Lookup NIP late so we have the best change of getting the
6654 * above info out without failing
6655 */
6656 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6657 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6658 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6659 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6660 #endif
6661 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6662 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6663 @@ -1331,10 +1331,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6664 newsp = stack[0];
6665 ip = stack[STACK_FRAME_LR_SAVE];
6666 if (!firstframe || ip != lr) {
6667 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6668 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6669 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6670 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6671 - printk(" (%pS)",
6672 + printk(" (%pA)",
6673 (void *)current->ret_stack[curr_frame].ret);
6674 curr_frame--;
6675 }
6676 @@ -1354,7 +1354,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6677 struct pt_regs *regs = (struct pt_regs *)
6678 (sp + STACK_FRAME_OVERHEAD);
6679 lr = regs->link;
6680 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6681 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6682 regs->trap, (void *)regs->nip, (void *)lr);
6683 firstframe = 1;
6684 }
6685 @@ -1396,58 +1396,3 @@ void notrace __ppc64_runlatch_off(void)
6686 mtspr(SPRN_CTRLT, ctrl);
6687 }
6688 #endif /* CONFIG_PPC64 */
6689 -
6690 -unsigned long arch_align_stack(unsigned long sp)
6691 -{
6692 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6693 - sp -= get_random_int() & ~PAGE_MASK;
6694 - return sp & ~0xf;
6695 -}
6696 -
6697 -static inline unsigned long brk_rnd(void)
6698 -{
6699 - unsigned long rnd = 0;
6700 -
6701 - /* 8MB for 32bit, 1GB for 64bit */
6702 - if (is_32bit_task())
6703 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6704 - else
6705 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6706 -
6707 - return rnd << PAGE_SHIFT;
6708 -}
6709 -
6710 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6711 -{
6712 - unsigned long base = mm->brk;
6713 - unsigned long ret;
6714 -
6715 -#ifdef CONFIG_PPC_STD_MMU_64
6716 - /*
6717 - * If we are using 1TB segments and we are allowed to randomise
6718 - * the heap, we can put it above 1TB so it is backed by a 1TB
6719 - * segment. Otherwise the heap will be in the bottom 1TB
6720 - * which always uses 256MB segments and this may result in a
6721 - * performance penalty.
6722 - */
6723 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6724 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6725 -#endif
6726 -
6727 - ret = PAGE_ALIGN(base + brk_rnd());
6728 -
6729 - if (ret < mm->brk)
6730 - return mm->brk;
6731 -
6732 - return ret;
6733 -}
6734 -
6735 -unsigned long randomize_et_dyn(unsigned long base)
6736 -{
6737 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6738 -
6739 - if (ret < base)
6740 - return base;
6741 -
6742 - return ret;
6743 -}
6744 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6745 index f9b30c6..d72e7a3 100644
6746 --- a/arch/powerpc/kernel/ptrace.c
6747 +++ b/arch/powerpc/kernel/ptrace.c
6748 @@ -1771,6 +1771,10 @@ long arch_ptrace(struct task_struct *child, long request,
6749 return ret;
6750 }
6751
6752 +#ifdef CONFIG_GRKERNSEC_SETXID
6753 +extern void gr_delayed_cred_worker(void);
6754 +#endif
6755 +
6756 /*
6757 * We must return the syscall number to actually look up in the table.
6758 * This can be -1L to skip running any syscall at all.
6759 @@ -1781,6 +1785,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6760
6761 secure_computing_strict(regs->gpr[0]);
6762
6763 +#ifdef CONFIG_GRKERNSEC_SETXID
6764 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6765 + gr_delayed_cred_worker();
6766 +#endif
6767 +
6768 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6769 tracehook_report_syscall_entry(regs))
6770 /*
6771 @@ -1815,6 +1824,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6772 {
6773 int step;
6774
6775 +#ifdef CONFIG_GRKERNSEC_SETXID
6776 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6777 + gr_delayed_cred_worker();
6778 +#endif
6779 +
6780 audit_syscall_exit(regs);
6781
6782 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6783 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6784 index 201385c..0f01828 100644
6785 --- a/arch/powerpc/kernel/signal_32.c
6786 +++ b/arch/powerpc/kernel/signal_32.c
6787 @@ -976,7 +976,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6788 /* Save user registers on the stack */
6789 frame = &rt_sf->uc.uc_mcontext;
6790 addr = frame;
6791 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6792 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6793 sigret = 0;
6794 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6795 } else {
6796 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6797 index 3459473..2d40783 100644
6798 --- a/arch/powerpc/kernel/signal_64.c
6799 +++ b/arch/powerpc/kernel/signal_64.c
6800 @@ -749,7 +749,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6801 #endif
6802
6803 /* Set up to return from userspace. */
6804 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6805 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6806 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6807 } else {
6808 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6809 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6810 index 3ce1f86..c30e629 100644
6811 --- a/arch/powerpc/kernel/sysfs.c
6812 +++ b/arch/powerpc/kernel/sysfs.c
6813 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6814 return NOTIFY_OK;
6815 }
6816
6817 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6818 +static struct notifier_block sysfs_cpu_nb = {
6819 .notifier_call = sysfs_cpu_notify,
6820 };
6821
6822 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6823 index bf33ace..e836d8b 100644
6824 --- a/arch/powerpc/kernel/traps.c
6825 +++ b/arch/powerpc/kernel/traps.c
6826 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6827 return flags;
6828 }
6829
6830 +extern void gr_handle_kernel_exploit(void);
6831 +
6832 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6833 int signr)
6834 {
6835 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6836 panic("Fatal exception in interrupt");
6837 if (panic_on_oops)
6838 panic("Fatal exception");
6839 +
6840 + gr_handle_kernel_exploit();
6841 +
6842 do_exit(signr);
6843 }
6844
6845 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6846 index 1b2076f..835e4be 100644
6847 --- a/arch/powerpc/kernel/vdso.c
6848 +++ b/arch/powerpc/kernel/vdso.c
6849 @@ -34,6 +34,7 @@
6850 #include <asm/firmware.h>
6851 #include <asm/vdso.h>
6852 #include <asm/vdso_datapage.h>
6853 +#include <asm/mman.h>
6854
6855 #include "setup.h"
6856
6857 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6858 vdso_base = VDSO32_MBASE;
6859 #endif
6860
6861 - current->mm->context.vdso_base = 0;
6862 + current->mm->context.vdso_base = ~0UL;
6863
6864 /* vDSO has a problem and was disabled, just don't "enable" it for the
6865 * process
6866 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6867 vdso_base = get_unmapped_area(NULL, vdso_base,
6868 (vdso_pages << PAGE_SHIFT) +
6869 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6870 - 0, 0);
6871 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6872 if (IS_ERR_VALUE(vdso_base)) {
6873 rc = vdso_base;
6874 goto fail_mmapsem;
6875 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6876 index 5eea6f3..5d10396 100644
6877 --- a/arch/powerpc/lib/usercopy_64.c
6878 +++ b/arch/powerpc/lib/usercopy_64.c
6879 @@ -9,22 +9,6 @@
6880 #include <linux/module.h>
6881 #include <asm/uaccess.h>
6882
6883 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6884 -{
6885 - if (likely(access_ok(VERIFY_READ, from, n)))
6886 - n = __copy_from_user(to, from, n);
6887 - else
6888 - memset(to, 0, n);
6889 - return n;
6890 -}
6891 -
6892 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6893 -{
6894 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6895 - n = __copy_to_user(to, from, n);
6896 - return n;
6897 -}
6898 -
6899 unsigned long copy_in_user(void __user *to, const void __user *from,
6900 unsigned long n)
6901 {
6902 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6903 return n;
6904 }
6905
6906 -EXPORT_SYMBOL(copy_from_user);
6907 -EXPORT_SYMBOL(copy_to_user);
6908 EXPORT_SYMBOL(copy_in_user);
6909
6910 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6911 index 229951f..cdeca42 100644
6912 --- a/arch/powerpc/mm/fault.c
6913 +++ b/arch/powerpc/mm/fault.c
6914 @@ -32,6 +32,10 @@
6915 #include <linux/perf_event.h>
6916 #include <linux/magic.h>
6917 #include <linux/ratelimit.h>
6918 +#include <linux/slab.h>
6919 +#include <linux/pagemap.h>
6920 +#include <linux/compiler.h>
6921 +#include <linux/unistd.h>
6922
6923 #include <asm/firmware.h>
6924 #include <asm/page.h>
6925 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
6926 }
6927 #endif
6928
6929 +#ifdef CONFIG_PAX_PAGEEXEC
6930 +/*
6931 + * PaX: decide what to do with offenders (regs->nip = fault address)
6932 + *
6933 + * returns 1 when task should be killed
6934 + */
6935 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6936 +{
6937 + return 1;
6938 +}
6939 +
6940 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6941 +{
6942 + unsigned long i;
6943 +
6944 + printk(KERN_ERR "PAX: bytes at PC: ");
6945 + for (i = 0; i < 5; i++) {
6946 + unsigned int c;
6947 + if (get_user(c, (unsigned int __user *)pc+i))
6948 + printk(KERN_CONT "???????? ");
6949 + else
6950 + printk(KERN_CONT "%08x ", c);
6951 + }
6952 + printk("\n");
6953 +}
6954 +#endif
6955 +
6956 /*
6957 * Check whether the instruction at regs->nip is a store using
6958 * an update addressing form which will update r1.
6959 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
6960 * indicate errors in DSISR but can validly be set in SRR1.
6961 */
6962 if (trap == 0x400)
6963 - error_code &= 0x48200000;
6964 + error_code &= 0x58200000;
6965 else
6966 is_write = error_code & DSISR_ISSTORE;
6967 #else
6968 @@ -364,7 +395,7 @@ good_area:
6969 * "undefined". Of those that can be set, this is the only
6970 * one which seems bad.
6971 */
6972 - if (error_code & 0x10000000)
6973 + if (error_code & DSISR_GUARDED)
6974 /* Guarded storage error. */
6975 goto bad_area;
6976 #endif /* CONFIG_8xx */
6977 @@ -379,7 +410,7 @@ good_area:
6978 * processors use the same I/D cache coherency mechanism
6979 * as embedded.
6980 */
6981 - if (error_code & DSISR_PROTFAULT)
6982 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
6983 goto bad_area;
6984 #endif /* CONFIG_PPC_STD_MMU */
6985
6986 @@ -462,6 +493,23 @@ bad_area:
6987 bad_area_nosemaphore:
6988 /* User mode accesses cause a SIGSEGV */
6989 if (user_mode(regs)) {
6990 +
6991 +#ifdef CONFIG_PAX_PAGEEXEC
6992 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
6993 +#ifdef CONFIG_PPC_STD_MMU
6994 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
6995 +#else
6996 + if (is_exec && regs->nip == address) {
6997 +#endif
6998 + switch (pax_handle_fetch_fault(regs)) {
6999 + }
7000 +
7001 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7002 + do_group_exit(SIGKILL);
7003 + }
7004 + }
7005 +#endif
7006 +
7007 _exception(SIGSEGV, regs, code, address);
7008 return 0;
7009 }
7010 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7011 index 67a42ed..cd463e0 100644
7012 --- a/arch/powerpc/mm/mmap_64.c
7013 +++ b/arch/powerpc/mm/mmap_64.c
7014 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7015 {
7016 unsigned long rnd = 0;
7017
7018 +#ifdef CONFIG_PAX_RANDMMAP
7019 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7020 +#endif
7021 +
7022 if (current->flags & PF_RANDOMIZE) {
7023 /* 8MB for 32bit, 1GB for 64bit */
7024 if (is_32bit_task())
7025 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7026 */
7027 if (mmap_is_legacy()) {
7028 mm->mmap_base = TASK_UNMAPPED_BASE;
7029 +
7030 +#ifdef CONFIG_PAX_RANDMMAP
7031 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7032 + mm->mmap_base += mm->delta_mmap;
7033 +#endif
7034 +
7035 mm->get_unmapped_area = arch_get_unmapped_area;
7036 mm->unmap_area = arch_unmap_area;
7037 } else {
7038 mm->mmap_base = mmap_base();
7039 +
7040 +#ifdef CONFIG_PAX_RANDMMAP
7041 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7042 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7043 +#endif
7044 +
7045 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7046 mm->unmap_area = arch_unmap_area_topdown;
7047 }
7048 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7049 index e779642..e5bb889 100644
7050 --- a/arch/powerpc/mm/mmu_context_nohash.c
7051 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7052 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7053 return NOTIFY_OK;
7054 }
7055
7056 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7057 +static struct notifier_block mmu_context_cpu_nb = {
7058 .notifier_call = mmu_context_cpu_notify,
7059 };
7060
7061 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7062 index 6a252c4..3024d81 100644
7063 --- a/arch/powerpc/mm/numa.c
7064 +++ b/arch/powerpc/mm/numa.c
7065 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7066 return ret;
7067 }
7068
7069 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7070 +static struct notifier_block ppc64_numa_nb = {
7071 .notifier_call = cpu_numa_callback,
7072 .priority = 1 /* Must run before sched domains notifier. */
7073 };
7074 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7075 index cf9dada..241529f 100644
7076 --- a/arch/powerpc/mm/slice.c
7077 +++ b/arch/powerpc/mm/slice.c
7078 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7079 if ((mm->task_size - len) < addr)
7080 return 0;
7081 vma = find_vma(mm, addr);
7082 - return (!vma || (addr + len) <= vma->vm_start);
7083 + return check_heap_stack_gap(vma, addr, len, 0);
7084 }
7085
7086 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7087 @@ -272,7 +272,7 @@ full_search:
7088 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7089 continue;
7090 }
7091 - if (!vma || addr + len <= vma->vm_start) {
7092 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7093 /*
7094 * Remember the place where we stopped the search:
7095 */
7096 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7097 }
7098 }
7099
7100 - addr = mm->mmap_base;
7101 - while (addr > len) {
7102 + if (mm->mmap_base < len)
7103 + addr = -ENOMEM;
7104 + else
7105 + addr = mm->mmap_base - len;
7106 +
7107 + while (!IS_ERR_VALUE(addr)) {
7108 /* Go down by chunk size */
7109 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7110 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7111
7112 /* Check for hit with different page size */
7113 mask = slice_range_to_mask(addr, len);
7114 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7115 * return with success:
7116 */
7117 vma = find_vma(mm, addr);
7118 - if (!vma || (addr + len) <= vma->vm_start) {
7119 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7120 /* remember the address as a hint for next time */
7121 if (use_cache)
7122 mm->free_area_cache = addr;
7123 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7124 mm->cached_hole_size = vma->vm_start - addr;
7125
7126 /* try just below the current vma->vm_start */
7127 - addr = vma->vm_start;
7128 + addr = skip_heap_stack_gap(vma, len, 0);
7129 }
7130
7131 /*
7132 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7133 if (fixed && addr > (mm->task_size - len))
7134 return -EINVAL;
7135
7136 +#ifdef CONFIG_PAX_RANDMMAP
7137 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7138 + addr = 0;
7139 +#endif
7140 +
7141 /* If hint, make sure it matches our alignment restrictions */
7142 if (!fixed && addr) {
7143 addr = _ALIGN_UP(addr, 1ul << pshift);
7144 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7145 index 68c57d3..1fdcfb2 100644
7146 --- a/arch/powerpc/platforms/cell/spufs/file.c
7147 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7148 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7149 return VM_FAULT_NOPAGE;
7150 }
7151
7152 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7153 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7154 unsigned long address,
7155 - void *buf, int len, int write)
7156 + void *buf, size_t len, int write)
7157 {
7158 struct spu_context *ctx = vma->vm_file->private_data;
7159 unsigned long offset = address - vma->vm_start;
7160 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7161 index bdb738a..49c9f95 100644
7162 --- a/arch/powerpc/platforms/powermac/smp.c
7163 +++ b/arch/powerpc/platforms/powermac/smp.c
7164 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7165 return NOTIFY_OK;
7166 }
7167
7168 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7169 +static struct notifier_block smp_core99_cpu_nb = {
7170 .notifier_call = smp_core99_cpu_notify,
7171 };
7172 #endif /* CONFIG_HOTPLUG_CPU */
7173 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7174 index c797832..ce575c8 100644
7175 --- a/arch/s390/include/asm/atomic.h
7176 +++ b/arch/s390/include/asm/atomic.h
7177 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7178 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7179 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7180
7181 +#define atomic64_read_unchecked(v) atomic64_read(v)
7182 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7183 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7184 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7185 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7186 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7187 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7188 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7189 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7190 +
7191 #define smp_mb__before_atomic_dec() smp_mb()
7192 #define smp_mb__after_atomic_dec() smp_mb()
7193 #define smp_mb__before_atomic_inc() smp_mb()
7194 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7195 index 4d7ccac..d03d0ad 100644
7196 --- a/arch/s390/include/asm/cache.h
7197 +++ b/arch/s390/include/asm/cache.h
7198 @@ -9,8 +9,10 @@
7199 #ifndef __ARCH_S390_CACHE_H
7200 #define __ARCH_S390_CACHE_H
7201
7202 -#define L1_CACHE_BYTES 256
7203 +#include <linux/const.h>
7204 +
7205 #define L1_CACHE_SHIFT 8
7206 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7207 #define NET_SKB_PAD 32
7208
7209 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7210 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7211 index 1bfdf24..9c9ab2e 100644
7212 --- a/arch/s390/include/asm/elf.h
7213 +++ b/arch/s390/include/asm/elf.h
7214 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7215 the loader. We need to make sure that it is out of the way of the program
7216 that it will "exec", and that there is sufficient room for the brk. */
7217
7218 -extern unsigned long randomize_et_dyn(unsigned long base);
7219 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7220 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7221 +
7222 +#ifdef CONFIG_PAX_ASLR
7223 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7224 +
7225 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7226 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7227 +#endif
7228
7229 /* This yields a mask that user programs can use to figure out what
7230 instruction set this CPU supports. */
7231 @@ -207,9 +213,6 @@ struct linux_binprm;
7232 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7233 int arch_setup_additional_pages(struct linux_binprm *, int);
7234
7235 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7236 -#define arch_randomize_brk arch_randomize_brk
7237 -
7238 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7239
7240 #endif
7241 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7242 index c4a93d6..4d2a9b4 100644
7243 --- a/arch/s390/include/asm/exec.h
7244 +++ b/arch/s390/include/asm/exec.h
7245 @@ -7,6 +7,6 @@
7246 #ifndef __ASM_EXEC_H
7247 #define __ASM_EXEC_H
7248
7249 -extern unsigned long arch_align_stack(unsigned long sp);
7250 +#define arch_align_stack(x) ((x) & ~0xfUL)
7251
7252 #endif /* __ASM_EXEC_H */
7253 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7254 index 9c33ed4..e40cbef 100644
7255 --- a/arch/s390/include/asm/uaccess.h
7256 +++ b/arch/s390/include/asm/uaccess.h
7257 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7258 copy_to_user(void __user *to, const void *from, unsigned long n)
7259 {
7260 might_fault();
7261 +
7262 + if ((long)n < 0)
7263 + return n;
7264 +
7265 return __copy_to_user(to, from, n);
7266 }
7267
7268 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7269 static inline unsigned long __must_check
7270 __copy_from_user(void *to, const void __user *from, unsigned long n)
7271 {
7272 + if ((long)n < 0)
7273 + return n;
7274 +
7275 if (__builtin_constant_p(n) && (n <= 256))
7276 return uaccess.copy_from_user_small(n, from, to);
7277 else
7278 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7279 static inline unsigned long __must_check
7280 copy_from_user(void *to, const void __user *from, unsigned long n)
7281 {
7282 - unsigned int sz = __compiletime_object_size(to);
7283 + size_t sz = __compiletime_object_size(to);
7284
7285 might_fault();
7286 - if (unlikely(sz != -1 && sz < n)) {
7287 +
7288 + if ((long)n < 0)
7289 + return n;
7290 +
7291 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7292 copy_from_user_overflow();
7293 return n;
7294 }
7295 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7296 index 7845e15..59c4353 100644
7297 --- a/arch/s390/kernel/module.c
7298 +++ b/arch/s390/kernel/module.c
7299 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7300
7301 /* Increase core size by size of got & plt and set start
7302 offsets for got and plt. */
7303 - me->core_size = ALIGN(me->core_size, 4);
7304 - me->arch.got_offset = me->core_size;
7305 - me->core_size += me->arch.got_size;
7306 - me->arch.plt_offset = me->core_size;
7307 - me->core_size += me->arch.plt_size;
7308 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7309 + me->arch.got_offset = me->core_size_rw;
7310 + me->core_size_rw += me->arch.got_size;
7311 + me->arch.plt_offset = me->core_size_rx;
7312 + me->core_size_rx += me->arch.plt_size;
7313 return 0;
7314 }
7315
7316 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7317 if (info->got_initialized == 0) {
7318 Elf_Addr *gotent;
7319
7320 - gotent = me->module_core + me->arch.got_offset +
7321 + gotent = me->module_core_rw + me->arch.got_offset +
7322 info->got_offset;
7323 *gotent = val;
7324 info->got_initialized = 1;
7325 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7326 rc = apply_rela_bits(loc, val, 0, 64, 0);
7327 else if (r_type == R_390_GOTENT ||
7328 r_type == R_390_GOTPLTENT) {
7329 - val += (Elf_Addr) me->module_core - loc;
7330 + val += (Elf_Addr) me->module_core_rw - loc;
7331 rc = apply_rela_bits(loc, val, 1, 32, 1);
7332 }
7333 break;
7334 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7335 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7336 if (info->plt_initialized == 0) {
7337 unsigned int *ip;
7338 - ip = me->module_core + me->arch.plt_offset +
7339 + ip = me->module_core_rx + me->arch.plt_offset +
7340 info->plt_offset;
7341 #ifndef CONFIG_64BIT
7342 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7343 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7344 val - loc + 0xffffUL < 0x1ffffeUL) ||
7345 (r_type == R_390_PLT32DBL &&
7346 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7347 - val = (Elf_Addr) me->module_core +
7348 + val = (Elf_Addr) me->module_core_rx +
7349 me->arch.plt_offset +
7350 info->plt_offset;
7351 val += rela->r_addend - loc;
7352 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7353 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7354 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7355 val = val + rela->r_addend -
7356 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7357 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7358 if (r_type == R_390_GOTOFF16)
7359 rc = apply_rela_bits(loc, val, 0, 16, 0);
7360 else if (r_type == R_390_GOTOFF32)
7361 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7362 break;
7363 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7364 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7365 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7366 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7367 rela->r_addend - loc;
7368 if (r_type == R_390_GOTPC)
7369 rc = apply_rela_bits(loc, val, 1, 32, 0);
7370 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7371 index 536d645..4a5bd9e 100644
7372 --- a/arch/s390/kernel/process.c
7373 +++ b/arch/s390/kernel/process.c
7374 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7375 }
7376 return 0;
7377 }
7378 -
7379 -unsigned long arch_align_stack(unsigned long sp)
7380 -{
7381 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7382 - sp -= get_random_int() & ~PAGE_MASK;
7383 - return sp & ~0xf;
7384 -}
7385 -
7386 -static inline unsigned long brk_rnd(void)
7387 -{
7388 - /* 8MB for 32bit, 1GB for 64bit */
7389 - if (is_32bit_task())
7390 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7391 - else
7392 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7393 -}
7394 -
7395 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7396 -{
7397 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7398 -
7399 - if (ret < mm->brk)
7400 - return mm->brk;
7401 - return ret;
7402 -}
7403 -
7404 -unsigned long randomize_et_dyn(unsigned long base)
7405 -{
7406 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7407 -
7408 - if (!(current->flags & PF_RANDOMIZE))
7409 - return base;
7410 - if (ret < base)
7411 - return base;
7412 - return ret;
7413 -}
7414 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7415 index 06bafec..2bca531 100644
7416 --- a/arch/s390/mm/mmap.c
7417 +++ b/arch/s390/mm/mmap.c
7418 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7419 */
7420 if (mmap_is_legacy()) {
7421 mm->mmap_base = TASK_UNMAPPED_BASE;
7422 +
7423 +#ifdef CONFIG_PAX_RANDMMAP
7424 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7425 + mm->mmap_base += mm->delta_mmap;
7426 +#endif
7427 +
7428 mm->get_unmapped_area = arch_get_unmapped_area;
7429 mm->unmap_area = arch_unmap_area;
7430 } else {
7431 mm->mmap_base = mmap_base();
7432 +
7433 +#ifdef CONFIG_PAX_RANDMMAP
7434 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7435 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7436 +#endif
7437 +
7438 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7439 mm->unmap_area = arch_unmap_area_topdown;
7440 }
7441 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7442 */
7443 if (mmap_is_legacy()) {
7444 mm->mmap_base = TASK_UNMAPPED_BASE;
7445 +
7446 +#ifdef CONFIG_PAX_RANDMMAP
7447 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7448 + mm->mmap_base += mm->delta_mmap;
7449 +#endif
7450 +
7451 mm->get_unmapped_area = s390_get_unmapped_area;
7452 mm->unmap_area = arch_unmap_area;
7453 } else {
7454 mm->mmap_base = mmap_base();
7455 +
7456 +#ifdef CONFIG_PAX_RANDMMAP
7457 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7458 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7459 +#endif
7460 +
7461 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7462 mm->unmap_area = arch_unmap_area_topdown;
7463 }
7464 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7465 index ae3d59f..f65f075 100644
7466 --- a/arch/score/include/asm/cache.h
7467 +++ b/arch/score/include/asm/cache.h
7468 @@ -1,7 +1,9 @@
7469 #ifndef _ASM_SCORE_CACHE_H
7470 #define _ASM_SCORE_CACHE_H
7471
7472 +#include <linux/const.h>
7473 +
7474 #define L1_CACHE_SHIFT 4
7475 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7476 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7477
7478 #endif /* _ASM_SCORE_CACHE_H */
7479 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7480 index f9f3cd5..58ff438 100644
7481 --- a/arch/score/include/asm/exec.h
7482 +++ b/arch/score/include/asm/exec.h
7483 @@ -1,6 +1,6 @@
7484 #ifndef _ASM_SCORE_EXEC_H
7485 #define _ASM_SCORE_EXEC_H
7486
7487 -extern unsigned long arch_align_stack(unsigned long sp);
7488 +#define arch_align_stack(x) (x)
7489
7490 #endif /* _ASM_SCORE_EXEC_H */
7491 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7492 index 7956846..5f37677 100644
7493 --- a/arch/score/kernel/process.c
7494 +++ b/arch/score/kernel/process.c
7495 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7496
7497 return task_pt_regs(task)->cp0_epc;
7498 }
7499 -
7500 -unsigned long arch_align_stack(unsigned long sp)
7501 -{
7502 - return sp;
7503 -}
7504 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7505 index ef9e555..331bd29 100644
7506 --- a/arch/sh/include/asm/cache.h
7507 +++ b/arch/sh/include/asm/cache.h
7508 @@ -9,10 +9,11 @@
7509 #define __ASM_SH_CACHE_H
7510 #ifdef __KERNEL__
7511
7512 +#include <linux/const.h>
7513 #include <linux/init.h>
7514 #include <cpu/cache.h>
7515
7516 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7517 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7518
7519 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7520
7521 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7522 index 03f2b55..b0270327 100644
7523 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7524 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7525 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7526 return NOTIFY_OK;
7527 }
7528
7529 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7530 +static struct notifier_block shx3_cpu_notifier = {
7531 .notifier_call = shx3_cpu_callback,
7532 };
7533
7534 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7535 index 6777177..cb5e44f 100644
7536 --- a/arch/sh/mm/mmap.c
7537 +++ b/arch/sh/mm/mmap.c
7538 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7539 struct mm_struct *mm = current->mm;
7540 struct vm_area_struct *vma;
7541 int do_colour_align;
7542 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7543 struct vm_unmapped_area_info info;
7544
7545 if (flags & MAP_FIXED) {
7546 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7547 if (filp || (flags & MAP_SHARED))
7548 do_colour_align = 1;
7549
7550 +#ifdef CONFIG_PAX_RANDMMAP
7551 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7552 +#endif
7553 +
7554 if (addr) {
7555 if (do_colour_align)
7556 addr = COLOUR_ALIGN(addr, pgoff);
7557 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7558 addr = PAGE_ALIGN(addr);
7559
7560 vma = find_vma(mm, addr);
7561 - if (TASK_SIZE - len >= addr &&
7562 - (!vma || addr + len <= vma->vm_start))
7563 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7564 return addr;
7565 }
7566
7567 info.flags = 0;
7568 info.length = len;
7569 - info.low_limit = TASK_UNMAPPED_BASE;
7570 + info.low_limit = mm->mmap_base;
7571 info.high_limit = TASK_SIZE;
7572 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7573 info.align_offset = pgoff << PAGE_SHIFT;
7574 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7575 struct mm_struct *mm = current->mm;
7576 unsigned long addr = addr0;
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 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
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 /* requesting a specific address */
7591 if (addr) {
7592 if (do_colour_align)
7593 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
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 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7604 VM_BUG_ON(addr != -ENOMEM);
7605 info.flags = 0;
7606 info.low_limit = TASK_UNMAPPED_BASE;
7607 +
7608 +#ifdef CONFIG_PAX_RANDMMAP
7609 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7610 + info.low_limit += mm->delta_mmap;
7611 +#endif
7612 +
7613 info.high_limit = TASK_SIZE;
7614 addr = vm_unmapped_area(&info);
7615 }
7616 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7617 index be56a24..443328f 100644
7618 --- a/arch/sparc/include/asm/atomic_64.h
7619 +++ b/arch/sparc/include/asm/atomic_64.h
7620 @@ -14,18 +14,40 @@
7621 #define ATOMIC64_INIT(i) { (i) }
7622
7623 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7624 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7625 +{
7626 + return v->counter;
7627 +}
7628 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7629 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7630 +{
7631 + return v->counter;
7632 +}
7633
7634 #define atomic_set(v, i) (((v)->counter) = i)
7635 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7636 +{
7637 + v->counter = i;
7638 +}
7639 #define atomic64_set(v, i) (((v)->counter) = i)
7640 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7641 +{
7642 + v->counter = i;
7643 +}
7644
7645 extern void atomic_add(int, atomic_t *);
7646 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7647 extern void atomic64_add(long, atomic64_t *);
7648 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7649 extern void atomic_sub(int, atomic_t *);
7650 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7651 extern void atomic64_sub(long, atomic64_t *);
7652 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7653
7654 extern int atomic_add_ret(int, atomic_t *);
7655 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7656 extern long atomic64_add_ret(long, atomic64_t *);
7657 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7658 extern int atomic_sub_ret(int, atomic_t *);
7659 extern long atomic64_sub_ret(long, atomic64_t *);
7660
7661 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7662 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7663
7664 #define atomic_inc_return(v) atomic_add_ret(1, v)
7665 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7666 +{
7667 + return atomic_add_ret_unchecked(1, v);
7668 +}
7669 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7670 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7671 +{
7672 + return atomic64_add_ret_unchecked(1, v);
7673 +}
7674
7675 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7676 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7677
7678 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7679 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7680 +{
7681 + return atomic_add_ret_unchecked(i, v);
7682 +}
7683 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7684 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7685 +{
7686 + return atomic64_add_ret_unchecked(i, v);
7687 +}
7688
7689 /*
7690 * atomic_inc_and_test - increment and test
7691 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7692 * other cases.
7693 */
7694 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7695 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7696 +{
7697 + return atomic_inc_return_unchecked(v) == 0;
7698 +}
7699 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7700
7701 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7702 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7703 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7704
7705 #define atomic_inc(v) atomic_add(1, v)
7706 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7707 +{
7708 + atomic_add_unchecked(1, v);
7709 +}
7710 #define atomic64_inc(v) atomic64_add(1, v)
7711 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7712 +{
7713 + atomic64_add_unchecked(1, v);
7714 +}
7715
7716 #define atomic_dec(v) atomic_sub(1, v)
7717 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7718 +{
7719 + atomic_sub_unchecked(1, v);
7720 +}
7721 #define atomic64_dec(v) atomic64_sub(1, v)
7722 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7723 +{
7724 + atomic64_sub_unchecked(1, v);
7725 +}
7726
7727 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7728 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7729
7730 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7731 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7732 +{
7733 + return cmpxchg(&v->counter, old, new);
7734 +}
7735 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7736 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7737 +{
7738 + return xchg(&v->counter, new);
7739 +}
7740
7741 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7742 {
7743 - int c, old;
7744 + int c, old, new;
7745 c = atomic_read(v);
7746 for (;;) {
7747 - if (unlikely(c == (u)))
7748 + if (unlikely(c == u))
7749 break;
7750 - old = atomic_cmpxchg((v), c, c + (a));
7751 +
7752 + asm volatile("addcc %2, %0, %0\n"
7753 +
7754 +#ifdef CONFIG_PAX_REFCOUNT
7755 + "tvs %%icc, 6\n"
7756 +#endif
7757 +
7758 + : "=r" (new)
7759 + : "0" (c), "ir" (a)
7760 + : "cc");
7761 +
7762 + old = atomic_cmpxchg(v, c, new);
7763 if (likely(old == c))
7764 break;
7765 c = old;
7766 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7767 #define atomic64_cmpxchg(v, o, n) \
7768 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7769 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7770 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7771 +{
7772 + return xchg(&v->counter, new);
7773 +}
7774
7775 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7776 {
7777 - long c, old;
7778 + long c, old, new;
7779 c = atomic64_read(v);
7780 for (;;) {
7781 - if (unlikely(c == (u)))
7782 + if (unlikely(c == u))
7783 break;
7784 - old = atomic64_cmpxchg((v), c, c + (a));
7785 +
7786 + asm volatile("addcc %2, %0, %0\n"
7787 +
7788 +#ifdef CONFIG_PAX_REFCOUNT
7789 + "tvs %%xcc, 6\n"
7790 +#endif
7791 +
7792 + : "=r" (new)
7793 + : "0" (c), "ir" (a)
7794 + : "cc");
7795 +
7796 + old = atomic64_cmpxchg(v, c, new);
7797 if (likely(old == c))
7798 break;
7799 c = old;
7800 }
7801 - return c != (u);
7802 + return c != u;
7803 }
7804
7805 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7806 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7807 index 5bb6991..5c2132e 100644
7808 --- a/arch/sparc/include/asm/cache.h
7809 +++ b/arch/sparc/include/asm/cache.h
7810 @@ -7,10 +7,12 @@
7811 #ifndef _SPARC_CACHE_H
7812 #define _SPARC_CACHE_H
7813
7814 +#include <linux/const.h>
7815 +
7816 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7817
7818 #define L1_CACHE_SHIFT 5
7819 -#define L1_CACHE_BYTES 32
7820 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7821
7822 #ifdef CONFIG_SPARC32
7823 #define SMP_CACHE_BYTES_SHIFT 5
7824 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7825 index a24e41f..47677ff 100644
7826 --- a/arch/sparc/include/asm/elf_32.h
7827 +++ b/arch/sparc/include/asm/elf_32.h
7828 @@ -114,6 +114,13 @@ typedef struct {
7829
7830 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7831
7832 +#ifdef CONFIG_PAX_ASLR
7833 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7834 +
7835 +#define PAX_DELTA_MMAP_LEN 16
7836 +#define PAX_DELTA_STACK_LEN 16
7837 +#endif
7838 +
7839 /* This yields a mask that user programs can use to figure out what
7840 instruction set this cpu supports. This can NOT be done in userspace
7841 on Sparc. */
7842 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7843 index 370ca1e..d4f4a98 100644
7844 --- a/arch/sparc/include/asm/elf_64.h
7845 +++ b/arch/sparc/include/asm/elf_64.h
7846 @@ -189,6 +189,13 @@ typedef struct {
7847 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7848 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7849
7850 +#ifdef CONFIG_PAX_ASLR
7851 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7852 +
7853 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7854 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7855 +#endif
7856 +
7857 extern unsigned long sparc64_elf_hwcap;
7858 #define ELF_HWCAP sparc64_elf_hwcap
7859
7860 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7861 index 9b1c36d..209298b 100644
7862 --- a/arch/sparc/include/asm/pgalloc_32.h
7863 +++ b/arch/sparc/include/asm/pgalloc_32.h
7864 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7865 }
7866
7867 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7868 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7869
7870 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7871 unsigned long address)
7872 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7873 index bcfe063..b333142 100644
7874 --- a/arch/sparc/include/asm/pgalloc_64.h
7875 +++ b/arch/sparc/include/asm/pgalloc_64.h
7876 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7877 }
7878
7879 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7880 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7881
7882 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7883 {
7884 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7885 index 6fc1348..390c50a 100644
7886 --- a/arch/sparc/include/asm/pgtable_32.h
7887 +++ b/arch/sparc/include/asm/pgtable_32.h
7888 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7889 #define PAGE_SHARED SRMMU_PAGE_SHARED
7890 #define PAGE_COPY SRMMU_PAGE_COPY
7891 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7892 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7893 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7894 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7895 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7896
7897 /* Top-level page directory - dummy used by init-mm.
7898 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7899
7900 /* xwr */
7901 #define __P000 PAGE_NONE
7902 -#define __P001 PAGE_READONLY
7903 -#define __P010 PAGE_COPY
7904 -#define __P011 PAGE_COPY
7905 +#define __P001 PAGE_READONLY_NOEXEC
7906 +#define __P010 PAGE_COPY_NOEXEC
7907 +#define __P011 PAGE_COPY_NOEXEC
7908 #define __P100 PAGE_READONLY
7909 #define __P101 PAGE_READONLY
7910 #define __P110 PAGE_COPY
7911 #define __P111 PAGE_COPY
7912
7913 #define __S000 PAGE_NONE
7914 -#define __S001 PAGE_READONLY
7915 -#define __S010 PAGE_SHARED
7916 -#define __S011 PAGE_SHARED
7917 +#define __S001 PAGE_READONLY_NOEXEC
7918 +#define __S010 PAGE_SHARED_NOEXEC
7919 +#define __S011 PAGE_SHARED_NOEXEC
7920 #define __S100 PAGE_READONLY
7921 #define __S101 PAGE_READONLY
7922 #define __S110 PAGE_SHARED
7923 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7924 index 79da178..c2eede8 100644
7925 --- a/arch/sparc/include/asm/pgtsrmmu.h
7926 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7927 @@ -115,6 +115,11 @@
7928 SRMMU_EXEC | SRMMU_REF)
7929 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7930 SRMMU_EXEC | SRMMU_REF)
7931 +
7932 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7933 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7934 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7935 +
7936 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7937 SRMMU_DIRTY | SRMMU_REF)
7938
7939 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7940 index 9689176..63c18ea 100644
7941 --- a/arch/sparc/include/asm/spinlock_64.h
7942 +++ b/arch/sparc/include/asm/spinlock_64.h
7943 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7944
7945 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7946
7947 -static void inline arch_read_lock(arch_rwlock_t *lock)
7948 +static inline void arch_read_lock(arch_rwlock_t *lock)
7949 {
7950 unsigned long tmp1, tmp2;
7951
7952 __asm__ __volatile__ (
7953 "1: ldsw [%2], %0\n"
7954 " brlz,pn %0, 2f\n"
7955 -"4: add %0, 1, %1\n"
7956 +"4: addcc %0, 1, %1\n"
7957 +
7958 +#ifdef CONFIG_PAX_REFCOUNT
7959 +" tvs %%icc, 6\n"
7960 +#endif
7961 +
7962 " cas [%2], %0, %1\n"
7963 " cmp %0, %1\n"
7964 " bne,pn %%icc, 1b\n"
7965 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
7966 " .previous"
7967 : "=&r" (tmp1), "=&r" (tmp2)
7968 : "r" (lock)
7969 - : "memory");
7970 + : "memory", "cc");
7971 }
7972
7973 -static int inline arch_read_trylock(arch_rwlock_t *lock)
7974 +static inline int arch_read_trylock(arch_rwlock_t *lock)
7975 {
7976 int tmp1, tmp2;
7977
7978 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
7979 "1: ldsw [%2], %0\n"
7980 " brlz,a,pn %0, 2f\n"
7981 " mov 0, %0\n"
7982 -" add %0, 1, %1\n"
7983 +" addcc %0, 1, %1\n"
7984 +
7985 +#ifdef CONFIG_PAX_REFCOUNT
7986 +" tvs %%icc, 6\n"
7987 +#endif
7988 +
7989 " cas [%2], %0, %1\n"
7990 " cmp %0, %1\n"
7991 " bne,pn %%icc, 1b\n"
7992 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
7993 return tmp1;
7994 }
7995
7996 -static void inline arch_read_unlock(arch_rwlock_t *lock)
7997 +static inline void arch_read_unlock(arch_rwlock_t *lock)
7998 {
7999 unsigned long tmp1, tmp2;
8000
8001 __asm__ __volatile__(
8002 "1: lduw [%2], %0\n"
8003 -" sub %0, 1, %1\n"
8004 +" subcc %0, 1, %1\n"
8005 +
8006 +#ifdef CONFIG_PAX_REFCOUNT
8007 +" tvs %%icc, 6\n"
8008 +#endif
8009 +
8010 " cas [%2], %0, %1\n"
8011 " cmp %0, %1\n"
8012 " bne,pn %%xcc, 1b\n"
8013 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8014 : "memory");
8015 }
8016
8017 -static void inline arch_write_lock(arch_rwlock_t *lock)
8018 +static inline void arch_write_lock(arch_rwlock_t *lock)
8019 {
8020 unsigned long mask, tmp1, tmp2;
8021
8022 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8023 : "memory");
8024 }
8025
8026 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8027 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8028 {
8029 __asm__ __volatile__(
8030 " stw %%g0, [%0]"
8031 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8032 : "memory");
8033 }
8034
8035 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8036 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8037 {
8038 unsigned long mask, tmp1, tmp2, result;
8039
8040 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8041 index 25849ae..924c54b 100644
8042 --- a/arch/sparc/include/asm/thread_info_32.h
8043 +++ b/arch/sparc/include/asm/thread_info_32.h
8044 @@ -49,6 +49,8 @@ struct thread_info {
8045 unsigned long w_saved;
8046
8047 struct restart_block restart_block;
8048 +
8049 + unsigned long lowest_stack;
8050 };
8051
8052 /*
8053 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8054 index 269bd92..e46a9b8 100644
8055 --- a/arch/sparc/include/asm/thread_info_64.h
8056 +++ b/arch/sparc/include/asm/thread_info_64.h
8057 @@ -63,6 +63,8 @@ struct thread_info {
8058 struct pt_regs *kern_una_regs;
8059 unsigned int kern_una_insn;
8060
8061 + unsigned long lowest_stack;
8062 +
8063 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8064 };
8065
8066 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8067 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8068 /* flag bit 6 is available */
8069 #define TIF_32BIT 7 /* 32-bit binary */
8070 -/* flag bit 8 is available */
8071 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8072 #define TIF_SECCOMP 9 /* secure computing */
8073 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8074 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8075 +
8076 /* NOTE: Thread flags >= 12 should be ones we have no interest
8077 * in using in assembly, else we can't use the mask as
8078 * an immediate value in instructions such as andcc.
8079 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8080 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8081 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8082 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8083 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8084
8085 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8086 _TIF_DO_NOTIFY_RESUME_MASK | \
8087 _TIF_NEED_RESCHED)
8088 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8089
8090 +#define _TIF_WORK_SYSCALL \
8091 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8092 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8093 +
8094 +
8095 /*
8096 * Thread-synchronous status.
8097 *
8098 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8099 index 0167d26..767bb0c 100644
8100 --- a/arch/sparc/include/asm/uaccess.h
8101 +++ b/arch/sparc/include/asm/uaccess.h
8102 @@ -1,5 +1,6 @@
8103 #ifndef ___ASM_SPARC_UACCESS_H
8104 #define ___ASM_SPARC_UACCESS_H
8105 +
8106 #if defined(__sparc__) && defined(__arch64__)
8107 #include <asm/uaccess_64.h>
8108 #else
8109 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8110 index 53a28dd..50c38c3 100644
8111 --- a/arch/sparc/include/asm/uaccess_32.h
8112 +++ b/arch/sparc/include/asm/uaccess_32.h
8113 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8114
8115 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8116 {
8117 - if (n && __access_ok((unsigned long) to, n))
8118 + if ((long)n < 0)
8119 + return n;
8120 +
8121 + if (n && __access_ok((unsigned long) to, n)) {
8122 + if (!__builtin_constant_p(n))
8123 + check_object_size(from, n, true);
8124 return __copy_user(to, (__force void __user *) from, n);
8125 - else
8126 + } else
8127 return n;
8128 }
8129
8130 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8131 {
8132 + if ((long)n < 0)
8133 + return n;
8134 +
8135 + if (!__builtin_constant_p(n))
8136 + check_object_size(from, n, true);
8137 +
8138 return __copy_user(to, (__force void __user *) from, n);
8139 }
8140
8141 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8142 {
8143 - if (n && __access_ok((unsigned long) from, n))
8144 + if ((long)n < 0)
8145 + return n;
8146 +
8147 + if (n && __access_ok((unsigned long) from, n)) {
8148 + if (!__builtin_constant_p(n))
8149 + check_object_size(to, n, false);
8150 return __copy_user((__force void __user *) to, from, n);
8151 - else
8152 + } else
8153 return n;
8154 }
8155
8156 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8157 {
8158 + if ((long)n < 0)
8159 + return n;
8160 +
8161 return __copy_user((__force void __user *) to, from, n);
8162 }
8163
8164 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8165 index e562d3c..191f176 100644
8166 --- a/arch/sparc/include/asm/uaccess_64.h
8167 +++ b/arch/sparc/include/asm/uaccess_64.h
8168 @@ -10,6 +10,7 @@
8169 #include <linux/compiler.h>
8170 #include <linux/string.h>
8171 #include <linux/thread_info.h>
8172 +#include <linux/kernel.h>
8173 #include <asm/asi.h>
8174 #include <asm/spitfire.h>
8175 #include <asm-generic/uaccess-unaligned.h>
8176 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8177 static inline unsigned long __must_check
8178 copy_from_user(void *to, const void __user *from, unsigned long size)
8179 {
8180 - unsigned long ret = ___copy_from_user(to, from, size);
8181 + unsigned long ret;
8182
8183 + if ((long)size < 0 || size > INT_MAX)
8184 + return size;
8185 +
8186 + if (!__builtin_constant_p(size))
8187 + check_object_size(to, size, false);
8188 +
8189 + ret = ___copy_from_user(to, from, size);
8190 if (unlikely(ret))
8191 ret = copy_from_user_fixup(to, from, size);
8192
8193 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8194 static inline unsigned long __must_check
8195 copy_to_user(void __user *to, const void *from, unsigned long size)
8196 {
8197 - unsigned long ret = ___copy_to_user(to, from, size);
8198 + unsigned long ret;
8199
8200 + if ((long)size < 0 || size > INT_MAX)
8201 + return size;
8202 +
8203 + if (!__builtin_constant_p(size))
8204 + check_object_size(from, size, true);
8205 +
8206 + ret = ___copy_to_user(to, from, size);
8207 if (unlikely(ret))
8208 ret = copy_to_user_fixup(to, from, size);
8209 return ret;
8210 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8211 index 6cf591b..b49e65a 100644
8212 --- a/arch/sparc/kernel/Makefile
8213 +++ b/arch/sparc/kernel/Makefile
8214 @@ -3,7 +3,7 @@
8215 #
8216
8217 asflags-y := -ansi
8218 -ccflags-y := -Werror
8219 +#ccflags-y := -Werror
8220
8221 extra-y := head_$(BITS).o
8222
8223 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8224 index 62eede1..9c5b904 100644
8225 --- a/arch/sparc/kernel/process_32.c
8226 +++ b/arch/sparc/kernel/process_32.c
8227 @@ -125,14 +125,14 @@ void show_regs(struct pt_regs *r)
8228
8229 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8230 r->psr, r->pc, r->npc, r->y, print_tainted());
8231 - printk("PC: <%pS>\n", (void *) r->pc);
8232 + printk("PC: <%pA>\n", (void *) r->pc);
8233 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8234 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8235 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8236 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8237 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8238 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8239 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8240 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8241
8242 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8243 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8244 @@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8245 rw = (struct reg_window32 *) fp;
8246 pc = rw->ins[7];
8247 printk("[%08lx : ", pc);
8248 - printk("%pS ] ", (void *) pc);
8249 + printk("%pA ] ", (void *) pc);
8250 fp = rw->ins[6];
8251 } while (++count < 16);
8252 printk("\n");
8253 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8254 index cdb80b2..5ca141d 100644
8255 --- a/arch/sparc/kernel/process_64.c
8256 +++ b/arch/sparc/kernel/process_64.c
8257 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8258 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8259 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8260 if (regs->tstate & TSTATE_PRIV)
8261 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8262 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8263 }
8264
8265 void show_regs(struct pt_regs *regs)
8266 {
8267 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8268 regs->tpc, regs->tnpc, regs->y, print_tainted());
8269 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8270 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8271 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8272 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8273 regs->u_regs[3]);
8274 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8275 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8276 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8277 regs->u_regs[15]);
8278 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8279 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8280 show_regwindow(regs);
8281 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8282 }
8283 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8284 ((tp && tp->task) ? tp->task->pid : -1));
8285
8286 if (gp->tstate & TSTATE_PRIV) {
8287 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8288 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8289 (void *) gp->tpc,
8290 (void *) gp->o7,
8291 (void *) gp->i7,
8292 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8293 index 9f20566..67eb41b 100644
8294 --- a/arch/sparc/kernel/prom_common.c
8295 +++ b/arch/sparc/kernel/prom_common.c
8296 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8297
8298 unsigned int prom_early_allocated __initdata;
8299
8300 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8301 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8302 .nextprop = prom_common_nextprop,
8303 .getproplen = prom_getproplen,
8304 .getproperty = prom_getproperty,
8305 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8306 index 7ff45e4..a58f271 100644
8307 --- a/arch/sparc/kernel/ptrace_64.c
8308 +++ b/arch/sparc/kernel/ptrace_64.c
8309 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8310 return ret;
8311 }
8312
8313 +#ifdef CONFIG_GRKERNSEC_SETXID
8314 +extern void gr_delayed_cred_worker(void);
8315 +#endif
8316 +
8317 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8318 {
8319 int ret = 0;
8320 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8321 /* do the secure computing check first */
8322 secure_computing_strict(regs->u_regs[UREG_G1]);
8323
8324 +#ifdef CONFIG_GRKERNSEC_SETXID
8325 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8326 + gr_delayed_cred_worker();
8327 +#endif
8328 +
8329 if (test_thread_flag(TIF_SYSCALL_TRACE))
8330 ret = tracehook_report_syscall_entry(regs);
8331
8332 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8333
8334 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8335 {
8336 +#ifdef CONFIG_GRKERNSEC_SETXID
8337 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8338 + gr_delayed_cred_worker();
8339 +#endif
8340 +
8341 audit_syscall_exit(regs);
8342
8343 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8344 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8345 index 3a8d184..49498a8 100644
8346 --- a/arch/sparc/kernel/sys_sparc_32.c
8347 +++ b/arch/sparc/kernel/sys_sparc_32.c
8348 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8349 if (len > TASK_SIZE - PAGE_SIZE)
8350 return -ENOMEM;
8351 if (!addr)
8352 - addr = TASK_UNMAPPED_BASE;
8353 + addr = current->mm->mmap_base;
8354
8355 info.flags = 0;
8356 info.length = len;
8357 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8358 index 708bc29..6bfdfad 100644
8359 --- a/arch/sparc/kernel/sys_sparc_64.c
8360 +++ b/arch/sparc/kernel/sys_sparc_64.c
8361 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8362 struct vm_area_struct * vma;
8363 unsigned long task_size = TASK_SIZE;
8364 int do_color_align;
8365 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8366 struct vm_unmapped_area_info info;
8367
8368 if (flags & MAP_FIXED) {
8369 /* We do not accept a shared mapping if it would violate
8370 * cache aliasing constraints.
8371 */
8372 - if ((flags & MAP_SHARED) &&
8373 + if ((filp || (flags & MAP_SHARED)) &&
8374 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8375 return -EINVAL;
8376 return addr;
8377 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8378 if (filp || (flags & MAP_SHARED))
8379 do_color_align = 1;
8380
8381 +#ifdef CONFIG_PAX_RANDMMAP
8382 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8383 +#endif
8384 +
8385 if (addr) {
8386 if (do_color_align)
8387 addr = COLOR_ALIGN(addr, pgoff);
8388 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8389 addr = PAGE_ALIGN(addr);
8390
8391 vma = find_vma(mm, addr);
8392 - if (task_size - len >= addr &&
8393 - (!vma || addr + len <= vma->vm_start))
8394 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8395 return addr;
8396 }
8397
8398 info.flags = 0;
8399 info.length = len;
8400 - info.low_limit = TASK_UNMAPPED_BASE;
8401 + info.low_limit = mm->mmap_base;
8402 info.high_limit = min(task_size, VA_EXCLUDE_START);
8403 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8404 info.align_offset = pgoff << PAGE_SHIFT;
8405 + info.threadstack_offset = offset;
8406 addr = vm_unmapped_area(&info);
8407
8408 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8409 VM_BUG_ON(addr != -ENOMEM);
8410 info.low_limit = VA_EXCLUDE_END;
8411 +
8412 +#ifdef CONFIG_PAX_RANDMMAP
8413 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8414 + info.low_limit += mm->delta_mmap;
8415 +#endif
8416 +
8417 info.high_limit = task_size;
8418 addr = vm_unmapped_area(&info);
8419 }
8420 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8421 unsigned long task_size = STACK_TOP32;
8422 unsigned long addr = addr0;
8423 int do_color_align;
8424 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8425 struct vm_unmapped_area_info info;
8426
8427 /* This should only ever run for 32-bit processes. */
8428 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8429 /* We do not accept a shared mapping if it would violate
8430 * cache aliasing constraints.
8431 */
8432 - if ((flags & MAP_SHARED) &&
8433 + if ((filp || (flags & MAP_SHARED)) &&
8434 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8435 return -EINVAL;
8436 return addr;
8437 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8438 if (filp || (flags & MAP_SHARED))
8439 do_color_align = 1;
8440
8441 +#ifdef CONFIG_PAX_RANDMMAP
8442 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8443 +#endif
8444 +
8445 /* requesting a specific address */
8446 if (addr) {
8447 if (do_color_align)
8448 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8449 addr = PAGE_ALIGN(addr);
8450
8451 vma = find_vma(mm, addr);
8452 - if (task_size - len >= addr &&
8453 - (!vma || addr + len <= vma->vm_start))
8454 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8455 return addr;
8456 }
8457
8458 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8459 info.high_limit = mm->mmap_base;
8460 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8461 info.align_offset = pgoff << PAGE_SHIFT;
8462 + info.threadstack_offset = offset;
8463 addr = vm_unmapped_area(&info);
8464
8465 /*
8466 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8467 VM_BUG_ON(addr != -ENOMEM);
8468 info.flags = 0;
8469 info.low_limit = TASK_UNMAPPED_BASE;
8470 +
8471 +#ifdef CONFIG_PAX_RANDMMAP
8472 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8473 + info.low_limit += mm->delta_mmap;
8474 +#endif
8475 +
8476 info.high_limit = STACK_TOP32;
8477 addr = vm_unmapped_area(&info);
8478 }
8479 @@ -264,6 +286,10 @@ static unsigned long mmap_rnd(void)
8480 {
8481 unsigned long rnd = 0UL;
8482
8483 +#ifdef CONFIG_PAX_RANDMMAP
8484 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8485 +#endif
8486 +
8487 if (current->flags & PF_RANDOMIZE) {
8488 unsigned long val = get_random_int();
8489 if (test_thread_flag(TIF_32BIT))
8490 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8491 gap == RLIM_INFINITY ||
8492 sysctl_legacy_va_layout) {
8493 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8494 +
8495 +#ifdef CONFIG_PAX_RANDMMAP
8496 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8497 + mm->mmap_base += mm->delta_mmap;
8498 +#endif
8499 +
8500 mm->get_unmapped_area = arch_get_unmapped_area;
8501 mm->unmap_area = arch_unmap_area;
8502 } else {
8503 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8504 gap = (task_size / 6 * 5);
8505
8506 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8507 +
8508 +#ifdef CONFIG_PAX_RANDMMAP
8509 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8510 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8511 +#endif
8512 +
8513 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8514 mm->unmap_area = arch_unmap_area_topdown;
8515 }
8516 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8517 index 22a1098..6255eb9 100644
8518 --- a/arch/sparc/kernel/syscalls.S
8519 +++ b/arch/sparc/kernel/syscalls.S
8520 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8521 #endif
8522 .align 32
8523 1: ldx [%g6 + TI_FLAGS], %l5
8524 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8525 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8526 be,pt %icc, rtrap
8527 nop
8528 call syscall_trace_leave
8529 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8530
8531 srl %i5, 0, %o5 ! IEU1
8532 srl %i2, 0, %o2 ! IEU0 Group
8533 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8534 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8535 bne,pn %icc, linux_syscall_trace32 ! CTI
8536 mov %i0, %l5 ! IEU1
8537 call %l7 ! CTI Group brk forced
8538 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8539
8540 mov %i3, %o3 ! IEU1
8541 mov %i4, %o4 ! IEU0 Group
8542 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8543 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8544 bne,pn %icc, linux_syscall_trace ! CTI Group
8545 mov %i0, %l5 ! IEU0
8546 2: call %l7 ! CTI Group brk forced
8547 @@ -223,7 +223,7 @@ ret_sys_call:
8548
8549 cmp %o0, -ERESTART_RESTARTBLOCK
8550 bgeu,pn %xcc, 1f
8551 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8552 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8553 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8554
8555 2:
8556 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8557 index 654e8aa..45f431b 100644
8558 --- a/arch/sparc/kernel/sysfs.c
8559 +++ b/arch/sparc/kernel/sysfs.c
8560 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8561 return NOTIFY_OK;
8562 }
8563
8564 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8565 +static struct notifier_block sysfs_cpu_nb = {
8566 .notifier_call = sysfs_cpu_notify,
8567 };
8568
8569 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8570 index 6629829..036032d 100644
8571 --- a/arch/sparc/kernel/traps_32.c
8572 +++ b/arch/sparc/kernel/traps_32.c
8573 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8574 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8575 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8576
8577 +extern void gr_handle_kernel_exploit(void);
8578 +
8579 void die_if_kernel(char *str, struct pt_regs *regs)
8580 {
8581 static int die_counter;
8582 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8583 count++ < 30 &&
8584 (((unsigned long) rw) >= PAGE_OFFSET) &&
8585 !(((unsigned long) rw) & 0x7)) {
8586 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8587 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8588 (void *) rw->ins[7]);
8589 rw = (struct reg_window32 *)rw->ins[6];
8590 }
8591 }
8592 printk("Instruction DUMP:");
8593 instruction_dump ((unsigned long *) regs->pc);
8594 - if(regs->psr & PSR_PS)
8595 + if(regs->psr & PSR_PS) {
8596 + gr_handle_kernel_exploit();
8597 do_exit(SIGKILL);
8598 + }
8599 do_exit(SIGSEGV);
8600 }
8601
8602 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8603 index 8d38ca9..845b1d6 100644
8604 --- a/arch/sparc/kernel/traps_64.c
8605 +++ b/arch/sparc/kernel/traps_64.c
8606 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8607 i + 1,
8608 p->trapstack[i].tstate, p->trapstack[i].tpc,
8609 p->trapstack[i].tnpc, p->trapstack[i].tt);
8610 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8611 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8612 }
8613 }
8614
8615 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8616
8617 lvl -= 0x100;
8618 if (regs->tstate & TSTATE_PRIV) {
8619 +
8620 +#ifdef CONFIG_PAX_REFCOUNT
8621 + if (lvl == 6)
8622 + pax_report_refcount_overflow(regs);
8623 +#endif
8624 +
8625 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8626 die_if_kernel(buffer, regs);
8627 }
8628 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8629 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8630 {
8631 char buffer[32];
8632 -
8633 +
8634 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8635 0, lvl, SIGTRAP) == NOTIFY_STOP)
8636 return;
8637
8638 +#ifdef CONFIG_PAX_REFCOUNT
8639 + if (lvl == 6)
8640 + pax_report_refcount_overflow(regs);
8641 +#endif
8642 +
8643 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8644
8645 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8646 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8647 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8648 printk("%s" "ERROR(%d): ",
8649 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8650 - printk("TPC<%pS>\n", (void *) regs->tpc);
8651 + printk("TPC<%pA>\n", (void *) regs->tpc);
8652 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8653 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8654 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8655 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8656 smp_processor_id(),
8657 (type & 0x1) ? 'I' : 'D',
8658 regs->tpc);
8659 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8660 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8661 panic("Irrecoverable Cheetah+ parity error.");
8662 }
8663
8664 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8665 smp_processor_id(),
8666 (type & 0x1) ? 'I' : 'D',
8667 regs->tpc);
8668 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8669 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8670 }
8671
8672 struct sun4v_error_entry {
8673 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8674
8675 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8676 regs->tpc, tl);
8677 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8678 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8679 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8680 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8681 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8682 (void *) regs->u_regs[UREG_I7]);
8683 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8684 "pte[%lx] error[%lx]\n",
8685 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8686
8687 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8688 regs->tpc, tl);
8689 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8690 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8691 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8692 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8693 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8694 (void *) regs->u_regs[UREG_I7]);
8695 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8696 "pte[%lx] error[%lx]\n",
8697 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8698 fp = (unsigned long)sf->fp + STACK_BIAS;
8699 }
8700
8701 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8702 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8703 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8704 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8705 int index = tsk->curr_ret_stack;
8706 if (tsk->ret_stack && index >= graph) {
8707 pc = tsk->ret_stack[index - graph].ret;
8708 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8709 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8710 graph++;
8711 }
8712 }
8713 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8714 return (struct reg_window *) (fp + STACK_BIAS);
8715 }
8716
8717 +extern void gr_handle_kernel_exploit(void);
8718 +
8719 void die_if_kernel(char *str, struct pt_regs *regs)
8720 {
8721 static int die_counter;
8722 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8723 while (rw &&
8724 count++ < 30 &&
8725 kstack_valid(tp, (unsigned long) rw)) {
8726 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8727 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8728 (void *) rw->ins[7]);
8729
8730 rw = kernel_stack_up(rw);
8731 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8732 }
8733 user_instruction_dump ((unsigned int __user *) regs->tpc);
8734 }
8735 - if (regs->tstate & TSTATE_PRIV)
8736 + if (regs->tstate & TSTATE_PRIV) {
8737 + gr_handle_kernel_exploit();
8738 do_exit(SIGKILL);
8739 + }
8740 do_exit(SIGSEGV);
8741 }
8742 EXPORT_SYMBOL(die_if_kernel);
8743 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8744 index 8201c25e..072a2a7 100644
8745 --- a/arch/sparc/kernel/unaligned_64.c
8746 +++ b/arch/sparc/kernel/unaligned_64.c
8747 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8748 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8749
8750 if (__ratelimit(&ratelimit)) {
8751 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8752 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8753 regs->tpc, (void *) regs->tpc);
8754 }
8755 }
8756 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
8757 index eb1624b..55100de 100644
8758 --- a/arch/sparc/kernel/us3_cpufreq.c
8759 +++ b/arch/sparc/kernel/us3_cpufreq.c
8760 @@ -18,14 +18,12 @@
8761 #include <asm/head.h>
8762 #include <asm/timer.h>
8763
8764 -static struct cpufreq_driver *cpufreq_us3_driver;
8765 -
8766 struct us3_freq_percpu_info {
8767 struct cpufreq_frequency_table table[4];
8768 };
8769
8770 /* Indexed by cpu number. */
8771 -static struct us3_freq_percpu_info *us3_freq_table;
8772 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
8773
8774 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
8775 * in the Safari config register.
8776 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
8777
8778 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
8779 {
8780 - if (cpufreq_us3_driver)
8781 - us3_set_cpu_divider_index(policy->cpu, 0);
8782 + us3_set_cpu_divider_index(policy->cpu, 0);
8783
8784 return 0;
8785 }
8786
8787 +static int __init us3_freq_init(void);
8788 +static void __exit us3_freq_exit(void);
8789 +
8790 +static struct cpufreq_driver cpufreq_us3_driver = {
8791 + .init = us3_freq_cpu_init,
8792 + .verify = us3_freq_verify,
8793 + .target = us3_freq_target,
8794 + .get = us3_freq_get,
8795 + .exit = us3_freq_cpu_exit,
8796 + .owner = THIS_MODULE,
8797 + .name = "UltraSPARC-III",
8798 +
8799 +};
8800 +
8801 static int __init us3_freq_init(void)
8802 {
8803 unsigned long manuf, impl, ver;
8804 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
8805 (impl == CHEETAH_IMPL ||
8806 impl == CHEETAH_PLUS_IMPL ||
8807 impl == JAGUAR_IMPL ||
8808 - impl == PANTHER_IMPL)) {
8809 - struct cpufreq_driver *driver;
8810 -
8811 - ret = -ENOMEM;
8812 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
8813 - if (!driver)
8814 - goto err_out;
8815 -
8816 - us3_freq_table = kzalloc(
8817 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
8818 - GFP_KERNEL);
8819 - if (!us3_freq_table)
8820 - goto err_out;
8821 -
8822 - driver->init = us3_freq_cpu_init;
8823 - driver->verify = us3_freq_verify;
8824 - driver->target = us3_freq_target;
8825 - driver->get = us3_freq_get;
8826 - driver->exit = us3_freq_cpu_exit;
8827 - driver->owner = THIS_MODULE,
8828 - strcpy(driver->name, "UltraSPARC-III");
8829 -
8830 - cpufreq_us3_driver = driver;
8831 - ret = cpufreq_register_driver(driver);
8832 - if (ret)
8833 - goto err_out;
8834 -
8835 - return 0;
8836 -
8837 -err_out:
8838 - if (driver) {
8839 - kfree(driver);
8840 - cpufreq_us3_driver = NULL;
8841 - }
8842 - kfree(us3_freq_table);
8843 - us3_freq_table = NULL;
8844 - return ret;
8845 - }
8846 + impl == PANTHER_IMPL))
8847 + return cpufreq_register_driver(&cpufreq_us3_driver);
8848
8849 return -ENODEV;
8850 }
8851
8852 static void __exit us3_freq_exit(void)
8853 {
8854 - if (cpufreq_us3_driver) {
8855 - cpufreq_unregister_driver(cpufreq_us3_driver);
8856 - kfree(cpufreq_us3_driver);
8857 - cpufreq_us3_driver = NULL;
8858 - kfree(us3_freq_table);
8859 - us3_freq_table = NULL;
8860 - }
8861 + cpufreq_unregister_driver(&cpufreq_us3_driver);
8862 }
8863
8864 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
8865 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8866 index 8410065f2..4fd4ca22 100644
8867 --- a/arch/sparc/lib/Makefile
8868 +++ b/arch/sparc/lib/Makefile
8869 @@ -2,7 +2,7 @@
8870 #
8871
8872 asflags-y := -ansi -DST_DIV0=0x02
8873 -ccflags-y := -Werror
8874 +#ccflags-y := -Werror
8875
8876 lib-$(CONFIG_SPARC32) += ashrdi3.o
8877 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8878 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8879 index 85c233d..68500e0 100644
8880 --- a/arch/sparc/lib/atomic_64.S
8881 +++ b/arch/sparc/lib/atomic_64.S
8882 @@ -17,7 +17,12 @@
8883 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8884 BACKOFF_SETUP(%o2)
8885 1: lduw [%o1], %g1
8886 - add %g1, %o0, %g7
8887 + addcc %g1, %o0, %g7
8888 +
8889 +#ifdef CONFIG_PAX_REFCOUNT
8890 + tvs %icc, 6
8891 +#endif
8892 +
8893 cas [%o1], %g1, %g7
8894 cmp %g1, %g7
8895 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8896 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8897 2: BACKOFF_SPIN(%o2, %o3, 1b)
8898 ENDPROC(atomic_add)
8899
8900 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8901 + BACKOFF_SETUP(%o2)
8902 +1: lduw [%o1], %g1
8903 + add %g1, %o0, %g7
8904 + cas [%o1], %g1, %g7
8905 + cmp %g1, %g7
8906 + bne,pn %icc, 2f
8907 + nop
8908 + retl
8909 + nop
8910 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8911 +ENDPROC(atomic_add_unchecked)
8912 +
8913 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8914 BACKOFF_SETUP(%o2)
8915 1: lduw [%o1], %g1
8916 - sub %g1, %o0, %g7
8917 + subcc %g1, %o0, %g7
8918 +
8919 +#ifdef CONFIG_PAX_REFCOUNT
8920 + tvs %icc, 6
8921 +#endif
8922 +
8923 cas [%o1], %g1, %g7
8924 cmp %g1, %g7
8925 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8926 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8927 2: BACKOFF_SPIN(%o2, %o3, 1b)
8928 ENDPROC(atomic_sub)
8929
8930 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8931 + BACKOFF_SETUP(%o2)
8932 +1: lduw [%o1], %g1
8933 + sub %g1, %o0, %g7
8934 + cas [%o1], %g1, %g7
8935 + cmp %g1, %g7
8936 + bne,pn %icc, 2f
8937 + nop
8938 + retl
8939 + nop
8940 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8941 +ENDPROC(atomic_sub_unchecked)
8942 +
8943 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8944 BACKOFF_SETUP(%o2)
8945 1: lduw [%o1], %g1
8946 - add %g1, %o0, %g7
8947 + addcc %g1, %o0, %g7
8948 +
8949 +#ifdef CONFIG_PAX_REFCOUNT
8950 + tvs %icc, 6
8951 +#endif
8952 +
8953 cas [%o1], %g1, %g7
8954 cmp %g1, %g7
8955 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8956 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8957 2: BACKOFF_SPIN(%o2, %o3, 1b)
8958 ENDPROC(atomic_add_ret)
8959
8960 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8961 + BACKOFF_SETUP(%o2)
8962 +1: lduw [%o1], %g1
8963 + addcc %g1, %o0, %g7
8964 + cas [%o1], %g1, %g7
8965 + cmp %g1, %g7
8966 + bne,pn %icc, 2f
8967 + add %g7, %o0, %g7
8968 + sra %g7, 0, %o0
8969 + retl
8970 + nop
8971 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8972 +ENDPROC(atomic_add_ret_unchecked)
8973 +
8974 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8975 BACKOFF_SETUP(%o2)
8976 1: lduw [%o1], %g1
8977 - sub %g1, %o0, %g7
8978 + subcc %g1, %o0, %g7
8979 +
8980 +#ifdef CONFIG_PAX_REFCOUNT
8981 + tvs %icc, 6
8982 +#endif
8983 +
8984 cas [%o1], %g1, %g7
8985 cmp %g1, %g7
8986 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8987 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8988 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8989 BACKOFF_SETUP(%o2)
8990 1: ldx [%o1], %g1
8991 - add %g1, %o0, %g7
8992 + addcc %g1, %o0, %g7
8993 +
8994 +#ifdef CONFIG_PAX_REFCOUNT
8995 + tvs %xcc, 6
8996 +#endif
8997 +
8998 casx [%o1], %g1, %g7
8999 cmp %g1, %g7
9000 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9001 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9002 2: BACKOFF_SPIN(%o2, %o3, 1b)
9003 ENDPROC(atomic64_add)
9004
9005 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9006 + BACKOFF_SETUP(%o2)
9007 +1: ldx [%o1], %g1
9008 + addcc %g1, %o0, %g7
9009 + casx [%o1], %g1, %g7
9010 + cmp %g1, %g7
9011 + bne,pn %xcc, 2f
9012 + nop
9013 + retl
9014 + nop
9015 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9016 +ENDPROC(atomic64_add_unchecked)
9017 +
9018 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9019 BACKOFF_SETUP(%o2)
9020 1: ldx [%o1], %g1
9021 - sub %g1, %o0, %g7
9022 + subcc %g1, %o0, %g7
9023 +
9024 +#ifdef CONFIG_PAX_REFCOUNT
9025 + tvs %xcc, 6
9026 +#endif
9027 +
9028 casx [%o1], %g1, %g7
9029 cmp %g1, %g7
9030 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9031 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9032 2: BACKOFF_SPIN(%o2, %o3, 1b)
9033 ENDPROC(atomic64_sub)
9034
9035 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9036 + BACKOFF_SETUP(%o2)
9037 +1: ldx [%o1], %g1
9038 + subcc %g1, %o0, %g7
9039 + casx [%o1], %g1, %g7
9040 + cmp %g1, %g7
9041 + bne,pn %xcc, 2f
9042 + nop
9043 + retl
9044 + nop
9045 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9046 +ENDPROC(atomic64_sub_unchecked)
9047 +
9048 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9049 BACKOFF_SETUP(%o2)
9050 1: ldx [%o1], %g1
9051 - add %g1, %o0, %g7
9052 + addcc %g1, %o0, %g7
9053 +
9054 +#ifdef CONFIG_PAX_REFCOUNT
9055 + tvs %xcc, 6
9056 +#endif
9057 +
9058 casx [%o1], %g1, %g7
9059 cmp %g1, %g7
9060 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9061 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9062 2: BACKOFF_SPIN(%o2, %o3, 1b)
9063 ENDPROC(atomic64_add_ret)
9064
9065 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9066 + BACKOFF_SETUP(%o2)
9067 +1: ldx [%o1], %g1
9068 + addcc %g1, %o0, %g7
9069 + casx [%o1], %g1, %g7
9070 + cmp %g1, %g7
9071 + bne,pn %xcc, 2f
9072 + add %g7, %o0, %g7
9073 + mov %g7, %o0
9074 + retl
9075 + nop
9076 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9077 +ENDPROC(atomic64_add_ret_unchecked)
9078 +
9079 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9080 BACKOFF_SETUP(%o2)
9081 1: ldx [%o1], %g1
9082 - sub %g1, %o0, %g7
9083 + subcc %g1, %o0, %g7
9084 +
9085 +#ifdef CONFIG_PAX_REFCOUNT
9086 + tvs %xcc, 6
9087 +#endif
9088 +
9089 casx [%o1], %g1, %g7
9090 cmp %g1, %g7
9091 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9092 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9093 index 0c4e35e..745d3e4 100644
9094 --- a/arch/sparc/lib/ksyms.c
9095 +++ b/arch/sparc/lib/ksyms.c
9096 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9097
9098 /* Atomic counter implementation. */
9099 EXPORT_SYMBOL(atomic_add);
9100 +EXPORT_SYMBOL(atomic_add_unchecked);
9101 EXPORT_SYMBOL(atomic_add_ret);
9102 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9103 EXPORT_SYMBOL(atomic_sub);
9104 +EXPORT_SYMBOL(atomic_sub_unchecked);
9105 EXPORT_SYMBOL(atomic_sub_ret);
9106 EXPORT_SYMBOL(atomic64_add);
9107 +EXPORT_SYMBOL(atomic64_add_unchecked);
9108 EXPORT_SYMBOL(atomic64_add_ret);
9109 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9110 EXPORT_SYMBOL(atomic64_sub);
9111 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9112 EXPORT_SYMBOL(atomic64_sub_ret);
9113 EXPORT_SYMBOL(atomic64_dec_if_positive);
9114
9115 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9116 index 30c3ecc..736f015 100644
9117 --- a/arch/sparc/mm/Makefile
9118 +++ b/arch/sparc/mm/Makefile
9119 @@ -2,7 +2,7 @@
9120 #
9121
9122 asflags-y := -ansi
9123 -ccflags-y := -Werror
9124 +#ccflags-y := -Werror
9125
9126 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9127 obj-y += fault_$(BITS).o
9128 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9129 index e98bfda..ea8d221 100644
9130 --- a/arch/sparc/mm/fault_32.c
9131 +++ b/arch/sparc/mm/fault_32.c
9132 @@ -21,6 +21,9 @@
9133 #include <linux/perf_event.h>
9134 #include <linux/interrupt.h>
9135 #include <linux/kdebug.h>
9136 +#include <linux/slab.h>
9137 +#include <linux/pagemap.h>
9138 +#include <linux/compiler.h>
9139
9140 #include <asm/page.h>
9141 #include <asm/pgtable.h>
9142 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9143 return safe_compute_effective_address(regs, insn);
9144 }
9145
9146 +#ifdef CONFIG_PAX_PAGEEXEC
9147 +#ifdef CONFIG_PAX_DLRESOLVE
9148 +static void pax_emuplt_close(struct vm_area_struct *vma)
9149 +{
9150 + vma->vm_mm->call_dl_resolve = 0UL;
9151 +}
9152 +
9153 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9154 +{
9155 + unsigned int *kaddr;
9156 +
9157 + vmf->page = alloc_page(GFP_HIGHUSER);
9158 + if (!vmf->page)
9159 + return VM_FAULT_OOM;
9160 +
9161 + kaddr = kmap(vmf->page);
9162 + memset(kaddr, 0, PAGE_SIZE);
9163 + kaddr[0] = 0x9DE3BFA8U; /* save */
9164 + flush_dcache_page(vmf->page);
9165 + kunmap(vmf->page);
9166 + return VM_FAULT_MAJOR;
9167 +}
9168 +
9169 +static const struct vm_operations_struct pax_vm_ops = {
9170 + .close = pax_emuplt_close,
9171 + .fault = pax_emuplt_fault
9172 +};
9173 +
9174 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9175 +{
9176 + int ret;
9177 +
9178 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9179 + vma->vm_mm = current->mm;
9180 + vma->vm_start = addr;
9181 + vma->vm_end = addr + PAGE_SIZE;
9182 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9183 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9184 + vma->vm_ops = &pax_vm_ops;
9185 +
9186 + ret = insert_vm_struct(current->mm, vma);
9187 + if (ret)
9188 + return ret;
9189 +
9190 + ++current->mm->total_vm;
9191 + return 0;
9192 +}
9193 +#endif
9194 +
9195 +/*
9196 + * PaX: decide what to do with offenders (regs->pc = fault address)
9197 + *
9198 + * returns 1 when task should be killed
9199 + * 2 when patched PLT trampoline was detected
9200 + * 3 when unpatched PLT trampoline was detected
9201 + */
9202 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9203 +{
9204 +
9205 +#ifdef CONFIG_PAX_EMUPLT
9206 + int err;
9207 +
9208 + do { /* PaX: patched PLT emulation #1 */
9209 + unsigned int sethi1, sethi2, jmpl;
9210 +
9211 + err = get_user(sethi1, (unsigned int *)regs->pc);
9212 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9213 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9214 +
9215 + if (err)
9216 + break;
9217 +
9218 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9219 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9220 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9221 + {
9222 + unsigned int addr;
9223 +
9224 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9225 + addr = regs->u_regs[UREG_G1];
9226 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9227 + regs->pc = addr;
9228 + regs->npc = addr+4;
9229 + return 2;
9230 + }
9231 + } while (0);
9232 +
9233 + do { /* PaX: patched PLT emulation #2 */
9234 + unsigned int ba;
9235 +
9236 + err = get_user(ba, (unsigned int *)regs->pc);
9237 +
9238 + if (err)
9239 + break;
9240 +
9241 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9242 + unsigned int addr;
9243 +
9244 + if ((ba & 0xFFC00000U) == 0x30800000U)
9245 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9246 + else
9247 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9248 + regs->pc = addr;
9249 + regs->npc = addr+4;
9250 + return 2;
9251 + }
9252 + } while (0);
9253 +
9254 + do { /* PaX: patched PLT emulation #3 */
9255 + unsigned int sethi, bajmpl, nop;
9256 +
9257 + err = get_user(sethi, (unsigned int *)regs->pc);
9258 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9259 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9260 +
9261 + if (err)
9262 + break;
9263 +
9264 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9265 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9266 + nop == 0x01000000U)
9267 + {
9268 + unsigned int addr;
9269 +
9270 + addr = (sethi & 0x003FFFFFU) << 10;
9271 + regs->u_regs[UREG_G1] = addr;
9272 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9273 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9274 + else
9275 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9276 + regs->pc = addr;
9277 + regs->npc = addr+4;
9278 + return 2;
9279 + }
9280 + } while (0);
9281 +
9282 + do { /* PaX: unpatched PLT emulation step 1 */
9283 + unsigned int sethi, ba, nop;
9284 +
9285 + err = get_user(sethi, (unsigned int *)regs->pc);
9286 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9287 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9288 +
9289 + if (err)
9290 + break;
9291 +
9292 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9293 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9294 + nop == 0x01000000U)
9295 + {
9296 + unsigned int addr, save, call;
9297 +
9298 + if ((ba & 0xFFC00000U) == 0x30800000U)
9299 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9300 + else
9301 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9302 +
9303 + err = get_user(save, (unsigned int *)addr);
9304 + err |= get_user(call, (unsigned int *)(addr+4));
9305 + err |= get_user(nop, (unsigned int *)(addr+8));
9306 + if (err)
9307 + break;
9308 +
9309 +#ifdef CONFIG_PAX_DLRESOLVE
9310 + if (save == 0x9DE3BFA8U &&
9311 + (call & 0xC0000000U) == 0x40000000U &&
9312 + nop == 0x01000000U)
9313 + {
9314 + struct vm_area_struct *vma;
9315 + unsigned long call_dl_resolve;
9316 +
9317 + down_read(&current->mm->mmap_sem);
9318 + call_dl_resolve = current->mm->call_dl_resolve;
9319 + up_read(&current->mm->mmap_sem);
9320 + if (likely(call_dl_resolve))
9321 + goto emulate;
9322 +
9323 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9324 +
9325 + down_write(&current->mm->mmap_sem);
9326 + if (current->mm->call_dl_resolve) {
9327 + call_dl_resolve = current->mm->call_dl_resolve;
9328 + up_write(&current->mm->mmap_sem);
9329 + if (vma)
9330 + kmem_cache_free(vm_area_cachep, vma);
9331 + goto emulate;
9332 + }
9333 +
9334 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9335 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9336 + up_write(&current->mm->mmap_sem);
9337 + if (vma)
9338 + kmem_cache_free(vm_area_cachep, vma);
9339 + return 1;
9340 + }
9341 +
9342 + if (pax_insert_vma(vma, call_dl_resolve)) {
9343 + up_write(&current->mm->mmap_sem);
9344 + kmem_cache_free(vm_area_cachep, vma);
9345 + return 1;
9346 + }
9347 +
9348 + current->mm->call_dl_resolve = call_dl_resolve;
9349 + up_write(&current->mm->mmap_sem);
9350 +
9351 +emulate:
9352 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9353 + regs->pc = call_dl_resolve;
9354 + regs->npc = addr+4;
9355 + return 3;
9356 + }
9357 +#endif
9358 +
9359 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9360 + if ((save & 0xFFC00000U) == 0x05000000U &&
9361 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9362 + nop == 0x01000000U)
9363 + {
9364 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9365 + regs->u_regs[UREG_G2] = addr + 4;
9366 + addr = (save & 0x003FFFFFU) << 10;
9367 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9368 + regs->pc = addr;
9369 + regs->npc = addr+4;
9370 + return 3;
9371 + }
9372 + }
9373 + } while (0);
9374 +
9375 + do { /* PaX: unpatched PLT emulation step 2 */
9376 + unsigned int save, call, nop;
9377 +
9378 + err = get_user(save, (unsigned int *)(regs->pc-4));
9379 + err |= get_user(call, (unsigned int *)regs->pc);
9380 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9381 + if (err)
9382 + break;
9383 +
9384 + if (save == 0x9DE3BFA8U &&
9385 + (call & 0xC0000000U) == 0x40000000U &&
9386 + nop == 0x01000000U)
9387 + {
9388 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9389 +
9390 + regs->u_regs[UREG_RETPC] = regs->pc;
9391 + regs->pc = dl_resolve;
9392 + regs->npc = dl_resolve+4;
9393 + return 3;
9394 + }
9395 + } while (0);
9396 +#endif
9397 +
9398 + return 1;
9399 +}
9400 +
9401 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9402 +{
9403 + unsigned long i;
9404 +
9405 + printk(KERN_ERR "PAX: bytes at PC: ");
9406 + for (i = 0; i < 8; i++) {
9407 + unsigned int c;
9408 + if (get_user(c, (unsigned int *)pc+i))
9409 + printk(KERN_CONT "???????? ");
9410 + else
9411 + printk(KERN_CONT "%08x ", c);
9412 + }
9413 + printk("\n");
9414 +}
9415 +#endif
9416 +
9417 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9418 int text_fault)
9419 {
9420 @@ -230,6 +504,24 @@ good_area:
9421 if (!(vma->vm_flags & VM_WRITE))
9422 goto bad_area;
9423 } else {
9424 +
9425 +#ifdef CONFIG_PAX_PAGEEXEC
9426 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9427 + up_read(&mm->mmap_sem);
9428 + switch (pax_handle_fetch_fault(regs)) {
9429 +
9430 +#ifdef CONFIG_PAX_EMUPLT
9431 + case 2:
9432 + case 3:
9433 + return;
9434 +#endif
9435 +
9436 + }
9437 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9438 + do_group_exit(SIGKILL);
9439 + }
9440 +#endif
9441 +
9442 /* Allow reads even for write-only mappings */
9443 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9444 goto bad_area;
9445 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9446 index 5062ff3..e0b75f3 100644
9447 --- a/arch/sparc/mm/fault_64.c
9448 +++ b/arch/sparc/mm/fault_64.c
9449 @@ -21,6 +21,9 @@
9450 #include <linux/kprobes.h>
9451 #include <linux/kdebug.h>
9452 #include <linux/percpu.h>
9453 +#include <linux/slab.h>
9454 +#include <linux/pagemap.h>
9455 +#include <linux/compiler.h>
9456
9457 #include <asm/page.h>
9458 #include <asm/pgtable.h>
9459 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9460 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9461 regs->tpc);
9462 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9463 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9464 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9465 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9466 dump_stack();
9467 unhandled_fault(regs->tpc, current, regs);
9468 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9469 show_regs(regs);
9470 }
9471
9472 +#ifdef CONFIG_PAX_PAGEEXEC
9473 +#ifdef CONFIG_PAX_DLRESOLVE
9474 +static void pax_emuplt_close(struct vm_area_struct *vma)
9475 +{
9476 + vma->vm_mm->call_dl_resolve = 0UL;
9477 +}
9478 +
9479 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9480 +{
9481 + unsigned int *kaddr;
9482 +
9483 + vmf->page = alloc_page(GFP_HIGHUSER);
9484 + if (!vmf->page)
9485 + return VM_FAULT_OOM;
9486 +
9487 + kaddr = kmap(vmf->page);
9488 + memset(kaddr, 0, PAGE_SIZE);
9489 + kaddr[0] = 0x9DE3BFA8U; /* save */
9490 + flush_dcache_page(vmf->page);
9491 + kunmap(vmf->page);
9492 + return VM_FAULT_MAJOR;
9493 +}
9494 +
9495 +static const struct vm_operations_struct pax_vm_ops = {
9496 + .close = pax_emuplt_close,
9497 + .fault = pax_emuplt_fault
9498 +};
9499 +
9500 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9501 +{
9502 + int ret;
9503 +
9504 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9505 + vma->vm_mm = current->mm;
9506 + vma->vm_start = addr;
9507 + vma->vm_end = addr + PAGE_SIZE;
9508 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9509 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9510 + vma->vm_ops = &pax_vm_ops;
9511 +
9512 + ret = insert_vm_struct(current->mm, vma);
9513 + if (ret)
9514 + return ret;
9515 +
9516 + ++current->mm->total_vm;
9517 + return 0;
9518 +}
9519 +#endif
9520 +
9521 +/*
9522 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9523 + *
9524 + * returns 1 when task should be killed
9525 + * 2 when patched PLT trampoline was detected
9526 + * 3 when unpatched PLT trampoline was detected
9527 + */
9528 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9529 +{
9530 +
9531 +#ifdef CONFIG_PAX_EMUPLT
9532 + int err;
9533 +
9534 + do { /* PaX: patched PLT emulation #1 */
9535 + unsigned int sethi1, sethi2, jmpl;
9536 +
9537 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9538 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9539 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9540 +
9541 + if (err)
9542 + break;
9543 +
9544 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9545 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9546 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9547 + {
9548 + unsigned long addr;
9549 +
9550 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9551 + addr = regs->u_regs[UREG_G1];
9552 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9553 +
9554 + if (test_thread_flag(TIF_32BIT))
9555 + addr &= 0xFFFFFFFFUL;
9556 +
9557 + regs->tpc = addr;
9558 + regs->tnpc = addr+4;
9559 + return 2;
9560 + }
9561 + } while (0);
9562 +
9563 + do { /* PaX: patched PLT emulation #2 */
9564 + unsigned int ba;
9565 +
9566 + err = get_user(ba, (unsigned int *)regs->tpc);
9567 +
9568 + if (err)
9569 + break;
9570 +
9571 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9572 + unsigned long addr;
9573 +
9574 + if ((ba & 0xFFC00000U) == 0x30800000U)
9575 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9576 + else
9577 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9578 +
9579 + if (test_thread_flag(TIF_32BIT))
9580 + addr &= 0xFFFFFFFFUL;
9581 +
9582 + regs->tpc = addr;
9583 + regs->tnpc = addr+4;
9584 + return 2;
9585 + }
9586 + } while (0);
9587 +
9588 + do { /* PaX: patched PLT emulation #3 */
9589 + unsigned int sethi, bajmpl, nop;
9590 +
9591 + err = get_user(sethi, (unsigned int *)regs->tpc);
9592 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9593 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9594 +
9595 + if (err)
9596 + break;
9597 +
9598 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9599 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9600 + nop == 0x01000000U)
9601 + {
9602 + unsigned long addr;
9603 +
9604 + addr = (sethi & 0x003FFFFFU) << 10;
9605 + regs->u_regs[UREG_G1] = addr;
9606 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9607 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9608 + else
9609 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9610 +
9611 + if (test_thread_flag(TIF_32BIT))
9612 + addr &= 0xFFFFFFFFUL;
9613 +
9614 + regs->tpc = addr;
9615 + regs->tnpc = addr+4;
9616 + return 2;
9617 + }
9618 + } while (0);
9619 +
9620 + do { /* PaX: patched PLT emulation #4 */
9621 + unsigned int sethi, mov1, call, mov2;
9622 +
9623 + err = get_user(sethi, (unsigned int *)regs->tpc);
9624 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9625 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9626 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9627 +
9628 + if (err)
9629 + break;
9630 +
9631 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9632 + mov1 == 0x8210000FU &&
9633 + (call & 0xC0000000U) == 0x40000000U &&
9634 + mov2 == 0x9E100001U)
9635 + {
9636 + unsigned long addr;
9637 +
9638 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9639 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9640 +
9641 + if (test_thread_flag(TIF_32BIT))
9642 + addr &= 0xFFFFFFFFUL;
9643 +
9644 + regs->tpc = addr;
9645 + regs->tnpc = addr+4;
9646 + return 2;
9647 + }
9648 + } while (0);
9649 +
9650 + do { /* PaX: patched PLT emulation #5 */
9651 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9652 +
9653 + err = get_user(sethi, (unsigned int *)regs->tpc);
9654 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9655 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9656 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9657 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9658 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9659 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9660 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9661 +
9662 + if (err)
9663 + break;
9664 +
9665 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9666 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9667 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9668 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9669 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9670 + sllx == 0x83287020U &&
9671 + jmpl == 0x81C04005U &&
9672 + nop == 0x01000000U)
9673 + {
9674 + unsigned long addr;
9675 +
9676 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9677 + regs->u_regs[UREG_G1] <<= 32;
9678 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9679 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9680 + regs->tpc = addr;
9681 + regs->tnpc = addr+4;
9682 + return 2;
9683 + }
9684 + } while (0);
9685 +
9686 + do { /* PaX: patched PLT emulation #6 */
9687 + unsigned int sethi, sethi1, sethi2, sllx, or, 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(sllx, (unsigned int *)(regs->tpc+12));
9693 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9694 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9695 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9696 +
9697 + if (err)
9698 + break;
9699 +
9700 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9701 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9702 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9703 + sllx == 0x83287020U &&
9704 + (or & 0xFFFFE000U) == 0x8A116000U &&
9705 + jmpl == 0x81C04005U &&
9706 + nop == 0x01000000U)
9707 + {
9708 + unsigned long addr;
9709 +
9710 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9711 + regs->u_regs[UREG_G1] <<= 32;
9712 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9713 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9714 + regs->tpc = addr;
9715 + regs->tnpc = addr+4;
9716 + return 2;
9717 + }
9718 + } while (0);
9719 +
9720 + do { /* PaX: unpatched PLT emulation step 1 */
9721 + unsigned int sethi, ba, nop;
9722 +
9723 + err = get_user(sethi, (unsigned int *)regs->tpc);
9724 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9725 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9726 +
9727 + if (err)
9728 + break;
9729 +
9730 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9731 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9732 + nop == 0x01000000U)
9733 + {
9734 + unsigned long addr;
9735 + unsigned int save, call;
9736 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9737 +
9738 + if ((ba & 0xFFC00000U) == 0x30800000U)
9739 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9740 + else
9741 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9742 +
9743 + if (test_thread_flag(TIF_32BIT))
9744 + addr &= 0xFFFFFFFFUL;
9745 +
9746 + err = get_user(save, (unsigned int *)addr);
9747 + err |= get_user(call, (unsigned int *)(addr+4));
9748 + err |= get_user(nop, (unsigned int *)(addr+8));
9749 + if (err)
9750 + break;
9751 +
9752 +#ifdef CONFIG_PAX_DLRESOLVE
9753 + if (save == 0x9DE3BFA8U &&
9754 + (call & 0xC0000000U) == 0x40000000U &&
9755 + nop == 0x01000000U)
9756 + {
9757 + struct vm_area_struct *vma;
9758 + unsigned long call_dl_resolve;
9759 +
9760 + down_read(&current->mm->mmap_sem);
9761 + call_dl_resolve = current->mm->call_dl_resolve;
9762 + up_read(&current->mm->mmap_sem);
9763 + if (likely(call_dl_resolve))
9764 + goto emulate;
9765 +
9766 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9767 +
9768 + down_write(&current->mm->mmap_sem);
9769 + if (current->mm->call_dl_resolve) {
9770 + call_dl_resolve = current->mm->call_dl_resolve;
9771 + up_write(&current->mm->mmap_sem);
9772 + if (vma)
9773 + kmem_cache_free(vm_area_cachep, vma);
9774 + goto emulate;
9775 + }
9776 +
9777 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9778 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9779 + up_write(&current->mm->mmap_sem);
9780 + if (vma)
9781 + kmem_cache_free(vm_area_cachep, vma);
9782 + return 1;
9783 + }
9784 +
9785 + if (pax_insert_vma(vma, call_dl_resolve)) {
9786 + up_write(&current->mm->mmap_sem);
9787 + kmem_cache_free(vm_area_cachep, vma);
9788 + return 1;
9789 + }
9790 +
9791 + current->mm->call_dl_resolve = call_dl_resolve;
9792 + up_write(&current->mm->mmap_sem);
9793 +
9794 +emulate:
9795 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9796 + regs->tpc = call_dl_resolve;
9797 + regs->tnpc = addr+4;
9798 + return 3;
9799 + }
9800 +#endif
9801 +
9802 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9803 + if ((save & 0xFFC00000U) == 0x05000000U &&
9804 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9805 + nop == 0x01000000U)
9806 + {
9807 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9808 + regs->u_regs[UREG_G2] = addr + 4;
9809 + addr = (save & 0x003FFFFFU) << 10;
9810 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9811 +
9812 + if (test_thread_flag(TIF_32BIT))
9813 + addr &= 0xFFFFFFFFUL;
9814 +
9815 + regs->tpc = addr;
9816 + regs->tnpc = addr+4;
9817 + return 3;
9818 + }
9819 +
9820 + /* PaX: 64-bit PLT stub */
9821 + err = get_user(sethi1, (unsigned int *)addr);
9822 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9823 + err |= get_user(or1, (unsigned int *)(addr+8));
9824 + err |= get_user(or2, (unsigned int *)(addr+12));
9825 + err |= get_user(sllx, (unsigned int *)(addr+16));
9826 + err |= get_user(add, (unsigned int *)(addr+20));
9827 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9828 + err |= get_user(nop, (unsigned int *)(addr+28));
9829 + if (err)
9830 + break;
9831 +
9832 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9833 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9834 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9835 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9836 + sllx == 0x89293020U &&
9837 + add == 0x8A010005U &&
9838 + jmpl == 0x89C14000U &&
9839 + nop == 0x01000000U)
9840 + {
9841 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9842 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9843 + regs->u_regs[UREG_G4] <<= 32;
9844 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9845 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9846 + regs->u_regs[UREG_G4] = addr + 24;
9847 + addr = regs->u_regs[UREG_G5];
9848 + regs->tpc = addr;
9849 + regs->tnpc = addr+4;
9850 + return 3;
9851 + }
9852 + }
9853 + } while (0);
9854 +
9855 +#ifdef CONFIG_PAX_DLRESOLVE
9856 + do { /* PaX: unpatched PLT emulation step 2 */
9857 + unsigned int save, call, nop;
9858 +
9859 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9860 + err |= get_user(call, (unsigned int *)regs->tpc);
9861 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9862 + if (err)
9863 + break;
9864 +
9865 + if (save == 0x9DE3BFA8U &&
9866 + (call & 0xC0000000U) == 0x40000000U &&
9867 + nop == 0x01000000U)
9868 + {
9869 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9870 +
9871 + if (test_thread_flag(TIF_32BIT))
9872 + dl_resolve &= 0xFFFFFFFFUL;
9873 +
9874 + regs->u_regs[UREG_RETPC] = regs->tpc;
9875 + regs->tpc = dl_resolve;
9876 + regs->tnpc = dl_resolve+4;
9877 + return 3;
9878 + }
9879 + } while (0);
9880 +#endif
9881 +
9882 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9883 + unsigned int sethi, ba, nop;
9884 +
9885 + err = get_user(sethi, (unsigned int *)regs->tpc);
9886 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9887 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9888 +
9889 + if (err)
9890 + break;
9891 +
9892 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9893 + (ba & 0xFFF00000U) == 0x30600000U &&
9894 + nop == 0x01000000U)
9895 + {
9896 + unsigned long addr;
9897 +
9898 + addr = (sethi & 0x003FFFFFU) << 10;
9899 + regs->u_regs[UREG_G1] = addr;
9900 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9901 +
9902 + if (test_thread_flag(TIF_32BIT))
9903 + addr &= 0xFFFFFFFFUL;
9904 +
9905 + regs->tpc = addr;
9906 + regs->tnpc = addr+4;
9907 + return 2;
9908 + }
9909 + } while (0);
9910 +
9911 +#endif
9912 +
9913 + return 1;
9914 +}
9915 +
9916 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9917 +{
9918 + unsigned long i;
9919 +
9920 + printk(KERN_ERR "PAX: bytes at PC: ");
9921 + for (i = 0; i < 8; i++) {
9922 + unsigned int c;
9923 + if (get_user(c, (unsigned int *)pc+i))
9924 + printk(KERN_CONT "???????? ");
9925 + else
9926 + printk(KERN_CONT "%08x ", c);
9927 + }
9928 + printk("\n");
9929 +}
9930 +#endif
9931 +
9932 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9933 {
9934 struct mm_struct *mm = current->mm;
9935 @@ -341,6 +804,29 @@ retry:
9936 if (!vma)
9937 goto bad_area;
9938
9939 +#ifdef CONFIG_PAX_PAGEEXEC
9940 + /* PaX: detect ITLB misses on non-exec pages */
9941 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9942 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9943 + {
9944 + if (address != regs->tpc)
9945 + goto good_area;
9946 +
9947 + up_read(&mm->mmap_sem);
9948 + switch (pax_handle_fetch_fault(regs)) {
9949 +
9950 +#ifdef CONFIG_PAX_EMUPLT
9951 + case 2:
9952 + case 3:
9953 + return;
9954 +#endif
9955 +
9956 + }
9957 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9958 + do_group_exit(SIGKILL);
9959 + }
9960 +#endif
9961 +
9962 /* Pure DTLB misses do not tell us whether the fault causing
9963 * load/store/atomic was a write or not, it only says that there
9964 * was no match. So in such a case we (carefully) read the
9965 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9966 index d2b5944..bd813f2 100644
9967 --- a/arch/sparc/mm/hugetlbpage.c
9968 +++ b/arch/sparc/mm/hugetlbpage.c
9969 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9970
9971 info.flags = 0;
9972 info.length = len;
9973 - info.low_limit = TASK_UNMAPPED_BASE;
9974 + info.low_limit = mm->mmap_base;
9975 info.high_limit = min(task_size, VA_EXCLUDE_START);
9976 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9977 info.align_offset = 0;
9978 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9979 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9980 VM_BUG_ON(addr != -ENOMEM);
9981 info.low_limit = VA_EXCLUDE_END;
9982 +
9983 +#ifdef CONFIG_PAX_RANDMMAP
9984 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9985 + info.low_limit += mm->delta_mmap;
9986 +#endif
9987 +
9988 info.high_limit = task_size;
9989 addr = vm_unmapped_area(&info);
9990 }
9991 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9992 VM_BUG_ON(addr != -ENOMEM);
9993 info.flags = 0;
9994 info.low_limit = TASK_UNMAPPED_BASE;
9995 +
9996 +#ifdef CONFIG_PAX_RANDMMAP
9997 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9998 + info.low_limit += mm->delta_mmap;
9999 +#endif
10000 +
10001 info.high_limit = STACK_TOP32;
10002 addr = vm_unmapped_area(&info);
10003 }
10004 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10005 struct mm_struct *mm = current->mm;
10006 struct vm_area_struct *vma;
10007 unsigned long task_size = TASK_SIZE;
10008 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10009
10010 if (test_thread_flag(TIF_32BIT))
10011 task_size = STACK_TOP32;
10012 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10013 return addr;
10014 }
10015
10016 +#ifdef CONFIG_PAX_RANDMMAP
10017 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10018 +#endif
10019 +
10020 if (addr) {
10021 addr = ALIGN(addr, HPAGE_SIZE);
10022 vma = find_vma(mm, addr);
10023 - if (task_size - len >= addr &&
10024 - (!vma || addr + len <= vma->vm_start))
10025 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10026 return addr;
10027 }
10028 if (mm->get_unmapped_area == arch_get_unmapped_area)
10029 diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
10030 index 83d89bc..37e7bc4 100644
10031 --- a/arch/sparc/mm/tlb.c
10032 +++ b/arch/sparc/mm/tlb.c
10033 @@ -85,8 +85,8 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,
10034 }
10035
10036 if (!tb->active) {
10037 - global_flush_tlb_page(mm, vaddr);
10038 flush_tsb_user_page(mm, vaddr);
10039 + global_flush_tlb_page(mm, vaddr);
10040 goto out;
10041 }
10042
10043 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10044 index f4500c6..889656c 100644
10045 --- a/arch/tile/include/asm/atomic_64.h
10046 +++ b/arch/tile/include/asm/atomic_64.h
10047 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10048
10049 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10050
10051 +#define atomic64_read_unchecked(v) atomic64_read(v)
10052 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10053 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10054 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10055 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10056 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10057 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10058 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10059 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10060 +
10061 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10062 #define smp_mb__before_atomic_dec() smp_mb()
10063 #define smp_mb__after_atomic_dec() smp_mb()
10064 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10065 index a9a5299..0fce79e 100644
10066 --- a/arch/tile/include/asm/cache.h
10067 +++ b/arch/tile/include/asm/cache.h
10068 @@ -15,11 +15,12 @@
10069 #ifndef _ASM_TILE_CACHE_H
10070 #define _ASM_TILE_CACHE_H
10071
10072 +#include <linux/const.h>
10073 #include <arch/chip.h>
10074
10075 /* bytes per L1 data cache line */
10076 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10077 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10078 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10079
10080 /* bytes per L2 cache line */
10081 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10082 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10083 index 9ab078a..d6635c2 100644
10084 --- a/arch/tile/include/asm/uaccess.h
10085 +++ b/arch/tile/include/asm/uaccess.h
10086 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10087 const void __user *from,
10088 unsigned long n)
10089 {
10090 - int sz = __compiletime_object_size(to);
10091 + size_t sz = __compiletime_object_size(to);
10092
10093 - if (likely(sz == -1 || sz >= n))
10094 + if (likely(sz == (size_t)-1 || sz >= n))
10095 n = _copy_from_user(to, from, n);
10096 else
10097 copy_from_user_overflow();
10098 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10099 index 650ccff..45fe2d6 100644
10100 --- a/arch/tile/mm/hugetlbpage.c
10101 +++ b/arch/tile/mm/hugetlbpage.c
10102 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10103 info.high_limit = TASK_SIZE;
10104 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10105 info.align_offset = 0;
10106 + info.threadstack_offset = 0;
10107 return vm_unmapped_area(&info);
10108 }
10109
10110 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10111 info.high_limit = current->mm->mmap_base;
10112 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10113 info.align_offset = 0;
10114 + info.threadstack_offset = 0;
10115 addr = vm_unmapped_area(&info);
10116
10117 /*
10118 diff --git a/arch/um/Makefile b/arch/um/Makefile
10119 index 133f7de..1d6f2f1 100644
10120 --- a/arch/um/Makefile
10121 +++ b/arch/um/Makefile
10122 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10123 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10124 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10125
10126 +ifdef CONSTIFY_PLUGIN
10127 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10128 +endif
10129 +
10130 #This will adjust *FLAGS accordingly to the platform.
10131 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10132
10133 diff --git a/arch/um/defconfig b/arch/um/defconfig
10134 index 08107a7..ab22afe 100644
10135 --- a/arch/um/defconfig
10136 +++ b/arch/um/defconfig
10137 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10138 CONFIG_X86_L1_CACHE_SHIFT=5
10139 CONFIG_X86_XADD=y
10140 CONFIG_X86_PPRO_FENCE=y
10141 -CONFIG_X86_WP_WORKS_OK=y
10142 CONFIG_X86_INVLPG=y
10143 CONFIG_X86_BSWAP=y
10144 CONFIG_X86_POPAD_OK=y
10145 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10146 index 19e1bdd..3665b77 100644
10147 --- a/arch/um/include/asm/cache.h
10148 +++ b/arch/um/include/asm/cache.h
10149 @@ -1,6 +1,7 @@
10150 #ifndef __UM_CACHE_H
10151 #define __UM_CACHE_H
10152
10153 +#include <linux/const.h>
10154
10155 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10156 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10157 @@ -12,6 +13,6 @@
10158 # define L1_CACHE_SHIFT 5
10159 #endif
10160
10161 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10162 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10163
10164 #endif
10165 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10166 index 2e0a6b1..a64d0f5 100644
10167 --- a/arch/um/include/asm/kmap_types.h
10168 +++ b/arch/um/include/asm/kmap_types.h
10169 @@ -8,6 +8,6 @@
10170
10171 /* No more #include "asm/arch/kmap_types.h" ! */
10172
10173 -#define KM_TYPE_NR 14
10174 +#define KM_TYPE_NR 15
10175
10176 #endif
10177 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10178 index 5ff53d9..5850cdf 100644
10179 --- a/arch/um/include/asm/page.h
10180 +++ b/arch/um/include/asm/page.h
10181 @@ -14,6 +14,9 @@
10182 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10183 #define PAGE_MASK (~(PAGE_SIZE-1))
10184
10185 +#define ktla_ktva(addr) (addr)
10186 +#define ktva_ktla(addr) (addr)
10187 +
10188 #ifndef __ASSEMBLY__
10189
10190 struct page;
10191 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10192 index 0032f92..cd151e0 100644
10193 --- a/arch/um/include/asm/pgtable-3level.h
10194 +++ b/arch/um/include/asm/pgtable-3level.h
10195 @@ -58,6 +58,7 @@
10196 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10197 #define pud_populate(mm, pud, pmd) \
10198 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10199 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10200
10201 #ifdef CONFIG_64BIT
10202 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10203 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10204 index b462b13..e7a19aa 100644
10205 --- a/arch/um/kernel/process.c
10206 +++ b/arch/um/kernel/process.c
10207 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10208 return 2;
10209 }
10210
10211 -/*
10212 - * Only x86 and x86_64 have an arch_align_stack().
10213 - * All other arches have "#define arch_align_stack(x) (x)"
10214 - * in their asm/system.h
10215 - * As this is included in UML from asm-um/system-generic.h,
10216 - * we can use it to behave as the subarch does.
10217 - */
10218 -#ifndef arch_align_stack
10219 -unsigned long arch_align_stack(unsigned long sp)
10220 -{
10221 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10222 - sp -= get_random_int() % 8192;
10223 - return sp & ~0xf;
10224 -}
10225 -#endif
10226 -
10227 unsigned long get_wchan(struct task_struct *p)
10228 {
10229 unsigned long stack_page, sp, ip;
10230 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10231 index ad8f795..2c7eec6 100644
10232 --- a/arch/unicore32/include/asm/cache.h
10233 +++ b/arch/unicore32/include/asm/cache.h
10234 @@ -12,8 +12,10 @@
10235 #ifndef __UNICORE_CACHE_H__
10236 #define __UNICORE_CACHE_H__
10237
10238 -#define L1_CACHE_SHIFT (5)
10239 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10240 +#include <linux/const.h>
10241 +
10242 +#define L1_CACHE_SHIFT 5
10243 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10244
10245 /*
10246 * Memory returned by kmalloc() may be used for DMA, so we must make
10247 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10248 index de80b33..c0f0899 100644
10249 --- a/arch/x86/Kconfig
10250 +++ b/arch/x86/Kconfig
10251 @@ -243,7 +243,7 @@ config X86_HT
10252
10253 config X86_32_LAZY_GS
10254 def_bool y
10255 - depends on X86_32 && !CC_STACKPROTECTOR
10256 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10257
10258 config ARCH_HWEIGHT_CFLAGS
10259 string
10260 @@ -1076,6 +1076,7 @@ config MICROCODE_EARLY
10261
10262 config X86_MSR
10263 tristate "/dev/cpu/*/msr - Model-specific register support"
10264 + depends on !GRKERNSEC_KMEM
10265 ---help---
10266 This device gives privileged processes access to the x86
10267 Model-Specific Registers (MSRs). It is a character device with
10268 @@ -1099,7 +1100,7 @@ choice
10269
10270 config NOHIGHMEM
10271 bool "off"
10272 - depends on !X86_NUMAQ
10273 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10274 ---help---
10275 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10276 However, the address space of 32-bit x86 processors is only 4
10277 @@ -1136,7 +1137,7 @@ config NOHIGHMEM
10278
10279 config HIGHMEM4G
10280 bool "4GB"
10281 - depends on !X86_NUMAQ
10282 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10283 ---help---
10284 Select this if you have a 32-bit processor and between 1 and 4
10285 gigabytes of physical RAM.
10286 @@ -1189,7 +1190,7 @@ config PAGE_OFFSET
10287 hex
10288 default 0xB0000000 if VMSPLIT_3G_OPT
10289 default 0x80000000 if VMSPLIT_2G
10290 - default 0x78000000 if VMSPLIT_2G_OPT
10291 + default 0x70000000 if VMSPLIT_2G_OPT
10292 default 0x40000000 if VMSPLIT_1G
10293 default 0xC0000000
10294 depends on X86_32
10295 @@ -1587,6 +1588,7 @@ config SECCOMP
10296
10297 config CC_STACKPROTECTOR
10298 bool "Enable -fstack-protector buffer overflow detection"
10299 + depends on X86_64 || !PAX_MEMORY_UDEREF
10300 ---help---
10301 This option turns on the -fstack-protector GCC feature. This
10302 feature puts, at the beginning of functions, a canary value on
10303 @@ -1706,6 +1708,8 @@ config X86_NEED_RELOCS
10304 config PHYSICAL_ALIGN
10305 hex "Alignment value to which kernel should be aligned" if X86_32
10306 default "0x1000000"
10307 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10308 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10309 range 0x2000 0x1000000
10310 ---help---
10311 This value puts the alignment restrictions on physical address
10312 @@ -1781,9 +1785,10 @@ config DEBUG_HOTPLUG_CPU0
10313 If unsure, say N.
10314
10315 config COMPAT_VDSO
10316 - def_bool y
10317 + def_bool n
10318 prompt "Compat VDSO support"
10319 depends on X86_32 || IA32_EMULATION
10320 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10321 ---help---
10322 Map the 32-bit VDSO to the predictable old-style address too.
10323
10324 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10325 index c026cca..14657ae 100644
10326 --- a/arch/x86/Kconfig.cpu
10327 +++ b/arch/x86/Kconfig.cpu
10328 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10329
10330 config X86_F00F_BUG
10331 def_bool y
10332 - depends on M586MMX || M586TSC || M586 || M486
10333 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10334
10335 config X86_INVD_BUG
10336 def_bool y
10337 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10338
10339 config X86_ALIGNMENT_16
10340 def_bool y
10341 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10342 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10343
10344 config X86_INTEL_USERCOPY
10345 def_bool y
10346 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10347 # generates cmov.
10348 config X86_CMOV
10349 def_bool y
10350 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10351 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10352
10353 config X86_MINIMUM_CPU_FAMILY
10354 int
10355 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10356 index b322f12..652d0d9 100644
10357 --- a/arch/x86/Kconfig.debug
10358 +++ b/arch/x86/Kconfig.debug
10359 @@ -84,7 +84,7 @@ config X86_PTDUMP
10360 config DEBUG_RODATA
10361 bool "Write protect kernel read-only data structures"
10362 default y
10363 - depends on DEBUG_KERNEL
10364 + depends on DEBUG_KERNEL && BROKEN
10365 ---help---
10366 Mark the kernel read-only data as write-protected in the pagetables,
10367 in order to catch accidental (and incorrect) writes to such const
10368 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10369
10370 config DEBUG_SET_MODULE_RONX
10371 bool "Set loadable kernel module data as NX and text as RO"
10372 - depends on MODULES
10373 + depends on MODULES && BROKEN
10374 ---help---
10375 This option helps catch unintended modifications to loadable
10376 kernel module's text and read-only data. It also prevents execution
10377 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10378
10379 config DEBUG_STRICT_USER_COPY_CHECKS
10380 bool "Strict copy size checks"
10381 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10382 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10383 ---help---
10384 Enabling this option turns a certain set of sanity checks for user
10385 copy operations into compile time failures.
10386 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10387 index 5c47726..8c4fa67 100644
10388 --- a/arch/x86/Makefile
10389 +++ b/arch/x86/Makefile
10390 @@ -54,6 +54,7 @@ else
10391 UTS_MACHINE := x86_64
10392 CHECKFLAGS += -D__x86_64__ -m64
10393
10394 + biarch := $(call cc-option,-m64)
10395 KBUILD_AFLAGS += -m64
10396 KBUILD_CFLAGS += -m64
10397
10398 @@ -234,3 +235,12 @@ define archhelp
10399 echo ' FDARGS="..." arguments for the booted kernel'
10400 echo ' FDINITRD=file initrd for the booted kernel'
10401 endef
10402 +
10403 +define OLD_LD
10404 +
10405 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10406 +*** Please upgrade your binutils to 2.18 or newer
10407 +endef
10408 +
10409 +archprepare:
10410 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10411 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10412 index 379814b..add62ce 100644
10413 --- a/arch/x86/boot/Makefile
10414 +++ b/arch/x86/boot/Makefile
10415 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10416 $(call cc-option, -fno-stack-protector) \
10417 $(call cc-option, -mpreferred-stack-boundary=2)
10418 KBUILD_CFLAGS += $(call cc-option, -m32)
10419 +ifdef CONSTIFY_PLUGIN
10420 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10421 +endif
10422 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10423 GCOV_PROFILE := n
10424
10425 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10426 index 878e4b9..20537ab 100644
10427 --- a/arch/x86/boot/bitops.h
10428 +++ b/arch/x86/boot/bitops.h
10429 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10430 u8 v;
10431 const u32 *p = (const u32 *)addr;
10432
10433 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10434 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10435 return v;
10436 }
10437
10438 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10439
10440 static inline void set_bit(int nr, void *addr)
10441 {
10442 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10443 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10444 }
10445
10446 #endif /* BOOT_BITOPS_H */
10447 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10448 index 5b75319..331a4ca 100644
10449 --- a/arch/x86/boot/boot.h
10450 +++ b/arch/x86/boot/boot.h
10451 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10452 static inline u16 ds(void)
10453 {
10454 u16 seg;
10455 - asm("movw %%ds,%0" : "=rm" (seg));
10456 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10457 return seg;
10458 }
10459
10460 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10461 static inline int memcmp(const void *s1, const void *s2, size_t len)
10462 {
10463 u8 diff;
10464 - asm("repe; cmpsb; setnz %0"
10465 + asm volatile("repe; cmpsb; setnz %0"
10466 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10467 return diff;
10468 }
10469 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10470 index 5ef205c..342191d 100644
10471 --- a/arch/x86/boot/compressed/Makefile
10472 +++ b/arch/x86/boot/compressed/Makefile
10473 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10474 KBUILD_CFLAGS += $(cflags-y)
10475 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10476 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10477 +ifdef CONSTIFY_PLUGIN
10478 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10479 +endif
10480
10481 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10482 GCOV_PROFILE := n
10483 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10484 index c205035..5853587 100644
10485 --- a/arch/x86/boot/compressed/eboot.c
10486 +++ b/arch/x86/boot/compressed/eboot.c
10487 @@ -150,7 +150,6 @@ again:
10488 *addr = max_addr;
10489 }
10490
10491 -free_pool:
10492 efi_call_phys1(sys_table->boottime->free_pool, map);
10493
10494 fail:
10495 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10496 if (i == map_size / desc_size)
10497 status = EFI_NOT_FOUND;
10498
10499 -free_pool:
10500 efi_call_phys1(sys_table->boottime->free_pool, map);
10501 fail:
10502 return status;
10503 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
10504 index a53440e..c3dbf1e 100644
10505 --- a/arch/x86/boot/compressed/efi_stub_32.S
10506 +++ b/arch/x86/boot/compressed/efi_stub_32.S
10507 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
10508 * parameter 2, ..., param n. To make things easy, we save the return
10509 * address of efi_call_phys in a global variable.
10510 */
10511 - popl %ecx
10512 - movl %ecx, saved_return_addr(%edx)
10513 - /* get the function pointer into ECX*/
10514 - popl %ecx
10515 - movl %ecx, efi_rt_function_ptr(%edx)
10516 + popl saved_return_addr(%edx)
10517 + popl efi_rt_function_ptr(%edx)
10518
10519 /*
10520 * 3. Call the physical function.
10521 */
10522 - call *%ecx
10523 + call *efi_rt_function_ptr(%edx)
10524
10525 /*
10526 * 4. Balance the stack. And because EAX contain the return value,
10527 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
10528 1: popl %edx
10529 subl $1b, %edx
10530
10531 - movl efi_rt_function_ptr(%edx), %ecx
10532 - pushl %ecx
10533 + pushl efi_rt_function_ptr(%edx)
10534
10535 /*
10536 * 10. Push the saved return address onto the stack and return.
10537 */
10538 - movl saved_return_addr(%edx), %ecx
10539 - pushl %ecx
10540 - ret
10541 + jmpl *saved_return_addr(%edx)
10542 ENDPROC(efi_call_phys)
10543 .previous
10544
10545 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10546 index 1e3184f..0d11e2e 100644
10547 --- a/arch/x86/boot/compressed/head_32.S
10548 +++ b/arch/x86/boot/compressed/head_32.S
10549 @@ -118,7 +118,7 @@ preferred_addr:
10550 notl %eax
10551 andl %eax, %ebx
10552 #else
10553 - movl $LOAD_PHYSICAL_ADDR, %ebx
10554 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10555 #endif
10556
10557 /* Target address to relocate to for decompression */
10558 @@ -204,7 +204,7 @@ relocated:
10559 * and where it was actually loaded.
10560 */
10561 movl %ebp, %ebx
10562 - subl $LOAD_PHYSICAL_ADDR, %ebx
10563 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10564 jz 2f /* Nothing to be done if loaded at compiled addr. */
10565 /*
10566 * Process relocations.
10567 @@ -212,8 +212,7 @@ relocated:
10568
10569 1: subl $4, %edi
10570 movl (%edi), %ecx
10571 - testl %ecx, %ecx
10572 - jz 2f
10573 + jecxz 2f
10574 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10575 jmp 1b
10576 2:
10577 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10578 index c1d383d..57ab51c 100644
10579 --- a/arch/x86/boot/compressed/head_64.S
10580 +++ b/arch/x86/boot/compressed/head_64.S
10581 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10582 notl %eax
10583 andl %eax, %ebx
10584 #else
10585 - movl $LOAD_PHYSICAL_ADDR, %ebx
10586 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10587 #endif
10588
10589 /* Target address to relocate to for decompression */
10590 @@ -272,7 +272,7 @@ preferred_addr:
10591 notq %rax
10592 andq %rax, %rbp
10593 #else
10594 - movq $LOAD_PHYSICAL_ADDR, %rbp
10595 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10596 #endif
10597
10598 /* Target address to relocate to for decompression */
10599 @@ -363,8 +363,8 @@ gdt:
10600 .long gdt
10601 .word 0
10602 .quad 0x0000000000000000 /* NULL descriptor */
10603 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10604 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10605 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10606 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10607 .quad 0x0080890000000000 /* TS descriptor */
10608 .quad 0x0000000000000000 /* TS continued */
10609 gdt_end:
10610 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10611 index 7cb56c6..d382d84 100644
10612 --- a/arch/x86/boot/compressed/misc.c
10613 +++ b/arch/x86/boot/compressed/misc.c
10614 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10615 case PT_LOAD:
10616 #ifdef CONFIG_RELOCATABLE
10617 dest = output;
10618 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10619 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10620 #else
10621 dest = (void *)(phdr->p_paddr);
10622 #endif
10623 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10624 error("Destination address too large");
10625 #endif
10626 #ifndef CONFIG_RELOCATABLE
10627 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10628 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10629 error("Wrong destination address");
10630 #endif
10631
10632 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10633 index 4d3ff03..e4972ff 100644
10634 --- a/arch/x86/boot/cpucheck.c
10635 +++ b/arch/x86/boot/cpucheck.c
10636 @@ -74,7 +74,7 @@ static int has_fpu(void)
10637 u16 fcw = -1, fsw = -1;
10638 u32 cr0;
10639
10640 - asm("movl %%cr0,%0" : "=r" (cr0));
10641 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10642 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10643 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10644 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10645 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10646 {
10647 u32 f0, f1;
10648
10649 - asm("pushfl ; "
10650 + asm volatile("pushfl ; "
10651 "pushfl ; "
10652 "popl %0 ; "
10653 "movl %0,%1 ; "
10654 @@ -115,7 +115,7 @@ static void get_flags(void)
10655 set_bit(X86_FEATURE_FPU, cpu.flags);
10656
10657 if (has_eflag(X86_EFLAGS_ID)) {
10658 - asm("cpuid"
10659 + asm volatile("cpuid"
10660 : "=a" (max_intel_level),
10661 "=b" (cpu_vendor[0]),
10662 "=d" (cpu_vendor[1]),
10663 @@ -124,7 +124,7 @@ static void get_flags(void)
10664
10665 if (max_intel_level >= 0x00000001 &&
10666 max_intel_level <= 0x0000ffff) {
10667 - asm("cpuid"
10668 + asm volatile("cpuid"
10669 : "=a" (tfms),
10670 "=c" (cpu.flags[4]),
10671 "=d" (cpu.flags[0])
10672 @@ -136,7 +136,7 @@ static void get_flags(void)
10673 cpu.model += ((tfms >> 16) & 0xf) << 4;
10674 }
10675
10676 - asm("cpuid"
10677 + asm volatile("cpuid"
10678 : "=a" (max_amd_level)
10679 : "a" (0x80000000)
10680 : "ebx", "ecx", "edx");
10681 @@ -144,7 +144,7 @@ static void get_flags(void)
10682 if (max_amd_level >= 0x80000001 &&
10683 max_amd_level <= 0x8000ffff) {
10684 u32 eax = 0x80000001;
10685 - asm("cpuid"
10686 + asm volatile("cpuid"
10687 : "+a" (eax),
10688 "=c" (cpu.flags[6]),
10689 "=d" (cpu.flags[1])
10690 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10691 u32 ecx = MSR_K7_HWCR;
10692 u32 eax, edx;
10693
10694 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10695 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10696 eax &= ~(1 << 15);
10697 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10698 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10699
10700 get_flags(); /* Make sure it really did something */
10701 err = check_flags();
10702 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10703 u32 ecx = MSR_VIA_FCR;
10704 u32 eax, edx;
10705
10706 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10707 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10708 eax |= (1<<1)|(1<<7);
10709 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10710 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10711
10712 set_bit(X86_FEATURE_CX8, cpu.flags);
10713 err = check_flags();
10714 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10715 u32 eax, edx;
10716 u32 level = 1;
10717
10718 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10719 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10720 - asm("cpuid"
10721 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10722 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10723 + asm volatile("cpuid"
10724 : "+a" (level), "=d" (cpu.flags[0])
10725 : : "ecx", "ebx");
10726 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10727 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10728
10729 err = check_flags();
10730 }
10731 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10732 index 9ec06a1..2c25e79 100644
10733 --- a/arch/x86/boot/header.S
10734 +++ b/arch/x86/boot/header.S
10735 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10736 # single linked list of
10737 # struct setup_data
10738
10739 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10740 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10741
10742 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10743 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10744 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10745 +#else
10746 #define VO_INIT_SIZE (VO__end - VO__text)
10747 +#endif
10748 #if ZO_INIT_SIZE > VO_INIT_SIZE
10749 #define INIT_SIZE ZO_INIT_SIZE
10750 #else
10751 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10752 index db75d07..8e6d0af 100644
10753 --- a/arch/x86/boot/memory.c
10754 +++ b/arch/x86/boot/memory.c
10755 @@ -19,7 +19,7 @@
10756
10757 static int detect_memory_e820(void)
10758 {
10759 - int count = 0;
10760 + unsigned int count = 0;
10761 struct biosregs ireg, oreg;
10762 struct e820entry *desc = boot_params.e820_map;
10763 static struct e820entry buf; /* static so it is zeroed */
10764 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10765 index 11e8c6e..fdbb1ed 100644
10766 --- a/arch/x86/boot/video-vesa.c
10767 +++ b/arch/x86/boot/video-vesa.c
10768 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10769
10770 boot_params.screen_info.vesapm_seg = oreg.es;
10771 boot_params.screen_info.vesapm_off = oreg.di;
10772 + boot_params.screen_info.vesapm_size = oreg.cx;
10773 }
10774
10775 /*
10776 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10777 index 43eda28..5ab5fdb 100644
10778 --- a/arch/x86/boot/video.c
10779 +++ b/arch/x86/boot/video.c
10780 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10781 static unsigned int get_entry(void)
10782 {
10783 char entry_buf[4];
10784 - int i, len = 0;
10785 + unsigned int i, len = 0;
10786 int key;
10787 unsigned int v;
10788
10789 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10790 index 9105655..5e37f27 100644
10791 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10792 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10793 @@ -8,6 +8,8 @@
10794 * including this sentence is retained in full.
10795 */
10796
10797 +#include <asm/alternative-asm.h>
10798 +
10799 .extern crypto_ft_tab
10800 .extern crypto_it_tab
10801 .extern crypto_fl_tab
10802 @@ -70,6 +72,8 @@
10803 je B192; \
10804 leaq 32(r9),r9;
10805
10806 +#define ret pax_force_retaddr 0, 1; ret
10807 +
10808 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10809 movq r1,r2; \
10810 movq r3,r4; \
10811 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10812 index 04b7977..402f223 100644
10813 --- a/arch/x86/crypto/aesni-intel_asm.S
10814 +++ b/arch/x86/crypto/aesni-intel_asm.S
10815 @@ -31,6 +31,7 @@
10816
10817 #include <linux/linkage.h>
10818 #include <asm/inst.h>
10819 +#include <asm/alternative-asm.h>
10820
10821 #ifdef __x86_64__
10822 .data
10823 @@ -1435,6 +1436,7 @@ _return_T_done_decrypt:
10824 pop %r14
10825 pop %r13
10826 pop %r12
10827 + pax_force_retaddr 0, 1
10828 ret
10829 ENDPROC(aesni_gcm_dec)
10830
10831 @@ -1699,6 +1701,7 @@ _return_T_done_encrypt:
10832 pop %r14
10833 pop %r13
10834 pop %r12
10835 + pax_force_retaddr 0, 1
10836 ret
10837 ENDPROC(aesni_gcm_enc)
10838
10839 @@ -1716,6 +1719,7 @@ _key_expansion_256a:
10840 pxor %xmm1, %xmm0
10841 movaps %xmm0, (TKEYP)
10842 add $0x10, TKEYP
10843 + pax_force_retaddr_bts
10844 ret
10845 ENDPROC(_key_expansion_128)
10846 ENDPROC(_key_expansion_256a)
10847 @@ -1742,6 +1746,7 @@ _key_expansion_192a:
10848 shufps $0b01001110, %xmm2, %xmm1
10849 movaps %xmm1, 0x10(TKEYP)
10850 add $0x20, TKEYP
10851 + pax_force_retaddr_bts
10852 ret
10853 ENDPROC(_key_expansion_192a)
10854
10855 @@ -1762,6 +1767,7 @@ _key_expansion_192b:
10856
10857 movaps %xmm0, (TKEYP)
10858 add $0x10, TKEYP
10859 + pax_force_retaddr_bts
10860 ret
10861 ENDPROC(_key_expansion_192b)
10862
10863 @@ -1775,6 +1781,7 @@ _key_expansion_256b:
10864 pxor %xmm1, %xmm2
10865 movaps %xmm2, (TKEYP)
10866 add $0x10, TKEYP
10867 + pax_force_retaddr_bts
10868 ret
10869 ENDPROC(_key_expansion_256b)
10870
10871 @@ -1888,6 +1895,7 @@ ENTRY(aesni_set_key)
10872 #ifndef __x86_64__
10873 popl KEYP
10874 #endif
10875 + pax_force_retaddr 0, 1
10876 ret
10877 ENDPROC(aesni_set_key)
10878
10879 @@ -1910,6 +1918,7 @@ ENTRY(aesni_enc)
10880 popl KLEN
10881 popl KEYP
10882 #endif
10883 + pax_force_retaddr 0, 1
10884 ret
10885 ENDPROC(aesni_enc)
10886
10887 @@ -1968,6 +1977,7 @@ _aesni_enc1:
10888 AESENC KEY STATE
10889 movaps 0x70(TKEYP), KEY
10890 AESENCLAST KEY STATE
10891 + pax_force_retaddr_bts
10892 ret
10893 ENDPROC(_aesni_enc1)
10894
10895 @@ -2077,6 +2087,7 @@ _aesni_enc4:
10896 AESENCLAST KEY STATE2
10897 AESENCLAST KEY STATE3
10898 AESENCLAST KEY STATE4
10899 + pax_force_retaddr_bts
10900 ret
10901 ENDPROC(_aesni_enc4)
10902
10903 @@ -2100,6 +2111,7 @@ ENTRY(aesni_dec)
10904 popl KLEN
10905 popl KEYP
10906 #endif
10907 + pax_force_retaddr 0, 1
10908 ret
10909 ENDPROC(aesni_dec)
10910
10911 @@ -2158,6 +2170,7 @@ _aesni_dec1:
10912 AESDEC KEY STATE
10913 movaps 0x70(TKEYP), KEY
10914 AESDECLAST KEY STATE
10915 + pax_force_retaddr_bts
10916 ret
10917 ENDPROC(_aesni_dec1)
10918
10919 @@ -2267,6 +2280,7 @@ _aesni_dec4:
10920 AESDECLAST KEY STATE2
10921 AESDECLAST KEY STATE3
10922 AESDECLAST KEY STATE4
10923 + pax_force_retaddr_bts
10924 ret
10925 ENDPROC(_aesni_dec4)
10926
10927 @@ -2325,6 +2339,7 @@ ENTRY(aesni_ecb_enc)
10928 popl KEYP
10929 popl LEN
10930 #endif
10931 + pax_force_retaddr 0, 1
10932 ret
10933 ENDPROC(aesni_ecb_enc)
10934
10935 @@ -2384,6 +2399,7 @@ ENTRY(aesni_ecb_dec)
10936 popl KEYP
10937 popl LEN
10938 #endif
10939 + pax_force_retaddr 0, 1
10940 ret
10941 ENDPROC(aesni_ecb_dec)
10942
10943 @@ -2426,6 +2442,7 @@ ENTRY(aesni_cbc_enc)
10944 popl LEN
10945 popl IVP
10946 #endif
10947 + pax_force_retaddr 0, 1
10948 ret
10949 ENDPROC(aesni_cbc_enc)
10950
10951 @@ -2517,6 +2534,7 @@ ENTRY(aesni_cbc_dec)
10952 popl LEN
10953 popl IVP
10954 #endif
10955 + pax_force_retaddr 0, 1
10956 ret
10957 ENDPROC(aesni_cbc_dec)
10958
10959 @@ -2544,6 +2562,7 @@ _aesni_inc_init:
10960 mov $1, TCTR_LOW
10961 MOVQ_R64_XMM TCTR_LOW INC
10962 MOVQ_R64_XMM CTR TCTR_LOW
10963 + pax_force_retaddr_bts
10964 ret
10965 ENDPROC(_aesni_inc_init)
10966
10967 @@ -2573,6 +2592,7 @@ _aesni_inc:
10968 .Linc_low:
10969 movaps CTR, IV
10970 PSHUFB_XMM BSWAP_MASK IV
10971 + pax_force_retaddr_bts
10972 ret
10973 ENDPROC(_aesni_inc)
10974
10975 @@ -2634,6 +2654,7 @@ ENTRY(aesni_ctr_enc)
10976 .Lctr_enc_ret:
10977 movups IV, (IVP)
10978 .Lctr_enc_just_ret:
10979 + pax_force_retaddr 0, 1
10980 ret
10981 ENDPROC(aesni_ctr_enc)
10982 #endif
10983 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10984 index 246c670..4d1ed00 100644
10985 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10986 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10987 @@ -21,6 +21,7 @@
10988 */
10989
10990 #include <linux/linkage.h>
10991 +#include <asm/alternative-asm.h>
10992
10993 .file "blowfish-x86_64-asm.S"
10994 .text
10995 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10996 jnz .L__enc_xor;
10997
10998 write_block();
10999 + pax_force_retaddr 0, 1
11000 ret;
11001 .L__enc_xor:
11002 xor_block();
11003 + pax_force_retaddr 0, 1
11004 ret;
11005 ENDPROC(__blowfish_enc_blk)
11006
11007 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
11008
11009 movq %r11, %rbp;
11010
11011 + pax_force_retaddr 0, 1
11012 ret;
11013 ENDPROC(blowfish_dec_blk)
11014
11015 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
11016
11017 popq %rbx;
11018 popq %rbp;
11019 + pax_force_retaddr 0, 1
11020 ret;
11021
11022 .L__enc_xor4:
11023 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
11024
11025 popq %rbx;
11026 popq %rbp;
11027 + pax_force_retaddr 0, 1
11028 ret;
11029 ENDPROC(__blowfish_enc_blk_4way)
11030
11031 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
11032 popq %rbx;
11033 popq %rbp;
11034
11035 + pax_force_retaddr 0, 1
11036 ret;
11037 ENDPROC(blowfish_dec_blk_4way)
11038 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11039 index 310319c..ce174a4 100644
11040 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11041 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11042 @@ -21,6 +21,7 @@
11043 */
11044
11045 #include <linux/linkage.h>
11046 +#include <asm/alternative-asm.h>
11047
11048 .file "camellia-x86_64-asm_64.S"
11049 .text
11050 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11051 enc_outunpack(mov, RT1);
11052
11053 movq RRBP, %rbp;
11054 + pax_force_retaddr 0, 1
11055 ret;
11056
11057 .L__enc_xor:
11058 enc_outunpack(xor, RT1);
11059
11060 movq RRBP, %rbp;
11061 + pax_force_retaddr 0, 1
11062 ret;
11063 ENDPROC(__camellia_enc_blk)
11064
11065 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11066 dec_outunpack();
11067
11068 movq RRBP, %rbp;
11069 + pax_force_retaddr 0, 1
11070 ret;
11071 ENDPROC(camellia_dec_blk)
11072
11073 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11074
11075 movq RRBP, %rbp;
11076 popq %rbx;
11077 + pax_force_retaddr 0, 1
11078 ret;
11079
11080 .L__enc2_xor:
11081 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11082
11083 movq RRBP, %rbp;
11084 popq %rbx;
11085 + pax_force_retaddr 0, 1
11086 ret;
11087 ENDPROC(__camellia_enc_blk_2way)
11088
11089 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11090
11091 movq RRBP, %rbp;
11092 movq RXOR, %rbx;
11093 + pax_force_retaddr 0, 1
11094 ret;
11095 ENDPROC(camellia_dec_blk_2way)
11096 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11097 index c35fd5d..c1ee236 100644
11098 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11099 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11100 @@ -24,6 +24,7 @@
11101 */
11102
11103 #include <linux/linkage.h>
11104 +#include <asm/alternative-asm.h>
11105
11106 .file "cast5-avx-x86_64-asm_64.S"
11107
11108 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11109 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11110 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11111
11112 + pax_force_retaddr 0, 1
11113 ret;
11114 ENDPROC(__cast5_enc_blk16)
11115
11116 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11117 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11118 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11119
11120 + pax_force_retaddr 0, 1
11121 ret;
11122
11123 .L__skip_dec:
11124 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11125 vmovdqu RR4, (6*4*4)(%r11);
11126 vmovdqu RL4, (7*4*4)(%r11);
11127
11128 + pax_force_retaddr
11129 ret;
11130 ENDPROC(cast5_ecb_enc_16way)
11131
11132 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11133 vmovdqu RR4, (6*4*4)(%r11);
11134 vmovdqu RL4, (7*4*4)(%r11);
11135
11136 + pax_force_retaddr
11137 ret;
11138 ENDPROC(cast5_ecb_dec_16way)
11139
11140 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11141
11142 popq %r12;
11143
11144 + pax_force_retaddr
11145 ret;
11146 ENDPROC(cast5_cbc_dec_16way)
11147
11148 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11149
11150 popq %r12;
11151
11152 + pax_force_retaddr
11153 ret;
11154 ENDPROC(cast5_ctr_16way)
11155 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11156 index f93b610..c09bf40 100644
11157 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11158 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11159 @@ -24,6 +24,7 @@
11160 */
11161
11162 #include <linux/linkage.h>
11163 +#include <asm/alternative-asm.h>
11164 #include "glue_helper-asm-avx.S"
11165
11166 .file "cast6-avx-x86_64-asm_64.S"
11167 @@ -293,6 +294,7 @@ __cast6_enc_blk8:
11168 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11169 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11170
11171 + pax_force_retaddr 0, 1
11172 ret;
11173 ENDPROC(__cast6_enc_blk8)
11174
11175 @@ -338,6 +340,7 @@ __cast6_dec_blk8:
11176 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11177 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11178
11179 + pax_force_retaddr 0, 1
11180 ret;
11181 ENDPROC(__cast6_dec_blk8)
11182
11183 @@ -356,6 +359,7 @@ ENTRY(cast6_ecb_enc_8way)
11184
11185 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11186
11187 + pax_force_retaddr
11188 ret;
11189 ENDPROC(cast6_ecb_enc_8way)
11190
11191 @@ -374,6 +378,7 @@ ENTRY(cast6_ecb_dec_8way)
11192
11193 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11194
11195 + pax_force_retaddr
11196 ret;
11197 ENDPROC(cast6_ecb_dec_8way)
11198
11199 @@ -397,6 +402,7 @@ ENTRY(cast6_cbc_dec_8way)
11200
11201 popq %r12;
11202
11203 + pax_force_retaddr
11204 ret;
11205 ENDPROC(cast6_cbc_dec_8way)
11206
11207 @@ -422,5 +428,6 @@ ENTRY(cast6_ctr_8way)
11208
11209 popq %r12;
11210
11211 + pax_force_retaddr
11212 ret;
11213 ENDPROC(cast6_ctr_8way)
11214 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11215 index 9279e0b..9270820 100644
11216 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11217 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11218 @@ -1,4 +1,5 @@
11219 #include <linux/linkage.h>
11220 +#include <asm/alternative-asm.h>
11221
11222 # enter salsa20_encrypt_bytes
11223 ENTRY(salsa20_encrypt_bytes)
11224 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11225 add %r11,%rsp
11226 mov %rdi,%rax
11227 mov %rsi,%rdx
11228 + pax_force_retaddr 0, 1
11229 ret
11230 # bytesatleast65:
11231 ._bytesatleast65:
11232 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11233 add %r11,%rsp
11234 mov %rdi,%rax
11235 mov %rsi,%rdx
11236 + pax_force_retaddr
11237 ret
11238 ENDPROC(salsa20_keysetup)
11239
11240 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11241 add %r11,%rsp
11242 mov %rdi,%rax
11243 mov %rsi,%rdx
11244 + pax_force_retaddr
11245 ret
11246 ENDPROC(salsa20_ivsetup)
11247 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11248 index 43c9386..a0e2d60 100644
11249 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11250 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11251 @@ -25,6 +25,7 @@
11252 */
11253
11254 #include <linux/linkage.h>
11255 +#include <asm/alternative-asm.h>
11256 #include "glue_helper-asm-avx.S"
11257
11258 .file "serpent-avx-x86_64-asm_64.S"
11259 @@ -617,6 +618,7 @@ __serpent_enc_blk8_avx:
11260 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11261 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11262
11263 + pax_force_retaddr
11264 ret;
11265 ENDPROC(__serpent_enc_blk8_avx)
11266
11267 @@ -671,6 +673,7 @@ __serpent_dec_blk8_avx:
11268 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11269 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11270
11271 + pax_force_retaddr
11272 ret;
11273 ENDPROC(__serpent_dec_blk8_avx)
11274
11275 @@ -687,6 +690,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11276
11277 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11278
11279 + pax_force_retaddr
11280 ret;
11281 ENDPROC(serpent_ecb_enc_8way_avx)
11282
11283 @@ -703,6 +707,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11284
11285 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11286
11287 + pax_force_retaddr
11288 ret;
11289 ENDPROC(serpent_ecb_dec_8way_avx)
11290
11291 @@ -719,6 +724,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11292
11293 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11294
11295 + pax_force_retaddr
11296 ret;
11297 ENDPROC(serpent_cbc_dec_8way_avx)
11298
11299 @@ -737,5 +743,6 @@ ENTRY(serpent_ctr_8way_avx)
11300
11301 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11302
11303 + pax_force_retaddr
11304 ret;
11305 ENDPROC(serpent_ctr_8way_avx)
11306 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11307 index acc066c..1559cc4 100644
11308 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11309 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11310 @@ -25,6 +25,7 @@
11311 */
11312
11313 #include <linux/linkage.h>
11314 +#include <asm/alternative-asm.h>
11315
11316 .file "serpent-sse2-x86_64-asm_64.S"
11317 .text
11318 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11319 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11320 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11321
11322 + pax_force_retaddr
11323 ret;
11324
11325 .L__enc_xor8:
11326 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11327 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11328
11329 + pax_force_retaddr
11330 ret;
11331 ENDPROC(__serpent_enc_blk_8way)
11332
11333 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11334 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11335 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11336
11337 + pax_force_retaddr
11338 ret;
11339 ENDPROC(serpent_dec_blk_8way)
11340 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11341 index a410950..3356d42 100644
11342 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11343 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11344 @@ -29,6 +29,7 @@
11345 */
11346
11347 #include <linux/linkage.h>
11348 +#include <asm/alternative-asm.h>
11349
11350 #define CTX %rdi // arg1
11351 #define BUF %rsi // arg2
11352 @@ -104,6 +105,7 @@
11353 pop %r12
11354 pop %rbp
11355 pop %rbx
11356 + pax_force_retaddr 0, 1
11357 ret
11358
11359 ENDPROC(\name)
11360 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11361 index 8d3e113..898b161 100644
11362 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11363 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11364 @@ -24,6 +24,7 @@
11365 */
11366
11367 #include <linux/linkage.h>
11368 +#include <asm/alternative-asm.h>
11369 #include "glue_helper-asm-avx.S"
11370
11371 .file "twofish-avx-x86_64-asm_64.S"
11372 @@ -282,6 +283,7 @@ __twofish_enc_blk8:
11373 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11374 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11375
11376 + pax_force_retaddr 0, 1
11377 ret;
11378 ENDPROC(__twofish_enc_blk8)
11379
11380 @@ -322,6 +324,7 @@ __twofish_dec_blk8:
11381 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11382 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11383
11384 + pax_force_retaddr 0, 1
11385 ret;
11386 ENDPROC(__twofish_dec_blk8)
11387
11388 @@ -340,6 +343,7 @@ ENTRY(twofish_ecb_enc_8way)
11389
11390 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11391
11392 + pax_force_retaddr 0, 1
11393 ret;
11394 ENDPROC(twofish_ecb_enc_8way)
11395
11396 @@ -358,6 +362,7 @@ ENTRY(twofish_ecb_dec_8way)
11397
11398 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11399
11400 + pax_force_retaddr 0, 1
11401 ret;
11402 ENDPROC(twofish_ecb_dec_8way)
11403
11404 @@ -381,6 +386,7 @@ ENTRY(twofish_cbc_dec_8way)
11405
11406 popq %r12;
11407
11408 + pax_force_retaddr 0, 1
11409 ret;
11410 ENDPROC(twofish_cbc_dec_8way)
11411
11412 @@ -406,5 +412,6 @@ ENTRY(twofish_ctr_8way)
11413
11414 popq %r12;
11415
11416 + pax_force_retaddr 0, 1
11417 ret;
11418 ENDPROC(twofish_ctr_8way)
11419 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11420 index 1c3b7ce..b365c5e 100644
11421 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11422 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11423 @@ -21,6 +21,7 @@
11424 */
11425
11426 #include <linux/linkage.h>
11427 +#include <asm/alternative-asm.h>
11428
11429 .file "twofish-x86_64-asm-3way.S"
11430 .text
11431 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11432 popq %r13;
11433 popq %r14;
11434 popq %r15;
11435 + pax_force_retaddr 0, 1
11436 ret;
11437
11438 .L__enc_xor3:
11439 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11440 popq %r13;
11441 popq %r14;
11442 popq %r15;
11443 + pax_force_retaddr 0, 1
11444 ret;
11445 ENDPROC(__twofish_enc_blk_3way)
11446
11447 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11448 popq %r13;
11449 popq %r14;
11450 popq %r15;
11451 + pax_force_retaddr 0, 1
11452 ret;
11453 ENDPROC(twofish_dec_blk_3way)
11454 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11455 index a039d21..29e7615 100644
11456 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11457 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11458 @@ -22,6 +22,7 @@
11459
11460 #include <linux/linkage.h>
11461 #include <asm/asm-offsets.h>
11462 +#include <asm/alternative-asm.h>
11463
11464 #define a_offset 0
11465 #define b_offset 4
11466 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11467
11468 popq R1
11469 movq $1,%rax
11470 + pax_force_retaddr 0, 1
11471 ret
11472 ENDPROC(twofish_enc_blk)
11473
11474 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11475
11476 popq R1
11477 movq $1,%rax
11478 + pax_force_retaddr 0, 1
11479 ret
11480 ENDPROC(twofish_dec_blk)
11481 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11482 index 03abf9b..a42ba29 100644
11483 --- a/arch/x86/ia32/ia32_aout.c
11484 +++ b/arch/x86/ia32/ia32_aout.c
11485 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11486 unsigned long dump_start, dump_size;
11487 struct user32 dump;
11488
11489 + memset(&dump, 0, sizeof(dump));
11490 +
11491 fs = get_fs();
11492 set_fs(KERNEL_DS);
11493 has_dumped = 1;
11494 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11495 index cf1a471..3bc4cf8 100644
11496 --- a/arch/x86/ia32/ia32_signal.c
11497 +++ b/arch/x86/ia32/ia32_signal.c
11498 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11499 sp -= frame_size;
11500 /* Align the stack pointer according to the i386 ABI,
11501 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11502 - sp = ((sp + 4) & -16ul) - 4;
11503 + sp = ((sp - 12) & -16ul) - 4;
11504 return (void __user *) sp;
11505 }
11506
11507 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11508 * These are actually not used anymore, but left because some
11509 * gdb versions depend on them as a marker.
11510 */
11511 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11512 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11513 } put_user_catch(err);
11514
11515 if (err)
11516 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11517 0xb8,
11518 __NR_ia32_rt_sigreturn,
11519 0x80cd,
11520 - 0,
11521 + 0
11522 };
11523
11524 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11525 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11526
11527 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11528 restorer = ksig->ka.sa.sa_restorer;
11529 + else if (current->mm->context.vdso)
11530 + /* Return stub is in 32bit vsyscall page */
11531 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11532 else
11533 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11534 - rt_sigreturn);
11535 + restorer = &frame->retcode;
11536 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11537
11538 /*
11539 * Not actually used anymore, but left because some gdb
11540 * versions need it.
11541 */
11542 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11543 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11544 } put_user_catch(err);
11545
11546 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11547 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11548 index 474dc1b..be7bff5 100644
11549 --- a/arch/x86/ia32/ia32entry.S
11550 +++ b/arch/x86/ia32/ia32entry.S
11551 @@ -15,8 +15,10 @@
11552 #include <asm/irqflags.h>
11553 #include <asm/asm.h>
11554 #include <asm/smap.h>
11555 +#include <asm/pgtable.h>
11556 #include <linux/linkage.h>
11557 #include <linux/err.h>
11558 +#include <asm/alternative-asm.h>
11559
11560 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11561 #include <linux/elf-em.h>
11562 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11563 ENDPROC(native_irq_enable_sysexit)
11564 #endif
11565
11566 + .macro pax_enter_kernel_user
11567 + pax_set_fptr_mask
11568 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11569 + call pax_enter_kernel_user
11570 +#endif
11571 + .endm
11572 +
11573 + .macro pax_exit_kernel_user
11574 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11575 + call pax_exit_kernel_user
11576 +#endif
11577 +#ifdef CONFIG_PAX_RANDKSTACK
11578 + pushq %rax
11579 + pushq %r11
11580 + call pax_randomize_kstack
11581 + popq %r11
11582 + popq %rax
11583 +#endif
11584 + .endm
11585 +
11586 +.macro pax_erase_kstack
11587 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11588 + call pax_erase_kstack
11589 +#endif
11590 +.endm
11591 +
11592 /*
11593 * 32bit SYSENTER instruction entry.
11594 *
11595 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11596 CFI_REGISTER rsp,rbp
11597 SWAPGS_UNSAFE_STACK
11598 movq PER_CPU_VAR(kernel_stack), %rsp
11599 - addq $(KERNEL_STACK_OFFSET),%rsp
11600 - /*
11601 - * No need to follow this irqs on/off section: the syscall
11602 - * disabled irqs, here we enable it straight after entry:
11603 - */
11604 - ENABLE_INTERRUPTS(CLBR_NONE)
11605 movl %ebp,%ebp /* zero extension */
11606 pushq_cfi $__USER32_DS
11607 /*CFI_REL_OFFSET ss,0*/
11608 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11609 CFI_REL_OFFSET rsp,0
11610 pushfq_cfi
11611 /*CFI_REL_OFFSET rflags,0*/
11612 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11613 - CFI_REGISTER rip,r10
11614 + orl $X86_EFLAGS_IF,(%rsp)
11615 + GET_THREAD_INFO(%r11)
11616 + movl TI_sysenter_return(%r11), %r11d
11617 + CFI_REGISTER rip,r11
11618 pushq_cfi $__USER32_CS
11619 /*CFI_REL_OFFSET cs,0*/
11620 movl %eax, %eax
11621 - pushq_cfi %r10
11622 + pushq_cfi %r11
11623 CFI_REL_OFFSET rip,0
11624 pushq_cfi %rax
11625 cld
11626 SAVE_ARGS 0,1,0
11627 + pax_enter_kernel_user
11628 +
11629 +#ifdef CONFIG_PAX_RANDKSTACK
11630 + pax_erase_kstack
11631 +#endif
11632 +
11633 + /*
11634 + * No need to follow this irqs on/off section: the syscall
11635 + * disabled irqs, here we enable it straight after entry:
11636 + */
11637 + ENABLE_INTERRUPTS(CLBR_NONE)
11638 /* no need to do an access_ok check here because rbp has been
11639 32bit zero extended */
11640 +
11641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11642 + mov pax_user_shadow_base,%r11
11643 + add %r11,%rbp
11644 +#endif
11645 +
11646 ASM_STAC
11647 1: movl (%rbp),%ebp
11648 _ASM_EXTABLE(1b,ia32_badarg)
11649 ASM_CLAC
11650 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11651 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11652 + GET_THREAD_INFO(%r11)
11653 + orl $TS_COMPAT,TI_status(%r11)
11654 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11655 CFI_REMEMBER_STATE
11656 jnz sysenter_tracesys
11657 cmpq $(IA32_NR_syscalls-1),%rax
11658 @@ -162,12 +204,15 @@ sysenter_do_call:
11659 sysenter_dispatch:
11660 call *ia32_sys_call_table(,%rax,8)
11661 movq %rax,RAX-ARGOFFSET(%rsp)
11662 + GET_THREAD_INFO(%r11)
11663 DISABLE_INTERRUPTS(CLBR_NONE)
11664 TRACE_IRQS_OFF
11665 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11666 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11667 jnz sysexit_audit
11668 sysexit_from_sys_call:
11669 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11670 + pax_exit_kernel_user
11671 + pax_erase_kstack
11672 + andl $~TS_COMPAT,TI_status(%r11)
11673 /* clear IF, that popfq doesn't enable interrupts early */
11674 andl $~0x200,EFLAGS-R11(%rsp)
11675 movl RIP-R11(%rsp),%edx /* User %eip */
11676 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11677 movl %eax,%esi /* 2nd arg: syscall number */
11678 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11679 call __audit_syscall_entry
11680 +
11681 + pax_erase_kstack
11682 +
11683 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11684 cmpq $(IA32_NR_syscalls-1),%rax
11685 ja ia32_badsys
11686 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11687 .endm
11688
11689 .macro auditsys_exit exit
11690 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11691 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11692 jnz ia32_ret_from_sys_call
11693 TRACE_IRQS_ON
11694 ENABLE_INTERRUPTS(CLBR_NONE)
11695 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11696 1: setbe %al /* 1 if error, 0 if not */
11697 movzbl %al,%edi /* zero-extend that into %edi */
11698 call __audit_syscall_exit
11699 + GET_THREAD_INFO(%r11)
11700 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11701 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11702 DISABLE_INTERRUPTS(CLBR_NONE)
11703 TRACE_IRQS_OFF
11704 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11705 + testl %edi,TI_flags(%r11)
11706 jz \exit
11707 CLEAR_RREGS -ARGOFFSET
11708 jmp int_with_check
11709 @@ -237,7 +286,7 @@ sysexit_audit:
11710
11711 sysenter_tracesys:
11712 #ifdef CONFIG_AUDITSYSCALL
11713 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11714 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11715 jz sysenter_auditsys
11716 #endif
11717 SAVE_REST
11718 @@ -249,6 +298,9 @@ sysenter_tracesys:
11719 RESTORE_REST
11720 cmpq $(IA32_NR_syscalls-1),%rax
11721 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11722 +
11723 + pax_erase_kstack
11724 +
11725 jmp sysenter_do_call
11726 CFI_ENDPROC
11727 ENDPROC(ia32_sysenter_target)
11728 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11729 ENTRY(ia32_cstar_target)
11730 CFI_STARTPROC32 simple
11731 CFI_SIGNAL_FRAME
11732 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11733 + CFI_DEF_CFA rsp,0
11734 CFI_REGISTER rip,rcx
11735 /*CFI_REGISTER rflags,r11*/
11736 SWAPGS_UNSAFE_STACK
11737 movl %esp,%r8d
11738 CFI_REGISTER rsp,r8
11739 movq PER_CPU_VAR(kernel_stack),%rsp
11740 + SAVE_ARGS 8*6,0,0
11741 + pax_enter_kernel_user
11742 +
11743 +#ifdef CONFIG_PAX_RANDKSTACK
11744 + pax_erase_kstack
11745 +#endif
11746 +
11747 /*
11748 * No need to follow this irqs on/off section: the syscall
11749 * disabled irqs and here we enable it straight after entry:
11750 */
11751 ENABLE_INTERRUPTS(CLBR_NONE)
11752 - SAVE_ARGS 8,0,0
11753 movl %eax,%eax /* zero extension */
11754 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11755 movq %rcx,RIP-ARGOFFSET(%rsp)
11756 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11757 /* no need to do an access_ok check here because r8 has been
11758 32bit zero extended */
11759 /* hardware stack frame is complete now */
11760 +
11761 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11762 + mov pax_user_shadow_base,%r11
11763 + add %r11,%r8
11764 +#endif
11765 +
11766 ASM_STAC
11767 1: movl (%r8),%r9d
11768 _ASM_EXTABLE(1b,ia32_badarg)
11769 ASM_CLAC
11770 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11771 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11772 + GET_THREAD_INFO(%r11)
11773 + orl $TS_COMPAT,TI_status(%r11)
11774 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11775 CFI_REMEMBER_STATE
11776 jnz cstar_tracesys
11777 cmpq $IA32_NR_syscalls-1,%rax
11778 @@ -319,12 +384,15 @@ cstar_do_call:
11779 cstar_dispatch:
11780 call *ia32_sys_call_table(,%rax,8)
11781 movq %rax,RAX-ARGOFFSET(%rsp)
11782 + GET_THREAD_INFO(%r11)
11783 DISABLE_INTERRUPTS(CLBR_NONE)
11784 TRACE_IRQS_OFF
11785 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11786 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11787 jnz sysretl_audit
11788 sysretl_from_sys_call:
11789 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11790 + pax_exit_kernel_user
11791 + pax_erase_kstack
11792 + andl $~TS_COMPAT,TI_status(%r11)
11793 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11794 movl RIP-ARGOFFSET(%rsp),%ecx
11795 CFI_REGISTER rip,rcx
11796 @@ -352,7 +420,7 @@ sysretl_audit:
11797
11798 cstar_tracesys:
11799 #ifdef CONFIG_AUDITSYSCALL
11800 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11801 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11802 jz cstar_auditsys
11803 #endif
11804 xchgl %r9d,%ebp
11805 @@ -366,6 +434,9 @@ cstar_tracesys:
11806 xchgl %ebp,%r9d
11807 cmpq $(IA32_NR_syscalls-1),%rax
11808 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11809 +
11810 + pax_erase_kstack
11811 +
11812 jmp cstar_do_call
11813 END(ia32_cstar_target)
11814
11815 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11816 CFI_REL_OFFSET rip,RIP-RIP
11817 PARAVIRT_ADJUST_EXCEPTION_FRAME
11818 SWAPGS
11819 - /*
11820 - * No need to follow this irqs on/off section: the syscall
11821 - * disabled irqs and here we enable it straight after entry:
11822 - */
11823 - ENABLE_INTERRUPTS(CLBR_NONE)
11824 movl %eax,%eax
11825 pushq_cfi %rax
11826 cld
11827 /* note the registers are not zero extended to the sf.
11828 this could be a problem. */
11829 SAVE_ARGS 0,1,0
11830 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11831 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11832 + pax_enter_kernel_user
11833 +
11834 +#ifdef CONFIG_PAX_RANDKSTACK
11835 + pax_erase_kstack
11836 +#endif
11837 +
11838 + /*
11839 + * No need to follow this irqs on/off section: the syscall
11840 + * disabled irqs and here we enable it straight after entry:
11841 + */
11842 + ENABLE_INTERRUPTS(CLBR_NONE)
11843 + GET_THREAD_INFO(%r11)
11844 + orl $TS_COMPAT,TI_status(%r11)
11845 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11846 jnz ia32_tracesys
11847 cmpq $(IA32_NR_syscalls-1),%rax
11848 ja ia32_badsys
11849 @@ -442,6 +520,9 @@ ia32_tracesys:
11850 RESTORE_REST
11851 cmpq $(IA32_NR_syscalls-1),%rax
11852 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11853 +
11854 + pax_erase_kstack
11855 +
11856 jmp ia32_do_call
11857 END(ia32_syscall)
11858
11859 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11860 index ad7a20c..1ffa3c1 100644
11861 --- a/arch/x86/ia32/sys_ia32.c
11862 +++ b/arch/x86/ia32/sys_ia32.c
11863 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11864 */
11865 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11866 {
11867 - typeof(ubuf->st_uid) uid = 0;
11868 - typeof(ubuf->st_gid) gid = 0;
11869 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11870 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11871 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11872 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11873 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11874 @@ -205,7 +205,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
11875 return -EFAULT;
11876
11877 set_fs(KERNEL_DS);
11878 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
11879 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
11880 count);
11881 set_fs(old_fs);
11882
11883 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11884 index 372231c..a5aa1a1 100644
11885 --- a/arch/x86/include/asm/alternative-asm.h
11886 +++ b/arch/x86/include/asm/alternative-asm.h
11887 @@ -18,6 +18,45 @@
11888 .endm
11889 #endif
11890
11891 +#ifdef KERNEXEC_PLUGIN
11892 + .macro pax_force_retaddr_bts rip=0
11893 + btsq $63,\rip(%rsp)
11894 + .endm
11895 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11896 + .macro pax_force_retaddr rip=0, reload=0
11897 + btsq $63,\rip(%rsp)
11898 + .endm
11899 + .macro pax_force_fptr ptr
11900 + btsq $63,\ptr
11901 + .endm
11902 + .macro pax_set_fptr_mask
11903 + .endm
11904 +#endif
11905 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11906 + .macro pax_force_retaddr rip=0, reload=0
11907 + .if \reload
11908 + pax_set_fptr_mask
11909 + .endif
11910 + orq %r10,\rip(%rsp)
11911 + .endm
11912 + .macro pax_force_fptr ptr
11913 + orq %r10,\ptr
11914 + .endm
11915 + .macro pax_set_fptr_mask
11916 + movabs $0x8000000000000000,%r10
11917 + .endm
11918 +#endif
11919 +#else
11920 + .macro pax_force_retaddr rip=0, reload=0
11921 + .endm
11922 + .macro pax_force_fptr ptr
11923 + .endm
11924 + .macro pax_force_retaddr_bts rip=0
11925 + .endm
11926 + .macro pax_set_fptr_mask
11927 + .endm
11928 +#endif
11929 +
11930 .macro altinstruction_entry orig alt feature orig_len alt_len
11931 .long \orig - .
11932 .long \alt - .
11933 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11934 index 58ed6d9..f1cbe58 100644
11935 --- a/arch/x86/include/asm/alternative.h
11936 +++ b/arch/x86/include/asm/alternative.h
11937 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11938 ".pushsection .discard,\"aw\",@progbits\n" \
11939 DISCARD_ENTRY(1) \
11940 ".popsection\n" \
11941 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11942 + ".pushsection .altinstr_replacement, \"a\"\n" \
11943 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11944 ".popsection"
11945
11946 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11947 DISCARD_ENTRY(1) \
11948 DISCARD_ENTRY(2) \
11949 ".popsection\n" \
11950 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11951 + ".pushsection .altinstr_replacement, \"a\"\n" \
11952 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11953 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11954 ".popsection"
11955 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11956 index 3388034..050f0b9 100644
11957 --- a/arch/x86/include/asm/apic.h
11958 +++ b/arch/x86/include/asm/apic.h
11959 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11960
11961 #ifdef CONFIG_X86_LOCAL_APIC
11962
11963 -extern unsigned int apic_verbosity;
11964 +extern int apic_verbosity;
11965 extern int local_apic_timer_c2_ok;
11966
11967 extern int disable_apic;
11968 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11969 index 20370c6..a2eb9b0 100644
11970 --- a/arch/x86/include/asm/apm.h
11971 +++ b/arch/x86/include/asm/apm.h
11972 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11973 __asm__ __volatile__(APM_DO_ZERO_SEGS
11974 "pushl %%edi\n\t"
11975 "pushl %%ebp\n\t"
11976 - "lcall *%%cs:apm_bios_entry\n\t"
11977 + "lcall *%%ss:apm_bios_entry\n\t"
11978 "setc %%al\n\t"
11979 "popl %%ebp\n\t"
11980 "popl %%edi\n\t"
11981 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11982 __asm__ __volatile__(APM_DO_ZERO_SEGS
11983 "pushl %%edi\n\t"
11984 "pushl %%ebp\n\t"
11985 - "lcall *%%cs:apm_bios_entry\n\t"
11986 + "lcall *%%ss:apm_bios_entry\n\t"
11987 "setc %%bl\n\t"
11988 "popl %%ebp\n\t"
11989 "popl %%edi\n\t"
11990 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11991 index 722aa3b..3a0bb27 100644
11992 --- a/arch/x86/include/asm/atomic.h
11993 +++ b/arch/x86/include/asm/atomic.h
11994 @@ -22,7 +22,18 @@
11995 */
11996 static inline int atomic_read(const atomic_t *v)
11997 {
11998 - return (*(volatile int *)&(v)->counter);
11999 + return (*(volatile const int *)&(v)->counter);
12000 +}
12001 +
12002 +/**
12003 + * atomic_read_unchecked - read atomic variable
12004 + * @v: pointer of type atomic_unchecked_t
12005 + *
12006 + * Atomically reads the value of @v.
12007 + */
12008 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12009 +{
12010 + return (*(volatile const int *)&(v)->counter);
12011 }
12012
12013 /**
12014 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12015 }
12016
12017 /**
12018 + * atomic_set_unchecked - set atomic variable
12019 + * @v: pointer of type atomic_unchecked_t
12020 + * @i: required value
12021 + *
12022 + * Atomically sets the value of @v to @i.
12023 + */
12024 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12025 +{
12026 + v->counter = i;
12027 +}
12028 +
12029 +/**
12030 * atomic_add - add integer to atomic variable
12031 * @i: integer value to add
12032 * @v: pointer of type atomic_t
12033 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12034 */
12035 static inline void atomic_add(int i, atomic_t *v)
12036 {
12037 - asm volatile(LOCK_PREFIX "addl %1,%0"
12038 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12039 +
12040 +#ifdef CONFIG_PAX_REFCOUNT
12041 + "jno 0f\n"
12042 + LOCK_PREFIX "subl %1,%0\n"
12043 + "int $4\n0:\n"
12044 + _ASM_EXTABLE(0b, 0b)
12045 +#endif
12046 +
12047 + : "+m" (v->counter)
12048 + : "ir" (i));
12049 +}
12050 +
12051 +/**
12052 + * atomic_add_unchecked - add integer to atomic variable
12053 + * @i: integer value to add
12054 + * @v: pointer of type atomic_unchecked_t
12055 + *
12056 + * Atomically adds @i to @v.
12057 + */
12058 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12059 +{
12060 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12061 : "+m" (v->counter)
12062 : "ir" (i));
12063 }
12064 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12065 */
12066 static inline void atomic_sub(int i, atomic_t *v)
12067 {
12068 - asm volatile(LOCK_PREFIX "subl %1,%0"
12069 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12070 +
12071 +#ifdef CONFIG_PAX_REFCOUNT
12072 + "jno 0f\n"
12073 + LOCK_PREFIX "addl %1,%0\n"
12074 + "int $4\n0:\n"
12075 + _ASM_EXTABLE(0b, 0b)
12076 +#endif
12077 +
12078 + : "+m" (v->counter)
12079 + : "ir" (i));
12080 +}
12081 +
12082 +/**
12083 + * atomic_sub_unchecked - subtract integer from atomic variable
12084 + * @i: integer value to subtract
12085 + * @v: pointer of type atomic_unchecked_t
12086 + *
12087 + * Atomically subtracts @i from @v.
12088 + */
12089 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12090 +{
12091 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12092 : "+m" (v->counter)
12093 : "ir" (i));
12094 }
12095 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12096 {
12097 unsigned char c;
12098
12099 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12100 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12101 +
12102 +#ifdef CONFIG_PAX_REFCOUNT
12103 + "jno 0f\n"
12104 + LOCK_PREFIX "addl %2,%0\n"
12105 + "int $4\n0:\n"
12106 + _ASM_EXTABLE(0b, 0b)
12107 +#endif
12108 +
12109 + "sete %1\n"
12110 : "+m" (v->counter), "=qm" (c)
12111 : "ir" (i) : "memory");
12112 return c;
12113 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12114 */
12115 static inline void atomic_inc(atomic_t *v)
12116 {
12117 - asm volatile(LOCK_PREFIX "incl %0"
12118 + asm volatile(LOCK_PREFIX "incl %0\n"
12119 +
12120 +#ifdef CONFIG_PAX_REFCOUNT
12121 + "jno 0f\n"
12122 + LOCK_PREFIX "decl %0\n"
12123 + "int $4\n0:\n"
12124 + _ASM_EXTABLE(0b, 0b)
12125 +#endif
12126 +
12127 + : "+m" (v->counter));
12128 +}
12129 +
12130 +/**
12131 + * atomic_inc_unchecked - increment atomic variable
12132 + * @v: pointer of type atomic_unchecked_t
12133 + *
12134 + * Atomically increments @v by 1.
12135 + */
12136 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12137 +{
12138 + asm volatile(LOCK_PREFIX "incl %0\n"
12139 : "+m" (v->counter));
12140 }
12141
12142 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12143 */
12144 static inline void atomic_dec(atomic_t *v)
12145 {
12146 - asm volatile(LOCK_PREFIX "decl %0"
12147 + asm volatile(LOCK_PREFIX "decl %0\n"
12148 +
12149 +#ifdef CONFIG_PAX_REFCOUNT
12150 + "jno 0f\n"
12151 + LOCK_PREFIX "incl %0\n"
12152 + "int $4\n0:\n"
12153 + _ASM_EXTABLE(0b, 0b)
12154 +#endif
12155 +
12156 + : "+m" (v->counter));
12157 +}
12158 +
12159 +/**
12160 + * atomic_dec_unchecked - decrement atomic variable
12161 + * @v: pointer of type atomic_unchecked_t
12162 + *
12163 + * Atomically decrements @v by 1.
12164 + */
12165 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12166 +{
12167 + asm volatile(LOCK_PREFIX "decl %0\n"
12168 : "+m" (v->counter));
12169 }
12170
12171 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12172 {
12173 unsigned char c;
12174
12175 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12176 + asm volatile(LOCK_PREFIX "decl %0\n"
12177 +
12178 +#ifdef CONFIG_PAX_REFCOUNT
12179 + "jno 0f\n"
12180 + LOCK_PREFIX "incl %0\n"
12181 + "int $4\n0:\n"
12182 + _ASM_EXTABLE(0b, 0b)
12183 +#endif
12184 +
12185 + "sete %1\n"
12186 : "+m" (v->counter), "=qm" (c)
12187 : : "memory");
12188 return c != 0;
12189 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12190 {
12191 unsigned char c;
12192
12193 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12194 + asm volatile(LOCK_PREFIX "incl %0\n"
12195 +
12196 +#ifdef CONFIG_PAX_REFCOUNT
12197 + "jno 0f\n"
12198 + LOCK_PREFIX "decl %0\n"
12199 + "int $4\n0:\n"
12200 + _ASM_EXTABLE(0b, 0b)
12201 +#endif
12202 +
12203 + "sete %1\n"
12204 + : "+m" (v->counter), "=qm" (c)
12205 + : : "memory");
12206 + return c != 0;
12207 +}
12208 +
12209 +/**
12210 + * atomic_inc_and_test_unchecked - increment and test
12211 + * @v: pointer of type atomic_unchecked_t
12212 + *
12213 + * Atomically increments @v by 1
12214 + * and returns true if the result is zero, or false for all
12215 + * other cases.
12216 + */
12217 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12218 +{
12219 + unsigned char c;
12220 +
12221 + asm volatile(LOCK_PREFIX "incl %0\n"
12222 + "sete %1\n"
12223 : "+m" (v->counter), "=qm" (c)
12224 : : "memory");
12225 return c != 0;
12226 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12227 {
12228 unsigned char c;
12229
12230 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12231 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12232 +
12233 +#ifdef CONFIG_PAX_REFCOUNT
12234 + "jno 0f\n"
12235 + LOCK_PREFIX "subl %2,%0\n"
12236 + "int $4\n0:\n"
12237 + _ASM_EXTABLE(0b, 0b)
12238 +#endif
12239 +
12240 + "sets %1\n"
12241 : "+m" (v->counter), "=qm" (c)
12242 : "ir" (i) : "memory");
12243 return c;
12244 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12245 */
12246 static inline int atomic_add_return(int i, atomic_t *v)
12247 {
12248 + return i + xadd_check_overflow(&v->counter, i);
12249 +}
12250 +
12251 +/**
12252 + * atomic_add_return_unchecked - add integer and return
12253 + * @i: integer value to add
12254 + * @v: pointer of type atomic_unchecked_t
12255 + *
12256 + * Atomically adds @i to @v and returns @i + @v
12257 + */
12258 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12259 +{
12260 return i + xadd(&v->counter, i);
12261 }
12262
12263 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12264 }
12265
12266 #define atomic_inc_return(v) (atomic_add_return(1, v))
12267 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12268 +{
12269 + return atomic_add_return_unchecked(1, v);
12270 +}
12271 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12272
12273 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12274 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12275 return cmpxchg(&v->counter, old, new);
12276 }
12277
12278 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12279 +{
12280 + return cmpxchg(&v->counter, old, new);
12281 +}
12282 +
12283 static inline int atomic_xchg(atomic_t *v, int new)
12284 {
12285 return xchg(&v->counter, new);
12286 }
12287
12288 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12289 +{
12290 + return xchg(&v->counter, new);
12291 +}
12292 +
12293 /**
12294 * __atomic_add_unless - add unless the number is already a given value
12295 * @v: pointer of type atomic_t
12296 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12297 */
12298 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12299 {
12300 - int c, old;
12301 + int c, old, new;
12302 c = atomic_read(v);
12303 for (;;) {
12304 - if (unlikely(c == (u)))
12305 + if (unlikely(c == u))
12306 break;
12307 - old = atomic_cmpxchg((v), c, c + (a));
12308 +
12309 + asm volatile("addl %2,%0\n"
12310 +
12311 +#ifdef CONFIG_PAX_REFCOUNT
12312 + "jno 0f\n"
12313 + "subl %2,%0\n"
12314 + "int $4\n0:\n"
12315 + _ASM_EXTABLE(0b, 0b)
12316 +#endif
12317 +
12318 + : "=r" (new)
12319 + : "0" (c), "ir" (a));
12320 +
12321 + old = atomic_cmpxchg(v, c, new);
12322 if (likely(old == c))
12323 break;
12324 c = old;
12325 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12326 }
12327
12328 /**
12329 + * atomic_inc_not_zero_hint - increment if not null
12330 + * @v: pointer of type atomic_t
12331 + * @hint: probable value of the atomic before the increment
12332 + *
12333 + * This version of atomic_inc_not_zero() gives a hint of probable
12334 + * value of the atomic. This helps processor to not read the memory
12335 + * before doing the atomic read/modify/write cycle, lowering
12336 + * number of bus transactions on some arches.
12337 + *
12338 + * Returns: 0 if increment was not done, 1 otherwise.
12339 + */
12340 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12341 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12342 +{
12343 + int val, c = hint, new;
12344 +
12345 + /* sanity test, should be removed by compiler if hint is a constant */
12346 + if (!hint)
12347 + return __atomic_add_unless(v, 1, 0);
12348 +
12349 + do {
12350 + asm volatile("incl %0\n"
12351 +
12352 +#ifdef CONFIG_PAX_REFCOUNT
12353 + "jno 0f\n"
12354 + "decl %0\n"
12355 + "int $4\n0:\n"
12356 + _ASM_EXTABLE(0b, 0b)
12357 +#endif
12358 +
12359 + : "=r" (new)
12360 + : "0" (c));
12361 +
12362 + val = atomic_cmpxchg(v, c, new);
12363 + if (val == c)
12364 + return 1;
12365 + c = val;
12366 + } while (c);
12367 +
12368 + return 0;
12369 +}
12370 +
12371 +/**
12372 * atomic_inc_short - increment of a short integer
12373 * @v: pointer to type int
12374 *
12375 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12376 #endif
12377
12378 /* These are x86-specific, used by some header files */
12379 -#define atomic_clear_mask(mask, addr) \
12380 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12381 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12382 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12383 +{
12384 + asm volatile(LOCK_PREFIX "andl %1,%0"
12385 + : "+m" (v->counter)
12386 + : "r" (~(mask))
12387 + : "memory");
12388 +}
12389
12390 -#define atomic_set_mask(mask, addr) \
12391 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12392 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12393 - : "memory")
12394 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12395 +{
12396 + asm volatile(LOCK_PREFIX "andl %1,%0"
12397 + : "+m" (v->counter)
12398 + : "r" (~(mask))
12399 + : "memory");
12400 +}
12401 +
12402 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12403 +{
12404 + asm volatile(LOCK_PREFIX "orl %1,%0"
12405 + : "+m" (v->counter)
12406 + : "r" (mask)
12407 + : "memory");
12408 +}
12409 +
12410 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12411 +{
12412 + asm volatile(LOCK_PREFIX "orl %1,%0"
12413 + : "+m" (v->counter)
12414 + : "r" (mask)
12415 + : "memory");
12416 +}
12417
12418 /* Atomic operations are already serializing on x86 */
12419 #define smp_mb__before_atomic_dec() barrier()
12420 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12421 index b154de7..aadebd8 100644
12422 --- a/arch/x86/include/asm/atomic64_32.h
12423 +++ b/arch/x86/include/asm/atomic64_32.h
12424 @@ -12,6 +12,14 @@ typedef struct {
12425 u64 __aligned(8) counter;
12426 } atomic64_t;
12427
12428 +#ifdef CONFIG_PAX_REFCOUNT
12429 +typedef struct {
12430 + u64 __aligned(8) counter;
12431 +} atomic64_unchecked_t;
12432 +#else
12433 +typedef atomic64_t atomic64_unchecked_t;
12434 +#endif
12435 +
12436 #define ATOMIC64_INIT(val) { (val) }
12437
12438 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12439 @@ -37,21 +45,31 @@ typedef struct {
12440 ATOMIC64_DECL_ONE(sym##_386)
12441
12442 ATOMIC64_DECL_ONE(add_386);
12443 +ATOMIC64_DECL_ONE(add_unchecked_386);
12444 ATOMIC64_DECL_ONE(sub_386);
12445 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12446 ATOMIC64_DECL_ONE(inc_386);
12447 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12448 ATOMIC64_DECL_ONE(dec_386);
12449 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12450 #endif
12451
12452 #define alternative_atomic64(f, out, in...) \
12453 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12454
12455 ATOMIC64_DECL(read);
12456 +ATOMIC64_DECL(read_unchecked);
12457 ATOMIC64_DECL(set);
12458 +ATOMIC64_DECL(set_unchecked);
12459 ATOMIC64_DECL(xchg);
12460 ATOMIC64_DECL(add_return);
12461 +ATOMIC64_DECL(add_return_unchecked);
12462 ATOMIC64_DECL(sub_return);
12463 +ATOMIC64_DECL(sub_return_unchecked);
12464 ATOMIC64_DECL(inc_return);
12465 +ATOMIC64_DECL(inc_return_unchecked);
12466 ATOMIC64_DECL(dec_return);
12467 +ATOMIC64_DECL(dec_return_unchecked);
12468 ATOMIC64_DECL(dec_if_positive);
12469 ATOMIC64_DECL(inc_not_zero);
12470 ATOMIC64_DECL(add_unless);
12471 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12472 }
12473
12474 /**
12475 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12476 + * @p: pointer to type atomic64_unchecked_t
12477 + * @o: expected value
12478 + * @n: new value
12479 + *
12480 + * Atomically sets @v to @n if it was equal to @o and returns
12481 + * the old value.
12482 + */
12483 +
12484 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12485 +{
12486 + return cmpxchg64(&v->counter, o, n);
12487 +}
12488 +
12489 +/**
12490 * atomic64_xchg - xchg atomic64 variable
12491 * @v: pointer to type atomic64_t
12492 * @n: value to assign
12493 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12494 }
12495
12496 /**
12497 + * atomic64_set_unchecked - set atomic64 variable
12498 + * @v: pointer to type atomic64_unchecked_t
12499 + * @n: value to assign
12500 + *
12501 + * Atomically sets the value of @v to @n.
12502 + */
12503 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12504 +{
12505 + unsigned high = (unsigned)(i >> 32);
12506 + unsigned low = (unsigned)i;
12507 + alternative_atomic64(set, /* no output */,
12508 + "S" (v), "b" (low), "c" (high)
12509 + : "eax", "edx", "memory");
12510 +}
12511 +
12512 +/**
12513 * atomic64_read - read atomic64 variable
12514 * @v: pointer to type atomic64_t
12515 *
12516 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12517 }
12518
12519 /**
12520 + * atomic64_read_unchecked - read atomic64 variable
12521 + * @v: pointer to type atomic64_unchecked_t
12522 + *
12523 + * Atomically reads the value of @v and returns it.
12524 + */
12525 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12526 +{
12527 + long long r;
12528 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12529 + return r;
12530 + }
12531 +
12532 +/**
12533 * atomic64_add_return - add and return
12534 * @i: integer value to add
12535 * @v: pointer to type atomic64_t
12536 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12537 return i;
12538 }
12539
12540 +/**
12541 + * atomic64_add_return_unchecked - add and return
12542 + * @i: integer value to add
12543 + * @v: pointer to type atomic64_unchecked_t
12544 + *
12545 + * Atomically adds @i to @v and returns @i + *@v
12546 + */
12547 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12548 +{
12549 + alternative_atomic64(add_return_unchecked,
12550 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12551 + ASM_NO_INPUT_CLOBBER("memory"));
12552 + return i;
12553 +}
12554 +
12555 /*
12556 * Other variants with different arithmetic operators:
12557 */
12558 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12559 return a;
12560 }
12561
12562 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12563 +{
12564 + long long a;
12565 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12566 + "S" (v) : "memory", "ecx");
12567 + return a;
12568 +}
12569 +
12570 static inline long long atomic64_dec_return(atomic64_t *v)
12571 {
12572 long long a;
12573 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12574 }
12575
12576 /**
12577 + * atomic64_add_unchecked - add integer to atomic64 variable
12578 + * @i: integer value to add
12579 + * @v: pointer to type atomic64_unchecked_t
12580 + *
12581 + * Atomically adds @i to @v.
12582 + */
12583 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12584 +{
12585 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12586 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12587 + ASM_NO_INPUT_CLOBBER("memory"));
12588 + return i;
12589 +}
12590 +
12591 +/**
12592 * atomic64_sub - subtract the atomic64 variable
12593 * @i: integer value to subtract
12594 * @v: pointer to type atomic64_t
12595 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12596 index 0e1cbfc..5623683 100644
12597 --- a/arch/x86/include/asm/atomic64_64.h
12598 +++ b/arch/x86/include/asm/atomic64_64.h
12599 @@ -18,7 +18,19 @@
12600 */
12601 static inline long atomic64_read(const atomic64_t *v)
12602 {
12603 - return (*(volatile long *)&(v)->counter);
12604 + return (*(volatile const long *)&(v)->counter);
12605 +}
12606 +
12607 +/**
12608 + * atomic64_read_unchecked - read atomic64 variable
12609 + * @v: pointer of type atomic64_unchecked_t
12610 + *
12611 + * Atomically reads the value of @v.
12612 + * Doesn't imply a read memory barrier.
12613 + */
12614 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12615 +{
12616 + return (*(volatile const long *)&(v)->counter);
12617 }
12618
12619 /**
12620 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12621 }
12622
12623 /**
12624 + * atomic64_set_unchecked - set atomic64 variable
12625 + * @v: pointer to type atomic64_unchecked_t
12626 + * @i: required value
12627 + *
12628 + * Atomically sets the value of @v to @i.
12629 + */
12630 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12631 +{
12632 + v->counter = i;
12633 +}
12634 +
12635 +/**
12636 * atomic64_add - add integer to atomic64 variable
12637 * @i: integer value to add
12638 * @v: pointer to type atomic64_t
12639 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12640 */
12641 static inline void atomic64_add(long i, atomic64_t *v)
12642 {
12643 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12644 +
12645 +#ifdef CONFIG_PAX_REFCOUNT
12646 + "jno 0f\n"
12647 + LOCK_PREFIX "subq %1,%0\n"
12648 + "int $4\n0:\n"
12649 + _ASM_EXTABLE(0b, 0b)
12650 +#endif
12651 +
12652 + : "=m" (v->counter)
12653 + : "er" (i), "m" (v->counter));
12654 +}
12655 +
12656 +/**
12657 + * atomic64_add_unchecked - add integer to atomic64 variable
12658 + * @i: integer value to add
12659 + * @v: pointer to type atomic64_unchecked_t
12660 + *
12661 + * Atomically adds @i to @v.
12662 + */
12663 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12664 +{
12665 asm volatile(LOCK_PREFIX "addq %1,%0"
12666 : "=m" (v->counter)
12667 : "er" (i), "m" (v->counter));
12668 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12669 */
12670 static inline void atomic64_sub(long i, atomic64_t *v)
12671 {
12672 - asm volatile(LOCK_PREFIX "subq %1,%0"
12673 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12674 +
12675 +#ifdef CONFIG_PAX_REFCOUNT
12676 + "jno 0f\n"
12677 + LOCK_PREFIX "addq %1,%0\n"
12678 + "int $4\n0:\n"
12679 + _ASM_EXTABLE(0b, 0b)
12680 +#endif
12681 +
12682 + : "=m" (v->counter)
12683 + : "er" (i), "m" (v->counter));
12684 +}
12685 +
12686 +/**
12687 + * atomic64_sub_unchecked - subtract the atomic64 variable
12688 + * @i: integer value to subtract
12689 + * @v: pointer to type atomic64_unchecked_t
12690 + *
12691 + * Atomically subtracts @i from @v.
12692 + */
12693 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12694 +{
12695 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12696 : "=m" (v->counter)
12697 : "er" (i), "m" (v->counter));
12698 }
12699 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12700 {
12701 unsigned char c;
12702
12703 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12704 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12705 +
12706 +#ifdef CONFIG_PAX_REFCOUNT
12707 + "jno 0f\n"
12708 + LOCK_PREFIX "addq %2,%0\n"
12709 + "int $4\n0:\n"
12710 + _ASM_EXTABLE(0b, 0b)
12711 +#endif
12712 +
12713 + "sete %1\n"
12714 : "=m" (v->counter), "=qm" (c)
12715 : "er" (i), "m" (v->counter) : "memory");
12716 return c;
12717 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12718 */
12719 static inline void atomic64_inc(atomic64_t *v)
12720 {
12721 + asm volatile(LOCK_PREFIX "incq %0\n"
12722 +
12723 +#ifdef CONFIG_PAX_REFCOUNT
12724 + "jno 0f\n"
12725 + LOCK_PREFIX "decq %0\n"
12726 + "int $4\n0:\n"
12727 + _ASM_EXTABLE(0b, 0b)
12728 +#endif
12729 +
12730 + : "=m" (v->counter)
12731 + : "m" (v->counter));
12732 +}
12733 +
12734 +/**
12735 + * atomic64_inc_unchecked - increment atomic64 variable
12736 + * @v: pointer to type atomic64_unchecked_t
12737 + *
12738 + * Atomically increments @v by 1.
12739 + */
12740 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12741 +{
12742 asm volatile(LOCK_PREFIX "incq %0"
12743 : "=m" (v->counter)
12744 : "m" (v->counter));
12745 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12746 */
12747 static inline void atomic64_dec(atomic64_t *v)
12748 {
12749 - asm volatile(LOCK_PREFIX "decq %0"
12750 + asm volatile(LOCK_PREFIX "decq %0\n"
12751 +
12752 +#ifdef CONFIG_PAX_REFCOUNT
12753 + "jno 0f\n"
12754 + LOCK_PREFIX "incq %0\n"
12755 + "int $4\n0:\n"
12756 + _ASM_EXTABLE(0b, 0b)
12757 +#endif
12758 +
12759 + : "=m" (v->counter)
12760 + : "m" (v->counter));
12761 +}
12762 +
12763 +/**
12764 + * atomic64_dec_unchecked - decrement atomic64 variable
12765 + * @v: pointer to type atomic64_t
12766 + *
12767 + * Atomically decrements @v by 1.
12768 + */
12769 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12770 +{
12771 + asm volatile(LOCK_PREFIX "decq %0\n"
12772 : "=m" (v->counter)
12773 : "m" (v->counter));
12774 }
12775 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12776 {
12777 unsigned char c;
12778
12779 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12780 + asm volatile(LOCK_PREFIX "decq %0\n"
12781 +
12782 +#ifdef CONFIG_PAX_REFCOUNT
12783 + "jno 0f\n"
12784 + LOCK_PREFIX "incq %0\n"
12785 + "int $4\n0:\n"
12786 + _ASM_EXTABLE(0b, 0b)
12787 +#endif
12788 +
12789 + "sete %1\n"
12790 : "=m" (v->counter), "=qm" (c)
12791 : "m" (v->counter) : "memory");
12792 return c != 0;
12793 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12794 {
12795 unsigned char c;
12796
12797 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12798 + asm volatile(LOCK_PREFIX "incq %0\n"
12799 +
12800 +#ifdef CONFIG_PAX_REFCOUNT
12801 + "jno 0f\n"
12802 + LOCK_PREFIX "decq %0\n"
12803 + "int $4\n0:\n"
12804 + _ASM_EXTABLE(0b, 0b)
12805 +#endif
12806 +
12807 + "sete %1\n"
12808 : "=m" (v->counter), "=qm" (c)
12809 : "m" (v->counter) : "memory");
12810 return c != 0;
12811 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12812 {
12813 unsigned char c;
12814
12815 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12816 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12817 +
12818 +#ifdef CONFIG_PAX_REFCOUNT
12819 + "jno 0f\n"
12820 + LOCK_PREFIX "subq %2,%0\n"
12821 + "int $4\n0:\n"
12822 + _ASM_EXTABLE(0b, 0b)
12823 +#endif
12824 +
12825 + "sets %1\n"
12826 : "=m" (v->counter), "=qm" (c)
12827 : "er" (i), "m" (v->counter) : "memory");
12828 return c;
12829 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12830 */
12831 static inline long atomic64_add_return(long i, atomic64_t *v)
12832 {
12833 + return i + xadd_check_overflow(&v->counter, i);
12834 +}
12835 +
12836 +/**
12837 + * atomic64_add_return_unchecked - add and return
12838 + * @i: integer value to add
12839 + * @v: pointer to type atomic64_unchecked_t
12840 + *
12841 + * Atomically adds @i to @v and returns @i + @v
12842 + */
12843 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12844 +{
12845 return i + xadd(&v->counter, i);
12846 }
12847
12848 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12849 }
12850
12851 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12852 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12853 +{
12854 + return atomic64_add_return_unchecked(1, v);
12855 +}
12856 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12857
12858 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12859 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12860 return cmpxchg(&v->counter, old, new);
12861 }
12862
12863 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12864 +{
12865 + return cmpxchg(&v->counter, old, new);
12866 +}
12867 +
12868 static inline long atomic64_xchg(atomic64_t *v, long new)
12869 {
12870 return xchg(&v->counter, new);
12871 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12872 */
12873 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12874 {
12875 - long c, old;
12876 + long c, old, new;
12877 c = atomic64_read(v);
12878 for (;;) {
12879 - if (unlikely(c == (u)))
12880 + if (unlikely(c == u))
12881 break;
12882 - old = atomic64_cmpxchg((v), c, c + (a));
12883 +
12884 + asm volatile("add %2,%0\n"
12885 +
12886 +#ifdef CONFIG_PAX_REFCOUNT
12887 + "jno 0f\n"
12888 + "sub %2,%0\n"
12889 + "int $4\n0:\n"
12890 + _ASM_EXTABLE(0b, 0b)
12891 +#endif
12892 +
12893 + : "=r" (new)
12894 + : "0" (c), "ir" (a));
12895 +
12896 + old = atomic64_cmpxchg(v, c, new);
12897 if (likely(old == c))
12898 break;
12899 c = old;
12900 }
12901 - return c != (u);
12902 + return c != u;
12903 }
12904
12905 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12906 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12907 index 6dfd019..28e188d 100644
12908 --- a/arch/x86/include/asm/bitops.h
12909 +++ b/arch/x86/include/asm/bitops.h
12910 @@ -40,7 +40,7 @@
12911 * a mask operation on a byte.
12912 */
12913 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12914 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12915 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12916 #define CONST_MASK(nr) (1 << ((nr) & 7))
12917
12918 /**
12919 @@ -486,7 +486,7 @@ static inline int fls(int x)
12920 * at position 64.
12921 */
12922 #ifdef CONFIG_X86_64
12923 -static __always_inline int fls64(__u64 x)
12924 +static __always_inline long fls64(__u64 x)
12925 {
12926 int bitpos = -1;
12927 /*
12928 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12929 index 4fa687a..60f2d39 100644
12930 --- a/arch/x86/include/asm/boot.h
12931 +++ b/arch/x86/include/asm/boot.h
12932 @@ -6,10 +6,15 @@
12933 #include <uapi/asm/boot.h>
12934
12935 /* Physical address where kernel should be loaded. */
12936 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12937 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12938 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12939 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12940
12941 +#ifndef __ASSEMBLY__
12942 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12943 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12944 +#endif
12945 +
12946 /* Minimum kernel alignment, as a power of two */
12947 #ifdef CONFIG_X86_64
12948 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12949 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12950 index 48f99f1..d78ebf9 100644
12951 --- a/arch/x86/include/asm/cache.h
12952 +++ b/arch/x86/include/asm/cache.h
12953 @@ -5,12 +5,13 @@
12954
12955 /* L1 cache line size */
12956 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12957 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12958 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12959
12960 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12961 +#define __read_only __attribute__((__section__(".data..read_only")))
12962
12963 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12964 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12965 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12966
12967 #ifdef CONFIG_X86_VSMP
12968 #ifdef CONFIG_SMP
12969 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12970 index 9863ee3..4a1f8e1 100644
12971 --- a/arch/x86/include/asm/cacheflush.h
12972 +++ b/arch/x86/include/asm/cacheflush.h
12973 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12974 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12975
12976 if (pg_flags == _PGMT_DEFAULT)
12977 - return -1;
12978 + return ~0UL;
12979 else if (pg_flags == _PGMT_WC)
12980 return _PAGE_CACHE_WC;
12981 else if (pg_flags == _PGMT_UC_MINUS)
12982 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12983 index 46fc474..b02b0f9 100644
12984 --- a/arch/x86/include/asm/checksum_32.h
12985 +++ b/arch/x86/include/asm/checksum_32.h
12986 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12987 int len, __wsum sum,
12988 int *src_err_ptr, int *dst_err_ptr);
12989
12990 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12991 + int len, __wsum sum,
12992 + int *src_err_ptr, int *dst_err_ptr);
12993 +
12994 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12995 + int len, __wsum sum,
12996 + int *src_err_ptr, int *dst_err_ptr);
12997 +
12998 /*
12999 * Note: when you get a NULL pointer exception here this means someone
13000 * passed in an incorrect kernel address to one of these functions.
13001 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13002 int *err_ptr)
13003 {
13004 might_sleep();
13005 - return csum_partial_copy_generic((__force void *)src, dst,
13006 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13007 len, sum, err_ptr, NULL);
13008 }
13009
13010 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13011 {
13012 might_sleep();
13013 if (access_ok(VERIFY_WRITE, dst, len))
13014 - return csum_partial_copy_generic(src, (__force void *)dst,
13015 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13016 len, sum, NULL, err_ptr);
13017
13018 if (len)
13019 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13020 index 8d871ea..c1a0dc9 100644
13021 --- a/arch/x86/include/asm/cmpxchg.h
13022 +++ b/arch/x86/include/asm/cmpxchg.h
13023 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13024 __compiletime_error("Bad argument size for cmpxchg");
13025 extern void __xadd_wrong_size(void)
13026 __compiletime_error("Bad argument size for xadd");
13027 +extern void __xadd_check_overflow_wrong_size(void)
13028 + __compiletime_error("Bad argument size for xadd_check_overflow");
13029 extern void __add_wrong_size(void)
13030 __compiletime_error("Bad argument size for add");
13031 +extern void __add_check_overflow_wrong_size(void)
13032 + __compiletime_error("Bad argument size for add_check_overflow");
13033
13034 /*
13035 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13036 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13037 __ret; \
13038 })
13039
13040 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13041 + ({ \
13042 + __typeof__ (*(ptr)) __ret = (arg); \
13043 + switch (sizeof(*(ptr))) { \
13044 + case __X86_CASE_L: \
13045 + asm volatile (lock #op "l %0, %1\n" \
13046 + "jno 0f\n" \
13047 + "mov %0,%1\n" \
13048 + "int $4\n0:\n" \
13049 + _ASM_EXTABLE(0b, 0b) \
13050 + : "+r" (__ret), "+m" (*(ptr)) \
13051 + : : "memory", "cc"); \
13052 + break; \
13053 + case __X86_CASE_Q: \
13054 + asm volatile (lock #op "q %q0, %1\n" \
13055 + "jno 0f\n" \
13056 + "mov %0,%1\n" \
13057 + "int $4\n0:\n" \
13058 + _ASM_EXTABLE(0b, 0b) \
13059 + : "+r" (__ret), "+m" (*(ptr)) \
13060 + : : "memory", "cc"); \
13061 + break; \
13062 + default: \
13063 + __ ## op ## _check_overflow_wrong_size(); \
13064 + } \
13065 + __ret; \
13066 + })
13067 +
13068 /*
13069 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13070 * Since this is generally used to protect other memory information, we
13071 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13072 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13073 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13074
13075 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13076 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13077 +
13078 #define __add(ptr, inc, lock) \
13079 ({ \
13080 __typeof__ (*(ptr)) __ret = (inc); \
13081 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13082 index 59c6c40..5e0b22c 100644
13083 --- a/arch/x86/include/asm/compat.h
13084 +++ b/arch/x86/include/asm/compat.h
13085 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13086 typedef u32 compat_uint_t;
13087 typedef u32 compat_ulong_t;
13088 typedef u64 __attribute__((aligned(4))) compat_u64;
13089 -typedef u32 compat_uptr_t;
13090 +typedef u32 __user compat_uptr_t;
13091
13092 struct compat_timespec {
13093 compat_time_t tv_sec;
13094 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13095 index 93fe929..90858b7 100644
13096 --- a/arch/x86/include/asm/cpufeature.h
13097 +++ b/arch/x86/include/asm/cpufeature.h
13098 @@ -207,7 +207,7 @@
13099 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13100 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13101 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13102 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13103 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13104 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13105 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13106 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13107 @@ -377,7 +377,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13108 ".section .discard,\"aw\",@progbits\n"
13109 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13110 ".previous\n"
13111 - ".section .altinstr_replacement,\"ax\"\n"
13112 + ".section .altinstr_replacement,\"a\"\n"
13113 "3: movb $1,%0\n"
13114 "4:\n"
13115 ".previous\n"
13116 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13117 index 8bf1c06..b6ae785 100644
13118 --- a/arch/x86/include/asm/desc.h
13119 +++ b/arch/x86/include/asm/desc.h
13120 @@ -4,6 +4,7 @@
13121 #include <asm/desc_defs.h>
13122 #include <asm/ldt.h>
13123 #include <asm/mmu.h>
13124 +#include <asm/pgtable.h>
13125
13126 #include <linux/smp.h>
13127 #include <linux/percpu.h>
13128 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13129
13130 desc->type = (info->read_exec_only ^ 1) << 1;
13131 desc->type |= info->contents << 2;
13132 + desc->type |= info->seg_not_present ^ 1;
13133
13134 desc->s = 1;
13135 desc->dpl = 0x3;
13136 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13137 }
13138
13139 extern struct desc_ptr idt_descr;
13140 -extern gate_desc idt_table[];
13141 extern struct desc_ptr nmi_idt_descr;
13142 -extern gate_desc nmi_idt_table[];
13143 -
13144 -struct gdt_page {
13145 - struct desc_struct gdt[GDT_ENTRIES];
13146 -} __attribute__((aligned(PAGE_SIZE)));
13147 -
13148 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13149 +extern gate_desc idt_table[256];
13150 +extern gate_desc nmi_idt_table[256];
13151
13152 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13153 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13154 {
13155 - return per_cpu(gdt_page, cpu).gdt;
13156 + return cpu_gdt_table[cpu];
13157 }
13158
13159 #ifdef CONFIG_X86_64
13160 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13161 unsigned long base, unsigned dpl, unsigned flags,
13162 unsigned short seg)
13163 {
13164 - gate->a = (seg << 16) | (base & 0xffff);
13165 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13166 + gate->gate.offset_low = base;
13167 + gate->gate.seg = seg;
13168 + gate->gate.reserved = 0;
13169 + gate->gate.type = type;
13170 + gate->gate.s = 0;
13171 + gate->gate.dpl = dpl;
13172 + gate->gate.p = 1;
13173 + gate->gate.offset_high = base >> 16;
13174 }
13175
13176 #endif
13177 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13178
13179 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13180 {
13181 + pax_open_kernel();
13182 memcpy(&idt[entry], gate, sizeof(*gate));
13183 + pax_close_kernel();
13184 }
13185
13186 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13187 {
13188 + pax_open_kernel();
13189 memcpy(&ldt[entry], desc, 8);
13190 + pax_close_kernel();
13191 }
13192
13193 static inline void
13194 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13195 default: size = sizeof(*gdt); break;
13196 }
13197
13198 + pax_open_kernel();
13199 memcpy(&gdt[entry], desc, size);
13200 + pax_close_kernel();
13201 }
13202
13203 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13204 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13205
13206 static inline void native_load_tr_desc(void)
13207 {
13208 + pax_open_kernel();
13209 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13210 + pax_close_kernel();
13211 }
13212
13213 static inline void native_load_gdt(const struct desc_ptr *dtr)
13214 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13215 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13216 unsigned int i;
13217
13218 + pax_open_kernel();
13219 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13220 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13221 + pax_close_kernel();
13222 }
13223
13224 #define _LDT_empty(info) \
13225 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13226 preempt_enable();
13227 }
13228
13229 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13230 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13231 {
13232 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13233 }
13234 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13235 }
13236
13237 #ifdef CONFIG_X86_64
13238 -static inline void set_nmi_gate(int gate, void *addr)
13239 +static inline void set_nmi_gate(int gate, const void *addr)
13240 {
13241 gate_desc s;
13242
13243 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13244 }
13245 #endif
13246
13247 -static inline void _set_gate(int gate, unsigned type, void *addr,
13248 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13249 unsigned dpl, unsigned ist, unsigned seg)
13250 {
13251 gate_desc s;
13252 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13253 * Pentium F0 0F bugfix can have resulted in the mapped
13254 * IDT being write-protected.
13255 */
13256 -static inline void set_intr_gate(unsigned int n, void *addr)
13257 +static inline void set_intr_gate(unsigned int n, const void *addr)
13258 {
13259 BUG_ON((unsigned)n > 0xFF);
13260 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13261 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13262 /*
13263 * This routine sets up an interrupt gate at directory privilege level 3.
13264 */
13265 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13266 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13267 {
13268 BUG_ON((unsigned)n > 0xFF);
13269 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13270 }
13271
13272 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13273 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13274 {
13275 BUG_ON((unsigned)n > 0xFF);
13276 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13277 }
13278
13279 -static inline void set_trap_gate(unsigned int n, void *addr)
13280 +static inline void set_trap_gate(unsigned int n, const void *addr)
13281 {
13282 BUG_ON((unsigned)n > 0xFF);
13283 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13284 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13285 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13286 {
13287 BUG_ON((unsigned)n > 0xFF);
13288 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13289 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13290 }
13291
13292 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13293 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13294 {
13295 BUG_ON((unsigned)n > 0xFF);
13296 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13297 }
13298
13299 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13300 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13301 {
13302 BUG_ON((unsigned)n > 0xFF);
13303 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13304 }
13305
13306 +#ifdef CONFIG_X86_32
13307 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13308 +{
13309 + struct desc_struct d;
13310 +
13311 + if (likely(limit))
13312 + limit = (limit - 1UL) >> PAGE_SHIFT;
13313 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13314 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13315 +}
13316 +#endif
13317 +
13318 #endif /* _ASM_X86_DESC_H */
13319 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13320 index 278441f..b95a174 100644
13321 --- a/arch/x86/include/asm/desc_defs.h
13322 +++ b/arch/x86/include/asm/desc_defs.h
13323 @@ -31,6 +31,12 @@ struct desc_struct {
13324 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13325 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13326 };
13327 + struct {
13328 + u16 offset_low;
13329 + u16 seg;
13330 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13331 + unsigned offset_high: 16;
13332 + } gate;
13333 };
13334 } __attribute__((packed));
13335
13336 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13337 index ced283a..ffe04cc 100644
13338 --- a/arch/x86/include/asm/div64.h
13339 +++ b/arch/x86/include/asm/div64.h
13340 @@ -39,7 +39,7 @@
13341 __mod; \
13342 })
13343
13344 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13345 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13346 {
13347 union {
13348 u64 v64;
13349 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13350 index 9c999c1..3860cb8 100644
13351 --- a/arch/x86/include/asm/elf.h
13352 +++ b/arch/x86/include/asm/elf.h
13353 @@ -243,7 +243,25 @@ extern int force_personality32;
13354 the loader. We need to make sure that it is out of the way of the program
13355 that it will "exec", and that there is sufficient room for the brk. */
13356
13357 +#ifdef CONFIG_PAX_SEGMEXEC
13358 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13359 +#else
13360 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13361 +#endif
13362 +
13363 +#ifdef CONFIG_PAX_ASLR
13364 +#ifdef CONFIG_X86_32
13365 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13366 +
13367 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13368 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13369 +#else
13370 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13371 +
13372 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13373 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13374 +#endif
13375 +#endif
13376
13377 /* This yields a mask that user programs can use to figure out what
13378 instruction set this CPU supports. This could be done in user space,
13379 @@ -296,16 +314,12 @@ do { \
13380
13381 #define ARCH_DLINFO \
13382 do { \
13383 - if (vdso_enabled) \
13384 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13385 - (unsigned long)current->mm->context.vdso); \
13386 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13387 } while (0)
13388
13389 #define ARCH_DLINFO_X32 \
13390 do { \
13391 - if (vdso_enabled) \
13392 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13393 - (unsigned long)current->mm->context.vdso); \
13394 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13395 } while (0)
13396
13397 #define AT_SYSINFO 32
13398 @@ -320,7 +334,7 @@ else \
13399
13400 #endif /* !CONFIG_X86_32 */
13401
13402 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13403 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13404
13405 #define VDSO_ENTRY \
13406 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13407 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13408 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13409 #define compat_arch_setup_additional_pages syscall32_setup_pages
13410
13411 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13412 -#define arch_randomize_brk arch_randomize_brk
13413 -
13414 /*
13415 * True on X86_32 or when emulating IA32 on X86_64
13416 */
13417 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13418 index 75ce3f4..882e801 100644
13419 --- a/arch/x86/include/asm/emergency-restart.h
13420 +++ b/arch/x86/include/asm/emergency-restart.h
13421 @@ -13,6 +13,6 @@ enum reboot_type {
13422
13423 extern enum reboot_type reboot_type;
13424
13425 -extern void machine_emergency_restart(void);
13426 +extern void machine_emergency_restart(void) __noreturn;
13427
13428 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13429 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13430 index e25cc33..425d099 100644
13431 --- a/arch/x86/include/asm/fpu-internal.h
13432 +++ b/arch/x86/include/asm/fpu-internal.h
13433 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13434 ({ \
13435 int err; \
13436 asm volatile(ASM_STAC "\n" \
13437 - "1:" #insn "\n\t" \
13438 + "1:" \
13439 + __copyuser_seg \
13440 + #insn "\n\t" \
13441 "2: " ASM_CLAC "\n" \
13442 ".section .fixup,\"ax\"\n" \
13443 "3: movl $-1,%[err]\n" \
13444 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13445 "emms\n\t" /* clear stack tags */
13446 "fildl %P[addr]", /* set F?P to defined value */
13447 X86_FEATURE_FXSAVE_LEAK,
13448 - [addr] "m" (tsk->thread.fpu.has_fpu));
13449 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13450
13451 return fpu_restore_checking(&tsk->thread.fpu);
13452 }
13453 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13454 index be27ba1..8f13ff9 100644
13455 --- a/arch/x86/include/asm/futex.h
13456 +++ b/arch/x86/include/asm/futex.h
13457 @@ -12,6 +12,7 @@
13458 #include <asm/smap.h>
13459
13460 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13461 + typecheck(u32 __user *, uaddr); \
13462 asm volatile("\t" ASM_STAC "\n" \
13463 "1:\t" insn "\n" \
13464 "2:\t" ASM_CLAC "\n" \
13465 @@ -20,15 +21,16 @@
13466 "\tjmp\t2b\n" \
13467 "\t.previous\n" \
13468 _ASM_EXTABLE(1b, 3b) \
13469 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13470 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13471 : "i" (-EFAULT), "0" (oparg), "1" (0))
13472
13473 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13474 + typecheck(u32 __user *, uaddr); \
13475 asm volatile("\t" ASM_STAC "\n" \
13476 "1:\tmovl %2, %0\n" \
13477 "\tmovl\t%0, %3\n" \
13478 "\t" insn "\n" \
13479 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13480 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13481 "\tjnz\t1b\n" \
13482 "3:\t" ASM_CLAC "\n" \
13483 "\t.section .fixup,\"ax\"\n" \
13484 @@ -38,7 +40,7 @@
13485 _ASM_EXTABLE(1b, 4b) \
13486 _ASM_EXTABLE(2b, 4b) \
13487 : "=&a" (oldval), "=&r" (ret), \
13488 - "+m" (*uaddr), "=&r" (tem) \
13489 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13490 : "r" (oparg), "i" (-EFAULT), "1" (0))
13491
13492 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13493 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13494
13495 switch (op) {
13496 case FUTEX_OP_SET:
13497 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13498 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13499 break;
13500 case FUTEX_OP_ADD:
13501 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13502 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13503 uaddr, oparg);
13504 break;
13505 case FUTEX_OP_OR:
13506 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13507 return -EFAULT;
13508
13509 asm volatile("\t" ASM_STAC "\n"
13510 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13511 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13512 "2:\t" ASM_CLAC "\n"
13513 "\t.section .fixup, \"ax\"\n"
13514 "3:\tmov %3, %0\n"
13515 "\tjmp 2b\n"
13516 "\t.previous\n"
13517 _ASM_EXTABLE(1b, 3b)
13518 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13519 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13520 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13521 : "memory"
13522 );
13523 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13524 index 10a78c3..cc77143 100644
13525 --- a/arch/x86/include/asm/hw_irq.h
13526 +++ b/arch/x86/include/asm/hw_irq.h
13527 @@ -147,8 +147,8 @@ extern void setup_ioapic_dest(void);
13528 extern void enable_IO_APIC(void);
13529
13530 /* Statistics */
13531 -extern atomic_t irq_err_count;
13532 -extern atomic_t irq_mis_count;
13533 +extern atomic_unchecked_t irq_err_count;
13534 +extern atomic_unchecked_t irq_mis_count;
13535
13536 /* EISA */
13537 extern void eisa_set_level_irq(unsigned int irq);
13538 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13539 index a203659..9889f1c 100644
13540 --- a/arch/x86/include/asm/i8259.h
13541 +++ b/arch/x86/include/asm/i8259.h
13542 @@ -62,7 +62,7 @@ struct legacy_pic {
13543 void (*init)(int auto_eoi);
13544 int (*irq_pending)(unsigned int irq);
13545 void (*make_irq)(unsigned int irq);
13546 -};
13547 +} __do_const;
13548
13549 extern struct legacy_pic *legacy_pic;
13550 extern struct legacy_pic null_legacy_pic;
13551 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13552 index d8e8eef..1765f78 100644
13553 --- a/arch/x86/include/asm/io.h
13554 +++ b/arch/x86/include/asm/io.h
13555 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13556 "m" (*(volatile type __force *)addr) barrier); }
13557
13558 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13559 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13560 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13561 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13562 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13563
13564 build_mmio_read(__readb, "b", unsigned char, "=q", )
13565 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13566 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13567 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13568 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13569
13570 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13571 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13572 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13573 return ioremap_nocache(offset, size);
13574 }
13575
13576 -extern void iounmap(volatile void __iomem *addr);
13577 +extern void iounmap(const volatile void __iomem *addr);
13578
13579 extern void set_iounmap_nonlazy(void);
13580
13581 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13582
13583 #include <linux/vmalloc.h>
13584
13585 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13586 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13587 +{
13588 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13589 +}
13590 +
13591 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13592 +{
13593 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13594 +}
13595 +
13596 /*
13597 * Convert a virtual cached pointer to an uncached pointer
13598 */
13599 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13600 index bba3cf8..06bc8da 100644
13601 --- a/arch/x86/include/asm/irqflags.h
13602 +++ b/arch/x86/include/asm/irqflags.h
13603 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13604 sti; \
13605 sysexit
13606
13607 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13608 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13609 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13610 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13611 +
13612 #else
13613 #define INTERRUPT_RETURN iret
13614 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13615 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13616 index 5a6d287..f815789 100644
13617 --- a/arch/x86/include/asm/kprobes.h
13618 +++ b/arch/x86/include/asm/kprobes.h
13619 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13620 #define RELATIVEJUMP_SIZE 5
13621 #define RELATIVECALL_OPCODE 0xe8
13622 #define RELATIVE_ADDR_SIZE 4
13623 -#define MAX_STACK_SIZE 64
13624 -#define MIN_STACK_SIZE(ADDR) \
13625 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13626 - THREAD_SIZE - (unsigned long)(ADDR))) \
13627 - ? (MAX_STACK_SIZE) \
13628 - : (((unsigned long)current_thread_info()) + \
13629 - THREAD_SIZE - (unsigned long)(ADDR)))
13630 +#define MAX_STACK_SIZE 64UL
13631 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13632
13633 #define flush_insn_slot(p) do { } while (0)
13634
13635 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13636 index 2d89e39..baee879 100644
13637 --- a/arch/x86/include/asm/local.h
13638 +++ b/arch/x86/include/asm/local.h
13639 @@ -10,33 +10,97 @@ typedef struct {
13640 atomic_long_t a;
13641 } local_t;
13642
13643 +typedef struct {
13644 + atomic_long_unchecked_t a;
13645 +} local_unchecked_t;
13646 +
13647 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13648
13649 #define local_read(l) atomic_long_read(&(l)->a)
13650 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13651 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13652 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13653
13654 static inline void local_inc(local_t *l)
13655 {
13656 - asm volatile(_ASM_INC "%0"
13657 + asm volatile(_ASM_INC "%0\n"
13658 +
13659 +#ifdef CONFIG_PAX_REFCOUNT
13660 + "jno 0f\n"
13661 + _ASM_DEC "%0\n"
13662 + "int $4\n0:\n"
13663 + _ASM_EXTABLE(0b, 0b)
13664 +#endif
13665 +
13666 + : "+m" (l->a.counter));
13667 +}
13668 +
13669 +static inline void local_inc_unchecked(local_unchecked_t *l)
13670 +{
13671 + asm volatile(_ASM_INC "%0\n"
13672 : "+m" (l->a.counter));
13673 }
13674
13675 static inline void local_dec(local_t *l)
13676 {
13677 - asm volatile(_ASM_DEC "%0"
13678 + asm volatile(_ASM_DEC "%0\n"
13679 +
13680 +#ifdef CONFIG_PAX_REFCOUNT
13681 + "jno 0f\n"
13682 + _ASM_INC "%0\n"
13683 + "int $4\n0:\n"
13684 + _ASM_EXTABLE(0b, 0b)
13685 +#endif
13686 +
13687 + : "+m" (l->a.counter));
13688 +}
13689 +
13690 +static inline void local_dec_unchecked(local_unchecked_t *l)
13691 +{
13692 + asm volatile(_ASM_DEC "%0\n"
13693 : "+m" (l->a.counter));
13694 }
13695
13696 static inline void local_add(long i, local_t *l)
13697 {
13698 - asm volatile(_ASM_ADD "%1,%0"
13699 + asm volatile(_ASM_ADD "%1,%0\n"
13700 +
13701 +#ifdef CONFIG_PAX_REFCOUNT
13702 + "jno 0f\n"
13703 + _ASM_SUB "%1,%0\n"
13704 + "int $4\n0:\n"
13705 + _ASM_EXTABLE(0b, 0b)
13706 +#endif
13707 +
13708 + : "+m" (l->a.counter)
13709 + : "ir" (i));
13710 +}
13711 +
13712 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13713 +{
13714 + asm volatile(_ASM_ADD "%1,%0\n"
13715 : "+m" (l->a.counter)
13716 : "ir" (i));
13717 }
13718
13719 static inline void local_sub(long i, local_t *l)
13720 {
13721 - asm volatile(_ASM_SUB "%1,%0"
13722 + asm volatile(_ASM_SUB "%1,%0\n"
13723 +
13724 +#ifdef CONFIG_PAX_REFCOUNT
13725 + "jno 0f\n"
13726 + _ASM_ADD "%1,%0\n"
13727 + "int $4\n0:\n"
13728 + _ASM_EXTABLE(0b, 0b)
13729 +#endif
13730 +
13731 + : "+m" (l->a.counter)
13732 + : "ir" (i));
13733 +}
13734 +
13735 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13736 +{
13737 + asm volatile(_ASM_SUB "%1,%0\n"
13738 : "+m" (l->a.counter)
13739 : "ir" (i));
13740 }
13741 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13742 {
13743 unsigned char c;
13744
13745 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13746 + asm volatile(_ASM_SUB "%2,%0\n"
13747 +
13748 +#ifdef CONFIG_PAX_REFCOUNT
13749 + "jno 0f\n"
13750 + _ASM_ADD "%2,%0\n"
13751 + "int $4\n0:\n"
13752 + _ASM_EXTABLE(0b, 0b)
13753 +#endif
13754 +
13755 + "sete %1\n"
13756 : "+m" (l->a.counter), "=qm" (c)
13757 : "ir" (i) : "memory");
13758 return c;
13759 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13760 {
13761 unsigned char c;
13762
13763 - asm volatile(_ASM_DEC "%0; sete %1"
13764 + asm volatile(_ASM_DEC "%0\n"
13765 +
13766 +#ifdef CONFIG_PAX_REFCOUNT
13767 + "jno 0f\n"
13768 + _ASM_INC "%0\n"
13769 + "int $4\n0:\n"
13770 + _ASM_EXTABLE(0b, 0b)
13771 +#endif
13772 +
13773 + "sete %1\n"
13774 : "+m" (l->a.counter), "=qm" (c)
13775 : : "memory");
13776 return c != 0;
13777 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13778 {
13779 unsigned char c;
13780
13781 - asm volatile(_ASM_INC "%0; sete %1"
13782 + asm volatile(_ASM_INC "%0\n"
13783 +
13784 +#ifdef CONFIG_PAX_REFCOUNT
13785 + "jno 0f\n"
13786 + _ASM_DEC "%0\n"
13787 + "int $4\n0:\n"
13788 + _ASM_EXTABLE(0b, 0b)
13789 +#endif
13790 +
13791 + "sete %1\n"
13792 : "+m" (l->a.counter), "=qm" (c)
13793 : : "memory");
13794 return c != 0;
13795 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13796 {
13797 unsigned char c;
13798
13799 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13800 + asm volatile(_ASM_ADD "%2,%0\n"
13801 +
13802 +#ifdef CONFIG_PAX_REFCOUNT
13803 + "jno 0f\n"
13804 + _ASM_SUB "%2,%0\n"
13805 + "int $4\n0:\n"
13806 + _ASM_EXTABLE(0b, 0b)
13807 +#endif
13808 +
13809 + "sets %1\n"
13810 : "+m" (l->a.counter), "=qm" (c)
13811 : "ir" (i) : "memory");
13812 return c;
13813 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13814 static inline long local_add_return(long i, local_t *l)
13815 {
13816 long __i = i;
13817 + asm volatile(_ASM_XADD "%0, %1\n"
13818 +
13819 +#ifdef CONFIG_PAX_REFCOUNT
13820 + "jno 0f\n"
13821 + _ASM_MOV "%0,%1\n"
13822 + "int $4\n0:\n"
13823 + _ASM_EXTABLE(0b, 0b)
13824 +#endif
13825 +
13826 + : "+r" (i), "+m" (l->a.counter)
13827 + : : "memory");
13828 + return i + __i;
13829 +}
13830 +
13831 +/**
13832 + * local_add_return_unchecked - add and return
13833 + * @i: integer value to add
13834 + * @l: pointer to type local_unchecked_t
13835 + *
13836 + * Atomically adds @i to @l and returns @i + @l
13837 + */
13838 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13839 +{
13840 + long __i = i;
13841 asm volatile(_ASM_XADD "%0, %1;"
13842 : "+r" (i), "+m" (l->a.counter)
13843 : : "memory");
13844 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13845
13846 #define local_cmpxchg(l, o, n) \
13847 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13848 +#define local_cmpxchg_unchecked(l, o, n) \
13849 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13850 /* Always has a lock prefix */
13851 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13852
13853 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13854 new file mode 100644
13855 index 0000000..2bfd3ba
13856 --- /dev/null
13857 +++ b/arch/x86/include/asm/mman.h
13858 @@ -0,0 +1,15 @@
13859 +#ifndef _X86_MMAN_H
13860 +#define _X86_MMAN_H
13861 +
13862 +#include <uapi/asm/mman.h>
13863 +
13864 +#ifdef __KERNEL__
13865 +#ifndef __ASSEMBLY__
13866 +#ifdef CONFIG_X86_32
13867 +#define arch_mmap_check i386_mmap_check
13868 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13869 +#endif
13870 +#endif
13871 +#endif
13872 +
13873 +#endif /* X86_MMAN_H */
13874 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13875 index 5f55e69..e20bfb1 100644
13876 --- a/arch/x86/include/asm/mmu.h
13877 +++ b/arch/x86/include/asm/mmu.h
13878 @@ -9,7 +9,7 @@
13879 * we put the segment information here.
13880 */
13881 typedef struct {
13882 - void *ldt;
13883 + struct desc_struct *ldt;
13884 int size;
13885
13886 #ifdef CONFIG_X86_64
13887 @@ -18,7 +18,19 @@ typedef struct {
13888 #endif
13889
13890 struct mutex lock;
13891 - void *vdso;
13892 + unsigned long vdso;
13893 +
13894 +#ifdef CONFIG_X86_32
13895 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13896 + unsigned long user_cs_base;
13897 + unsigned long user_cs_limit;
13898 +
13899 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13900 + cpumask_t cpu_user_cs_mask;
13901 +#endif
13902 +
13903 +#endif
13904 +#endif
13905 } mm_context_t;
13906
13907 #ifdef CONFIG_SMP
13908 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13909 index cdbf367..adb37ac 100644
13910 --- a/arch/x86/include/asm/mmu_context.h
13911 +++ b/arch/x86/include/asm/mmu_context.h
13912 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13913
13914 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13915 {
13916 +
13917 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13918 + unsigned int i;
13919 + pgd_t *pgd;
13920 +
13921 + pax_open_kernel();
13922 + pgd = get_cpu_pgd(smp_processor_id());
13923 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13924 + set_pgd_batched(pgd+i, native_make_pgd(0));
13925 + pax_close_kernel();
13926 +#endif
13927 +
13928 #ifdef CONFIG_SMP
13929 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13930 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13931 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13932 struct task_struct *tsk)
13933 {
13934 unsigned cpu = smp_processor_id();
13935 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13936 + int tlbstate = TLBSTATE_OK;
13937 +#endif
13938
13939 if (likely(prev != next)) {
13940 #ifdef CONFIG_SMP
13941 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13942 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13943 +#endif
13944 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13945 this_cpu_write(cpu_tlbstate.active_mm, next);
13946 #endif
13947 cpumask_set_cpu(cpu, mm_cpumask(next));
13948
13949 /* Re-load page tables */
13950 +#ifdef CONFIG_PAX_PER_CPU_PGD
13951 + pax_open_kernel();
13952 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13953 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13954 + pax_close_kernel();
13955 + load_cr3(get_cpu_pgd(cpu));
13956 +#else
13957 load_cr3(next->pgd);
13958 +#endif
13959
13960 /* stop flush ipis for the previous mm */
13961 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13962 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13963 */
13964 if (unlikely(prev->context.ldt != next->context.ldt))
13965 load_LDT_nolock(&next->context);
13966 - }
13967 +
13968 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13969 + if (!(__supported_pte_mask & _PAGE_NX)) {
13970 + smp_mb__before_clear_bit();
13971 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13972 + smp_mb__after_clear_bit();
13973 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13974 + }
13975 +#endif
13976 +
13977 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13978 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13979 + prev->context.user_cs_limit != next->context.user_cs_limit))
13980 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13981 #ifdef CONFIG_SMP
13982 + else if (unlikely(tlbstate != TLBSTATE_OK))
13983 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13984 +#endif
13985 +#endif
13986 +
13987 + }
13988 else {
13989 +
13990 +#ifdef CONFIG_PAX_PER_CPU_PGD
13991 + pax_open_kernel();
13992 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13993 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13994 + pax_close_kernel();
13995 + load_cr3(get_cpu_pgd(cpu));
13996 +#endif
13997 +
13998 +#ifdef CONFIG_SMP
13999 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14000 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14001
14002 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14003 * tlb flush IPI delivery. We must reload CR3
14004 * to make sure to use no freed page tables.
14005 */
14006 +
14007 +#ifndef CONFIG_PAX_PER_CPU_PGD
14008 load_cr3(next->pgd);
14009 +#endif
14010 +
14011 load_LDT_nolock(&next->context);
14012 +
14013 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14014 + if (!(__supported_pte_mask & _PAGE_NX))
14015 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14016 +#endif
14017 +
14018 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14019 +#ifdef CONFIG_PAX_PAGEEXEC
14020 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14021 +#endif
14022 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14023 +#endif
14024 +
14025 }
14026 +#endif
14027 }
14028 -#endif
14029 }
14030
14031 #define activate_mm(prev, next) \
14032 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14033 index e3b7819..b257c64 100644
14034 --- a/arch/x86/include/asm/module.h
14035 +++ b/arch/x86/include/asm/module.h
14036 @@ -5,6 +5,7 @@
14037
14038 #ifdef CONFIG_X86_64
14039 /* X86_64 does not define MODULE_PROC_FAMILY */
14040 +#define MODULE_PROC_FAMILY ""
14041 #elif defined CONFIG_M486
14042 #define MODULE_PROC_FAMILY "486 "
14043 #elif defined CONFIG_M586
14044 @@ -57,8 +58,20 @@
14045 #error unknown processor family
14046 #endif
14047
14048 -#ifdef CONFIG_X86_32
14049 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14050 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14051 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14052 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14053 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14054 +#else
14055 +#define MODULE_PAX_KERNEXEC ""
14056 #endif
14057
14058 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14059 +#define MODULE_PAX_UDEREF "UDEREF "
14060 +#else
14061 +#define MODULE_PAX_UDEREF ""
14062 +#endif
14063 +
14064 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14065 +
14066 #endif /* _ASM_X86_MODULE_H */
14067 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14068 index c0fa356..07a498a 100644
14069 --- a/arch/x86/include/asm/nmi.h
14070 +++ b/arch/x86/include/asm/nmi.h
14071 @@ -42,11 +42,11 @@ struct nmiaction {
14072 nmi_handler_t handler;
14073 unsigned long flags;
14074 const char *name;
14075 -};
14076 +} __do_const;
14077
14078 #define register_nmi_handler(t, fn, fg, n, init...) \
14079 ({ \
14080 - static struct nmiaction init fn##_na = { \
14081 + static const struct nmiaction init fn##_na = { \
14082 .handler = (fn), \
14083 .name = (n), \
14084 .flags = (fg), \
14085 @@ -54,7 +54,7 @@ struct nmiaction {
14086 __register_nmi_handler((t), &fn##_na); \
14087 })
14088
14089 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14090 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14091
14092 void unregister_nmi_handler(unsigned int, const char *);
14093
14094 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14095 index 0f1ddee..e2fc3d1 100644
14096 --- a/arch/x86/include/asm/page_64.h
14097 +++ b/arch/x86/include/asm/page_64.h
14098 @@ -7,9 +7,9 @@
14099
14100 /* duplicated to the one in bootmem.h */
14101 extern unsigned long max_pfn;
14102 -extern unsigned long phys_base;
14103 +extern const unsigned long phys_base;
14104
14105 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14106 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14107 {
14108 unsigned long y = x - __START_KERNEL_map;
14109
14110 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14111 index 7361e47..16dc226 100644
14112 --- a/arch/x86/include/asm/paravirt.h
14113 +++ b/arch/x86/include/asm/paravirt.h
14114 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14115 return (pmd_t) { ret };
14116 }
14117
14118 -static inline pmdval_t pmd_val(pmd_t pmd)
14119 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14120 {
14121 pmdval_t ret;
14122
14123 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14124 val);
14125 }
14126
14127 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14128 +{
14129 + pgdval_t val = native_pgd_val(pgd);
14130 +
14131 + if (sizeof(pgdval_t) > sizeof(long))
14132 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14133 + val, (u64)val >> 32);
14134 + else
14135 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14136 + val);
14137 +}
14138 +
14139 static inline void pgd_clear(pgd_t *pgdp)
14140 {
14141 set_pgd(pgdp, __pgd(0));
14142 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14143 pv_mmu_ops.set_fixmap(idx, phys, flags);
14144 }
14145
14146 +#ifdef CONFIG_PAX_KERNEXEC
14147 +static inline unsigned long pax_open_kernel(void)
14148 +{
14149 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14150 +}
14151 +
14152 +static inline unsigned long pax_close_kernel(void)
14153 +{
14154 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14155 +}
14156 +#else
14157 +static inline unsigned long pax_open_kernel(void) { return 0; }
14158 +static inline unsigned long pax_close_kernel(void) { return 0; }
14159 +#endif
14160 +
14161 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14162
14163 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14164 @@ -930,7 +957,7 @@ extern void default_banner(void);
14165
14166 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14167 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14168 -#define PARA_INDIRECT(addr) *%cs:addr
14169 +#define PARA_INDIRECT(addr) *%ss:addr
14170 #endif
14171
14172 #define INTERRUPT_RETURN \
14173 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
14174 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14175 CLBR_NONE, \
14176 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14177 +
14178 +#define GET_CR0_INTO_RDI \
14179 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14180 + mov %rax,%rdi
14181 +
14182 +#define SET_RDI_INTO_CR0 \
14183 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14184 +
14185 +#define GET_CR3_INTO_RDI \
14186 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14187 + mov %rax,%rdi
14188 +
14189 +#define SET_RDI_INTO_CR3 \
14190 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14191 +
14192 #endif /* CONFIG_X86_32 */
14193
14194 #endif /* __ASSEMBLY__ */
14195 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14196 index b3b0ec1..b1cd3eb 100644
14197 --- a/arch/x86/include/asm/paravirt_types.h
14198 +++ b/arch/x86/include/asm/paravirt_types.h
14199 @@ -84,7 +84,7 @@ struct pv_init_ops {
14200 */
14201 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14202 unsigned long addr, unsigned len);
14203 -};
14204 +} __no_const;
14205
14206
14207 struct pv_lazy_ops {
14208 @@ -98,7 +98,7 @@ struct pv_time_ops {
14209 unsigned long long (*sched_clock)(void);
14210 unsigned long long (*steal_clock)(int cpu);
14211 unsigned long (*get_tsc_khz)(void);
14212 -};
14213 +} __no_const;
14214
14215 struct pv_cpu_ops {
14216 /* hooks for various privileged instructions */
14217 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14218
14219 void (*start_context_switch)(struct task_struct *prev);
14220 void (*end_context_switch)(struct task_struct *next);
14221 -};
14222 +} __no_const;
14223
14224 struct pv_irq_ops {
14225 /*
14226 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14227 unsigned long start_eip,
14228 unsigned long start_esp);
14229 #endif
14230 -};
14231 +} __no_const;
14232
14233 struct pv_mmu_ops {
14234 unsigned long (*read_cr2)(void);
14235 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14236 struct paravirt_callee_save make_pud;
14237
14238 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14239 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14240 #endif /* PAGETABLE_LEVELS == 4 */
14241 #endif /* PAGETABLE_LEVELS >= 3 */
14242
14243 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14244 an mfn. We can tell which is which from the index. */
14245 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14246 phys_addr_t phys, pgprot_t flags);
14247 +
14248 +#ifdef CONFIG_PAX_KERNEXEC
14249 + unsigned long (*pax_open_kernel)(void);
14250 + unsigned long (*pax_close_kernel)(void);
14251 +#endif
14252 +
14253 };
14254
14255 struct arch_spinlock;
14256 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14257 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14258 int (*spin_trylock)(struct arch_spinlock *lock);
14259 void (*spin_unlock)(struct arch_spinlock *lock);
14260 -};
14261 +} __no_const;
14262
14263 /* This contains all the paravirt structures: we get a convenient
14264 * number for each function using the offset which we use to indicate
14265 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14266 index b4389a4..7024269 100644
14267 --- a/arch/x86/include/asm/pgalloc.h
14268 +++ b/arch/x86/include/asm/pgalloc.h
14269 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14270 pmd_t *pmd, pte_t *pte)
14271 {
14272 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14273 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14274 +}
14275 +
14276 +static inline void pmd_populate_user(struct mm_struct *mm,
14277 + pmd_t *pmd, pte_t *pte)
14278 +{
14279 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14280 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14281 }
14282
14283 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14284
14285 #ifdef CONFIG_X86_PAE
14286 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14287 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14288 +{
14289 + pud_populate(mm, pudp, pmd);
14290 +}
14291 #else /* !CONFIG_X86_PAE */
14292 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14293 {
14294 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14295 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14296 }
14297 +
14298 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14299 +{
14300 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14301 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14302 +}
14303 #endif /* CONFIG_X86_PAE */
14304
14305 #if PAGETABLE_LEVELS > 3
14306 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14307 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14308 }
14309
14310 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14311 +{
14312 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14313 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14314 +}
14315 +
14316 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14317 {
14318 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14319 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14320 index f2b489c..4f7e2e5 100644
14321 --- a/arch/x86/include/asm/pgtable-2level.h
14322 +++ b/arch/x86/include/asm/pgtable-2level.h
14323 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14324
14325 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14326 {
14327 + pax_open_kernel();
14328 *pmdp = pmd;
14329 + pax_close_kernel();
14330 }
14331
14332 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14333 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14334 index 4cc9f2b..5fd9226 100644
14335 --- a/arch/x86/include/asm/pgtable-3level.h
14336 +++ b/arch/x86/include/asm/pgtable-3level.h
14337 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14338
14339 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14340 {
14341 + pax_open_kernel();
14342 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14343 + pax_close_kernel();
14344 }
14345
14346 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14347 {
14348 + pax_open_kernel();
14349 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14350 + pax_close_kernel();
14351 }
14352
14353 /*
14354 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14355 index 1e67223..dd6e7ea 100644
14356 --- a/arch/x86/include/asm/pgtable.h
14357 +++ b/arch/x86/include/asm/pgtable.h
14358 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14359
14360 #ifndef __PAGETABLE_PUD_FOLDED
14361 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14362 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14363 #define pgd_clear(pgd) native_pgd_clear(pgd)
14364 #endif
14365
14366 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14367
14368 #define arch_end_context_switch(prev) do {} while(0)
14369
14370 +#define pax_open_kernel() native_pax_open_kernel()
14371 +#define pax_close_kernel() native_pax_close_kernel()
14372 #endif /* CONFIG_PARAVIRT */
14373
14374 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14375 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14376 +
14377 +#ifdef CONFIG_PAX_KERNEXEC
14378 +static inline unsigned long native_pax_open_kernel(void)
14379 +{
14380 + unsigned long cr0;
14381 +
14382 + preempt_disable();
14383 + barrier();
14384 + cr0 = read_cr0() ^ X86_CR0_WP;
14385 + BUG_ON(cr0 & X86_CR0_WP);
14386 + write_cr0(cr0);
14387 + return cr0 ^ X86_CR0_WP;
14388 +}
14389 +
14390 +static inline unsigned long native_pax_close_kernel(void)
14391 +{
14392 + unsigned long cr0;
14393 +
14394 + cr0 = read_cr0() ^ X86_CR0_WP;
14395 + BUG_ON(!(cr0 & X86_CR0_WP));
14396 + write_cr0(cr0);
14397 + barrier();
14398 + preempt_enable_no_resched();
14399 + return cr0 ^ X86_CR0_WP;
14400 +}
14401 +#else
14402 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14403 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14404 +#endif
14405 +
14406 /*
14407 * The following only work if pte_present() is true.
14408 * Undefined behaviour if not..
14409 */
14410 +static inline int pte_user(pte_t pte)
14411 +{
14412 + return pte_val(pte) & _PAGE_USER;
14413 +}
14414 +
14415 static inline int pte_dirty(pte_t pte)
14416 {
14417 return pte_flags(pte) & _PAGE_DIRTY;
14418 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14419 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14420 }
14421
14422 +static inline unsigned long pgd_pfn(pgd_t pgd)
14423 +{
14424 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14425 +}
14426 +
14427 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14428
14429 static inline int pmd_large(pmd_t pte)
14430 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14431 return pte_clear_flags(pte, _PAGE_RW);
14432 }
14433
14434 +static inline pte_t pte_mkread(pte_t pte)
14435 +{
14436 + return __pte(pte_val(pte) | _PAGE_USER);
14437 +}
14438 +
14439 static inline pte_t pte_mkexec(pte_t pte)
14440 {
14441 - return pte_clear_flags(pte, _PAGE_NX);
14442 +#ifdef CONFIG_X86_PAE
14443 + if (__supported_pte_mask & _PAGE_NX)
14444 + return pte_clear_flags(pte, _PAGE_NX);
14445 + else
14446 +#endif
14447 + return pte_set_flags(pte, _PAGE_USER);
14448 +}
14449 +
14450 +static inline pte_t pte_exprotect(pte_t pte)
14451 +{
14452 +#ifdef CONFIG_X86_PAE
14453 + if (__supported_pte_mask & _PAGE_NX)
14454 + return pte_set_flags(pte, _PAGE_NX);
14455 + else
14456 +#endif
14457 + return pte_clear_flags(pte, _PAGE_USER);
14458 }
14459
14460 static inline pte_t pte_mkdirty(pte_t pte)
14461 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14462 #endif
14463
14464 #ifndef __ASSEMBLY__
14465 +
14466 +#ifdef CONFIG_PAX_PER_CPU_PGD
14467 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14468 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14469 +{
14470 + return cpu_pgd[cpu];
14471 +}
14472 +#endif
14473 +
14474 #include <linux/mm_types.h>
14475 #include <linux/log2.h>
14476
14477 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14478 * Currently stuck as a macro due to indirect forward reference to
14479 * linux/mmzone.h's __section_mem_map_addr() definition:
14480 */
14481 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14482 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14483
14484 /* Find an entry in the second-level page table.. */
14485 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14486 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14487 * Currently stuck as a macro due to indirect forward reference to
14488 * linux/mmzone.h's __section_mem_map_addr() definition:
14489 */
14490 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14491 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14492
14493 /* to find an entry in a page-table-directory. */
14494 static inline unsigned long pud_index(unsigned long address)
14495 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14496
14497 static inline int pgd_bad(pgd_t pgd)
14498 {
14499 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14500 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14501 }
14502
14503 static inline int pgd_none(pgd_t pgd)
14504 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14505 * pgd_offset() returns a (pgd_t *)
14506 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14507 */
14508 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14509 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14510 +
14511 +#ifdef CONFIG_PAX_PER_CPU_PGD
14512 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14513 +#endif
14514 +
14515 /*
14516 * a shortcut which implies the use of the kernel's pgd, instead
14517 * of a process's
14518 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14519 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14520 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14521
14522 +#ifdef CONFIG_X86_32
14523 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14524 +#else
14525 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14526 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14527 +
14528 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14529 +#ifdef __ASSEMBLY__
14530 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14531 +#else
14532 +extern unsigned long pax_user_shadow_base;
14533 +#endif
14534 +#endif
14535 +
14536 +#endif
14537 +
14538 #ifndef __ASSEMBLY__
14539
14540 extern int direct_gbpages;
14541 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14542 * dst and src can be on the same page, but the range must not overlap,
14543 * and must not cross a page boundary.
14544 */
14545 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14546 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14547 {
14548 - memcpy(dst, src, count * sizeof(pgd_t));
14549 + pax_open_kernel();
14550 + while (count--)
14551 + *dst++ = *src++;
14552 + pax_close_kernel();
14553 }
14554
14555 +#ifdef CONFIG_PAX_PER_CPU_PGD
14556 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14557 +#endif
14558 +
14559 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14560 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14561 +#else
14562 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14563 +#endif
14564 +
14565 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14566 static inline int page_level_shift(enum pg_level level)
14567 {
14568 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14569 index 9ee3221..b979c6b 100644
14570 --- a/arch/x86/include/asm/pgtable_32.h
14571 +++ b/arch/x86/include/asm/pgtable_32.h
14572 @@ -25,9 +25,6 @@
14573 struct mm_struct;
14574 struct vm_area_struct;
14575
14576 -extern pgd_t swapper_pg_dir[1024];
14577 -extern pgd_t initial_page_table[1024];
14578 -
14579 static inline void pgtable_cache_init(void) { }
14580 static inline void check_pgt_cache(void) { }
14581 void paging_init(void);
14582 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14583 # include <asm/pgtable-2level.h>
14584 #endif
14585
14586 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14587 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14588 +#ifdef CONFIG_X86_PAE
14589 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14590 +#endif
14591 +
14592 #if defined(CONFIG_HIGHPTE)
14593 #define pte_offset_map(dir, address) \
14594 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14595 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14596 /* Clear a kernel PTE and flush it from the TLB */
14597 #define kpte_clear_flush(ptep, vaddr) \
14598 do { \
14599 + pax_open_kernel(); \
14600 pte_clear(&init_mm, (vaddr), (ptep)); \
14601 + pax_close_kernel(); \
14602 __flush_tlb_one((vaddr)); \
14603 } while (0)
14604
14605 #endif /* !__ASSEMBLY__ */
14606
14607 +#define HAVE_ARCH_UNMAPPED_AREA
14608 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14609 +
14610 /*
14611 * kern_addr_valid() is (1) for FLATMEM and (0) for
14612 * SPARSEMEM and DISCONTIGMEM
14613 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14614 index ed5903b..c7fe163 100644
14615 --- a/arch/x86/include/asm/pgtable_32_types.h
14616 +++ b/arch/x86/include/asm/pgtable_32_types.h
14617 @@ -8,7 +8,7 @@
14618 */
14619 #ifdef CONFIG_X86_PAE
14620 # include <asm/pgtable-3level_types.h>
14621 -# define PMD_SIZE (1UL << PMD_SHIFT)
14622 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14623 # define PMD_MASK (~(PMD_SIZE - 1))
14624 #else
14625 # include <asm/pgtable-2level_types.h>
14626 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14627 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14628 #endif
14629
14630 +#ifdef CONFIG_PAX_KERNEXEC
14631 +#ifndef __ASSEMBLY__
14632 +extern unsigned char MODULES_EXEC_VADDR[];
14633 +extern unsigned char MODULES_EXEC_END[];
14634 +#endif
14635 +#include <asm/boot.h>
14636 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14637 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14638 +#else
14639 +#define ktla_ktva(addr) (addr)
14640 +#define ktva_ktla(addr) (addr)
14641 +#endif
14642 +
14643 #define MODULES_VADDR VMALLOC_START
14644 #define MODULES_END VMALLOC_END
14645 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14646 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14647 index e22c1db..23a625a 100644
14648 --- a/arch/x86/include/asm/pgtable_64.h
14649 +++ b/arch/x86/include/asm/pgtable_64.h
14650 @@ -16,10 +16,14 @@
14651
14652 extern pud_t level3_kernel_pgt[512];
14653 extern pud_t level3_ident_pgt[512];
14654 +extern pud_t level3_vmalloc_start_pgt[512];
14655 +extern pud_t level3_vmalloc_end_pgt[512];
14656 +extern pud_t level3_vmemmap_pgt[512];
14657 +extern pud_t level2_vmemmap_pgt[512];
14658 extern pmd_t level2_kernel_pgt[512];
14659 extern pmd_t level2_fixmap_pgt[512];
14660 -extern pmd_t level2_ident_pgt[512];
14661 -extern pgd_t init_level4_pgt[];
14662 +extern pmd_t level2_ident_pgt[512*2];
14663 +extern pgd_t init_level4_pgt[512];
14664
14665 #define swapper_pg_dir init_level4_pgt
14666
14667 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14668
14669 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14670 {
14671 + pax_open_kernel();
14672 *pmdp = pmd;
14673 + pax_close_kernel();
14674 }
14675
14676 static inline void native_pmd_clear(pmd_t *pmd)
14677 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14678
14679 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14680 {
14681 + pax_open_kernel();
14682 *pudp = pud;
14683 + pax_close_kernel();
14684 }
14685
14686 static inline void native_pud_clear(pud_t *pud)
14687 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14688
14689 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14690 {
14691 + pax_open_kernel();
14692 + *pgdp = pgd;
14693 + pax_close_kernel();
14694 +}
14695 +
14696 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14697 +{
14698 *pgdp = pgd;
14699 }
14700
14701 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14702 index 2d88344..4679fc3 100644
14703 --- a/arch/x86/include/asm/pgtable_64_types.h
14704 +++ b/arch/x86/include/asm/pgtable_64_types.h
14705 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14706 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14707 #define MODULES_END _AC(0xffffffffff000000, UL)
14708 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14709 +#define MODULES_EXEC_VADDR MODULES_VADDR
14710 +#define MODULES_EXEC_END MODULES_END
14711 +
14712 +#define ktla_ktva(addr) (addr)
14713 +#define ktva_ktla(addr) (addr)
14714
14715 #define EARLY_DYNAMIC_PAGE_TABLES 64
14716
14717 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14718 index 567b5d0..bd91d64 100644
14719 --- a/arch/x86/include/asm/pgtable_types.h
14720 +++ b/arch/x86/include/asm/pgtable_types.h
14721 @@ -16,13 +16,12 @@
14722 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14723 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14724 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14725 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14726 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14727 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14728 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14729 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14730 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14731 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14732 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14733 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14734 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14735 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14736
14737 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14738 @@ -40,7 +39,6 @@
14739 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14740 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14741 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14742 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14743 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14744 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14745 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14746 @@ -57,8 +55,10 @@
14747
14748 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14749 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14750 -#else
14751 +#elif defined(CONFIG_KMEMCHECK)
14752 #define _PAGE_NX (_AT(pteval_t, 0))
14753 +#else
14754 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14755 #endif
14756
14757 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14758 @@ -116,6 +116,9 @@
14759 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14760 _PAGE_ACCESSED)
14761
14762 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14763 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14764 +
14765 #define __PAGE_KERNEL_EXEC \
14766 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14767 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14768 @@ -126,7 +129,7 @@
14769 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14770 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14771 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14772 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14773 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14774 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14775 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14776 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14777 @@ -188,8 +191,8 @@
14778 * bits are combined, this will alow user to access the high address mapped
14779 * VDSO in the presence of CONFIG_COMPAT_VDSO
14780 */
14781 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14782 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14783 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14784 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14785 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14786 #endif
14787
14788 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14789 {
14790 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14791 }
14792 +#endif
14793
14794 +#if PAGETABLE_LEVELS == 3
14795 +#include <asm-generic/pgtable-nopud.h>
14796 +#endif
14797 +
14798 +#if PAGETABLE_LEVELS == 2
14799 +#include <asm-generic/pgtable-nopmd.h>
14800 +#endif
14801 +
14802 +#ifndef __ASSEMBLY__
14803 #if PAGETABLE_LEVELS > 3
14804 typedef struct { pudval_t pud; } pud_t;
14805
14806 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14807 return pud.pud;
14808 }
14809 #else
14810 -#include <asm-generic/pgtable-nopud.h>
14811 -
14812 static inline pudval_t native_pud_val(pud_t pud)
14813 {
14814 return native_pgd_val(pud.pgd);
14815 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14816 return pmd.pmd;
14817 }
14818 #else
14819 -#include <asm-generic/pgtable-nopmd.h>
14820 -
14821 static inline pmdval_t native_pmd_val(pmd_t pmd)
14822 {
14823 return native_pgd_val(pmd.pud.pgd);
14824 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14825
14826 extern pteval_t __supported_pte_mask;
14827 extern void set_nx(void);
14828 -extern int nx_enabled;
14829
14830 #define pgprot_writecombine pgprot_writecombine
14831 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14832 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14833 index 3270116..8d99d82 100644
14834 --- a/arch/x86/include/asm/processor.h
14835 +++ b/arch/x86/include/asm/processor.h
14836 @@ -285,7 +285,7 @@ struct tss_struct {
14837
14838 } ____cacheline_aligned;
14839
14840 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14841 +extern struct tss_struct init_tss[NR_CPUS];
14842
14843 /*
14844 * Save the original ist values for checking stack pointers during debugging
14845 @@ -826,11 +826,18 @@ static inline void spin_lock_prefetch(const void *x)
14846 */
14847 #define TASK_SIZE PAGE_OFFSET
14848 #define TASK_SIZE_MAX TASK_SIZE
14849 +
14850 +#ifdef CONFIG_PAX_SEGMEXEC
14851 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14852 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14853 +#else
14854 #define STACK_TOP TASK_SIZE
14855 -#define STACK_TOP_MAX STACK_TOP
14856 +#endif
14857 +
14858 +#define STACK_TOP_MAX TASK_SIZE
14859
14860 #define INIT_THREAD { \
14861 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14862 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14863 .vm86_info = NULL, \
14864 .sysenter_cs = __KERNEL_CS, \
14865 .io_bitmap_ptr = NULL, \
14866 @@ -844,7 +851,7 @@ static inline void spin_lock_prefetch(const void *x)
14867 */
14868 #define INIT_TSS { \
14869 .x86_tss = { \
14870 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14871 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14872 .ss0 = __KERNEL_DS, \
14873 .ss1 = __KERNEL_CS, \
14874 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14875 @@ -855,11 +862,7 @@ static inline void spin_lock_prefetch(const void *x)
14876 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14877
14878 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14879 -#define KSTK_TOP(info) \
14880 -({ \
14881 - unsigned long *__ptr = (unsigned long *)(info); \
14882 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14883 -})
14884 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14885
14886 /*
14887 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14888 @@ -874,7 +877,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14889 #define task_pt_regs(task) \
14890 ({ \
14891 struct pt_regs *__regs__; \
14892 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14893 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14894 __regs__ - 1; \
14895 })
14896
14897 @@ -884,13 +887,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14898 /*
14899 * User space process size. 47bits minus one guard page.
14900 */
14901 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14902 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14903
14904 /* This decides where the kernel will search for a free chunk of vm
14905 * space during mmap's.
14906 */
14907 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14908 - 0xc0000000 : 0xFFFFe000)
14909 + 0xc0000000 : 0xFFFFf000)
14910
14911 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14912 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14913 @@ -901,11 +904,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14914 #define STACK_TOP_MAX TASK_SIZE_MAX
14915
14916 #define INIT_THREAD { \
14917 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14918 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14919 }
14920
14921 #define INIT_TSS { \
14922 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14923 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14924 }
14925
14926 /*
14927 @@ -933,6 +936,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14928 */
14929 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14930
14931 +#ifdef CONFIG_PAX_SEGMEXEC
14932 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14933 +#endif
14934 +
14935 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14936
14937 /* Get/set a process' ability to use the timestamp counter instruction */
14938 @@ -993,7 +1000,7 @@ extern bool cpu_has_amd_erratum(const int *);
14939 #define cpu_has_amd_erratum(x) (false)
14940 #endif /* CONFIG_CPU_SUP_AMD */
14941
14942 -extern unsigned long arch_align_stack(unsigned long sp);
14943 +#define arch_align_stack(x) ((x) & ~0xfUL)
14944 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14945
14946 void default_idle(void);
14947 @@ -1003,6 +1010,6 @@ bool xen_set_default_idle(void);
14948 #define xen_set_default_idle 0
14949 #endif
14950
14951 -void stop_this_cpu(void *dummy);
14952 +void stop_this_cpu(void *dummy) __noreturn;
14953
14954 #endif /* _ASM_X86_PROCESSOR_H */
14955 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14956 index 942a086..6c26446 100644
14957 --- a/arch/x86/include/asm/ptrace.h
14958 +++ b/arch/x86/include/asm/ptrace.h
14959 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14960 }
14961
14962 /*
14963 - * user_mode_vm(regs) determines whether a register set came from user mode.
14964 + * user_mode(regs) determines whether a register set came from user mode.
14965 * This is true if V8086 mode was enabled OR if the register set was from
14966 * protected mode with RPL-3 CS value. This tricky test checks that with
14967 * one comparison. Many places in the kernel can bypass this full check
14968 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14969 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14970 + * be used.
14971 */
14972 -static inline int user_mode(struct pt_regs *regs)
14973 +static inline int user_mode_novm(struct pt_regs *regs)
14974 {
14975 #ifdef CONFIG_X86_32
14976 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14977 #else
14978 - return !!(regs->cs & 3);
14979 + return !!(regs->cs & SEGMENT_RPL_MASK);
14980 #endif
14981 }
14982
14983 -static inline int user_mode_vm(struct pt_regs *regs)
14984 +static inline int user_mode(struct pt_regs *regs)
14985 {
14986 #ifdef CONFIG_X86_32
14987 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14988 USER_RPL;
14989 #else
14990 - return user_mode(regs);
14991 + return user_mode_novm(regs);
14992 #endif
14993 }
14994
14995 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14996 #ifdef CONFIG_X86_64
14997 static inline bool user_64bit_mode(struct pt_regs *regs)
14998 {
14999 + unsigned long cs = regs->cs & 0xffff;
15000 #ifndef CONFIG_PARAVIRT
15001 /*
15002 * On non-paravirt systems, this is the only long mode CPL 3
15003 * selector. We do not allow long mode selectors in the LDT.
15004 */
15005 - return regs->cs == __USER_CS;
15006 + return cs == __USER_CS;
15007 #else
15008 /* Headers are too twisted for this to go in paravirt.h. */
15009 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15010 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15011 #endif
15012 }
15013
15014 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15015 * Traps from the kernel do not save sp and ss.
15016 * Use the helper function to retrieve sp.
15017 */
15018 - if (offset == offsetof(struct pt_regs, sp) &&
15019 - regs->cs == __KERNEL_CS)
15020 - return kernel_stack_pointer(regs);
15021 + if (offset == offsetof(struct pt_regs, sp)) {
15022 + unsigned long cs = regs->cs & 0xffff;
15023 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15024 + return kernel_stack_pointer(regs);
15025 + }
15026 #endif
15027 return *(unsigned long *)((unsigned long)regs + offset);
15028 }
15029 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15030 index 9c6b890..5305f53 100644
15031 --- a/arch/x86/include/asm/realmode.h
15032 +++ b/arch/x86/include/asm/realmode.h
15033 @@ -22,16 +22,14 @@ struct real_mode_header {
15034 #endif
15035 /* APM/BIOS reboot */
15036 u32 machine_real_restart_asm;
15037 -#ifdef CONFIG_X86_64
15038 u32 machine_real_restart_seg;
15039 -#endif
15040 };
15041
15042 /* This must match data at trampoline_32/64.S */
15043 struct trampoline_header {
15044 #ifdef CONFIG_X86_32
15045 u32 start;
15046 - u16 gdt_pad;
15047 + u16 boot_cs;
15048 u16 gdt_limit;
15049 u32 gdt_base;
15050 #else
15051 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15052 index a82c4f1..ac45053 100644
15053 --- a/arch/x86/include/asm/reboot.h
15054 +++ b/arch/x86/include/asm/reboot.h
15055 @@ -6,13 +6,13 @@
15056 struct pt_regs;
15057
15058 struct machine_ops {
15059 - void (*restart)(char *cmd);
15060 - void (*halt)(void);
15061 - void (*power_off)(void);
15062 + void (* __noreturn restart)(char *cmd);
15063 + void (* __noreturn halt)(void);
15064 + void (* __noreturn power_off)(void);
15065 void (*shutdown)(void);
15066 void (*crash_shutdown)(struct pt_regs *);
15067 - void (*emergency_restart)(void);
15068 -};
15069 + void (* __noreturn emergency_restart)(void);
15070 +} __no_const;
15071
15072 extern struct machine_ops machine_ops;
15073
15074 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15075 index 2dbe4a7..ce1db00 100644
15076 --- a/arch/x86/include/asm/rwsem.h
15077 +++ b/arch/x86/include/asm/rwsem.h
15078 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15079 {
15080 asm volatile("# beginning down_read\n\t"
15081 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15082 +
15083 +#ifdef CONFIG_PAX_REFCOUNT
15084 + "jno 0f\n"
15085 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15086 + "int $4\n0:\n"
15087 + _ASM_EXTABLE(0b, 0b)
15088 +#endif
15089 +
15090 /* adds 0x00000001 */
15091 " jns 1f\n"
15092 " call call_rwsem_down_read_failed\n"
15093 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15094 "1:\n\t"
15095 " mov %1,%2\n\t"
15096 " add %3,%2\n\t"
15097 +
15098 +#ifdef CONFIG_PAX_REFCOUNT
15099 + "jno 0f\n"
15100 + "sub %3,%2\n"
15101 + "int $4\n0:\n"
15102 + _ASM_EXTABLE(0b, 0b)
15103 +#endif
15104 +
15105 " jle 2f\n\t"
15106 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15107 " jnz 1b\n\t"
15108 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15109 long tmp;
15110 asm volatile("# beginning down_write\n\t"
15111 LOCK_PREFIX " xadd %1,(%2)\n\t"
15112 +
15113 +#ifdef CONFIG_PAX_REFCOUNT
15114 + "jno 0f\n"
15115 + "mov %1,(%2)\n"
15116 + "int $4\n0:\n"
15117 + _ASM_EXTABLE(0b, 0b)
15118 +#endif
15119 +
15120 /* adds 0xffff0001, returns the old value */
15121 " test %1,%1\n\t"
15122 /* was the count 0 before? */
15123 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15124 long tmp;
15125 asm volatile("# beginning __up_read\n\t"
15126 LOCK_PREFIX " xadd %1,(%2)\n\t"
15127 +
15128 +#ifdef CONFIG_PAX_REFCOUNT
15129 + "jno 0f\n"
15130 + "mov %1,(%2)\n"
15131 + "int $4\n0:\n"
15132 + _ASM_EXTABLE(0b, 0b)
15133 +#endif
15134 +
15135 /* subtracts 1, returns the old value */
15136 " jns 1f\n\t"
15137 " call call_rwsem_wake\n" /* expects old value in %edx */
15138 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15139 long tmp;
15140 asm volatile("# beginning __up_write\n\t"
15141 LOCK_PREFIX " xadd %1,(%2)\n\t"
15142 +
15143 +#ifdef CONFIG_PAX_REFCOUNT
15144 + "jno 0f\n"
15145 + "mov %1,(%2)\n"
15146 + "int $4\n0:\n"
15147 + _ASM_EXTABLE(0b, 0b)
15148 +#endif
15149 +
15150 /* subtracts 0xffff0001, returns the old value */
15151 " jns 1f\n\t"
15152 " call call_rwsem_wake\n" /* expects old value in %edx */
15153 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15154 {
15155 asm volatile("# beginning __downgrade_write\n\t"
15156 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15157 +
15158 +#ifdef CONFIG_PAX_REFCOUNT
15159 + "jno 0f\n"
15160 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15161 + "int $4\n0:\n"
15162 + _ASM_EXTABLE(0b, 0b)
15163 +#endif
15164 +
15165 /*
15166 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15167 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15168 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15169 */
15170 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15171 {
15172 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15173 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15174 +
15175 +#ifdef CONFIG_PAX_REFCOUNT
15176 + "jno 0f\n"
15177 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15178 + "int $4\n0:\n"
15179 + _ASM_EXTABLE(0b, 0b)
15180 +#endif
15181 +
15182 : "+m" (sem->count)
15183 : "er" (delta));
15184 }
15185 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15186 */
15187 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15188 {
15189 - return delta + xadd(&sem->count, delta);
15190 + return delta + xadd_check_overflow(&sem->count, delta);
15191 }
15192
15193 #endif /* __KERNEL__ */
15194 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15195 index c48a950..c6d7468 100644
15196 --- a/arch/x86/include/asm/segment.h
15197 +++ b/arch/x86/include/asm/segment.h
15198 @@ -64,10 +64,15 @@
15199 * 26 - ESPFIX small SS
15200 * 27 - per-cpu [ offset to per-cpu data area ]
15201 * 28 - stack_canary-20 [ for stack protector ]
15202 - * 29 - unused
15203 - * 30 - unused
15204 + * 29 - PCI BIOS CS
15205 + * 30 - PCI BIOS DS
15206 * 31 - TSS for double fault handler
15207 */
15208 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15209 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15210 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15211 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15212 +
15213 #define GDT_ENTRY_TLS_MIN 6
15214 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15215
15216 @@ -79,6 +84,8 @@
15217
15218 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15219
15220 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15221 +
15222 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15223
15224 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15225 @@ -104,6 +111,12 @@
15226 #define __KERNEL_STACK_CANARY 0
15227 #endif
15228
15229 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15230 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15231 +
15232 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15233 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15234 +
15235 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15236
15237 /*
15238 @@ -141,7 +154,7 @@
15239 */
15240
15241 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15242 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15243 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15244
15245
15246 #else
15247 @@ -165,6 +178,8 @@
15248 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15249 #define __USER32_DS __USER_DS
15250
15251 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15252 +
15253 #define GDT_ENTRY_TSS 8 /* needs two entries */
15254 #define GDT_ENTRY_LDT 10 /* needs two entries */
15255 #define GDT_ENTRY_TLS_MIN 12
15256 @@ -185,6 +200,7 @@
15257 #endif
15258
15259 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15260 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15261 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15262 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15263 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15264 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15265 {
15266 unsigned long __limit;
15267 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15268 - return __limit + 1;
15269 + return __limit;
15270 }
15271
15272 #endif /* !__ASSEMBLY__ */
15273 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15274 index b073aae..39f9bdd 100644
15275 --- a/arch/x86/include/asm/smp.h
15276 +++ b/arch/x86/include/asm/smp.h
15277 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15278 /* cpus sharing the last level cache: */
15279 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15280 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15281 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15282 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15283
15284 static inline struct cpumask *cpu_sibling_mask(int cpu)
15285 {
15286 @@ -79,7 +79,7 @@ struct smp_ops {
15287
15288 void (*send_call_func_ipi)(const struct cpumask *mask);
15289 void (*send_call_func_single_ipi)(int cpu);
15290 -};
15291 +} __no_const;
15292
15293 /* Globals due to paravirt */
15294 extern void set_cpu_sibling_map(int cpu);
15295 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15296 extern int safe_smp_processor_id(void);
15297
15298 #elif defined(CONFIG_X86_64_SMP)
15299 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15300 -
15301 -#define stack_smp_processor_id() \
15302 -({ \
15303 - struct thread_info *ti; \
15304 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15305 - ti->cpu; \
15306 -})
15307 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15308 +#define stack_smp_processor_id() raw_smp_processor_id()
15309 #define safe_smp_processor_id() smp_processor_id()
15310
15311 #endif
15312 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15313 index 33692ea..350a534 100644
15314 --- a/arch/x86/include/asm/spinlock.h
15315 +++ b/arch/x86/include/asm/spinlock.h
15316 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15317 static inline void arch_read_lock(arch_rwlock_t *rw)
15318 {
15319 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15320 +
15321 +#ifdef CONFIG_PAX_REFCOUNT
15322 + "jno 0f\n"
15323 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15324 + "int $4\n0:\n"
15325 + _ASM_EXTABLE(0b, 0b)
15326 +#endif
15327 +
15328 "jns 1f\n"
15329 "call __read_lock_failed\n\t"
15330 "1:\n"
15331 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15332 static inline void arch_write_lock(arch_rwlock_t *rw)
15333 {
15334 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15335 +
15336 +#ifdef CONFIG_PAX_REFCOUNT
15337 + "jno 0f\n"
15338 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15339 + "int $4\n0:\n"
15340 + _ASM_EXTABLE(0b, 0b)
15341 +#endif
15342 +
15343 "jz 1f\n"
15344 "call __write_lock_failed\n\t"
15345 "1:\n"
15346 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15347
15348 static inline void arch_read_unlock(arch_rwlock_t *rw)
15349 {
15350 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15351 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15352 +
15353 +#ifdef CONFIG_PAX_REFCOUNT
15354 + "jno 0f\n"
15355 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15356 + "int $4\n0:\n"
15357 + _ASM_EXTABLE(0b, 0b)
15358 +#endif
15359 +
15360 :"+m" (rw->lock) : : "memory");
15361 }
15362
15363 static inline void arch_write_unlock(arch_rwlock_t *rw)
15364 {
15365 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15366 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15367 +
15368 +#ifdef CONFIG_PAX_REFCOUNT
15369 + "jno 0f\n"
15370 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15371 + "int $4\n0:\n"
15372 + _ASM_EXTABLE(0b, 0b)
15373 +#endif
15374 +
15375 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15376 }
15377
15378 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15379 index 6a99859..03cb807 100644
15380 --- a/arch/x86/include/asm/stackprotector.h
15381 +++ b/arch/x86/include/asm/stackprotector.h
15382 @@ -47,7 +47,7 @@
15383 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15384 */
15385 #define GDT_STACK_CANARY_INIT \
15386 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15387 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15388
15389 /*
15390 * Initialize the stackprotector canary value.
15391 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15392
15393 static inline void load_stack_canary_segment(void)
15394 {
15395 -#ifdef CONFIG_X86_32
15396 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15397 asm volatile ("mov %0, %%gs" : : "r" (0));
15398 #endif
15399 }
15400 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15401 index 70bbe39..4ae2bd4 100644
15402 --- a/arch/x86/include/asm/stacktrace.h
15403 +++ b/arch/x86/include/asm/stacktrace.h
15404 @@ -11,28 +11,20 @@
15405
15406 extern int kstack_depth_to_print;
15407
15408 -struct thread_info;
15409 +struct task_struct;
15410 struct stacktrace_ops;
15411
15412 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15413 - unsigned long *stack,
15414 - unsigned long bp,
15415 - const struct stacktrace_ops *ops,
15416 - void *data,
15417 - unsigned long *end,
15418 - int *graph);
15419 +typedef unsigned long walk_stack_t(struct task_struct *task,
15420 + void *stack_start,
15421 + unsigned long *stack,
15422 + unsigned long bp,
15423 + const struct stacktrace_ops *ops,
15424 + void *data,
15425 + unsigned long *end,
15426 + int *graph);
15427
15428 -extern unsigned long
15429 -print_context_stack(struct thread_info *tinfo,
15430 - unsigned long *stack, unsigned long bp,
15431 - const struct stacktrace_ops *ops, void *data,
15432 - unsigned long *end, int *graph);
15433 -
15434 -extern unsigned long
15435 -print_context_stack_bp(struct thread_info *tinfo,
15436 - unsigned long *stack, unsigned long bp,
15437 - const struct stacktrace_ops *ops, void *data,
15438 - unsigned long *end, int *graph);
15439 +extern walk_stack_t print_context_stack;
15440 +extern walk_stack_t print_context_stack_bp;
15441
15442 /* Generic stack tracer with callbacks */
15443
15444 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15445 void (*address)(void *data, unsigned long address, int reliable);
15446 /* On negative return stop dumping */
15447 int (*stack)(void *data, char *name);
15448 - walk_stack_t walk_stack;
15449 + walk_stack_t *walk_stack;
15450 };
15451
15452 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15453 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15454 index 4ec45b3..a4f0a8a 100644
15455 --- a/arch/x86/include/asm/switch_to.h
15456 +++ b/arch/x86/include/asm/switch_to.h
15457 @@ -108,7 +108,7 @@ do { \
15458 "call __switch_to\n\t" \
15459 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15460 __switch_canary \
15461 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15462 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15463 "movq %%rax,%%rdi\n\t" \
15464 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15465 "jnz ret_from_fork\n\t" \
15466 @@ -119,7 +119,7 @@ do { \
15467 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15468 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15469 [_tif_fork] "i" (_TIF_FORK), \
15470 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15471 + [thread_info] "m" (current_tinfo), \
15472 [current_task] "m" (current_task) \
15473 __switch_canary_iparam \
15474 : "memory", "cc" __EXTRA_CLOBBER)
15475 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15476 index 2cd056e..0224df8 100644
15477 --- a/arch/x86/include/asm/thread_info.h
15478 +++ b/arch/x86/include/asm/thread_info.h
15479 @@ -10,6 +10,7 @@
15480 #include <linux/compiler.h>
15481 #include <asm/page.h>
15482 #include <asm/types.h>
15483 +#include <asm/percpu.h>
15484
15485 /*
15486 * low level task data that entry.S needs immediate access to
15487 @@ -23,7 +24,6 @@ struct exec_domain;
15488 #include <linux/atomic.h>
15489
15490 struct thread_info {
15491 - struct task_struct *task; /* main task structure */
15492 struct exec_domain *exec_domain; /* execution domain */
15493 __u32 flags; /* low level flags */
15494 __u32 status; /* thread synchronous flags */
15495 @@ -33,19 +33,13 @@ struct thread_info {
15496 mm_segment_t addr_limit;
15497 struct restart_block restart_block;
15498 void __user *sysenter_return;
15499 -#ifdef CONFIG_X86_32
15500 - unsigned long previous_esp; /* ESP of the previous stack in
15501 - case of nested (IRQ) stacks
15502 - */
15503 - __u8 supervisor_stack[0];
15504 -#endif
15505 + unsigned long lowest_stack;
15506 unsigned int sig_on_uaccess_error:1;
15507 unsigned int uaccess_err:1; /* uaccess failed */
15508 };
15509
15510 -#define INIT_THREAD_INFO(tsk) \
15511 +#define INIT_THREAD_INFO \
15512 { \
15513 - .task = &tsk, \
15514 .exec_domain = &default_exec_domain, \
15515 .flags = 0, \
15516 .cpu = 0, \
15517 @@ -56,7 +50,7 @@ struct thread_info {
15518 }, \
15519 }
15520
15521 -#define init_thread_info (init_thread_union.thread_info)
15522 +#define init_thread_info (init_thread_union.stack)
15523 #define init_stack (init_thread_union.stack)
15524
15525 #else /* !__ASSEMBLY__ */
15526 @@ -97,6 +91,7 @@ struct thread_info {
15527 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15528 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15529 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15530 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15531
15532 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15533 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15534 @@ -121,17 +116,18 @@ struct thread_info {
15535 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15536 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15537 #define _TIF_X32 (1 << TIF_X32)
15538 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15539
15540 /* work to do in syscall_trace_enter() */
15541 #define _TIF_WORK_SYSCALL_ENTRY \
15542 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15543 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15544 - _TIF_NOHZ)
15545 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15546
15547 /* work to do in syscall_trace_leave() */
15548 #define _TIF_WORK_SYSCALL_EXIT \
15549 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15550 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15551 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15552
15553 /* work to do on interrupt/exception return */
15554 #define _TIF_WORK_MASK \
15555 @@ -142,7 +138,7 @@ struct thread_info {
15556 /* work to do on any return to user space */
15557 #define _TIF_ALLWORK_MASK \
15558 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15559 - _TIF_NOHZ)
15560 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15561
15562 /* Only used for 64 bit */
15563 #define _TIF_DO_NOTIFY_MASK \
15564 @@ -158,45 +154,40 @@ struct thread_info {
15565
15566 #define PREEMPT_ACTIVE 0x10000000
15567
15568 -#ifdef CONFIG_X86_32
15569 -
15570 -#define STACK_WARN (THREAD_SIZE/8)
15571 -/*
15572 - * macros/functions for gaining access to the thread information structure
15573 - *
15574 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15575 - */
15576 -#ifndef __ASSEMBLY__
15577 -
15578 -
15579 -/* how to get the current stack pointer from C */
15580 -register unsigned long current_stack_pointer asm("esp") __used;
15581 -
15582 -/* how to get the thread information struct from C */
15583 -static inline struct thread_info *current_thread_info(void)
15584 -{
15585 - return (struct thread_info *)
15586 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15587 -}
15588 -
15589 -#else /* !__ASSEMBLY__ */
15590 -
15591 +#ifdef __ASSEMBLY__
15592 /* how to get the thread information struct from ASM */
15593 #define GET_THREAD_INFO(reg) \
15594 - movl $-THREAD_SIZE, reg; \
15595 - andl %esp, reg
15596 + mov PER_CPU_VAR(current_tinfo), reg
15597
15598 /* use this one if reg already contains %esp */
15599 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15600 - andl $-THREAD_SIZE, reg
15601 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15602 +#else
15603 +/* how to get the thread information struct from C */
15604 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15605 +
15606 +static __always_inline struct thread_info *current_thread_info(void)
15607 +{
15608 + return this_cpu_read_stable(current_tinfo);
15609 +}
15610 +#endif
15611 +
15612 +#ifdef CONFIG_X86_32
15613 +
15614 +#define STACK_WARN (THREAD_SIZE/8)
15615 +/*
15616 + * macros/functions for gaining access to the thread information structure
15617 + *
15618 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15619 + */
15620 +#ifndef __ASSEMBLY__
15621 +
15622 +/* how to get the current stack pointer from C */
15623 +register unsigned long current_stack_pointer asm("esp") __used;
15624
15625 #endif
15626
15627 #else /* X86_32 */
15628
15629 -#include <asm/percpu.h>
15630 -#define KERNEL_STACK_OFFSET (5*8)
15631 -
15632 /*
15633 * macros/functions for gaining access to the thread information structure
15634 * preempt_count needs to be 1 initially, until the scheduler is functional.
15635 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15636 #ifndef __ASSEMBLY__
15637 DECLARE_PER_CPU(unsigned long, kernel_stack);
15638
15639 -static inline struct thread_info *current_thread_info(void)
15640 -{
15641 - struct thread_info *ti;
15642 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15643 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15644 - return ti;
15645 -}
15646 -
15647 -#else /* !__ASSEMBLY__ */
15648 -
15649 -/* how to get the thread information struct from ASM */
15650 -#define GET_THREAD_INFO(reg) \
15651 - movq PER_CPU_VAR(kernel_stack),reg ; \
15652 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15653 -
15654 -/*
15655 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15656 - * a certain register (to be used in assembler memory operands).
15657 - */
15658 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15659 -
15660 +/* how to get the current stack pointer from C */
15661 +register unsigned long current_stack_pointer asm("rsp") __used;
15662 #endif
15663
15664 #endif /* !X86_32 */
15665 @@ -285,5 +257,12 @@ static inline bool is_ia32_task(void)
15666 extern void arch_task_cache_init(void);
15667 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15668 extern void arch_release_task_struct(struct task_struct *tsk);
15669 +
15670 +#define __HAVE_THREAD_FUNCTIONS
15671 +#define task_thread_info(task) (&(task)->tinfo)
15672 +#define task_stack_page(task) ((task)->stack)
15673 +#define setup_thread_stack(p, org) do {} while (0)
15674 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15675 +
15676 #endif
15677 #endif /* _ASM_X86_THREAD_INFO_H */
15678 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15679 index 5ee2687..70d5895 100644
15680 --- a/arch/x86/include/asm/uaccess.h
15681 +++ b/arch/x86/include/asm/uaccess.h
15682 @@ -7,6 +7,7 @@
15683 #include <linux/compiler.h>
15684 #include <linux/thread_info.h>
15685 #include <linux/string.h>
15686 +#include <linux/sched.h>
15687 #include <asm/asm.h>
15688 #include <asm/page.h>
15689 #include <asm/smap.h>
15690 @@ -29,7 +30,12 @@
15691
15692 #define get_ds() (KERNEL_DS)
15693 #define get_fs() (current_thread_info()->addr_limit)
15694 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15695 +void __set_fs(mm_segment_t x);
15696 +void set_fs(mm_segment_t x);
15697 +#else
15698 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15699 +#endif
15700
15701 #define segment_eq(a, b) ((a).seg == (b).seg)
15702
15703 @@ -77,8 +83,33 @@
15704 * checks that the pointer is in the user space range - after calling
15705 * this function, memory access functions may still return -EFAULT.
15706 */
15707 -#define access_ok(type, addr, size) \
15708 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15709 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15710 +#define access_ok(type, addr, size) \
15711 +({ \
15712 + long __size = size; \
15713 + unsigned long __addr = (unsigned long)addr; \
15714 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15715 + unsigned long __end_ao = __addr + __size - 1; \
15716 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15717 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15718 + while(__addr_ao <= __end_ao) { \
15719 + char __c_ao; \
15720 + __addr_ao += PAGE_SIZE; \
15721 + if (__size > PAGE_SIZE) \
15722 + cond_resched(); \
15723 + if (__get_user(__c_ao, (char __user *)__addr)) \
15724 + break; \
15725 + if (type != VERIFY_WRITE) { \
15726 + __addr = __addr_ao; \
15727 + continue; \
15728 + } \
15729 + if (__put_user(__c_ao, (char __user *)__addr)) \
15730 + break; \
15731 + __addr = __addr_ao; \
15732 + } \
15733 + } \
15734 + __ret_ao; \
15735 +})
15736
15737 /*
15738 * The exception table consists of pairs of addresses relative to the
15739 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15740 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15741 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15742
15743 -
15744 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15745 +#define __copyuser_seg "gs;"
15746 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15747 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15748 +#else
15749 +#define __copyuser_seg
15750 +#define __COPYUSER_SET_ES
15751 +#define __COPYUSER_RESTORE_ES
15752 +#endif
15753
15754 #ifdef CONFIG_X86_32
15755 #define __put_user_asm_u64(x, addr, err, errret) \
15756 asm volatile(ASM_STAC "\n" \
15757 - "1: movl %%eax,0(%2)\n" \
15758 - "2: movl %%edx,4(%2)\n" \
15759 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15760 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15761 "3: " ASM_CLAC "\n" \
15762 ".section .fixup,\"ax\"\n" \
15763 "4: movl %3,%0\n" \
15764 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15765
15766 #define __put_user_asm_ex_u64(x, addr) \
15767 asm volatile(ASM_STAC "\n" \
15768 - "1: movl %%eax,0(%1)\n" \
15769 - "2: movl %%edx,4(%1)\n" \
15770 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15771 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15772 "3: " ASM_CLAC "\n" \
15773 _ASM_EXTABLE_EX(1b, 2b) \
15774 _ASM_EXTABLE_EX(2b, 3b) \
15775 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15776 __typeof__(*(ptr)) __pu_val; \
15777 __chk_user_ptr(ptr); \
15778 might_fault(); \
15779 - __pu_val = x; \
15780 + __pu_val = (x); \
15781 switch (sizeof(*(ptr))) { \
15782 case 1: \
15783 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15784 @@ -345,7 +384,7 @@ do { \
15785
15786 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15787 asm volatile(ASM_STAC "\n" \
15788 - "1: mov"itype" %2,%"rtype"1\n" \
15789 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15790 "2: " ASM_CLAC "\n" \
15791 ".section .fixup,\"ax\"\n" \
15792 "3: mov %3,%0\n" \
15793 @@ -353,7 +392,7 @@ do { \
15794 " jmp 2b\n" \
15795 ".previous\n" \
15796 _ASM_EXTABLE(1b, 3b) \
15797 - : "=r" (err), ltype(x) \
15798 + : "=r" (err), ltype (x) \
15799 : "m" (__m(addr)), "i" (errret), "0" (err))
15800
15801 #define __get_user_size_ex(x, ptr, size) \
15802 @@ -378,7 +417,7 @@ do { \
15803 } while (0)
15804
15805 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15806 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15807 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15808 "2:\n" \
15809 _ASM_EXTABLE_EX(1b, 2b) \
15810 : ltype(x) : "m" (__m(addr)))
15811 @@ -395,13 +434,24 @@ do { \
15812 int __gu_err; \
15813 unsigned long __gu_val; \
15814 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15815 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15816 + (x) = (__typeof__(*(ptr)))__gu_val; \
15817 __gu_err; \
15818 })
15819
15820 /* FIXME: this hack is definitely wrong -AK */
15821 struct __large_struct { unsigned long buf[100]; };
15822 -#define __m(x) (*(struct __large_struct __user *)(x))
15823 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15824 +#define ____m(x) \
15825 +({ \
15826 + unsigned long ____x = (unsigned long)(x); \
15827 + if (____x < pax_user_shadow_base) \
15828 + ____x += pax_user_shadow_base; \
15829 + (typeof(x))____x; \
15830 +})
15831 +#else
15832 +#define ____m(x) (x)
15833 +#endif
15834 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15835
15836 /*
15837 * Tell gcc we read from memory instead of writing: this is because
15838 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15839 */
15840 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15841 asm volatile(ASM_STAC "\n" \
15842 - "1: mov"itype" %"rtype"1,%2\n" \
15843 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15844 "2: " ASM_CLAC "\n" \
15845 ".section .fixup,\"ax\"\n" \
15846 "3: mov %3,%0\n" \
15847 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15848 ".previous\n" \
15849 _ASM_EXTABLE(1b, 3b) \
15850 : "=r"(err) \
15851 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15852 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15853
15854 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15855 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15856 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15857 "2:\n" \
15858 _ASM_EXTABLE_EX(1b, 2b) \
15859 : : ltype(x), "m" (__m(addr)))
15860 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15861 * On error, the variable @x is set to zero.
15862 */
15863
15864 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15865 +#define __get_user(x, ptr) get_user((x), (ptr))
15866 +#else
15867 #define __get_user(x, ptr) \
15868 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15869 +#endif
15870
15871 /**
15872 * __put_user: - Write a simple value into user space, with less checking.
15873 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15874 * Returns zero on success, or -EFAULT on error.
15875 */
15876
15877 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15878 +#define __put_user(x, ptr) put_user((x), (ptr))
15879 +#else
15880 #define __put_user(x, ptr) \
15881 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15882 +#endif
15883
15884 #define __get_user_unaligned __get_user
15885 #define __put_user_unaligned __put_user
15886 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15887 #define get_user_ex(x, ptr) do { \
15888 unsigned long __gue_val; \
15889 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15890 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15891 + (x) = (__typeof__(*(ptr)))__gue_val; \
15892 } while (0)
15893
15894 #define put_user_try uaccess_try
15895 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15896 extern __must_check long strlen_user(const char __user *str);
15897 extern __must_check long strnlen_user(const char __user *str, long n);
15898
15899 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15900 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15901 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15902 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15903
15904 /*
15905 * movsl can be slow when source and dest are not both 8-byte aligned
15906 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15907 index 7f760a9..04b1c65 100644
15908 --- a/arch/x86/include/asm/uaccess_32.h
15909 +++ b/arch/x86/include/asm/uaccess_32.h
15910 @@ -11,15 +11,15 @@
15911 #include <asm/page.h>
15912
15913 unsigned long __must_check __copy_to_user_ll
15914 - (void __user *to, const void *from, unsigned long n);
15915 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15916 unsigned long __must_check __copy_from_user_ll
15917 - (void *to, const void __user *from, unsigned long n);
15918 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15919 unsigned long __must_check __copy_from_user_ll_nozero
15920 - (void *to, const void __user *from, unsigned long n);
15921 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15922 unsigned long __must_check __copy_from_user_ll_nocache
15923 - (void *to, const void __user *from, unsigned long n);
15924 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15925 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15926 - (void *to, const void __user *from, unsigned long n);
15927 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15928
15929 /**
15930 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15931 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15932 static __always_inline unsigned long __must_check
15933 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15934 {
15935 + if ((long)n < 0)
15936 + return n;
15937 +
15938 + check_object_size(from, n, true);
15939 +
15940 if (__builtin_constant_p(n)) {
15941 unsigned long ret;
15942
15943 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15944 __copy_to_user(void __user *to, const void *from, unsigned long n)
15945 {
15946 might_fault();
15947 +
15948 return __copy_to_user_inatomic(to, from, n);
15949 }
15950
15951 static __always_inline unsigned long
15952 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15953 {
15954 + if ((long)n < 0)
15955 + return n;
15956 +
15957 /* Avoid zeroing the tail if the copy fails..
15958 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15959 * but as the zeroing behaviour is only significant when n is not
15960 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15961 __copy_from_user(void *to, const void __user *from, unsigned long n)
15962 {
15963 might_fault();
15964 +
15965 + if ((long)n < 0)
15966 + return n;
15967 +
15968 + check_object_size(to, n, false);
15969 +
15970 if (__builtin_constant_p(n)) {
15971 unsigned long ret;
15972
15973 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15974 const void __user *from, unsigned long n)
15975 {
15976 might_fault();
15977 +
15978 + if ((long)n < 0)
15979 + return n;
15980 +
15981 if (__builtin_constant_p(n)) {
15982 unsigned long ret;
15983
15984 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15985 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15986 unsigned long n)
15987 {
15988 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15989 + if ((long)n < 0)
15990 + return n;
15991 +
15992 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15993 }
15994
15995 -unsigned long __must_check copy_to_user(void __user *to,
15996 - const void *from, unsigned long n);
15997 -unsigned long __must_check _copy_from_user(void *to,
15998 - const void __user *from,
15999 - unsigned long n);
16000 -
16001 +extern void copy_to_user_overflow(void)
16002 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16003 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16004 +#else
16005 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16006 +#endif
16007 +;
16008
16009 extern void copy_from_user_overflow(void)
16010 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16011 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16012 #endif
16013 ;
16014
16015 -static inline unsigned long __must_check copy_from_user(void *to,
16016 - const void __user *from,
16017 - unsigned long n)
16018 +/**
16019 + * copy_to_user: - Copy a block of data into user space.
16020 + * @to: Destination address, in user space.
16021 + * @from: Source address, in kernel space.
16022 + * @n: Number of bytes to copy.
16023 + *
16024 + * Context: User context only. This function may sleep.
16025 + *
16026 + * Copy data from kernel space to user space.
16027 + *
16028 + * Returns number of bytes that could not be copied.
16029 + * On success, this will be zero.
16030 + */
16031 +static inline unsigned long __must_check
16032 +copy_to_user(void __user *to, const void *from, unsigned long n)
16033 {
16034 - int sz = __compiletime_object_size(to);
16035 + size_t sz = __compiletime_object_size(from);
16036
16037 - if (likely(sz == -1 || sz >= n))
16038 - n = _copy_from_user(to, from, n);
16039 - else
16040 + if (unlikely(sz != (size_t)-1 && sz < n))
16041 + copy_to_user_overflow();
16042 + else if (access_ok(VERIFY_WRITE, to, n))
16043 + n = __copy_to_user(to, from, n);
16044 + return n;
16045 +}
16046 +
16047 +/**
16048 + * copy_from_user: - Copy a block of data from user space.
16049 + * @to: Destination address, in kernel space.
16050 + * @from: Source address, in user space.
16051 + * @n: Number of bytes to copy.
16052 + *
16053 + * Context: User context only. This function may sleep.
16054 + *
16055 + * Copy data from user space to kernel space.
16056 + *
16057 + * Returns number of bytes that could not be copied.
16058 + * On success, this will be zero.
16059 + *
16060 + * If some data could not be copied, this function will pad the copied
16061 + * data to the requested size using zero bytes.
16062 + */
16063 +static inline unsigned long __must_check
16064 +copy_from_user(void *to, const void __user *from, unsigned long n)
16065 +{
16066 + size_t sz = __compiletime_object_size(to);
16067 +
16068 + check_object_size(to, n, false);
16069 +
16070 + if (unlikely(sz != (size_t)-1 && sz < n))
16071 copy_from_user_overflow();
16072 -
16073 + else if (access_ok(VERIFY_READ, from, n))
16074 + n = __copy_from_user(to, from, n);
16075 + else if ((long)n > 0)
16076 + memset(to, 0, n);
16077 return n;
16078 }
16079
16080 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16081 index 142810c..1f2a0a7 100644
16082 --- a/arch/x86/include/asm/uaccess_64.h
16083 +++ b/arch/x86/include/asm/uaccess_64.h
16084 @@ -10,6 +10,9 @@
16085 #include <asm/alternative.h>
16086 #include <asm/cpufeature.h>
16087 #include <asm/page.h>
16088 +#include <asm/pgtable.h>
16089 +
16090 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16091
16092 /*
16093 * Copy To/From Userspace
16094 @@ -17,13 +20,13 @@
16095
16096 /* Handles exceptions in both to and from, but doesn't do access_ok */
16097 __must_check unsigned long
16098 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16099 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16100 __must_check unsigned long
16101 -copy_user_generic_string(void *to, const void *from, unsigned len);
16102 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16103 __must_check unsigned long
16104 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16105 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16106
16107 -static __always_inline __must_check unsigned long
16108 +static __always_inline __must_check __size_overflow(3) unsigned long
16109 copy_user_generic(void *to, const void *from, unsigned len)
16110 {
16111 unsigned ret;
16112 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16113 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16114 "=d" (len)),
16115 "1" (to), "2" (from), "3" (len)
16116 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16117 + : "memory", "rcx", "r8", "r9", "r11");
16118 return ret;
16119 }
16120
16121 +static __always_inline __must_check unsigned long
16122 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16123 +static __always_inline __must_check unsigned long
16124 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16125 __must_check unsigned long
16126 -_copy_to_user(void __user *to, const void *from, unsigned len);
16127 -__must_check unsigned long
16128 -_copy_from_user(void *to, const void __user *from, unsigned len);
16129 -__must_check unsigned long
16130 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16131 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16132 +
16133 +extern void copy_to_user_overflow(void)
16134 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16135 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16136 +#else
16137 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16138 +#endif
16139 +;
16140 +
16141 +extern void copy_from_user_overflow(void)
16142 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16143 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16144 +#else
16145 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16146 +#endif
16147 +;
16148
16149 static inline unsigned long __must_check copy_from_user(void *to,
16150 const void __user *from,
16151 unsigned long n)
16152 {
16153 - int sz = __compiletime_object_size(to);
16154 -
16155 might_fault();
16156 - if (likely(sz == -1 || sz >= n))
16157 - n = _copy_from_user(to, from, n);
16158 -#ifdef CONFIG_DEBUG_VM
16159 - else
16160 - WARN(1, "Buffer overflow detected!\n");
16161 -#endif
16162 +
16163 + check_object_size(to, n, false);
16164 +
16165 + if (access_ok(VERIFY_READ, from, n))
16166 + n = __copy_from_user(to, from, n);
16167 + else if (n < INT_MAX)
16168 + memset(to, 0, n);
16169 return n;
16170 }
16171
16172 static __always_inline __must_check
16173 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16174 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16175 {
16176 might_fault();
16177
16178 - return _copy_to_user(dst, src, size);
16179 + if (access_ok(VERIFY_WRITE, dst, size))
16180 + size = __copy_to_user(dst, src, size);
16181 + return size;
16182 }
16183
16184 static __always_inline __must_check
16185 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16186 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16187 {
16188 - int ret = 0;
16189 + size_t sz = __compiletime_object_size(dst);
16190 + unsigned ret = 0;
16191
16192 might_fault();
16193 +
16194 + if (size > INT_MAX)
16195 + return size;
16196 +
16197 + check_object_size(dst, size, false);
16198 +
16199 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16200 + if (!__access_ok(VERIFY_READ, src, size))
16201 + return size;
16202 +#endif
16203 +
16204 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16205 + copy_from_user_overflow();
16206 + return size;
16207 + }
16208 +
16209 if (!__builtin_constant_p(size))
16210 - return copy_user_generic(dst, (__force void *)src, size);
16211 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16212 switch (size) {
16213 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16214 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16215 ret, "b", "b", "=q", 1);
16216 return ret;
16217 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16218 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16219 ret, "w", "w", "=r", 2);
16220 return ret;
16221 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16222 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16223 ret, "l", "k", "=r", 4);
16224 return ret;
16225 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16226 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16227 ret, "q", "", "=r", 8);
16228 return ret;
16229 case 10:
16230 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16231 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16232 ret, "q", "", "=r", 10);
16233 if (unlikely(ret))
16234 return ret;
16235 __get_user_asm(*(u16 *)(8 + (char *)dst),
16236 - (u16 __user *)(8 + (char __user *)src),
16237 + (const u16 __user *)(8 + (const char __user *)src),
16238 ret, "w", "w", "=r", 2);
16239 return ret;
16240 case 16:
16241 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16242 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16243 ret, "q", "", "=r", 16);
16244 if (unlikely(ret))
16245 return ret;
16246 __get_user_asm(*(u64 *)(8 + (char *)dst),
16247 - (u64 __user *)(8 + (char __user *)src),
16248 + (const u64 __user *)(8 + (const char __user *)src),
16249 ret, "q", "", "=r", 8);
16250 return ret;
16251 default:
16252 - return copy_user_generic(dst, (__force void *)src, size);
16253 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16254 }
16255 }
16256
16257 static __always_inline __must_check
16258 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16259 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16260 {
16261 - int ret = 0;
16262 + size_t sz = __compiletime_object_size(src);
16263 + unsigned ret = 0;
16264
16265 might_fault();
16266 +
16267 + if (size > INT_MAX)
16268 + return size;
16269 +
16270 + check_object_size(src, size, true);
16271 +
16272 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16273 + if (!__access_ok(VERIFY_WRITE, dst, size))
16274 + return size;
16275 +#endif
16276 +
16277 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16278 + copy_to_user_overflow();
16279 + return size;
16280 + }
16281 +
16282 if (!__builtin_constant_p(size))
16283 - return copy_user_generic((__force void *)dst, src, size);
16284 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16285 switch (size) {
16286 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16287 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16288 ret, "b", "b", "iq", 1);
16289 return ret;
16290 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16291 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16292 ret, "w", "w", "ir", 2);
16293 return ret;
16294 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16295 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16296 ret, "l", "k", "ir", 4);
16297 return ret;
16298 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16299 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16300 ret, "q", "", "er", 8);
16301 return ret;
16302 case 10:
16303 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16304 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16305 ret, "q", "", "er", 10);
16306 if (unlikely(ret))
16307 return ret;
16308 asm("":::"memory");
16309 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16310 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16311 ret, "w", "w", "ir", 2);
16312 return ret;
16313 case 16:
16314 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16315 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16316 ret, "q", "", "er", 16);
16317 if (unlikely(ret))
16318 return ret;
16319 asm("":::"memory");
16320 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16321 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16322 ret, "q", "", "er", 8);
16323 return ret;
16324 default:
16325 - return copy_user_generic((__force void *)dst, src, size);
16326 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16327 }
16328 }
16329
16330 static __always_inline __must_check
16331 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16332 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16333 {
16334 - int ret = 0;
16335 + unsigned ret = 0;
16336
16337 might_fault();
16338 +
16339 + if (size > INT_MAX)
16340 + return size;
16341 +
16342 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16343 + if (!__access_ok(VERIFY_READ, src, size))
16344 + return size;
16345 + if (!__access_ok(VERIFY_WRITE, dst, size))
16346 + return size;
16347 +#endif
16348 +
16349 if (!__builtin_constant_p(size))
16350 - return copy_user_generic((__force void *)dst,
16351 - (__force void *)src, size);
16352 + return copy_user_generic((__force_kernel void *)____m(dst),
16353 + (__force_kernel const void *)____m(src), size);
16354 switch (size) {
16355 case 1: {
16356 u8 tmp;
16357 - __get_user_asm(tmp, (u8 __user *)src,
16358 + __get_user_asm(tmp, (const u8 __user *)src,
16359 ret, "b", "b", "=q", 1);
16360 if (likely(!ret))
16361 __put_user_asm(tmp, (u8 __user *)dst,
16362 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16363 }
16364 case 2: {
16365 u16 tmp;
16366 - __get_user_asm(tmp, (u16 __user *)src,
16367 + __get_user_asm(tmp, (const u16 __user *)src,
16368 ret, "w", "w", "=r", 2);
16369 if (likely(!ret))
16370 __put_user_asm(tmp, (u16 __user *)dst,
16371 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16372
16373 case 4: {
16374 u32 tmp;
16375 - __get_user_asm(tmp, (u32 __user *)src,
16376 + __get_user_asm(tmp, (const u32 __user *)src,
16377 ret, "l", "k", "=r", 4);
16378 if (likely(!ret))
16379 __put_user_asm(tmp, (u32 __user *)dst,
16380 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16381 }
16382 case 8: {
16383 u64 tmp;
16384 - __get_user_asm(tmp, (u64 __user *)src,
16385 + __get_user_asm(tmp, (const u64 __user *)src,
16386 ret, "q", "", "=r", 8);
16387 if (likely(!ret))
16388 __put_user_asm(tmp, (u64 __user *)dst,
16389 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16390 return ret;
16391 }
16392 default:
16393 - return copy_user_generic((__force void *)dst,
16394 - (__force void *)src, size);
16395 + return copy_user_generic((__force_kernel void *)____m(dst),
16396 + (__force_kernel const void *)____m(src), size);
16397 }
16398 }
16399
16400 static __must_check __always_inline int
16401 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16402 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16403 {
16404 - return copy_user_generic(dst, (__force const void *)src, size);
16405 + if (size > INT_MAX)
16406 + return size;
16407 +
16408 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16409 + if (!__access_ok(VERIFY_READ, src, size))
16410 + return size;
16411 +#endif
16412 +
16413 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16414 }
16415
16416 -static __must_check __always_inline int
16417 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16418 +static __must_check __always_inline unsigned long
16419 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16420 {
16421 - return copy_user_generic((__force void *)dst, src, size);
16422 + if (size > INT_MAX)
16423 + return size;
16424 +
16425 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16426 + if (!__access_ok(VERIFY_WRITE, dst, size))
16427 + return size;
16428 +#endif
16429 +
16430 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16431 }
16432
16433 -extern long __copy_user_nocache(void *dst, const void __user *src,
16434 - unsigned size, int zerorest);
16435 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16436 + unsigned long size, int zerorest) __size_overflow(3);
16437
16438 -static inline int
16439 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16440 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16441 {
16442 might_sleep();
16443 +
16444 + if (size > INT_MAX)
16445 + return size;
16446 +
16447 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16448 + if (!__access_ok(VERIFY_READ, src, size))
16449 + return size;
16450 +#endif
16451 +
16452 return __copy_user_nocache(dst, src, size, 1);
16453 }
16454
16455 -static inline int
16456 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16457 - unsigned size)
16458 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16459 + unsigned long size)
16460 {
16461 + if (size > INT_MAX)
16462 + return size;
16463 +
16464 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16465 + if (!__access_ok(VERIFY_READ, src, size))
16466 + return size;
16467 +#endif
16468 +
16469 return __copy_user_nocache(dst, src, size, 0);
16470 }
16471
16472 -unsigned long
16473 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16474 +extern unsigned long
16475 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16476
16477 #endif /* _ASM_X86_UACCESS_64_H */
16478 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16479 index 5b238981..77fdd78 100644
16480 --- a/arch/x86/include/asm/word-at-a-time.h
16481 +++ b/arch/x86/include/asm/word-at-a-time.h
16482 @@ -11,7 +11,7 @@
16483 * and shift, for example.
16484 */
16485 struct word_at_a_time {
16486 - const unsigned long one_bits, high_bits;
16487 + unsigned long one_bits, high_bits;
16488 };
16489
16490 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16491 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16492 index d8d9922..bf6cecb 100644
16493 --- a/arch/x86/include/asm/x86_init.h
16494 +++ b/arch/x86/include/asm/x86_init.h
16495 @@ -129,7 +129,7 @@ struct x86_init_ops {
16496 struct x86_init_timers timers;
16497 struct x86_init_iommu iommu;
16498 struct x86_init_pci pci;
16499 -};
16500 +} __no_const;
16501
16502 /**
16503 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16504 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16505 void (*setup_percpu_clockev)(void);
16506 void (*early_percpu_clock_init)(void);
16507 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16508 -};
16509 +} __no_const;
16510
16511 /**
16512 * struct x86_platform_ops - platform specific runtime functions
16513 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16514 void (*save_sched_clock_state)(void);
16515 void (*restore_sched_clock_state)(void);
16516 void (*apic_post_init)(void);
16517 -};
16518 +} __no_const;
16519
16520 struct pci_dev;
16521 struct msi_msg;
16522 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16523 void (*teardown_msi_irqs)(struct pci_dev *dev);
16524 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16525 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16526 -};
16527 +} __no_const;
16528
16529 struct IO_APIC_route_entry;
16530 struct io_apic_irq_attr;
16531 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16532 unsigned int destination, int vector,
16533 struct io_apic_irq_attr *attr);
16534 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16535 -};
16536 +} __no_const;
16537
16538 extern struct x86_init_ops x86_init;
16539 extern struct x86_cpuinit_ops x86_cpuinit;
16540 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16541 index 0415cda..b43d877 100644
16542 --- a/arch/x86/include/asm/xsave.h
16543 +++ b/arch/x86/include/asm/xsave.h
16544 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16545 return -EFAULT;
16546
16547 __asm__ __volatile__(ASM_STAC "\n"
16548 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16549 + "1:"
16550 + __copyuser_seg
16551 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16552 "2: " ASM_CLAC "\n"
16553 ".section .fixup,\"ax\"\n"
16554 "3: movl $-1,%[err]\n"
16555 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16556 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16557 {
16558 int err;
16559 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16560 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16561 u32 lmask = mask;
16562 u32 hmask = mask >> 32;
16563
16564 __asm__ __volatile__(ASM_STAC "\n"
16565 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16566 + "1:"
16567 + __copyuser_seg
16568 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16569 "2: " ASM_CLAC "\n"
16570 ".section .fixup,\"ax\"\n"
16571 "3: movl $-1,%[err]\n"
16572 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16573 index bbae024..e1528f9 100644
16574 --- a/arch/x86/include/uapi/asm/e820.h
16575 +++ b/arch/x86/include/uapi/asm/e820.h
16576 @@ -63,7 +63,7 @@ struct e820map {
16577 #define ISA_START_ADDRESS 0xa0000
16578 #define ISA_END_ADDRESS 0x100000
16579
16580 -#define BIOS_BEGIN 0x000a0000
16581 +#define BIOS_BEGIN 0x000c0000
16582 #define BIOS_END 0x00100000
16583
16584 #define BIOS_ROM_BASE 0xffe00000
16585 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16586 index 7bd3bd3..5dac791 100644
16587 --- a/arch/x86/kernel/Makefile
16588 +++ b/arch/x86/kernel/Makefile
16589 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16590 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16591 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16592 obj-y += probe_roms.o
16593 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16594 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16595 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16596 obj-y += syscall_$(BITS).o
16597 obj-$(CONFIG_X86_64) += vsyscall_64.o
16598 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16599 index 230c8ea..f915130 100644
16600 --- a/arch/x86/kernel/acpi/boot.c
16601 +++ b/arch/x86/kernel/acpi/boot.c
16602 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16603 * If your system is blacklisted here, but you find that acpi=force
16604 * works for you, please contact linux-acpi@vger.kernel.org
16605 */
16606 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16607 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16608 /*
16609 * Boxes that need ACPI disabled
16610 */
16611 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16612 };
16613
16614 /* second table for DMI checks that should run after early-quirks */
16615 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16616 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16617 /*
16618 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16619 * which includes some code which overrides all temperature
16620 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16621 index 0532f5d..36afc0a 100644
16622 --- a/arch/x86/kernel/acpi/sleep.c
16623 +++ b/arch/x86/kernel/acpi/sleep.c
16624 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16625 #else /* CONFIG_64BIT */
16626 #ifdef CONFIG_SMP
16627 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16628 +
16629 + pax_open_kernel();
16630 early_gdt_descr.address =
16631 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16632 + pax_close_kernel();
16633 +
16634 initial_gs = per_cpu_offset(smp_processor_id());
16635 #endif
16636 initial_code = (unsigned long)wakeup_long64;
16637 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16638 index 13ab720..95d5442 100644
16639 --- a/arch/x86/kernel/acpi/wakeup_32.S
16640 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16641 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16642 # and restore the stack ... but you need gdt for this to work
16643 movl saved_context_esp, %esp
16644
16645 - movl %cs:saved_magic, %eax
16646 - cmpl $0x12345678, %eax
16647 + cmpl $0x12345678, saved_magic
16648 jne bogus_magic
16649
16650 # jump to place where we left off
16651 - movl saved_eip, %eax
16652 - jmp *%eax
16653 + jmp *(saved_eip)
16654
16655 bogus_magic:
16656 jmp bogus_magic
16657 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16658 index ef5ccca..bd83949 100644
16659 --- a/arch/x86/kernel/alternative.c
16660 +++ b/arch/x86/kernel/alternative.c
16661 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16662 */
16663 for (a = start; a < end; a++) {
16664 instr = (u8 *)&a->instr_offset + a->instr_offset;
16665 +
16666 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16667 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16668 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16669 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16670 +#endif
16671 +
16672 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16673 BUG_ON(a->replacementlen > a->instrlen);
16674 BUG_ON(a->instrlen > sizeof(insnbuf));
16675 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16676 for (poff = start; poff < end; poff++) {
16677 u8 *ptr = (u8 *)poff + *poff;
16678
16679 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16680 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16681 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16682 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16683 +#endif
16684 +
16685 if (!*poff || ptr < text || ptr >= text_end)
16686 continue;
16687 /* turn DS segment override prefix into lock prefix */
16688 - if (*ptr == 0x3e)
16689 + if (*ktla_ktva(ptr) == 0x3e)
16690 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16691 }
16692 mutex_unlock(&text_mutex);
16693 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16694 for (poff = start; poff < end; poff++) {
16695 u8 *ptr = (u8 *)poff + *poff;
16696
16697 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16698 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16699 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16700 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16701 +#endif
16702 +
16703 if (!*poff || ptr < text || ptr >= text_end)
16704 continue;
16705 /* turn lock prefix into DS segment override prefix */
16706 - if (*ptr == 0xf0)
16707 + if (*ktla_ktva(ptr) == 0xf0)
16708 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16709 }
16710 mutex_unlock(&text_mutex);
16711 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16712
16713 BUG_ON(p->len > MAX_PATCH_LEN);
16714 /* prep the buffer with the original instructions */
16715 - memcpy(insnbuf, p->instr, p->len);
16716 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16717 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16718 (unsigned long)p->instr, p->len);
16719
16720 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16721 if (!uniproc_patched || num_possible_cpus() == 1)
16722 free_init_pages("SMP alternatives",
16723 (unsigned long)__smp_locks,
16724 - (unsigned long)__smp_locks_end);
16725 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16726 #endif
16727
16728 apply_paravirt(__parainstructions, __parainstructions_end);
16729 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16730 * instructions. And on the local CPU you need to be protected again NMI or MCE
16731 * handlers seeing an inconsistent instruction while you patch.
16732 */
16733 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16734 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16735 size_t len)
16736 {
16737 unsigned long flags;
16738 local_irq_save(flags);
16739 - memcpy(addr, opcode, len);
16740 +
16741 + pax_open_kernel();
16742 + memcpy(ktla_ktva(addr), opcode, len);
16743 sync_core();
16744 + pax_close_kernel();
16745 +
16746 local_irq_restore(flags);
16747 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16748 that causes hangs on some VIA CPUs. */
16749 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16750 */
16751 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16752 {
16753 - unsigned long flags;
16754 - char *vaddr;
16755 + unsigned char *vaddr = ktla_ktva(addr);
16756 struct page *pages[2];
16757 - int i;
16758 + size_t i;
16759
16760 if (!core_kernel_text((unsigned long)addr)) {
16761 - pages[0] = vmalloc_to_page(addr);
16762 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16763 + pages[0] = vmalloc_to_page(vaddr);
16764 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16765 } else {
16766 - pages[0] = virt_to_page(addr);
16767 + pages[0] = virt_to_page(vaddr);
16768 WARN_ON(!PageReserved(pages[0]));
16769 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16770 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16771 }
16772 BUG_ON(!pages[0]);
16773 - local_irq_save(flags);
16774 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16775 - if (pages[1])
16776 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16777 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16778 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16779 - clear_fixmap(FIX_TEXT_POKE0);
16780 - if (pages[1])
16781 - clear_fixmap(FIX_TEXT_POKE1);
16782 - local_flush_tlb();
16783 - sync_core();
16784 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16785 - that causes hangs on some VIA CPUs. */
16786 + text_poke_early(addr, opcode, len);
16787 for (i = 0; i < len; i++)
16788 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16789 - local_irq_restore(flags);
16790 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16791 return addr;
16792 }
16793
16794 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16795 index 904611b..004dde6 100644
16796 --- a/arch/x86/kernel/apic/apic.c
16797 +++ b/arch/x86/kernel/apic/apic.c
16798 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16799 /*
16800 * Debug level, exported for io_apic.c
16801 */
16802 -unsigned int apic_verbosity;
16803 +int apic_verbosity;
16804
16805 int pic_mode;
16806
16807 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16808 apic_write(APIC_ESR, 0);
16809 v1 = apic_read(APIC_ESR);
16810 ack_APIC_irq();
16811 - atomic_inc(&irq_err_count);
16812 + atomic_inc_unchecked(&irq_err_count);
16813
16814 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16815 smp_processor_id(), v0 , v1);
16816 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16817 index 00c77cf..2dc6a2d 100644
16818 --- a/arch/x86/kernel/apic/apic_flat_64.c
16819 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16820 @@ -157,7 +157,7 @@ static int flat_probe(void)
16821 return 1;
16822 }
16823
16824 -static struct apic apic_flat = {
16825 +static struct apic apic_flat __read_only = {
16826 .name = "flat",
16827 .probe = flat_probe,
16828 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16829 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16830 return 0;
16831 }
16832
16833 -static struct apic apic_physflat = {
16834 +static struct apic apic_physflat __read_only = {
16835
16836 .name = "physical flat",
16837 .probe = physflat_probe,
16838 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16839 index e145f28..2752888 100644
16840 --- a/arch/x86/kernel/apic/apic_noop.c
16841 +++ b/arch/x86/kernel/apic/apic_noop.c
16842 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16843 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16844 }
16845
16846 -struct apic apic_noop = {
16847 +struct apic apic_noop __read_only = {
16848 .name = "noop",
16849 .probe = noop_probe,
16850 .acpi_madt_oem_check = NULL,
16851 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16852 index d50e364..543bee3 100644
16853 --- a/arch/x86/kernel/apic/bigsmp_32.c
16854 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16855 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16856 return dmi_bigsmp;
16857 }
16858
16859 -static struct apic apic_bigsmp = {
16860 +static struct apic apic_bigsmp __read_only = {
16861
16862 .name = "bigsmp",
16863 .probe = probe_bigsmp,
16864 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16865 index 0874799..a7a7892 100644
16866 --- a/arch/x86/kernel/apic/es7000_32.c
16867 +++ b/arch/x86/kernel/apic/es7000_32.c
16868 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16869 return ret && es7000_apic_is_cluster();
16870 }
16871
16872 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16873 -static struct apic __refdata apic_es7000_cluster = {
16874 +static struct apic apic_es7000_cluster __read_only = {
16875
16876 .name = "es7000",
16877 .probe = probe_es7000,
16878 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16879 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16880 };
16881
16882 -static struct apic __refdata apic_es7000 = {
16883 +static struct apic apic_es7000 __read_only = {
16884
16885 .name = "es7000",
16886 .probe = probe_es7000,
16887 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16888 index 9ed796c..e930fe4 100644
16889 --- a/arch/x86/kernel/apic/io_apic.c
16890 +++ b/arch/x86/kernel/apic/io_apic.c
16891 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16892 }
16893 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16894
16895 -void lock_vector_lock(void)
16896 +void lock_vector_lock(void) __acquires(vector_lock)
16897 {
16898 /* Used to the online set of cpus does not change
16899 * during assign_irq_vector.
16900 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16901 raw_spin_lock(&vector_lock);
16902 }
16903
16904 -void unlock_vector_lock(void)
16905 +void unlock_vector_lock(void) __releases(vector_lock)
16906 {
16907 raw_spin_unlock(&vector_lock);
16908 }
16909 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16910 ack_APIC_irq();
16911 }
16912
16913 -atomic_t irq_mis_count;
16914 +atomic_unchecked_t irq_mis_count;
16915
16916 #ifdef CONFIG_GENERIC_PENDING_IRQ
16917 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16918 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16919 * at the cpu.
16920 */
16921 if (!(v & (1 << (i & 0x1f)))) {
16922 - atomic_inc(&irq_mis_count);
16923 + atomic_inc_unchecked(&irq_mis_count);
16924
16925 eoi_ioapic_irq(irq, cfg);
16926 }
16927 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16928 index d661ee9..791fd33 100644
16929 --- a/arch/x86/kernel/apic/numaq_32.c
16930 +++ b/arch/x86/kernel/apic/numaq_32.c
16931 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16932 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16933 }
16934
16935 -/* Use __refdata to keep false positive warning calm. */
16936 -static struct apic __refdata apic_numaq = {
16937 +static struct apic apic_numaq __read_only = {
16938
16939 .name = "NUMAQ",
16940 .probe = probe_numaq,
16941 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16942 index eb35ef9..f184a21 100644
16943 --- a/arch/x86/kernel/apic/probe_32.c
16944 +++ b/arch/x86/kernel/apic/probe_32.c
16945 @@ -72,7 +72,7 @@ static int probe_default(void)
16946 return 1;
16947 }
16948
16949 -static struct apic apic_default = {
16950 +static struct apic apic_default __read_only = {
16951
16952 .name = "default",
16953 .probe = probe_default,
16954 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16955 index 77c95c0..434f8a4 100644
16956 --- a/arch/x86/kernel/apic/summit_32.c
16957 +++ b/arch/x86/kernel/apic/summit_32.c
16958 @@ -486,7 +486,7 @@ void setup_summit(void)
16959 }
16960 #endif
16961
16962 -static struct apic apic_summit = {
16963 +static struct apic apic_summit __read_only = {
16964
16965 .name = "summit",
16966 .probe = probe_summit,
16967 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16968 index c88baa4..757aee1 100644
16969 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16970 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16971 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16972 return notifier_from_errno(err);
16973 }
16974
16975 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16976 +static struct notifier_block x2apic_cpu_notifier = {
16977 .notifier_call = update_clusterinfo,
16978 };
16979
16980 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16981 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16982 }
16983
16984 -static struct apic apic_x2apic_cluster = {
16985 +static struct apic apic_x2apic_cluster __read_only = {
16986
16987 .name = "cluster x2apic",
16988 .probe = x2apic_cluster_probe,
16989 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16990 index 562a76d..a003c0f 100644
16991 --- a/arch/x86/kernel/apic/x2apic_phys.c
16992 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16993 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16994 return apic == &apic_x2apic_phys;
16995 }
16996
16997 -static struct apic apic_x2apic_phys = {
16998 +static struct apic apic_x2apic_phys __read_only = {
16999
17000 .name = "physical x2apic",
17001 .probe = x2apic_phys_probe,
17002 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17003 index 794f6eb..67e1db2 100644
17004 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17005 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17006 @@ -342,7 +342,7 @@ static int uv_probe(void)
17007 return apic == &apic_x2apic_uv_x;
17008 }
17009
17010 -static struct apic __refdata apic_x2apic_uv_x = {
17011 +static struct apic apic_x2apic_uv_x __read_only = {
17012
17013 .name = "UV large system",
17014 .probe = uv_probe,
17015 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17016 index 66b5faf..3442423 100644
17017 --- a/arch/x86/kernel/apm_32.c
17018 +++ b/arch/x86/kernel/apm_32.c
17019 @@ -434,7 +434,7 @@ static DEFINE_MUTEX(apm_mutex);
17020 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17021 * even though they are called in protected mode.
17022 */
17023 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17024 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17025 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17026
17027 static const char driver_version[] = "1.16ac"; /* no spaces */
17028 @@ -612,7 +612,10 @@ static long __apm_bios_call(void *_call)
17029 BUG_ON(cpu != 0);
17030 gdt = get_cpu_gdt_table(cpu);
17031 save_desc_40 = gdt[0x40 / 8];
17032 +
17033 + pax_open_kernel();
17034 gdt[0x40 / 8] = bad_bios_desc;
17035 + pax_close_kernel();
17036
17037 apm_irq_save(flags);
17038 APM_DO_SAVE_SEGS;
17039 @@ -621,7 +624,11 @@ static long __apm_bios_call(void *_call)
17040 &call->esi);
17041 APM_DO_RESTORE_SEGS;
17042 apm_irq_restore(flags);
17043 +
17044 + pax_open_kernel();
17045 gdt[0x40 / 8] = save_desc_40;
17046 + pax_close_kernel();
17047 +
17048 put_cpu();
17049
17050 return call->eax & 0xff;
17051 @@ -688,7 +695,10 @@ static long __apm_bios_call_simple(void *_call)
17052 BUG_ON(cpu != 0);
17053 gdt = get_cpu_gdt_table(cpu);
17054 save_desc_40 = gdt[0x40 / 8];
17055 +
17056 + pax_open_kernel();
17057 gdt[0x40 / 8] = bad_bios_desc;
17058 + pax_close_kernel();
17059
17060 apm_irq_save(flags);
17061 APM_DO_SAVE_SEGS;
17062 @@ -696,7 +706,11 @@ static long __apm_bios_call_simple(void *_call)
17063 &call->eax);
17064 APM_DO_RESTORE_SEGS;
17065 apm_irq_restore(flags);
17066 +
17067 + pax_open_kernel();
17068 gdt[0x40 / 8] = save_desc_40;
17069 + pax_close_kernel();
17070 +
17071 put_cpu();
17072 return error;
17073 }
17074 @@ -2363,12 +2377,15 @@ static int __init apm_init(void)
17075 * code to that CPU.
17076 */
17077 gdt = get_cpu_gdt_table(0);
17078 +
17079 + pax_open_kernel();
17080 set_desc_base(&gdt[APM_CS >> 3],
17081 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17082 set_desc_base(&gdt[APM_CS_16 >> 3],
17083 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17084 set_desc_base(&gdt[APM_DS >> 3],
17085 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17086 + pax_close_kernel();
17087
17088 proc_create("apm", 0, NULL, &apm_file_ops);
17089
17090 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17091 index 2861082..6d4718e 100644
17092 --- a/arch/x86/kernel/asm-offsets.c
17093 +++ b/arch/x86/kernel/asm-offsets.c
17094 @@ -33,6 +33,8 @@ void common(void) {
17095 OFFSET(TI_status, thread_info, status);
17096 OFFSET(TI_addr_limit, thread_info, addr_limit);
17097 OFFSET(TI_preempt_count, thread_info, preempt_count);
17098 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17099 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17100
17101 BLANK();
17102 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17103 @@ -53,8 +55,26 @@ void common(void) {
17104 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17105 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17106 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17107 +
17108 +#ifdef CONFIG_PAX_KERNEXEC
17109 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17110 #endif
17111
17112 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17113 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17114 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17115 +#ifdef CONFIG_X86_64
17116 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17117 +#endif
17118 +#endif
17119 +
17120 +#endif
17121 +
17122 + BLANK();
17123 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17124 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17125 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17126 +
17127 #ifdef CONFIG_XEN
17128 BLANK();
17129 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17130 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17131 index 1b4754f..fbb4227 100644
17132 --- a/arch/x86/kernel/asm-offsets_64.c
17133 +++ b/arch/x86/kernel/asm-offsets_64.c
17134 @@ -76,6 +76,7 @@ int main(void)
17135 BLANK();
17136 #undef ENTRY
17137
17138 + DEFINE(TSS_size, sizeof(struct tss_struct));
17139 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17140 BLANK();
17141
17142 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17143 index a0e067d..9c7db16 100644
17144 --- a/arch/x86/kernel/cpu/Makefile
17145 +++ b/arch/x86/kernel/cpu/Makefile
17146 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17147 CFLAGS_REMOVE_perf_event.o = -pg
17148 endif
17149
17150 -# Make sure load_percpu_segment has no stackprotector
17151 -nostackp := $(call cc-option, -fno-stack-protector)
17152 -CFLAGS_common.o := $(nostackp)
17153 -
17154 obj-y := intel_cacheinfo.o scattered.o topology.o
17155 obj-y += proc.o capflags.o powerflags.o common.o
17156 obj-y += vmware.o hypervisor.o mshyperv.o
17157 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17158 index fa96eb0..03efe73 100644
17159 --- a/arch/x86/kernel/cpu/amd.c
17160 +++ b/arch/x86/kernel/cpu/amd.c
17161 @@ -737,7 +737,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17162 unsigned int size)
17163 {
17164 /* AMD errata T13 (order #21922) */
17165 - if ((c->x86 == 6)) {
17166 + if (c->x86 == 6) {
17167 /* Duron Rev A0 */
17168 if (c->x86_model == 3 && c->x86_mask == 0)
17169 size = 64;
17170 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17171 index d814772..c615653 100644
17172 --- a/arch/x86/kernel/cpu/common.c
17173 +++ b/arch/x86/kernel/cpu/common.c
17174 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17175
17176 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17177
17178 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17179 -#ifdef CONFIG_X86_64
17180 - /*
17181 - * We need valid kernel segments for data and code in long mode too
17182 - * IRET will check the segment types kkeil 2000/10/28
17183 - * Also sysret mandates a special GDT layout
17184 - *
17185 - * TLS descriptors are currently at a different place compared to i386.
17186 - * Hopefully nobody expects them at a fixed place (Wine?)
17187 - */
17188 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17189 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17190 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17191 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17192 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17193 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17194 -#else
17195 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17196 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17197 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17198 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17199 - /*
17200 - * Segments used for calling PnP BIOS have byte granularity.
17201 - * They code segments and data segments have fixed 64k limits,
17202 - * the transfer segment sizes are set at run time.
17203 - */
17204 - /* 32-bit code */
17205 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17206 - /* 16-bit code */
17207 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17208 - /* 16-bit data */
17209 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17210 - /* 16-bit data */
17211 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17212 - /* 16-bit data */
17213 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17214 - /*
17215 - * The APM segments have byte granularity and their bases
17216 - * are set at run time. All have 64k limits.
17217 - */
17218 - /* 32-bit code */
17219 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17220 - /* 16-bit code */
17221 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17222 - /* data */
17223 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17224 -
17225 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17226 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17227 - GDT_STACK_CANARY_INIT
17228 -#endif
17229 -} };
17230 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17231 -
17232 static int __init x86_xsave_setup(char *s)
17233 {
17234 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17235 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17236 {
17237 struct desc_ptr gdt_descr;
17238
17239 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17240 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17241 gdt_descr.size = GDT_SIZE - 1;
17242 load_gdt(&gdt_descr);
17243 /* Reload the per-cpu base */
17244 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17245 /* Filter out anything that depends on CPUID levels we don't have */
17246 filter_cpuid_features(c, true);
17247
17248 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17249 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17250 +#endif
17251 +
17252 /* If the model name is still unset, do table lookup. */
17253 if (!c->x86_model_id[0]) {
17254 const char *p;
17255 @@ -1065,10 +1015,12 @@ static __init int setup_disablecpuid(char *arg)
17256 }
17257 __setup("clearcpuid=", setup_disablecpuid);
17258
17259 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17260 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17261 +
17262 #ifdef CONFIG_X86_64
17263 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17264 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17265 - (unsigned long) nmi_idt_table };
17266 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17267
17268 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17269 irq_stack_union) __aligned(PAGE_SIZE);
17270 @@ -1082,7 +1034,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17271 EXPORT_PER_CPU_SYMBOL(current_task);
17272
17273 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17274 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17275 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17276 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17277
17278 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17279 @@ -1227,7 +1179,7 @@ void __cpuinit cpu_init(void)
17280 load_ucode_ap();
17281
17282 cpu = stack_smp_processor_id();
17283 - t = &per_cpu(init_tss, cpu);
17284 + t = init_tss + cpu;
17285 oist = &per_cpu(orig_ist, cpu);
17286
17287 #ifdef CONFIG_NUMA
17288 @@ -1253,7 +1205,7 @@ void __cpuinit cpu_init(void)
17289 switch_to_new_gdt(cpu);
17290 loadsegment(fs, 0);
17291
17292 - load_idt((const struct desc_ptr *)&idt_descr);
17293 + load_idt(&idt_descr);
17294
17295 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17296 syscall_init();
17297 @@ -1262,7 +1214,6 @@ void __cpuinit cpu_init(void)
17298 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17299 barrier();
17300
17301 - x86_configure_nx();
17302 enable_x2apic();
17303
17304 /*
17305 @@ -1314,7 +1265,7 @@ void __cpuinit cpu_init(void)
17306 {
17307 int cpu = smp_processor_id();
17308 struct task_struct *curr = current;
17309 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17310 + struct tss_struct *t = init_tss + cpu;
17311 struct thread_struct *thread = &curr->thread;
17312
17313 show_ucode_info_early();
17314 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17315 index 1905ce9..a7ac587 100644
17316 --- a/arch/x86/kernel/cpu/intel.c
17317 +++ b/arch/x86/kernel/cpu/intel.c
17318 @@ -173,7 +173,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17319 * Update the IDT descriptor and reload the IDT so that
17320 * it uses the read-only mapped virtual address.
17321 */
17322 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17323 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17324 load_idt(&idt_descr);
17325 }
17326 #endif
17327 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17328 index 7c6f7d5..8cac382 100644
17329 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17330 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17331 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17332 };
17333
17334 #ifdef CONFIG_AMD_NB
17335 +static struct attribute *default_attrs_amd_nb[] = {
17336 + &type.attr,
17337 + &level.attr,
17338 + &coherency_line_size.attr,
17339 + &physical_line_partition.attr,
17340 + &ways_of_associativity.attr,
17341 + &number_of_sets.attr,
17342 + &size.attr,
17343 + &shared_cpu_map.attr,
17344 + &shared_cpu_list.attr,
17345 + NULL,
17346 + NULL,
17347 + NULL,
17348 + NULL
17349 +};
17350 +
17351 static struct attribute ** __cpuinit amd_l3_attrs(void)
17352 {
17353 static struct attribute **attrs;
17354 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17355
17356 n = ARRAY_SIZE(default_attrs);
17357
17358 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17359 - n += 2;
17360 -
17361 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17362 - n += 1;
17363 -
17364 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17365 - if (attrs == NULL)
17366 - return attrs = default_attrs;
17367 -
17368 - for (n = 0; default_attrs[n]; n++)
17369 - attrs[n] = default_attrs[n];
17370 + attrs = default_attrs_amd_nb;
17371
17372 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17373 attrs[n++] = &cache_disable_0.attr;
17374 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17375 .default_attrs = default_attrs,
17376 };
17377
17378 +#ifdef CONFIG_AMD_NB
17379 +static struct kobj_type ktype_cache_amd_nb = {
17380 + .sysfs_ops = &sysfs_ops,
17381 + .default_attrs = default_attrs_amd_nb,
17382 +};
17383 +#endif
17384 +
17385 static struct kobj_type ktype_percpu_entry = {
17386 .sysfs_ops = &sysfs_ops,
17387 };
17388 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17389 return retval;
17390 }
17391
17392 +#ifdef CONFIG_AMD_NB
17393 + amd_l3_attrs();
17394 +#endif
17395 +
17396 for (i = 0; i < num_cache_leaves; i++) {
17397 + struct kobj_type *ktype;
17398 +
17399 this_object = INDEX_KOBJECT_PTR(cpu, i);
17400 this_object->cpu = cpu;
17401 this_object->index = i;
17402
17403 this_leaf = CPUID4_INFO_IDX(cpu, i);
17404
17405 - ktype_cache.default_attrs = default_attrs;
17406 + ktype = &ktype_cache;
17407 #ifdef CONFIG_AMD_NB
17408 if (this_leaf->base.nb)
17409 - ktype_cache.default_attrs = amd_l3_attrs();
17410 + ktype = &ktype_cache_amd_nb;
17411 #endif
17412 retval = kobject_init_and_add(&(this_object->kobj),
17413 - &ktype_cache,
17414 + ktype,
17415 per_cpu(ici_cache_kobject, cpu),
17416 "index%1lu", i);
17417 if (unlikely(retval)) {
17418 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17419 return NOTIFY_OK;
17420 }
17421
17422 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17423 +static struct notifier_block cacheinfo_cpu_notifier = {
17424 .notifier_call = cacheinfo_cpu_callback,
17425 };
17426
17427 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17428 index 7bc1263..bff5686 100644
17429 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17430 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17431 @@ -45,6 +45,7 @@
17432 #include <asm/processor.h>
17433 #include <asm/mce.h>
17434 #include <asm/msr.h>
17435 +#include <asm/local.h>
17436
17437 #include "mce-internal.h"
17438
17439 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17440 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17441 m->cs, m->ip);
17442
17443 - if (m->cs == __KERNEL_CS)
17444 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17445 print_symbol("{%s}", m->ip);
17446 pr_cont("\n");
17447 }
17448 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17449
17450 #define PANIC_TIMEOUT 5 /* 5 seconds */
17451
17452 -static atomic_t mce_paniced;
17453 +static atomic_unchecked_t mce_paniced;
17454
17455 static int fake_panic;
17456 -static atomic_t mce_fake_paniced;
17457 +static atomic_unchecked_t mce_fake_paniced;
17458
17459 /* Panic in progress. Enable interrupts and wait for final IPI */
17460 static void wait_for_panic(void)
17461 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17462 /*
17463 * Make sure only one CPU runs in machine check panic
17464 */
17465 - if (atomic_inc_return(&mce_paniced) > 1)
17466 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17467 wait_for_panic();
17468 barrier();
17469
17470 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17471 console_verbose();
17472 } else {
17473 /* Don't log too much for fake panic */
17474 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17475 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17476 return;
17477 }
17478 /* First print corrected ones that are still unlogged */
17479 @@ -353,7 +354,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17480 if (!fake_panic) {
17481 if (panic_timeout == 0)
17482 panic_timeout = mca_cfg.panic_timeout;
17483 - panic(msg);
17484 + panic("%s", msg);
17485 } else
17486 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
17487 }
17488 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17489 * might have been modified by someone else.
17490 */
17491 rmb();
17492 - if (atomic_read(&mce_paniced))
17493 + if (atomic_read_unchecked(&mce_paniced))
17494 wait_for_panic();
17495 if (!mca_cfg.monarch_timeout)
17496 goto out;
17497 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17498 }
17499
17500 /* Call the installed machine check handler for this CPU setup. */
17501 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17502 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17503 unexpected_machine_check;
17504
17505 /*
17506 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17507 return;
17508 }
17509
17510 + pax_open_kernel();
17511 machine_check_vector = do_machine_check;
17512 + pax_close_kernel();
17513
17514 __mcheck_cpu_init_generic();
17515 __mcheck_cpu_init_vendor(c);
17516 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17517 */
17518
17519 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17520 -static int mce_chrdev_open_count; /* #times opened */
17521 +static local_t mce_chrdev_open_count; /* #times opened */
17522 static int mce_chrdev_open_exclu; /* already open exclusive? */
17523
17524 static int mce_chrdev_open(struct inode *inode, struct file *file)
17525 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17526 spin_lock(&mce_chrdev_state_lock);
17527
17528 if (mce_chrdev_open_exclu ||
17529 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17530 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17531 spin_unlock(&mce_chrdev_state_lock);
17532
17533 return -EBUSY;
17534 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17535
17536 if (file->f_flags & O_EXCL)
17537 mce_chrdev_open_exclu = 1;
17538 - mce_chrdev_open_count++;
17539 + local_inc(&mce_chrdev_open_count);
17540
17541 spin_unlock(&mce_chrdev_state_lock);
17542
17543 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17544 {
17545 spin_lock(&mce_chrdev_state_lock);
17546
17547 - mce_chrdev_open_count--;
17548 + local_dec(&mce_chrdev_open_count);
17549 mce_chrdev_open_exclu = 0;
17550
17551 spin_unlock(&mce_chrdev_state_lock);
17552 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17553 return NOTIFY_OK;
17554 }
17555
17556 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17557 +static struct notifier_block mce_cpu_notifier = {
17558 .notifier_call = mce_cpu_callback,
17559 };
17560
17561 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17562
17563 for (i = 0; i < mca_cfg.banks; i++) {
17564 struct mce_bank *b = &mce_banks[i];
17565 - struct device_attribute *a = &b->attr;
17566 + device_attribute_no_const *a = &b->attr;
17567
17568 sysfs_attr_init(&a->attr);
17569 a->attr.name = b->attrname;
17570 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17571 static void mce_reset(void)
17572 {
17573 cpu_missing = 0;
17574 - atomic_set(&mce_fake_paniced, 0);
17575 + atomic_set_unchecked(&mce_fake_paniced, 0);
17576 atomic_set(&mce_executing, 0);
17577 atomic_set(&mce_callin, 0);
17578 atomic_set(&global_nwo, 0);
17579 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17580 index 1c044b1..37a2a43 100644
17581 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17582 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17583 @@ -11,6 +11,7 @@
17584 #include <asm/processor.h>
17585 #include <asm/mce.h>
17586 #include <asm/msr.h>
17587 +#include <asm/pgtable.h>
17588
17589 /* By default disabled */
17590 int mce_p5_enabled __read_mostly;
17591 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17592 if (!cpu_has(c, X86_FEATURE_MCE))
17593 return;
17594
17595 + pax_open_kernel();
17596 machine_check_vector = pentium_machine_check;
17597 + pax_close_kernel();
17598 /* Make sure the vector pointer is visible before we enable MCEs: */
17599 wmb();
17600
17601 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17602 index 47a1870..8c019a7 100644
17603 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17604 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17605 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17606 return notifier_from_errno(err);
17607 }
17608
17609 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17610 +static struct notifier_block thermal_throttle_cpu_notifier =
17611 {
17612 .notifier_call = thermal_throttle_cpu_callback,
17613 };
17614 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17615 index e9a701a..35317d6 100644
17616 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17617 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17618 @@ -10,6 +10,7 @@
17619 #include <asm/processor.h>
17620 #include <asm/mce.h>
17621 #include <asm/msr.h>
17622 +#include <asm/pgtable.h>
17623
17624 /* Machine check handler for WinChip C6: */
17625 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17626 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17627 {
17628 u32 lo, hi;
17629
17630 + pax_open_kernel();
17631 machine_check_vector = winchip_machine_check;
17632 + pax_close_kernel();
17633 /* Make sure the vector pointer is visible before we enable MCEs: */
17634 wmb();
17635
17636 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17637 index 726bf96..81f0526 100644
17638 --- a/arch/x86/kernel/cpu/mtrr/main.c
17639 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17640 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17641 u64 size_or_mask, size_and_mask;
17642 static bool mtrr_aps_delayed_init;
17643
17644 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17645 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17646
17647 const struct mtrr_ops *mtrr_if;
17648
17649 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17650 index df5e41f..816c719 100644
17651 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17652 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17653 @@ -25,7 +25,7 @@ struct mtrr_ops {
17654 int (*validate_add_page)(unsigned long base, unsigned long size,
17655 unsigned int type);
17656 int (*have_wrcomb)(void);
17657 -};
17658 +} __do_const;
17659
17660 extern int generic_get_free_region(unsigned long base, unsigned long size,
17661 int replace_reg);
17662 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17663 index bf0f01a..9adfee1 100644
17664 --- a/arch/x86/kernel/cpu/perf_event.c
17665 +++ b/arch/x86/kernel/cpu/perf_event.c
17666 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17667 pr_info("no hardware sampling interrupt available.\n");
17668 }
17669
17670 -static struct attribute_group x86_pmu_format_group = {
17671 +static attribute_group_no_const x86_pmu_format_group = {
17672 .name = "format",
17673 .attrs = NULL,
17674 };
17675 @@ -1374,7 +1374,7 @@ static struct attribute *events_attr[] = {
17676 NULL,
17677 };
17678
17679 -static struct attribute_group x86_pmu_events_group = {
17680 +static attribute_group_no_const x86_pmu_events_group = {
17681 .name = "events",
17682 .attrs = events_attr,
17683 };
17684 @@ -1873,7 +1873,7 @@ static unsigned long get_segment_base(unsigned int segment)
17685 if (idx > GDT_ENTRIES)
17686 return 0;
17687
17688 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17689 + desc = get_cpu_gdt_table(smp_processor_id());
17690 }
17691
17692 return get_desc_base(desc + idx);
17693 @@ -1963,7 +1963,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17694 break;
17695
17696 perf_callchain_store(entry, frame.return_address);
17697 - fp = frame.next_frame;
17698 + fp = (const void __force_user *)frame.next_frame;
17699 }
17700 }
17701
17702 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17703 index 4a0a462..be3b204 100644
17704 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17705 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17706 @@ -1994,10 +1994,10 @@ __init int intel_pmu_init(void)
17707 * v2 and above have a perf capabilities MSR
17708 */
17709 if (version > 1) {
17710 - u64 capabilities;
17711 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17712
17713 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17714 - x86_pmu.intel_cap.capabilities = capabilities;
17715 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17716 + x86_pmu.intel_cap.capabilities = capabilities;
17717 }
17718
17719 intel_ds_init();
17720 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17721 index 3e091f0..d2dc8d6 100644
17722 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17723 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17724 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17725 static int __init uncore_type_init(struct intel_uncore_type *type)
17726 {
17727 struct intel_uncore_pmu *pmus;
17728 - struct attribute_group *attr_group;
17729 + attribute_group_no_const *attr_group;
17730 struct attribute **attrs;
17731 int i, j;
17732
17733 @@ -2826,7 +2826,7 @@ static int
17734 return NOTIFY_OK;
17735 }
17736
17737 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17738 +static struct notifier_block uncore_cpu_nb = {
17739 .notifier_call = uncore_cpu_notifier,
17740 /*
17741 * to migrate uncore events, our notifier should be executed
17742 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17743 index e68a455..975a932 100644
17744 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17745 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17746 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17747 struct uncore_event_desc {
17748 struct kobj_attribute attr;
17749 const char *config;
17750 -};
17751 +} __do_const;
17752
17753 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17754 { \
17755 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17756 index 1e4dbcf..b9a34c2 100644
17757 --- a/arch/x86/kernel/cpuid.c
17758 +++ b/arch/x86/kernel/cpuid.c
17759 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17760 return notifier_from_errno(err);
17761 }
17762
17763 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17764 +static struct notifier_block cpuid_class_cpu_notifier =
17765 {
17766 .notifier_call = cpuid_class_cpu_callback,
17767 };
17768 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17769 index 74467fe..18793d5 100644
17770 --- a/arch/x86/kernel/crash.c
17771 +++ b/arch/x86/kernel/crash.c
17772 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17773 {
17774 #ifdef CONFIG_X86_32
17775 struct pt_regs fixed_regs;
17776 -#endif
17777
17778 -#ifdef CONFIG_X86_32
17779 - if (!user_mode_vm(regs)) {
17780 + if (!user_mode(regs)) {
17781 crash_fixup_ss_esp(&fixed_regs, regs);
17782 regs = &fixed_regs;
17783 }
17784 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17785 index afa64ad..dce67dd 100644
17786 --- a/arch/x86/kernel/crash_dump_64.c
17787 +++ b/arch/x86/kernel/crash_dump_64.c
17788 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17789 return -ENOMEM;
17790
17791 if (userbuf) {
17792 - if (copy_to_user(buf, vaddr + offset, csize)) {
17793 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17794 iounmap(vaddr);
17795 return -EFAULT;
17796 }
17797 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17798 index 37250fe..bf2ec74 100644
17799 --- a/arch/x86/kernel/doublefault_32.c
17800 +++ b/arch/x86/kernel/doublefault_32.c
17801 @@ -11,7 +11,7 @@
17802
17803 #define DOUBLEFAULT_STACKSIZE (1024)
17804 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17805 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17806 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17807
17808 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17809
17810 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17811 unsigned long gdt, tss;
17812
17813 store_gdt(&gdt_desc);
17814 - gdt = gdt_desc.address;
17815 + gdt = (unsigned long)gdt_desc.address;
17816
17817 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17818
17819 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17820 /* 0x2 bit is always set */
17821 .flags = X86_EFLAGS_SF | 0x2,
17822 .sp = STACK_START,
17823 - .es = __USER_DS,
17824 + .es = __KERNEL_DS,
17825 .cs = __KERNEL_CS,
17826 .ss = __KERNEL_DS,
17827 - .ds = __USER_DS,
17828 + .ds = __KERNEL_DS,
17829 .fs = __KERNEL_PERCPU,
17830
17831 .__cr3 = __pa_nodebug(swapper_pg_dir),
17832 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17833 index c8797d5..c605e53 100644
17834 --- a/arch/x86/kernel/dumpstack.c
17835 +++ b/arch/x86/kernel/dumpstack.c
17836 @@ -2,6 +2,9 @@
17837 * Copyright (C) 1991, 1992 Linus Torvalds
17838 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17839 */
17840 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17841 +#define __INCLUDED_BY_HIDESYM 1
17842 +#endif
17843 #include <linux/kallsyms.h>
17844 #include <linux/kprobes.h>
17845 #include <linux/uaccess.h>
17846 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17847 static void
17848 print_ftrace_graph_addr(unsigned long addr, void *data,
17849 const struct stacktrace_ops *ops,
17850 - struct thread_info *tinfo, int *graph)
17851 + struct task_struct *task, int *graph)
17852 {
17853 - struct task_struct *task;
17854 unsigned long ret_addr;
17855 int index;
17856
17857 if (addr != (unsigned long)return_to_handler)
17858 return;
17859
17860 - task = tinfo->task;
17861 index = task->curr_ret_stack;
17862
17863 if (!task->ret_stack || index < *graph)
17864 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17865 static inline void
17866 print_ftrace_graph_addr(unsigned long addr, void *data,
17867 const struct stacktrace_ops *ops,
17868 - struct thread_info *tinfo, int *graph)
17869 + struct task_struct *task, int *graph)
17870 { }
17871 #endif
17872
17873 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17874 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17875 */
17876
17877 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17878 - void *p, unsigned int size, void *end)
17879 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17880 {
17881 - void *t = tinfo;
17882 if (end) {
17883 if (p < end && p >= (end-THREAD_SIZE))
17884 return 1;
17885 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17886 }
17887
17888 unsigned long
17889 -print_context_stack(struct thread_info *tinfo,
17890 +print_context_stack(struct task_struct *task, void *stack_start,
17891 unsigned long *stack, unsigned long bp,
17892 const struct stacktrace_ops *ops, void *data,
17893 unsigned long *end, int *graph)
17894 {
17895 struct stack_frame *frame = (struct stack_frame *)bp;
17896
17897 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17898 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17899 unsigned long addr;
17900
17901 addr = *stack;
17902 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17903 } else {
17904 ops->address(data, addr, 0);
17905 }
17906 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17907 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17908 }
17909 stack++;
17910 }
17911 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17912 EXPORT_SYMBOL_GPL(print_context_stack);
17913
17914 unsigned long
17915 -print_context_stack_bp(struct thread_info *tinfo,
17916 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17917 unsigned long *stack, unsigned long bp,
17918 const struct stacktrace_ops *ops, void *data,
17919 unsigned long *end, int *graph)
17920 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17921 struct stack_frame *frame = (struct stack_frame *)bp;
17922 unsigned long *ret_addr = &frame->return_address;
17923
17924 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17925 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17926 unsigned long addr = *ret_addr;
17927
17928 if (!__kernel_text_address(addr))
17929 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17930 ops->address(data, addr, 1);
17931 frame = frame->next_frame;
17932 ret_addr = &frame->return_address;
17933 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17934 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17935 }
17936
17937 return (unsigned long)frame;
17938 @@ -189,7 +188,7 @@ void dump_stack(void)
17939
17940 bp = stack_frame(current, NULL);
17941 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17942 - current->pid, current->comm, print_tainted(),
17943 + task_pid_nr(current), current->comm, print_tainted(),
17944 init_utsname()->release,
17945 (int)strcspn(init_utsname()->version, " "),
17946 init_utsname()->version);
17947 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17948 }
17949 EXPORT_SYMBOL_GPL(oops_begin);
17950
17951 +extern void gr_handle_kernel_exploit(void);
17952 +
17953 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17954 {
17955 if (regs && kexec_should_crash(current))
17956 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17957 panic("Fatal exception in interrupt");
17958 if (panic_on_oops)
17959 panic("Fatal exception");
17960 - do_exit(signr);
17961 +
17962 + gr_handle_kernel_exploit();
17963 +
17964 + do_group_exit(signr);
17965 }
17966
17967 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17968 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17969 print_modules();
17970 show_regs(regs);
17971 #ifdef CONFIG_X86_32
17972 - if (user_mode_vm(regs)) {
17973 + if (user_mode(regs)) {
17974 sp = regs->sp;
17975 ss = regs->ss & 0xffff;
17976 } else {
17977 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17978 unsigned long flags = oops_begin();
17979 int sig = SIGSEGV;
17980
17981 - if (!user_mode_vm(regs))
17982 + if (!user_mode(regs))
17983 report_bug(regs->ip, regs);
17984
17985 if (__die(str, regs, err))
17986 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17987 index 1038a41..db2c12b 100644
17988 --- a/arch/x86/kernel/dumpstack_32.c
17989 +++ b/arch/x86/kernel/dumpstack_32.c
17990 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17991 bp = stack_frame(task, regs);
17992
17993 for (;;) {
17994 - struct thread_info *context;
17995 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17996
17997 - context = (struct thread_info *)
17998 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17999 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18000 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18001
18002 - stack = (unsigned long *)context->previous_esp;
18003 - if (!stack)
18004 + if (stack_start == task_stack_page(task))
18005 break;
18006 + stack = *(unsigned long **)stack_start;
18007 if (ops->stack(data, "IRQ") < 0)
18008 break;
18009 touch_nmi_watchdog();
18010 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18011 {
18012 int i;
18013
18014 - __show_regs(regs, !user_mode_vm(regs));
18015 + __show_regs(regs, !user_mode(regs));
18016
18017 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18018 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18019 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18020 * When in-kernel, we also print out the stack and code at the
18021 * time of the fault..
18022 */
18023 - if (!user_mode_vm(regs)) {
18024 + if (!user_mode(regs)) {
18025 unsigned int code_prologue = code_bytes * 43 / 64;
18026 unsigned int code_len = code_bytes;
18027 unsigned char c;
18028 u8 *ip;
18029 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18030
18031 pr_emerg("Stack:\n");
18032 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18033
18034 pr_emerg("Code:");
18035
18036 - ip = (u8 *)regs->ip - code_prologue;
18037 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18038 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18039 /* try starting at IP */
18040 - ip = (u8 *)regs->ip;
18041 + ip = (u8 *)regs->ip + cs_base;
18042 code_len = code_len - code_prologue + 1;
18043 }
18044 for (i = 0; i < code_len; i++, ip++) {
18045 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18046 pr_cont(" Bad EIP value.");
18047 break;
18048 }
18049 - if (ip == (u8 *)regs->ip)
18050 + if (ip == (u8 *)regs->ip + cs_base)
18051 pr_cont(" <%02x>", c);
18052 else
18053 pr_cont(" %02x", c);
18054 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18055 {
18056 unsigned short ud2;
18057
18058 + ip = ktla_ktva(ip);
18059 if (ip < PAGE_OFFSET)
18060 return 0;
18061 if (probe_kernel_address((unsigned short *)ip, ud2))
18062 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18063
18064 return ud2 == 0x0b0f;
18065 }
18066 +
18067 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18068 +void pax_check_alloca(unsigned long size)
18069 +{
18070 + unsigned long sp = (unsigned long)&sp, stack_left;
18071 +
18072 + /* all kernel stacks are of the same size */
18073 + stack_left = sp & (THREAD_SIZE - 1);
18074 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18075 +}
18076 +EXPORT_SYMBOL(pax_check_alloca);
18077 +#endif
18078 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18079 index b653675..51cc8c0 100644
18080 --- a/arch/x86/kernel/dumpstack_64.c
18081 +++ b/arch/x86/kernel/dumpstack_64.c
18082 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18083 unsigned long *irq_stack_end =
18084 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18085 unsigned used = 0;
18086 - struct thread_info *tinfo;
18087 int graph = 0;
18088 unsigned long dummy;
18089 + void *stack_start;
18090
18091 if (!task)
18092 task = current;
18093 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18094 * current stack address. If the stacks consist of nested
18095 * exceptions
18096 */
18097 - tinfo = task_thread_info(task);
18098 for (;;) {
18099 char *id;
18100 unsigned long *estack_end;
18101 +
18102 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18103 &used, &id);
18104
18105 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18106 if (ops->stack(data, id) < 0)
18107 break;
18108
18109 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18110 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18111 data, estack_end, &graph);
18112 ops->stack(data, "<EOE>");
18113 /*
18114 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18115 * second-to-last pointer (index -2 to end) in the
18116 * exception stack:
18117 */
18118 + if ((u16)estack_end[-1] != __KERNEL_DS)
18119 + goto out;
18120 stack = (unsigned long *) estack_end[-2];
18121 continue;
18122 }
18123 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18124 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18125 if (ops->stack(data, "IRQ") < 0)
18126 break;
18127 - bp = ops->walk_stack(tinfo, stack, bp,
18128 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18129 ops, data, irq_stack_end, &graph);
18130 /*
18131 * We link to the next stack (which would be
18132 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18133 /*
18134 * This handles the process stack:
18135 */
18136 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18137 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18138 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18139 +out:
18140 put_cpu();
18141 }
18142 EXPORT_SYMBOL(dump_trace);
18143 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18144 {
18145 int i;
18146 unsigned long sp;
18147 - const int cpu = smp_processor_id();
18148 + const int cpu = raw_smp_processor_id();
18149 struct task_struct *cur = current;
18150
18151 sp = regs->sp;
18152 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18153
18154 return ud2 == 0x0b0f;
18155 }
18156 +
18157 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18158 +void pax_check_alloca(unsigned long size)
18159 +{
18160 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18161 + unsigned cpu, used;
18162 + char *id;
18163 +
18164 + /* check the process stack first */
18165 + stack_start = (unsigned long)task_stack_page(current);
18166 + stack_end = stack_start + THREAD_SIZE;
18167 + if (likely(stack_start <= sp && sp < stack_end)) {
18168 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18169 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18170 + return;
18171 + }
18172 +
18173 + cpu = get_cpu();
18174 +
18175 + /* check the irq stacks */
18176 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18177 + stack_start = stack_end - IRQ_STACK_SIZE;
18178 + if (stack_start <= sp && sp < stack_end) {
18179 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18180 + put_cpu();
18181 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18182 + return;
18183 + }
18184 +
18185 + /* check the exception stacks */
18186 + used = 0;
18187 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18188 + stack_start = stack_end - EXCEPTION_STKSZ;
18189 + if (stack_end && stack_start <= sp && sp < stack_end) {
18190 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18191 + put_cpu();
18192 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18193 + return;
18194 + }
18195 +
18196 + put_cpu();
18197 +
18198 + /* unknown stack */
18199 + BUG();
18200 +}
18201 +EXPORT_SYMBOL(pax_check_alloca);
18202 +#endif
18203 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
18204 index d32abea..74daf4f 100644
18205 --- a/arch/x86/kernel/e820.c
18206 +++ b/arch/x86/kernel/e820.c
18207 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
18208
18209 static void early_panic(char *msg)
18210 {
18211 - early_printk(msg);
18212 - panic(msg);
18213 + early_printk("%s", msg);
18214 + panic("%s", msg);
18215 }
18216
18217 static int userdef __initdata;
18218 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18219 index 9b9f18b..9fcaa04 100644
18220 --- a/arch/x86/kernel/early_printk.c
18221 +++ b/arch/x86/kernel/early_printk.c
18222 @@ -7,6 +7,7 @@
18223 #include <linux/pci_regs.h>
18224 #include <linux/pci_ids.h>
18225 #include <linux/errno.h>
18226 +#include <linux/sched.h>
18227 #include <asm/io.h>
18228 #include <asm/processor.h>
18229 #include <asm/fcntl.h>
18230 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18231 index 8f3e2de..934870f 100644
18232 --- a/arch/x86/kernel/entry_32.S
18233 +++ b/arch/x86/kernel/entry_32.S
18234 @@ -177,13 +177,153 @@
18235 /*CFI_REL_OFFSET gs, PT_GS*/
18236 .endm
18237 .macro SET_KERNEL_GS reg
18238 +
18239 +#ifdef CONFIG_CC_STACKPROTECTOR
18240 movl $(__KERNEL_STACK_CANARY), \reg
18241 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18242 + movl $(__USER_DS), \reg
18243 +#else
18244 + xorl \reg, \reg
18245 +#endif
18246 +
18247 movl \reg, %gs
18248 .endm
18249
18250 #endif /* CONFIG_X86_32_LAZY_GS */
18251
18252 -.macro SAVE_ALL
18253 +.macro pax_enter_kernel
18254 +#ifdef CONFIG_PAX_KERNEXEC
18255 + call pax_enter_kernel
18256 +#endif
18257 +.endm
18258 +
18259 +.macro pax_exit_kernel
18260 +#ifdef CONFIG_PAX_KERNEXEC
18261 + call pax_exit_kernel
18262 +#endif
18263 +.endm
18264 +
18265 +#ifdef CONFIG_PAX_KERNEXEC
18266 +ENTRY(pax_enter_kernel)
18267 +#ifdef CONFIG_PARAVIRT
18268 + pushl %eax
18269 + pushl %ecx
18270 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18271 + mov %eax, %esi
18272 +#else
18273 + mov %cr0, %esi
18274 +#endif
18275 + bts $16, %esi
18276 + jnc 1f
18277 + mov %cs, %esi
18278 + cmp $__KERNEL_CS, %esi
18279 + jz 3f
18280 + ljmp $__KERNEL_CS, $3f
18281 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18282 +2:
18283 +#ifdef CONFIG_PARAVIRT
18284 + mov %esi, %eax
18285 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18286 +#else
18287 + mov %esi, %cr0
18288 +#endif
18289 +3:
18290 +#ifdef CONFIG_PARAVIRT
18291 + popl %ecx
18292 + popl %eax
18293 +#endif
18294 + ret
18295 +ENDPROC(pax_enter_kernel)
18296 +
18297 +ENTRY(pax_exit_kernel)
18298 +#ifdef CONFIG_PARAVIRT
18299 + pushl %eax
18300 + pushl %ecx
18301 +#endif
18302 + mov %cs, %esi
18303 + cmp $__KERNEXEC_KERNEL_CS, %esi
18304 + jnz 2f
18305 +#ifdef CONFIG_PARAVIRT
18306 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18307 + mov %eax, %esi
18308 +#else
18309 + mov %cr0, %esi
18310 +#endif
18311 + btr $16, %esi
18312 + ljmp $__KERNEL_CS, $1f
18313 +1:
18314 +#ifdef CONFIG_PARAVIRT
18315 + mov %esi, %eax
18316 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18317 +#else
18318 + mov %esi, %cr0
18319 +#endif
18320 +2:
18321 +#ifdef CONFIG_PARAVIRT
18322 + popl %ecx
18323 + popl %eax
18324 +#endif
18325 + ret
18326 +ENDPROC(pax_exit_kernel)
18327 +#endif
18328 +
18329 +.macro pax_erase_kstack
18330 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18331 + call pax_erase_kstack
18332 +#endif
18333 +.endm
18334 +
18335 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18336 +/*
18337 + * ebp: thread_info
18338 + */
18339 +ENTRY(pax_erase_kstack)
18340 + pushl %edi
18341 + pushl %ecx
18342 + pushl %eax
18343 +
18344 + mov TI_lowest_stack(%ebp), %edi
18345 + mov $-0xBEEF, %eax
18346 + std
18347 +
18348 +1: mov %edi, %ecx
18349 + and $THREAD_SIZE_asm - 1, %ecx
18350 + shr $2, %ecx
18351 + repne scasl
18352 + jecxz 2f
18353 +
18354 + cmp $2*16, %ecx
18355 + jc 2f
18356 +
18357 + mov $2*16, %ecx
18358 + repe scasl
18359 + jecxz 2f
18360 + jne 1b
18361 +
18362 +2: cld
18363 + mov %esp, %ecx
18364 + sub %edi, %ecx
18365 +
18366 + cmp $THREAD_SIZE_asm, %ecx
18367 + jb 3f
18368 + ud2
18369 +3:
18370 +
18371 + shr $2, %ecx
18372 + rep stosl
18373 +
18374 + mov TI_task_thread_sp0(%ebp), %edi
18375 + sub $128, %edi
18376 + mov %edi, TI_lowest_stack(%ebp)
18377 +
18378 + popl %eax
18379 + popl %ecx
18380 + popl %edi
18381 + ret
18382 +ENDPROC(pax_erase_kstack)
18383 +#endif
18384 +
18385 +.macro __SAVE_ALL _DS
18386 cld
18387 PUSH_GS
18388 pushl_cfi %fs
18389 @@ -206,7 +346,7 @@
18390 CFI_REL_OFFSET ecx, 0
18391 pushl_cfi %ebx
18392 CFI_REL_OFFSET ebx, 0
18393 - movl $(__USER_DS), %edx
18394 + movl $\_DS, %edx
18395 movl %edx, %ds
18396 movl %edx, %es
18397 movl $(__KERNEL_PERCPU), %edx
18398 @@ -214,6 +354,15 @@
18399 SET_KERNEL_GS %edx
18400 .endm
18401
18402 +.macro SAVE_ALL
18403 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18404 + __SAVE_ALL __KERNEL_DS
18405 + pax_enter_kernel
18406 +#else
18407 + __SAVE_ALL __USER_DS
18408 +#endif
18409 +.endm
18410 +
18411 .macro RESTORE_INT_REGS
18412 popl_cfi %ebx
18413 CFI_RESTORE ebx
18414 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18415 popfl_cfi
18416 jmp syscall_exit
18417 CFI_ENDPROC
18418 -END(ret_from_fork)
18419 +ENDPROC(ret_from_fork)
18420
18421 ENTRY(ret_from_kernel_thread)
18422 CFI_STARTPROC
18423 @@ -344,7 +493,15 @@ ret_from_intr:
18424 andl $SEGMENT_RPL_MASK, %eax
18425 #endif
18426 cmpl $USER_RPL, %eax
18427 +
18428 +#ifdef CONFIG_PAX_KERNEXEC
18429 + jae resume_userspace
18430 +
18431 + pax_exit_kernel
18432 + jmp resume_kernel
18433 +#else
18434 jb resume_kernel # not returning to v8086 or userspace
18435 +#endif
18436
18437 ENTRY(resume_userspace)
18438 LOCKDEP_SYS_EXIT
18439 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18440 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18441 # int/exception return?
18442 jne work_pending
18443 - jmp restore_all
18444 -END(ret_from_exception)
18445 + jmp restore_all_pax
18446 +ENDPROC(ret_from_exception)
18447
18448 #ifdef CONFIG_PREEMPT
18449 ENTRY(resume_kernel)
18450 @@ -372,7 +529,7 @@ need_resched:
18451 jz restore_all
18452 call preempt_schedule_irq
18453 jmp need_resched
18454 -END(resume_kernel)
18455 +ENDPROC(resume_kernel)
18456 #endif
18457 CFI_ENDPROC
18458 /*
18459 @@ -406,30 +563,45 @@ sysenter_past_esp:
18460 /*CFI_REL_OFFSET cs, 0*/
18461 /*
18462 * Push current_thread_info()->sysenter_return to the stack.
18463 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18464 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18465 */
18466 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18467 + pushl_cfi $0
18468 CFI_REL_OFFSET eip, 0
18469
18470 pushl_cfi %eax
18471 SAVE_ALL
18472 + GET_THREAD_INFO(%ebp)
18473 + movl TI_sysenter_return(%ebp),%ebp
18474 + movl %ebp,PT_EIP(%esp)
18475 ENABLE_INTERRUPTS(CLBR_NONE)
18476
18477 /*
18478 * Load the potential sixth argument from user stack.
18479 * Careful about security.
18480 */
18481 + movl PT_OLDESP(%esp),%ebp
18482 +
18483 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18484 + mov PT_OLDSS(%esp),%ds
18485 +1: movl %ds:(%ebp),%ebp
18486 + push %ss
18487 + pop %ds
18488 +#else
18489 cmpl $__PAGE_OFFSET-3,%ebp
18490 jae syscall_fault
18491 ASM_STAC
18492 1: movl (%ebp),%ebp
18493 ASM_CLAC
18494 +#endif
18495 +
18496 movl %ebp,PT_EBP(%esp)
18497 _ASM_EXTABLE(1b,syscall_fault)
18498
18499 GET_THREAD_INFO(%ebp)
18500
18501 +#ifdef CONFIG_PAX_RANDKSTACK
18502 + pax_erase_kstack
18503 +#endif
18504 +
18505 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18506 jnz sysenter_audit
18507 sysenter_do_call:
18508 @@ -444,12 +616,24 @@ sysenter_do_call:
18509 testl $_TIF_ALLWORK_MASK, %ecx
18510 jne sysexit_audit
18511 sysenter_exit:
18512 +
18513 +#ifdef CONFIG_PAX_RANDKSTACK
18514 + pushl_cfi %eax
18515 + movl %esp, %eax
18516 + call pax_randomize_kstack
18517 + popl_cfi %eax
18518 +#endif
18519 +
18520 + pax_erase_kstack
18521 +
18522 /* if something modifies registers it must also disable sysexit */
18523 movl PT_EIP(%esp), %edx
18524 movl PT_OLDESP(%esp), %ecx
18525 xorl %ebp,%ebp
18526 TRACE_IRQS_ON
18527 1: mov PT_FS(%esp), %fs
18528 +2: mov PT_DS(%esp), %ds
18529 +3: mov PT_ES(%esp), %es
18530 PTGS_TO_GS
18531 ENABLE_INTERRUPTS_SYSEXIT
18532
18533 @@ -466,6 +650,9 @@ sysenter_audit:
18534 movl %eax,%edx /* 2nd arg: syscall number */
18535 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18536 call __audit_syscall_entry
18537 +
18538 + pax_erase_kstack
18539 +
18540 pushl_cfi %ebx
18541 movl PT_EAX(%esp),%eax /* reload syscall number */
18542 jmp sysenter_do_call
18543 @@ -491,10 +678,16 @@ sysexit_audit:
18544
18545 CFI_ENDPROC
18546 .pushsection .fixup,"ax"
18547 -2: movl $0,PT_FS(%esp)
18548 +4: movl $0,PT_FS(%esp)
18549 + jmp 1b
18550 +5: movl $0,PT_DS(%esp)
18551 + jmp 1b
18552 +6: movl $0,PT_ES(%esp)
18553 jmp 1b
18554 .popsection
18555 - _ASM_EXTABLE(1b,2b)
18556 + _ASM_EXTABLE(1b,4b)
18557 + _ASM_EXTABLE(2b,5b)
18558 + _ASM_EXTABLE(3b,6b)
18559 PTGS_TO_GS_EX
18560 ENDPROC(ia32_sysenter_target)
18561
18562 @@ -509,6 +702,11 @@ ENTRY(system_call)
18563 pushl_cfi %eax # save orig_eax
18564 SAVE_ALL
18565 GET_THREAD_INFO(%ebp)
18566 +
18567 +#ifdef CONFIG_PAX_RANDKSTACK
18568 + pax_erase_kstack
18569 +#endif
18570 +
18571 # system call tracing in operation / emulation
18572 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18573 jnz syscall_trace_entry
18574 @@ -527,6 +725,15 @@ syscall_exit:
18575 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18576 jne syscall_exit_work
18577
18578 +restore_all_pax:
18579 +
18580 +#ifdef CONFIG_PAX_RANDKSTACK
18581 + movl %esp, %eax
18582 + call pax_randomize_kstack
18583 +#endif
18584 +
18585 + pax_erase_kstack
18586 +
18587 restore_all:
18588 TRACE_IRQS_IRET
18589 restore_all_notrace:
18590 @@ -583,14 +790,34 @@ ldt_ss:
18591 * compensating for the offset by changing to the ESPFIX segment with
18592 * a base address that matches for the difference.
18593 */
18594 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18595 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18596 mov %esp, %edx /* load kernel esp */
18597 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18598 mov %dx, %ax /* eax: new kernel esp */
18599 sub %eax, %edx /* offset (low word is 0) */
18600 +#ifdef CONFIG_SMP
18601 + movl PER_CPU_VAR(cpu_number), %ebx
18602 + shll $PAGE_SHIFT_asm, %ebx
18603 + addl $cpu_gdt_table, %ebx
18604 +#else
18605 + movl $cpu_gdt_table, %ebx
18606 +#endif
18607 shr $16, %edx
18608 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18609 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18610 +
18611 +#ifdef CONFIG_PAX_KERNEXEC
18612 + mov %cr0, %esi
18613 + btr $16, %esi
18614 + mov %esi, %cr0
18615 +#endif
18616 +
18617 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18618 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18619 +
18620 +#ifdef CONFIG_PAX_KERNEXEC
18621 + bts $16, %esi
18622 + mov %esi, %cr0
18623 +#endif
18624 +
18625 pushl_cfi $__ESPFIX_SS
18626 pushl_cfi %eax /* new kernel esp */
18627 /* Disable interrupts, but do not irqtrace this section: we
18628 @@ -619,20 +846,18 @@ work_resched:
18629 movl TI_flags(%ebp), %ecx
18630 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18631 # than syscall tracing?
18632 - jz restore_all
18633 + jz restore_all_pax
18634 testb $_TIF_NEED_RESCHED, %cl
18635 jnz work_resched
18636
18637 work_notifysig: # deal with pending signals and
18638 # notify-resume requests
18639 + movl %esp, %eax
18640 #ifdef CONFIG_VM86
18641 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18642 - movl %esp, %eax
18643 jne work_notifysig_v86 # returning to kernel-space or
18644 # vm86-space
18645 1:
18646 -#else
18647 - movl %esp, %eax
18648 #endif
18649 TRACE_IRQS_ON
18650 ENABLE_INTERRUPTS(CLBR_NONE)
18651 @@ -653,7 +878,7 @@ work_notifysig_v86:
18652 movl %eax, %esp
18653 jmp 1b
18654 #endif
18655 -END(work_pending)
18656 +ENDPROC(work_pending)
18657
18658 # perform syscall exit tracing
18659 ALIGN
18660 @@ -661,11 +886,14 @@ syscall_trace_entry:
18661 movl $-ENOSYS,PT_EAX(%esp)
18662 movl %esp, %eax
18663 call syscall_trace_enter
18664 +
18665 + pax_erase_kstack
18666 +
18667 /* What it returned is what we'll actually use. */
18668 cmpl $(NR_syscalls), %eax
18669 jnae syscall_call
18670 jmp syscall_exit
18671 -END(syscall_trace_entry)
18672 +ENDPROC(syscall_trace_entry)
18673
18674 # perform syscall exit tracing
18675 ALIGN
18676 @@ -678,21 +906,25 @@ syscall_exit_work:
18677 movl %esp, %eax
18678 call syscall_trace_leave
18679 jmp resume_userspace
18680 -END(syscall_exit_work)
18681 +ENDPROC(syscall_exit_work)
18682 CFI_ENDPROC
18683
18684 RING0_INT_FRAME # can't unwind into user space anyway
18685 syscall_fault:
18686 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18687 + push %ss
18688 + pop %ds
18689 +#endif
18690 ASM_CLAC
18691 GET_THREAD_INFO(%ebp)
18692 movl $-EFAULT,PT_EAX(%esp)
18693 jmp resume_userspace
18694 -END(syscall_fault)
18695 +ENDPROC(syscall_fault)
18696
18697 syscall_badsys:
18698 movl $-ENOSYS,PT_EAX(%esp)
18699 jmp resume_userspace
18700 -END(syscall_badsys)
18701 +ENDPROC(syscall_badsys)
18702 CFI_ENDPROC
18703 /*
18704 * End of kprobes section
18705 @@ -708,8 +940,15 @@ END(syscall_badsys)
18706 * normal stack and adjusts ESP with the matching offset.
18707 */
18708 /* fixup the stack */
18709 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18710 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18711 +#ifdef CONFIG_SMP
18712 + movl PER_CPU_VAR(cpu_number), %ebx
18713 + shll $PAGE_SHIFT_asm, %ebx
18714 + addl $cpu_gdt_table, %ebx
18715 +#else
18716 + movl $cpu_gdt_table, %ebx
18717 +#endif
18718 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18719 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18720 shl $16, %eax
18721 addl %esp, %eax /* the adjusted stack pointer */
18722 pushl_cfi $__KERNEL_DS
18723 @@ -762,7 +1001,7 @@ vector=vector+1
18724 .endr
18725 2: jmp common_interrupt
18726 .endr
18727 -END(irq_entries_start)
18728 +ENDPROC(irq_entries_start)
18729
18730 .previous
18731 END(interrupt)
18732 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18733 pushl_cfi $do_coprocessor_error
18734 jmp error_code
18735 CFI_ENDPROC
18736 -END(coprocessor_error)
18737 +ENDPROC(coprocessor_error)
18738
18739 ENTRY(simd_coprocessor_error)
18740 RING0_INT_FRAME
18741 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18742 #endif
18743 jmp error_code
18744 CFI_ENDPROC
18745 -END(simd_coprocessor_error)
18746 +ENDPROC(simd_coprocessor_error)
18747
18748 ENTRY(device_not_available)
18749 RING0_INT_FRAME
18750 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18751 pushl_cfi $do_device_not_available
18752 jmp error_code
18753 CFI_ENDPROC
18754 -END(device_not_available)
18755 +ENDPROC(device_not_available)
18756
18757 #ifdef CONFIG_PARAVIRT
18758 ENTRY(native_iret)
18759 iret
18760 _ASM_EXTABLE(native_iret, iret_exc)
18761 -END(native_iret)
18762 +ENDPROC(native_iret)
18763
18764 ENTRY(native_irq_enable_sysexit)
18765 sti
18766 sysexit
18767 -END(native_irq_enable_sysexit)
18768 +ENDPROC(native_irq_enable_sysexit)
18769 #endif
18770
18771 ENTRY(overflow)
18772 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18773 pushl_cfi $do_overflow
18774 jmp error_code
18775 CFI_ENDPROC
18776 -END(overflow)
18777 +ENDPROC(overflow)
18778
18779 ENTRY(bounds)
18780 RING0_INT_FRAME
18781 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18782 pushl_cfi $do_bounds
18783 jmp error_code
18784 CFI_ENDPROC
18785 -END(bounds)
18786 +ENDPROC(bounds)
18787
18788 ENTRY(invalid_op)
18789 RING0_INT_FRAME
18790 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18791 pushl_cfi $do_invalid_op
18792 jmp error_code
18793 CFI_ENDPROC
18794 -END(invalid_op)
18795 +ENDPROC(invalid_op)
18796
18797 ENTRY(coprocessor_segment_overrun)
18798 RING0_INT_FRAME
18799 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18800 pushl_cfi $do_coprocessor_segment_overrun
18801 jmp error_code
18802 CFI_ENDPROC
18803 -END(coprocessor_segment_overrun)
18804 +ENDPROC(coprocessor_segment_overrun)
18805
18806 ENTRY(invalid_TSS)
18807 RING0_EC_FRAME
18808 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18809 pushl_cfi $do_invalid_TSS
18810 jmp error_code
18811 CFI_ENDPROC
18812 -END(invalid_TSS)
18813 +ENDPROC(invalid_TSS)
18814
18815 ENTRY(segment_not_present)
18816 RING0_EC_FRAME
18817 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18818 pushl_cfi $do_segment_not_present
18819 jmp error_code
18820 CFI_ENDPROC
18821 -END(segment_not_present)
18822 +ENDPROC(segment_not_present)
18823
18824 ENTRY(stack_segment)
18825 RING0_EC_FRAME
18826 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18827 pushl_cfi $do_stack_segment
18828 jmp error_code
18829 CFI_ENDPROC
18830 -END(stack_segment)
18831 +ENDPROC(stack_segment)
18832
18833 ENTRY(alignment_check)
18834 RING0_EC_FRAME
18835 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18836 pushl_cfi $do_alignment_check
18837 jmp error_code
18838 CFI_ENDPROC
18839 -END(alignment_check)
18840 +ENDPROC(alignment_check)
18841
18842 ENTRY(divide_error)
18843 RING0_INT_FRAME
18844 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18845 pushl_cfi $do_divide_error
18846 jmp error_code
18847 CFI_ENDPROC
18848 -END(divide_error)
18849 +ENDPROC(divide_error)
18850
18851 #ifdef CONFIG_X86_MCE
18852 ENTRY(machine_check)
18853 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18854 pushl_cfi machine_check_vector
18855 jmp error_code
18856 CFI_ENDPROC
18857 -END(machine_check)
18858 +ENDPROC(machine_check)
18859 #endif
18860
18861 ENTRY(spurious_interrupt_bug)
18862 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18863 pushl_cfi $do_spurious_interrupt_bug
18864 jmp error_code
18865 CFI_ENDPROC
18866 -END(spurious_interrupt_bug)
18867 +ENDPROC(spurious_interrupt_bug)
18868 /*
18869 * End of kprobes section
18870 */
18871 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18872
18873 ENTRY(mcount)
18874 ret
18875 -END(mcount)
18876 +ENDPROC(mcount)
18877
18878 ENTRY(ftrace_caller)
18879 cmpl $0, function_trace_stop
18880 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18881 .globl ftrace_stub
18882 ftrace_stub:
18883 ret
18884 -END(ftrace_caller)
18885 +ENDPROC(ftrace_caller)
18886
18887 ENTRY(ftrace_regs_caller)
18888 pushf /* push flags before compare (in cs location) */
18889 @@ -1197,7 +1436,7 @@ trace:
18890 popl %ecx
18891 popl %eax
18892 jmp ftrace_stub
18893 -END(mcount)
18894 +ENDPROC(mcount)
18895 #endif /* CONFIG_DYNAMIC_FTRACE */
18896 #endif /* CONFIG_FUNCTION_TRACER */
18897
18898 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18899 popl %ecx
18900 popl %eax
18901 ret
18902 -END(ftrace_graph_caller)
18903 +ENDPROC(ftrace_graph_caller)
18904
18905 .globl return_to_handler
18906 return_to_handler:
18907 @@ -1271,15 +1510,18 @@ error_code:
18908 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18909 REG_TO_PTGS %ecx
18910 SET_KERNEL_GS %ecx
18911 - movl $(__USER_DS), %ecx
18912 + movl $(__KERNEL_DS), %ecx
18913 movl %ecx, %ds
18914 movl %ecx, %es
18915 +
18916 + pax_enter_kernel
18917 +
18918 TRACE_IRQS_OFF
18919 movl %esp,%eax # pt_regs pointer
18920 call *%edi
18921 jmp ret_from_exception
18922 CFI_ENDPROC
18923 -END(page_fault)
18924 +ENDPROC(page_fault)
18925
18926 /*
18927 * Debug traps and NMI can happen at the one SYSENTER instruction
18928 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18929 call do_debug
18930 jmp ret_from_exception
18931 CFI_ENDPROC
18932 -END(debug)
18933 +ENDPROC(debug)
18934
18935 /*
18936 * NMI is doubly nasty. It can happen _while_ we're handling
18937 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18938 xorl %edx,%edx # zero error code
18939 movl %esp,%eax # pt_regs pointer
18940 call do_nmi
18941 +
18942 + pax_exit_kernel
18943 +
18944 jmp restore_all_notrace
18945 CFI_ENDPROC
18946
18947 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18948 FIXUP_ESPFIX_STACK # %eax == %esp
18949 xorl %edx,%edx # zero error code
18950 call do_nmi
18951 +
18952 + pax_exit_kernel
18953 +
18954 RESTORE_REGS
18955 lss 12+4(%esp), %esp # back to espfix stack
18956 CFI_ADJUST_CFA_OFFSET -24
18957 jmp irq_return
18958 CFI_ENDPROC
18959 -END(nmi)
18960 +ENDPROC(nmi)
18961
18962 ENTRY(int3)
18963 RING0_INT_FRAME
18964 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18965 call do_int3
18966 jmp ret_from_exception
18967 CFI_ENDPROC
18968 -END(int3)
18969 +ENDPROC(int3)
18970
18971 ENTRY(general_protection)
18972 RING0_EC_FRAME
18973 pushl_cfi $do_general_protection
18974 jmp error_code
18975 CFI_ENDPROC
18976 -END(general_protection)
18977 +ENDPROC(general_protection)
18978
18979 #ifdef CONFIG_KVM_GUEST
18980 ENTRY(async_page_fault)
18981 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18982 pushl_cfi $do_async_page_fault
18983 jmp error_code
18984 CFI_ENDPROC
18985 -END(async_page_fault)
18986 +ENDPROC(async_page_fault)
18987 #endif
18988
18989 /*
18990 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18991 index c1d01e6..7f633850 100644
18992 --- a/arch/x86/kernel/entry_64.S
18993 +++ b/arch/x86/kernel/entry_64.S
18994 @@ -59,6 +59,8 @@
18995 #include <asm/context_tracking.h>
18996 #include <asm/smap.h>
18997 #include <linux/err.h>
18998 +#include <asm/pgtable.h>
18999 +#include <asm/alternative-asm.h>
19000
19001 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19002 #include <linux/elf-em.h>
19003 @@ -80,8 +82,9 @@
19004 #ifdef CONFIG_DYNAMIC_FTRACE
19005
19006 ENTRY(function_hook)
19007 + pax_force_retaddr
19008 retq
19009 -END(function_hook)
19010 +ENDPROC(function_hook)
19011
19012 /* skip is set if stack has been adjusted */
19013 .macro ftrace_caller_setup skip=0
19014 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19015 #endif
19016
19017 GLOBAL(ftrace_stub)
19018 + pax_force_retaddr
19019 retq
19020 -END(ftrace_caller)
19021 +ENDPROC(ftrace_caller)
19022
19023 ENTRY(ftrace_regs_caller)
19024 /* Save the current flags before compare (in SS location)*/
19025 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19026 popfq
19027 jmp ftrace_stub
19028
19029 -END(ftrace_regs_caller)
19030 +ENDPROC(ftrace_regs_caller)
19031
19032
19033 #else /* ! CONFIG_DYNAMIC_FTRACE */
19034 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19035 #endif
19036
19037 GLOBAL(ftrace_stub)
19038 + pax_force_retaddr
19039 retq
19040
19041 trace:
19042 @@ -225,12 +230,13 @@ trace:
19043 #endif
19044 subq $MCOUNT_INSN_SIZE, %rdi
19045
19046 + pax_force_fptr ftrace_trace_function
19047 call *ftrace_trace_function
19048
19049 MCOUNT_RESTORE_FRAME
19050
19051 jmp ftrace_stub
19052 -END(function_hook)
19053 +ENDPROC(function_hook)
19054 #endif /* CONFIG_DYNAMIC_FTRACE */
19055 #endif /* CONFIG_FUNCTION_TRACER */
19056
19057 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19058
19059 MCOUNT_RESTORE_FRAME
19060
19061 + pax_force_retaddr
19062 retq
19063 -END(ftrace_graph_caller)
19064 +ENDPROC(ftrace_graph_caller)
19065
19066 GLOBAL(return_to_handler)
19067 subq $24, %rsp
19068 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19069 movq 8(%rsp), %rdx
19070 movq (%rsp), %rax
19071 addq $24, %rsp
19072 + pax_force_fptr %rdi
19073 jmp *%rdi
19074 +ENDPROC(return_to_handler)
19075 #endif
19076
19077
19078 @@ -284,6 +293,309 @@ ENTRY(native_usergs_sysret64)
19079 ENDPROC(native_usergs_sysret64)
19080 #endif /* CONFIG_PARAVIRT */
19081
19082 + .macro ljmpq sel, off
19083 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19084 + .byte 0x48; ljmp *1234f(%rip)
19085 + .pushsection .rodata
19086 + .align 16
19087 + 1234: .quad \off; .word \sel
19088 + .popsection
19089 +#else
19090 + pushq $\sel
19091 + pushq $\off
19092 + lretq
19093 +#endif
19094 + .endm
19095 +
19096 + .macro pax_enter_kernel
19097 + pax_set_fptr_mask
19098 +#ifdef CONFIG_PAX_KERNEXEC
19099 + call pax_enter_kernel
19100 +#endif
19101 + .endm
19102 +
19103 + .macro pax_exit_kernel
19104 +#ifdef CONFIG_PAX_KERNEXEC
19105 + call pax_exit_kernel
19106 +#endif
19107 + .endm
19108 +
19109 +#ifdef CONFIG_PAX_KERNEXEC
19110 +ENTRY(pax_enter_kernel)
19111 + pushq %rdi
19112 +
19113 +#ifdef CONFIG_PARAVIRT
19114 + PV_SAVE_REGS(CLBR_RDI)
19115 +#endif
19116 +
19117 + GET_CR0_INTO_RDI
19118 + bts $16,%rdi
19119 + jnc 3f
19120 + mov %cs,%edi
19121 + cmp $__KERNEL_CS,%edi
19122 + jnz 2f
19123 +1:
19124 +
19125 +#ifdef CONFIG_PARAVIRT
19126 + PV_RESTORE_REGS(CLBR_RDI)
19127 +#endif
19128 +
19129 + popq %rdi
19130 + pax_force_retaddr
19131 + retq
19132 +
19133 +2: ljmpq __KERNEL_CS,1b
19134 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19135 +4: SET_RDI_INTO_CR0
19136 + jmp 1b
19137 +ENDPROC(pax_enter_kernel)
19138 +
19139 +ENTRY(pax_exit_kernel)
19140 + pushq %rdi
19141 +
19142 +#ifdef CONFIG_PARAVIRT
19143 + PV_SAVE_REGS(CLBR_RDI)
19144 +#endif
19145 +
19146 + mov %cs,%rdi
19147 + cmp $__KERNEXEC_KERNEL_CS,%edi
19148 + jz 2f
19149 + GET_CR0_INTO_RDI
19150 + bts $16,%rdi
19151 + jnc 4f
19152 +1:
19153 +
19154 +#ifdef CONFIG_PARAVIRT
19155 + PV_RESTORE_REGS(CLBR_RDI);
19156 +#endif
19157 +
19158 + popq %rdi
19159 + pax_force_retaddr
19160 + retq
19161 +
19162 +2: GET_CR0_INTO_RDI
19163 + btr $16,%rdi
19164 + jnc 4f
19165 + ljmpq __KERNEL_CS,3f
19166 +3: SET_RDI_INTO_CR0
19167 + jmp 1b
19168 +4: ud2
19169 + jmp 4b
19170 +ENDPROC(pax_exit_kernel)
19171 +#endif
19172 +
19173 + .macro pax_enter_kernel_user
19174 + pax_set_fptr_mask
19175 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19176 + call pax_enter_kernel_user
19177 +#endif
19178 + .endm
19179 +
19180 + .macro pax_exit_kernel_user
19181 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19182 + call pax_exit_kernel_user
19183 +#endif
19184 +#ifdef CONFIG_PAX_RANDKSTACK
19185 + pushq %rax
19186 + pushq %r11
19187 + call pax_randomize_kstack
19188 + popq %r11
19189 + popq %rax
19190 +#endif
19191 + .endm
19192 +
19193 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19194 +ENTRY(pax_enter_kernel_user)
19195 + pushq %rdi
19196 + pushq %rbx
19197 +
19198 +#ifdef CONFIG_PARAVIRT
19199 + PV_SAVE_REGS(CLBR_RDI)
19200 +#endif
19201 +
19202 + GET_CR3_INTO_RDI
19203 + mov %rdi,%rbx
19204 + add $__START_KERNEL_map,%rbx
19205 + sub phys_base(%rip),%rbx
19206 +
19207 +#ifdef CONFIG_PARAVIRT
19208 + cmpl $0, pv_info+PARAVIRT_enabled
19209 + jz 1f
19210 + pushq %rdi
19211 + i = 0
19212 + .rept USER_PGD_PTRS
19213 + mov i*8(%rbx),%rsi
19214 + mov $0,%sil
19215 + lea i*8(%rbx),%rdi
19216 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19217 + i = i + 1
19218 + .endr
19219 + popq %rdi
19220 + jmp 2f
19221 +1:
19222 +#endif
19223 +
19224 + i = 0
19225 + .rept USER_PGD_PTRS
19226 + movb $0,i*8(%rbx)
19227 + i = i + 1
19228 + .endr
19229 +
19230 +#ifdef CONFIG_PARAVIRT
19231 +2:
19232 +#endif
19233 + SET_RDI_INTO_CR3
19234 +
19235 +#ifdef CONFIG_PAX_KERNEXEC
19236 + GET_CR0_INTO_RDI
19237 + bts $16,%rdi
19238 + SET_RDI_INTO_CR0
19239 +#endif
19240 +
19241 +#ifdef CONFIG_PARAVIRT
19242 + PV_RESTORE_REGS(CLBR_RDI)
19243 +#endif
19244 +
19245 + popq %rbx
19246 + popq %rdi
19247 + pax_force_retaddr
19248 + retq
19249 +ENDPROC(pax_enter_kernel_user)
19250 +
19251 +ENTRY(pax_exit_kernel_user)
19252 + pushq %rdi
19253 + pushq %rbx
19254 +
19255 +#ifdef CONFIG_PARAVIRT
19256 + PV_SAVE_REGS(CLBR_RDI)
19257 +#endif
19258 +
19259 +#ifdef CONFIG_PAX_KERNEXEC
19260 + GET_CR0_INTO_RDI
19261 + btr $16,%rdi
19262 + jnc 3f
19263 + SET_RDI_INTO_CR0
19264 +#endif
19265 +
19266 + GET_CR3_INTO_RDI
19267 + mov %rdi,%rbx
19268 + add $__START_KERNEL_map,%rbx
19269 + sub phys_base(%rip),%rbx
19270 +
19271 +#ifdef CONFIG_PARAVIRT
19272 + cmpl $0, pv_info+PARAVIRT_enabled
19273 + jz 1f
19274 + i = 0
19275 + .rept USER_PGD_PTRS
19276 + mov i*8(%rbx),%rsi
19277 + mov $0x67,%sil
19278 + lea i*8(%rbx),%rdi
19279 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19280 + i = i + 1
19281 + .endr
19282 + jmp 2f
19283 +1:
19284 +#endif
19285 +
19286 + i = 0
19287 + .rept USER_PGD_PTRS
19288 + movb $0x67,i*8(%rbx)
19289 + i = i + 1
19290 + .endr
19291 +
19292 +#ifdef CONFIG_PARAVIRT
19293 +2: PV_RESTORE_REGS(CLBR_RDI)
19294 +#endif
19295 +
19296 + popq %rbx
19297 + popq %rdi
19298 + pax_force_retaddr
19299 + retq
19300 +3: ud2
19301 + jmp 3b
19302 +ENDPROC(pax_exit_kernel_user)
19303 +#endif
19304 +
19305 + .macro pax_enter_kernel_nmi
19306 + pax_set_fptr_mask
19307 +
19308 +#ifdef CONFIG_PAX_KERNEXEC
19309 + GET_CR0_INTO_RDI
19310 + bts $16,%rdi
19311 + jc 110f
19312 + SET_RDI_INTO_CR0
19313 + or $2,%ebx
19314 +110:
19315 +#endif
19316 + .endm
19317 +
19318 + .macro pax_exit_kernel_nmi
19319 +#ifdef CONFIG_PAX_KERNEXEC
19320 + btr $1,%ebx
19321 + jnc 110f
19322 + GET_CR0_INTO_RDI
19323 + btr $16,%rdi
19324 + SET_RDI_INTO_CR0
19325 +110:
19326 +#endif
19327 + .endm
19328 +
19329 +.macro pax_erase_kstack
19330 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19331 + call pax_erase_kstack
19332 +#endif
19333 +.endm
19334 +
19335 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19336 +ENTRY(pax_erase_kstack)
19337 + pushq %rdi
19338 + pushq %rcx
19339 + pushq %rax
19340 + pushq %r11
19341 +
19342 + GET_THREAD_INFO(%r11)
19343 + mov TI_lowest_stack(%r11), %rdi
19344 + mov $-0xBEEF, %rax
19345 + std
19346 +
19347 +1: mov %edi, %ecx
19348 + and $THREAD_SIZE_asm - 1, %ecx
19349 + shr $3, %ecx
19350 + repne scasq
19351 + jecxz 2f
19352 +
19353 + cmp $2*8, %ecx
19354 + jc 2f
19355 +
19356 + mov $2*8, %ecx
19357 + repe scasq
19358 + jecxz 2f
19359 + jne 1b
19360 +
19361 +2: cld
19362 + mov %esp, %ecx
19363 + sub %edi, %ecx
19364 +
19365 + cmp $THREAD_SIZE_asm, %rcx
19366 + jb 3f
19367 + ud2
19368 +3:
19369 +
19370 + shr $3, %ecx
19371 + rep stosq
19372 +
19373 + mov TI_task_thread_sp0(%r11), %rdi
19374 + sub $256, %rdi
19375 + mov %rdi, TI_lowest_stack(%r11)
19376 +
19377 + popq %r11
19378 + popq %rax
19379 + popq %rcx
19380 + popq %rdi
19381 + pax_force_retaddr
19382 + ret
19383 +ENDPROC(pax_erase_kstack)
19384 +#endif
19385
19386 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19387 #ifdef CONFIG_TRACE_IRQFLAGS
19388 @@ -375,8 +687,8 @@ ENDPROC(native_usergs_sysret64)
19389 .endm
19390
19391 .macro UNFAKE_STACK_FRAME
19392 - addq $8*6, %rsp
19393 - CFI_ADJUST_CFA_OFFSET -(6*8)
19394 + addq $8*6 + ARG_SKIP, %rsp
19395 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19396 .endm
19397
19398 /*
19399 @@ -463,7 +775,7 @@ ENDPROC(native_usergs_sysret64)
19400 movq %rsp, %rsi
19401
19402 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19403 - testl $3, CS-RBP(%rsi)
19404 + testb $3, CS-RBP(%rsi)
19405 je 1f
19406 SWAPGS
19407 /*
19408 @@ -498,9 +810,10 @@ ENTRY(save_rest)
19409 movq_cfi r15, R15+16
19410 movq %r11, 8(%rsp) /* return address */
19411 FIXUP_TOP_OF_STACK %r11, 16
19412 + pax_force_retaddr
19413 ret
19414 CFI_ENDPROC
19415 -END(save_rest)
19416 +ENDPROC(save_rest)
19417
19418 /* save complete stack frame */
19419 .pushsection .kprobes.text, "ax"
19420 @@ -529,9 +842,10 @@ ENTRY(save_paranoid)
19421 js 1f /* negative -> in kernel */
19422 SWAPGS
19423 xorl %ebx,%ebx
19424 -1: ret
19425 +1: pax_force_retaddr_bts
19426 + ret
19427 CFI_ENDPROC
19428 -END(save_paranoid)
19429 +ENDPROC(save_paranoid)
19430 .popsection
19431
19432 /*
19433 @@ -553,7 +867,7 @@ ENTRY(ret_from_fork)
19434
19435 RESTORE_REST
19436
19437 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19438 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19439 jz 1f
19440
19441 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19442 @@ -571,7 +885,7 @@ ENTRY(ret_from_fork)
19443 RESTORE_REST
19444 jmp int_ret_from_sys_call
19445 CFI_ENDPROC
19446 -END(ret_from_fork)
19447 +ENDPROC(ret_from_fork)
19448
19449 /*
19450 * System call entry. Up to 6 arguments in registers are supported.
19451 @@ -608,7 +922,7 @@ END(ret_from_fork)
19452 ENTRY(system_call)
19453 CFI_STARTPROC simple
19454 CFI_SIGNAL_FRAME
19455 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19456 + CFI_DEF_CFA rsp,0
19457 CFI_REGISTER rip,rcx
19458 /*CFI_REGISTER rflags,r11*/
19459 SWAPGS_UNSAFE_STACK
19460 @@ -621,16 +935,23 @@ GLOBAL(system_call_after_swapgs)
19461
19462 movq %rsp,PER_CPU_VAR(old_rsp)
19463 movq PER_CPU_VAR(kernel_stack),%rsp
19464 + SAVE_ARGS 8*6,0
19465 + pax_enter_kernel_user
19466 +
19467 +#ifdef CONFIG_PAX_RANDKSTACK
19468 + pax_erase_kstack
19469 +#endif
19470 +
19471 /*
19472 * No need to follow this irqs off/on section - it's straight
19473 * and short:
19474 */
19475 ENABLE_INTERRUPTS(CLBR_NONE)
19476 - SAVE_ARGS 8,0
19477 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19478 movq %rcx,RIP-ARGOFFSET(%rsp)
19479 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19480 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19481 + GET_THREAD_INFO(%rcx)
19482 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19483 jnz tracesys
19484 system_call_fastpath:
19485 #if __SYSCALL_MASK == ~0
19486 @@ -640,7 +961,7 @@ system_call_fastpath:
19487 cmpl $__NR_syscall_max,%eax
19488 #endif
19489 ja badsys
19490 - movq %r10,%rcx
19491 + movq R10-ARGOFFSET(%rsp),%rcx
19492 call *sys_call_table(,%rax,8) # XXX: rip relative
19493 movq %rax,RAX-ARGOFFSET(%rsp)
19494 /*
19495 @@ -654,10 +975,13 @@ sysret_check:
19496 LOCKDEP_SYS_EXIT
19497 DISABLE_INTERRUPTS(CLBR_NONE)
19498 TRACE_IRQS_OFF
19499 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19500 + GET_THREAD_INFO(%rcx)
19501 + movl TI_flags(%rcx),%edx
19502 andl %edi,%edx
19503 jnz sysret_careful
19504 CFI_REMEMBER_STATE
19505 + pax_exit_kernel_user
19506 + pax_erase_kstack
19507 /*
19508 * sysretq will re-enable interrupts:
19509 */
19510 @@ -709,14 +1033,18 @@ badsys:
19511 * jump back to the normal fast path.
19512 */
19513 auditsys:
19514 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19515 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19516 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19517 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19518 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19519 movq %rax,%rsi /* 2nd arg: syscall number */
19520 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19521 call __audit_syscall_entry
19522 +
19523 + pax_erase_kstack
19524 +
19525 LOAD_ARGS 0 /* reload call-clobbered registers */
19526 + pax_set_fptr_mask
19527 jmp system_call_fastpath
19528
19529 /*
19530 @@ -737,7 +1065,7 @@ sysret_audit:
19531 /* Do syscall tracing */
19532 tracesys:
19533 #ifdef CONFIG_AUDITSYSCALL
19534 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19535 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19536 jz auditsys
19537 #endif
19538 SAVE_REST
19539 @@ -745,12 +1073,16 @@ tracesys:
19540 FIXUP_TOP_OF_STACK %rdi
19541 movq %rsp,%rdi
19542 call syscall_trace_enter
19543 +
19544 + pax_erase_kstack
19545 +
19546 /*
19547 * Reload arg registers from stack in case ptrace changed them.
19548 * We don't reload %rax because syscall_trace_enter() returned
19549 * the value it wants us to use in the table lookup.
19550 */
19551 LOAD_ARGS ARGOFFSET, 1
19552 + pax_set_fptr_mask
19553 RESTORE_REST
19554 #if __SYSCALL_MASK == ~0
19555 cmpq $__NR_syscall_max,%rax
19556 @@ -759,7 +1091,7 @@ tracesys:
19557 cmpl $__NR_syscall_max,%eax
19558 #endif
19559 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19560 - movq %r10,%rcx /* fixup for C */
19561 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19562 call *sys_call_table(,%rax,8)
19563 movq %rax,RAX-ARGOFFSET(%rsp)
19564 /* Use IRET because user could have changed frame */
19565 @@ -780,7 +1112,9 @@ GLOBAL(int_with_check)
19566 andl %edi,%edx
19567 jnz int_careful
19568 andl $~TS_COMPAT,TI_status(%rcx)
19569 - jmp retint_swapgs
19570 + pax_exit_kernel_user
19571 + pax_erase_kstack
19572 + jmp retint_swapgs_pax
19573
19574 /* Either reschedule or signal or syscall exit tracking needed. */
19575 /* First do a reschedule test. */
19576 @@ -826,7 +1160,7 @@ int_restore_rest:
19577 TRACE_IRQS_OFF
19578 jmp int_with_check
19579 CFI_ENDPROC
19580 -END(system_call)
19581 +ENDPROC(system_call)
19582
19583 .macro FORK_LIKE func
19584 ENTRY(stub_\func)
19585 @@ -839,9 +1173,10 @@ ENTRY(stub_\func)
19586 DEFAULT_FRAME 0 8 /* offset 8: return address */
19587 call sys_\func
19588 RESTORE_TOP_OF_STACK %r11, 8
19589 + pax_force_retaddr
19590 ret $REST_SKIP /* pop extended registers */
19591 CFI_ENDPROC
19592 -END(stub_\func)
19593 +ENDPROC(stub_\func)
19594 .endm
19595
19596 .macro FIXED_FRAME label,func
19597 @@ -851,9 +1186,10 @@ ENTRY(\label)
19598 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19599 call \func
19600 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19601 + pax_force_retaddr
19602 ret
19603 CFI_ENDPROC
19604 -END(\label)
19605 +ENDPROC(\label)
19606 .endm
19607
19608 FORK_LIKE clone
19609 @@ -870,9 +1206,10 @@ ENTRY(ptregscall_common)
19610 movq_cfi_restore R12+8, r12
19611 movq_cfi_restore RBP+8, rbp
19612 movq_cfi_restore RBX+8, rbx
19613 + pax_force_retaddr
19614 ret $REST_SKIP /* pop extended registers */
19615 CFI_ENDPROC
19616 -END(ptregscall_common)
19617 +ENDPROC(ptregscall_common)
19618
19619 ENTRY(stub_execve)
19620 CFI_STARTPROC
19621 @@ -885,7 +1222,7 @@ ENTRY(stub_execve)
19622 RESTORE_REST
19623 jmp int_ret_from_sys_call
19624 CFI_ENDPROC
19625 -END(stub_execve)
19626 +ENDPROC(stub_execve)
19627
19628 /*
19629 * sigreturn is special because it needs to restore all registers on return.
19630 @@ -902,7 +1239,7 @@ ENTRY(stub_rt_sigreturn)
19631 RESTORE_REST
19632 jmp int_ret_from_sys_call
19633 CFI_ENDPROC
19634 -END(stub_rt_sigreturn)
19635 +ENDPROC(stub_rt_sigreturn)
19636
19637 #ifdef CONFIG_X86_X32_ABI
19638 ENTRY(stub_x32_rt_sigreturn)
19639 @@ -916,7 +1253,7 @@ ENTRY(stub_x32_rt_sigreturn)
19640 RESTORE_REST
19641 jmp int_ret_from_sys_call
19642 CFI_ENDPROC
19643 -END(stub_x32_rt_sigreturn)
19644 +ENDPROC(stub_x32_rt_sigreturn)
19645
19646 ENTRY(stub_x32_execve)
19647 CFI_STARTPROC
19648 @@ -930,7 +1267,7 @@ ENTRY(stub_x32_execve)
19649 RESTORE_REST
19650 jmp int_ret_from_sys_call
19651 CFI_ENDPROC
19652 -END(stub_x32_execve)
19653 +ENDPROC(stub_x32_execve)
19654
19655 #endif
19656
19657 @@ -967,7 +1304,7 @@ vector=vector+1
19658 2: jmp common_interrupt
19659 .endr
19660 CFI_ENDPROC
19661 -END(irq_entries_start)
19662 +ENDPROC(irq_entries_start)
19663
19664 .previous
19665 END(interrupt)
19666 @@ -987,6 +1324,16 @@ END(interrupt)
19667 subq $ORIG_RAX-RBP, %rsp
19668 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19669 SAVE_ARGS_IRQ
19670 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19671 + testb $3, CS(%rdi)
19672 + jnz 1f
19673 + pax_enter_kernel
19674 + jmp 2f
19675 +1: pax_enter_kernel_user
19676 +2:
19677 +#else
19678 + pax_enter_kernel
19679 +#endif
19680 call \func
19681 .endm
19682
19683 @@ -1019,7 +1366,7 @@ ret_from_intr:
19684
19685 exit_intr:
19686 GET_THREAD_INFO(%rcx)
19687 - testl $3,CS-ARGOFFSET(%rsp)
19688 + testb $3,CS-ARGOFFSET(%rsp)
19689 je retint_kernel
19690
19691 /* Interrupt came from user space */
19692 @@ -1041,12 +1388,16 @@ retint_swapgs: /* return to user-space */
19693 * The iretq could re-enable interrupts:
19694 */
19695 DISABLE_INTERRUPTS(CLBR_ANY)
19696 + pax_exit_kernel_user
19697 +retint_swapgs_pax:
19698 TRACE_IRQS_IRETQ
19699 SWAPGS
19700 jmp restore_args
19701
19702 retint_restore_args: /* return to kernel space */
19703 DISABLE_INTERRUPTS(CLBR_ANY)
19704 + pax_exit_kernel
19705 + pax_force_retaddr (RIP-ARGOFFSET)
19706 /*
19707 * The iretq could re-enable interrupts:
19708 */
19709 @@ -1129,7 +1480,7 @@ ENTRY(retint_kernel)
19710 #endif
19711
19712 CFI_ENDPROC
19713 -END(common_interrupt)
19714 +ENDPROC(common_interrupt)
19715 /*
19716 * End of kprobes section
19717 */
19718 @@ -1147,7 +1498,7 @@ ENTRY(\sym)
19719 interrupt \do_sym
19720 jmp ret_from_intr
19721 CFI_ENDPROC
19722 -END(\sym)
19723 +ENDPROC(\sym)
19724 .endm
19725
19726 #ifdef CONFIG_SMP
19727 @@ -1203,12 +1554,22 @@ ENTRY(\sym)
19728 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19729 call error_entry
19730 DEFAULT_FRAME 0
19731 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19732 + testb $3, CS(%rsp)
19733 + jnz 1f
19734 + pax_enter_kernel
19735 + jmp 2f
19736 +1: pax_enter_kernel_user
19737 +2:
19738 +#else
19739 + pax_enter_kernel
19740 +#endif
19741 movq %rsp,%rdi /* pt_regs pointer */
19742 xorl %esi,%esi /* no error code */
19743 call \do_sym
19744 jmp error_exit /* %ebx: no swapgs flag */
19745 CFI_ENDPROC
19746 -END(\sym)
19747 +ENDPROC(\sym)
19748 .endm
19749
19750 .macro paranoidzeroentry sym do_sym
19751 @@ -1221,15 +1582,25 @@ ENTRY(\sym)
19752 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19753 call save_paranoid
19754 TRACE_IRQS_OFF
19755 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19756 + testb $3, CS(%rsp)
19757 + jnz 1f
19758 + pax_enter_kernel
19759 + jmp 2f
19760 +1: pax_enter_kernel_user
19761 +2:
19762 +#else
19763 + pax_enter_kernel
19764 +#endif
19765 movq %rsp,%rdi /* pt_regs pointer */
19766 xorl %esi,%esi /* no error code */
19767 call \do_sym
19768 jmp paranoid_exit /* %ebx: no swapgs flag */
19769 CFI_ENDPROC
19770 -END(\sym)
19771 +ENDPROC(\sym)
19772 .endm
19773
19774 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19775 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19776 .macro paranoidzeroentry_ist sym do_sym ist
19777 ENTRY(\sym)
19778 INTR_FRAME
19779 @@ -1240,14 +1611,30 @@ ENTRY(\sym)
19780 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19781 call save_paranoid
19782 TRACE_IRQS_OFF_DEBUG
19783 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19784 + testb $3, CS(%rsp)
19785 + jnz 1f
19786 + pax_enter_kernel
19787 + jmp 2f
19788 +1: pax_enter_kernel_user
19789 +2:
19790 +#else
19791 + pax_enter_kernel
19792 +#endif
19793 movq %rsp,%rdi /* pt_regs pointer */
19794 xorl %esi,%esi /* no error code */
19795 +#ifdef CONFIG_SMP
19796 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19797 + lea init_tss(%r12), %r12
19798 +#else
19799 + lea init_tss(%rip), %r12
19800 +#endif
19801 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19802 call \do_sym
19803 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19804 jmp paranoid_exit /* %ebx: no swapgs flag */
19805 CFI_ENDPROC
19806 -END(\sym)
19807 +ENDPROC(\sym)
19808 .endm
19809
19810 .macro errorentry sym do_sym
19811 @@ -1259,13 +1646,23 @@ ENTRY(\sym)
19812 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19813 call error_entry
19814 DEFAULT_FRAME 0
19815 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19816 + testb $3, CS(%rsp)
19817 + jnz 1f
19818 + pax_enter_kernel
19819 + jmp 2f
19820 +1: pax_enter_kernel_user
19821 +2:
19822 +#else
19823 + pax_enter_kernel
19824 +#endif
19825 movq %rsp,%rdi /* pt_regs pointer */
19826 movq ORIG_RAX(%rsp),%rsi /* get error code */
19827 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19828 call \do_sym
19829 jmp error_exit /* %ebx: no swapgs flag */
19830 CFI_ENDPROC
19831 -END(\sym)
19832 +ENDPROC(\sym)
19833 .endm
19834
19835 /* error code is on the stack already */
19836 @@ -1279,13 +1676,23 @@ ENTRY(\sym)
19837 call save_paranoid
19838 DEFAULT_FRAME 0
19839 TRACE_IRQS_OFF
19840 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19841 + testb $3, CS(%rsp)
19842 + jnz 1f
19843 + pax_enter_kernel
19844 + jmp 2f
19845 +1: pax_enter_kernel_user
19846 +2:
19847 +#else
19848 + pax_enter_kernel
19849 +#endif
19850 movq %rsp,%rdi /* pt_regs pointer */
19851 movq ORIG_RAX(%rsp),%rsi /* get error code */
19852 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19853 call \do_sym
19854 jmp paranoid_exit /* %ebx: no swapgs flag */
19855 CFI_ENDPROC
19856 -END(\sym)
19857 +ENDPROC(\sym)
19858 .endm
19859
19860 zeroentry divide_error do_divide_error
19861 @@ -1315,9 +1722,10 @@ gs_change:
19862 2: mfence /* workaround */
19863 SWAPGS
19864 popfq_cfi
19865 + pax_force_retaddr
19866 ret
19867 CFI_ENDPROC
19868 -END(native_load_gs_index)
19869 +ENDPROC(native_load_gs_index)
19870
19871 _ASM_EXTABLE(gs_change,bad_gs)
19872 .section .fixup,"ax"
19873 @@ -1345,9 +1753,10 @@ ENTRY(call_softirq)
19874 CFI_DEF_CFA_REGISTER rsp
19875 CFI_ADJUST_CFA_OFFSET -8
19876 decl PER_CPU_VAR(irq_count)
19877 + pax_force_retaddr
19878 ret
19879 CFI_ENDPROC
19880 -END(call_softirq)
19881 +ENDPROC(call_softirq)
19882
19883 #ifdef CONFIG_XEN
19884 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19885 @@ -1385,7 +1794,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19886 decl PER_CPU_VAR(irq_count)
19887 jmp error_exit
19888 CFI_ENDPROC
19889 -END(xen_do_hypervisor_callback)
19890 +ENDPROC(xen_do_hypervisor_callback)
19891
19892 /*
19893 * Hypervisor uses this for application faults while it executes.
19894 @@ -1444,7 +1853,7 @@ ENTRY(xen_failsafe_callback)
19895 SAVE_ALL
19896 jmp error_exit
19897 CFI_ENDPROC
19898 -END(xen_failsafe_callback)
19899 +ENDPROC(xen_failsafe_callback)
19900
19901 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19902 xen_hvm_callback_vector xen_evtchn_do_upcall
19903 @@ -1498,16 +1907,31 @@ ENTRY(paranoid_exit)
19904 TRACE_IRQS_OFF_DEBUG
19905 testl %ebx,%ebx /* swapgs needed? */
19906 jnz paranoid_restore
19907 - testl $3,CS(%rsp)
19908 + testb $3,CS(%rsp)
19909 jnz paranoid_userspace
19910 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19911 + pax_exit_kernel
19912 + TRACE_IRQS_IRETQ 0
19913 + SWAPGS_UNSAFE_STACK
19914 + RESTORE_ALL 8
19915 + pax_force_retaddr_bts
19916 + jmp irq_return
19917 +#endif
19918 paranoid_swapgs:
19919 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19920 + pax_exit_kernel_user
19921 +#else
19922 + pax_exit_kernel
19923 +#endif
19924 TRACE_IRQS_IRETQ 0
19925 SWAPGS_UNSAFE_STACK
19926 RESTORE_ALL 8
19927 jmp irq_return
19928 paranoid_restore:
19929 + pax_exit_kernel
19930 TRACE_IRQS_IRETQ_DEBUG 0
19931 RESTORE_ALL 8
19932 + pax_force_retaddr_bts
19933 jmp irq_return
19934 paranoid_userspace:
19935 GET_THREAD_INFO(%rcx)
19936 @@ -1536,7 +1960,7 @@ paranoid_schedule:
19937 TRACE_IRQS_OFF
19938 jmp paranoid_userspace
19939 CFI_ENDPROC
19940 -END(paranoid_exit)
19941 +ENDPROC(paranoid_exit)
19942
19943 /*
19944 * Exception entry point. This expects an error code/orig_rax on the stack.
19945 @@ -1563,12 +1987,13 @@ ENTRY(error_entry)
19946 movq_cfi r14, R14+8
19947 movq_cfi r15, R15+8
19948 xorl %ebx,%ebx
19949 - testl $3,CS+8(%rsp)
19950 + testb $3,CS+8(%rsp)
19951 je error_kernelspace
19952 error_swapgs:
19953 SWAPGS
19954 error_sti:
19955 TRACE_IRQS_OFF
19956 + pax_force_retaddr_bts
19957 ret
19958
19959 /*
19960 @@ -1595,7 +2020,7 @@ bstep_iret:
19961 movq %rcx,RIP+8(%rsp)
19962 jmp error_swapgs
19963 CFI_ENDPROC
19964 -END(error_entry)
19965 +ENDPROC(error_entry)
19966
19967
19968 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19969 @@ -1615,7 +2040,7 @@ ENTRY(error_exit)
19970 jnz retint_careful
19971 jmp retint_swapgs
19972 CFI_ENDPROC
19973 -END(error_exit)
19974 +ENDPROC(error_exit)
19975
19976 /*
19977 * Test if a given stack is an NMI stack or not.
19978 @@ -1673,9 +2098,11 @@ ENTRY(nmi)
19979 * If %cs was not the kernel segment, then the NMI triggered in user
19980 * space, which means it is definitely not nested.
19981 */
19982 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19983 + je 1f
19984 cmpl $__KERNEL_CS, 16(%rsp)
19985 jne first_nmi
19986 -
19987 +1:
19988 /*
19989 * Check the special variable on the stack to see if NMIs are
19990 * executing.
19991 @@ -1709,8 +2136,7 @@ nested_nmi:
19992
19993 1:
19994 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
19995 - leaq -1*8(%rsp), %rdx
19996 - movq %rdx, %rsp
19997 + subq $8, %rsp
19998 CFI_ADJUST_CFA_OFFSET 1*8
19999 leaq -10*8(%rsp), %rdx
20000 pushq_cfi $__KERNEL_DS
20001 @@ -1728,6 +2154,7 @@ nested_nmi_out:
20002 CFI_RESTORE rdx
20003
20004 /* No need to check faults here */
20005 +# pax_force_retaddr_bts
20006 INTERRUPT_RETURN
20007
20008 CFI_RESTORE_STATE
20009 @@ -1844,6 +2271,8 @@ end_repeat_nmi:
20010 */
20011 movq %cr2, %r12
20012
20013 + pax_enter_kernel_nmi
20014 +
20015 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20016 movq %rsp,%rdi
20017 movq $-1,%rsi
20018 @@ -1856,26 +2285,31 @@ end_repeat_nmi:
20019 movq %r12, %cr2
20020 1:
20021
20022 - testl %ebx,%ebx /* swapgs needed? */
20023 + testl $1,%ebx /* swapgs needed? */
20024 jnz nmi_restore
20025 nmi_swapgs:
20026 SWAPGS_UNSAFE_STACK
20027 nmi_restore:
20028 + pax_exit_kernel_nmi
20029 /* Pop the extra iret frame at once */
20030 RESTORE_ALL 6*8
20031 + testb $3, 8(%rsp)
20032 + jnz 1f
20033 + pax_force_retaddr_bts
20034 +1:
20035
20036 /* Clear the NMI executing stack variable */
20037 movq $0, 5*8(%rsp)
20038 jmp irq_return
20039 CFI_ENDPROC
20040 -END(nmi)
20041 +ENDPROC(nmi)
20042
20043 ENTRY(ignore_sysret)
20044 CFI_STARTPROC
20045 mov $-ENOSYS,%eax
20046 sysret
20047 CFI_ENDPROC
20048 -END(ignore_sysret)
20049 +ENDPROC(ignore_sysret)
20050
20051 /*
20052 * End of kprobes section
20053 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20054 index 42a392a..fbbd930 100644
20055 --- a/arch/x86/kernel/ftrace.c
20056 +++ b/arch/x86/kernel/ftrace.c
20057 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20058 {
20059 unsigned char replaced[MCOUNT_INSN_SIZE];
20060
20061 + ip = ktla_ktva(ip);
20062 +
20063 /*
20064 * Note: Due to modules and __init, code can
20065 * disappear and change, we need to protect against faulting
20066 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20067 unsigned char old[MCOUNT_INSN_SIZE], *new;
20068 int ret;
20069
20070 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20071 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20072 new = ftrace_call_replace(ip, (unsigned long)func);
20073
20074 /* See comment above by declaration of modifying_ftrace_code */
20075 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20076 /* Also update the regs callback function */
20077 if (!ret) {
20078 ip = (unsigned long)(&ftrace_regs_call);
20079 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20080 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20081 new = ftrace_call_replace(ip, (unsigned long)func);
20082 ret = ftrace_modify_code(ip, old, new);
20083 }
20084 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20085 * kernel identity mapping to modify code.
20086 */
20087 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20088 - ip = (unsigned long)__va(__pa_symbol(ip));
20089 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20090
20091 return probe_kernel_write((void *)ip, val, size);
20092 }
20093 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20094 unsigned char replaced[MCOUNT_INSN_SIZE];
20095 unsigned char brk = BREAKPOINT_INSTRUCTION;
20096
20097 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20098 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20099 return -EFAULT;
20100
20101 /* Make sure it is what we expect it to be */
20102 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20103 return ret;
20104
20105 fail_update:
20106 - probe_kernel_write((void *)ip, &old_code[0], 1);
20107 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20108 goto out;
20109 }
20110
20111 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20112 {
20113 unsigned char code[MCOUNT_INSN_SIZE];
20114
20115 + ip = ktla_ktva(ip);
20116 +
20117 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20118 return -EFAULT;
20119
20120 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20121 index 8f3201d..aa860bf 100644
20122 --- a/arch/x86/kernel/head64.c
20123 +++ b/arch/x86/kernel/head64.c
20124 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20125 if (console_loglevel == 10)
20126 early_printk("Kernel alive\n");
20127
20128 - clear_page(init_level4_pgt);
20129 /* set init_level4_pgt kernel high mapping*/
20130 init_level4_pgt[511] = early_level4_pgt[511];
20131
20132 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20133 index 73afd11..d1670f5 100644
20134 --- a/arch/x86/kernel/head_32.S
20135 +++ b/arch/x86/kernel/head_32.S
20136 @@ -26,6 +26,12 @@
20137 /* Physical address */
20138 #define pa(X) ((X) - __PAGE_OFFSET)
20139
20140 +#ifdef CONFIG_PAX_KERNEXEC
20141 +#define ta(X) (X)
20142 +#else
20143 +#define ta(X) ((X) - __PAGE_OFFSET)
20144 +#endif
20145 +
20146 /*
20147 * References to members of the new_cpu_data structure.
20148 */
20149 @@ -55,11 +61,7 @@
20150 * and small than max_low_pfn, otherwise will waste some page table entries
20151 */
20152
20153 -#if PTRS_PER_PMD > 1
20154 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20155 -#else
20156 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20157 -#endif
20158 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20159
20160 /* Number of possible pages in the lowmem region */
20161 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20162 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20163 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20164
20165 /*
20166 + * Real beginning of normal "text" segment
20167 + */
20168 +ENTRY(stext)
20169 +ENTRY(_stext)
20170 +
20171 +/*
20172 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20173 * %esi points to the real-mode code as a 32-bit pointer.
20174 * CS and DS must be 4 GB flat segments, but we don't depend on
20175 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20176 * can.
20177 */
20178 __HEAD
20179 +
20180 +#ifdef CONFIG_PAX_KERNEXEC
20181 + jmp startup_32
20182 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20183 +.fill PAGE_SIZE-5,1,0xcc
20184 +#endif
20185 +
20186 ENTRY(startup_32)
20187 movl pa(stack_start),%ecx
20188
20189 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20190 2:
20191 leal -__PAGE_OFFSET(%ecx),%esp
20192
20193 +#ifdef CONFIG_SMP
20194 + movl $pa(cpu_gdt_table),%edi
20195 + movl $__per_cpu_load,%eax
20196 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20197 + rorl $16,%eax
20198 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20199 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20200 + movl $__per_cpu_end - 1,%eax
20201 + subl $__per_cpu_start,%eax
20202 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20203 +#endif
20204 +
20205 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20206 + movl $NR_CPUS,%ecx
20207 + movl $pa(cpu_gdt_table),%edi
20208 +1:
20209 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20210 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20211 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20212 + addl $PAGE_SIZE_asm,%edi
20213 + loop 1b
20214 +#endif
20215 +
20216 +#ifdef CONFIG_PAX_KERNEXEC
20217 + movl $pa(boot_gdt),%edi
20218 + movl $__LOAD_PHYSICAL_ADDR,%eax
20219 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20220 + rorl $16,%eax
20221 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20222 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20223 + rorl $16,%eax
20224 +
20225 + ljmp $(__BOOT_CS),$1f
20226 +1:
20227 +
20228 + movl $NR_CPUS,%ecx
20229 + movl $pa(cpu_gdt_table),%edi
20230 + addl $__PAGE_OFFSET,%eax
20231 +1:
20232 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20233 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20234 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20235 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20236 + rorl $16,%eax
20237 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20238 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20239 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20240 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20241 + rorl $16,%eax
20242 + addl $PAGE_SIZE_asm,%edi
20243 + loop 1b
20244 +#endif
20245 +
20246 /*
20247 * Clear BSS first so that there are no surprises...
20248 */
20249 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20250 movl %eax, pa(max_pfn_mapped)
20251
20252 /* Do early initialization of the fixmap area */
20253 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20254 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20255 +#ifdef CONFIG_COMPAT_VDSO
20256 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20257 +#else
20258 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20259 +#endif
20260 #else /* Not PAE */
20261
20262 page_pde_offset = (__PAGE_OFFSET >> 20);
20263 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20264 movl %eax, pa(max_pfn_mapped)
20265
20266 /* Do early initialization of the fixmap area */
20267 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20268 - movl %eax,pa(initial_page_table+0xffc)
20269 +#ifdef CONFIG_COMPAT_VDSO
20270 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20271 +#else
20272 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20273 +#endif
20274 #endif
20275
20276 #ifdef CONFIG_PARAVIRT
20277 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20278 cmpl $num_subarch_entries, %eax
20279 jae bad_subarch
20280
20281 - movl pa(subarch_entries)(,%eax,4), %eax
20282 - subl $__PAGE_OFFSET, %eax
20283 - jmp *%eax
20284 + jmp *pa(subarch_entries)(,%eax,4)
20285
20286 bad_subarch:
20287 WEAK(lguest_entry)
20288 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20289 __INITDATA
20290
20291 subarch_entries:
20292 - .long default_entry /* normal x86/PC */
20293 - .long lguest_entry /* lguest hypervisor */
20294 - .long xen_entry /* Xen hypervisor */
20295 - .long default_entry /* Moorestown MID */
20296 + .long ta(default_entry) /* normal x86/PC */
20297 + .long ta(lguest_entry) /* lguest hypervisor */
20298 + .long ta(xen_entry) /* Xen hypervisor */
20299 + .long ta(default_entry) /* Moorestown MID */
20300 num_subarch_entries = (. - subarch_entries) / 4
20301 .previous
20302 #else
20303 @@ -355,6 +427,7 @@ default_entry:
20304 movl pa(mmu_cr4_features),%eax
20305 movl %eax,%cr4
20306
20307 +#ifdef CONFIG_X86_PAE
20308 testb $X86_CR4_PAE, %al # check if PAE is enabled
20309 jz enable_paging
20310
20311 @@ -383,6 +456,9 @@ default_entry:
20312 /* Make changes effective */
20313 wrmsr
20314
20315 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20316 +#endif
20317 +
20318 enable_paging:
20319
20320 /*
20321 @@ -451,14 +527,20 @@ is486:
20322 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20323 movl %eax,%ss # after changing gdt.
20324
20325 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20326 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20327 movl %eax,%ds
20328 movl %eax,%es
20329
20330 movl $(__KERNEL_PERCPU), %eax
20331 movl %eax,%fs # set this cpu's percpu
20332
20333 +#ifdef CONFIG_CC_STACKPROTECTOR
20334 movl $(__KERNEL_STACK_CANARY),%eax
20335 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20336 + movl $(__USER_DS),%eax
20337 +#else
20338 + xorl %eax,%eax
20339 +#endif
20340 movl %eax,%gs
20341
20342 xorl %eax,%eax # Clear LDT
20343 @@ -534,8 +616,11 @@ setup_once:
20344 * relocation. Manually set base address in stack canary
20345 * segment descriptor.
20346 */
20347 - movl $gdt_page,%eax
20348 + movl $cpu_gdt_table,%eax
20349 movl $stack_canary,%ecx
20350 +#ifdef CONFIG_SMP
20351 + addl $__per_cpu_load,%ecx
20352 +#endif
20353 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20354 shrl $16, %ecx
20355 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20356 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20357 /* This is global to keep gas from relaxing the jumps */
20358 ENTRY(early_idt_handler)
20359 cld
20360 - cmpl $2,%ss:early_recursion_flag
20361 + cmpl $1,%ss:early_recursion_flag
20362 je hlt_loop
20363 incl %ss:early_recursion_flag
20364
20365 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20366 pushl (20+6*4)(%esp) /* trapno */
20367 pushl $fault_msg
20368 call printk
20369 -#endif
20370 call dump_stack
20371 +#endif
20372 hlt_loop:
20373 hlt
20374 jmp hlt_loop
20375 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20376 /* This is the default interrupt "handler" :-) */
20377 ALIGN
20378 ignore_int:
20379 - cld
20380 #ifdef CONFIG_PRINTK
20381 + cmpl $2,%ss:early_recursion_flag
20382 + je hlt_loop
20383 + incl %ss:early_recursion_flag
20384 + cld
20385 pushl %eax
20386 pushl %ecx
20387 pushl %edx
20388 @@ -634,9 +722,6 @@ ignore_int:
20389 movl $(__KERNEL_DS),%eax
20390 movl %eax,%ds
20391 movl %eax,%es
20392 - cmpl $2,early_recursion_flag
20393 - je hlt_loop
20394 - incl early_recursion_flag
20395 pushl 16(%esp)
20396 pushl 24(%esp)
20397 pushl 32(%esp)
20398 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20399 /*
20400 * BSS section
20401 */
20402 -__PAGE_ALIGNED_BSS
20403 - .align PAGE_SIZE
20404 #ifdef CONFIG_X86_PAE
20405 +.section .initial_pg_pmd,"a",@progbits
20406 initial_pg_pmd:
20407 .fill 1024*KPMDS,4,0
20408 #else
20409 +.section .initial_page_table,"a",@progbits
20410 ENTRY(initial_page_table)
20411 .fill 1024,4,0
20412 #endif
20413 +.section .initial_pg_fixmap,"a",@progbits
20414 initial_pg_fixmap:
20415 .fill 1024,4,0
20416 +.section .empty_zero_page,"a",@progbits
20417 ENTRY(empty_zero_page)
20418 .fill 4096,1,0
20419 +.section .swapper_pg_dir,"a",@progbits
20420 ENTRY(swapper_pg_dir)
20421 +#ifdef CONFIG_X86_PAE
20422 + .fill 4,8,0
20423 +#else
20424 .fill 1024,4,0
20425 +#endif
20426 +
20427 +/*
20428 + * The IDT has to be page-aligned to simplify the Pentium
20429 + * F0 0F bug workaround.. We have a special link segment
20430 + * for this.
20431 + */
20432 +.section .idt,"a",@progbits
20433 +ENTRY(idt_table)
20434 + .fill 256,8,0
20435
20436 /*
20437 * This starts the data section.
20438 */
20439 #ifdef CONFIG_X86_PAE
20440 -__PAGE_ALIGNED_DATA
20441 - /* Page-aligned for the benefit of paravirt? */
20442 - .align PAGE_SIZE
20443 +.section .initial_page_table,"a",@progbits
20444 ENTRY(initial_page_table)
20445 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20446 # if KPMDS == 3
20447 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20448 # error "Kernel PMDs should be 1, 2 or 3"
20449 # endif
20450 .align PAGE_SIZE /* needs to be page-sized too */
20451 +
20452 +#ifdef CONFIG_PAX_PER_CPU_PGD
20453 +ENTRY(cpu_pgd)
20454 + .rept NR_CPUS
20455 + .fill 4,8,0
20456 + .endr
20457 +#endif
20458 +
20459 #endif
20460
20461 .data
20462 .balign 4
20463 ENTRY(stack_start)
20464 - .long init_thread_union+THREAD_SIZE
20465 + .long init_thread_union+THREAD_SIZE-8
20466
20467 __INITRODATA
20468 int_msg:
20469 @@ -744,7 +851,7 @@ fault_msg:
20470 * segment size, and 32-bit linear address value:
20471 */
20472
20473 - .data
20474 +.section .rodata,"a",@progbits
20475 .globl boot_gdt_descr
20476 .globl idt_descr
20477
20478 @@ -753,7 +860,7 @@ fault_msg:
20479 .word 0 # 32 bit align gdt_desc.address
20480 boot_gdt_descr:
20481 .word __BOOT_DS+7
20482 - .long boot_gdt - __PAGE_OFFSET
20483 + .long pa(boot_gdt)
20484
20485 .word 0 # 32-bit align idt_desc.address
20486 idt_descr:
20487 @@ -764,7 +871,7 @@ idt_descr:
20488 .word 0 # 32 bit align gdt_desc.address
20489 ENTRY(early_gdt_descr)
20490 .word GDT_ENTRIES*8-1
20491 - .long gdt_page /* Overwritten for secondary CPUs */
20492 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20493
20494 /*
20495 * The boot_gdt must mirror the equivalent in setup.S and is
20496 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20497 .align L1_CACHE_BYTES
20498 ENTRY(boot_gdt)
20499 .fill GDT_ENTRY_BOOT_CS,8,0
20500 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20501 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20502 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20503 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20504 +
20505 + .align PAGE_SIZE_asm
20506 +ENTRY(cpu_gdt_table)
20507 + .rept NR_CPUS
20508 + .quad 0x0000000000000000 /* NULL descriptor */
20509 + .quad 0x0000000000000000 /* 0x0b reserved */
20510 + .quad 0x0000000000000000 /* 0x13 reserved */
20511 + .quad 0x0000000000000000 /* 0x1b reserved */
20512 +
20513 +#ifdef CONFIG_PAX_KERNEXEC
20514 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20515 +#else
20516 + .quad 0x0000000000000000 /* 0x20 unused */
20517 +#endif
20518 +
20519 + .quad 0x0000000000000000 /* 0x28 unused */
20520 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20521 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20522 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20523 + .quad 0x0000000000000000 /* 0x4b reserved */
20524 + .quad 0x0000000000000000 /* 0x53 reserved */
20525 + .quad 0x0000000000000000 /* 0x5b reserved */
20526 +
20527 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20528 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20529 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20530 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20531 +
20532 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20533 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20534 +
20535 + /*
20536 + * Segments used for calling PnP BIOS have byte granularity.
20537 + * The code segments and data segments have fixed 64k limits,
20538 + * the transfer segment sizes are set at run time.
20539 + */
20540 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20541 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20542 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20543 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20544 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20545 +
20546 + /*
20547 + * The APM segments have byte granularity and their bases
20548 + * are set at run time. All have 64k limits.
20549 + */
20550 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20551 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20552 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20553 +
20554 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20555 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20556 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20557 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20558 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20559 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20560 +
20561 + /* Be sure this is zeroed to avoid false validations in Xen */
20562 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20563 + .endr
20564 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20565 index 321d65e..7830f05 100644
20566 --- a/arch/x86/kernel/head_64.S
20567 +++ b/arch/x86/kernel/head_64.S
20568 @@ -20,6 +20,8 @@
20569 #include <asm/processor-flags.h>
20570 #include <asm/percpu.h>
20571 #include <asm/nops.h>
20572 +#include <asm/cpufeature.h>
20573 +#include <asm/alternative-asm.h>
20574
20575 #ifdef CONFIG_PARAVIRT
20576 #include <asm/asm-offsets.h>
20577 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20578 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20579 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20580 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20581 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20582 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20583 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20584 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20585 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20586 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20587
20588 .text
20589 __HEAD
20590 @@ -89,11 +97,15 @@ startup_64:
20591 * Fixup the physical addresses in the page table
20592 */
20593 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20594 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20595 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20596 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20597
20598 addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20599 addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20600
20601 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20602 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20603
20604 /*
20605 * Set up the identity mapping for the switchover. These
20606 @@ -177,8 +189,8 @@ ENTRY(secondary_startup_64)
20607 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20608 1:
20609
20610 - /* Enable PAE mode and PGE */
20611 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20612 + /* Enable PAE mode and PSE/PGE */
20613 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20614 movq %rcx, %cr4
20615
20616 /* Setup early boot stage 4 level pagetables. */
20617 @@ -199,10 +211,18 @@ ENTRY(secondary_startup_64)
20618 movl $MSR_EFER, %ecx
20619 rdmsr
20620 btsl $_EFER_SCE, %eax /* Enable System Call */
20621 - btl $20,%edi /* No Execute supported? */
20622 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20623 jnc 1f
20624 btsl $_EFER_NX, %eax
20625 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20626 + leaq init_level4_pgt(%rip), %rdi
20627 +#ifndef CONFIG_EFI
20628 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20629 +#endif
20630 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20631 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20632 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20633 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20634 1: wrmsr /* Make changes effective */
20635
20636 /* Setup cr0 */
20637 @@ -282,6 +302,7 @@ ENTRY(secondary_startup_64)
20638 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20639 * address given in m16:64.
20640 */
20641 + pax_set_fptr_mask
20642 movq initial_code(%rip),%rax
20643 pushq $0 # fake return address to stop unwinder
20644 pushq $__KERNEL_CS # set correct cs
20645 @@ -388,7 +409,7 @@ ENTRY(early_idt_handler)
20646 call dump_stack
20647 #ifdef CONFIG_KALLSYMS
20648 leaq early_idt_ripmsg(%rip),%rdi
20649 - movq 40(%rsp),%rsi # %rip again
20650 + movq 88(%rsp),%rsi # %rip again
20651 call __print_symbol
20652 #endif
20653 #endif /* EARLY_PRINTK */
20654 @@ -416,6 +437,7 @@ ENDPROC(early_idt_handler)
20655 early_recursion_flag:
20656 .long 0
20657
20658 + .section .rodata,"a",@progbits
20659 #ifdef CONFIG_EARLY_PRINTK
20660 early_idt_msg:
20661 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20662 @@ -445,27 +467,50 @@ NEXT_PAGE(early_dynamic_pgts)
20663
20664 .data
20665
20666 -#ifndef CONFIG_XEN
20667 NEXT_PAGE(init_level4_pgt)
20668 - .fill 512,8,0
20669 -#else
20670 -NEXT_PAGE(init_level4_pgt)
20671 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20672 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20673 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20674 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20675 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20676 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20677 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20678 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20679 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20680 .org init_level4_pgt + L4_START_KERNEL*8, 0
20681 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20682 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20683
20684 +#ifdef CONFIG_PAX_PER_CPU_PGD
20685 +NEXT_PAGE(cpu_pgd)
20686 + .rept NR_CPUS
20687 + .fill 512,8,0
20688 + .endr
20689 +#endif
20690 +
20691 NEXT_PAGE(level3_ident_pgt)
20692 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20693 +#ifdef CONFIG_XEN
20694 .fill 511, 8, 0
20695 +#else
20696 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20697 + .fill 510,8,0
20698 +#endif
20699 +
20700 +NEXT_PAGE(level3_vmalloc_start_pgt)
20701 + .fill 512,8,0
20702 +
20703 +NEXT_PAGE(level3_vmalloc_end_pgt)
20704 + .fill 512,8,0
20705 +
20706 +NEXT_PAGE(level3_vmemmap_pgt)
20707 + .fill L3_VMEMMAP_START,8,0
20708 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20709 +
20710 NEXT_PAGE(level2_ident_pgt)
20711 - /* Since I easily can, map the first 1G.
20712 + /* Since I easily can, map the first 2G.
20713 * Don't set NX because code runs from these pages.
20714 */
20715 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20716 -#endif
20717 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20718
20719 NEXT_PAGE(level3_kernel_pgt)
20720 .fill L3_START_KERNEL,8,0
20721 @@ -473,6 +518,9 @@ NEXT_PAGE(level3_kernel_pgt)
20722 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20723 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20724
20725 +NEXT_PAGE(level2_vmemmap_pgt)
20726 + .fill 512,8,0
20727 +
20728 NEXT_PAGE(level2_kernel_pgt)
20729 /*
20730 * 512 MB kernel mapping. We spend a full page on this pagetable
20731 @@ -488,39 +536,64 @@ NEXT_PAGE(level2_kernel_pgt)
20732 KERNEL_IMAGE_SIZE/PMD_SIZE)
20733
20734 NEXT_PAGE(level2_fixmap_pgt)
20735 - .fill 506,8,0
20736 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20737 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20738 - .fill 5,8,0
20739 + .fill 507,8,0
20740 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20741 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20742 + .fill 4,8,0
20743
20744 -NEXT_PAGE(level1_fixmap_pgt)
20745 +NEXT_PAGE(level1_vsyscall_pgt)
20746 .fill 512,8,0
20747
20748 #undef PMDS
20749
20750 - .data
20751 + .align PAGE_SIZE
20752 +ENTRY(cpu_gdt_table)
20753 + .rept NR_CPUS
20754 + .quad 0x0000000000000000 /* NULL descriptor */
20755 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20756 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20757 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20758 + .quad 0x00cffb000000ffff /* __USER32_CS */
20759 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20760 + .quad 0x00affb000000ffff /* __USER_CS */
20761 +
20762 +#ifdef CONFIG_PAX_KERNEXEC
20763 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20764 +#else
20765 + .quad 0x0 /* unused */
20766 +#endif
20767 +
20768 + .quad 0,0 /* TSS */
20769 + .quad 0,0 /* LDT */
20770 + .quad 0,0,0 /* three TLS descriptors */
20771 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20772 + /* asm/segment.h:GDT_ENTRIES must match this */
20773 +
20774 + /* zero the remaining page */
20775 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20776 + .endr
20777 +
20778 .align 16
20779 .globl early_gdt_descr
20780 early_gdt_descr:
20781 .word GDT_ENTRIES*8-1
20782 early_gdt_descr_base:
20783 - .quad INIT_PER_CPU_VAR(gdt_page)
20784 + .quad cpu_gdt_table
20785
20786 ENTRY(phys_base)
20787 /* This must match the first entry in level2_kernel_pgt */
20788 .quad 0x0000000000000000
20789
20790 #include "../../x86/xen/xen-head.S"
20791 -
20792 - .section .bss, "aw", @nobits
20793 +
20794 + .section .rodata,"a",@progbits
20795 .align L1_CACHE_BYTES
20796 ENTRY(idt_table)
20797 - .skip IDT_ENTRIES * 16
20798 + .fill 512,8,0
20799
20800 .align L1_CACHE_BYTES
20801 ENTRY(nmi_idt_table)
20802 - .skip IDT_ENTRIES * 16
20803 + .fill 512,8,0
20804
20805 - __PAGE_ALIGNED_BSS
20806 NEXT_PAGE(empty_zero_page)
20807 .skip PAGE_SIZE
20808 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20809 index 0fa6912..37fce70 100644
20810 --- a/arch/x86/kernel/i386_ksyms_32.c
20811 +++ b/arch/x86/kernel/i386_ksyms_32.c
20812 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20813 EXPORT_SYMBOL(cmpxchg8b_emu);
20814 #endif
20815
20816 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20817 +
20818 /* Networking helper routines. */
20819 EXPORT_SYMBOL(csum_partial_copy_generic);
20820 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20821 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20822
20823 EXPORT_SYMBOL(__get_user_1);
20824 EXPORT_SYMBOL(__get_user_2);
20825 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20826
20827 EXPORT_SYMBOL(csum_partial);
20828 EXPORT_SYMBOL(empty_zero_page);
20829 +
20830 +#ifdef CONFIG_PAX_KERNEXEC
20831 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20832 +#endif
20833 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20834 index cb33909..1163b40 100644
20835 --- a/arch/x86/kernel/i387.c
20836 +++ b/arch/x86/kernel/i387.c
20837 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20838 static inline bool interrupted_user_mode(void)
20839 {
20840 struct pt_regs *regs = get_irq_regs();
20841 - return regs && user_mode_vm(regs);
20842 + return regs && user_mode(regs);
20843 }
20844
20845 /*
20846 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20847 index 9a5c460..84868423 100644
20848 --- a/arch/x86/kernel/i8259.c
20849 +++ b/arch/x86/kernel/i8259.c
20850 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20851 static void make_8259A_irq(unsigned int irq)
20852 {
20853 disable_irq_nosync(irq);
20854 - io_apic_irqs &= ~(1<<irq);
20855 + io_apic_irqs &= ~(1UL<<irq);
20856 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20857 i8259A_chip.name);
20858 enable_irq(irq);
20859 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20860 "spurious 8259A interrupt: IRQ%d.\n", irq);
20861 spurious_irq_mask |= irqmask;
20862 }
20863 - atomic_inc(&irq_err_count);
20864 + atomic_inc_unchecked(&irq_err_count);
20865 /*
20866 * Theoretically we do not have to handle this IRQ,
20867 * but in Linux this does not cause problems and is
20868 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20869 /* (slave's support for AEOI in flat mode is to be investigated) */
20870 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20871
20872 + pax_open_kernel();
20873 if (auto_eoi)
20874 /*
20875 * In AEOI mode we just have to mask the interrupt
20876 * when acking.
20877 */
20878 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20879 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20880 else
20881 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20882 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20883 + pax_close_kernel();
20884
20885 udelay(100); /* wait for 8259A to initialize */
20886
20887 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20888 index a979b5b..1d6db75 100644
20889 --- a/arch/x86/kernel/io_delay.c
20890 +++ b/arch/x86/kernel/io_delay.c
20891 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20892 * Quirk table for systems that misbehave (lock up, etc.) if port
20893 * 0x80 is used:
20894 */
20895 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20896 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20897 {
20898 .callback = dmi_io_delay_0xed_port,
20899 .ident = "Compaq Presario V6000",
20900 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20901 index 4ddaf66..6292f4e 100644
20902 --- a/arch/x86/kernel/ioport.c
20903 +++ b/arch/x86/kernel/ioport.c
20904 @@ -6,6 +6,7 @@
20905 #include <linux/sched.h>
20906 #include <linux/kernel.h>
20907 #include <linux/capability.h>
20908 +#include <linux/security.h>
20909 #include <linux/errno.h>
20910 #include <linux/types.h>
20911 #include <linux/ioport.h>
20912 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20913
20914 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20915 return -EINVAL;
20916 +#ifdef CONFIG_GRKERNSEC_IO
20917 + if (turn_on && grsec_disable_privio) {
20918 + gr_handle_ioperm();
20919 + return -EPERM;
20920 + }
20921 +#endif
20922 if (turn_on && !capable(CAP_SYS_RAWIO))
20923 return -EPERM;
20924
20925 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20926 * because the ->io_bitmap_max value must match the bitmap
20927 * contents:
20928 */
20929 - tss = &per_cpu(init_tss, get_cpu());
20930 + tss = init_tss + get_cpu();
20931
20932 if (turn_on)
20933 bitmap_clear(t->io_bitmap_ptr, from, num);
20934 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20935 return -EINVAL;
20936 /* Trying to gain more privileges? */
20937 if (level > old) {
20938 +#ifdef CONFIG_GRKERNSEC_IO
20939 + if (grsec_disable_privio) {
20940 + gr_handle_iopl();
20941 + return -EPERM;
20942 + }
20943 +#endif
20944 if (!capable(CAP_SYS_RAWIO))
20945 return -EPERM;
20946 }
20947 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20948 index 84b7789..e65e8be 100644
20949 --- a/arch/x86/kernel/irq.c
20950 +++ b/arch/x86/kernel/irq.c
20951 @@ -18,7 +18,7 @@
20952 #include <asm/mce.h>
20953 #include <asm/hw_irq.h>
20954
20955 -atomic_t irq_err_count;
20956 +atomic_unchecked_t irq_err_count;
20957
20958 /* Function pointer for generic interrupt vector handling */
20959 void (*x86_platform_ipi_callback)(void) = NULL;
20960 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20961 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20962 seq_printf(p, " Machine check polls\n");
20963 #endif
20964 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20965 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20966 #if defined(CONFIG_X86_IO_APIC)
20967 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20968 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20969 #endif
20970 return 0;
20971 }
20972 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20973
20974 u64 arch_irq_stat(void)
20975 {
20976 - u64 sum = atomic_read(&irq_err_count);
20977 + u64 sum = atomic_read_unchecked(&irq_err_count);
20978 return sum;
20979 }
20980
20981 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20982 index 344faf8..355f60d 100644
20983 --- a/arch/x86/kernel/irq_32.c
20984 +++ b/arch/x86/kernel/irq_32.c
20985 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20986 __asm__ __volatile__("andl %%esp,%0" :
20987 "=r" (sp) : "0" (THREAD_SIZE - 1));
20988
20989 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20990 + return sp < STACK_WARN;
20991 }
20992
20993 static void print_stack_overflow(void)
20994 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
20995 * per-CPU IRQ handling contexts (thread information and stack)
20996 */
20997 union irq_ctx {
20998 - struct thread_info tinfo;
20999 - u32 stack[THREAD_SIZE/sizeof(u32)];
21000 + unsigned long previous_esp;
21001 + u32 stack[THREAD_SIZE/sizeof(u32)];
21002 } __attribute__((aligned(THREAD_SIZE)));
21003
21004 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21005 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21006 static inline int
21007 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21008 {
21009 - union irq_ctx *curctx, *irqctx;
21010 + union irq_ctx *irqctx;
21011 u32 *isp, arg1, arg2;
21012
21013 - curctx = (union irq_ctx *) current_thread_info();
21014 irqctx = __this_cpu_read(hardirq_ctx);
21015
21016 /*
21017 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21018 * handler) we can't do that and just have to keep using the
21019 * current stack (which is the irq stack already after all)
21020 */
21021 - if (unlikely(curctx == irqctx))
21022 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21023 return 0;
21024
21025 /* build the stack frame on the IRQ stack */
21026 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21027 - irqctx->tinfo.task = curctx->tinfo.task;
21028 - irqctx->tinfo.previous_esp = current_stack_pointer;
21029 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21030 + irqctx->previous_esp = current_stack_pointer;
21031
21032 - /* Copy the preempt_count so that the [soft]irq checks work. */
21033 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21034 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21035 + __set_fs(MAKE_MM_SEG(0));
21036 +#endif
21037
21038 if (unlikely(overflow))
21039 call_on_stack(print_stack_overflow, isp);
21040 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21041 : "0" (irq), "1" (desc), "2" (isp),
21042 "D" (desc->handle_irq)
21043 : "memory", "cc", "ecx");
21044 +
21045 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21046 + __set_fs(current_thread_info()->addr_limit);
21047 +#endif
21048 +
21049 return 1;
21050 }
21051
21052 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21053 */
21054 void __cpuinit irq_ctx_init(int cpu)
21055 {
21056 - union irq_ctx *irqctx;
21057 -
21058 if (per_cpu(hardirq_ctx, cpu))
21059 return;
21060
21061 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21062 - THREADINFO_GFP,
21063 - THREAD_SIZE_ORDER));
21064 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21065 - irqctx->tinfo.cpu = cpu;
21066 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21067 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21068 -
21069 - per_cpu(hardirq_ctx, cpu) = irqctx;
21070 -
21071 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21072 - THREADINFO_GFP,
21073 - THREAD_SIZE_ORDER));
21074 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21075 - irqctx->tinfo.cpu = cpu;
21076 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21077 -
21078 - per_cpu(softirq_ctx, cpu) = irqctx;
21079 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21080 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21081 +
21082 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21083 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21084
21085 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21086 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21087 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21088 asmlinkage void do_softirq(void)
21089 {
21090 unsigned long flags;
21091 - struct thread_info *curctx;
21092 union irq_ctx *irqctx;
21093 u32 *isp;
21094
21095 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21096 local_irq_save(flags);
21097
21098 if (local_softirq_pending()) {
21099 - curctx = current_thread_info();
21100 irqctx = __this_cpu_read(softirq_ctx);
21101 - irqctx->tinfo.task = curctx->task;
21102 - irqctx->tinfo.previous_esp = current_stack_pointer;
21103 + irqctx->previous_esp = current_stack_pointer;
21104
21105 /* build the stack frame on the softirq stack */
21106 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21107 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21108 +
21109 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21110 + __set_fs(MAKE_MM_SEG(0));
21111 +#endif
21112
21113 call_on_stack(__do_softirq, isp);
21114 +
21115 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21116 + __set_fs(current_thread_info()->addr_limit);
21117 +#endif
21118 +
21119 /*
21120 * Shouldn't happen, we returned above if in_interrupt():
21121 */
21122 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21123 if (unlikely(!desc))
21124 return false;
21125
21126 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21127 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21128 if (unlikely(overflow))
21129 print_stack_overflow();
21130 desc->handle_irq(irq, desc);
21131 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21132 index d04d3ec..ea4b374 100644
21133 --- a/arch/x86/kernel/irq_64.c
21134 +++ b/arch/x86/kernel/irq_64.c
21135 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21136 u64 estack_top, estack_bottom;
21137 u64 curbase = (u64)task_stack_page(current);
21138
21139 - if (user_mode_vm(regs))
21140 + if (user_mode(regs))
21141 return;
21142
21143 if (regs->sp >= curbase + sizeof(struct thread_info) +
21144 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21145 index dc1404b..bbc43e7 100644
21146 --- a/arch/x86/kernel/kdebugfs.c
21147 +++ b/arch/x86/kernel/kdebugfs.c
21148 @@ -27,7 +27,7 @@ struct setup_data_node {
21149 u32 len;
21150 };
21151
21152 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21153 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21154 size_t count, loff_t *ppos)
21155 {
21156 struct setup_data_node *node = file->private_data;
21157 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21158 index 836f832..a8bda67 100644
21159 --- a/arch/x86/kernel/kgdb.c
21160 +++ b/arch/x86/kernel/kgdb.c
21161 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21162 #ifdef CONFIG_X86_32
21163 switch (regno) {
21164 case GDB_SS:
21165 - if (!user_mode_vm(regs))
21166 + if (!user_mode(regs))
21167 *(unsigned long *)mem = __KERNEL_DS;
21168 break;
21169 case GDB_SP:
21170 - if (!user_mode_vm(regs))
21171 + if (!user_mode(regs))
21172 *(unsigned long *)mem = kernel_stack_pointer(regs);
21173 break;
21174 case GDB_GS:
21175 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21176 bp->attr.bp_addr = breakinfo[breakno].addr;
21177 bp->attr.bp_len = breakinfo[breakno].len;
21178 bp->attr.bp_type = breakinfo[breakno].type;
21179 - info->address = breakinfo[breakno].addr;
21180 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21181 + info->address = ktla_ktva(breakinfo[breakno].addr);
21182 + else
21183 + info->address = breakinfo[breakno].addr;
21184 info->len = breakinfo[breakno].len;
21185 info->type = breakinfo[breakno].type;
21186 val = arch_install_hw_breakpoint(bp);
21187 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21188 case 'k':
21189 /* clear the trace bit */
21190 linux_regs->flags &= ~X86_EFLAGS_TF;
21191 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21192 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21193
21194 /* set the trace bit if we're stepping */
21195 if (remcomInBuffer[0] == 's') {
21196 linux_regs->flags |= X86_EFLAGS_TF;
21197 - atomic_set(&kgdb_cpu_doing_single_step,
21198 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21199 raw_smp_processor_id());
21200 }
21201
21202 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21203
21204 switch (cmd) {
21205 case DIE_DEBUG:
21206 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21207 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21208 if (user_mode(regs))
21209 return single_step_cont(regs, args);
21210 break;
21211 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21212 #endif /* CONFIG_DEBUG_RODATA */
21213
21214 bpt->type = BP_BREAKPOINT;
21215 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21216 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21217 BREAK_INSTR_SIZE);
21218 if (err)
21219 return err;
21220 - err = probe_kernel_write((char *)bpt->bpt_addr,
21221 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21222 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21223 #ifdef CONFIG_DEBUG_RODATA
21224 if (!err)
21225 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21226 return -EBUSY;
21227 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21228 BREAK_INSTR_SIZE);
21229 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21230 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21231 if (err)
21232 return err;
21233 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21234 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21235 if (mutex_is_locked(&text_mutex))
21236 goto knl_write;
21237 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21238 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21239 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21240 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21241 goto knl_write;
21242 return err;
21243 knl_write:
21244 #endif /* CONFIG_DEBUG_RODATA */
21245 - return probe_kernel_write((char *)bpt->bpt_addr,
21246 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21247 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21248 }
21249
21250 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21251 index 7bfe318..383d238 100644
21252 --- a/arch/x86/kernel/kprobes/core.c
21253 +++ b/arch/x86/kernel/kprobes/core.c
21254 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21255 s32 raddr;
21256 } __packed *insn;
21257
21258 - insn = (struct __arch_relative_insn *)from;
21259 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21260 +
21261 + pax_open_kernel();
21262 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21263 insn->op = op;
21264 + pax_close_kernel();
21265 }
21266
21267 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21268 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21269 kprobe_opcode_t opcode;
21270 kprobe_opcode_t *orig_opcodes = opcodes;
21271
21272 - if (search_exception_tables((unsigned long)opcodes))
21273 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21274 return 0; /* Page fault may occur on this address. */
21275
21276 retry:
21277 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21278 * for the first byte, we can recover the original instruction
21279 * from it and kp->opcode.
21280 */
21281 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21282 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21283 buf[0] = kp->opcode;
21284 - return (unsigned long)buf;
21285 + return ktva_ktla((unsigned long)buf);
21286 }
21287
21288 /*
21289 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21290 /* Another subsystem puts a breakpoint, failed to recover */
21291 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21292 return 0;
21293 + pax_open_kernel();
21294 memcpy(dest, insn.kaddr, insn.length);
21295 + pax_close_kernel();
21296
21297 #ifdef CONFIG_X86_64
21298 if (insn_rip_relative(&insn)) {
21299 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21300 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21301 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21302 disp = (u8 *) dest + insn_offset_displacement(&insn);
21303 + pax_open_kernel();
21304 *(s32 *) disp = (s32) newdisp;
21305 + pax_close_kernel();
21306 }
21307 #endif
21308 return insn.length;
21309 @@ -488,7 +495,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21310 * nor set current_kprobe, because it doesn't use single
21311 * stepping.
21312 */
21313 - regs->ip = (unsigned long)p->ainsn.insn;
21314 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21315 preempt_enable_no_resched();
21316 return;
21317 }
21318 @@ -505,9 +512,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21319 regs->flags &= ~X86_EFLAGS_IF;
21320 /* single step inline if the instruction is an int3 */
21321 if (p->opcode == BREAKPOINT_INSTRUCTION)
21322 - regs->ip = (unsigned long)p->addr;
21323 + regs->ip = ktla_ktva((unsigned long)p->addr);
21324 else
21325 - regs->ip = (unsigned long)p->ainsn.insn;
21326 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21327 }
21328
21329 /*
21330 @@ -586,7 +593,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21331 setup_singlestep(p, regs, kcb, 0);
21332 return 1;
21333 }
21334 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21335 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21336 /*
21337 * The breakpoint instruction was removed right
21338 * after we hit it. Another cpu has removed
21339 @@ -632,6 +639,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21340 " movq %rax, 152(%rsp)\n"
21341 RESTORE_REGS_STRING
21342 " popfq\n"
21343 +#ifdef KERNEXEC_PLUGIN
21344 + " btsq $63,(%rsp)\n"
21345 +#endif
21346 #else
21347 " pushf\n"
21348 SAVE_REGS_STRING
21349 @@ -769,7 +779,7 @@ static void __kprobes
21350 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21351 {
21352 unsigned long *tos = stack_addr(regs);
21353 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21354 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21355 unsigned long orig_ip = (unsigned long)p->addr;
21356 kprobe_opcode_t *insn = p->ainsn.insn;
21357
21358 @@ -951,7 +961,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21359 struct die_args *args = data;
21360 int ret = NOTIFY_DONE;
21361
21362 - if (args->regs && user_mode_vm(args->regs))
21363 + if (args->regs && user_mode(args->regs))
21364 return ret;
21365
21366 switch (val) {
21367 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21368 index 76dc6f0..66bdfc3 100644
21369 --- a/arch/x86/kernel/kprobes/opt.c
21370 +++ b/arch/x86/kernel/kprobes/opt.c
21371 @@ -79,6 +79,7 @@ found:
21372 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21373 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21374 {
21375 + pax_open_kernel();
21376 #ifdef CONFIG_X86_64
21377 *addr++ = 0x48;
21378 *addr++ = 0xbf;
21379 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21380 *addr++ = 0xb8;
21381 #endif
21382 *(unsigned long *)addr = val;
21383 + pax_close_kernel();
21384 }
21385
21386 static void __used __kprobes kprobes_optinsn_template_holder(void)
21387 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21388 * Verify if the address gap is in 2GB range, because this uses
21389 * a relative jump.
21390 */
21391 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21392 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21393 if (abs(rel) > 0x7fffffff)
21394 return -ERANGE;
21395
21396 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21397 op->optinsn.size = ret;
21398
21399 /* Copy arch-dep-instance from template */
21400 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21401 + pax_open_kernel();
21402 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21403 + pax_close_kernel();
21404
21405 /* Set probe information */
21406 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21407
21408 /* Set probe function call */
21409 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21410 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21411
21412 /* Set returning jmp instruction at the tail of out-of-line buffer */
21413 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21414 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21415 (u8 *)op->kp.addr + op->optinsn.size);
21416
21417 flush_icache_range((unsigned long) buf,
21418 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21419 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21420
21421 /* Backup instructions which will be replaced by jump address */
21422 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21423 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21424 RELATIVE_ADDR_SIZE);
21425
21426 insn_buf[0] = RELATIVEJUMP_OPCODE;
21427 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21428 /* This kprobe is really able to run optimized path. */
21429 op = container_of(p, struct optimized_kprobe, kp);
21430 /* Detour through copied instructions */
21431 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21432 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21433 if (!reenter)
21434 reset_current_kprobe();
21435 preempt_enable_no_resched();
21436 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21437 index b686a90..60d36fb 100644
21438 --- a/arch/x86/kernel/kvm.c
21439 +++ b/arch/x86/kernel/kvm.c
21440 @@ -453,7 +453,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21441 return NOTIFY_OK;
21442 }
21443
21444 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21445 +static struct notifier_block kvm_cpu_notifier = {
21446 .notifier_call = kvm_cpu_notify,
21447 };
21448 #endif
21449 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21450 index ebc9873..1b9724b 100644
21451 --- a/arch/x86/kernel/ldt.c
21452 +++ b/arch/x86/kernel/ldt.c
21453 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21454 if (reload) {
21455 #ifdef CONFIG_SMP
21456 preempt_disable();
21457 - load_LDT(pc);
21458 + load_LDT_nolock(pc);
21459 if (!cpumask_equal(mm_cpumask(current->mm),
21460 cpumask_of(smp_processor_id())))
21461 smp_call_function(flush_ldt, current->mm, 1);
21462 preempt_enable();
21463 #else
21464 - load_LDT(pc);
21465 + load_LDT_nolock(pc);
21466 #endif
21467 }
21468 if (oldsize) {
21469 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21470 return err;
21471
21472 for (i = 0; i < old->size; i++)
21473 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21474 + write_ldt_entry(new->ldt, i, old->ldt + i);
21475 return 0;
21476 }
21477
21478 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21479 retval = copy_ldt(&mm->context, &old_mm->context);
21480 mutex_unlock(&old_mm->context.lock);
21481 }
21482 +
21483 + if (tsk == current) {
21484 + mm->context.vdso = 0;
21485 +
21486 +#ifdef CONFIG_X86_32
21487 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21488 + mm->context.user_cs_base = 0UL;
21489 + mm->context.user_cs_limit = ~0UL;
21490 +
21491 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21492 + cpus_clear(mm->context.cpu_user_cs_mask);
21493 +#endif
21494 +
21495 +#endif
21496 +#endif
21497 +
21498 + }
21499 +
21500 return retval;
21501 }
21502
21503 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21504 }
21505 }
21506
21507 +#ifdef CONFIG_PAX_SEGMEXEC
21508 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21509 + error = -EINVAL;
21510 + goto out_unlock;
21511 + }
21512 +#endif
21513 +
21514 fill_ldt(&ldt, &ldt_info);
21515 if (oldmode)
21516 ldt.avl = 0;
21517 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21518 index 5b19e4d..6476a76 100644
21519 --- a/arch/x86/kernel/machine_kexec_32.c
21520 +++ b/arch/x86/kernel/machine_kexec_32.c
21521 @@ -26,7 +26,7 @@
21522 #include <asm/cacheflush.h>
21523 #include <asm/debugreg.h>
21524
21525 -static void set_idt(void *newidt, __u16 limit)
21526 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21527 {
21528 struct desc_ptr curidt;
21529
21530 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21531 }
21532
21533
21534 -static void set_gdt(void *newgdt, __u16 limit)
21535 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21536 {
21537 struct desc_ptr curgdt;
21538
21539 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21540 }
21541
21542 control_page = page_address(image->control_code_page);
21543 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21544 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21545
21546 relocate_kernel_ptr = control_page;
21547 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21548 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21549 index 22db92b..d546bec 100644
21550 --- a/arch/x86/kernel/microcode_core.c
21551 +++ b/arch/x86/kernel/microcode_core.c
21552 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21553 return NOTIFY_OK;
21554 }
21555
21556 -static struct notifier_block __refdata mc_cpu_notifier = {
21557 +static struct notifier_block mc_cpu_notifier = {
21558 .notifier_call = mc_cpu_callback,
21559 };
21560
21561 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21562 index 5fb2ceb..3ae90bb 100644
21563 --- a/arch/x86/kernel/microcode_intel.c
21564 +++ b/arch/x86/kernel/microcode_intel.c
21565 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21566
21567 static int get_ucode_user(void *to, const void *from, size_t n)
21568 {
21569 - return copy_from_user(to, from, n);
21570 + return copy_from_user(to, (const void __force_user *)from, n);
21571 }
21572
21573 static enum ucode_state
21574 request_microcode_user(int cpu, const void __user *buf, size_t size)
21575 {
21576 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21577 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21578 }
21579
21580 static void microcode_fini_cpu(int cpu)
21581 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21582 index 216a4d7..228255a 100644
21583 --- a/arch/x86/kernel/module.c
21584 +++ b/arch/x86/kernel/module.c
21585 @@ -43,15 +43,60 @@ do { \
21586 } while (0)
21587 #endif
21588
21589 -void *module_alloc(unsigned long size)
21590 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21591 {
21592 - if (PAGE_ALIGN(size) > MODULES_LEN)
21593 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21594 return NULL;
21595 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21596 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21597 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21598 -1, __builtin_return_address(0));
21599 }
21600
21601 +void *module_alloc(unsigned long size)
21602 +{
21603 +
21604 +#ifdef CONFIG_PAX_KERNEXEC
21605 + return __module_alloc(size, PAGE_KERNEL);
21606 +#else
21607 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21608 +#endif
21609 +
21610 +}
21611 +
21612 +#ifdef CONFIG_PAX_KERNEXEC
21613 +#ifdef CONFIG_X86_32
21614 +void *module_alloc_exec(unsigned long size)
21615 +{
21616 + struct vm_struct *area;
21617 +
21618 + if (size == 0)
21619 + return NULL;
21620 +
21621 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21622 + return area ? area->addr : NULL;
21623 +}
21624 +EXPORT_SYMBOL(module_alloc_exec);
21625 +
21626 +void module_free_exec(struct module *mod, void *module_region)
21627 +{
21628 + vunmap(module_region);
21629 +}
21630 +EXPORT_SYMBOL(module_free_exec);
21631 +#else
21632 +void module_free_exec(struct module *mod, void *module_region)
21633 +{
21634 + module_free(mod, module_region);
21635 +}
21636 +EXPORT_SYMBOL(module_free_exec);
21637 +
21638 +void *module_alloc_exec(unsigned long size)
21639 +{
21640 + return __module_alloc(size, PAGE_KERNEL_RX);
21641 +}
21642 +EXPORT_SYMBOL(module_alloc_exec);
21643 +#endif
21644 +#endif
21645 +
21646 #ifdef CONFIG_X86_32
21647 int apply_relocate(Elf32_Shdr *sechdrs,
21648 const char *strtab,
21649 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21650 unsigned int i;
21651 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21652 Elf32_Sym *sym;
21653 - uint32_t *location;
21654 + uint32_t *plocation, location;
21655
21656 DEBUGP("Applying relocate section %u to %u\n",
21657 relsec, sechdrs[relsec].sh_info);
21658 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21659 /* This is where to make the change */
21660 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21661 - + rel[i].r_offset;
21662 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21663 + location = (uint32_t)plocation;
21664 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21665 + plocation = ktla_ktva((void *)plocation);
21666 /* This is the symbol it is referring to. Note that all
21667 undefined symbols have been resolved. */
21668 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21669 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21670 switch (ELF32_R_TYPE(rel[i].r_info)) {
21671 case R_386_32:
21672 /* We add the value into the location given */
21673 - *location += sym->st_value;
21674 + pax_open_kernel();
21675 + *plocation += sym->st_value;
21676 + pax_close_kernel();
21677 break;
21678 case R_386_PC32:
21679 /* Add the value, subtract its position */
21680 - *location += sym->st_value - (uint32_t)location;
21681 + pax_open_kernel();
21682 + *plocation += sym->st_value - location;
21683 + pax_close_kernel();
21684 break;
21685 default:
21686 pr_err("%s: Unknown relocation: %u\n",
21687 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21688 case R_X86_64_NONE:
21689 break;
21690 case R_X86_64_64:
21691 + pax_open_kernel();
21692 *(u64 *)loc = val;
21693 + pax_close_kernel();
21694 break;
21695 case R_X86_64_32:
21696 + pax_open_kernel();
21697 *(u32 *)loc = val;
21698 + pax_close_kernel();
21699 if (val != *(u32 *)loc)
21700 goto overflow;
21701 break;
21702 case R_X86_64_32S:
21703 + pax_open_kernel();
21704 *(s32 *)loc = val;
21705 + pax_close_kernel();
21706 if ((s64)val != *(s32 *)loc)
21707 goto overflow;
21708 break;
21709 case R_X86_64_PC32:
21710 val -= (u64)loc;
21711 + pax_open_kernel();
21712 *(u32 *)loc = val;
21713 + pax_close_kernel();
21714 +
21715 #if 0
21716 if ((s64)val != *(s32 *)loc)
21717 goto overflow;
21718 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21719 index ce13049..e2e9c3c 100644
21720 --- a/arch/x86/kernel/msr.c
21721 +++ b/arch/x86/kernel/msr.c
21722 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21723 return notifier_from_errno(err);
21724 }
21725
21726 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21727 +static struct notifier_block msr_class_cpu_notifier = {
21728 .notifier_call = msr_class_cpu_callback,
21729 };
21730
21731 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21732 index 6030805..2d33f21 100644
21733 --- a/arch/x86/kernel/nmi.c
21734 +++ b/arch/x86/kernel/nmi.c
21735 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21736 return handled;
21737 }
21738
21739 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21740 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21741 {
21742 struct nmi_desc *desc = nmi_to_desc(type);
21743 unsigned long flags;
21744 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21745 * event confuses some handlers (kdump uses this flag)
21746 */
21747 if (action->flags & NMI_FLAG_FIRST)
21748 - list_add_rcu(&action->list, &desc->head);
21749 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21750 else
21751 - list_add_tail_rcu(&action->list, &desc->head);
21752 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21753
21754 spin_unlock_irqrestore(&desc->lock, flags);
21755 return 0;
21756 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21757 if (!strcmp(n->name, name)) {
21758 WARN(in_nmi(),
21759 "Trying to free NMI (%s) from NMI context!\n", n->name);
21760 - list_del_rcu(&n->list);
21761 + pax_list_del_rcu((struct list_head *)&n->list);
21762 break;
21763 }
21764 }
21765 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21766 dotraplinkage notrace __kprobes void
21767 do_nmi(struct pt_regs *regs, long error_code)
21768 {
21769 +
21770 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21771 + if (!user_mode(regs)) {
21772 + unsigned long cs = regs->cs & 0xFFFF;
21773 + unsigned long ip = ktva_ktla(regs->ip);
21774 +
21775 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21776 + regs->ip = ip;
21777 + }
21778 +#endif
21779 +
21780 nmi_nesting_preprocess(regs);
21781
21782 nmi_enter();
21783 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21784 index 6d9582e..f746287 100644
21785 --- a/arch/x86/kernel/nmi_selftest.c
21786 +++ b/arch/x86/kernel/nmi_selftest.c
21787 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21788 {
21789 /* trap all the unknown NMIs we may generate */
21790 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21791 - __initdata);
21792 + __initconst);
21793 }
21794
21795 static void __init cleanup_nmi_testsuite(void)
21796 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21797 unsigned long timeout;
21798
21799 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21800 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21801 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21802 nmi_fail = FAILURE;
21803 return;
21804 }
21805 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21806 index 676b8c7..870ba04 100644
21807 --- a/arch/x86/kernel/paravirt-spinlocks.c
21808 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21809 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21810 arch_spin_lock(lock);
21811 }
21812
21813 -struct pv_lock_ops pv_lock_ops = {
21814 +struct pv_lock_ops pv_lock_ops __read_only = {
21815 #ifdef CONFIG_SMP
21816 .spin_is_locked = __ticket_spin_is_locked,
21817 .spin_is_contended = __ticket_spin_is_contended,
21818 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21819 index 8bfb335..c1463c6 100644
21820 --- a/arch/x86/kernel/paravirt.c
21821 +++ b/arch/x86/kernel/paravirt.c
21822 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21823 {
21824 return x;
21825 }
21826 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21827 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21828 +#endif
21829
21830 void __init default_banner(void)
21831 {
21832 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21833 if (opfunc == NULL)
21834 /* If there's no function, patch it with a ud2a (BUG) */
21835 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21836 - else if (opfunc == _paravirt_nop)
21837 + else if (opfunc == (void *)_paravirt_nop)
21838 /* If the operation is a nop, then nop the callsite */
21839 ret = paravirt_patch_nop();
21840
21841 /* identity functions just return their single argument */
21842 - else if (opfunc == _paravirt_ident_32)
21843 + else if (opfunc == (void *)_paravirt_ident_32)
21844 ret = paravirt_patch_ident_32(insnbuf, len);
21845 - else if (opfunc == _paravirt_ident_64)
21846 + else if (opfunc == (void *)_paravirt_ident_64)
21847 ret = paravirt_patch_ident_64(insnbuf, len);
21848 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21849 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21850 + ret = paravirt_patch_ident_64(insnbuf, len);
21851 +#endif
21852
21853 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21854 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21855 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21856 if (insn_len > len || start == NULL)
21857 insn_len = len;
21858 else
21859 - memcpy(insnbuf, start, insn_len);
21860 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21861
21862 return insn_len;
21863 }
21864 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21865 return this_cpu_read(paravirt_lazy_mode);
21866 }
21867
21868 -struct pv_info pv_info = {
21869 +struct pv_info pv_info __read_only = {
21870 .name = "bare hardware",
21871 .paravirt_enabled = 0,
21872 .kernel_rpl = 0,
21873 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21874 #endif
21875 };
21876
21877 -struct pv_init_ops pv_init_ops = {
21878 +struct pv_init_ops pv_init_ops __read_only = {
21879 .patch = native_patch,
21880 };
21881
21882 -struct pv_time_ops pv_time_ops = {
21883 +struct pv_time_ops pv_time_ops __read_only = {
21884 .sched_clock = native_sched_clock,
21885 .steal_clock = native_steal_clock,
21886 };
21887
21888 -struct pv_irq_ops pv_irq_ops = {
21889 +struct pv_irq_ops pv_irq_ops __read_only = {
21890 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21891 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21892 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21893 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21894 #endif
21895 };
21896
21897 -struct pv_cpu_ops pv_cpu_ops = {
21898 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21899 .cpuid = native_cpuid,
21900 .get_debugreg = native_get_debugreg,
21901 .set_debugreg = native_set_debugreg,
21902 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21903 .end_context_switch = paravirt_nop,
21904 };
21905
21906 -struct pv_apic_ops pv_apic_ops = {
21907 +struct pv_apic_ops pv_apic_ops __read_only= {
21908 #ifdef CONFIG_X86_LOCAL_APIC
21909 .startup_ipi_hook = paravirt_nop,
21910 #endif
21911 };
21912
21913 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21914 +#ifdef CONFIG_X86_32
21915 +#ifdef CONFIG_X86_PAE
21916 +/* 64-bit pagetable entries */
21917 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21918 +#else
21919 /* 32-bit pagetable entries */
21920 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21921 +#endif
21922 #else
21923 /* 64-bit pagetable entries */
21924 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21925 #endif
21926
21927 -struct pv_mmu_ops pv_mmu_ops = {
21928 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21929
21930 .read_cr2 = native_read_cr2,
21931 .write_cr2 = native_write_cr2,
21932 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21933 .make_pud = PTE_IDENT,
21934
21935 .set_pgd = native_set_pgd,
21936 + .set_pgd_batched = native_set_pgd_batched,
21937 #endif
21938 #endif /* PAGETABLE_LEVELS >= 3 */
21939
21940 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21941 },
21942
21943 .set_fixmap = native_set_fixmap,
21944 +
21945 +#ifdef CONFIG_PAX_KERNEXEC
21946 + .pax_open_kernel = native_pax_open_kernel,
21947 + .pax_close_kernel = native_pax_close_kernel,
21948 +#endif
21949 +
21950 };
21951
21952 EXPORT_SYMBOL_GPL(pv_time_ops);
21953 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
21954 index 299d493..2ccb0ee 100644
21955 --- a/arch/x86/kernel/pci-calgary_64.c
21956 +++ b/arch/x86/kernel/pci-calgary_64.c
21957 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
21958 tce_space = be64_to_cpu(readq(target));
21959 tce_space = tce_space & TAR_SW_BITS;
21960
21961 - tce_space = tce_space & (~specified_table_size);
21962 + tce_space = tce_space & (~(unsigned long)specified_table_size);
21963 info->tce_space = (u64 *)__va(tce_space);
21964 }
21965 }
21966 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21967 index 35ccf75..7a15747 100644
21968 --- a/arch/x86/kernel/pci-iommu_table.c
21969 +++ b/arch/x86/kernel/pci-iommu_table.c
21970 @@ -2,7 +2,7 @@
21971 #include <asm/iommu_table.h>
21972 #include <linux/string.h>
21973 #include <linux/kallsyms.h>
21974 -
21975 +#include <linux/sched.h>
21976
21977 #define DEBUG 1
21978
21979 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21980 index 6c483ba..d10ce2f 100644
21981 --- a/arch/x86/kernel/pci-swiotlb.c
21982 +++ b/arch/x86/kernel/pci-swiotlb.c
21983 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21984 void *vaddr, dma_addr_t dma_addr,
21985 struct dma_attrs *attrs)
21986 {
21987 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21988 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21989 }
21990
21991 static struct dma_map_ops swiotlb_dma_ops = {
21992 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
21993 index 14ae100..752a4f6 100644
21994 --- a/arch/x86/kernel/process.c
21995 +++ b/arch/x86/kernel/process.c
21996 @@ -36,7 +36,8 @@
21997 * section. Since TSS's are completely CPU-local, we want them
21998 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
21999 */
22000 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22001 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22002 +EXPORT_SYMBOL(init_tss);
22003
22004 #ifdef CONFIG_X86_64
22005 static DEFINE_PER_CPU(unsigned char, is_idle);
22006 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22007 task_xstate_cachep =
22008 kmem_cache_create("task_xstate", xstate_size,
22009 __alignof__(union thread_xstate),
22010 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22011 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22012 }
22013
22014 /*
22015 @@ -105,7 +106,7 @@ void exit_thread(void)
22016 unsigned long *bp = t->io_bitmap_ptr;
22017
22018 if (bp) {
22019 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22020 + struct tss_struct *tss = init_tss + get_cpu();
22021
22022 t->io_bitmap_ptr = NULL;
22023 clear_thread_flag(TIF_IO_BITMAP);
22024 @@ -136,7 +137,7 @@ void show_regs_common(void)
22025 board = dmi_get_system_info(DMI_BOARD_NAME);
22026
22027 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22028 - current->pid, current->comm, print_tainted(),
22029 + task_pid_nr(current), current->comm, print_tainted(),
22030 init_utsname()->release,
22031 (int)strcspn(init_utsname()->version, " "),
22032 init_utsname()->version,
22033 @@ -149,6 +150,9 @@ void flush_thread(void)
22034 {
22035 struct task_struct *tsk = current;
22036
22037 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22038 + loadsegment(gs, 0);
22039 +#endif
22040 flush_ptrace_hw_breakpoint(tsk);
22041 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22042 drop_init_fpu(tsk);
22043 @@ -295,7 +299,7 @@ static void __exit_idle(void)
22044 void exit_idle(void)
22045 {
22046 /* idle loop has pid 0 */
22047 - if (current->pid)
22048 + if (task_pid_nr(current))
22049 return;
22050 __exit_idle();
22051 }
22052 @@ -398,7 +402,7 @@ bool xen_set_default_idle(void)
22053 return ret;
22054 }
22055 #endif
22056 -void stop_this_cpu(void *dummy)
22057 +__noreturn void stop_this_cpu(void *dummy)
22058 {
22059 local_irq_disable();
22060 /*
22061 @@ -544,16 +548,37 @@ static int __init idle_setup(char *str)
22062 }
22063 early_param("idle", idle_setup);
22064
22065 -unsigned long arch_align_stack(unsigned long sp)
22066 +#ifdef CONFIG_PAX_RANDKSTACK
22067 +void pax_randomize_kstack(struct pt_regs *regs)
22068 {
22069 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22070 - sp -= get_random_int() % 8192;
22071 - return sp & ~0xf;
22072 -}
22073 + struct thread_struct *thread = &current->thread;
22074 + unsigned long time;
22075
22076 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22077 -{
22078 - unsigned long range_end = mm->brk + 0x02000000;
22079 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22080 -}
22081 + if (!randomize_va_space)
22082 + return;
22083 +
22084 + if (v8086_mode(regs))
22085 + return;
22086
22087 + rdtscl(time);
22088 +
22089 + /* P4 seems to return a 0 LSB, ignore it */
22090 +#ifdef CONFIG_MPENTIUM4
22091 + time &= 0x3EUL;
22092 + time <<= 2;
22093 +#elif defined(CONFIG_X86_64)
22094 + time &= 0xFUL;
22095 + time <<= 4;
22096 +#else
22097 + time &= 0x1FUL;
22098 + time <<= 3;
22099 +#endif
22100 +
22101 + thread->sp0 ^= time;
22102 + load_sp0(init_tss + smp_processor_id(), thread);
22103 +
22104 +#ifdef CONFIG_X86_64
22105 + this_cpu_write(kernel_stack, thread->sp0);
22106 +#endif
22107 +}
22108 +#endif
22109 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22110 index b5a8905..d9cacac 100644
22111 --- a/arch/x86/kernel/process_32.c
22112 +++ b/arch/x86/kernel/process_32.c
22113 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22114 unsigned long thread_saved_pc(struct task_struct *tsk)
22115 {
22116 return ((unsigned long *)tsk->thread.sp)[3];
22117 +//XXX return tsk->thread.eip;
22118 }
22119
22120 void __show_regs(struct pt_regs *regs, int all)
22121 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22122 unsigned long sp;
22123 unsigned short ss, gs;
22124
22125 - if (user_mode_vm(regs)) {
22126 + if (user_mode(regs)) {
22127 sp = regs->sp;
22128 ss = regs->ss & 0xffff;
22129 - gs = get_user_gs(regs);
22130 } else {
22131 sp = kernel_stack_pointer(regs);
22132 savesegment(ss, ss);
22133 - savesegment(gs, gs);
22134 }
22135 + gs = get_user_gs(regs);
22136
22137 show_regs_common();
22138
22139 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22140 (u16)regs->cs, regs->ip, regs->flags,
22141 - smp_processor_id());
22142 + raw_smp_processor_id());
22143 print_symbol("EIP is at %s\n", regs->ip);
22144
22145 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22146 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22147 int copy_thread(unsigned long clone_flags, unsigned long sp,
22148 unsigned long arg, struct task_struct *p)
22149 {
22150 - struct pt_regs *childregs = task_pt_regs(p);
22151 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22152 struct task_struct *tsk;
22153 int err;
22154
22155 p->thread.sp = (unsigned long) childregs;
22156 p->thread.sp0 = (unsigned long) (childregs+1);
22157 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22158
22159 if (unlikely(p->flags & PF_KTHREAD)) {
22160 /* kernel thread */
22161 memset(childregs, 0, sizeof(struct pt_regs));
22162 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22163 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22164 - childregs->ds = __USER_DS;
22165 - childregs->es = __USER_DS;
22166 + savesegment(gs, childregs->gs);
22167 + childregs->ds = __KERNEL_DS;
22168 + childregs->es = __KERNEL_DS;
22169 childregs->fs = __KERNEL_PERCPU;
22170 childregs->bx = sp; /* function */
22171 childregs->bp = arg;
22172 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22173 struct thread_struct *prev = &prev_p->thread,
22174 *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 fpu_switch_t fpu;
22179
22180 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22181 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22182 */
22183 lazy_save_gs(prev->gs);
22184
22185 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22186 + __set_fs(task_thread_info(next_p)->addr_limit);
22187 +#endif
22188 +
22189 /*
22190 * Load the per-thread Thread-Local Storage descriptor.
22191 */
22192 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22193 */
22194 arch_end_context_switch(next_p);
22195
22196 + this_cpu_write(current_task, next_p);
22197 + this_cpu_write(current_tinfo, &next_p->tinfo);
22198 +
22199 /*
22200 * Restore %gs if needed (which is common)
22201 */
22202 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22203
22204 switch_fpu_finish(next_p, fpu);
22205
22206 - this_cpu_write(current_task, next_p);
22207 -
22208 return prev_p;
22209 }
22210
22211 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22212 } while (count++ < 16);
22213 return 0;
22214 }
22215 -
22216 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22217 index 0f49677..fcbf88c 100644
22218 --- a/arch/x86/kernel/process_64.c
22219 +++ b/arch/x86/kernel/process_64.c
22220 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22221 struct pt_regs *childregs;
22222 struct task_struct *me = current;
22223
22224 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22225 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22226 childregs = task_pt_regs(p);
22227 p->thread.sp = (unsigned long) childregs;
22228 p->thread.usersp = me->thread.usersp;
22229 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22230 set_tsk_thread_flag(p, TIF_FORK);
22231 p->fpu_counter = 0;
22232 p->thread.io_bitmap_ptr = NULL;
22233 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22234 struct thread_struct *prev = &prev_p->thread;
22235 struct thread_struct *next = &next_p->thread;
22236 int cpu = smp_processor_id();
22237 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22238 + struct tss_struct *tss = init_tss + cpu;
22239 unsigned fsindex, gsindex;
22240 fpu_switch_t fpu;
22241
22242 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22243 prev->usersp = this_cpu_read(old_rsp);
22244 this_cpu_write(old_rsp, next->usersp);
22245 this_cpu_write(current_task, next_p);
22246 + this_cpu_write(current_tinfo, &next_p->tinfo);
22247
22248 - this_cpu_write(kernel_stack,
22249 - (unsigned long)task_stack_page(next_p) +
22250 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22251 + this_cpu_write(kernel_stack, next->sp0);
22252
22253 /*
22254 * Now maybe reload the debug registers and handle I/O bitmaps
22255 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22256 if (!p || p == current || p->state == TASK_RUNNING)
22257 return 0;
22258 stack = (unsigned long)task_stack_page(p);
22259 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22260 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22261 return 0;
22262 fp = *(u64 *)(p->thread.sp);
22263 do {
22264 - if (fp < (unsigned long)stack ||
22265 - fp >= (unsigned long)stack+THREAD_SIZE)
22266 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22267 return 0;
22268 ip = *(u64 *)(fp+8);
22269 if (!in_sched_functions(ip))
22270 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22271 index 29a8120..a50b5ee 100644
22272 --- a/arch/x86/kernel/ptrace.c
22273 +++ b/arch/x86/kernel/ptrace.c
22274 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22275 {
22276 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22277 unsigned long sp = (unsigned long)&regs->sp;
22278 - struct thread_info *tinfo;
22279
22280 - if (context == (sp & ~(THREAD_SIZE - 1)))
22281 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22282 return sp;
22283
22284 - tinfo = (struct thread_info *)context;
22285 - if (tinfo->previous_esp)
22286 - return tinfo->previous_esp;
22287 + sp = *(unsigned long *)context;
22288 + if (sp)
22289 + return sp;
22290
22291 return (unsigned long)regs;
22292 }
22293 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22294 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22295 {
22296 int i;
22297 - int dr7 = 0;
22298 + unsigned long dr7 = 0;
22299 struct arch_hw_breakpoint *info;
22300
22301 for (i = 0; i < HBP_NUM; i++) {
22302 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22303 unsigned long addr, unsigned long data)
22304 {
22305 int ret;
22306 - unsigned long __user *datap = (unsigned long __user *)data;
22307 + unsigned long __user *datap = (__force unsigned long __user *)data;
22308
22309 switch (request) {
22310 /* read the word at location addr in the USER area. */
22311 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22312 if ((int) addr < 0)
22313 return -EIO;
22314 ret = do_get_thread_area(child, addr,
22315 - (struct user_desc __user *)data);
22316 + (__force struct user_desc __user *) data);
22317 break;
22318
22319 case PTRACE_SET_THREAD_AREA:
22320 if ((int) addr < 0)
22321 return -EIO;
22322 ret = do_set_thread_area(child, addr,
22323 - (struct user_desc __user *)data, 0);
22324 + (__force struct user_desc __user *) data, 0);
22325 break;
22326 #endif
22327
22328 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22329
22330 #ifdef CONFIG_X86_64
22331
22332 -static struct user_regset x86_64_regsets[] __read_mostly = {
22333 +static user_regset_no_const x86_64_regsets[] __read_only = {
22334 [REGSET_GENERAL] = {
22335 .core_note_type = NT_PRSTATUS,
22336 .n = sizeof(struct user_regs_struct) / sizeof(long),
22337 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22338 #endif /* CONFIG_X86_64 */
22339
22340 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22341 -static struct user_regset x86_32_regsets[] __read_mostly = {
22342 +static user_regset_no_const x86_32_regsets[] __read_only = {
22343 [REGSET_GENERAL] = {
22344 .core_note_type = NT_PRSTATUS,
22345 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22346 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22347 */
22348 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22349
22350 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22351 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22352 {
22353 #ifdef CONFIG_X86_64
22354 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22355 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22356 memset(info, 0, sizeof(*info));
22357 info->si_signo = SIGTRAP;
22358 info->si_code = si_code;
22359 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22360 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22361 }
22362
22363 void user_single_step_siginfo(struct task_struct *tsk,
22364 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22365 # define IS_IA32 0
22366 #endif
22367
22368 +#ifdef CONFIG_GRKERNSEC_SETXID
22369 +extern void gr_delayed_cred_worker(void);
22370 +#endif
22371 +
22372 /*
22373 * We must return the syscall number to actually look up in the table.
22374 * This can be -1L to skip running any syscall at all.
22375 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22376
22377 user_exit();
22378
22379 +#ifdef CONFIG_GRKERNSEC_SETXID
22380 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22381 + gr_delayed_cred_worker();
22382 +#endif
22383 +
22384 /*
22385 * If we stepped into a sysenter/syscall insn, it trapped in
22386 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22387 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22388 */
22389 user_exit();
22390
22391 +#ifdef CONFIG_GRKERNSEC_SETXID
22392 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22393 + gr_delayed_cred_worker();
22394 +#endif
22395 +
22396 audit_syscall_exit(regs);
22397
22398 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22399 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22400 index 2cb9470..ff1fd80 100644
22401 --- a/arch/x86/kernel/pvclock.c
22402 +++ b/arch/x86/kernel/pvclock.c
22403 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22404 return pv_tsc_khz;
22405 }
22406
22407 -static atomic64_t last_value = ATOMIC64_INIT(0);
22408 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22409
22410 void pvclock_resume(void)
22411 {
22412 - atomic64_set(&last_value, 0);
22413 + atomic64_set_unchecked(&last_value, 0);
22414 }
22415
22416 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22417 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22418 * updating at the same time, and one of them could be slightly behind,
22419 * making the assumption that last_value always go forward fail to hold.
22420 */
22421 - last = atomic64_read(&last_value);
22422 + last = atomic64_read_unchecked(&last_value);
22423 do {
22424 if (ret < last)
22425 return last;
22426 - last = atomic64_cmpxchg(&last_value, last, ret);
22427 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22428 } while (unlikely(last != ret));
22429
22430 return ret;
22431 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22432 index 76fa1e9..abf09ea 100644
22433 --- a/arch/x86/kernel/reboot.c
22434 +++ b/arch/x86/kernel/reboot.c
22435 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22436 EXPORT_SYMBOL(pm_power_off);
22437
22438 static const struct desc_ptr no_idt = {};
22439 -static int reboot_mode;
22440 +static unsigned short reboot_mode;
22441 enum reboot_type reboot_type = BOOT_ACPI;
22442 int reboot_force;
22443
22444 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22445
22446 void __noreturn machine_real_restart(unsigned int type)
22447 {
22448 +
22449 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22450 + struct desc_struct *gdt;
22451 +#endif
22452 +
22453 local_irq_disable();
22454
22455 /*
22456 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22457
22458 /* Jump to the identity-mapped low memory code */
22459 #ifdef CONFIG_X86_32
22460 - asm volatile("jmpl *%0" : :
22461 +
22462 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22463 + gdt = get_cpu_gdt_table(smp_processor_id());
22464 + pax_open_kernel();
22465 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22466 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22467 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22468 + loadsegment(ds, __KERNEL_DS);
22469 + loadsegment(es, __KERNEL_DS);
22470 + loadsegment(ss, __KERNEL_DS);
22471 +#endif
22472 +#ifdef CONFIG_PAX_KERNEXEC
22473 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22474 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22475 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22476 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22477 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22478 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22479 +#endif
22480 + pax_close_kernel();
22481 +#endif
22482 +
22483 + asm volatile("ljmpl *%0" : :
22484 "rm" (real_mode_header->machine_real_restart_asm),
22485 "a" (type));
22486 #else
22487 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22488 * try to force a triple fault and then cycle between hitting the keyboard
22489 * controller and doing that
22490 */
22491 -static void native_machine_emergency_restart(void)
22492 +static void __noreturn native_machine_emergency_restart(void)
22493 {
22494 int i;
22495 int attempt = 0;
22496 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22497 #endif
22498 }
22499
22500 -static void __machine_emergency_restart(int emergency)
22501 +static void __noreturn __machine_emergency_restart(int emergency)
22502 {
22503 reboot_emergency = emergency;
22504 machine_ops.emergency_restart();
22505 }
22506
22507 -static void native_machine_restart(char *__unused)
22508 +static void __noreturn native_machine_restart(char *__unused)
22509 {
22510 pr_notice("machine restart\n");
22511
22512 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22513 __machine_emergency_restart(0);
22514 }
22515
22516 -static void native_machine_halt(void)
22517 +static void __noreturn native_machine_halt(void)
22518 {
22519 /* Stop other cpus and apics */
22520 machine_shutdown();
22521 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22522 stop_this_cpu(NULL);
22523 }
22524
22525 -static void native_machine_power_off(void)
22526 +static void __noreturn native_machine_power_off(void)
22527 {
22528 if (pm_power_off) {
22529 if (!reboot_force)
22530 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22531 }
22532 /* A fallback in case there is no PM info available */
22533 tboot_shutdown(TB_SHUTDOWN_HALT);
22534 + unreachable();
22535 }
22536
22537 -struct machine_ops machine_ops = {
22538 +struct machine_ops machine_ops __read_only = {
22539 .power_off = native_machine_power_off,
22540 .shutdown = native_machine_shutdown,
22541 .emergency_restart = native_machine_emergency_restart,
22542 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22543 index f2bb9c9..bed145d7 100644
22544 --- a/arch/x86/kernel/relocate_kernel_64.S
22545 +++ b/arch/x86/kernel/relocate_kernel_64.S
22546 @@ -11,6 +11,7 @@
22547 #include <asm/kexec.h>
22548 #include <asm/processor-flags.h>
22549 #include <asm/pgtable_types.h>
22550 +#include <asm/alternative-asm.h>
22551
22552 /*
22553 * Must be relocatable PIC code callable as a C function
22554 @@ -167,6 +168,7 @@ identity_mapped:
22555 xorq %r14, %r14
22556 xorq %r15, %r15
22557
22558 + pax_force_retaddr 0, 1
22559 ret
22560
22561 1:
22562 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22563 index fae9134..8fcd87c 100644
22564 --- a/arch/x86/kernel/setup.c
22565 +++ b/arch/x86/kernel/setup.c
22566 @@ -111,6 +111,7 @@
22567 #include <asm/mce.h>
22568 #include <asm/alternative.h>
22569 #include <asm/prom.h>
22570 +#include <asm/boot.h>
22571
22572 /*
22573 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22574 @@ -447,7 +448,7 @@ static void __init parse_setup_data(void)
22575
22576 switch (data->type) {
22577 case SETUP_E820_EXT:
22578 - parse_e820_ext(data);
22579 + parse_e820_ext((struct setup_data __force_kernel *)data);
22580 break;
22581 case SETUP_DTB:
22582 add_dtb(pa_data);
22583 @@ -774,7 +775,7 @@ static void __init trim_bios_range(void)
22584 * area (640->1Mb) as ram even though it is not.
22585 * take them out.
22586 */
22587 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22588 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22589
22590 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22591 }
22592 @@ -782,7 +783,7 @@ static void __init trim_bios_range(void)
22593 /* called before trim_bios_range() to spare extra sanitize */
22594 static void __init e820_add_kernel_range(void)
22595 {
22596 - u64 start = __pa_symbol(_text);
22597 + u64 start = __pa_symbol(ktla_ktva(_text));
22598 u64 size = __pa_symbol(_end) - start;
22599
22600 /*
22601 @@ -844,8 +845,12 @@ static void __init trim_low_memory_range(void)
22602
22603 void __init setup_arch(char **cmdline_p)
22604 {
22605 +#ifdef CONFIG_X86_32
22606 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
22607 +#else
22608 memblock_reserve(__pa_symbol(_text),
22609 (unsigned long)__bss_stop - (unsigned long)_text);
22610 +#endif
22611
22612 early_reserve_initrd();
22613
22614 @@ -937,14 +942,14 @@ void __init setup_arch(char **cmdline_p)
22615
22616 if (!boot_params.hdr.root_flags)
22617 root_mountflags &= ~MS_RDONLY;
22618 - init_mm.start_code = (unsigned long) _text;
22619 - init_mm.end_code = (unsigned long) _etext;
22620 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22621 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22622 init_mm.end_data = (unsigned long) _edata;
22623 init_mm.brk = _brk_end;
22624
22625 - code_resource.start = __pa_symbol(_text);
22626 - code_resource.end = __pa_symbol(_etext)-1;
22627 - data_resource.start = __pa_symbol(_etext);
22628 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22629 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22630 + data_resource.start = __pa_symbol(_sdata);
22631 data_resource.end = __pa_symbol(_edata)-1;
22632 bss_resource.start = __pa_symbol(__bss_start);
22633 bss_resource.end = __pa_symbol(__bss_stop)-1;
22634 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22635 index 5cdff03..80fa283 100644
22636 --- a/arch/x86/kernel/setup_percpu.c
22637 +++ b/arch/x86/kernel/setup_percpu.c
22638 @@ -21,19 +21,17 @@
22639 #include <asm/cpu.h>
22640 #include <asm/stackprotector.h>
22641
22642 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22643 +#ifdef CONFIG_SMP
22644 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22645 EXPORT_PER_CPU_SYMBOL(cpu_number);
22646 +#endif
22647
22648 -#ifdef CONFIG_X86_64
22649 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22650 -#else
22651 -#define BOOT_PERCPU_OFFSET 0
22652 -#endif
22653
22654 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22655 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22656
22657 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22658 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22659 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22660 };
22661 EXPORT_SYMBOL(__per_cpu_offset);
22662 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22663 {
22664 #ifdef CONFIG_NEED_MULTIPLE_NODES
22665 pg_data_t *last = NULL;
22666 - unsigned int cpu;
22667 + int cpu;
22668
22669 for_each_possible_cpu(cpu) {
22670 int node = early_cpu_to_node(cpu);
22671 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22672 {
22673 #ifdef CONFIG_X86_32
22674 struct desc_struct gdt;
22675 + unsigned long base = per_cpu_offset(cpu);
22676
22677 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22678 - 0x2 | DESCTYPE_S, 0x8);
22679 - gdt.s = 1;
22680 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22681 + 0x83 | DESCTYPE_S, 0xC);
22682 write_gdt_entry(get_cpu_gdt_table(cpu),
22683 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22684 #endif
22685 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22686 /* alrighty, percpu areas up and running */
22687 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22688 for_each_possible_cpu(cpu) {
22689 +#ifdef CONFIG_CC_STACKPROTECTOR
22690 +#ifdef CONFIG_X86_32
22691 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22692 +#endif
22693 +#endif
22694 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22695 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22696 per_cpu(cpu_number, cpu) = cpu;
22697 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22698 */
22699 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22700 #endif
22701 +#ifdef CONFIG_CC_STACKPROTECTOR
22702 +#ifdef CONFIG_X86_32
22703 + if (!cpu)
22704 + per_cpu(stack_canary.canary, cpu) = canary;
22705 +#endif
22706 +#endif
22707 /*
22708 * Up to this point, the boot CPU has been using .init.data
22709 * area. Reload any changed state for the boot CPU.
22710 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22711 index 6956299..f20beae 100644
22712 --- a/arch/x86/kernel/signal.c
22713 +++ b/arch/x86/kernel/signal.c
22714 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22715 * Align the stack pointer according to the i386 ABI,
22716 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22717 */
22718 - sp = ((sp + 4) & -16ul) - 4;
22719 + sp = ((sp - 12) & -16ul) - 4;
22720 #else /* !CONFIG_X86_32 */
22721 sp = round_down(sp, 16) - 8;
22722 #endif
22723 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22724 }
22725
22726 if (current->mm->context.vdso)
22727 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22728 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22729 else
22730 - restorer = &frame->retcode;
22731 + restorer = (void __user *)&frame->retcode;
22732 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22733 restorer = ksig->ka.sa.sa_restorer;
22734
22735 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22736 * reasons and because gdb uses it as a signature to notice
22737 * signal handler stack frames.
22738 */
22739 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22740 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22741
22742 if (err)
22743 return -EFAULT;
22744 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22745 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22746
22747 /* Set up to return from userspace. */
22748 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22749 + if (current->mm->context.vdso)
22750 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22751 + else
22752 + restorer = (void __user *)&frame->retcode;
22753 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22754 restorer = ksig->ka.sa.sa_restorer;
22755 put_user_ex(restorer, &frame->pretcode);
22756 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22757 * reasons and because gdb uses it as a signature to notice
22758 * signal handler stack frames.
22759 */
22760 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22761 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22762 } put_user_catch(err);
22763
22764 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22765 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22766 {
22767 int usig = signr_convert(ksig->sig);
22768 sigset_t *set = sigmask_to_save();
22769 - compat_sigset_t *cset = (compat_sigset_t *) set;
22770 + sigset_t sigcopy;
22771 + compat_sigset_t *cset;
22772 +
22773 + sigcopy = *set;
22774 +
22775 + cset = (compat_sigset_t *) &sigcopy;
22776
22777 /* Set up the stack frame */
22778 if (is_ia32_frame()) {
22779 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22780 } else if (is_x32_frame()) {
22781 return x32_setup_rt_frame(ksig, cset, regs);
22782 } else {
22783 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22784 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22785 }
22786 }
22787
22788 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22789 index 48d2b7d..90d328a 100644
22790 --- a/arch/x86/kernel/smp.c
22791 +++ b/arch/x86/kernel/smp.c
22792 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22793
22794 __setup("nonmi_ipi", nonmi_ipi_setup);
22795
22796 -struct smp_ops smp_ops = {
22797 +struct smp_ops smp_ops __read_only = {
22798 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22799 .smp_prepare_cpus = native_smp_prepare_cpus,
22800 .smp_cpus_done = native_smp_cpus_done,
22801 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22802 index 9f190a2..90a0688 100644
22803 --- a/arch/x86/kernel/smpboot.c
22804 +++ b/arch/x86/kernel/smpboot.c
22805 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22806 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22807 (THREAD_SIZE + task_stack_page(idle))) - 1);
22808 per_cpu(current_task, cpu) = idle;
22809 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22810
22811 #ifdef CONFIG_X86_32
22812 /* Stack for startup_32 can be just as for start_secondary onwards */
22813 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22814 #else
22815 clear_tsk_thread_flag(idle, TIF_FORK);
22816 initial_gs = per_cpu_offset(cpu);
22817 - per_cpu(kernel_stack, cpu) =
22818 - (unsigned long)task_stack_page(idle) -
22819 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22820 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22821 #endif
22822 +
22823 + pax_open_kernel();
22824 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22825 + pax_close_kernel();
22826 +
22827 initial_code = (unsigned long)start_secondary;
22828 stack_start = idle->thread.sp;
22829
22830 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22831 /* the FPU context is blank, nobody can own it */
22832 __cpu_disable_lazy_restore(cpu);
22833
22834 +#ifdef CONFIG_PAX_PER_CPU_PGD
22835 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22836 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22837 + KERNEL_PGD_PTRS);
22838 +#endif
22839 +
22840 + /* the FPU context is blank, nobody can own it */
22841 + __cpu_disable_lazy_restore(cpu);
22842 +
22843 err = do_boot_cpu(apicid, cpu, tidle);
22844 if (err) {
22845 pr_debug("do_boot_cpu failed %d\n", err);
22846 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22847 index 9b4d51d..5d28b58 100644
22848 --- a/arch/x86/kernel/step.c
22849 +++ b/arch/x86/kernel/step.c
22850 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22851 struct desc_struct *desc;
22852 unsigned long base;
22853
22854 - seg &= ~7UL;
22855 + seg >>= 3;
22856
22857 mutex_lock(&child->mm->context.lock);
22858 - if (unlikely((seg >> 3) >= child->mm->context.size))
22859 + if (unlikely(seg >= child->mm->context.size))
22860 addr = -1L; /* bogus selector, access would fault */
22861 else {
22862 desc = child->mm->context.ldt + seg;
22863 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22864 addr += base;
22865 }
22866 mutex_unlock(&child->mm->context.lock);
22867 - }
22868 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22869 + addr = ktla_ktva(addr);
22870
22871 return addr;
22872 }
22873 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22874 unsigned char opcode[15];
22875 unsigned long addr = convert_ip_to_linear(child, regs);
22876
22877 + if (addr == -EINVAL)
22878 + return 0;
22879 +
22880 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22881 for (i = 0; i < copied; i++) {
22882 switch (opcode[i]) {
22883 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22884 new file mode 100644
22885 index 0000000..5877189
22886 --- /dev/null
22887 +++ b/arch/x86/kernel/sys_i386_32.c
22888 @@ -0,0 +1,189 @@
22889 +/*
22890 + * This file contains various random system calls that
22891 + * have a non-standard calling sequence on the Linux/i386
22892 + * platform.
22893 + */
22894 +
22895 +#include <linux/errno.h>
22896 +#include <linux/sched.h>
22897 +#include <linux/mm.h>
22898 +#include <linux/fs.h>
22899 +#include <linux/smp.h>
22900 +#include <linux/sem.h>
22901 +#include <linux/msg.h>
22902 +#include <linux/shm.h>
22903 +#include <linux/stat.h>
22904 +#include <linux/syscalls.h>
22905 +#include <linux/mman.h>
22906 +#include <linux/file.h>
22907 +#include <linux/utsname.h>
22908 +#include <linux/ipc.h>
22909 +#include <linux/elf.h>
22910 +
22911 +#include <linux/uaccess.h>
22912 +#include <linux/unistd.h>
22913 +
22914 +#include <asm/syscalls.h>
22915 +
22916 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22917 +{
22918 + unsigned long pax_task_size = TASK_SIZE;
22919 +
22920 +#ifdef CONFIG_PAX_SEGMEXEC
22921 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22922 + pax_task_size = SEGMEXEC_TASK_SIZE;
22923 +#endif
22924 +
22925 + if (flags & MAP_FIXED)
22926 + if (len > pax_task_size || addr > pax_task_size - len)
22927 + return -EINVAL;
22928 +
22929 + return 0;
22930 +}
22931 +
22932 +/*
22933 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
22934 + */
22935 +static unsigned long get_align_mask(void)
22936 +{
22937 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
22938 + return 0;
22939 +
22940 + if (!(current->flags & PF_RANDOMIZE))
22941 + return 0;
22942 +
22943 + return va_align.mask;
22944 +}
22945 +
22946 +unsigned long
22947 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22948 + unsigned long len, unsigned long pgoff, unsigned long flags)
22949 +{
22950 + struct mm_struct *mm = current->mm;
22951 + struct vm_area_struct *vma;
22952 + unsigned long pax_task_size = TASK_SIZE;
22953 + struct vm_unmapped_area_info info;
22954 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22955 +
22956 +#ifdef CONFIG_PAX_SEGMEXEC
22957 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22958 + pax_task_size = SEGMEXEC_TASK_SIZE;
22959 +#endif
22960 +
22961 + pax_task_size -= PAGE_SIZE;
22962 +
22963 + if (len > pax_task_size)
22964 + return -ENOMEM;
22965 +
22966 + if (flags & MAP_FIXED)
22967 + return addr;
22968 +
22969 +#ifdef CONFIG_PAX_RANDMMAP
22970 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22971 +#endif
22972 +
22973 + if (addr) {
22974 + addr = PAGE_ALIGN(addr);
22975 + if (pax_task_size - len >= addr) {
22976 + vma = find_vma(mm, addr);
22977 + if (check_heap_stack_gap(vma, addr, len, offset))
22978 + return addr;
22979 + }
22980 + }
22981 +
22982 + info.flags = 0;
22983 + info.length = len;
22984 + info.align_mask = filp ? get_align_mask() : 0;
22985 + info.align_offset = pgoff << PAGE_SHIFT;
22986 + info.threadstack_offset = offset;
22987 +
22988 +#ifdef CONFIG_PAX_PAGEEXEC
22989 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
22990 + info.low_limit = 0x00110000UL;
22991 + info.high_limit = mm->start_code;
22992 +
22993 +#ifdef CONFIG_PAX_RANDMMAP
22994 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22995 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
22996 +#endif
22997 +
22998 + if (info.low_limit < info.high_limit) {
22999 + addr = vm_unmapped_area(&info);
23000 + if (!IS_ERR_VALUE(addr))
23001 + return addr;
23002 + }
23003 + } else
23004 +#endif
23005 +
23006 + info.low_limit = mm->mmap_base;
23007 + info.high_limit = pax_task_size;
23008 +
23009 + return vm_unmapped_area(&info);
23010 +}
23011 +
23012 +unsigned long
23013 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23014 + const unsigned long len, const unsigned long pgoff,
23015 + const unsigned long flags)
23016 +{
23017 + struct vm_area_struct *vma;
23018 + struct mm_struct *mm = current->mm;
23019 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
23020 + struct vm_unmapped_area_info info;
23021 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23022 +
23023 +#ifdef CONFIG_PAX_SEGMEXEC
23024 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23025 + pax_task_size = SEGMEXEC_TASK_SIZE;
23026 +#endif
23027 +
23028 + pax_task_size -= PAGE_SIZE;
23029 +
23030 + /* requested length too big for entire address space */
23031 + if (len > pax_task_size)
23032 + return -ENOMEM;
23033 +
23034 + if (flags & MAP_FIXED)
23035 + return addr;
23036 +
23037 +#ifdef CONFIG_PAX_PAGEEXEC
23038 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23039 + goto bottomup;
23040 +#endif
23041 +
23042 +#ifdef CONFIG_PAX_RANDMMAP
23043 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23044 +#endif
23045 +
23046 + /* requesting a specific address */
23047 + if (addr) {
23048 + addr = PAGE_ALIGN(addr);
23049 + if (pax_task_size - len >= addr) {
23050 + vma = find_vma(mm, addr);
23051 + if (check_heap_stack_gap(vma, addr, len, offset))
23052 + return addr;
23053 + }
23054 + }
23055 +
23056 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
23057 + info.length = len;
23058 + info.low_limit = PAGE_SIZE;
23059 + info.high_limit = mm->mmap_base;
23060 + info.align_mask = filp ? get_align_mask() : 0;
23061 + info.align_offset = pgoff << PAGE_SHIFT;
23062 + info.threadstack_offset = offset;
23063 +
23064 + addr = vm_unmapped_area(&info);
23065 + if (!(addr & ~PAGE_MASK))
23066 + return addr;
23067 + VM_BUG_ON(addr != -ENOMEM);
23068 +
23069 +bottomup:
23070 + /*
23071 + * A failed mmap() very likely causes application failure,
23072 + * so fall back to the bottom-up function here. This scenario
23073 + * can happen with large stack limits and large mmap()
23074 + * allocations.
23075 + */
23076 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23077 +}
23078 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23079 index dbded5a..ace2781 100644
23080 --- a/arch/x86/kernel/sys_x86_64.c
23081 +++ b/arch/x86/kernel/sys_x86_64.c
23082 @@ -81,8 +81,8 @@ out:
23083 return error;
23084 }
23085
23086 -static void find_start_end(unsigned long flags, unsigned long *begin,
23087 - unsigned long *end)
23088 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23089 + unsigned long *begin, unsigned long *end)
23090 {
23091 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23092 unsigned long new_begin;
23093 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23094 *begin = new_begin;
23095 }
23096 } else {
23097 - *begin = TASK_UNMAPPED_BASE;
23098 + *begin = mm->mmap_base;
23099 *end = TASK_SIZE;
23100 }
23101 }
23102 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23103 struct vm_area_struct *vma;
23104 struct vm_unmapped_area_info info;
23105 unsigned long begin, end;
23106 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23107
23108 if (flags & MAP_FIXED)
23109 return addr;
23110
23111 - find_start_end(flags, &begin, &end);
23112 + find_start_end(mm, flags, &begin, &end);
23113
23114 if (len > end)
23115 return -ENOMEM;
23116
23117 +#ifdef CONFIG_PAX_RANDMMAP
23118 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23119 +#endif
23120 +
23121 if (addr) {
23122 addr = PAGE_ALIGN(addr);
23123 vma = find_vma(mm, addr);
23124 - if (end - len >= addr &&
23125 - (!vma || addr + len <= vma->vm_start))
23126 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23127 return addr;
23128 }
23129
23130 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23131 info.high_limit = end;
23132 info.align_mask = filp ? get_align_mask() : 0;
23133 info.align_offset = pgoff << PAGE_SHIFT;
23134 + info.threadstack_offset = offset;
23135 return vm_unmapped_area(&info);
23136 }
23137
23138 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23139 struct mm_struct *mm = current->mm;
23140 unsigned long addr = addr0;
23141 struct vm_unmapped_area_info info;
23142 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23143
23144 /* requested length too big for entire address space */
23145 if (len > TASK_SIZE)
23146 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23147 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23148 goto bottomup;
23149
23150 +#ifdef CONFIG_PAX_RANDMMAP
23151 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23152 +#endif
23153 +
23154 /* requesting a specific address */
23155 if (addr) {
23156 addr = PAGE_ALIGN(addr);
23157 vma = find_vma(mm, addr);
23158 - if (TASK_SIZE - len >= addr &&
23159 - (!vma || addr + len <= vma->vm_start))
23160 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23161 return addr;
23162 }
23163
23164 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23165 info.high_limit = mm->mmap_base;
23166 info.align_mask = filp ? get_align_mask() : 0;
23167 info.align_offset = pgoff << PAGE_SHIFT;
23168 + info.threadstack_offset = offset;
23169 addr = vm_unmapped_area(&info);
23170 if (!(addr & ~PAGE_MASK))
23171 return addr;
23172 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23173 index f84fe00..f41d9f1 100644
23174 --- a/arch/x86/kernel/tboot.c
23175 +++ b/arch/x86/kernel/tboot.c
23176 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23177
23178 void tboot_shutdown(u32 shutdown_type)
23179 {
23180 - void (*shutdown)(void);
23181 + void (* __noreturn shutdown)(void);
23182
23183 if (!tboot_enabled())
23184 return;
23185 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23186
23187 switch_to_tboot_pt();
23188
23189 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23190 + shutdown = (void *)tboot->shutdown_entry;
23191 shutdown();
23192
23193 /* should not reach here */
23194 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23195 return 0;
23196 }
23197
23198 -static atomic_t ap_wfs_count;
23199 +static atomic_unchecked_t ap_wfs_count;
23200
23201 static int tboot_wait_for_aps(int num_aps)
23202 {
23203 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23204 {
23205 switch (action) {
23206 case CPU_DYING:
23207 - atomic_inc(&ap_wfs_count);
23208 + atomic_inc_unchecked(&ap_wfs_count);
23209 if (num_online_cpus() == 1)
23210 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23211 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23212 return NOTIFY_BAD;
23213 break;
23214 }
23215 return NOTIFY_OK;
23216 }
23217
23218 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23219 +static struct notifier_block tboot_cpu_notifier =
23220 {
23221 .notifier_call = tboot_cpu_callback,
23222 };
23223 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23224
23225 tboot_create_trampoline();
23226
23227 - atomic_set(&ap_wfs_count, 0);
23228 + atomic_set_unchecked(&ap_wfs_count, 0);
23229 register_hotcpu_notifier(&tboot_cpu_notifier);
23230
23231 acpi_os_set_prepare_sleep(&tboot_sleep);
23232 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23233 index 24d3c91..d06b473 100644
23234 --- a/arch/x86/kernel/time.c
23235 +++ b/arch/x86/kernel/time.c
23236 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23237 {
23238 unsigned long pc = instruction_pointer(regs);
23239
23240 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23241 + if (!user_mode(regs) && in_lock_functions(pc)) {
23242 #ifdef CONFIG_FRAME_POINTER
23243 - return *(unsigned long *)(regs->bp + sizeof(long));
23244 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23245 #else
23246 unsigned long *sp =
23247 (unsigned long *)kernel_stack_pointer(regs);
23248 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23249 * or above a saved flags. Eflags has bits 22-31 zero,
23250 * kernel addresses don't.
23251 */
23252 +
23253 +#ifdef CONFIG_PAX_KERNEXEC
23254 + return ktla_ktva(sp[0]);
23255 +#else
23256 if (sp[0] >> 22)
23257 return sp[0];
23258 if (sp[1] >> 22)
23259 return sp[1];
23260 #endif
23261 +
23262 +#endif
23263 }
23264 return pc;
23265 }
23266 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23267 index 9d9d2f9..cad418a 100644
23268 --- a/arch/x86/kernel/tls.c
23269 +++ b/arch/x86/kernel/tls.c
23270 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23271 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23272 return -EINVAL;
23273
23274 +#ifdef CONFIG_PAX_SEGMEXEC
23275 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23276 + return -EINVAL;
23277 +#endif
23278 +
23279 set_tls_desc(p, idx, &info, 1);
23280
23281 return 0;
23282 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23283
23284 if (kbuf)
23285 info = kbuf;
23286 - else if (__copy_from_user(infobuf, ubuf, count))
23287 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23288 return -EFAULT;
23289 else
23290 info = infobuf;
23291 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23292 index 68bda7a..3ec7bb7 100644
23293 --- a/arch/x86/kernel/traps.c
23294 +++ b/arch/x86/kernel/traps.c
23295 @@ -68,12 +68,6 @@
23296 #include <asm/setup.h>
23297
23298 asmlinkage int system_call(void);
23299 -
23300 -/*
23301 - * The IDT has to be page-aligned to simplify the Pentium
23302 - * F0 0F bug workaround.
23303 - */
23304 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23305 #endif
23306
23307 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23308 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23309 }
23310
23311 static int __kprobes
23312 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23313 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23314 struct pt_regs *regs, long error_code)
23315 {
23316 #ifdef CONFIG_X86_32
23317 - if (regs->flags & X86_VM_MASK) {
23318 + if (v8086_mode(regs)) {
23319 /*
23320 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23321 * On nmi (interrupt 2), do_trap should not be called.
23322 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23323 return -1;
23324 }
23325 #endif
23326 - if (!user_mode(regs)) {
23327 + if (!user_mode_novm(regs)) {
23328 if (!fixup_exception(regs)) {
23329 tsk->thread.error_code = error_code;
23330 tsk->thread.trap_nr = trapnr;
23331 +
23332 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23333 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23334 + str = "PAX: suspicious stack segment fault";
23335 +#endif
23336 +
23337 die(str, regs, error_code);
23338 }
23339 +
23340 +#ifdef CONFIG_PAX_REFCOUNT
23341 + if (trapnr == 4)
23342 + pax_report_refcount_overflow(regs);
23343 +#endif
23344 +
23345 return 0;
23346 }
23347
23348 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23349 }
23350
23351 static void __kprobes
23352 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23353 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23354 long error_code, siginfo_t *info)
23355 {
23356 struct task_struct *tsk = current;
23357 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23358 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23359 printk_ratelimit()) {
23360 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23361 - tsk->comm, tsk->pid, str,
23362 + tsk->comm, task_pid_nr(tsk), str,
23363 regs->ip, regs->sp, error_code);
23364 print_vma_addr(" in ", regs->ip);
23365 pr_cont("\n");
23366 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23367 conditional_sti(regs);
23368
23369 #ifdef CONFIG_X86_32
23370 - if (regs->flags & X86_VM_MASK) {
23371 + if (v8086_mode(regs)) {
23372 local_irq_enable();
23373 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23374 goto exit;
23375 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23376 #endif
23377
23378 tsk = current;
23379 - if (!user_mode(regs)) {
23380 + if (!user_mode_novm(regs)) {
23381 if (fixup_exception(regs))
23382 goto exit;
23383
23384 tsk->thread.error_code = error_code;
23385 tsk->thread.trap_nr = X86_TRAP_GP;
23386 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23387 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23388 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23389 +
23390 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23391 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23392 + die("PAX: suspicious general protection fault", regs, error_code);
23393 + else
23394 +#endif
23395 +
23396 die("general protection fault", regs, error_code);
23397 + }
23398 goto exit;
23399 }
23400
23401 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23402 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23403 + struct mm_struct *mm = tsk->mm;
23404 + unsigned long limit;
23405 +
23406 + down_write(&mm->mmap_sem);
23407 + limit = mm->context.user_cs_limit;
23408 + if (limit < TASK_SIZE) {
23409 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23410 + up_write(&mm->mmap_sem);
23411 + return;
23412 + }
23413 + up_write(&mm->mmap_sem);
23414 + }
23415 +#endif
23416 +
23417 tsk->thread.error_code = error_code;
23418 tsk->thread.trap_nr = X86_TRAP_GP;
23419
23420 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23421 /* It's safe to allow irq's after DR6 has been saved */
23422 preempt_conditional_sti(regs);
23423
23424 - if (regs->flags & X86_VM_MASK) {
23425 + if (v8086_mode(regs)) {
23426 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23427 X86_TRAP_DB);
23428 preempt_conditional_cli(regs);
23429 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23430 * We already checked v86 mode above, so we can check for kernel mode
23431 * by just checking the CPL of CS.
23432 */
23433 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23434 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23435 tsk->thread.debugreg6 &= ~DR_STEP;
23436 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23437 regs->flags &= ~X86_EFLAGS_TF;
23438 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23439 return;
23440 conditional_sti(regs);
23441
23442 - if (!user_mode_vm(regs))
23443 + if (!user_mode(regs))
23444 {
23445 if (!fixup_exception(regs)) {
23446 task->thread.error_code = error_code;
23447 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23448 index 0ba4cfb..4596bec 100644
23449 --- a/arch/x86/kernel/uprobes.c
23450 +++ b/arch/x86/kernel/uprobes.c
23451 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23452 int ret = NOTIFY_DONE;
23453
23454 /* We are only interested in userspace traps */
23455 - if (regs && !user_mode_vm(regs))
23456 + if (regs && !user_mode(regs))
23457 return NOTIFY_DONE;
23458
23459 switch (val) {
23460 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23461 index b9242ba..50c5edd 100644
23462 --- a/arch/x86/kernel/verify_cpu.S
23463 +++ b/arch/x86/kernel/verify_cpu.S
23464 @@ -20,6 +20,7 @@
23465 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23466 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23467 * arch/x86/kernel/head_32.S: processor startup
23468 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23469 *
23470 * verify_cpu, returns the status of longmode and SSE in register %eax.
23471 * 0: Success 1: Failure
23472 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23473 index 3dbdd9c..888b14e 100644
23474 --- a/arch/x86/kernel/vm86_32.c
23475 +++ b/arch/x86/kernel/vm86_32.c
23476 @@ -44,6 +44,7 @@
23477 #include <linux/ptrace.h>
23478 #include <linux/audit.h>
23479 #include <linux/stddef.h>
23480 +#include <linux/grsecurity.h>
23481
23482 #include <asm/uaccess.h>
23483 #include <asm/io.h>
23484 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23485 do_exit(SIGSEGV);
23486 }
23487
23488 - tss = &per_cpu(init_tss, get_cpu());
23489 + tss = init_tss + get_cpu();
23490 current->thread.sp0 = current->thread.saved_sp0;
23491 current->thread.sysenter_cs = __KERNEL_CS;
23492 load_sp0(tss, &current->thread);
23493 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23494
23495 if (tsk->thread.saved_sp0)
23496 goto out;
23497 +
23498 +#ifdef CONFIG_GRKERNSEC_VM86
23499 + if (!capable(CAP_SYS_RAWIO)) {
23500 + gr_handle_vm86();
23501 + goto out;
23502 + }
23503 +#endif
23504 +
23505 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23506 offsetof(struct kernel_vm86_struct, vm86plus) -
23507 sizeof(info.regs));
23508 @@ -242,6 +251,14 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23509 int tmp, ret;
23510 struct vm86plus_struct __user *v86;
23511
23512 +#ifdef CONFIG_GRKERNSEC_VM86
23513 + if (!capable(CAP_SYS_RAWIO)) {
23514 + gr_handle_vm86();
23515 + ret = -EPERM;
23516 + goto out;
23517 + }
23518 +#endif
23519 +
23520 tsk = current;
23521 switch (cmd) {
23522 case VM86_REQUEST_IRQ:
23523 @@ -329,7 +346,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23524 tsk->thread.saved_fs = info->regs32->fs;
23525 tsk->thread.saved_gs = get_user_gs(info->regs32);
23526
23527 - tss = &per_cpu(init_tss, get_cpu());
23528 + tss = init_tss + get_cpu();
23529 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23530 if (cpu_has_sep)
23531 tsk->thread.sysenter_cs = 0;
23532 @@ -536,7 +553,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23533 goto cannot_handle;
23534 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23535 goto cannot_handle;
23536 - intr_ptr = (unsigned long __user *) (i << 2);
23537 + intr_ptr = (__force unsigned long __user *) (i << 2);
23538 if (get_user(segoffs, intr_ptr))
23539 goto cannot_handle;
23540 if ((segoffs >> 16) == BIOSSEG)
23541 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23542 index 22a1530..5efafbf 100644
23543 --- a/arch/x86/kernel/vmlinux.lds.S
23544 +++ b/arch/x86/kernel/vmlinux.lds.S
23545 @@ -26,6 +26,13 @@
23546 #include <asm/page_types.h>
23547 #include <asm/cache.h>
23548 #include <asm/boot.h>
23549 +#include <asm/segment.h>
23550 +
23551 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23552 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23553 +#else
23554 +#define __KERNEL_TEXT_OFFSET 0
23555 +#endif
23556
23557 #undef i386 /* in case the preprocessor is a 32bit one */
23558
23559 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23560
23561 PHDRS {
23562 text PT_LOAD FLAGS(5); /* R_E */
23563 +#ifdef CONFIG_X86_32
23564 + module PT_LOAD FLAGS(5); /* R_E */
23565 +#endif
23566 +#ifdef CONFIG_XEN
23567 + rodata PT_LOAD FLAGS(5); /* R_E */
23568 +#else
23569 + rodata PT_LOAD FLAGS(4); /* R__ */
23570 +#endif
23571 data PT_LOAD FLAGS(6); /* RW_ */
23572 -#ifdef CONFIG_X86_64
23573 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23574 #ifdef CONFIG_SMP
23575 percpu PT_LOAD FLAGS(6); /* RW_ */
23576 #endif
23577 + text.init PT_LOAD FLAGS(5); /* R_E */
23578 + text.exit PT_LOAD FLAGS(5); /* R_E */
23579 init PT_LOAD FLAGS(7); /* RWE */
23580 -#endif
23581 note PT_NOTE FLAGS(0); /* ___ */
23582 }
23583
23584 SECTIONS
23585 {
23586 #ifdef CONFIG_X86_32
23587 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23588 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23589 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23590 #else
23591 - . = __START_KERNEL;
23592 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23593 + . = __START_KERNEL;
23594 #endif
23595
23596 /* Text and read-only data */
23597 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23598 - _text = .;
23599 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23600 /* bootstrapping code */
23601 +#ifdef CONFIG_X86_32
23602 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23603 +#else
23604 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23605 +#endif
23606 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23607 + _text = .;
23608 HEAD_TEXT
23609 #ifdef CONFIG_X86_32
23610 . = ALIGN(PAGE_SIZE);
23611 @@ -108,13 +128,48 @@ SECTIONS
23612 IRQENTRY_TEXT
23613 *(.fixup)
23614 *(.gnu.warning)
23615 - /* End of text section */
23616 - _etext = .;
23617 } :text = 0x9090
23618
23619 - NOTES :text :note
23620 + . += __KERNEL_TEXT_OFFSET;
23621
23622 - EXCEPTION_TABLE(16) :text = 0x9090
23623 +#ifdef CONFIG_X86_32
23624 + . = ALIGN(PAGE_SIZE);
23625 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23626 +
23627 +#ifdef CONFIG_PAX_KERNEXEC
23628 + MODULES_EXEC_VADDR = .;
23629 + BYTE(0)
23630 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23631 + . = ALIGN(HPAGE_SIZE) - 1;
23632 + MODULES_EXEC_END = .;
23633 +#endif
23634 +
23635 + } :module
23636 +#endif
23637 +
23638 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23639 + /* End of text section */
23640 + BYTE(0)
23641 + _etext = . - __KERNEL_TEXT_OFFSET;
23642 + }
23643 +
23644 +#ifdef CONFIG_X86_32
23645 + . = ALIGN(PAGE_SIZE);
23646 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23647 + *(.idt)
23648 + . = ALIGN(PAGE_SIZE);
23649 + *(.empty_zero_page)
23650 + *(.initial_pg_fixmap)
23651 + *(.initial_pg_pmd)
23652 + *(.initial_page_table)
23653 + *(.swapper_pg_dir)
23654 + } :rodata
23655 +#endif
23656 +
23657 + . = ALIGN(PAGE_SIZE);
23658 + NOTES :rodata :note
23659 +
23660 + EXCEPTION_TABLE(16) :rodata
23661
23662 #if defined(CONFIG_DEBUG_RODATA)
23663 /* .text should occupy whole number of pages */
23664 @@ -126,16 +181,20 @@ SECTIONS
23665
23666 /* Data */
23667 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23668 +
23669 +#ifdef CONFIG_PAX_KERNEXEC
23670 + . = ALIGN(HPAGE_SIZE);
23671 +#else
23672 + . = ALIGN(PAGE_SIZE);
23673 +#endif
23674 +
23675 /* Start of data section */
23676 _sdata = .;
23677
23678 /* init_task */
23679 INIT_TASK_DATA(THREAD_SIZE)
23680
23681 -#ifdef CONFIG_X86_32
23682 - /* 32 bit has nosave before _edata */
23683 NOSAVE_DATA
23684 -#endif
23685
23686 PAGE_ALIGNED_DATA(PAGE_SIZE)
23687
23688 @@ -176,12 +235,19 @@ SECTIONS
23689 #endif /* CONFIG_X86_64 */
23690
23691 /* Init code and data - will be freed after init */
23692 - . = ALIGN(PAGE_SIZE);
23693 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23694 + BYTE(0)
23695 +
23696 +#ifdef CONFIG_PAX_KERNEXEC
23697 + . = ALIGN(HPAGE_SIZE);
23698 +#else
23699 + . = ALIGN(PAGE_SIZE);
23700 +#endif
23701 +
23702 __init_begin = .; /* paired with __init_end */
23703 - }
23704 + } :init.begin
23705
23706 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23707 +#ifdef CONFIG_SMP
23708 /*
23709 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23710 * output PHDR, so the next output section - .init.text - should
23711 @@ -190,12 +256,27 @@ SECTIONS
23712 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23713 #endif
23714
23715 - INIT_TEXT_SECTION(PAGE_SIZE)
23716 -#ifdef CONFIG_X86_64
23717 - :init
23718 -#endif
23719 + . = ALIGN(PAGE_SIZE);
23720 + init_begin = .;
23721 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23722 + VMLINUX_SYMBOL(_sinittext) = .;
23723 + INIT_TEXT
23724 + VMLINUX_SYMBOL(_einittext) = .;
23725 + . = ALIGN(PAGE_SIZE);
23726 + } :text.init
23727
23728 - INIT_DATA_SECTION(16)
23729 + /*
23730 + * .exit.text is discard at runtime, not link time, to deal with
23731 + * references from .altinstructions and .eh_frame
23732 + */
23733 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23734 + EXIT_TEXT
23735 + . = ALIGN(16);
23736 + } :text.exit
23737 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23738 +
23739 + . = ALIGN(PAGE_SIZE);
23740 + INIT_DATA_SECTION(16) :init
23741
23742 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23743 __x86_cpu_dev_start = .;
23744 @@ -257,19 +338,12 @@ SECTIONS
23745 }
23746
23747 . = ALIGN(8);
23748 - /*
23749 - * .exit.text is discard at runtime, not link time, to deal with
23750 - * references from .altinstructions and .eh_frame
23751 - */
23752 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23753 - EXIT_TEXT
23754 - }
23755
23756 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23757 EXIT_DATA
23758 }
23759
23760 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23761 +#ifndef CONFIG_SMP
23762 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23763 #endif
23764
23765 @@ -288,16 +362,10 @@ SECTIONS
23766 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23767 __smp_locks = .;
23768 *(.smp_locks)
23769 - . = ALIGN(PAGE_SIZE);
23770 __smp_locks_end = .;
23771 + . = ALIGN(PAGE_SIZE);
23772 }
23773
23774 -#ifdef CONFIG_X86_64
23775 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23776 - NOSAVE_DATA
23777 - }
23778 -#endif
23779 -
23780 /* BSS */
23781 . = ALIGN(PAGE_SIZE);
23782 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23783 @@ -313,6 +381,7 @@ SECTIONS
23784 __brk_base = .;
23785 . += 64 * 1024; /* 64k alignment slop space */
23786 *(.brk_reservation) /* areas brk users have reserved */
23787 + . = ALIGN(HPAGE_SIZE);
23788 __brk_limit = .;
23789 }
23790
23791 @@ -339,13 +408,12 @@ SECTIONS
23792 * for the boot processor.
23793 */
23794 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23795 -INIT_PER_CPU(gdt_page);
23796 INIT_PER_CPU(irq_stack_union);
23797
23798 /*
23799 * Build-time check on the image size:
23800 */
23801 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23802 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23803 "kernel image bigger than KERNEL_IMAGE_SIZE");
23804
23805 #ifdef CONFIG_SMP
23806 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23807 index 9a907a6..f83f921 100644
23808 --- a/arch/x86/kernel/vsyscall_64.c
23809 +++ b/arch/x86/kernel/vsyscall_64.c
23810 @@ -56,15 +56,13 @@
23811 DEFINE_VVAR(int, vgetcpu_mode);
23812 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23813
23814 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23815 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23816
23817 static int __init vsyscall_setup(char *str)
23818 {
23819 if (str) {
23820 if (!strcmp("emulate", str))
23821 vsyscall_mode = EMULATE;
23822 - else if (!strcmp("native", str))
23823 - vsyscall_mode = NATIVE;
23824 else if (!strcmp("none", str))
23825 vsyscall_mode = NONE;
23826 else
23827 @@ -323,8 +321,7 @@ do_ret:
23828 return true;
23829
23830 sigsegv:
23831 - force_sig(SIGSEGV, current);
23832 - return true;
23833 + do_group_exit(SIGKILL);
23834 }
23835
23836 /*
23837 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23838 extern char __vvar_page;
23839 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23840
23841 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23842 - vsyscall_mode == NATIVE
23843 - ? PAGE_KERNEL_VSYSCALL
23844 - : PAGE_KERNEL_VVAR);
23845 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23846 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23847 (unsigned long)VSYSCALL_START);
23848
23849 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23850 index b014d94..6d6ca7b 100644
23851 --- a/arch/x86/kernel/x8664_ksyms_64.c
23852 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23853 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23854 EXPORT_SYMBOL(copy_user_generic_unrolled);
23855 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23856 EXPORT_SYMBOL(__copy_user_nocache);
23857 -EXPORT_SYMBOL(_copy_from_user);
23858 -EXPORT_SYMBOL(_copy_to_user);
23859
23860 EXPORT_SYMBOL(copy_page);
23861 EXPORT_SYMBOL(clear_page);
23862 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23863 index 45a14db..075bb9b 100644
23864 --- a/arch/x86/kernel/x86_init.c
23865 +++ b/arch/x86/kernel/x86_init.c
23866 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23867 },
23868 };
23869
23870 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23871 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23872 .early_percpu_clock_init = x86_init_noop,
23873 .setup_percpu_clockev = setup_secondary_APIC_clock,
23874 };
23875 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23876 static void default_nmi_init(void) { };
23877 static int default_i8042_detect(void) { return 1; };
23878
23879 -struct x86_platform_ops x86_platform = {
23880 +struct x86_platform_ops x86_platform __read_only = {
23881 .calibrate_tsc = native_calibrate_tsc,
23882 .get_wallclock = mach_get_cmos_time,
23883 .set_wallclock = mach_set_rtc_mmss,
23884 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23885 };
23886
23887 EXPORT_SYMBOL_GPL(x86_platform);
23888 -struct x86_msi_ops x86_msi = {
23889 +struct x86_msi_ops x86_msi __read_only = {
23890 .setup_msi_irqs = native_setup_msi_irqs,
23891 .compose_msi_msg = native_compose_msi_msg,
23892 .teardown_msi_irq = native_teardown_msi_irq,
23893 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23894 .setup_hpet_msi = default_setup_hpet_msi,
23895 };
23896
23897 -struct x86_io_apic_ops x86_io_apic_ops = {
23898 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23899 .init = native_io_apic_init_mappings,
23900 .read = native_io_apic_read,
23901 .write = native_io_apic_write,
23902 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23903 index ada87a3..afea76d 100644
23904 --- a/arch/x86/kernel/xsave.c
23905 +++ b/arch/x86/kernel/xsave.c
23906 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23907 {
23908 int err;
23909
23910 + buf = (struct xsave_struct __user *)____m(buf);
23911 if (use_xsave())
23912 err = xsave_user(buf);
23913 else if (use_fxsr())
23914 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23915 */
23916 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23917 {
23918 + buf = (void __user *)____m(buf);
23919 if (use_xsave()) {
23920 if ((unsigned long)buf % 64 || fx_only) {
23921 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23922 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23923 index a20ecb5..d0e2194 100644
23924 --- a/arch/x86/kvm/cpuid.c
23925 +++ b/arch/x86/kvm/cpuid.c
23926 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23927 struct kvm_cpuid2 *cpuid,
23928 struct kvm_cpuid_entry2 __user *entries)
23929 {
23930 - int r;
23931 + int r, i;
23932
23933 r = -E2BIG;
23934 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23935 goto out;
23936 r = -EFAULT;
23937 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23938 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23939 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23940 goto out;
23941 + for (i = 0; i < cpuid->nent; ++i) {
23942 + struct kvm_cpuid_entry2 cpuid_entry;
23943 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23944 + goto out;
23945 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23946 + }
23947 vcpu->arch.cpuid_nent = cpuid->nent;
23948 kvm_apic_set_version(vcpu);
23949 kvm_x86_ops->cpuid_update(vcpu);
23950 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23951 struct kvm_cpuid2 *cpuid,
23952 struct kvm_cpuid_entry2 __user *entries)
23953 {
23954 - int r;
23955 + int r, i;
23956
23957 r = -E2BIG;
23958 if (cpuid->nent < vcpu->arch.cpuid_nent)
23959 goto out;
23960 r = -EFAULT;
23961 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23962 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23963 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23964 goto out;
23965 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23966 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23967 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23968 + goto out;
23969 + }
23970 return 0;
23971
23972 out:
23973 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23974 index 698eece..776b682 100644
23975 --- a/arch/x86/kvm/emulate.c
23976 +++ b/arch/x86/kvm/emulate.c
23977 @@ -328,6 +328,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23978
23979 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23980 do { \
23981 + unsigned long _tmp; \
23982 __asm__ __volatile__ ( \
23983 _PRE_EFLAGS("0", "4", "2") \
23984 _op _suffix " %"_x"3,%1; " \
23985 @@ -342,8 +343,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23986 /* Raw emulation: instruction has two explicit operands. */
23987 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23988 do { \
23989 - unsigned long _tmp; \
23990 - \
23991 switch ((ctxt)->dst.bytes) { \
23992 case 2: \
23993 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23994 @@ -359,7 +358,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23995
23996 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
23997 do { \
23998 - unsigned long _tmp; \
23999 switch ((ctxt)->dst.bytes) { \
24000 case 1: \
24001 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24002 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24003 index f77df1c..6f20690 100644
24004 --- a/arch/x86/kvm/lapic.c
24005 +++ b/arch/x86/kvm/lapic.c
24006 @@ -55,7 +55,7 @@
24007 #define APIC_BUS_CYCLE_NS 1
24008
24009 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24010 -#define apic_debug(fmt, arg...)
24011 +#define apic_debug(fmt, arg...) do {} while (0)
24012
24013 #define APIC_LVT_NUM 6
24014 /* 14 is the version for Xeon and Pentium 8.4.8*/
24015 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24016 index 105dd5b..1b0ccc2 100644
24017 --- a/arch/x86/kvm/paging_tmpl.h
24018 +++ b/arch/x86/kvm/paging_tmpl.h
24019 @@ -208,7 +208,7 @@ retry_walk:
24020 if (unlikely(kvm_is_error_hva(host_addr)))
24021 goto error;
24022
24023 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24024 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24025 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24026 goto error;
24027 walker->ptep_user[walker->level - 1] = ptep_user;
24028 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24029 index e1b1ce2..f7b4b43 100644
24030 --- a/arch/x86/kvm/svm.c
24031 +++ b/arch/x86/kvm/svm.c
24032 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24033 int cpu = raw_smp_processor_id();
24034
24035 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24036 +
24037 + pax_open_kernel();
24038 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24039 + pax_close_kernel();
24040 +
24041 load_TR_desc();
24042 }
24043
24044 @@ -3901,6 +3905,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24045 #endif
24046 #endif
24047
24048 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24049 + __set_fs(current_thread_info()->addr_limit);
24050 +#endif
24051 +
24052 reload_tss(vcpu);
24053
24054 local_irq_disable();
24055 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24056 index 0af1807..06912bb 100644
24057 --- a/arch/x86/kvm/vmx.c
24058 +++ b/arch/x86/kvm/vmx.c
24059 @@ -1184,12 +1184,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24060 #endif
24061 }
24062
24063 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24064 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24065 {
24066 vmcs_writel(field, vmcs_readl(field) & ~mask);
24067 }
24068
24069 -static void vmcs_set_bits(unsigned long field, u32 mask)
24070 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24071 {
24072 vmcs_writel(field, vmcs_readl(field) | mask);
24073 }
24074 @@ -1390,7 +1390,11 @@ static void reload_tss(void)
24075 struct desc_struct *descs;
24076
24077 descs = (void *)gdt->address;
24078 +
24079 + pax_open_kernel();
24080 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24081 + pax_close_kernel();
24082 +
24083 load_TR_desc();
24084 }
24085
24086 @@ -1614,6 +1618,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24087 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24088 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24089
24090 +#ifdef CONFIG_PAX_PER_CPU_PGD
24091 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24092 +#endif
24093 +
24094 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24095 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24096 vmx->loaded_vmcs->cpu = cpu;
24097 @@ -2779,8 +2787,11 @@ static __init int hardware_setup(void)
24098 if (!cpu_has_vmx_flexpriority())
24099 flexpriority_enabled = 0;
24100
24101 - if (!cpu_has_vmx_tpr_shadow())
24102 - kvm_x86_ops->update_cr8_intercept = NULL;
24103 + if (!cpu_has_vmx_tpr_shadow()) {
24104 + pax_open_kernel();
24105 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24106 + pax_close_kernel();
24107 + }
24108
24109 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24110 kvm_disable_largepages();
24111 @@ -2792,10 +2803,12 @@ static __init int hardware_setup(void)
24112 !cpu_has_vmx_virtual_intr_delivery())
24113 enable_apicv_reg_vid = 0;
24114
24115 + pax_open_kernel();
24116 if (enable_apicv_reg_vid)
24117 - kvm_x86_ops->update_cr8_intercept = NULL;
24118 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24119 else
24120 - kvm_x86_ops->hwapic_irr_update = NULL;
24121 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24122 + pax_close_kernel();
24123
24124 if (nested)
24125 nested_vmx_setup_ctls_msrs();
24126 @@ -3883,7 +3896,10 @@ static void vmx_set_constant_host_state(void)
24127
24128 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24129 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24130 +
24131 +#ifndef CONFIG_PAX_PER_CPU_PGD
24132 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24133 +#endif
24134
24135 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24136 #ifdef CONFIG_X86_64
24137 @@ -3904,7 +3920,7 @@ static void vmx_set_constant_host_state(void)
24138 native_store_idt(&dt);
24139 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24140
24141 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24142 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24143
24144 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24145 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24146 @@ -6580,6 +6596,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24147 "jmp 2f \n\t"
24148 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24149 "2: "
24150 +
24151 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24152 + "ljmp %[cs],$3f\n\t"
24153 + "3: "
24154 +#endif
24155 +
24156 /* Save guest registers, load host registers, keep flags */
24157 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24158 "pop %0 \n\t"
24159 @@ -6632,6 +6654,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24160 #endif
24161 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24162 [wordsize]"i"(sizeof(ulong))
24163 +
24164 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24165 + ,[cs]"i"(__KERNEL_CS)
24166 +#endif
24167 +
24168 : "cc", "memory"
24169 #ifdef CONFIG_X86_64
24170 , "rax", "rbx", "rdi", "rsi"
24171 @@ -6645,7 +6672,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24172 if (debugctlmsr)
24173 update_debugctlmsr(debugctlmsr);
24174
24175 -#ifndef CONFIG_X86_64
24176 +#ifdef CONFIG_X86_32
24177 /*
24178 * The sysexit path does not restore ds/es, so we must set them to
24179 * a reasonable value ourselves.
24180 @@ -6654,8 +6681,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24181 * may be executed in interrupt context, which saves and restore segments
24182 * around it, nullifying its effect.
24183 */
24184 - loadsegment(ds, __USER_DS);
24185 - loadsegment(es, __USER_DS);
24186 + loadsegment(ds, __KERNEL_DS);
24187 + loadsegment(es, __KERNEL_DS);
24188 + loadsegment(ss, __KERNEL_DS);
24189 +
24190 +#ifdef CONFIG_PAX_KERNEXEC
24191 + loadsegment(fs, __KERNEL_PERCPU);
24192 +#endif
24193 +
24194 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24195 + __set_fs(current_thread_info()->addr_limit);
24196 +#endif
24197 +
24198 #endif
24199
24200 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24201 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24202 index 8563b45..272f1fe 100644
24203 --- a/arch/x86/kvm/x86.c
24204 +++ b/arch/x86/kvm/x86.c
24205 @@ -1685,8 +1685,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24206 {
24207 struct kvm *kvm = vcpu->kvm;
24208 int lm = is_long_mode(vcpu);
24209 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24210 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24211 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24212 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24213 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24214 : kvm->arch.xen_hvm_config.blob_size_32;
24215 u32 page_num = data & ~PAGE_MASK;
24216 @@ -2566,6 +2566,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24217 if (n < msr_list.nmsrs)
24218 goto out;
24219 r = -EFAULT;
24220 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24221 + goto out;
24222 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24223 num_msrs_to_save * sizeof(u32)))
24224 goto out;
24225 @@ -2695,7 +2697,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24226 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24227 struct kvm_interrupt *irq)
24228 {
24229 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24230 + if (irq->irq >= KVM_NR_INTERRUPTS)
24231 return -EINVAL;
24232 if (irqchip_in_kernel(vcpu->kvm))
24233 return -ENXIO;
24234 @@ -5246,7 +5248,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24235 };
24236 #endif
24237
24238 -int kvm_arch_init(void *opaque)
24239 +int kvm_arch_init(const void *opaque)
24240 {
24241 int r;
24242 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24243 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24244 index 7114c63..a1018fc 100644
24245 --- a/arch/x86/lguest/boot.c
24246 +++ b/arch/x86/lguest/boot.c
24247 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24248 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24249 * Launcher to reboot us.
24250 */
24251 -static void lguest_restart(char *reason)
24252 +static __noreturn void lguest_restart(char *reason)
24253 {
24254 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24255 + BUG();
24256 }
24257
24258 /*G:050
24259 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24260 index 00933d5..3a64af9 100644
24261 --- a/arch/x86/lib/atomic64_386_32.S
24262 +++ b/arch/x86/lib/atomic64_386_32.S
24263 @@ -48,6 +48,10 @@ BEGIN(read)
24264 movl (v), %eax
24265 movl 4(v), %edx
24266 RET_ENDP
24267 +BEGIN(read_unchecked)
24268 + movl (v), %eax
24269 + movl 4(v), %edx
24270 +RET_ENDP
24271 #undef v
24272
24273 #define v %esi
24274 @@ -55,6 +59,10 @@ BEGIN(set)
24275 movl %ebx, (v)
24276 movl %ecx, 4(v)
24277 RET_ENDP
24278 +BEGIN(set_unchecked)
24279 + movl %ebx, (v)
24280 + movl %ecx, 4(v)
24281 +RET_ENDP
24282 #undef v
24283
24284 #define v %esi
24285 @@ -70,6 +78,20 @@ RET_ENDP
24286 BEGIN(add)
24287 addl %eax, (v)
24288 adcl %edx, 4(v)
24289 +
24290 +#ifdef CONFIG_PAX_REFCOUNT
24291 + jno 0f
24292 + subl %eax, (v)
24293 + sbbl %edx, 4(v)
24294 + int $4
24295 +0:
24296 + _ASM_EXTABLE(0b, 0b)
24297 +#endif
24298 +
24299 +RET_ENDP
24300 +BEGIN(add_unchecked)
24301 + addl %eax, (v)
24302 + adcl %edx, 4(v)
24303 RET_ENDP
24304 #undef v
24305
24306 @@ -77,6 +99,24 @@ RET_ENDP
24307 BEGIN(add_return)
24308 addl (v), %eax
24309 adcl 4(v), %edx
24310 +
24311 +#ifdef CONFIG_PAX_REFCOUNT
24312 + into
24313 +1234:
24314 + _ASM_EXTABLE(1234b, 2f)
24315 +#endif
24316 +
24317 + movl %eax, (v)
24318 + movl %edx, 4(v)
24319 +
24320 +#ifdef CONFIG_PAX_REFCOUNT
24321 +2:
24322 +#endif
24323 +
24324 +RET_ENDP
24325 +BEGIN(add_return_unchecked)
24326 + addl (v), %eax
24327 + adcl 4(v), %edx
24328 movl %eax, (v)
24329 movl %edx, 4(v)
24330 RET_ENDP
24331 @@ -86,6 +126,20 @@ RET_ENDP
24332 BEGIN(sub)
24333 subl %eax, (v)
24334 sbbl %edx, 4(v)
24335 +
24336 +#ifdef CONFIG_PAX_REFCOUNT
24337 + jno 0f
24338 + addl %eax, (v)
24339 + adcl %edx, 4(v)
24340 + int $4
24341 +0:
24342 + _ASM_EXTABLE(0b, 0b)
24343 +#endif
24344 +
24345 +RET_ENDP
24346 +BEGIN(sub_unchecked)
24347 + subl %eax, (v)
24348 + sbbl %edx, 4(v)
24349 RET_ENDP
24350 #undef v
24351
24352 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24353 sbbl $0, %edx
24354 addl (v), %eax
24355 adcl 4(v), %edx
24356 +
24357 +#ifdef CONFIG_PAX_REFCOUNT
24358 + into
24359 +1234:
24360 + _ASM_EXTABLE(1234b, 2f)
24361 +#endif
24362 +
24363 + movl %eax, (v)
24364 + movl %edx, 4(v)
24365 +
24366 +#ifdef CONFIG_PAX_REFCOUNT
24367 +2:
24368 +#endif
24369 +
24370 +RET_ENDP
24371 +BEGIN(sub_return_unchecked)
24372 + negl %edx
24373 + negl %eax
24374 + sbbl $0, %edx
24375 + addl (v), %eax
24376 + adcl 4(v), %edx
24377 movl %eax, (v)
24378 movl %edx, 4(v)
24379 RET_ENDP
24380 @@ -105,6 +180,20 @@ RET_ENDP
24381 BEGIN(inc)
24382 addl $1, (v)
24383 adcl $0, 4(v)
24384 +
24385 +#ifdef CONFIG_PAX_REFCOUNT
24386 + jno 0f
24387 + subl $1, (v)
24388 + sbbl $0, 4(v)
24389 + int $4
24390 +0:
24391 + _ASM_EXTABLE(0b, 0b)
24392 +#endif
24393 +
24394 +RET_ENDP
24395 +BEGIN(inc_unchecked)
24396 + addl $1, (v)
24397 + adcl $0, 4(v)
24398 RET_ENDP
24399 #undef v
24400
24401 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24402 movl 4(v), %edx
24403 addl $1, %eax
24404 adcl $0, %edx
24405 +
24406 +#ifdef CONFIG_PAX_REFCOUNT
24407 + into
24408 +1234:
24409 + _ASM_EXTABLE(1234b, 2f)
24410 +#endif
24411 +
24412 + movl %eax, (v)
24413 + movl %edx, 4(v)
24414 +
24415 +#ifdef CONFIG_PAX_REFCOUNT
24416 +2:
24417 +#endif
24418 +
24419 +RET_ENDP
24420 +BEGIN(inc_return_unchecked)
24421 + movl (v), %eax
24422 + movl 4(v), %edx
24423 + addl $1, %eax
24424 + adcl $0, %edx
24425 movl %eax, (v)
24426 movl %edx, 4(v)
24427 RET_ENDP
24428 @@ -123,6 +232,20 @@ RET_ENDP
24429 BEGIN(dec)
24430 subl $1, (v)
24431 sbbl $0, 4(v)
24432 +
24433 +#ifdef CONFIG_PAX_REFCOUNT
24434 + jno 0f
24435 + addl $1, (v)
24436 + adcl $0, 4(v)
24437 + int $4
24438 +0:
24439 + _ASM_EXTABLE(0b, 0b)
24440 +#endif
24441 +
24442 +RET_ENDP
24443 +BEGIN(dec_unchecked)
24444 + subl $1, (v)
24445 + sbbl $0, 4(v)
24446 RET_ENDP
24447 #undef v
24448
24449 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24450 movl 4(v), %edx
24451 subl $1, %eax
24452 sbbl $0, %edx
24453 +
24454 +#ifdef CONFIG_PAX_REFCOUNT
24455 + into
24456 +1234:
24457 + _ASM_EXTABLE(1234b, 2f)
24458 +#endif
24459 +
24460 + movl %eax, (v)
24461 + movl %edx, 4(v)
24462 +
24463 +#ifdef CONFIG_PAX_REFCOUNT
24464 +2:
24465 +#endif
24466 +
24467 +RET_ENDP
24468 +BEGIN(dec_return_unchecked)
24469 + movl (v), %eax
24470 + movl 4(v), %edx
24471 + subl $1, %eax
24472 + sbbl $0, %edx
24473 movl %eax, (v)
24474 movl %edx, 4(v)
24475 RET_ENDP
24476 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24477 adcl %edx, %edi
24478 addl (v), %eax
24479 adcl 4(v), %edx
24480 +
24481 +#ifdef CONFIG_PAX_REFCOUNT
24482 + into
24483 +1234:
24484 + _ASM_EXTABLE(1234b, 2f)
24485 +#endif
24486 +
24487 cmpl %eax, %ecx
24488 je 3f
24489 1:
24490 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24491 1:
24492 addl $1, %eax
24493 adcl $0, %edx
24494 +
24495 +#ifdef CONFIG_PAX_REFCOUNT
24496 + into
24497 +1234:
24498 + _ASM_EXTABLE(1234b, 2f)
24499 +#endif
24500 +
24501 movl %eax, (v)
24502 movl %edx, 4(v)
24503 movl $1, %eax
24504 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24505 movl 4(v), %edx
24506 subl $1, %eax
24507 sbbl $0, %edx
24508 +
24509 +#ifdef CONFIG_PAX_REFCOUNT
24510 + into
24511 +1234:
24512 + _ASM_EXTABLE(1234b, 1f)
24513 +#endif
24514 +
24515 js 1f
24516 movl %eax, (v)
24517 movl %edx, 4(v)
24518 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24519 index f5cc9eb..51fa319 100644
24520 --- a/arch/x86/lib/atomic64_cx8_32.S
24521 +++ b/arch/x86/lib/atomic64_cx8_32.S
24522 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24523 CFI_STARTPROC
24524
24525 read64 %ecx
24526 + pax_force_retaddr
24527 ret
24528 CFI_ENDPROC
24529 ENDPROC(atomic64_read_cx8)
24530
24531 +ENTRY(atomic64_read_unchecked_cx8)
24532 + CFI_STARTPROC
24533 +
24534 + read64 %ecx
24535 + pax_force_retaddr
24536 + ret
24537 + CFI_ENDPROC
24538 +ENDPROC(atomic64_read_unchecked_cx8)
24539 +
24540 ENTRY(atomic64_set_cx8)
24541 CFI_STARTPROC
24542
24543 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24544 cmpxchg8b (%esi)
24545 jne 1b
24546
24547 + pax_force_retaddr
24548 ret
24549 CFI_ENDPROC
24550 ENDPROC(atomic64_set_cx8)
24551
24552 +ENTRY(atomic64_set_unchecked_cx8)
24553 + CFI_STARTPROC
24554 +
24555 +1:
24556 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24557 + * are atomic on 586 and newer */
24558 + cmpxchg8b (%esi)
24559 + jne 1b
24560 +
24561 + pax_force_retaddr
24562 + ret
24563 + CFI_ENDPROC
24564 +ENDPROC(atomic64_set_unchecked_cx8)
24565 +
24566 ENTRY(atomic64_xchg_cx8)
24567 CFI_STARTPROC
24568
24569 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24570 cmpxchg8b (%esi)
24571 jne 1b
24572
24573 + pax_force_retaddr
24574 ret
24575 CFI_ENDPROC
24576 ENDPROC(atomic64_xchg_cx8)
24577
24578 -.macro addsub_return func ins insc
24579 -ENTRY(atomic64_\func\()_return_cx8)
24580 +.macro addsub_return func ins insc unchecked=""
24581 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24582 CFI_STARTPROC
24583 SAVE ebp
24584 SAVE ebx
24585 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24586 movl %edx, %ecx
24587 \ins\()l %esi, %ebx
24588 \insc\()l %edi, %ecx
24589 +
24590 +.ifb \unchecked
24591 +#ifdef CONFIG_PAX_REFCOUNT
24592 + into
24593 +2:
24594 + _ASM_EXTABLE(2b, 3f)
24595 +#endif
24596 +.endif
24597 +
24598 LOCK_PREFIX
24599 cmpxchg8b (%ebp)
24600 jne 1b
24601 -
24602 -10:
24603 movl %ebx, %eax
24604 movl %ecx, %edx
24605 +
24606 +.ifb \unchecked
24607 +#ifdef CONFIG_PAX_REFCOUNT
24608 +3:
24609 +#endif
24610 +.endif
24611 +
24612 RESTORE edi
24613 RESTORE esi
24614 RESTORE ebx
24615 RESTORE ebp
24616 + pax_force_retaddr
24617 ret
24618 CFI_ENDPROC
24619 -ENDPROC(atomic64_\func\()_return_cx8)
24620 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24621 .endm
24622
24623 addsub_return add add adc
24624 addsub_return sub sub sbb
24625 +addsub_return add add adc _unchecked
24626 +addsub_return sub sub sbb _unchecked
24627
24628 -.macro incdec_return func ins insc
24629 -ENTRY(atomic64_\func\()_return_cx8)
24630 +.macro incdec_return func ins insc unchecked=""
24631 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24632 CFI_STARTPROC
24633 SAVE ebx
24634
24635 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24636 movl %edx, %ecx
24637 \ins\()l $1, %ebx
24638 \insc\()l $0, %ecx
24639 +
24640 +.ifb \unchecked
24641 +#ifdef CONFIG_PAX_REFCOUNT
24642 + into
24643 +2:
24644 + _ASM_EXTABLE(2b, 3f)
24645 +#endif
24646 +.endif
24647 +
24648 LOCK_PREFIX
24649 cmpxchg8b (%esi)
24650 jne 1b
24651
24652 -10:
24653 movl %ebx, %eax
24654 movl %ecx, %edx
24655 +
24656 +.ifb \unchecked
24657 +#ifdef CONFIG_PAX_REFCOUNT
24658 +3:
24659 +#endif
24660 +.endif
24661 +
24662 RESTORE ebx
24663 + pax_force_retaddr
24664 ret
24665 CFI_ENDPROC
24666 -ENDPROC(atomic64_\func\()_return_cx8)
24667 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24668 .endm
24669
24670 incdec_return inc add adc
24671 incdec_return dec sub sbb
24672 +incdec_return inc add adc _unchecked
24673 +incdec_return dec sub sbb _unchecked
24674
24675 ENTRY(atomic64_dec_if_positive_cx8)
24676 CFI_STARTPROC
24677 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24678 movl %edx, %ecx
24679 subl $1, %ebx
24680 sbb $0, %ecx
24681 +
24682 +#ifdef CONFIG_PAX_REFCOUNT
24683 + into
24684 +1234:
24685 + _ASM_EXTABLE(1234b, 2f)
24686 +#endif
24687 +
24688 js 2f
24689 LOCK_PREFIX
24690 cmpxchg8b (%esi)
24691 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24692 movl %ebx, %eax
24693 movl %ecx, %edx
24694 RESTORE ebx
24695 + pax_force_retaddr
24696 ret
24697 CFI_ENDPROC
24698 ENDPROC(atomic64_dec_if_positive_cx8)
24699 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24700 movl %edx, %ecx
24701 addl %ebp, %ebx
24702 adcl %edi, %ecx
24703 +
24704 +#ifdef CONFIG_PAX_REFCOUNT
24705 + into
24706 +1234:
24707 + _ASM_EXTABLE(1234b, 3f)
24708 +#endif
24709 +
24710 LOCK_PREFIX
24711 cmpxchg8b (%esi)
24712 jne 1b
24713 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24714 CFI_ADJUST_CFA_OFFSET -8
24715 RESTORE ebx
24716 RESTORE ebp
24717 + pax_force_retaddr
24718 ret
24719 4:
24720 cmpl %edx, 4(%esp)
24721 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24722 xorl %ecx, %ecx
24723 addl $1, %ebx
24724 adcl %edx, %ecx
24725 +
24726 +#ifdef CONFIG_PAX_REFCOUNT
24727 + into
24728 +1234:
24729 + _ASM_EXTABLE(1234b, 3f)
24730 +#endif
24731 +
24732 LOCK_PREFIX
24733 cmpxchg8b (%esi)
24734 jne 1b
24735 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24736 movl $1, %eax
24737 3:
24738 RESTORE ebx
24739 + pax_force_retaddr
24740 ret
24741 CFI_ENDPROC
24742 ENDPROC(atomic64_inc_not_zero_cx8)
24743 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24744 index 2af5df3..62b1a5a 100644
24745 --- a/arch/x86/lib/checksum_32.S
24746 +++ b/arch/x86/lib/checksum_32.S
24747 @@ -29,7 +29,8 @@
24748 #include <asm/dwarf2.h>
24749 #include <asm/errno.h>
24750 #include <asm/asm.h>
24751 -
24752 +#include <asm/segment.h>
24753 +
24754 /*
24755 * computes a partial checksum, e.g. for TCP/UDP fragments
24756 */
24757 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24758
24759 #define ARGBASE 16
24760 #define FP 12
24761 -
24762 -ENTRY(csum_partial_copy_generic)
24763 +
24764 +ENTRY(csum_partial_copy_generic_to_user)
24765 CFI_STARTPROC
24766 +
24767 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24768 + pushl_cfi %gs
24769 + popl_cfi %es
24770 + jmp csum_partial_copy_generic
24771 +#endif
24772 +
24773 +ENTRY(csum_partial_copy_generic_from_user)
24774 +
24775 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24776 + pushl_cfi %gs
24777 + popl_cfi %ds
24778 +#endif
24779 +
24780 +ENTRY(csum_partial_copy_generic)
24781 subl $4,%esp
24782 CFI_ADJUST_CFA_OFFSET 4
24783 pushl_cfi %edi
24784 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24785 jmp 4f
24786 SRC(1: movw (%esi), %bx )
24787 addl $2, %esi
24788 -DST( movw %bx, (%edi) )
24789 +DST( movw %bx, %es:(%edi) )
24790 addl $2, %edi
24791 addw %bx, %ax
24792 adcl $0, %eax
24793 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24794 SRC(1: movl (%esi), %ebx )
24795 SRC( movl 4(%esi), %edx )
24796 adcl %ebx, %eax
24797 -DST( movl %ebx, (%edi) )
24798 +DST( movl %ebx, %es:(%edi) )
24799 adcl %edx, %eax
24800 -DST( movl %edx, 4(%edi) )
24801 +DST( movl %edx, %es:4(%edi) )
24802
24803 SRC( movl 8(%esi), %ebx )
24804 SRC( movl 12(%esi), %edx )
24805 adcl %ebx, %eax
24806 -DST( movl %ebx, 8(%edi) )
24807 +DST( movl %ebx, %es:8(%edi) )
24808 adcl %edx, %eax
24809 -DST( movl %edx, 12(%edi) )
24810 +DST( movl %edx, %es:12(%edi) )
24811
24812 SRC( movl 16(%esi), %ebx )
24813 SRC( movl 20(%esi), %edx )
24814 adcl %ebx, %eax
24815 -DST( movl %ebx, 16(%edi) )
24816 +DST( movl %ebx, %es:16(%edi) )
24817 adcl %edx, %eax
24818 -DST( movl %edx, 20(%edi) )
24819 +DST( movl %edx, %es:20(%edi) )
24820
24821 SRC( movl 24(%esi), %ebx )
24822 SRC( movl 28(%esi), %edx )
24823 adcl %ebx, %eax
24824 -DST( movl %ebx, 24(%edi) )
24825 +DST( movl %ebx, %es:24(%edi) )
24826 adcl %edx, %eax
24827 -DST( movl %edx, 28(%edi) )
24828 +DST( movl %edx, %es:28(%edi) )
24829
24830 lea 32(%esi), %esi
24831 lea 32(%edi), %edi
24832 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24833 shrl $2, %edx # This clears CF
24834 SRC(3: movl (%esi), %ebx )
24835 adcl %ebx, %eax
24836 -DST( movl %ebx, (%edi) )
24837 +DST( movl %ebx, %es:(%edi) )
24838 lea 4(%esi), %esi
24839 lea 4(%edi), %edi
24840 dec %edx
24841 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24842 jb 5f
24843 SRC( movw (%esi), %cx )
24844 leal 2(%esi), %esi
24845 -DST( movw %cx, (%edi) )
24846 +DST( movw %cx, %es:(%edi) )
24847 leal 2(%edi), %edi
24848 je 6f
24849 shll $16,%ecx
24850 SRC(5: movb (%esi), %cl )
24851 -DST( movb %cl, (%edi) )
24852 +DST( movb %cl, %es:(%edi) )
24853 6: addl %ecx, %eax
24854 adcl $0, %eax
24855 7:
24856 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24857
24858 6001:
24859 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24860 - movl $-EFAULT, (%ebx)
24861 + movl $-EFAULT, %ss:(%ebx)
24862
24863 # zero the complete destination - computing the rest
24864 # is too much work
24865 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24866
24867 6002:
24868 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24869 - movl $-EFAULT,(%ebx)
24870 + movl $-EFAULT,%ss:(%ebx)
24871 jmp 5000b
24872
24873 .previous
24874
24875 + pushl_cfi %ss
24876 + popl_cfi %ds
24877 + pushl_cfi %ss
24878 + popl_cfi %es
24879 popl_cfi %ebx
24880 CFI_RESTORE ebx
24881 popl_cfi %esi
24882 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24883 popl_cfi %ecx # equivalent to addl $4,%esp
24884 ret
24885 CFI_ENDPROC
24886 -ENDPROC(csum_partial_copy_generic)
24887 +ENDPROC(csum_partial_copy_generic_to_user)
24888
24889 #else
24890
24891 /* Version for PentiumII/PPro */
24892
24893 #define ROUND1(x) \
24894 + nop; nop; nop; \
24895 SRC(movl x(%esi), %ebx ) ; \
24896 addl %ebx, %eax ; \
24897 - DST(movl %ebx, x(%edi) ) ;
24898 + DST(movl %ebx, %es:x(%edi)) ;
24899
24900 #define ROUND(x) \
24901 + nop; nop; nop; \
24902 SRC(movl x(%esi), %ebx ) ; \
24903 adcl %ebx, %eax ; \
24904 - DST(movl %ebx, x(%edi) ) ;
24905 + DST(movl %ebx, %es:x(%edi)) ;
24906
24907 #define ARGBASE 12
24908 -
24909 -ENTRY(csum_partial_copy_generic)
24910 +
24911 +ENTRY(csum_partial_copy_generic_to_user)
24912 CFI_STARTPROC
24913 +
24914 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24915 + pushl_cfi %gs
24916 + popl_cfi %es
24917 + jmp csum_partial_copy_generic
24918 +#endif
24919 +
24920 +ENTRY(csum_partial_copy_generic_from_user)
24921 +
24922 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24923 + pushl_cfi %gs
24924 + popl_cfi %ds
24925 +#endif
24926 +
24927 +ENTRY(csum_partial_copy_generic)
24928 pushl_cfi %ebx
24929 CFI_REL_OFFSET ebx, 0
24930 pushl_cfi %edi
24931 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24932 subl %ebx, %edi
24933 lea -1(%esi),%edx
24934 andl $-32,%edx
24935 - lea 3f(%ebx,%ebx), %ebx
24936 + lea 3f(%ebx,%ebx,2), %ebx
24937 testl %esi, %esi
24938 jmp *%ebx
24939 1: addl $64,%esi
24940 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24941 jb 5f
24942 SRC( movw (%esi), %dx )
24943 leal 2(%esi), %esi
24944 -DST( movw %dx, (%edi) )
24945 +DST( movw %dx, %es:(%edi) )
24946 leal 2(%edi), %edi
24947 je 6f
24948 shll $16,%edx
24949 5:
24950 SRC( movb (%esi), %dl )
24951 -DST( movb %dl, (%edi) )
24952 +DST( movb %dl, %es:(%edi) )
24953 6: addl %edx, %eax
24954 adcl $0, %eax
24955 7:
24956 .section .fixup, "ax"
24957 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24958 - movl $-EFAULT, (%ebx)
24959 + movl $-EFAULT, %ss:(%ebx)
24960 # zero the complete destination (computing the rest is too much work)
24961 movl ARGBASE+8(%esp),%edi # dst
24962 movl ARGBASE+12(%esp),%ecx # len
24963 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24964 rep; stosb
24965 jmp 7b
24966 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24967 - movl $-EFAULT, (%ebx)
24968 + movl $-EFAULT, %ss:(%ebx)
24969 jmp 7b
24970 .previous
24971
24972 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24973 + pushl_cfi %ss
24974 + popl_cfi %ds
24975 + pushl_cfi %ss
24976 + popl_cfi %es
24977 +#endif
24978 +
24979 popl_cfi %esi
24980 CFI_RESTORE esi
24981 popl_cfi %edi
24982 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24983 CFI_RESTORE ebx
24984 ret
24985 CFI_ENDPROC
24986 -ENDPROC(csum_partial_copy_generic)
24987 +ENDPROC(csum_partial_copy_generic_to_user)
24988
24989 #undef ROUND
24990 #undef ROUND1
24991 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24992 index f2145cf..cea889d 100644
24993 --- a/arch/x86/lib/clear_page_64.S
24994 +++ b/arch/x86/lib/clear_page_64.S
24995 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24996 movl $4096/8,%ecx
24997 xorl %eax,%eax
24998 rep stosq
24999 + pax_force_retaddr
25000 ret
25001 CFI_ENDPROC
25002 ENDPROC(clear_page_c)
25003 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25004 movl $4096,%ecx
25005 xorl %eax,%eax
25006 rep stosb
25007 + pax_force_retaddr
25008 ret
25009 CFI_ENDPROC
25010 ENDPROC(clear_page_c_e)
25011 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25012 leaq 64(%rdi),%rdi
25013 jnz .Lloop
25014 nop
25015 + pax_force_retaddr
25016 ret
25017 CFI_ENDPROC
25018 .Lclear_page_end:
25019 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25020
25021 #include <asm/cpufeature.h>
25022
25023 - .section .altinstr_replacement,"ax"
25024 + .section .altinstr_replacement,"a"
25025 1: .byte 0xeb /* jmp <disp8> */
25026 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25027 2: .byte 0xeb /* jmp <disp8> */
25028 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25029 index 1e572c5..2a162cd 100644
25030 --- a/arch/x86/lib/cmpxchg16b_emu.S
25031 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25032 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25033
25034 popf
25035 mov $1, %al
25036 + pax_force_retaddr
25037 ret
25038
25039 not_same:
25040 popf
25041 xor %al,%al
25042 + pax_force_retaddr
25043 ret
25044
25045 CFI_ENDPROC
25046 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25047 index 176cca6..1166c50 100644
25048 --- a/arch/x86/lib/copy_page_64.S
25049 +++ b/arch/x86/lib/copy_page_64.S
25050 @@ -9,6 +9,7 @@ copy_page_rep:
25051 CFI_STARTPROC
25052 movl $4096/8, %ecx
25053 rep movsq
25054 + pax_force_retaddr
25055 ret
25056 CFI_ENDPROC
25057 ENDPROC(copy_page_rep)
25058 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25059
25060 ENTRY(copy_page)
25061 CFI_STARTPROC
25062 - subq $2*8, %rsp
25063 - CFI_ADJUST_CFA_OFFSET 2*8
25064 + subq $3*8, %rsp
25065 + CFI_ADJUST_CFA_OFFSET 3*8
25066 movq %rbx, (%rsp)
25067 CFI_REL_OFFSET rbx, 0
25068 movq %r12, 1*8(%rsp)
25069 CFI_REL_OFFSET r12, 1*8
25070 + movq %r13, 2*8(%rsp)
25071 + CFI_REL_OFFSET r13, 2*8
25072
25073 movl $(4096/64)-5, %ecx
25074 .p2align 4
25075 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25076 movq 0x8*2(%rsi), %rdx
25077 movq 0x8*3(%rsi), %r8
25078 movq 0x8*4(%rsi), %r9
25079 - movq 0x8*5(%rsi), %r10
25080 + movq 0x8*5(%rsi), %r13
25081 movq 0x8*6(%rsi), %r11
25082 movq 0x8*7(%rsi), %r12
25083
25084 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25085 movq %rdx, 0x8*2(%rdi)
25086 movq %r8, 0x8*3(%rdi)
25087 movq %r9, 0x8*4(%rdi)
25088 - movq %r10, 0x8*5(%rdi)
25089 + movq %r13, 0x8*5(%rdi)
25090 movq %r11, 0x8*6(%rdi)
25091 movq %r12, 0x8*7(%rdi)
25092
25093 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25094 movq 0x8*2(%rsi), %rdx
25095 movq 0x8*3(%rsi), %r8
25096 movq 0x8*4(%rsi), %r9
25097 - movq 0x8*5(%rsi), %r10
25098 + movq 0x8*5(%rsi), %r13
25099 movq 0x8*6(%rsi), %r11
25100 movq 0x8*7(%rsi), %r12
25101
25102 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25103 movq %rdx, 0x8*2(%rdi)
25104 movq %r8, 0x8*3(%rdi)
25105 movq %r9, 0x8*4(%rdi)
25106 - movq %r10, 0x8*5(%rdi)
25107 + movq %r13, 0x8*5(%rdi)
25108 movq %r11, 0x8*6(%rdi)
25109 movq %r12, 0x8*7(%rdi)
25110
25111 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25112 CFI_RESTORE rbx
25113 movq 1*8(%rsp), %r12
25114 CFI_RESTORE r12
25115 - addq $2*8, %rsp
25116 - CFI_ADJUST_CFA_OFFSET -2*8
25117 + movq 2*8(%rsp), %r13
25118 + CFI_RESTORE r13
25119 + addq $3*8, %rsp
25120 + CFI_ADJUST_CFA_OFFSET -3*8
25121 + pax_force_retaddr
25122 ret
25123 .Lcopy_page_end:
25124 CFI_ENDPROC
25125 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25126
25127 #include <asm/cpufeature.h>
25128
25129 - .section .altinstr_replacement,"ax"
25130 + .section .altinstr_replacement,"a"
25131 1: .byte 0xeb /* jmp <disp8> */
25132 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25133 2:
25134 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25135 index a30ca15..d25fab6 100644
25136 --- a/arch/x86/lib/copy_user_64.S
25137 +++ b/arch/x86/lib/copy_user_64.S
25138 @@ -18,6 +18,7 @@
25139 #include <asm/alternative-asm.h>
25140 #include <asm/asm.h>
25141 #include <asm/smap.h>
25142 +#include <asm/pgtable.h>
25143
25144 /*
25145 * By placing feature2 after feature1 in altinstructions section, we logically
25146 @@ -31,7 +32,7 @@
25147 .byte 0xe9 /* 32bit jump */
25148 .long \orig-1f /* by default jump to orig */
25149 1:
25150 - .section .altinstr_replacement,"ax"
25151 + .section .altinstr_replacement,"a"
25152 2: .byte 0xe9 /* near jump with 32bit immediate */
25153 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25154 3: .byte 0xe9 /* near jump with 32bit immediate */
25155 @@ -70,47 +71,20 @@
25156 #endif
25157 .endm
25158
25159 -/* Standard copy_to_user with segment limit checking */
25160 -ENTRY(_copy_to_user)
25161 - CFI_STARTPROC
25162 - GET_THREAD_INFO(%rax)
25163 - movq %rdi,%rcx
25164 - addq %rdx,%rcx
25165 - jc bad_to_user
25166 - cmpq TI_addr_limit(%rax),%rcx
25167 - ja bad_to_user
25168 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25169 - copy_user_generic_unrolled,copy_user_generic_string, \
25170 - copy_user_enhanced_fast_string
25171 - CFI_ENDPROC
25172 -ENDPROC(_copy_to_user)
25173 -
25174 -/* Standard copy_from_user with segment limit checking */
25175 -ENTRY(_copy_from_user)
25176 - CFI_STARTPROC
25177 - GET_THREAD_INFO(%rax)
25178 - movq %rsi,%rcx
25179 - addq %rdx,%rcx
25180 - jc bad_from_user
25181 - cmpq TI_addr_limit(%rax),%rcx
25182 - ja bad_from_user
25183 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25184 - copy_user_generic_unrolled,copy_user_generic_string, \
25185 - copy_user_enhanced_fast_string
25186 - CFI_ENDPROC
25187 -ENDPROC(_copy_from_user)
25188 -
25189 .section .fixup,"ax"
25190 /* must zero dest */
25191 ENTRY(bad_from_user)
25192 bad_from_user:
25193 CFI_STARTPROC
25194 + testl %edx,%edx
25195 + js bad_to_user
25196 movl %edx,%ecx
25197 xorl %eax,%eax
25198 rep
25199 stosb
25200 bad_to_user:
25201 movl %edx,%eax
25202 + pax_force_retaddr
25203 ret
25204 CFI_ENDPROC
25205 ENDPROC(bad_from_user)
25206 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25207 jz 17f
25208 1: movq (%rsi),%r8
25209 2: movq 1*8(%rsi),%r9
25210 -3: movq 2*8(%rsi),%r10
25211 +3: movq 2*8(%rsi),%rax
25212 4: movq 3*8(%rsi),%r11
25213 5: movq %r8,(%rdi)
25214 6: movq %r9,1*8(%rdi)
25215 -7: movq %r10,2*8(%rdi)
25216 +7: movq %rax,2*8(%rdi)
25217 8: movq %r11,3*8(%rdi)
25218 9: movq 4*8(%rsi),%r8
25219 10: movq 5*8(%rsi),%r9
25220 -11: movq 6*8(%rsi),%r10
25221 +11: movq 6*8(%rsi),%rax
25222 12: movq 7*8(%rsi),%r11
25223 13: movq %r8,4*8(%rdi)
25224 14: movq %r9,5*8(%rdi)
25225 -15: movq %r10,6*8(%rdi)
25226 +15: movq %rax,6*8(%rdi)
25227 16: movq %r11,7*8(%rdi)
25228 leaq 64(%rsi),%rsi
25229 leaq 64(%rdi),%rdi
25230 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25231 jnz 21b
25232 23: xor %eax,%eax
25233 ASM_CLAC
25234 + pax_force_retaddr
25235 ret
25236
25237 .section .fixup,"ax"
25238 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25239 movsb
25240 4: xorl %eax,%eax
25241 ASM_CLAC
25242 + pax_force_retaddr
25243 ret
25244
25245 .section .fixup,"ax"
25246 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25247 movsb
25248 2: xorl %eax,%eax
25249 ASM_CLAC
25250 + pax_force_retaddr
25251 ret
25252
25253 .section .fixup,"ax"
25254 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25255 index 6a4f43c..f08b4a2 100644
25256 --- a/arch/x86/lib/copy_user_nocache_64.S
25257 +++ b/arch/x86/lib/copy_user_nocache_64.S
25258 @@ -8,6 +8,7 @@
25259
25260 #include <linux/linkage.h>
25261 #include <asm/dwarf2.h>
25262 +#include <asm/alternative-asm.h>
25263
25264 #define FIX_ALIGNMENT 1
25265
25266 @@ -16,6 +17,7 @@
25267 #include <asm/thread_info.h>
25268 #include <asm/asm.h>
25269 #include <asm/smap.h>
25270 +#include <asm/pgtable.h>
25271
25272 .macro ALIGN_DESTINATION
25273 #ifdef FIX_ALIGNMENT
25274 @@ -49,6 +51,15 @@
25275 */
25276 ENTRY(__copy_user_nocache)
25277 CFI_STARTPROC
25278 +
25279 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25280 + mov pax_user_shadow_base,%rcx
25281 + cmp %rcx,%rsi
25282 + jae 1f
25283 + add %rcx,%rsi
25284 +1:
25285 +#endif
25286 +
25287 ASM_STAC
25288 cmpl $8,%edx
25289 jb 20f /* less then 8 bytes, go to byte copy loop */
25290 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25291 jz 17f
25292 1: movq (%rsi),%r8
25293 2: movq 1*8(%rsi),%r9
25294 -3: movq 2*8(%rsi),%r10
25295 +3: movq 2*8(%rsi),%rax
25296 4: movq 3*8(%rsi),%r11
25297 5: movnti %r8,(%rdi)
25298 6: movnti %r9,1*8(%rdi)
25299 -7: movnti %r10,2*8(%rdi)
25300 +7: movnti %rax,2*8(%rdi)
25301 8: movnti %r11,3*8(%rdi)
25302 9: movq 4*8(%rsi),%r8
25303 10: movq 5*8(%rsi),%r9
25304 -11: movq 6*8(%rsi),%r10
25305 +11: movq 6*8(%rsi),%rax
25306 12: movq 7*8(%rsi),%r11
25307 13: movnti %r8,4*8(%rdi)
25308 14: movnti %r9,5*8(%rdi)
25309 -15: movnti %r10,6*8(%rdi)
25310 +15: movnti %rax,6*8(%rdi)
25311 16: movnti %r11,7*8(%rdi)
25312 leaq 64(%rsi),%rsi
25313 leaq 64(%rdi),%rdi
25314 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25315 23: xorl %eax,%eax
25316 ASM_CLAC
25317 sfence
25318 + pax_force_retaddr
25319 ret
25320
25321 .section .fixup,"ax"
25322 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25323 index 2419d5f..953ee51 100644
25324 --- a/arch/x86/lib/csum-copy_64.S
25325 +++ b/arch/x86/lib/csum-copy_64.S
25326 @@ -9,6 +9,7 @@
25327 #include <asm/dwarf2.h>
25328 #include <asm/errno.h>
25329 #include <asm/asm.h>
25330 +#include <asm/alternative-asm.h>
25331
25332 /*
25333 * Checksum copy with exception handling.
25334 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25335 CFI_RESTORE rbp
25336 addq $7*8, %rsp
25337 CFI_ADJUST_CFA_OFFSET -7*8
25338 + pax_force_retaddr 0, 1
25339 ret
25340 CFI_RESTORE_STATE
25341
25342 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25343 index 25b7ae8..169fafc 100644
25344 --- a/arch/x86/lib/csum-wrappers_64.c
25345 +++ b/arch/x86/lib/csum-wrappers_64.c
25346 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25347 len -= 2;
25348 }
25349 }
25350 - isum = csum_partial_copy_generic((__force const void *)src,
25351 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25352 dst, len, isum, errp, NULL);
25353 if (unlikely(*errp))
25354 goto out_err;
25355 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25356 }
25357
25358 *errp = 0;
25359 - return csum_partial_copy_generic(src, (void __force *)dst,
25360 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25361 len, isum, NULL, errp);
25362 }
25363 EXPORT_SYMBOL(csum_partial_copy_to_user);
25364 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25365 index a451235..79fb5cf 100644
25366 --- a/arch/x86/lib/getuser.S
25367 +++ b/arch/x86/lib/getuser.S
25368 @@ -33,17 +33,40 @@
25369 #include <asm/thread_info.h>
25370 #include <asm/asm.h>
25371 #include <asm/smap.h>
25372 +#include <asm/segment.h>
25373 +#include <asm/pgtable.h>
25374 +#include <asm/alternative-asm.h>
25375 +
25376 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25377 +#define __copyuser_seg gs;
25378 +#else
25379 +#define __copyuser_seg
25380 +#endif
25381
25382 .text
25383 ENTRY(__get_user_1)
25384 CFI_STARTPROC
25385 +
25386 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25387 GET_THREAD_INFO(%_ASM_DX)
25388 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25389 jae bad_get_user
25390 ASM_STAC
25391 -1: movzbl (%_ASM_AX),%edx
25392 +
25393 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25394 + mov pax_user_shadow_base,%_ASM_DX
25395 + cmp %_ASM_DX,%_ASM_AX
25396 + jae 1234f
25397 + add %_ASM_DX,%_ASM_AX
25398 +1234:
25399 +#endif
25400 +
25401 +#endif
25402 +
25403 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25404 xor %eax,%eax
25405 ASM_CLAC
25406 + pax_force_retaddr
25407 ret
25408 CFI_ENDPROC
25409 ENDPROC(__get_user_1)
25410 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25411 ENTRY(__get_user_2)
25412 CFI_STARTPROC
25413 add $1,%_ASM_AX
25414 +
25415 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25416 jc bad_get_user
25417 GET_THREAD_INFO(%_ASM_DX)
25418 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25419 jae bad_get_user
25420 ASM_STAC
25421 -2: movzwl -1(%_ASM_AX),%edx
25422 +
25423 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25424 + mov pax_user_shadow_base,%_ASM_DX
25425 + cmp %_ASM_DX,%_ASM_AX
25426 + jae 1234f
25427 + add %_ASM_DX,%_ASM_AX
25428 +1234:
25429 +#endif
25430 +
25431 +#endif
25432 +
25433 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25434 xor %eax,%eax
25435 ASM_CLAC
25436 + pax_force_retaddr
25437 ret
25438 CFI_ENDPROC
25439 ENDPROC(__get_user_2)
25440 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25441 ENTRY(__get_user_4)
25442 CFI_STARTPROC
25443 add $3,%_ASM_AX
25444 +
25445 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25446 jc bad_get_user
25447 GET_THREAD_INFO(%_ASM_DX)
25448 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25449 jae bad_get_user
25450 ASM_STAC
25451 -3: movl -3(%_ASM_AX),%edx
25452 +
25453 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25454 + mov pax_user_shadow_base,%_ASM_DX
25455 + cmp %_ASM_DX,%_ASM_AX
25456 + jae 1234f
25457 + add %_ASM_DX,%_ASM_AX
25458 +1234:
25459 +#endif
25460 +
25461 +#endif
25462 +
25463 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25464 xor %eax,%eax
25465 ASM_CLAC
25466 + pax_force_retaddr
25467 ret
25468 CFI_ENDPROC
25469 ENDPROC(__get_user_4)
25470 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25471 GET_THREAD_INFO(%_ASM_DX)
25472 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25473 jae bad_get_user
25474 +
25475 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25476 + mov pax_user_shadow_base,%_ASM_DX
25477 + cmp %_ASM_DX,%_ASM_AX
25478 + jae 1234f
25479 + add %_ASM_DX,%_ASM_AX
25480 +1234:
25481 +#endif
25482 +
25483 ASM_STAC
25484 4: movq -7(%_ASM_AX),%rdx
25485 xor %eax,%eax
25486 ASM_CLAC
25487 + pax_force_retaddr
25488 ret
25489 #else
25490 add $7,%_ASM_AX
25491 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25492 5: movl -3(%_ASM_AX),%ecx
25493 xor %eax,%eax
25494 ASM_CLAC
25495 + pax_force_retaddr
25496 ret
25497 #endif
25498 CFI_ENDPROC
25499 @@ -113,6 +175,7 @@ bad_get_user:
25500 xor %edx,%edx
25501 mov $(-EFAULT),%_ASM_AX
25502 ASM_CLAC
25503 + pax_force_retaddr
25504 ret
25505 CFI_ENDPROC
25506 END(bad_get_user)
25507 @@ -124,6 +187,7 @@ bad_get_user_8:
25508 xor %ecx,%ecx
25509 mov $(-EFAULT),%_ASM_AX
25510 ASM_CLAC
25511 + pax_force_retaddr
25512 ret
25513 CFI_ENDPROC
25514 END(bad_get_user_8)
25515 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25516 index 54fcffe..7be149e 100644
25517 --- a/arch/x86/lib/insn.c
25518 +++ b/arch/x86/lib/insn.c
25519 @@ -20,8 +20,10 @@
25520
25521 #ifdef __KERNEL__
25522 #include <linux/string.h>
25523 +#include <asm/pgtable_types.h>
25524 #else
25525 #include <string.h>
25526 +#define ktla_ktva(addr) addr
25527 #endif
25528 #include <asm/inat.h>
25529 #include <asm/insn.h>
25530 @@ -53,8 +55,8 @@
25531 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25532 {
25533 memset(insn, 0, sizeof(*insn));
25534 - insn->kaddr = kaddr;
25535 - insn->next_byte = kaddr;
25536 + insn->kaddr = ktla_ktva(kaddr);
25537 + insn->next_byte = ktla_ktva(kaddr);
25538 insn->x86_64 = x86_64 ? 1 : 0;
25539 insn->opnd_bytes = 4;
25540 if (x86_64)
25541 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25542 index 05a95e7..326f2fa 100644
25543 --- a/arch/x86/lib/iomap_copy_64.S
25544 +++ b/arch/x86/lib/iomap_copy_64.S
25545 @@ -17,6 +17,7 @@
25546
25547 #include <linux/linkage.h>
25548 #include <asm/dwarf2.h>
25549 +#include <asm/alternative-asm.h>
25550
25551 /*
25552 * override generic version in lib/iomap_copy.c
25553 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25554 CFI_STARTPROC
25555 movl %edx,%ecx
25556 rep movsd
25557 + pax_force_retaddr
25558 ret
25559 CFI_ENDPROC
25560 ENDPROC(__iowrite32_copy)
25561 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25562 index 1c273be..da9cc0e 100644
25563 --- a/arch/x86/lib/memcpy_64.S
25564 +++ b/arch/x86/lib/memcpy_64.S
25565 @@ -33,6 +33,7 @@
25566 rep movsq
25567 movl %edx, %ecx
25568 rep movsb
25569 + pax_force_retaddr
25570 ret
25571 .Lmemcpy_e:
25572 .previous
25573 @@ -49,6 +50,7 @@
25574 movq %rdi, %rax
25575 movq %rdx, %rcx
25576 rep movsb
25577 + pax_force_retaddr
25578 ret
25579 .Lmemcpy_e_e:
25580 .previous
25581 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25582 */
25583 movq 0*8(%rsi), %r8
25584 movq 1*8(%rsi), %r9
25585 - movq 2*8(%rsi), %r10
25586 + movq 2*8(%rsi), %rcx
25587 movq 3*8(%rsi), %r11
25588 leaq 4*8(%rsi), %rsi
25589
25590 movq %r8, 0*8(%rdi)
25591 movq %r9, 1*8(%rdi)
25592 - movq %r10, 2*8(%rdi)
25593 + movq %rcx, 2*8(%rdi)
25594 movq %r11, 3*8(%rdi)
25595 leaq 4*8(%rdi), %rdi
25596 jae .Lcopy_forward_loop
25597 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25598 subq $0x20, %rdx
25599 movq -1*8(%rsi), %r8
25600 movq -2*8(%rsi), %r9
25601 - movq -3*8(%rsi), %r10
25602 + movq -3*8(%rsi), %rcx
25603 movq -4*8(%rsi), %r11
25604 leaq -4*8(%rsi), %rsi
25605 movq %r8, -1*8(%rdi)
25606 movq %r9, -2*8(%rdi)
25607 - movq %r10, -3*8(%rdi)
25608 + movq %rcx, -3*8(%rdi)
25609 movq %r11, -4*8(%rdi)
25610 leaq -4*8(%rdi), %rdi
25611 jae .Lcopy_backward_loop
25612 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25613 */
25614 movq 0*8(%rsi), %r8
25615 movq 1*8(%rsi), %r9
25616 - movq -2*8(%rsi, %rdx), %r10
25617 + movq -2*8(%rsi, %rdx), %rcx
25618 movq -1*8(%rsi, %rdx), %r11
25619 movq %r8, 0*8(%rdi)
25620 movq %r9, 1*8(%rdi)
25621 - movq %r10, -2*8(%rdi, %rdx)
25622 + movq %rcx, -2*8(%rdi, %rdx)
25623 movq %r11, -1*8(%rdi, %rdx)
25624 + pax_force_retaddr
25625 retq
25626 .p2align 4
25627 .Lless_16bytes:
25628 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25629 movq -1*8(%rsi, %rdx), %r9
25630 movq %r8, 0*8(%rdi)
25631 movq %r9, -1*8(%rdi, %rdx)
25632 + pax_force_retaddr
25633 retq
25634 .p2align 4
25635 .Lless_8bytes:
25636 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25637 movl -4(%rsi, %rdx), %r8d
25638 movl %ecx, (%rdi)
25639 movl %r8d, -4(%rdi, %rdx)
25640 + pax_force_retaddr
25641 retq
25642 .p2align 4
25643 .Lless_3bytes:
25644 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25645 movb %cl, (%rdi)
25646
25647 .Lend:
25648 + pax_force_retaddr
25649 retq
25650 CFI_ENDPROC
25651 ENDPROC(memcpy)
25652 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25653 index ee16461..c39c199 100644
25654 --- a/arch/x86/lib/memmove_64.S
25655 +++ b/arch/x86/lib/memmove_64.S
25656 @@ -61,13 +61,13 @@ ENTRY(memmove)
25657 5:
25658 sub $0x20, %rdx
25659 movq 0*8(%rsi), %r11
25660 - movq 1*8(%rsi), %r10
25661 + movq 1*8(%rsi), %rcx
25662 movq 2*8(%rsi), %r9
25663 movq 3*8(%rsi), %r8
25664 leaq 4*8(%rsi), %rsi
25665
25666 movq %r11, 0*8(%rdi)
25667 - movq %r10, 1*8(%rdi)
25668 + movq %rcx, 1*8(%rdi)
25669 movq %r9, 2*8(%rdi)
25670 movq %r8, 3*8(%rdi)
25671 leaq 4*8(%rdi), %rdi
25672 @@ -81,10 +81,10 @@ ENTRY(memmove)
25673 4:
25674 movq %rdx, %rcx
25675 movq -8(%rsi, %rdx), %r11
25676 - lea -8(%rdi, %rdx), %r10
25677 + lea -8(%rdi, %rdx), %r9
25678 shrq $3, %rcx
25679 rep movsq
25680 - movq %r11, (%r10)
25681 + movq %r11, (%r9)
25682 jmp 13f
25683 .Lmemmove_end_forward:
25684
25685 @@ -95,14 +95,14 @@ ENTRY(memmove)
25686 7:
25687 movq %rdx, %rcx
25688 movq (%rsi), %r11
25689 - movq %rdi, %r10
25690 + movq %rdi, %r9
25691 leaq -8(%rsi, %rdx), %rsi
25692 leaq -8(%rdi, %rdx), %rdi
25693 shrq $3, %rcx
25694 std
25695 rep movsq
25696 cld
25697 - movq %r11, (%r10)
25698 + movq %r11, (%r9)
25699 jmp 13f
25700
25701 /*
25702 @@ -127,13 +127,13 @@ ENTRY(memmove)
25703 8:
25704 subq $0x20, %rdx
25705 movq -1*8(%rsi), %r11
25706 - movq -2*8(%rsi), %r10
25707 + movq -2*8(%rsi), %rcx
25708 movq -3*8(%rsi), %r9
25709 movq -4*8(%rsi), %r8
25710 leaq -4*8(%rsi), %rsi
25711
25712 movq %r11, -1*8(%rdi)
25713 - movq %r10, -2*8(%rdi)
25714 + movq %rcx, -2*8(%rdi)
25715 movq %r9, -3*8(%rdi)
25716 movq %r8, -4*8(%rdi)
25717 leaq -4*8(%rdi), %rdi
25718 @@ -151,11 +151,11 @@ ENTRY(memmove)
25719 * Move data from 16 bytes to 31 bytes.
25720 */
25721 movq 0*8(%rsi), %r11
25722 - movq 1*8(%rsi), %r10
25723 + movq 1*8(%rsi), %rcx
25724 movq -2*8(%rsi, %rdx), %r9
25725 movq -1*8(%rsi, %rdx), %r8
25726 movq %r11, 0*8(%rdi)
25727 - movq %r10, 1*8(%rdi)
25728 + movq %rcx, 1*8(%rdi)
25729 movq %r9, -2*8(%rdi, %rdx)
25730 movq %r8, -1*8(%rdi, %rdx)
25731 jmp 13f
25732 @@ -167,9 +167,9 @@ ENTRY(memmove)
25733 * Move data from 8 bytes to 15 bytes.
25734 */
25735 movq 0*8(%rsi), %r11
25736 - movq -1*8(%rsi, %rdx), %r10
25737 + movq -1*8(%rsi, %rdx), %r9
25738 movq %r11, 0*8(%rdi)
25739 - movq %r10, -1*8(%rdi, %rdx)
25740 + movq %r9, -1*8(%rdi, %rdx)
25741 jmp 13f
25742 10:
25743 cmpq $4, %rdx
25744 @@ -178,9 +178,9 @@ ENTRY(memmove)
25745 * Move data from 4 bytes to 7 bytes.
25746 */
25747 movl (%rsi), %r11d
25748 - movl -4(%rsi, %rdx), %r10d
25749 + movl -4(%rsi, %rdx), %r9d
25750 movl %r11d, (%rdi)
25751 - movl %r10d, -4(%rdi, %rdx)
25752 + movl %r9d, -4(%rdi, %rdx)
25753 jmp 13f
25754 11:
25755 cmp $2, %rdx
25756 @@ -189,9 +189,9 @@ ENTRY(memmove)
25757 * Move data from 2 bytes to 3 bytes.
25758 */
25759 movw (%rsi), %r11w
25760 - movw -2(%rsi, %rdx), %r10w
25761 + movw -2(%rsi, %rdx), %r9w
25762 movw %r11w, (%rdi)
25763 - movw %r10w, -2(%rdi, %rdx)
25764 + movw %r9w, -2(%rdi, %rdx)
25765 jmp 13f
25766 12:
25767 cmp $1, %rdx
25768 @@ -202,6 +202,7 @@ ENTRY(memmove)
25769 movb (%rsi), %r11b
25770 movb %r11b, (%rdi)
25771 13:
25772 + pax_force_retaddr
25773 retq
25774 CFI_ENDPROC
25775
25776 @@ -210,6 +211,7 @@ ENTRY(memmove)
25777 /* Forward moving data. */
25778 movq %rdx, %rcx
25779 rep movsb
25780 + pax_force_retaddr
25781 retq
25782 .Lmemmove_end_forward_efs:
25783 .previous
25784 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25785 index 2dcb380..963660a 100644
25786 --- a/arch/x86/lib/memset_64.S
25787 +++ b/arch/x86/lib/memset_64.S
25788 @@ -30,6 +30,7 @@
25789 movl %edx,%ecx
25790 rep stosb
25791 movq %r9,%rax
25792 + pax_force_retaddr
25793 ret
25794 .Lmemset_e:
25795 .previous
25796 @@ -52,6 +53,7 @@
25797 movq %rdx,%rcx
25798 rep stosb
25799 movq %r9,%rax
25800 + pax_force_retaddr
25801 ret
25802 .Lmemset_e_e:
25803 .previous
25804 @@ -59,7 +61,7 @@
25805 ENTRY(memset)
25806 ENTRY(__memset)
25807 CFI_STARTPROC
25808 - movq %rdi,%r10
25809 + movq %rdi,%r11
25810
25811 /* expand byte value */
25812 movzbl %sil,%ecx
25813 @@ -117,7 +119,8 @@ ENTRY(__memset)
25814 jnz .Lloop_1
25815
25816 .Lende:
25817 - movq %r10,%rax
25818 + movq %r11,%rax
25819 + pax_force_retaddr
25820 ret
25821
25822 CFI_RESTORE_STATE
25823 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25824 index c9f2d9b..e7fd2c0 100644
25825 --- a/arch/x86/lib/mmx_32.c
25826 +++ b/arch/x86/lib/mmx_32.c
25827 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25828 {
25829 void *p;
25830 int i;
25831 + unsigned long cr0;
25832
25833 if (unlikely(in_interrupt()))
25834 return __memcpy(to, from, len);
25835 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25836 kernel_fpu_begin();
25837
25838 __asm__ __volatile__ (
25839 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25840 - " prefetch 64(%0)\n"
25841 - " prefetch 128(%0)\n"
25842 - " prefetch 192(%0)\n"
25843 - " prefetch 256(%0)\n"
25844 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25845 + " prefetch 64(%1)\n"
25846 + " prefetch 128(%1)\n"
25847 + " prefetch 192(%1)\n"
25848 + " prefetch 256(%1)\n"
25849 "2: \n"
25850 ".section .fixup, \"ax\"\n"
25851 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25852 + "3: \n"
25853 +
25854 +#ifdef CONFIG_PAX_KERNEXEC
25855 + " movl %%cr0, %0\n"
25856 + " movl %0, %%eax\n"
25857 + " andl $0xFFFEFFFF, %%eax\n"
25858 + " movl %%eax, %%cr0\n"
25859 +#endif
25860 +
25861 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25862 +
25863 +#ifdef CONFIG_PAX_KERNEXEC
25864 + " movl %0, %%cr0\n"
25865 +#endif
25866 +
25867 " jmp 2b\n"
25868 ".previous\n"
25869 _ASM_EXTABLE(1b, 3b)
25870 - : : "r" (from));
25871 + : "=&r" (cr0) : "r" (from) : "ax");
25872
25873 for ( ; i > 5; i--) {
25874 __asm__ __volatile__ (
25875 - "1: prefetch 320(%0)\n"
25876 - "2: movq (%0), %%mm0\n"
25877 - " movq 8(%0), %%mm1\n"
25878 - " movq 16(%0), %%mm2\n"
25879 - " movq 24(%0), %%mm3\n"
25880 - " movq %%mm0, (%1)\n"
25881 - " movq %%mm1, 8(%1)\n"
25882 - " movq %%mm2, 16(%1)\n"
25883 - " movq %%mm3, 24(%1)\n"
25884 - " movq 32(%0), %%mm0\n"
25885 - " movq 40(%0), %%mm1\n"
25886 - " movq 48(%0), %%mm2\n"
25887 - " movq 56(%0), %%mm3\n"
25888 - " movq %%mm0, 32(%1)\n"
25889 - " movq %%mm1, 40(%1)\n"
25890 - " movq %%mm2, 48(%1)\n"
25891 - " movq %%mm3, 56(%1)\n"
25892 + "1: prefetch 320(%1)\n"
25893 + "2: movq (%1), %%mm0\n"
25894 + " movq 8(%1), %%mm1\n"
25895 + " movq 16(%1), %%mm2\n"
25896 + " movq 24(%1), %%mm3\n"
25897 + " movq %%mm0, (%2)\n"
25898 + " movq %%mm1, 8(%2)\n"
25899 + " movq %%mm2, 16(%2)\n"
25900 + " movq %%mm3, 24(%2)\n"
25901 + " movq 32(%1), %%mm0\n"
25902 + " movq 40(%1), %%mm1\n"
25903 + " movq 48(%1), %%mm2\n"
25904 + " movq 56(%1), %%mm3\n"
25905 + " movq %%mm0, 32(%2)\n"
25906 + " movq %%mm1, 40(%2)\n"
25907 + " movq %%mm2, 48(%2)\n"
25908 + " movq %%mm3, 56(%2)\n"
25909 ".section .fixup, \"ax\"\n"
25910 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25911 + "3:\n"
25912 +
25913 +#ifdef CONFIG_PAX_KERNEXEC
25914 + " movl %%cr0, %0\n"
25915 + " movl %0, %%eax\n"
25916 + " andl $0xFFFEFFFF, %%eax\n"
25917 + " movl %%eax, %%cr0\n"
25918 +#endif
25919 +
25920 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25921 +
25922 +#ifdef CONFIG_PAX_KERNEXEC
25923 + " movl %0, %%cr0\n"
25924 +#endif
25925 +
25926 " jmp 2b\n"
25927 ".previous\n"
25928 _ASM_EXTABLE(1b, 3b)
25929 - : : "r" (from), "r" (to) : "memory");
25930 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25931
25932 from += 64;
25933 to += 64;
25934 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25935 static void fast_copy_page(void *to, void *from)
25936 {
25937 int i;
25938 + unsigned long cr0;
25939
25940 kernel_fpu_begin();
25941
25942 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25943 * but that is for later. -AV
25944 */
25945 __asm__ __volatile__(
25946 - "1: prefetch (%0)\n"
25947 - " prefetch 64(%0)\n"
25948 - " prefetch 128(%0)\n"
25949 - " prefetch 192(%0)\n"
25950 - " prefetch 256(%0)\n"
25951 + "1: prefetch (%1)\n"
25952 + " prefetch 64(%1)\n"
25953 + " prefetch 128(%1)\n"
25954 + " prefetch 192(%1)\n"
25955 + " prefetch 256(%1)\n"
25956 "2: \n"
25957 ".section .fixup, \"ax\"\n"
25958 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25959 + "3: \n"
25960 +
25961 +#ifdef CONFIG_PAX_KERNEXEC
25962 + " movl %%cr0, %0\n"
25963 + " movl %0, %%eax\n"
25964 + " andl $0xFFFEFFFF, %%eax\n"
25965 + " movl %%eax, %%cr0\n"
25966 +#endif
25967 +
25968 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25969 +
25970 +#ifdef CONFIG_PAX_KERNEXEC
25971 + " movl %0, %%cr0\n"
25972 +#endif
25973 +
25974 " jmp 2b\n"
25975 ".previous\n"
25976 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25977 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25978
25979 for (i = 0; i < (4096-320)/64; i++) {
25980 __asm__ __volatile__ (
25981 - "1: prefetch 320(%0)\n"
25982 - "2: movq (%0), %%mm0\n"
25983 - " movntq %%mm0, (%1)\n"
25984 - " movq 8(%0), %%mm1\n"
25985 - " movntq %%mm1, 8(%1)\n"
25986 - " movq 16(%0), %%mm2\n"
25987 - " movntq %%mm2, 16(%1)\n"
25988 - " movq 24(%0), %%mm3\n"
25989 - " movntq %%mm3, 24(%1)\n"
25990 - " movq 32(%0), %%mm4\n"
25991 - " movntq %%mm4, 32(%1)\n"
25992 - " movq 40(%0), %%mm5\n"
25993 - " movntq %%mm5, 40(%1)\n"
25994 - " movq 48(%0), %%mm6\n"
25995 - " movntq %%mm6, 48(%1)\n"
25996 - " movq 56(%0), %%mm7\n"
25997 - " movntq %%mm7, 56(%1)\n"
25998 + "1: prefetch 320(%1)\n"
25999 + "2: movq (%1), %%mm0\n"
26000 + " movntq %%mm0, (%2)\n"
26001 + " movq 8(%1), %%mm1\n"
26002 + " movntq %%mm1, 8(%2)\n"
26003 + " movq 16(%1), %%mm2\n"
26004 + " movntq %%mm2, 16(%2)\n"
26005 + " movq 24(%1), %%mm3\n"
26006 + " movntq %%mm3, 24(%2)\n"
26007 + " movq 32(%1), %%mm4\n"
26008 + " movntq %%mm4, 32(%2)\n"
26009 + " movq 40(%1), %%mm5\n"
26010 + " movntq %%mm5, 40(%2)\n"
26011 + " movq 48(%1), %%mm6\n"
26012 + " movntq %%mm6, 48(%2)\n"
26013 + " movq 56(%1), %%mm7\n"
26014 + " movntq %%mm7, 56(%2)\n"
26015 ".section .fixup, \"ax\"\n"
26016 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26017 + "3:\n"
26018 +
26019 +#ifdef CONFIG_PAX_KERNEXEC
26020 + " movl %%cr0, %0\n"
26021 + " movl %0, %%eax\n"
26022 + " andl $0xFFFEFFFF, %%eax\n"
26023 + " movl %%eax, %%cr0\n"
26024 +#endif
26025 +
26026 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26027 +
26028 +#ifdef CONFIG_PAX_KERNEXEC
26029 + " movl %0, %%cr0\n"
26030 +#endif
26031 +
26032 " jmp 2b\n"
26033 ".previous\n"
26034 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26035 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26036
26037 from += 64;
26038 to += 64;
26039 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26040 static void fast_copy_page(void *to, void *from)
26041 {
26042 int i;
26043 + unsigned long cr0;
26044
26045 kernel_fpu_begin();
26046
26047 __asm__ __volatile__ (
26048 - "1: prefetch (%0)\n"
26049 - " prefetch 64(%0)\n"
26050 - " prefetch 128(%0)\n"
26051 - " prefetch 192(%0)\n"
26052 - " prefetch 256(%0)\n"
26053 + "1: prefetch (%1)\n"
26054 + " prefetch 64(%1)\n"
26055 + " prefetch 128(%1)\n"
26056 + " prefetch 192(%1)\n"
26057 + " prefetch 256(%1)\n"
26058 "2: \n"
26059 ".section .fixup, \"ax\"\n"
26060 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26061 + "3: \n"
26062 +
26063 +#ifdef CONFIG_PAX_KERNEXEC
26064 + " movl %%cr0, %0\n"
26065 + " movl %0, %%eax\n"
26066 + " andl $0xFFFEFFFF, %%eax\n"
26067 + " movl %%eax, %%cr0\n"
26068 +#endif
26069 +
26070 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26071 +
26072 +#ifdef CONFIG_PAX_KERNEXEC
26073 + " movl %0, %%cr0\n"
26074 +#endif
26075 +
26076 " jmp 2b\n"
26077 ".previous\n"
26078 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26079 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26080
26081 for (i = 0; i < 4096/64; i++) {
26082 __asm__ __volatile__ (
26083 - "1: prefetch 320(%0)\n"
26084 - "2: movq (%0), %%mm0\n"
26085 - " movq 8(%0), %%mm1\n"
26086 - " movq 16(%0), %%mm2\n"
26087 - " movq 24(%0), %%mm3\n"
26088 - " movq %%mm0, (%1)\n"
26089 - " movq %%mm1, 8(%1)\n"
26090 - " movq %%mm2, 16(%1)\n"
26091 - " movq %%mm3, 24(%1)\n"
26092 - " movq 32(%0), %%mm0\n"
26093 - " movq 40(%0), %%mm1\n"
26094 - " movq 48(%0), %%mm2\n"
26095 - " movq 56(%0), %%mm3\n"
26096 - " movq %%mm0, 32(%1)\n"
26097 - " movq %%mm1, 40(%1)\n"
26098 - " movq %%mm2, 48(%1)\n"
26099 - " movq %%mm3, 56(%1)\n"
26100 + "1: prefetch 320(%1)\n"
26101 + "2: movq (%1), %%mm0\n"
26102 + " movq 8(%1), %%mm1\n"
26103 + " movq 16(%1), %%mm2\n"
26104 + " movq 24(%1), %%mm3\n"
26105 + " movq %%mm0, (%2)\n"
26106 + " movq %%mm1, 8(%2)\n"
26107 + " movq %%mm2, 16(%2)\n"
26108 + " movq %%mm3, 24(%2)\n"
26109 + " movq 32(%1), %%mm0\n"
26110 + " movq 40(%1), %%mm1\n"
26111 + " movq 48(%1), %%mm2\n"
26112 + " movq 56(%1), %%mm3\n"
26113 + " movq %%mm0, 32(%2)\n"
26114 + " movq %%mm1, 40(%2)\n"
26115 + " movq %%mm2, 48(%2)\n"
26116 + " movq %%mm3, 56(%2)\n"
26117 ".section .fixup, \"ax\"\n"
26118 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26119 + "3:\n"
26120 +
26121 +#ifdef CONFIG_PAX_KERNEXEC
26122 + " movl %%cr0, %0\n"
26123 + " movl %0, %%eax\n"
26124 + " andl $0xFFFEFFFF, %%eax\n"
26125 + " movl %%eax, %%cr0\n"
26126 +#endif
26127 +
26128 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26129 +
26130 +#ifdef CONFIG_PAX_KERNEXEC
26131 + " movl %0, %%cr0\n"
26132 +#endif
26133 +
26134 " jmp 2b\n"
26135 ".previous\n"
26136 _ASM_EXTABLE(1b, 3b)
26137 - : : "r" (from), "r" (to) : "memory");
26138 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26139
26140 from += 64;
26141 to += 64;
26142 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26143 index f6d13ee..aca5f0b 100644
26144 --- a/arch/x86/lib/msr-reg.S
26145 +++ b/arch/x86/lib/msr-reg.S
26146 @@ -3,6 +3,7 @@
26147 #include <asm/dwarf2.h>
26148 #include <asm/asm.h>
26149 #include <asm/msr.h>
26150 +#include <asm/alternative-asm.h>
26151
26152 #ifdef CONFIG_X86_64
26153 /*
26154 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26155 CFI_STARTPROC
26156 pushq_cfi %rbx
26157 pushq_cfi %rbp
26158 - movq %rdi, %r10 /* Save pointer */
26159 + movq %rdi, %r9 /* Save pointer */
26160 xorl %r11d, %r11d /* Return value */
26161 movl (%rdi), %eax
26162 movl 4(%rdi), %ecx
26163 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26164 movl 28(%rdi), %edi
26165 CFI_REMEMBER_STATE
26166 1: \op
26167 -2: movl %eax, (%r10)
26168 +2: movl %eax, (%r9)
26169 movl %r11d, %eax /* Return value */
26170 - movl %ecx, 4(%r10)
26171 - movl %edx, 8(%r10)
26172 - movl %ebx, 12(%r10)
26173 - movl %ebp, 20(%r10)
26174 - movl %esi, 24(%r10)
26175 - movl %edi, 28(%r10)
26176 + movl %ecx, 4(%r9)
26177 + movl %edx, 8(%r9)
26178 + movl %ebx, 12(%r9)
26179 + movl %ebp, 20(%r9)
26180 + movl %esi, 24(%r9)
26181 + movl %edi, 28(%r9)
26182 popq_cfi %rbp
26183 popq_cfi %rbx
26184 + pax_force_retaddr
26185 ret
26186 3:
26187 CFI_RESTORE_STATE
26188 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26189 index fc6ba17..d4d989d 100644
26190 --- a/arch/x86/lib/putuser.S
26191 +++ b/arch/x86/lib/putuser.S
26192 @@ -16,7 +16,9 @@
26193 #include <asm/errno.h>
26194 #include <asm/asm.h>
26195 #include <asm/smap.h>
26196 -
26197 +#include <asm/segment.h>
26198 +#include <asm/pgtable.h>
26199 +#include <asm/alternative-asm.h>
26200
26201 /*
26202 * __put_user_X
26203 @@ -30,57 +32,125 @@
26204 * as they get called from within inline assembly.
26205 */
26206
26207 -#define ENTER CFI_STARTPROC ; \
26208 - GET_THREAD_INFO(%_ASM_BX)
26209 -#define EXIT ASM_CLAC ; \
26210 - ret ; \
26211 +#define ENTER CFI_STARTPROC
26212 +#define EXIT ASM_CLAC ; \
26213 + pax_force_retaddr ; \
26214 + ret ; \
26215 CFI_ENDPROC
26216
26217 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26218 +#define _DEST %_ASM_CX,%_ASM_BX
26219 +#else
26220 +#define _DEST %_ASM_CX
26221 +#endif
26222 +
26223 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26224 +#define __copyuser_seg gs;
26225 +#else
26226 +#define __copyuser_seg
26227 +#endif
26228 +
26229 .text
26230 ENTRY(__put_user_1)
26231 ENTER
26232 +
26233 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26234 + GET_THREAD_INFO(%_ASM_BX)
26235 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26236 jae bad_put_user
26237 ASM_STAC
26238 -1: movb %al,(%_ASM_CX)
26239 +
26240 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26241 + mov pax_user_shadow_base,%_ASM_BX
26242 + cmp %_ASM_BX,%_ASM_CX
26243 + jb 1234f
26244 + xor %ebx,%ebx
26245 +1234:
26246 +#endif
26247 +
26248 +#endif
26249 +
26250 +1: __copyuser_seg movb %al,(_DEST)
26251 xor %eax,%eax
26252 EXIT
26253 ENDPROC(__put_user_1)
26254
26255 ENTRY(__put_user_2)
26256 ENTER
26257 +
26258 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26259 + GET_THREAD_INFO(%_ASM_BX)
26260 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26261 sub $1,%_ASM_BX
26262 cmp %_ASM_BX,%_ASM_CX
26263 jae bad_put_user
26264 ASM_STAC
26265 -2: movw %ax,(%_ASM_CX)
26266 +
26267 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26268 + mov pax_user_shadow_base,%_ASM_BX
26269 + cmp %_ASM_BX,%_ASM_CX
26270 + jb 1234f
26271 + xor %ebx,%ebx
26272 +1234:
26273 +#endif
26274 +
26275 +#endif
26276 +
26277 +2: __copyuser_seg movw %ax,(_DEST)
26278 xor %eax,%eax
26279 EXIT
26280 ENDPROC(__put_user_2)
26281
26282 ENTRY(__put_user_4)
26283 ENTER
26284 +
26285 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26286 + GET_THREAD_INFO(%_ASM_BX)
26287 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26288 sub $3,%_ASM_BX
26289 cmp %_ASM_BX,%_ASM_CX
26290 jae bad_put_user
26291 ASM_STAC
26292 -3: movl %eax,(%_ASM_CX)
26293 +
26294 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26295 + mov pax_user_shadow_base,%_ASM_BX
26296 + cmp %_ASM_BX,%_ASM_CX
26297 + jb 1234f
26298 + xor %ebx,%ebx
26299 +1234:
26300 +#endif
26301 +
26302 +#endif
26303 +
26304 +3: __copyuser_seg movl %eax,(_DEST)
26305 xor %eax,%eax
26306 EXIT
26307 ENDPROC(__put_user_4)
26308
26309 ENTRY(__put_user_8)
26310 ENTER
26311 +
26312 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26313 + GET_THREAD_INFO(%_ASM_BX)
26314 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26315 sub $7,%_ASM_BX
26316 cmp %_ASM_BX,%_ASM_CX
26317 jae bad_put_user
26318 ASM_STAC
26319 -4: mov %_ASM_AX,(%_ASM_CX)
26320 +
26321 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26322 + mov pax_user_shadow_base,%_ASM_BX
26323 + cmp %_ASM_BX,%_ASM_CX
26324 + jb 1234f
26325 + xor %ebx,%ebx
26326 +1234:
26327 +#endif
26328 +
26329 +#endif
26330 +
26331 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26332 #ifdef CONFIG_X86_32
26333 -5: movl %edx,4(%_ASM_CX)
26334 +5: __copyuser_seg movl %edx,4(_DEST)
26335 #endif
26336 xor %eax,%eax
26337 EXIT
26338 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26339 index 1cad221..de671ee 100644
26340 --- a/arch/x86/lib/rwlock.S
26341 +++ b/arch/x86/lib/rwlock.S
26342 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26343 FRAME
26344 0: LOCK_PREFIX
26345 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26346 +
26347 +#ifdef CONFIG_PAX_REFCOUNT
26348 + jno 1234f
26349 + LOCK_PREFIX
26350 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26351 + int $4
26352 +1234:
26353 + _ASM_EXTABLE(1234b, 1234b)
26354 +#endif
26355 +
26356 1: rep; nop
26357 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26358 jne 1b
26359 LOCK_PREFIX
26360 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26361 +
26362 +#ifdef CONFIG_PAX_REFCOUNT
26363 + jno 1234f
26364 + LOCK_PREFIX
26365 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26366 + int $4
26367 +1234:
26368 + _ASM_EXTABLE(1234b, 1234b)
26369 +#endif
26370 +
26371 jnz 0b
26372 ENDFRAME
26373 + pax_force_retaddr
26374 ret
26375 CFI_ENDPROC
26376 END(__write_lock_failed)
26377 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26378 FRAME
26379 0: LOCK_PREFIX
26380 READ_LOCK_SIZE(inc) (%__lock_ptr)
26381 +
26382 +#ifdef CONFIG_PAX_REFCOUNT
26383 + jno 1234f
26384 + LOCK_PREFIX
26385 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26386 + int $4
26387 +1234:
26388 + _ASM_EXTABLE(1234b, 1234b)
26389 +#endif
26390 +
26391 1: rep; nop
26392 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26393 js 1b
26394 LOCK_PREFIX
26395 READ_LOCK_SIZE(dec) (%__lock_ptr)
26396 +
26397 +#ifdef CONFIG_PAX_REFCOUNT
26398 + jno 1234f
26399 + LOCK_PREFIX
26400 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26401 + int $4
26402 +1234:
26403 + _ASM_EXTABLE(1234b, 1234b)
26404 +#endif
26405 +
26406 js 0b
26407 ENDFRAME
26408 + pax_force_retaddr
26409 ret
26410 CFI_ENDPROC
26411 END(__read_lock_failed)
26412 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26413 index 5dff5f0..cadebf4 100644
26414 --- a/arch/x86/lib/rwsem.S
26415 +++ b/arch/x86/lib/rwsem.S
26416 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26417 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26418 CFI_RESTORE __ASM_REG(dx)
26419 restore_common_regs
26420 + pax_force_retaddr
26421 ret
26422 CFI_ENDPROC
26423 ENDPROC(call_rwsem_down_read_failed)
26424 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26425 movq %rax,%rdi
26426 call rwsem_down_write_failed
26427 restore_common_regs
26428 + pax_force_retaddr
26429 ret
26430 CFI_ENDPROC
26431 ENDPROC(call_rwsem_down_write_failed)
26432 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26433 movq %rax,%rdi
26434 call rwsem_wake
26435 restore_common_regs
26436 -1: ret
26437 +1: pax_force_retaddr
26438 + ret
26439 CFI_ENDPROC
26440 ENDPROC(call_rwsem_wake)
26441
26442 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26443 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26444 CFI_RESTORE __ASM_REG(dx)
26445 restore_common_regs
26446 + pax_force_retaddr
26447 ret
26448 CFI_ENDPROC
26449 ENDPROC(call_rwsem_downgrade_wake)
26450 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26451 index a63efd6..ccecad8 100644
26452 --- a/arch/x86/lib/thunk_64.S
26453 +++ b/arch/x86/lib/thunk_64.S
26454 @@ -8,6 +8,7 @@
26455 #include <linux/linkage.h>
26456 #include <asm/dwarf2.h>
26457 #include <asm/calling.h>
26458 +#include <asm/alternative-asm.h>
26459
26460 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26461 .macro THUNK name, func, put_ret_addr_in_rdi=0
26462 @@ -41,5 +42,6 @@
26463 SAVE_ARGS
26464 restore:
26465 RESTORE_ARGS
26466 + pax_force_retaddr
26467 ret
26468 CFI_ENDPROC
26469 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26470 index f0312d7..9c39d63 100644
26471 --- a/arch/x86/lib/usercopy_32.c
26472 +++ b/arch/x86/lib/usercopy_32.c
26473 @@ -42,11 +42,13 @@ do { \
26474 int __d0; \
26475 might_fault(); \
26476 __asm__ __volatile__( \
26477 + __COPYUSER_SET_ES \
26478 ASM_STAC "\n" \
26479 "0: rep; stosl\n" \
26480 " movl %2,%0\n" \
26481 "1: rep; stosb\n" \
26482 "2: " ASM_CLAC "\n" \
26483 + __COPYUSER_RESTORE_ES \
26484 ".section .fixup,\"ax\"\n" \
26485 "3: lea 0(%2,%0,4),%0\n" \
26486 " jmp 2b\n" \
26487 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26488
26489 #ifdef CONFIG_X86_INTEL_USERCOPY
26490 static unsigned long
26491 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26492 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26493 {
26494 int d0, d1;
26495 __asm__ __volatile__(
26496 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26497 " .align 2,0x90\n"
26498 "3: movl 0(%4), %%eax\n"
26499 "4: movl 4(%4), %%edx\n"
26500 - "5: movl %%eax, 0(%3)\n"
26501 - "6: movl %%edx, 4(%3)\n"
26502 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26503 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26504 "7: movl 8(%4), %%eax\n"
26505 "8: movl 12(%4),%%edx\n"
26506 - "9: movl %%eax, 8(%3)\n"
26507 - "10: movl %%edx, 12(%3)\n"
26508 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26509 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26510 "11: movl 16(%4), %%eax\n"
26511 "12: movl 20(%4), %%edx\n"
26512 - "13: movl %%eax, 16(%3)\n"
26513 - "14: movl %%edx, 20(%3)\n"
26514 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26515 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26516 "15: movl 24(%4), %%eax\n"
26517 "16: movl 28(%4), %%edx\n"
26518 - "17: movl %%eax, 24(%3)\n"
26519 - "18: movl %%edx, 28(%3)\n"
26520 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26521 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26522 "19: movl 32(%4), %%eax\n"
26523 "20: movl 36(%4), %%edx\n"
26524 - "21: movl %%eax, 32(%3)\n"
26525 - "22: movl %%edx, 36(%3)\n"
26526 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26527 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26528 "23: movl 40(%4), %%eax\n"
26529 "24: movl 44(%4), %%edx\n"
26530 - "25: movl %%eax, 40(%3)\n"
26531 - "26: movl %%edx, 44(%3)\n"
26532 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26533 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26534 "27: movl 48(%4), %%eax\n"
26535 "28: movl 52(%4), %%edx\n"
26536 - "29: movl %%eax, 48(%3)\n"
26537 - "30: movl %%edx, 52(%3)\n"
26538 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26539 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26540 "31: movl 56(%4), %%eax\n"
26541 "32: movl 60(%4), %%edx\n"
26542 - "33: movl %%eax, 56(%3)\n"
26543 - "34: movl %%edx, 60(%3)\n"
26544 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26545 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26546 " addl $-64, %0\n"
26547 " addl $64, %4\n"
26548 " addl $64, %3\n"
26549 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26550 " shrl $2, %0\n"
26551 " andl $3, %%eax\n"
26552 " cld\n"
26553 + __COPYUSER_SET_ES
26554 "99: rep; movsl\n"
26555 "36: movl %%eax, %0\n"
26556 "37: rep; movsb\n"
26557 "100:\n"
26558 + __COPYUSER_RESTORE_ES
26559 ".section .fixup,\"ax\"\n"
26560 "101: lea 0(%%eax,%0,4),%0\n"
26561 " jmp 100b\n"
26562 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26563 }
26564
26565 static unsigned long
26566 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26567 +{
26568 + int d0, d1;
26569 + __asm__ __volatile__(
26570 + " .align 2,0x90\n"
26571 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26572 + " cmpl $67, %0\n"
26573 + " jbe 3f\n"
26574 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26575 + " .align 2,0x90\n"
26576 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26577 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26578 + "5: movl %%eax, 0(%3)\n"
26579 + "6: movl %%edx, 4(%3)\n"
26580 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26581 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26582 + "9: movl %%eax, 8(%3)\n"
26583 + "10: movl %%edx, 12(%3)\n"
26584 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26585 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26586 + "13: movl %%eax, 16(%3)\n"
26587 + "14: movl %%edx, 20(%3)\n"
26588 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26589 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26590 + "17: movl %%eax, 24(%3)\n"
26591 + "18: movl %%edx, 28(%3)\n"
26592 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26593 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26594 + "21: movl %%eax, 32(%3)\n"
26595 + "22: movl %%edx, 36(%3)\n"
26596 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26597 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26598 + "25: movl %%eax, 40(%3)\n"
26599 + "26: movl %%edx, 44(%3)\n"
26600 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26601 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26602 + "29: movl %%eax, 48(%3)\n"
26603 + "30: movl %%edx, 52(%3)\n"
26604 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26605 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26606 + "33: movl %%eax, 56(%3)\n"
26607 + "34: movl %%edx, 60(%3)\n"
26608 + " addl $-64, %0\n"
26609 + " addl $64, %4\n"
26610 + " addl $64, %3\n"
26611 + " cmpl $63, %0\n"
26612 + " ja 1b\n"
26613 + "35: movl %0, %%eax\n"
26614 + " shrl $2, %0\n"
26615 + " andl $3, %%eax\n"
26616 + " cld\n"
26617 + "99: rep; "__copyuser_seg" movsl\n"
26618 + "36: movl %%eax, %0\n"
26619 + "37: rep; "__copyuser_seg" movsb\n"
26620 + "100:\n"
26621 + ".section .fixup,\"ax\"\n"
26622 + "101: lea 0(%%eax,%0,4),%0\n"
26623 + " jmp 100b\n"
26624 + ".previous\n"
26625 + _ASM_EXTABLE(1b,100b)
26626 + _ASM_EXTABLE(2b,100b)
26627 + _ASM_EXTABLE(3b,100b)
26628 + _ASM_EXTABLE(4b,100b)
26629 + _ASM_EXTABLE(5b,100b)
26630 + _ASM_EXTABLE(6b,100b)
26631 + _ASM_EXTABLE(7b,100b)
26632 + _ASM_EXTABLE(8b,100b)
26633 + _ASM_EXTABLE(9b,100b)
26634 + _ASM_EXTABLE(10b,100b)
26635 + _ASM_EXTABLE(11b,100b)
26636 + _ASM_EXTABLE(12b,100b)
26637 + _ASM_EXTABLE(13b,100b)
26638 + _ASM_EXTABLE(14b,100b)
26639 + _ASM_EXTABLE(15b,100b)
26640 + _ASM_EXTABLE(16b,100b)
26641 + _ASM_EXTABLE(17b,100b)
26642 + _ASM_EXTABLE(18b,100b)
26643 + _ASM_EXTABLE(19b,100b)
26644 + _ASM_EXTABLE(20b,100b)
26645 + _ASM_EXTABLE(21b,100b)
26646 + _ASM_EXTABLE(22b,100b)
26647 + _ASM_EXTABLE(23b,100b)
26648 + _ASM_EXTABLE(24b,100b)
26649 + _ASM_EXTABLE(25b,100b)
26650 + _ASM_EXTABLE(26b,100b)
26651 + _ASM_EXTABLE(27b,100b)
26652 + _ASM_EXTABLE(28b,100b)
26653 + _ASM_EXTABLE(29b,100b)
26654 + _ASM_EXTABLE(30b,100b)
26655 + _ASM_EXTABLE(31b,100b)
26656 + _ASM_EXTABLE(32b,100b)
26657 + _ASM_EXTABLE(33b,100b)
26658 + _ASM_EXTABLE(34b,100b)
26659 + _ASM_EXTABLE(35b,100b)
26660 + _ASM_EXTABLE(36b,100b)
26661 + _ASM_EXTABLE(37b,100b)
26662 + _ASM_EXTABLE(99b,101b)
26663 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26664 + : "1"(to), "2"(from), "0"(size)
26665 + : "eax", "edx", "memory");
26666 + return size;
26667 +}
26668 +
26669 +static unsigned long __size_overflow(3)
26670 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26671 {
26672 int d0, d1;
26673 __asm__ __volatile__(
26674 " .align 2,0x90\n"
26675 - "0: movl 32(%4), %%eax\n"
26676 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26677 " cmpl $67, %0\n"
26678 " jbe 2f\n"
26679 - "1: movl 64(%4), %%eax\n"
26680 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26681 " .align 2,0x90\n"
26682 - "2: movl 0(%4), %%eax\n"
26683 - "21: movl 4(%4), %%edx\n"
26684 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26685 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26686 " movl %%eax, 0(%3)\n"
26687 " movl %%edx, 4(%3)\n"
26688 - "3: movl 8(%4), %%eax\n"
26689 - "31: movl 12(%4),%%edx\n"
26690 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26691 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26692 " movl %%eax, 8(%3)\n"
26693 " movl %%edx, 12(%3)\n"
26694 - "4: movl 16(%4), %%eax\n"
26695 - "41: movl 20(%4), %%edx\n"
26696 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26697 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26698 " movl %%eax, 16(%3)\n"
26699 " movl %%edx, 20(%3)\n"
26700 - "10: movl 24(%4), %%eax\n"
26701 - "51: movl 28(%4), %%edx\n"
26702 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26703 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26704 " movl %%eax, 24(%3)\n"
26705 " movl %%edx, 28(%3)\n"
26706 - "11: movl 32(%4), %%eax\n"
26707 - "61: movl 36(%4), %%edx\n"
26708 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26709 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26710 " movl %%eax, 32(%3)\n"
26711 " movl %%edx, 36(%3)\n"
26712 - "12: movl 40(%4), %%eax\n"
26713 - "71: movl 44(%4), %%edx\n"
26714 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26715 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26716 " movl %%eax, 40(%3)\n"
26717 " movl %%edx, 44(%3)\n"
26718 - "13: movl 48(%4), %%eax\n"
26719 - "81: movl 52(%4), %%edx\n"
26720 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26721 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26722 " movl %%eax, 48(%3)\n"
26723 " movl %%edx, 52(%3)\n"
26724 - "14: movl 56(%4), %%eax\n"
26725 - "91: movl 60(%4), %%edx\n"
26726 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26727 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26728 " movl %%eax, 56(%3)\n"
26729 " movl %%edx, 60(%3)\n"
26730 " addl $-64, %0\n"
26731 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26732 " shrl $2, %0\n"
26733 " andl $3, %%eax\n"
26734 " cld\n"
26735 - "6: rep; movsl\n"
26736 + "6: rep; "__copyuser_seg" movsl\n"
26737 " movl %%eax,%0\n"
26738 - "7: rep; movsb\n"
26739 + "7: rep; "__copyuser_seg" movsb\n"
26740 "8:\n"
26741 ".section .fixup,\"ax\"\n"
26742 "9: lea 0(%%eax,%0,4),%0\n"
26743 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26744 * hyoshiok@miraclelinux.com
26745 */
26746
26747 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26748 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26749 const void __user *from, unsigned long size)
26750 {
26751 int d0, d1;
26752
26753 __asm__ __volatile__(
26754 " .align 2,0x90\n"
26755 - "0: movl 32(%4), %%eax\n"
26756 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26757 " cmpl $67, %0\n"
26758 " jbe 2f\n"
26759 - "1: movl 64(%4), %%eax\n"
26760 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26761 " .align 2,0x90\n"
26762 - "2: movl 0(%4), %%eax\n"
26763 - "21: movl 4(%4), %%edx\n"
26764 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26765 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26766 " movnti %%eax, 0(%3)\n"
26767 " movnti %%edx, 4(%3)\n"
26768 - "3: movl 8(%4), %%eax\n"
26769 - "31: movl 12(%4),%%edx\n"
26770 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26771 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26772 " movnti %%eax, 8(%3)\n"
26773 " movnti %%edx, 12(%3)\n"
26774 - "4: movl 16(%4), %%eax\n"
26775 - "41: movl 20(%4), %%edx\n"
26776 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26777 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26778 " movnti %%eax, 16(%3)\n"
26779 " movnti %%edx, 20(%3)\n"
26780 - "10: movl 24(%4), %%eax\n"
26781 - "51: movl 28(%4), %%edx\n"
26782 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26783 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26784 " movnti %%eax, 24(%3)\n"
26785 " movnti %%edx, 28(%3)\n"
26786 - "11: movl 32(%4), %%eax\n"
26787 - "61: movl 36(%4), %%edx\n"
26788 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26789 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26790 " movnti %%eax, 32(%3)\n"
26791 " movnti %%edx, 36(%3)\n"
26792 - "12: movl 40(%4), %%eax\n"
26793 - "71: movl 44(%4), %%edx\n"
26794 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26795 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26796 " movnti %%eax, 40(%3)\n"
26797 " movnti %%edx, 44(%3)\n"
26798 - "13: movl 48(%4), %%eax\n"
26799 - "81: movl 52(%4), %%edx\n"
26800 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26801 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26802 " movnti %%eax, 48(%3)\n"
26803 " movnti %%edx, 52(%3)\n"
26804 - "14: movl 56(%4), %%eax\n"
26805 - "91: movl 60(%4), %%edx\n"
26806 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26807 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26808 " movnti %%eax, 56(%3)\n"
26809 " movnti %%edx, 60(%3)\n"
26810 " addl $-64, %0\n"
26811 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26812 " shrl $2, %0\n"
26813 " andl $3, %%eax\n"
26814 " cld\n"
26815 - "6: rep; movsl\n"
26816 + "6: rep; "__copyuser_seg" movsl\n"
26817 " movl %%eax,%0\n"
26818 - "7: rep; movsb\n"
26819 + "7: rep; "__copyuser_seg" movsb\n"
26820 "8:\n"
26821 ".section .fixup,\"ax\"\n"
26822 "9: lea 0(%%eax,%0,4),%0\n"
26823 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26824 return size;
26825 }
26826
26827 -static unsigned long __copy_user_intel_nocache(void *to,
26828 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26829 const void __user *from, unsigned long size)
26830 {
26831 int d0, d1;
26832
26833 __asm__ __volatile__(
26834 " .align 2,0x90\n"
26835 - "0: movl 32(%4), %%eax\n"
26836 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26837 " cmpl $67, %0\n"
26838 " jbe 2f\n"
26839 - "1: movl 64(%4), %%eax\n"
26840 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26841 " .align 2,0x90\n"
26842 - "2: movl 0(%4), %%eax\n"
26843 - "21: movl 4(%4), %%edx\n"
26844 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26845 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26846 " movnti %%eax, 0(%3)\n"
26847 " movnti %%edx, 4(%3)\n"
26848 - "3: movl 8(%4), %%eax\n"
26849 - "31: movl 12(%4),%%edx\n"
26850 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26851 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26852 " movnti %%eax, 8(%3)\n"
26853 " movnti %%edx, 12(%3)\n"
26854 - "4: movl 16(%4), %%eax\n"
26855 - "41: movl 20(%4), %%edx\n"
26856 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26857 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26858 " movnti %%eax, 16(%3)\n"
26859 " movnti %%edx, 20(%3)\n"
26860 - "10: movl 24(%4), %%eax\n"
26861 - "51: movl 28(%4), %%edx\n"
26862 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26863 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26864 " movnti %%eax, 24(%3)\n"
26865 " movnti %%edx, 28(%3)\n"
26866 - "11: movl 32(%4), %%eax\n"
26867 - "61: movl 36(%4), %%edx\n"
26868 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26869 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26870 " movnti %%eax, 32(%3)\n"
26871 " movnti %%edx, 36(%3)\n"
26872 - "12: movl 40(%4), %%eax\n"
26873 - "71: movl 44(%4), %%edx\n"
26874 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26875 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26876 " movnti %%eax, 40(%3)\n"
26877 " movnti %%edx, 44(%3)\n"
26878 - "13: movl 48(%4), %%eax\n"
26879 - "81: movl 52(%4), %%edx\n"
26880 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26881 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26882 " movnti %%eax, 48(%3)\n"
26883 " movnti %%edx, 52(%3)\n"
26884 - "14: movl 56(%4), %%eax\n"
26885 - "91: movl 60(%4), %%edx\n"
26886 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26887 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26888 " movnti %%eax, 56(%3)\n"
26889 " movnti %%edx, 60(%3)\n"
26890 " addl $-64, %0\n"
26891 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26892 " shrl $2, %0\n"
26893 " andl $3, %%eax\n"
26894 " cld\n"
26895 - "6: rep; movsl\n"
26896 + "6: rep; "__copyuser_seg" movsl\n"
26897 " movl %%eax,%0\n"
26898 - "7: rep; movsb\n"
26899 + "7: rep; "__copyuser_seg" movsb\n"
26900 "8:\n"
26901 ".section .fixup,\"ax\"\n"
26902 "9: lea 0(%%eax,%0,4),%0\n"
26903 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26904 */
26905 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26906 unsigned long size);
26907 -unsigned long __copy_user_intel(void __user *to, const void *from,
26908 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26909 + unsigned long size);
26910 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26911 unsigned long size);
26912 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26913 const void __user *from, unsigned long size);
26914 #endif /* CONFIG_X86_INTEL_USERCOPY */
26915
26916 /* Generic arbitrary sized copy. */
26917 -#define __copy_user(to, from, size) \
26918 +#define __copy_user(to, from, size, prefix, set, restore) \
26919 do { \
26920 int __d0, __d1, __d2; \
26921 __asm__ __volatile__( \
26922 + set \
26923 " cmp $7,%0\n" \
26924 " jbe 1f\n" \
26925 " movl %1,%0\n" \
26926 " negl %0\n" \
26927 " andl $7,%0\n" \
26928 " subl %0,%3\n" \
26929 - "4: rep; movsb\n" \
26930 + "4: rep; "prefix"movsb\n" \
26931 " movl %3,%0\n" \
26932 " shrl $2,%0\n" \
26933 " andl $3,%3\n" \
26934 " .align 2,0x90\n" \
26935 - "0: rep; movsl\n" \
26936 + "0: rep; "prefix"movsl\n" \
26937 " movl %3,%0\n" \
26938 - "1: rep; movsb\n" \
26939 + "1: rep; "prefix"movsb\n" \
26940 "2:\n" \
26941 + restore \
26942 ".section .fixup,\"ax\"\n" \
26943 "5: addl %3,%0\n" \
26944 " jmp 2b\n" \
26945 @@ -538,14 +650,14 @@ do { \
26946 " negl %0\n" \
26947 " andl $7,%0\n" \
26948 " subl %0,%3\n" \
26949 - "4: rep; movsb\n" \
26950 + "4: rep; "__copyuser_seg"movsb\n" \
26951 " movl %3,%0\n" \
26952 " shrl $2,%0\n" \
26953 " andl $3,%3\n" \
26954 " .align 2,0x90\n" \
26955 - "0: rep; movsl\n" \
26956 + "0: rep; "__copyuser_seg"movsl\n" \
26957 " movl %3,%0\n" \
26958 - "1: rep; movsb\n" \
26959 + "1: rep; "__copyuser_seg"movsb\n" \
26960 "2:\n" \
26961 ".section .fixup,\"ax\"\n" \
26962 "5: addl %3,%0\n" \
26963 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26964 {
26965 stac();
26966 if (movsl_is_ok(to, from, n))
26967 - __copy_user(to, from, n);
26968 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26969 else
26970 - n = __copy_user_intel(to, from, n);
26971 + n = __generic_copy_to_user_intel(to, from, n);
26972 clac();
26973 return n;
26974 }
26975 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26976 {
26977 stac();
26978 if (movsl_is_ok(to, from, n))
26979 - __copy_user(to, from, n);
26980 + __copy_user(to, from, n, __copyuser_seg, "", "");
26981 else
26982 - n = __copy_user_intel((void __user *)to,
26983 - (const void *)from, n);
26984 + n = __generic_copy_from_user_intel(to, from, n);
26985 clac();
26986 return n;
26987 }
26988 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26989 if (n > 64 && cpu_has_xmm2)
26990 n = __copy_user_intel_nocache(to, from, n);
26991 else
26992 - __copy_user(to, from, n);
26993 + __copy_user(to, from, n, __copyuser_seg, "", "");
26994 #else
26995 - __copy_user(to, from, n);
26996 + __copy_user(to, from, n, __copyuser_seg, "", "");
26997 #endif
26998 clac();
26999 return n;
27000 }
27001 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27002
27003 -/**
27004 - * copy_to_user: - Copy a block of data into user space.
27005 - * @to: Destination address, in user space.
27006 - * @from: Source address, in kernel space.
27007 - * @n: Number of bytes to copy.
27008 - *
27009 - * Context: User context only. This function may sleep.
27010 - *
27011 - * Copy data from kernel space to user space.
27012 - *
27013 - * Returns number of bytes that could not be copied.
27014 - * On success, this will be zero.
27015 - */
27016 -unsigned long
27017 -copy_to_user(void __user *to, const void *from, unsigned long n)
27018 -{
27019 - if (access_ok(VERIFY_WRITE, to, n))
27020 - n = __copy_to_user(to, from, n);
27021 - return n;
27022 -}
27023 -EXPORT_SYMBOL(copy_to_user);
27024 -
27025 -/**
27026 - * copy_from_user: - Copy a block of data from user space.
27027 - * @to: Destination address, in kernel space.
27028 - * @from: Source address, in user space.
27029 - * @n: Number of bytes to copy.
27030 - *
27031 - * Context: User context only. This function may sleep.
27032 - *
27033 - * Copy data from user space to kernel space.
27034 - *
27035 - * Returns number of bytes that could not be copied.
27036 - * On success, this will be zero.
27037 - *
27038 - * If some data could not be copied, this function will pad the copied
27039 - * data to the requested size using zero bytes.
27040 - */
27041 -unsigned long
27042 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27043 -{
27044 - if (access_ok(VERIFY_READ, from, n))
27045 - n = __copy_from_user(to, from, n);
27046 - else
27047 - memset(to, 0, n);
27048 - return n;
27049 -}
27050 -EXPORT_SYMBOL(_copy_from_user);
27051 -
27052 void copy_from_user_overflow(void)
27053 {
27054 WARN(1, "Buffer overflow detected!\n");
27055 }
27056 EXPORT_SYMBOL(copy_from_user_overflow);
27057 +
27058 +void copy_to_user_overflow(void)
27059 +{
27060 + WARN(1, "Buffer overflow detected!\n");
27061 +}
27062 +EXPORT_SYMBOL(copy_to_user_overflow);
27063 +
27064 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27065 +void __set_fs(mm_segment_t x)
27066 +{
27067 + switch (x.seg) {
27068 + case 0:
27069 + loadsegment(gs, 0);
27070 + break;
27071 + case TASK_SIZE_MAX:
27072 + loadsegment(gs, __USER_DS);
27073 + break;
27074 + case -1UL:
27075 + loadsegment(gs, __KERNEL_DS);
27076 + break;
27077 + default:
27078 + BUG();
27079 + }
27080 + return;
27081 +}
27082 +EXPORT_SYMBOL(__set_fs);
27083 +
27084 +void set_fs(mm_segment_t x)
27085 +{
27086 + current_thread_info()->addr_limit = x;
27087 + __set_fs(x);
27088 +}
27089 +EXPORT_SYMBOL(set_fs);
27090 +#endif
27091 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27092 index 906fea3..ee8a097 100644
27093 --- a/arch/x86/lib/usercopy_64.c
27094 +++ b/arch/x86/lib/usercopy_64.c
27095 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27096 _ASM_EXTABLE(0b,3b)
27097 _ASM_EXTABLE(1b,2b)
27098 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27099 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27100 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27101 [zero] "r" (0UL), [eight] "r" (8UL));
27102 clac();
27103 return size;
27104 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27105 }
27106 EXPORT_SYMBOL(clear_user);
27107
27108 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27109 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27110 {
27111 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27112 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27113 - }
27114 - return len;
27115 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27116 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27117 + return len;
27118 }
27119 EXPORT_SYMBOL(copy_in_user);
27120
27121 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27122 * it is not necessary to optimize tail handling.
27123 */
27124 unsigned long
27125 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27126 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27127 {
27128 char c;
27129 unsigned zero_len;
27130 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27131 clac();
27132 return len;
27133 }
27134 +
27135 +void copy_from_user_overflow(void)
27136 +{
27137 + WARN(1, "Buffer overflow detected!\n");
27138 +}
27139 +EXPORT_SYMBOL(copy_from_user_overflow);
27140 +
27141 +void copy_to_user_overflow(void)
27142 +{
27143 + WARN(1, "Buffer overflow detected!\n");
27144 +}
27145 +EXPORT_SYMBOL(copy_to_user_overflow);
27146 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27147 index 903ec1e..c4166b2 100644
27148 --- a/arch/x86/mm/extable.c
27149 +++ b/arch/x86/mm/extable.c
27150 @@ -6,12 +6,24 @@
27151 static inline unsigned long
27152 ex_insn_addr(const struct exception_table_entry *x)
27153 {
27154 - return (unsigned long)&x->insn + x->insn;
27155 + unsigned long reloc = 0;
27156 +
27157 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27158 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27159 +#endif
27160 +
27161 + return (unsigned long)&x->insn + x->insn + reloc;
27162 }
27163 static inline unsigned long
27164 ex_fixup_addr(const struct exception_table_entry *x)
27165 {
27166 - return (unsigned long)&x->fixup + x->fixup;
27167 + unsigned long reloc = 0;
27168 +
27169 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27170 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27171 +#endif
27172 +
27173 + return (unsigned long)&x->fixup + x->fixup + reloc;
27174 }
27175
27176 int fixup_exception(struct pt_regs *regs)
27177 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27178 unsigned long new_ip;
27179
27180 #ifdef CONFIG_PNPBIOS
27181 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27182 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27183 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27184 extern u32 pnp_bios_is_utter_crap;
27185 pnp_bios_is_utter_crap = 1;
27186 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27187 i += 4;
27188 p->fixup -= i;
27189 i += 4;
27190 +
27191 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27192 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27193 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27194 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27195 +#endif
27196 +
27197 }
27198 }
27199
27200 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27201 index 0e88336..2bb9777 100644
27202 --- a/arch/x86/mm/fault.c
27203 +++ b/arch/x86/mm/fault.c
27204 @@ -13,12 +13,19 @@
27205 #include <linux/perf_event.h> /* perf_sw_event */
27206 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27207 #include <linux/prefetch.h> /* prefetchw */
27208 +#include <linux/unistd.h>
27209 +#include <linux/compiler.h>
27210
27211 #include <asm/traps.h> /* dotraplinkage, ... */
27212 #include <asm/pgalloc.h> /* pgd_*(), ... */
27213 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27214 #include <asm/fixmap.h> /* VSYSCALL_START */
27215 #include <asm/context_tracking.h> /* exception_enter(), ... */
27216 +#include <asm/tlbflush.h>
27217 +
27218 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27219 +#include <asm/stacktrace.h>
27220 +#endif
27221
27222 /*
27223 * Page fault error code bits:
27224 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27225 int ret = 0;
27226
27227 /* kprobe_running() needs smp_processor_id() */
27228 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27229 + if (kprobes_built_in() && !user_mode(regs)) {
27230 preempt_disable();
27231 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27232 ret = 1;
27233 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27234 return !instr_lo || (instr_lo>>1) == 1;
27235 case 0x00:
27236 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27237 - if (probe_kernel_address(instr, opcode))
27238 + if (user_mode(regs)) {
27239 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27240 + return 0;
27241 + } else if (probe_kernel_address(instr, opcode))
27242 return 0;
27243
27244 *prefetch = (instr_lo == 0xF) &&
27245 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27246 while (instr < max_instr) {
27247 unsigned char opcode;
27248
27249 - if (probe_kernel_address(instr, opcode))
27250 + if (user_mode(regs)) {
27251 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27252 + break;
27253 + } else if (probe_kernel_address(instr, opcode))
27254 break;
27255
27256 instr++;
27257 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27258 force_sig_info(si_signo, &info, tsk);
27259 }
27260
27261 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27262 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27263 +#endif
27264 +
27265 +#ifdef CONFIG_PAX_EMUTRAMP
27266 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27267 +#endif
27268 +
27269 +#ifdef CONFIG_PAX_PAGEEXEC
27270 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27271 +{
27272 + pgd_t *pgd;
27273 + pud_t *pud;
27274 + pmd_t *pmd;
27275 +
27276 + pgd = pgd_offset(mm, address);
27277 + if (!pgd_present(*pgd))
27278 + return NULL;
27279 + pud = pud_offset(pgd, address);
27280 + if (!pud_present(*pud))
27281 + return NULL;
27282 + pmd = pmd_offset(pud, address);
27283 + if (!pmd_present(*pmd))
27284 + return NULL;
27285 + return pmd;
27286 +}
27287 +#endif
27288 +
27289 DEFINE_SPINLOCK(pgd_lock);
27290 LIST_HEAD(pgd_list);
27291
27292 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27293 for (address = VMALLOC_START & PMD_MASK;
27294 address >= TASK_SIZE && address < FIXADDR_TOP;
27295 address += PMD_SIZE) {
27296 +
27297 +#ifdef CONFIG_PAX_PER_CPU_PGD
27298 + unsigned long cpu;
27299 +#else
27300 struct page *page;
27301 +#endif
27302
27303 spin_lock(&pgd_lock);
27304 +
27305 +#ifdef CONFIG_PAX_PER_CPU_PGD
27306 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27307 + pgd_t *pgd = get_cpu_pgd(cpu);
27308 + pmd_t *ret;
27309 +#else
27310 list_for_each_entry(page, &pgd_list, lru) {
27311 + pgd_t *pgd;
27312 spinlock_t *pgt_lock;
27313 pmd_t *ret;
27314
27315 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27316 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27317
27318 spin_lock(pgt_lock);
27319 - ret = vmalloc_sync_one(page_address(page), address);
27320 + pgd = page_address(page);
27321 +#endif
27322 +
27323 + ret = vmalloc_sync_one(pgd, address);
27324 +
27325 +#ifndef CONFIG_PAX_PER_CPU_PGD
27326 spin_unlock(pgt_lock);
27327 +#endif
27328
27329 if (!ret)
27330 break;
27331 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27332 * an interrupt in the middle of a task switch..
27333 */
27334 pgd_paddr = read_cr3();
27335 +
27336 +#ifdef CONFIG_PAX_PER_CPU_PGD
27337 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27338 +#endif
27339 +
27340 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27341 if (!pmd_k)
27342 return -1;
27343 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27344 * happen within a race in page table update. In the later
27345 * case just flush:
27346 */
27347 +
27348 +#ifdef CONFIG_PAX_PER_CPU_PGD
27349 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27350 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27351 +#else
27352 pgd = pgd_offset(current->active_mm, address);
27353 +#endif
27354 +
27355 pgd_ref = pgd_offset_k(address);
27356 if (pgd_none(*pgd_ref))
27357 return -1;
27358 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27359 static int is_errata100(struct pt_regs *regs, unsigned long address)
27360 {
27361 #ifdef CONFIG_X86_64
27362 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27363 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27364 return 1;
27365 #endif
27366 return 0;
27367 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27368 }
27369
27370 static const char nx_warning[] = KERN_CRIT
27371 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27372 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27373
27374 static void
27375 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27376 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27377 if (!oops_may_print())
27378 return;
27379
27380 - if (error_code & PF_INSTR) {
27381 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27382 unsigned int level;
27383
27384 pte_t *pte = lookup_address(address, &level);
27385
27386 if (pte && pte_present(*pte) && !pte_exec(*pte))
27387 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27388 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27389 }
27390
27391 +#ifdef CONFIG_PAX_KERNEXEC
27392 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27393 + if (current->signal->curr_ip)
27394 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27395 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27396 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27397 + else
27398 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27399 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27400 + }
27401 +#endif
27402 +
27403 printk(KERN_ALERT "BUG: unable to handle kernel ");
27404 if (address < PAGE_SIZE)
27405 printk(KERN_CONT "NULL pointer dereference");
27406 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27407 return;
27408 }
27409 #endif
27410 +
27411 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27412 + if (pax_is_fetch_fault(regs, error_code, address)) {
27413 +
27414 +#ifdef CONFIG_PAX_EMUTRAMP
27415 + switch (pax_handle_fetch_fault(regs)) {
27416 + case 2:
27417 + return;
27418 + }
27419 +#endif
27420 +
27421 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27422 + do_group_exit(SIGKILL);
27423 + }
27424 +#endif
27425 +
27426 /* Kernel addresses are always protection faults: */
27427 if (address >= TASK_SIZE)
27428 error_code |= PF_PROT;
27429 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27430 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27431 printk(KERN_ERR
27432 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27433 - tsk->comm, tsk->pid, address);
27434 + tsk->comm, task_pid_nr(tsk), address);
27435 code = BUS_MCEERR_AR;
27436 }
27437 #endif
27438 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27439 return 1;
27440 }
27441
27442 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27443 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27444 +{
27445 + pte_t *pte;
27446 + pmd_t *pmd;
27447 + spinlock_t *ptl;
27448 + unsigned char pte_mask;
27449 +
27450 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27451 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27452 + return 0;
27453 +
27454 + /* PaX: it's our fault, let's handle it if we can */
27455 +
27456 + /* PaX: take a look at read faults before acquiring any locks */
27457 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27458 + /* instruction fetch attempt from a protected page in user mode */
27459 + up_read(&mm->mmap_sem);
27460 +
27461 +#ifdef CONFIG_PAX_EMUTRAMP
27462 + switch (pax_handle_fetch_fault(regs)) {
27463 + case 2:
27464 + return 1;
27465 + }
27466 +#endif
27467 +
27468 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27469 + do_group_exit(SIGKILL);
27470 + }
27471 +
27472 + pmd = pax_get_pmd(mm, address);
27473 + if (unlikely(!pmd))
27474 + return 0;
27475 +
27476 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27477 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27478 + pte_unmap_unlock(pte, ptl);
27479 + return 0;
27480 + }
27481 +
27482 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27483 + /* write attempt to a protected page in user mode */
27484 + pte_unmap_unlock(pte, ptl);
27485 + return 0;
27486 + }
27487 +
27488 +#ifdef CONFIG_SMP
27489 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27490 +#else
27491 + if (likely(address > get_limit(regs->cs)))
27492 +#endif
27493 + {
27494 + set_pte(pte, pte_mkread(*pte));
27495 + __flush_tlb_one(address);
27496 + pte_unmap_unlock(pte, ptl);
27497 + up_read(&mm->mmap_sem);
27498 + return 1;
27499 + }
27500 +
27501 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27502 +
27503 + /*
27504 + * PaX: fill DTLB with user rights and retry
27505 + */
27506 + __asm__ __volatile__ (
27507 + "orb %2,(%1)\n"
27508 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27509 +/*
27510 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27511 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27512 + * page fault when examined during a TLB load attempt. this is true not only
27513 + * for PTEs holding a non-present entry but also present entries that will
27514 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27515 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27516 + * for our target pages since their PTEs are simply not in the TLBs at all.
27517 +
27518 + * the best thing in omitting it is that we gain around 15-20% speed in the
27519 + * fast path of the page fault handler and can get rid of tracing since we
27520 + * can no longer flush unintended entries.
27521 + */
27522 + "invlpg (%0)\n"
27523 +#endif
27524 + __copyuser_seg"testb $0,(%0)\n"
27525 + "xorb %3,(%1)\n"
27526 + :
27527 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27528 + : "memory", "cc");
27529 + pte_unmap_unlock(pte, ptl);
27530 + up_read(&mm->mmap_sem);
27531 + return 1;
27532 +}
27533 +#endif
27534 +
27535 /*
27536 * Handle a spurious fault caused by a stale TLB entry.
27537 *
27538 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27539 static inline int
27540 access_error(unsigned long error_code, struct vm_area_struct *vma)
27541 {
27542 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27543 + return 1;
27544 +
27545 if (error_code & PF_WRITE) {
27546 /* write, present and write, not present: */
27547 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27548 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27549 if (error_code & PF_USER)
27550 return false;
27551
27552 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27553 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27554 return false;
27555
27556 return true;
27557 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27558 {
27559 struct vm_area_struct *vma;
27560 struct task_struct *tsk;
27561 - unsigned long address;
27562 struct mm_struct *mm;
27563 int fault;
27564 int write = error_code & PF_WRITE;
27565 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27566 (write ? FAULT_FLAG_WRITE : 0);
27567
27568 - tsk = current;
27569 - mm = tsk->mm;
27570 -
27571 /* Get the faulting address: */
27572 - address = read_cr2();
27573 + unsigned long address = read_cr2();
27574 +
27575 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27576 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27577 + if (!search_exception_tables(regs->ip)) {
27578 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27579 + bad_area_nosemaphore(regs, error_code, address);
27580 + return;
27581 + }
27582 + if (address < pax_user_shadow_base) {
27583 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27584 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27585 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27586 + } else
27587 + address -= pax_user_shadow_base;
27588 + }
27589 +#endif
27590 +
27591 + tsk = current;
27592 + mm = tsk->mm;
27593
27594 /*
27595 * Detect and handle instructions that would cause a page fault for
27596 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27597 * User-mode registers count as a user access even for any
27598 * potential system fault or CPU buglet:
27599 */
27600 - if (user_mode_vm(regs)) {
27601 + if (user_mode(regs)) {
27602 local_irq_enable();
27603 error_code |= PF_USER;
27604 } else {
27605 @@ -1142,6 +1352,11 @@ retry:
27606 might_sleep();
27607 }
27608
27609 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27610 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27611 + return;
27612 +#endif
27613 +
27614 vma = find_vma(mm, address);
27615 if (unlikely(!vma)) {
27616 bad_area(regs, error_code, address);
27617 @@ -1153,18 +1368,24 @@ retry:
27618 bad_area(regs, error_code, address);
27619 return;
27620 }
27621 - if (error_code & PF_USER) {
27622 - /*
27623 - * Accessing the stack below %sp is always a bug.
27624 - * The large cushion allows instructions like enter
27625 - * and pusha to work. ("enter $65535, $31" pushes
27626 - * 32 pointers and then decrements %sp by 65535.)
27627 - */
27628 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27629 - bad_area(regs, error_code, address);
27630 - return;
27631 - }
27632 + /*
27633 + * Accessing the stack below %sp is always a bug.
27634 + * The large cushion allows instructions like enter
27635 + * and pusha to work. ("enter $65535, $31" pushes
27636 + * 32 pointers and then decrements %sp by 65535.)
27637 + */
27638 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27639 + bad_area(regs, error_code, address);
27640 + return;
27641 }
27642 +
27643 +#ifdef CONFIG_PAX_SEGMEXEC
27644 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27645 + bad_area(regs, error_code, address);
27646 + return;
27647 + }
27648 +#endif
27649 +
27650 if (unlikely(expand_stack(vma, address))) {
27651 bad_area(regs, error_code, address);
27652 return;
27653 @@ -1228,3 +1449,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27654 __do_page_fault(regs, error_code);
27655 exception_exit(regs);
27656 }
27657 +
27658 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27659 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27660 +{
27661 + struct mm_struct *mm = current->mm;
27662 + unsigned long ip = regs->ip;
27663 +
27664 + if (v8086_mode(regs))
27665 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27666 +
27667 +#ifdef CONFIG_PAX_PAGEEXEC
27668 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27669 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27670 + return true;
27671 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27672 + return true;
27673 + return false;
27674 + }
27675 +#endif
27676 +
27677 +#ifdef CONFIG_PAX_SEGMEXEC
27678 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27679 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27680 + return true;
27681 + return false;
27682 + }
27683 +#endif
27684 +
27685 + return false;
27686 +}
27687 +#endif
27688 +
27689 +#ifdef CONFIG_PAX_EMUTRAMP
27690 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27691 +{
27692 + int err;
27693 +
27694 + do { /* PaX: libffi trampoline emulation */
27695 + unsigned char mov, jmp;
27696 + unsigned int addr1, addr2;
27697 +
27698 +#ifdef CONFIG_X86_64
27699 + if ((regs->ip + 9) >> 32)
27700 + break;
27701 +#endif
27702 +
27703 + err = get_user(mov, (unsigned char __user *)regs->ip);
27704 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27705 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27706 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27707 +
27708 + if (err)
27709 + break;
27710 +
27711 + if (mov == 0xB8 && jmp == 0xE9) {
27712 + regs->ax = addr1;
27713 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27714 + return 2;
27715 + }
27716 + } while (0);
27717 +
27718 + do { /* PaX: gcc trampoline emulation #1 */
27719 + unsigned char mov1, mov2;
27720 + unsigned short jmp;
27721 + unsigned int addr1, addr2;
27722 +
27723 +#ifdef CONFIG_X86_64
27724 + if ((regs->ip + 11) >> 32)
27725 + break;
27726 +#endif
27727 +
27728 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27729 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27730 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27731 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27732 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27733 +
27734 + if (err)
27735 + break;
27736 +
27737 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27738 + regs->cx = addr1;
27739 + regs->ax = addr2;
27740 + regs->ip = addr2;
27741 + return 2;
27742 + }
27743 + } while (0);
27744 +
27745 + do { /* PaX: gcc trampoline emulation #2 */
27746 + unsigned char mov, jmp;
27747 + unsigned int addr1, addr2;
27748 +
27749 +#ifdef CONFIG_X86_64
27750 + if ((regs->ip + 9) >> 32)
27751 + break;
27752 +#endif
27753 +
27754 + err = get_user(mov, (unsigned char __user *)regs->ip);
27755 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27756 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27757 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27758 +
27759 + if (err)
27760 + break;
27761 +
27762 + if (mov == 0xB9 && jmp == 0xE9) {
27763 + regs->cx = addr1;
27764 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27765 + return 2;
27766 + }
27767 + } while (0);
27768 +
27769 + return 1; /* PaX in action */
27770 +}
27771 +
27772 +#ifdef CONFIG_X86_64
27773 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27774 +{
27775 + int err;
27776 +
27777 + do { /* PaX: libffi trampoline emulation */
27778 + unsigned short mov1, mov2, jmp1;
27779 + unsigned char stcclc, jmp2;
27780 + unsigned long addr1, addr2;
27781 +
27782 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27783 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27784 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27785 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27786 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27787 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27788 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27789 +
27790 + if (err)
27791 + break;
27792 +
27793 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27794 + regs->r11 = addr1;
27795 + regs->r10 = addr2;
27796 + if (stcclc == 0xF8)
27797 + regs->flags &= ~X86_EFLAGS_CF;
27798 + else
27799 + regs->flags |= X86_EFLAGS_CF;
27800 + regs->ip = addr1;
27801 + return 2;
27802 + }
27803 + } while (0);
27804 +
27805 + do { /* PaX: gcc trampoline emulation #1 */
27806 + unsigned short mov1, mov2, jmp1;
27807 + unsigned char jmp2;
27808 + unsigned int addr1;
27809 + unsigned long addr2;
27810 +
27811 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27812 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27813 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27814 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27815 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27816 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27817 +
27818 + if (err)
27819 + break;
27820 +
27821 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27822 + regs->r11 = addr1;
27823 + regs->r10 = addr2;
27824 + regs->ip = addr1;
27825 + return 2;
27826 + }
27827 + } while (0);
27828 +
27829 + do { /* PaX: gcc trampoline emulation #2 */
27830 + unsigned short mov1, mov2, jmp1;
27831 + unsigned char jmp2;
27832 + unsigned long addr1, addr2;
27833 +
27834 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27835 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27836 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27837 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27838 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27839 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27840 +
27841 + if (err)
27842 + break;
27843 +
27844 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27845 + regs->r11 = addr1;
27846 + regs->r10 = addr2;
27847 + regs->ip = addr1;
27848 + return 2;
27849 + }
27850 + } while (0);
27851 +
27852 + return 1; /* PaX in action */
27853 +}
27854 +#endif
27855 +
27856 +/*
27857 + * PaX: decide what to do with offenders (regs->ip = fault address)
27858 + *
27859 + * returns 1 when task should be killed
27860 + * 2 when gcc trampoline was detected
27861 + */
27862 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27863 +{
27864 + if (v8086_mode(regs))
27865 + return 1;
27866 +
27867 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27868 + return 1;
27869 +
27870 +#ifdef CONFIG_X86_32
27871 + return pax_handle_fetch_fault_32(regs);
27872 +#else
27873 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27874 + return pax_handle_fetch_fault_32(regs);
27875 + else
27876 + return pax_handle_fetch_fault_64(regs);
27877 +#endif
27878 +}
27879 +#endif
27880 +
27881 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27882 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27883 +{
27884 + long i;
27885 +
27886 + printk(KERN_ERR "PAX: bytes at PC: ");
27887 + for (i = 0; i < 20; i++) {
27888 + unsigned char c;
27889 + if (get_user(c, (unsigned char __force_user *)pc+i))
27890 + printk(KERN_CONT "?? ");
27891 + else
27892 + printk(KERN_CONT "%02x ", c);
27893 + }
27894 + printk("\n");
27895 +
27896 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27897 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27898 + unsigned long c;
27899 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27900 +#ifdef CONFIG_X86_32
27901 + printk(KERN_CONT "???????? ");
27902 +#else
27903 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27904 + printk(KERN_CONT "???????? ???????? ");
27905 + else
27906 + printk(KERN_CONT "???????????????? ");
27907 +#endif
27908 + } else {
27909 +#ifdef CONFIG_X86_64
27910 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27911 + printk(KERN_CONT "%08x ", (unsigned int)c);
27912 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27913 + } else
27914 +#endif
27915 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27916 + }
27917 + }
27918 + printk("\n");
27919 +}
27920 +#endif
27921 +
27922 +/**
27923 + * probe_kernel_write(): safely attempt to write to a location
27924 + * @dst: address to write to
27925 + * @src: pointer to the data that shall be written
27926 + * @size: size of the data chunk
27927 + *
27928 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27929 + * happens, handle that and return -EFAULT.
27930 + */
27931 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27932 +{
27933 + long ret;
27934 + mm_segment_t old_fs = get_fs();
27935 +
27936 + set_fs(KERNEL_DS);
27937 + pagefault_disable();
27938 + pax_open_kernel();
27939 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27940 + pax_close_kernel();
27941 + pagefault_enable();
27942 + set_fs(old_fs);
27943 +
27944 + return ret ? -EFAULT : 0;
27945 +}
27946 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27947 index dd74e46..7d26398 100644
27948 --- a/arch/x86/mm/gup.c
27949 +++ b/arch/x86/mm/gup.c
27950 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27951 addr = start;
27952 len = (unsigned long) nr_pages << PAGE_SHIFT;
27953 end = start + len;
27954 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27955 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27956 (void __user *)start, len)))
27957 return 0;
27958
27959 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27960 index 6f31ee5..8ee4164 100644
27961 --- a/arch/x86/mm/highmem_32.c
27962 +++ b/arch/x86/mm/highmem_32.c
27963 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27964 idx = type + KM_TYPE_NR*smp_processor_id();
27965 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27966 BUG_ON(!pte_none(*(kmap_pte-idx)));
27967 +
27968 + pax_open_kernel();
27969 set_pte(kmap_pte-idx, mk_pte(page, prot));
27970 + pax_close_kernel();
27971 +
27972 arch_flush_lazy_mmu_mode();
27973
27974 return (void *)vaddr;
27975 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27976 index ae1aa71..d9bea75 100644
27977 --- a/arch/x86/mm/hugetlbpage.c
27978 +++ b/arch/x86/mm/hugetlbpage.c
27979 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
27980 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
27981 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27982 unsigned long addr, unsigned long len,
27983 - unsigned long pgoff, unsigned long flags)
27984 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27985 {
27986 struct hstate *h = hstate_file(file);
27987 struct vm_unmapped_area_info info;
27988 -
27989 +
27990 info.flags = 0;
27991 info.length = len;
27992 info.low_limit = TASK_UNMAPPED_BASE;
27993 +
27994 +#ifdef CONFIG_PAX_RANDMMAP
27995 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27996 + info.low_limit += current->mm->delta_mmap;
27997 +#endif
27998 +
27999 info.high_limit = TASK_SIZE;
28000 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28001 info.align_offset = 0;
28002 + info.threadstack_offset = offset;
28003 return vm_unmapped_area(&info);
28004 }
28005
28006 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28007 unsigned long addr0, unsigned long len,
28008 - unsigned long pgoff, unsigned long flags)
28009 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28010 {
28011 struct hstate *h = hstate_file(file);
28012 struct vm_unmapped_area_info info;
28013 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28014 info.high_limit = current->mm->mmap_base;
28015 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28016 info.align_offset = 0;
28017 + info.threadstack_offset = offset;
28018 addr = vm_unmapped_area(&info);
28019
28020 /*
28021 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28022 VM_BUG_ON(addr != -ENOMEM);
28023 info.flags = 0;
28024 info.low_limit = TASK_UNMAPPED_BASE;
28025 +
28026 +#ifdef CONFIG_PAX_RANDMMAP
28027 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28028 + info.low_limit += current->mm->delta_mmap;
28029 +#endif
28030 +
28031 info.high_limit = TASK_SIZE;
28032 addr = vm_unmapped_area(&info);
28033 }
28034 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28035 struct hstate *h = hstate_file(file);
28036 struct mm_struct *mm = current->mm;
28037 struct vm_area_struct *vma;
28038 + unsigned long pax_task_size = TASK_SIZE;
28039 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28040
28041 if (len & ~huge_page_mask(h))
28042 return -EINVAL;
28043 - if (len > TASK_SIZE)
28044 +
28045 +#ifdef CONFIG_PAX_SEGMEXEC
28046 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28047 + pax_task_size = SEGMEXEC_TASK_SIZE;
28048 +#endif
28049 +
28050 + pax_task_size -= PAGE_SIZE;
28051 +
28052 + if (len > pax_task_size)
28053 return -ENOMEM;
28054
28055 if (flags & MAP_FIXED) {
28056 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28057 return addr;
28058 }
28059
28060 +#ifdef CONFIG_PAX_RANDMMAP
28061 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28062 +#endif
28063 +
28064 if (addr) {
28065 addr = ALIGN(addr, huge_page_size(h));
28066 vma = find_vma(mm, addr);
28067 - if (TASK_SIZE - len >= addr &&
28068 - (!vma || addr + len <= vma->vm_start))
28069 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28070 return addr;
28071 }
28072 if (mm->get_unmapped_area == arch_get_unmapped_area)
28073 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28074 - pgoff, flags);
28075 + pgoff, flags, offset);
28076 else
28077 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28078 - pgoff, flags);
28079 + pgoff, flags, offset);
28080 }
28081
28082 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28083 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28084 index 0c13708..689fe7f 100644
28085 --- a/arch/x86/mm/init.c
28086 +++ b/arch/x86/mm/init.c
28087 @@ -4,6 +4,7 @@
28088 #include <linux/swap.h>
28089 #include <linux/memblock.h>
28090 #include <linux/bootmem.h> /* for max_low_pfn */
28091 +#include <linux/tboot.h>
28092
28093 #include <asm/cacheflush.h>
28094 #include <asm/e820.h>
28095 @@ -17,6 +18,8 @@
28096 #include <asm/proto.h>
28097 #include <asm/dma.h> /* for MAX_DMA_PFN */
28098 #include <asm/microcode.h>
28099 +#include <asm/desc.h>
28100 +#include <asm/bios_ebda.h>
28101
28102 #include "mm_internal.h"
28103
28104 @@ -464,10 +467,40 @@ void __init init_mem_mapping(void)
28105 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28106 * mmio resources as well as potential bios/acpi data regions.
28107 */
28108 +
28109 +#ifdef CONFIG_GRKERNSEC_KMEM
28110 +static unsigned int ebda_start __read_only;
28111 +static unsigned int ebda_end __read_only;
28112 +#endif
28113 +
28114 int devmem_is_allowed(unsigned long pagenr)
28115 {
28116 - if (pagenr < 256)
28117 +#ifdef CONFIG_GRKERNSEC_KMEM
28118 + /* allow BDA */
28119 + if (!pagenr)
28120 return 1;
28121 + /* allow EBDA */
28122 + if (pagenr >= ebda_start && pagenr < ebda_end)
28123 + return 1;
28124 + /* if tboot is in use, allow access to its hardcoded serial log range */
28125 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28126 + return 1;
28127 +#else
28128 + if (!pagenr)
28129 + return 1;
28130 +#ifdef CONFIG_VM86
28131 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28132 + return 1;
28133 +#endif
28134 +#endif
28135 +
28136 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28137 + return 1;
28138 +#ifdef CONFIG_GRKERNSEC_KMEM
28139 + /* throw out everything else below 1MB */
28140 + if (pagenr <= 256)
28141 + return 0;
28142 +#endif
28143 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28144 return 0;
28145 if (!page_is_ram(pagenr))
28146 @@ -524,8 +557,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28147 #endif
28148 }
28149
28150 +#ifdef CONFIG_GRKERNSEC_KMEM
28151 +static inline void gr_init_ebda(void)
28152 +{
28153 + unsigned int ebda_addr;
28154 + unsigned int ebda_size = 0;
28155 +
28156 + ebda_addr = get_bios_ebda();
28157 + if (ebda_addr) {
28158 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28159 + ebda_size <<= 10;
28160 + }
28161 + if (ebda_addr && ebda_size) {
28162 + ebda_start = ebda_addr >> PAGE_SHIFT;
28163 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28164 + } else {
28165 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28166 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28167 + }
28168 +}
28169 +#else
28170 +static inline void gr_init_ebda(void) { }
28171 +#endif
28172 +
28173 void free_initmem(void)
28174 {
28175 +#ifdef CONFIG_PAX_KERNEXEC
28176 +#ifdef CONFIG_X86_32
28177 + /* PaX: limit KERNEL_CS to actual size */
28178 + unsigned long addr, limit;
28179 + struct desc_struct d;
28180 + int cpu;
28181 +#else
28182 + pgd_t *pgd;
28183 + pud_t *pud;
28184 + pmd_t *pmd;
28185 + unsigned long addr, end;
28186 +#endif
28187 +#endif
28188 +
28189 + gr_init_ebda();
28190 +
28191 +#ifdef CONFIG_PAX_KERNEXEC
28192 +#ifdef CONFIG_X86_32
28193 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28194 + limit = (limit - 1UL) >> PAGE_SHIFT;
28195 +
28196 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28197 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28198 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28199 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28200 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28201 + }
28202 +
28203 + /* PaX: make KERNEL_CS read-only */
28204 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28205 + if (!paravirt_enabled())
28206 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28207 +/*
28208 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28209 + pgd = pgd_offset_k(addr);
28210 + pud = pud_offset(pgd, addr);
28211 + pmd = pmd_offset(pud, addr);
28212 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28213 + }
28214 +*/
28215 +#ifdef CONFIG_X86_PAE
28216 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28217 +/*
28218 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28219 + pgd = pgd_offset_k(addr);
28220 + pud = pud_offset(pgd, addr);
28221 + pmd = pmd_offset(pud, addr);
28222 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28223 + }
28224 +*/
28225 +#endif
28226 +
28227 +#ifdef CONFIG_MODULES
28228 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28229 +#endif
28230 +
28231 +#else
28232 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28233 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28234 + pgd = pgd_offset_k(addr);
28235 + pud = pud_offset(pgd, addr);
28236 + pmd = pmd_offset(pud, addr);
28237 + if (!pmd_present(*pmd))
28238 + continue;
28239 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28240 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28241 + else
28242 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28243 + }
28244 +
28245 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28246 + end = addr + KERNEL_IMAGE_SIZE;
28247 + for (; addr < end; addr += PMD_SIZE) {
28248 + pgd = pgd_offset_k(addr);
28249 + pud = pud_offset(pgd, addr);
28250 + pmd = pmd_offset(pud, addr);
28251 + if (!pmd_present(*pmd))
28252 + continue;
28253 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28254 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28255 + }
28256 +#endif
28257 +
28258 + flush_tlb_all();
28259 +#endif
28260 +
28261 free_init_pages("unused kernel memory",
28262 (unsigned long)(&__init_begin),
28263 (unsigned long)(&__init_end));
28264 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28265 index 2d19001..6a1046c 100644
28266 --- a/arch/x86/mm/init_32.c
28267 +++ b/arch/x86/mm/init_32.c
28268 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28269 bool __read_mostly __vmalloc_start_set = false;
28270
28271 /*
28272 - * Creates a middle page table and puts a pointer to it in the
28273 - * given global directory entry. This only returns the gd entry
28274 - * in non-PAE compilation mode, since the middle layer is folded.
28275 - */
28276 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28277 -{
28278 - pud_t *pud;
28279 - pmd_t *pmd_table;
28280 -
28281 -#ifdef CONFIG_X86_PAE
28282 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28283 - pmd_table = (pmd_t *)alloc_low_page();
28284 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28285 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28286 - pud = pud_offset(pgd, 0);
28287 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28288 -
28289 - return pmd_table;
28290 - }
28291 -#endif
28292 - pud = pud_offset(pgd, 0);
28293 - pmd_table = pmd_offset(pud, 0);
28294 -
28295 - return pmd_table;
28296 -}
28297 -
28298 -/*
28299 * Create a page table and place a pointer to it in a middle page
28300 * directory entry:
28301 */
28302 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28303 pte_t *page_table = (pte_t *)alloc_low_page();
28304
28305 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28306 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28307 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28308 +#else
28309 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28310 +#endif
28311 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28312 }
28313
28314 return pte_offset_kernel(pmd, 0);
28315 }
28316
28317 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28318 +{
28319 + pud_t *pud;
28320 + pmd_t *pmd_table;
28321 +
28322 + pud = pud_offset(pgd, 0);
28323 + pmd_table = pmd_offset(pud, 0);
28324 +
28325 + return pmd_table;
28326 +}
28327 +
28328 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28329 {
28330 int pgd_idx = pgd_index(vaddr);
28331 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28332 int pgd_idx, pmd_idx;
28333 unsigned long vaddr;
28334 pgd_t *pgd;
28335 + pud_t *pud;
28336 pmd_t *pmd;
28337 pte_t *pte = NULL;
28338 unsigned long count = page_table_range_init_count(start, end);
28339 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28340 pgd = pgd_base + pgd_idx;
28341
28342 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28343 - pmd = one_md_table_init(pgd);
28344 - pmd = pmd + pmd_index(vaddr);
28345 + pud = pud_offset(pgd, vaddr);
28346 + pmd = pmd_offset(pud, vaddr);
28347 +
28348 +#ifdef CONFIG_X86_PAE
28349 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28350 +#endif
28351 +
28352 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28353 pmd++, pmd_idx++) {
28354 pte = page_table_kmap_check(one_page_table_init(pmd),
28355 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28356 }
28357 }
28358
28359 -static inline int is_kernel_text(unsigned long addr)
28360 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28361 {
28362 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28363 - return 1;
28364 - return 0;
28365 + if ((start > ktla_ktva((unsigned long)_etext) ||
28366 + end <= ktla_ktva((unsigned long)_stext)) &&
28367 + (start > ktla_ktva((unsigned long)_einittext) ||
28368 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28369 +
28370 +#ifdef CONFIG_ACPI_SLEEP
28371 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28372 +#endif
28373 +
28374 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28375 + return 0;
28376 + return 1;
28377 }
28378
28379 /*
28380 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28381 unsigned long last_map_addr = end;
28382 unsigned long start_pfn, end_pfn;
28383 pgd_t *pgd_base = swapper_pg_dir;
28384 - int pgd_idx, pmd_idx, pte_ofs;
28385 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28386 unsigned long pfn;
28387 pgd_t *pgd;
28388 + pud_t *pud;
28389 pmd_t *pmd;
28390 pte_t *pte;
28391 unsigned pages_2m, pages_4k;
28392 @@ -291,8 +295,13 @@ repeat:
28393 pfn = start_pfn;
28394 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28395 pgd = pgd_base + pgd_idx;
28396 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28397 - pmd = one_md_table_init(pgd);
28398 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28399 + pud = pud_offset(pgd, 0);
28400 + pmd = pmd_offset(pud, 0);
28401 +
28402 +#ifdef CONFIG_X86_PAE
28403 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28404 +#endif
28405
28406 if (pfn >= end_pfn)
28407 continue;
28408 @@ -304,14 +313,13 @@ repeat:
28409 #endif
28410 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28411 pmd++, pmd_idx++) {
28412 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28413 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28414
28415 /*
28416 * Map with big pages if possible, otherwise
28417 * create normal page tables:
28418 */
28419 if (use_pse) {
28420 - unsigned int addr2;
28421 pgprot_t prot = PAGE_KERNEL_LARGE;
28422 /*
28423 * first pass will use the same initial
28424 @@ -322,11 +330,7 @@ repeat:
28425 _PAGE_PSE);
28426
28427 pfn &= PMD_MASK >> PAGE_SHIFT;
28428 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28429 - PAGE_OFFSET + PAGE_SIZE-1;
28430 -
28431 - if (is_kernel_text(addr) ||
28432 - is_kernel_text(addr2))
28433 + if (is_kernel_text(address, address + PMD_SIZE))
28434 prot = PAGE_KERNEL_LARGE_EXEC;
28435
28436 pages_2m++;
28437 @@ -343,7 +347,7 @@ repeat:
28438 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28439 pte += pte_ofs;
28440 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28441 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28442 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28443 pgprot_t prot = PAGE_KERNEL;
28444 /*
28445 * first pass will use the same initial
28446 @@ -351,7 +355,7 @@ repeat:
28447 */
28448 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28449
28450 - if (is_kernel_text(addr))
28451 + if (is_kernel_text(address, address + PAGE_SIZE))
28452 prot = PAGE_KERNEL_EXEC;
28453
28454 pages_4k++;
28455 @@ -482,7 +486,7 @@ void __init native_pagetable_init(void)
28456
28457 pud = pud_offset(pgd, va);
28458 pmd = pmd_offset(pud, va);
28459 - if (!pmd_present(*pmd))
28460 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28461 break;
28462
28463 /* should not be large page here */
28464 @@ -540,12 +544,10 @@ void __init early_ioremap_page_table_range_init(void)
28465
28466 static void __init pagetable_init(void)
28467 {
28468 - pgd_t *pgd_base = swapper_pg_dir;
28469 -
28470 - permanent_kmaps_init(pgd_base);
28471 + permanent_kmaps_init(swapper_pg_dir);
28472 }
28473
28474 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28475 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28476 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28477
28478 /* user-defined highmem size */
28479 @@ -752,6 +754,12 @@ void __init mem_init(void)
28480
28481 pci_iommu_alloc();
28482
28483 +#ifdef CONFIG_PAX_PER_CPU_PGD
28484 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28485 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28486 + KERNEL_PGD_PTRS);
28487 +#endif
28488 +
28489 #ifdef CONFIG_FLATMEM
28490 BUG_ON(!mem_map);
28491 #endif
28492 @@ -780,7 +788,7 @@ void __init mem_init(void)
28493 after_bootmem = 1;
28494
28495 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28496 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28497 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28498 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28499
28500 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28501 @@ -821,10 +829,10 @@ void __init mem_init(void)
28502 ((unsigned long)&__init_end -
28503 (unsigned long)&__init_begin) >> 10,
28504
28505 - (unsigned long)&_etext, (unsigned long)&_edata,
28506 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28507 + (unsigned long)&_sdata, (unsigned long)&_edata,
28508 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28509
28510 - (unsigned long)&_text, (unsigned long)&_etext,
28511 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28512 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28513
28514 /*
28515 @@ -914,6 +922,7 @@ void set_kernel_text_rw(void)
28516 if (!kernel_set_to_readonly)
28517 return;
28518
28519 + start = ktla_ktva(start);
28520 pr_debug("Set kernel text: %lx - %lx for read write\n",
28521 start, start+size);
28522
28523 @@ -928,6 +937,7 @@ void set_kernel_text_ro(void)
28524 if (!kernel_set_to_readonly)
28525 return;
28526
28527 + start = ktla_ktva(start);
28528 pr_debug("Set kernel text: %lx - %lx for read only\n",
28529 start, start+size);
28530
28531 @@ -956,6 +966,7 @@ void mark_rodata_ro(void)
28532 unsigned long start = PFN_ALIGN(_text);
28533 unsigned long size = PFN_ALIGN(_etext) - start;
28534
28535 + start = ktla_ktva(start);
28536 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28537 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28538 size >> 10);
28539 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28540 index 474e28f..647dd12 100644
28541 --- a/arch/x86/mm/init_64.c
28542 +++ b/arch/x86/mm/init_64.c
28543 @@ -150,7 +150,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28544 * around without checking the pgd every time.
28545 */
28546
28547 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28548 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28549 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28550
28551 int force_personality32;
28552 @@ -183,12 +183,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28553
28554 for (address = start; address <= end; address += PGDIR_SIZE) {
28555 const pgd_t *pgd_ref = pgd_offset_k(address);
28556 +
28557 +#ifdef CONFIG_PAX_PER_CPU_PGD
28558 + unsigned long cpu;
28559 +#else
28560 struct page *page;
28561 +#endif
28562
28563 if (pgd_none(*pgd_ref))
28564 continue;
28565
28566 spin_lock(&pgd_lock);
28567 +
28568 +#ifdef CONFIG_PAX_PER_CPU_PGD
28569 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28570 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28571 +#else
28572 list_for_each_entry(page, &pgd_list, lru) {
28573 pgd_t *pgd;
28574 spinlock_t *pgt_lock;
28575 @@ -197,6 +207,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28576 /* the pgt_lock only for Xen */
28577 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28578 spin_lock(pgt_lock);
28579 +#endif
28580
28581 if (pgd_none(*pgd))
28582 set_pgd(pgd, *pgd_ref);
28583 @@ -204,7 +215,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28584 BUG_ON(pgd_page_vaddr(*pgd)
28585 != pgd_page_vaddr(*pgd_ref));
28586
28587 +#ifndef CONFIG_PAX_PER_CPU_PGD
28588 spin_unlock(pgt_lock);
28589 +#endif
28590 +
28591 }
28592 spin_unlock(&pgd_lock);
28593 }
28594 @@ -237,7 +251,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28595 {
28596 if (pgd_none(*pgd)) {
28597 pud_t *pud = (pud_t *)spp_getpage();
28598 - pgd_populate(&init_mm, pgd, pud);
28599 + pgd_populate_kernel(&init_mm, pgd, pud);
28600 if (pud != pud_offset(pgd, 0))
28601 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28602 pud, pud_offset(pgd, 0));
28603 @@ -249,7 +263,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28604 {
28605 if (pud_none(*pud)) {
28606 pmd_t *pmd = (pmd_t *) spp_getpage();
28607 - pud_populate(&init_mm, pud, pmd);
28608 + pud_populate_kernel(&init_mm, pud, pmd);
28609 if (pmd != pmd_offset(pud, 0))
28610 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28611 pmd, pmd_offset(pud, 0));
28612 @@ -278,7 +292,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28613 pmd = fill_pmd(pud, vaddr);
28614 pte = fill_pte(pmd, vaddr);
28615
28616 + pax_open_kernel();
28617 set_pte(pte, new_pte);
28618 + pax_close_kernel();
28619
28620 /*
28621 * It's enough to flush this one mapping.
28622 @@ -337,14 +353,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28623 pgd = pgd_offset_k((unsigned long)__va(phys));
28624 if (pgd_none(*pgd)) {
28625 pud = (pud_t *) spp_getpage();
28626 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28627 - _PAGE_USER));
28628 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28629 }
28630 pud = pud_offset(pgd, (unsigned long)__va(phys));
28631 if (pud_none(*pud)) {
28632 pmd = (pmd_t *) spp_getpage();
28633 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28634 - _PAGE_USER));
28635 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28636 }
28637 pmd = pmd_offset(pud, phys);
28638 BUG_ON(!pmd_none(*pmd));
28639 @@ -585,7 +599,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28640 prot);
28641
28642 spin_lock(&init_mm.page_table_lock);
28643 - pud_populate(&init_mm, pud, pmd);
28644 + pud_populate_kernel(&init_mm, pud, pmd);
28645 spin_unlock(&init_mm.page_table_lock);
28646 }
28647 __flush_tlb_all();
28648 @@ -626,7 +640,7 @@ kernel_physical_mapping_init(unsigned long start,
28649 page_size_mask);
28650
28651 spin_lock(&init_mm.page_table_lock);
28652 - pgd_populate(&init_mm, pgd, pud);
28653 + pgd_populate_kernel(&init_mm, pgd, pud);
28654 spin_unlock(&init_mm.page_table_lock);
28655 pgd_changed = true;
28656 }
28657 @@ -1065,6 +1079,12 @@ void __init mem_init(void)
28658
28659 pci_iommu_alloc();
28660
28661 +#ifdef CONFIG_PAX_PER_CPU_PGD
28662 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28663 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28664 + KERNEL_PGD_PTRS);
28665 +#endif
28666 +
28667 /* clear_bss() already clear the empty_zero_page */
28668
28669 reservedpages = 0;
28670 @@ -1224,8 +1244,8 @@ int kern_addr_valid(unsigned long addr)
28671 static struct vm_area_struct gate_vma = {
28672 .vm_start = VSYSCALL_START,
28673 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28674 - .vm_page_prot = PAGE_READONLY_EXEC,
28675 - .vm_flags = VM_READ | VM_EXEC
28676 + .vm_page_prot = PAGE_READONLY,
28677 + .vm_flags = VM_READ
28678 };
28679
28680 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28681 @@ -1259,7 +1279,7 @@ int in_gate_area_no_mm(unsigned long addr)
28682
28683 const char *arch_vma_name(struct vm_area_struct *vma)
28684 {
28685 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28686 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28687 return "[vdso]";
28688 if (vma == &gate_vma)
28689 return "[vsyscall]";
28690 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28691 index 7b179b4..6bd17777 100644
28692 --- a/arch/x86/mm/iomap_32.c
28693 +++ b/arch/x86/mm/iomap_32.c
28694 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28695 type = kmap_atomic_idx_push();
28696 idx = type + KM_TYPE_NR * smp_processor_id();
28697 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28698 +
28699 + pax_open_kernel();
28700 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28701 + pax_close_kernel();
28702 +
28703 arch_flush_lazy_mmu_mode();
28704
28705 return (void *)vaddr;
28706 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28707 index 78fe3f1..73b95e2 100644
28708 --- a/arch/x86/mm/ioremap.c
28709 +++ b/arch/x86/mm/ioremap.c
28710 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28711 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28712 int is_ram = page_is_ram(pfn);
28713
28714 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28715 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28716 return NULL;
28717 WARN_ON_ONCE(is_ram);
28718 }
28719 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28720 *
28721 * Caller must ensure there is only one unmapping for the same pointer.
28722 */
28723 -void iounmap(volatile void __iomem *addr)
28724 +void iounmap(const volatile void __iomem *addr)
28725 {
28726 struct vm_struct *p, *o;
28727
28728 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28729
28730 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28731 if (page_is_ram(start >> PAGE_SHIFT))
28732 +#ifdef CONFIG_HIGHMEM
28733 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28734 +#endif
28735 return __va(phys);
28736
28737 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28738 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28739 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28740 {
28741 if (page_is_ram(phys >> PAGE_SHIFT))
28742 +#ifdef CONFIG_HIGHMEM
28743 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28744 +#endif
28745 return;
28746
28747 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28748 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
28749 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28750
28751 static __initdata int after_paging_init;
28752 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28753 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28754
28755 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28756 {
28757 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
28758 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28759
28760 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28761 - memset(bm_pte, 0, sizeof(bm_pte));
28762 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28763 + pmd_populate_user(&init_mm, pmd, bm_pte);
28764
28765 /*
28766 * The boot-ioremap range spans multiple pmds, for which
28767 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28768 index d87dd6d..bf3fa66 100644
28769 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28770 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28771 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28772 * memory (e.g. tracked pages)? For now, we need this to avoid
28773 * invoking kmemcheck for PnP BIOS calls.
28774 */
28775 - if (regs->flags & X86_VM_MASK)
28776 + if (v8086_mode(regs))
28777 return false;
28778 - if (regs->cs != __KERNEL_CS)
28779 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28780 return false;
28781
28782 pte = kmemcheck_pte_lookup(address);
28783 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28784 index 845df68..1d8d29f 100644
28785 --- a/arch/x86/mm/mmap.c
28786 +++ b/arch/x86/mm/mmap.c
28787 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28788 * Leave an at least ~128 MB hole with possible stack randomization.
28789 */
28790 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28791 -#define MAX_GAP (TASK_SIZE/6*5)
28792 +#define MAX_GAP (pax_task_size/6*5)
28793
28794 static int mmap_is_legacy(void)
28795 {
28796 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28797 return rnd << PAGE_SHIFT;
28798 }
28799
28800 -static unsigned long mmap_base(void)
28801 +static unsigned long mmap_base(struct mm_struct *mm)
28802 {
28803 unsigned long gap = rlimit(RLIMIT_STACK);
28804 + unsigned long pax_task_size = TASK_SIZE;
28805 +
28806 +#ifdef CONFIG_PAX_SEGMEXEC
28807 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28808 + pax_task_size = SEGMEXEC_TASK_SIZE;
28809 +#endif
28810
28811 if (gap < MIN_GAP)
28812 gap = MIN_GAP;
28813 else if (gap > MAX_GAP)
28814 gap = MAX_GAP;
28815
28816 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28817 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28818 }
28819
28820 /*
28821 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28822 * does, but not when emulating X86_32
28823 */
28824 -static unsigned long mmap_legacy_base(void)
28825 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28826 {
28827 - if (mmap_is_ia32())
28828 + if (mmap_is_ia32()) {
28829 +
28830 +#ifdef CONFIG_PAX_SEGMEXEC
28831 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28832 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28833 + else
28834 +#endif
28835 +
28836 return TASK_UNMAPPED_BASE;
28837 - else
28838 + } else
28839 return TASK_UNMAPPED_BASE + mmap_rnd();
28840 }
28841
28842 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28843 void arch_pick_mmap_layout(struct mm_struct *mm)
28844 {
28845 if (mmap_is_legacy()) {
28846 - mm->mmap_base = mmap_legacy_base();
28847 + mm->mmap_base = mmap_legacy_base(mm);
28848 +
28849 +#ifdef CONFIG_PAX_RANDMMAP
28850 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28851 + mm->mmap_base += mm->delta_mmap;
28852 +#endif
28853 +
28854 mm->get_unmapped_area = arch_get_unmapped_area;
28855 mm->unmap_area = arch_unmap_area;
28856 } else {
28857 - mm->mmap_base = mmap_base();
28858 + mm->mmap_base = mmap_base(mm);
28859 +
28860 +#ifdef CONFIG_PAX_RANDMMAP
28861 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28862 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28863 +#endif
28864 +
28865 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28866 mm->unmap_area = arch_unmap_area_topdown;
28867 }
28868 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28869 index dc0b727..f612039 100644
28870 --- a/arch/x86/mm/mmio-mod.c
28871 +++ b/arch/x86/mm/mmio-mod.c
28872 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28873 break;
28874 default:
28875 {
28876 - unsigned char *ip = (unsigned char *)instptr;
28877 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28878 my_trace->opcode = MMIO_UNKNOWN_OP;
28879 my_trace->width = 0;
28880 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28881 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28882 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28883 void __iomem *addr)
28884 {
28885 - static atomic_t next_id;
28886 + static atomic_unchecked_t next_id;
28887 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28888 /* These are page-unaligned. */
28889 struct mmiotrace_map map = {
28890 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28891 .private = trace
28892 },
28893 .phys = offset,
28894 - .id = atomic_inc_return(&next_id)
28895 + .id = atomic_inc_return_unchecked(&next_id)
28896 };
28897 map.map_id = trace->id;
28898
28899 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28900 ioremap_trace_core(offset, size, addr);
28901 }
28902
28903 -static void iounmap_trace_core(volatile void __iomem *addr)
28904 +static void iounmap_trace_core(const volatile void __iomem *addr)
28905 {
28906 struct mmiotrace_map map = {
28907 .phys = 0,
28908 @@ -328,7 +328,7 @@ not_enabled:
28909 }
28910 }
28911
28912 -void mmiotrace_iounmap(volatile void __iomem *addr)
28913 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28914 {
28915 might_sleep();
28916 if (is_enabled()) /* recheck and proper locking in *_core() */
28917 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28918 index 72fe01e..f1a8daa 100644
28919 --- a/arch/x86/mm/numa.c
28920 +++ b/arch/x86/mm/numa.c
28921 @@ -477,7 +477,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28922 return true;
28923 }
28924
28925 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28926 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28927 {
28928 unsigned long uninitialized_var(pfn_align);
28929 int i, nid;
28930 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28931 index 0e38951..4ca8458 100644
28932 --- a/arch/x86/mm/pageattr-test.c
28933 +++ b/arch/x86/mm/pageattr-test.c
28934 @@ -36,7 +36,7 @@ enum {
28935
28936 static int pte_testbit(pte_t pte)
28937 {
28938 - return pte_flags(pte) & _PAGE_UNUSED1;
28939 + return pte_flags(pte) & _PAGE_CPA_TEST;
28940 }
28941
28942 struct split_state {
28943 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28944 index fb4e73e..43f7238 100644
28945 --- a/arch/x86/mm/pageattr.c
28946 +++ b/arch/x86/mm/pageattr.c
28947 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28948 */
28949 #ifdef CONFIG_PCI_BIOS
28950 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28951 - pgprot_val(forbidden) |= _PAGE_NX;
28952 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28953 #endif
28954
28955 /*
28956 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28957 * Does not cover __inittext since that is gone later on. On
28958 * 64bit we do not enforce !NX on the low mapping
28959 */
28960 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28961 - pgprot_val(forbidden) |= _PAGE_NX;
28962 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28963 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28964
28965 +#ifdef CONFIG_DEBUG_RODATA
28966 /*
28967 * The .rodata section needs to be read-only. Using the pfn
28968 * catches all aliases.
28969 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28970 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28971 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28972 pgprot_val(forbidden) |= _PAGE_RW;
28973 +#endif
28974
28975 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28976 /*
28977 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28978 }
28979 #endif
28980
28981 +#ifdef CONFIG_PAX_KERNEXEC
28982 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28983 + pgprot_val(forbidden) |= _PAGE_RW;
28984 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28985 + }
28986 +#endif
28987 +
28988 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28989
28990 return prot;
28991 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
28992 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28993 {
28994 /* change init_mm */
28995 + pax_open_kernel();
28996 set_pte_atomic(kpte, pte);
28997 +
28998 #ifdef CONFIG_X86_32
28999 if (!SHARED_KERNEL_PMD) {
29000 +
29001 +#ifdef CONFIG_PAX_PER_CPU_PGD
29002 + unsigned long cpu;
29003 +#else
29004 struct page *page;
29005 +#endif
29006
29007 +#ifdef CONFIG_PAX_PER_CPU_PGD
29008 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29009 + pgd_t *pgd = get_cpu_pgd(cpu);
29010 +#else
29011 list_for_each_entry(page, &pgd_list, lru) {
29012 - pgd_t *pgd;
29013 + pgd_t *pgd = (pgd_t *)page_address(page);
29014 +#endif
29015 +
29016 pud_t *pud;
29017 pmd_t *pmd;
29018
29019 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29020 + pgd += pgd_index(address);
29021 pud = pud_offset(pgd, address);
29022 pmd = pmd_offset(pud, address);
29023 set_pte_atomic((pte_t *)pmd, pte);
29024 }
29025 }
29026 #endif
29027 + pax_close_kernel();
29028 }
29029
29030 static int
29031 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29032 index 6574388..87e9bef 100644
29033 --- a/arch/x86/mm/pat.c
29034 +++ b/arch/x86/mm/pat.c
29035 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29036
29037 if (!entry) {
29038 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29039 - current->comm, current->pid, start, end - 1);
29040 + current->comm, task_pid_nr(current), start, end - 1);
29041 return -EINVAL;
29042 }
29043
29044 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29045
29046 while (cursor < to) {
29047 if (!devmem_is_allowed(pfn)) {
29048 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29049 - current->comm, from, to - 1);
29050 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29051 + current->comm, from, to - 1, cursor);
29052 return 0;
29053 }
29054 cursor += PAGE_SIZE;
29055 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29056 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29057 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29058 "for [mem %#010Lx-%#010Lx]\n",
29059 - current->comm, current->pid,
29060 + current->comm, task_pid_nr(current),
29061 cattr_name(flags),
29062 base, (unsigned long long)(base + size-1));
29063 return -EINVAL;
29064 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29065 flags = lookup_memtype(paddr);
29066 if (want_flags != flags) {
29067 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29068 - current->comm, current->pid,
29069 + current->comm, task_pid_nr(current),
29070 cattr_name(want_flags),
29071 (unsigned long long)paddr,
29072 (unsigned long long)(paddr + size - 1),
29073 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29074 free_memtype(paddr, paddr + size);
29075 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29076 " for [mem %#010Lx-%#010Lx], got %s\n",
29077 - current->comm, current->pid,
29078 + current->comm, task_pid_nr(current),
29079 cattr_name(want_flags),
29080 (unsigned long long)paddr,
29081 (unsigned long long)(paddr + size - 1),
29082 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29083 index 9f0614d..92ae64a 100644
29084 --- a/arch/x86/mm/pf_in.c
29085 +++ b/arch/x86/mm/pf_in.c
29086 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29087 int i;
29088 enum reason_type rv = OTHERS;
29089
29090 - p = (unsigned char *)ins_addr;
29091 + p = (unsigned char *)ktla_ktva(ins_addr);
29092 p += skip_prefix(p, &prf);
29093 p += get_opcode(p, &opcode);
29094
29095 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29096 struct prefix_bits prf;
29097 int i;
29098
29099 - p = (unsigned char *)ins_addr;
29100 + p = (unsigned char *)ktla_ktva(ins_addr);
29101 p += skip_prefix(p, &prf);
29102 p += get_opcode(p, &opcode);
29103
29104 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29105 struct prefix_bits prf;
29106 int i;
29107
29108 - p = (unsigned char *)ins_addr;
29109 + p = (unsigned char *)ktla_ktva(ins_addr);
29110 p += skip_prefix(p, &prf);
29111 p += get_opcode(p, &opcode);
29112
29113 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29114 struct prefix_bits prf;
29115 int i;
29116
29117 - p = (unsigned char *)ins_addr;
29118 + p = (unsigned char *)ktla_ktva(ins_addr);
29119 p += skip_prefix(p, &prf);
29120 p += get_opcode(p, &opcode);
29121 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29122 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29123 struct prefix_bits prf;
29124 int i;
29125
29126 - p = (unsigned char *)ins_addr;
29127 + p = (unsigned char *)ktla_ktva(ins_addr);
29128 p += skip_prefix(p, &prf);
29129 p += get_opcode(p, &opcode);
29130 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29131 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29132 index 17fda6a..489c74a 100644
29133 --- a/arch/x86/mm/pgtable.c
29134 +++ b/arch/x86/mm/pgtable.c
29135 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29136 list_del(&page->lru);
29137 }
29138
29139 -#define UNSHARED_PTRS_PER_PGD \
29140 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29141 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29142 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29143
29144 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29145 +{
29146 + unsigned int count = USER_PGD_PTRS;
29147
29148 + while (count--)
29149 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29150 +}
29151 +#endif
29152 +
29153 +#ifdef CONFIG_PAX_PER_CPU_PGD
29154 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29155 +{
29156 + unsigned int count = USER_PGD_PTRS;
29157 +
29158 + while (count--) {
29159 + pgd_t pgd;
29160 +
29161 +#ifdef CONFIG_X86_64
29162 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29163 +#else
29164 + pgd = *src++;
29165 +#endif
29166 +
29167 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29168 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29169 +#endif
29170 +
29171 + *dst++ = pgd;
29172 + }
29173 +
29174 +}
29175 +#endif
29176 +
29177 +#ifdef CONFIG_X86_64
29178 +#define pxd_t pud_t
29179 +#define pyd_t pgd_t
29180 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29181 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29182 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29183 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29184 +#define PYD_SIZE PGDIR_SIZE
29185 +#else
29186 +#define pxd_t pmd_t
29187 +#define pyd_t pud_t
29188 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29189 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29190 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29191 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29192 +#define PYD_SIZE PUD_SIZE
29193 +#endif
29194 +
29195 +#ifdef CONFIG_PAX_PER_CPU_PGD
29196 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29197 +static inline void pgd_dtor(pgd_t *pgd) {}
29198 +#else
29199 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29200 {
29201 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29202 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29203 pgd_list_del(pgd);
29204 spin_unlock(&pgd_lock);
29205 }
29206 +#endif
29207
29208 /*
29209 * List of all pgd's needed for non-PAE so it can invalidate entries
29210 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29211 * -- nyc
29212 */
29213
29214 -#ifdef CONFIG_X86_PAE
29215 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29216 /*
29217 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29218 * updating the top-level pagetable entries to guarantee the
29219 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29220 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29221 * and initialize the kernel pmds here.
29222 */
29223 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29224 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29225
29226 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29227 {
29228 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29229 */
29230 flush_tlb_mm(mm);
29231 }
29232 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29233 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29234 #else /* !CONFIG_X86_PAE */
29235
29236 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29237 -#define PREALLOCATED_PMDS 0
29238 +#define PREALLOCATED_PXDS 0
29239
29240 #endif /* CONFIG_X86_PAE */
29241
29242 -static void free_pmds(pmd_t *pmds[])
29243 +static void free_pxds(pxd_t *pxds[])
29244 {
29245 int i;
29246
29247 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29248 - if (pmds[i])
29249 - free_page((unsigned long)pmds[i]);
29250 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29251 + if (pxds[i])
29252 + free_page((unsigned long)pxds[i]);
29253 }
29254
29255 -static int preallocate_pmds(pmd_t *pmds[])
29256 +static int preallocate_pxds(pxd_t *pxds[])
29257 {
29258 int i;
29259 bool failed = false;
29260
29261 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29262 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29263 - if (pmd == NULL)
29264 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29265 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29266 + if (pxd == NULL)
29267 failed = true;
29268 - pmds[i] = pmd;
29269 + pxds[i] = pxd;
29270 }
29271
29272 if (failed) {
29273 - free_pmds(pmds);
29274 + free_pxds(pxds);
29275 return -ENOMEM;
29276 }
29277
29278 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29279 * preallocate which never got a corresponding vma will need to be
29280 * freed manually.
29281 */
29282 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29283 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29284 {
29285 int i;
29286
29287 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29288 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29289 pgd_t pgd = pgdp[i];
29290
29291 if (pgd_val(pgd) != 0) {
29292 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29293 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29294
29295 - pgdp[i] = native_make_pgd(0);
29296 + set_pgd(pgdp + i, native_make_pgd(0));
29297
29298 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29299 - pmd_free(mm, pmd);
29300 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29301 + pxd_free(mm, pxd);
29302 }
29303 }
29304 }
29305
29306 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29307 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29308 {
29309 - pud_t *pud;
29310 + pyd_t *pyd;
29311 unsigned long addr;
29312 int i;
29313
29314 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29315 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29316 return;
29317
29318 - pud = pud_offset(pgd, 0);
29319 +#ifdef CONFIG_X86_64
29320 + pyd = pyd_offset(mm, 0L);
29321 +#else
29322 + pyd = pyd_offset(pgd, 0L);
29323 +#endif
29324
29325 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29326 - i++, pud++, addr += PUD_SIZE) {
29327 - pmd_t *pmd = pmds[i];
29328 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29329 + i++, pyd++, addr += PYD_SIZE) {
29330 + pxd_t *pxd = pxds[i];
29331
29332 if (i >= KERNEL_PGD_BOUNDARY)
29333 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29334 - sizeof(pmd_t) * PTRS_PER_PMD);
29335 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29336 + sizeof(pxd_t) * PTRS_PER_PMD);
29337
29338 - pud_populate(mm, pud, pmd);
29339 + pyd_populate(mm, pyd, pxd);
29340 }
29341 }
29342
29343 pgd_t *pgd_alloc(struct mm_struct *mm)
29344 {
29345 pgd_t *pgd;
29346 - pmd_t *pmds[PREALLOCATED_PMDS];
29347 + pxd_t *pxds[PREALLOCATED_PXDS];
29348
29349 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29350
29351 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29352
29353 mm->pgd = pgd;
29354
29355 - if (preallocate_pmds(pmds) != 0)
29356 + if (preallocate_pxds(pxds) != 0)
29357 goto out_free_pgd;
29358
29359 if (paravirt_pgd_alloc(mm) != 0)
29360 - goto out_free_pmds;
29361 + goto out_free_pxds;
29362
29363 /*
29364 * Make sure that pre-populating the pmds is atomic with
29365 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29366 spin_lock(&pgd_lock);
29367
29368 pgd_ctor(mm, pgd);
29369 - pgd_prepopulate_pmd(mm, pgd, pmds);
29370 + pgd_prepopulate_pxd(mm, pgd, pxds);
29371
29372 spin_unlock(&pgd_lock);
29373
29374 return pgd;
29375
29376 -out_free_pmds:
29377 - free_pmds(pmds);
29378 +out_free_pxds:
29379 + free_pxds(pxds);
29380 out_free_pgd:
29381 free_page((unsigned long)pgd);
29382 out:
29383 @@ -302,7 +363,7 @@ out:
29384
29385 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29386 {
29387 - pgd_mop_up_pmds(mm, pgd);
29388 + pgd_mop_up_pxds(mm, pgd);
29389 pgd_dtor(pgd);
29390 paravirt_pgd_free(mm, pgd);
29391 free_page((unsigned long)pgd);
29392 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29393 index a69bcb8..19068ab 100644
29394 --- a/arch/x86/mm/pgtable_32.c
29395 +++ b/arch/x86/mm/pgtable_32.c
29396 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29397 return;
29398 }
29399 pte = pte_offset_kernel(pmd, vaddr);
29400 +
29401 + pax_open_kernel();
29402 if (pte_val(pteval))
29403 set_pte_at(&init_mm, vaddr, pte, pteval);
29404 else
29405 pte_clear(&init_mm, vaddr, pte);
29406 + pax_close_kernel();
29407
29408 /*
29409 * It's enough to flush this one mapping.
29410 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29411 index e666cbb..61788c45 100644
29412 --- a/arch/x86/mm/physaddr.c
29413 +++ b/arch/x86/mm/physaddr.c
29414 @@ -10,7 +10,7 @@
29415 #ifdef CONFIG_X86_64
29416
29417 #ifdef CONFIG_DEBUG_VIRTUAL
29418 -unsigned long __phys_addr(unsigned long x)
29419 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29420 {
29421 unsigned long y = x - __START_KERNEL_map;
29422
29423 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29424 #else
29425
29426 #ifdef CONFIG_DEBUG_VIRTUAL
29427 -unsigned long __phys_addr(unsigned long x)
29428 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29429 {
29430 unsigned long phys_addr = x - PAGE_OFFSET;
29431 /* VMALLOC_* aren't constants */
29432 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29433 index 410531d..0f16030 100644
29434 --- a/arch/x86/mm/setup_nx.c
29435 +++ b/arch/x86/mm/setup_nx.c
29436 @@ -5,8 +5,10 @@
29437 #include <asm/pgtable.h>
29438 #include <asm/proto.h>
29439
29440 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29441 static int disable_nx __cpuinitdata;
29442
29443 +#ifndef CONFIG_PAX_PAGEEXEC
29444 /*
29445 * noexec = on|off
29446 *
29447 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29448 return 0;
29449 }
29450 early_param("noexec", noexec_setup);
29451 +#endif
29452 +
29453 +#endif
29454
29455 void __cpuinit x86_configure_nx(void)
29456 {
29457 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29458 if (cpu_has_nx && !disable_nx)
29459 __supported_pte_mask |= _PAGE_NX;
29460 else
29461 +#endif
29462 __supported_pte_mask &= ~_PAGE_NX;
29463 }
29464
29465 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29466 index 282375f..e03a98f 100644
29467 --- a/arch/x86/mm/tlb.c
29468 +++ b/arch/x86/mm/tlb.c
29469 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29470 BUG();
29471 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29472 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29473 +
29474 +#ifndef CONFIG_PAX_PER_CPU_PGD
29475 load_cr3(swapper_pg_dir);
29476 +#endif
29477 +
29478 }
29479 }
29480 EXPORT_SYMBOL_GPL(leave_mm);
29481 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29482 index 877b9a1..a8ecf42 100644
29483 --- a/arch/x86/net/bpf_jit.S
29484 +++ b/arch/x86/net/bpf_jit.S
29485 @@ -9,6 +9,7 @@
29486 */
29487 #include <linux/linkage.h>
29488 #include <asm/dwarf2.h>
29489 +#include <asm/alternative-asm.h>
29490
29491 /*
29492 * Calling convention :
29493 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29494 jle bpf_slow_path_word
29495 mov (SKBDATA,%rsi),%eax
29496 bswap %eax /* ntohl() */
29497 + pax_force_retaddr
29498 ret
29499
29500 sk_load_half:
29501 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29502 jle bpf_slow_path_half
29503 movzwl (SKBDATA,%rsi),%eax
29504 rol $8,%ax # ntohs()
29505 + pax_force_retaddr
29506 ret
29507
29508 sk_load_byte:
29509 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29510 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29511 jle bpf_slow_path_byte
29512 movzbl (SKBDATA,%rsi),%eax
29513 + pax_force_retaddr
29514 ret
29515
29516 /**
29517 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29518 movzbl (SKBDATA,%rsi),%ebx
29519 and $15,%bl
29520 shl $2,%bl
29521 + pax_force_retaddr
29522 ret
29523
29524 /* rsi contains offset and can be scratched */
29525 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29526 js bpf_error
29527 mov -12(%rbp),%eax
29528 bswap %eax
29529 + pax_force_retaddr
29530 ret
29531
29532 bpf_slow_path_half:
29533 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29534 mov -12(%rbp),%ax
29535 rol $8,%ax
29536 movzwl %ax,%eax
29537 + pax_force_retaddr
29538 ret
29539
29540 bpf_slow_path_byte:
29541 bpf_slow_path_common(1)
29542 js bpf_error
29543 movzbl -12(%rbp),%eax
29544 + pax_force_retaddr
29545 ret
29546
29547 bpf_slow_path_byte_msh:
29548 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29549 and $15,%al
29550 shl $2,%al
29551 xchg %eax,%ebx
29552 + pax_force_retaddr
29553 ret
29554
29555 #define sk_negative_common(SIZE) \
29556 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29557 sk_negative_common(4)
29558 mov (%rax), %eax
29559 bswap %eax
29560 + pax_force_retaddr
29561 ret
29562
29563 bpf_slow_path_half_neg:
29564 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29565 mov (%rax),%ax
29566 rol $8,%ax
29567 movzwl %ax,%eax
29568 + pax_force_retaddr
29569 ret
29570
29571 bpf_slow_path_byte_neg:
29572 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29573 .globl sk_load_byte_negative_offset
29574 sk_negative_common(1)
29575 movzbl (%rax), %eax
29576 + pax_force_retaddr
29577 ret
29578
29579 bpf_slow_path_byte_msh_neg:
29580 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29581 and $15,%al
29582 shl $2,%al
29583 xchg %eax,%ebx
29584 + pax_force_retaddr
29585 ret
29586
29587 bpf_error:
29588 @@ -197,4 +210,5 @@ bpf_error:
29589 xor %eax,%eax
29590 mov -8(%rbp),%rbx
29591 leaveq
29592 + pax_force_retaddr
29593 ret
29594 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29595 index 3cbe4538..003d011 100644
29596 --- a/arch/x86/net/bpf_jit_comp.c
29597 +++ b/arch/x86/net/bpf_jit_comp.c
29598 @@ -12,6 +12,7 @@
29599 #include <linux/netdevice.h>
29600 #include <linux/filter.h>
29601 #include <linux/if_vlan.h>
29602 +#include <linux/random.h>
29603
29604 /*
29605 * Conventions :
29606 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29607 return ptr + len;
29608 }
29609
29610 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29611 +#define MAX_INSTR_CODE_SIZE 96
29612 +#else
29613 +#define MAX_INSTR_CODE_SIZE 64
29614 +#endif
29615 +
29616 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29617
29618 #define EMIT1(b1) EMIT(b1, 1)
29619 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29620 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29621 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29622 +
29623 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29624 +/* original constant will appear in ecx */
29625 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29626 +do { \
29627 + /* mov ecx, randkey */ \
29628 + EMIT1(0xb9); \
29629 + EMIT(_key, 4); \
29630 + /* xor ecx, randkey ^ off */ \
29631 + EMIT2(0x81, 0xf1); \
29632 + EMIT((_key) ^ (_off), 4); \
29633 +} while (0)
29634 +
29635 +#define EMIT1_off32(b1, _off) \
29636 +do { \
29637 + switch (b1) { \
29638 + case 0x05: /* add eax, imm32 */ \
29639 + case 0x2d: /* sub eax, imm32 */ \
29640 + case 0x25: /* and eax, imm32 */ \
29641 + case 0x0d: /* or eax, imm32 */ \
29642 + case 0xb8: /* mov eax, imm32 */ \
29643 + case 0x35: /* xor eax, imm32 */ \
29644 + case 0x3d: /* cmp eax, imm32 */ \
29645 + case 0xa9: /* test eax, imm32 */ \
29646 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29647 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29648 + break; \
29649 + case 0xbb: /* mov ebx, imm32 */ \
29650 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29651 + /* mov ebx, ecx */ \
29652 + EMIT2(0x89, 0xcb); \
29653 + break; \
29654 + case 0xbe: /* mov esi, imm32 */ \
29655 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29656 + /* mov esi, ecx */ \
29657 + EMIT2(0x89, 0xce); \
29658 + break; \
29659 + case 0xe8: /* call rel imm32, always to known funcs */ \
29660 + EMIT1(b1); \
29661 + EMIT(_off, 4); \
29662 + break; \
29663 + case 0xe9: /* jmp rel imm32 */ \
29664 + EMIT1(b1); \
29665 + EMIT(_off, 4); \
29666 + /* prevent fall-through, we're not called if off = 0 */ \
29667 + EMIT(0xcccccccc, 4); \
29668 + EMIT(0xcccccccc, 4); \
29669 + break; \
29670 + default: \
29671 + BUILD_BUG(); \
29672 + } \
29673 +} while (0)
29674 +
29675 +#define EMIT2_off32(b1, b2, _off) \
29676 +do { \
29677 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29678 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29679 + EMIT(randkey, 4); \
29680 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29681 + EMIT((_off) - randkey, 4); \
29682 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29683 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29684 + /* imul eax, ecx */ \
29685 + EMIT3(0x0f, 0xaf, 0xc1); \
29686 + } else { \
29687 + BUILD_BUG(); \
29688 + } \
29689 +} while (0)
29690 +#else
29691 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29692 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29693 +#endif
29694
29695 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29696 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29697 @@ -90,6 +168,24 @@ do { \
29698 #define X86_JBE 0x76
29699 #define X86_JA 0x77
29700
29701 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29702 +#define APPEND_FLOW_VERIFY() \
29703 +do { \
29704 + /* mov ecx, randkey */ \
29705 + EMIT1(0xb9); \
29706 + EMIT(randkey, 4); \
29707 + /* cmp ecx, randkey */ \
29708 + EMIT2(0x81, 0xf9); \
29709 + EMIT(randkey, 4); \
29710 + /* jz after 8 int 3s */ \
29711 + EMIT2(0x74, 0x08); \
29712 + EMIT(0xcccccccc, 4); \
29713 + EMIT(0xcccccccc, 4); \
29714 +} while (0)
29715 +#else
29716 +#define APPEND_FLOW_VERIFY() do { } while (0)
29717 +#endif
29718 +
29719 #define EMIT_COND_JMP(op, offset) \
29720 do { \
29721 if (is_near(offset)) \
29722 @@ -97,6 +193,7 @@ do { \
29723 else { \
29724 EMIT2(0x0f, op + 0x10); \
29725 EMIT(offset, 4); /* jxx .+off32 */ \
29726 + APPEND_FLOW_VERIFY(); \
29727 } \
29728 } while (0)
29729
29730 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29731 set_fs(old_fs);
29732 }
29733
29734 +struct bpf_jit_work {
29735 + struct work_struct work;
29736 + void *image;
29737 +};
29738 +
29739 #define CHOOSE_LOAD_FUNC(K, func) \
29740 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29741
29742 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29743
29744 void bpf_jit_compile(struct sk_filter *fp)
29745 {
29746 - u8 temp[64];
29747 + u8 temp[MAX_INSTR_CODE_SIZE];
29748 u8 *prog;
29749 unsigned int proglen, oldproglen = 0;
29750 int ilen, i;
29751 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29752 unsigned int *addrs;
29753 const struct sock_filter *filter = fp->insns;
29754 int flen = fp->len;
29755 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29756 + unsigned int randkey;
29757 +#endif
29758
29759 if (!bpf_jit_enable)
29760 return;
29761 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29762 if (addrs == NULL)
29763 return;
29764
29765 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29766 + if (!fp->work)
29767 + goto out;
29768 +
29769 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29770 + randkey = get_random_int();
29771 +#endif
29772 +
29773 /* Before first pass, make a rough estimation of addrs[]
29774 - * each bpf instruction is translated to less than 64 bytes
29775 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29776 */
29777 for (proglen = 0, i = 0; i < flen; i++) {
29778 - proglen += 64;
29779 + proglen += MAX_INSTR_CODE_SIZE;
29780 addrs[i] = proglen;
29781 }
29782 cleanup_addr = proglen; /* epilogue address */
29783 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29784 case BPF_S_ALU_MUL_K: /* A *= K */
29785 if (is_imm8(K))
29786 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29787 - else {
29788 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29789 - EMIT(K, 4);
29790 - }
29791 + else
29792 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29793 break;
29794 case BPF_S_ALU_DIV_X: /* A /= X; */
29795 seen |= SEEN_XREG;
29796 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29797 break;
29798 case BPF_S_ALU_MOD_K: /* A %= K; */
29799 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29800 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29801 + DILUTE_CONST_SEQUENCE(K, randkey);
29802 +#else
29803 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29804 +#endif
29805 EMIT2(0xf7, 0xf1); /* div %ecx */
29806 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29807 break;
29808 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29809 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29810 + DILUTE_CONST_SEQUENCE(K, randkey);
29811 + // imul rax, rcx
29812 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29813 +#else
29814 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29815 EMIT(K, 4);
29816 +#endif
29817 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29818 break;
29819 case BPF_S_ALU_AND_X:
29820 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29821 if (is_imm8(K)) {
29822 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29823 } else {
29824 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29825 - EMIT(K, 4);
29826 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29827 }
29828 } else {
29829 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29830 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29831 break;
29832 default:
29833 /* hmm, too complex filter, give up with jit compiler */
29834 - goto out;
29835 + goto error;
29836 }
29837 ilen = prog - temp;
29838 if (image) {
29839 if (unlikely(proglen + ilen > oldproglen)) {
29840 pr_err("bpb_jit_compile fatal error\n");
29841 - kfree(addrs);
29842 - module_free(NULL, image);
29843 - return;
29844 + module_free_exec(NULL, image);
29845 + goto error;
29846 }
29847 + pax_open_kernel();
29848 memcpy(image + proglen, temp, ilen);
29849 + pax_close_kernel();
29850 }
29851 proglen += ilen;
29852 addrs[i] = proglen;
29853 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29854 break;
29855 }
29856 if (proglen == oldproglen) {
29857 - image = module_alloc(max_t(unsigned int,
29858 - proglen,
29859 - sizeof(struct work_struct)));
29860 + image = module_alloc_exec(proglen);
29861 if (!image)
29862 - goto out;
29863 + goto error;
29864 }
29865 oldproglen = proglen;
29866 }
29867 @@ -737,7 +856,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29868 bpf_flush_icache(image, image + proglen);
29869
29870 fp->bpf_func = (void *)image;
29871 - }
29872 + } else
29873 +error:
29874 + kfree(fp->work);
29875 +
29876 out:
29877 kfree(addrs);
29878 return;
29879 @@ -745,18 +867,20 @@ out:
29880
29881 static void jit_free_defer(struct work_struct *arg)
29882 {
29883 - module_free(NULL, arg);
29884 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29885 + kfree(arg);
29886 }
29887
29888 /* run from softirq, we must use a work_struct to call
29889 - * module_free() from process context
29890 + * module_free_exec() from process context
29891 */
29892 void bpf_jit_free(struct sk_filter *fp)
29893 {
29894 if (fp->bpf_func != sk_run_filter) {
29895 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29896 + struct work_struct *work = &fp->work->work;
29897
29898 INIT_WORK(work, jit_free_defer);
29899 + fp->work->image = fp->bpf_func;
29900 schedule_work(work);
29901 }
29902 }
29903 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29904 index d6aa6e8..266395a 100644
29905 --- a/arch/x86/oprofile/backtrace.c
29906 +++ b/arch/x86/oprofile/backtrace.c
29907 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29908 struct stack_frame_ia32 *fp;
29909 unsigned long bytes;
29910
29911 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29912 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29913 if (bytes != sizeof(bufhead))
29914 return NULL;
29915
29916 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29917 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29918
29919 oprofile_add_trace(bufhead[0].return_address);
29920
29921 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29922 struct stack_frame bufhead[2];
29923 unsigned long bytes;
29924
29925 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29926 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29927 if (bytes != sizeof(bufhead))
29928 return NULL;
29929
29930 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29931 {
29932 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29933
29934 - if (!user_mode_vm(regs)) {
29935 + if (!user_mode(regs)) {
29936 unsigned long stack = kernel_stack_pointer(regs);
29937 if (depth)
29938 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29939 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29940 index 48768df..ba9143c 100644
29941 --- a/arch/x86/oprofile/nmi_int.c
29942 +++ b/arch/x86/oprofile/nmi_int.c
29943 @@ -23,6 +23,7 @@
29944 #include <asm/nmi.h>
29945 #include <asm/msr.h>
29946 #include <asm/apic.h>
29947 +#include <asm/pgtable.h>
29948
29949 #include "op_counter.h"
29950 #include "op_x86_model.h"
29951 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29952 if (ret)
29953 return ret;
29954
29955 - if (!model->num_virt_counters)
29956 - model->num_virt_counters = model->num_counters;
29957 + if (!model->num_virt_counters) {
29958 + pax_open_kernel();
29959 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29960 + pax_close_kernel();
29961 + }
29962
29963 mux_init(ops);
29964
29965 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29966 index b2b9443..be58856 100644
29967 --- a/arch/x86/oprofile/op_model_amd.c
29968 +++ b/arch/x86/oprofile/op_model_amd.c
29969 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29970 num_counters = AMD64_NUM_COUNTERS;
29971 }
29972
29973 - op_amd_spec.num_counters = num_counters;
29974 - op_amd_spec.num_controls = num_counters;
29975 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29976 + pax_open_kernel();
29977 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29978 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29979 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29980 + pax_close_kernel();
29981
29982 return 0;
29983 }
29984 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29985 index d90528e..0127e2b 100644
29986 --- a/arch/x86/oprofile/op_model_ppro.c
29987 +++ b/arch/x86/oprofile/op_model_ppro.c
29988 @@ -19,6 +19,7 @@
29989 #include <asm/msr.h>
29990 #include <asm/apic.h>
29991 #include <asm/nmi.h>
29992 +#include <asm/pgtable.h>
29993
29994 #include "op_x86_model.h"
29995 #include "op_counter.h"
29996 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29997
29998 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29999
30000 - op_arch_perfmon_spec.num_counters = num_counters;
30001 - op_arch_perfmon_spec.num_controls = num_counters;
30002 + pax_open_kernel();
30003 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30004 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30005 + pax_close_kernel();
30006 }
30007
30008 static int arch_perfmon_init(struct oprofile_operations *ignore)
30009 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30010 index 71e8a67..6a313bb 100644
30011 --- a/arch/x86/oprofile/op_x86_model.h
30012 +++ b/arch/x86/oprofile/op_x86_model.h
30013 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30014 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30015 struct op_msrs const * const msrs);
30016 #endif
30017 -};
30018 +} __do_const;
30019
30020 struct op_counter_config;
30021
30022 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30023 index e9e6ed5..e47ae67 100644
30024 --- a/arch/x86/pci/amd_bus.c
30025 +++ b/arch/x86/pci/amd_bus.c
30026 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30027 return NOTIFY_OK;
30028 }
30029
30030 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30031 +static struct notifier_block amd_cpu_notifier = {
30032 .notifier_call = amd_cpu_notify,
30033 };
30034
30035 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30036 index 372e9b8..e775a6c 100644
30037 --- a/arch/x86/pci/irq.c
30038 +++ b/arch/x86/pci/irq.c
30039 @@ -50,7 +50,7 @@ struct irq_router {
30040 struct irq_router_handler {
30041 u16 vendor;
30042 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30043 -};
30044 +} __do_const;
30045
30046 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30047 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30048 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30049 return 0;
30050 }
30051
30052 -static __initdata struct irq_router_handler pirq_routers[] = {
30053 +static __initconst const struct irq_router_handler pirq_routers[] = {
30054 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30055 { PCI_VENDOR_ID_AL, ali_router_probe },
30056 { PCI_VENDOR_ID_ITE, ite_router_probe },
30057 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30058 static void __init pirq_find_router(struct irq_router *r)
30059 {
30060 struct irq_routing_table *rt = pirq_table;
30061 - struct irq_router_handler *h;
30062 + const struct irq_router_handler *h;
30063
30064 #ifdef CONFIG_PCI_BIOS
30065 if (!rt->signature) {
30066 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30067 return 0;
30068 }
30069
30070 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30071 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30072 {
30073 .callback = fix_broken_hp_bios_irq9,
30074 .ident = "HP Pavilion N5400 Series Laptop",
30075 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30076 index 6eb18c4..20d83de 100644
30077 --- a/arch/x86/pci/mrst.c
30078 +++ b/arch/x86/pci/mrst.c
30079 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30080 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30081 pci_mmcfg_late_init();
30082 pcibios_enable_irq = mrst_pci_irq_enable;
30083 - pci_root_ops = pci_mrst_ops;
30084 + pax_open_kernel();
30085 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30086 + pax_close_kernel();
30087 pci_soc_mode = 1;
30088 /* Continue with standard init */
30089 return 1;
30090 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30091 index c77b24a..c979855 100644
30092 --- a/arch/x86/pci/pcbios.c
30093 +++ b/arch/x86/pci/pcbios.c
30094 @@ -79,7 +79,7 @@ union bios32 {
30095 static struct {
30096 unsigned long address;
30097 unsigned short segment;
30098 -} bios32_indirect = { 0, __KERNEL_CS };
30099 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30100
30101 /*
30102 * Returns the entry point for the given service, NULL on error
30103 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30104 unsigned long length; /* %ecx */
30105 unsigned long entry; /* %edx */
30106 unsigned long flags;
30107 + struct desc_struct d, *gdt;
30108
30109 local_irq_save(flags);
30110 - __asm__("lcall *(%%edi); cld"
30111 +
30112 + gdt = get_cpu_gdt_table(smp_processor_id());
30113 +
30114 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30115 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30116 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30117 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30118 +
30119 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30120 : "=a" (return_code),
30121 "=b" (address),
30122 "=c" (length),
30123 "=d" (entry)
30124 : "0" (service),
30125 "1" (0),
30126 - "D" (&bios32_indirect));
30127 + "D" (&bios32_indirect),
30128 + "r"(__PCIBIOS_DS)
30129 + : "memory");
30130 +
30131 + pax_open_kernel();
30132 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30133 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30134 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30135 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30136 + pax_close_kernel();
30137 +
30138 local_irq_restore(flags);
30139
30140 switch (return_code) {
30141 - case 0:
30142 - return address + entry;
30143 - case 0x80: /* Not present */
30144 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30145 - return 0;
30146 - default: /* Shouldn't happen */
30147 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30148 - service, return_code);
30149 + case 0: {
30150 + int cpu;
30151 + unsigned char flags;
30152 +
30153 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30154 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30155 + printk(KERN_WARNING "bios32_service: not valid\n");
30156 return 0;
30157 + }
30158 + address = address + PAGE_OFFSET;
30159 + length += 16UL; /* some BIOSs underreport this... */
30160 + flags = 4;
30161 + if (length >= 64*1024*1024) {
30162 + length >>= PAGE_SHIFT;
30163 + flags |= 8;
30164 + }
30165 +
30166 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30167 + gdt = get_cpu_gdt_table(cpu);
30168 + pack_descriptor(&d, address, length, 0x9b, flags);
30169 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30170 + pack_descriptor(&d, address, length, 0x93, flags);
30171 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30172 + }
30173 + return entry;
30174 + }
30175 + case 0x80: /* Not present */
30176 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30177 + return 0;
30178 + default: /* Shouldn't happen */
30179 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30180 + service, return_code);
30181 + return 0;
30182 }
30183 }
30184
30185 static struct {
30186 unsigned long address;
30187 unsigned short segment;
30188 -} pci_indirect = { 0, __KERNEL_CS };
30189 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30190
30191 -static int pci_bios_present;
30192 +static int pci_bios_present __read_only;
30193
30194 static int check_pcibios(void)
30195 {
30196 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30197 unsigned long flags, pcibios_entry;
30198
30199 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30200 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30201 + pci_indirect.address = pcibios_entry;
30202
30203 local_irq_save(flags);
30204 - __asm__(
30205 - "lcall *(%%edi); cld\n\t"
30206 + __asm__("movw %w6, %%ds\n\t"
30207 + "lcall *%%ss:(%%edi); cld\n\t"
30208 + "push %%ss\n\t"
30209 + "pop %%ds\n\t"
30210 "jc 1f\n\t"
30211 "xor %%ah, %%ah\n"
30212 "1:"
30213 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30214 "=b" (ebx),
30215 "=c" (ecx)
30216 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30217 - "D" (&pci_indirect)
30218 + "D" (&pci_indirect),
30219 + "r" (__PCIBIOS_DS)
30220 : "memory");
30221 local_irq_restore(flags);
30222
30223 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30224
30225 switch (len) {
30226 case 1:
30227 - __asm__("lcall *(%%esi); cld\n\t"
30228 + __asm__("movw %w6, %%ds\n\t"
30229 + "lcall *%%ss:(%%esi); cld\n\t"
30230 + "push %%ss\n\t"
30231 + "pop %%ds\n\t"
30232 "jc 1f\n\t"
30233 "xor %%ah, %%ah\n"
30234 "1:"
30235 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30236 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30237 "b" (bx),
30238 "D" ((long)reg),
30239 - "S" (&pci_indirect));
30240 + "S" (&pci_indirect),
30241 + "r" (__PCIBIOS_DS));
30242 /*
30243 * Zero-extend the result beyond 8 bits, do not trust the
30244 * BIOS having done it:
30245 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30246 *value &= 0xff;
30247 break;
30248 case 2:
30249 - __asm__("lcall *(%%esi); cld\n\t"
30250 + __asm__("movw %w6, %%ds\n\t"
30251 + "lcall *%%ss:(%%esi); cld\n\t"
30252 + "push %%ss\n\t"
30253 + "pop %%ds\n\t"
30254 "jc 1f\n\t"
30255 "xor %%ah, %%ah\n"
30256 "1:"
30257 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30258 : "1" (PCIBIOS_READ_CONFIG_WORD),
30259 "b" (bx),
30260 "D" ((long)reg),
30261 - "S" (&pci_indirect));
30262 + "S" (&pci_indirect),
30263 + "r" (__PCIBIOS_DS));
30264 /*
30265 * Zero-extend the result beyond 16 bits, do not trust the
30266 * BIOS having done it:
30267 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30268 *value &= 0xffff;
30269 break;
30270 case 4:
30271 - __asm__("lcall *(%%esi); cld\n\t"
30272 + __asm__("movw %w6, %%ds\n\t"
30273 + "lcall *%%ss:(%%esi); cld\n\t"
30274 + "push %%ss\n\t"
30275 + "pop %%ds\n\t"
30276 "jc 1f\n\t"
30277 "xor %%ah, %%ah\n"
30278 "1:"
30279 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30280 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30281 "b" (bx),
30282 "D" ((long)reg),
30283 - "S" (&pci_indirect));
30284 + "S" (&pci_indirect),
30285 + "r" (__PCIBIOS_DS));
30286 break;
30287 }
30288
30289 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30290
30291 switch (len) {
30292 case 1:
30293 - __asm__("lcall *(%%esi); cld\n\t"
30294 + __asm__("movw %w6, %%ds\n\t"
30295 + "lcall *%%ss:(%%esi); cld\n\t"
30296 + "push %%ss\n\t"
30297 + "pop %%ds\n\t"
30298 "jc 1f\n\t"
30299 "xor %%ah, %%ah\n"
30300 "1:"
30301 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30302 "c" (value),
30303 "b" (bx),
30304 "D" ((long)reg),
30305 - "S" (&pci_indirect));
30306 + "S" (&pci_indirect),
30307 + "r" (__PCIBIOS_DS));
30308 break;
30309 case 2:
30310 - __asm__("lcall *(%%esi); cld\n\t"
30311 + __asm__("movw %w6, %%ds\n\t"
30312 + "lcall *%%ss:(%%esi); cld\n\t"
30313 + "push %%ss\n\t"
30314 + "pop %%ds\n\t"
30315 "jc 1f\n\t"
30316 "xor %%ah, %%ah\n"
30317 "1:"
30318 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30319 "c" (value),
30320 "b" (bx),
30321 "D" ((long)reg),
30322 - "S" (&pci_indirect));
30323 + "S" (&pci_indirect),
30324 + "r" (__PCIBIOS_DS));
30325 break;
30326 case 4:
30327 - __asm__("lcall *(%%esi); cld\n\t"
30328 + __asm__("movw %w6, %%ds\n\t"
30329 + "lcall *%%ss:(%%esi); cld\n\t"
30330 + "push %%ss\n\t"
30331 + "pop %%ds\n\t"
30332 "jc 1f\n\t"
30333 "xor %%ah, %%ah\n"
30334 "1:"
30335 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30336 "c" (value),
30337 "b" (bx),
30338 "D" ((long)reg),
30339 - "S" (&pci_indirect));
30340 + "S" (&pci_indirect),
30341 + "r" (__PCIBIOS_DS));
30342 break;
30343 }
30344
30345 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30346
30347 DBG("PCI: Fetching IRQ routing table... ");
30348 __asm__("push %%es\n\t"
30349 + "movw %w8, %%ds\n\t"
30350 "push %%ds\n\t"
30351 "pop %%es\n\t"
30352 - "lcall *(%%esi); cld\n\t"
30353 + "lcall *%%ss:(%%esi); cld\n\t"
30354 "pop %%es\n\t"
30355 + "push %%ss\n\t"
30356 + "pop %%ds\n"
30357 "jc 1f\n\t"
30358 "xor %%ah, %%ah\n"
30359 "1:"
30360 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30361 "1" (0),
30362 "D" ((long) &opt),
30363 "S" (&pci_indirect),
30364 - "m" (opt)
30365 + "m" (opt),
30366 + "r" (__PCIBIOS_DS)
30367 : "memory");
30368 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30369 if (ret & 0xff00)
30370 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30371 {
30372 int ret;
30373
30374 - __asm__("lcall *(%%esi); cld\n\t"
30375 + __asm__("movw %w5, %%ds\n\t"
30376 + "lcall *%%ss:(%%esi); cld\n\t"
30377 + "push %%ss\n\t"
30378 + "pop %%ds\n"
30379 "jc 1f\n\t"
30380 "xor %%ah, %%ah\n"
30381 "1:"
30382 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30383 : "0" (PCIBIOS_SET_PCI_HW_INT),
30384 "b" ((dev->bus->number << 8) | dev->devfn),
30385 "c" ((irq << 8) | (pin + 10)),
30386 - "S" (&pci_indirect));
30387 + "S" (&pci_indirect),
30388 + "r" (__PCIBIOS_DS));
30389 return !(ret & 0xff00);
30390 }
30391 EXPORT_SYMBOL(pcibios_set_irq_routing);
30392 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30393 index 40e4469..1ab536e 100644
30394 --- a/arch/x86/platform/efi/efi_32.c
30395 +++ b/arch/x86/platform/efi/efi_32.c
30396 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30397 {
30398 struct desc_ptr gdt_descr;
30399
30400 +#ifdef CONFIG_PAX_KERNEXEC
30401 + struct desc_struct d;
30402 +#endif
30403 +
30404 local_irq_save(efi_rt_eflags);
30405
30406 load_cr3(initial_page_table);
30407 __flush_tlb_all();
30408
30409 +#ifdef CONFIG_PAX_KERNEXEC
30410 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30411 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30412 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30413 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30414 +#endif
30415 +
30416 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30417 gdt_descr.size = GDT_SIZE - 1;
30418 load_gdt(&gdt_descr);
30419 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30420 {
30421 struct desc_ptr gdt_descr;
30422
30423 +#ifdef CONFIG_PAX_KERNEXEC
30424 + struct desc_struct d;
30425 +
30426 + memset(&d, 0, sizeof d);
30427 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30428 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30429 +#endif
30430 +
30431 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30432 gdt_descr.size = GDT_SIZE - 1;
30433 load_gdt(&gdt_descr);
30434 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30435 index fbe66e6..eae5e38 100644
30436 --- a/arch/x86/platform/efi/efi_stub_32.S
30437 +++ b/arch/x86/platform/efi/efi_stub_32.S
30438 @@ -6,7 +6,9 @@
30439 */
30440
30441 #include <linux/linkage.h>
30442 +#include <linux/init.h>
30443 #include <asm/page_types.h>
30444 +#include <asm/segment.h>
30445
30446 /*
30447 * efi_call_phys(void *, ...) is a function with variable parameters.
30448 @@ -20,7 +22,7 @@
30449 * service functions will comply with gcc calling convention, too.
30450 */
30451
30452 -.text
30453 +__INIT
30454 ENTRY(efi_call_phys)
30455 /*
30456 * 0. The function can only be called in Linux kernel. So CS has been
30457 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30458 * The mapping of lower virtual memory has been created in prelog and
30459 * epilog.
30460 */
30461 - movl $1f, %edx
30462 - subl $__PAGE_OFFSET, %edx
30463 - jmp *%edx
30464 +#ifdef CONFIG_PAX_KERNEXEC
30465 + movl $(__KERNEXEC_EFI_DS), %edx
30466 + mov %edx, %ds
30467 + mov %edx, %es
30468 + mov %edx, %ss
30469 + addl $2f,(1f)
30470 + ljmp *(1f)
30471 +
30472 +__INITDATA
30473 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30474 +.previous
30475 +
30476 +2:
30477 + subl $2b,(1b)
30478 +#else
30479 + jmp 1f-__PAGE_OFFSET
30480 1:
30481 +#endif
30482
30483 /*
30484 * 2. Now on the top of stack is the return
30485 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30486 * parameter 2, ..., param n. To make things easy, we save the return
30487 * address of efi_call_phys in a global variable.
30488 */
30489 - popl %edx
30490 - movl %edx, saved_return_addr
30491 - /* get the function pointer into ECX*/
30492 - popl %ecx
30493 - movl %ecx, efi_rt_function_ptr
30494 - movl $2f, %edx
30495 - subl $__PAGE_OFFSET, %edx
30496 - pushl %edx
30497 + popl (saved_return_addr)
30498 + popl (efi_rt_function_ptr)
30499
30500 /*
30501 * 3. Clear PG bit in %CR0.
30502 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30503 /*
30504 * 5. Call the physical function.
30505 */
30506 - jmp *%ecx
30507 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30508
30509 -2:
30510 /*
30511 * 6. After EFI runtime service returns, control will return to
30512 * following instruction. We'd better readjust stack pointer first.
30513 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30514 movl %cr0, %edx
30515 orl $0x80000000, %edx
30516 movl %edx, %cr0
30517 - jmp 1f
30518 -1:
30519 +
30520 /*
30521 * 8. Now restore the virtual mode from flat mode by
30522 * adding EIP with PAGE_OFFSET.
30523 */
30524 - movl $1f, %edx
30525 - jmp *%edx
30526 +#ifdef CONFIG_PAX_KERNEXEC
30527 + movl $(__KERNEL_DS), %edx
30528 + mov %edx, %ds
30529 + mov %edx, %es
30530 + mov %edx, %ss
30531 + ljmp $(__KERNEL_CS),$1f
30532 +#else
30533 + jmp 1f+__PAGE_OFFSET
30534 +#endif
30535 1:
30536
30537 /*
30538 * 9. Balance the stack. And because EAX contain the return value,
30539 * we'd better not clobber it.
30540 */
30541 - leal efi_rt_function_ptr, %edx
30542 - movl (%edx), %ecx
30543 - pushl %ecx
30544 + pushl (efi_rt_function_ptr)
30545
30546 /*
30547 - * 10. Push the saved return address onto the stack and return.
30548 + * 10. Return to the saved return address.
30549 */
30550 - leal saved_return_addr, %edx
30551 - movl (%edx), %ecx
30552 - pushl %ecx
30553 - ret
30554 + jmpl *(saved_return_addr)
30555 ENDPROC(efi_call_phys)
30556 .previous
30557
30558 -.data
30559 +__INITDATA
30560 saved_return_addr:
30561 .long 0
30562 efi_rt_function_ptr:
30563 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30564 index 4c07cca..2c8427d 100644
30565 --- a/arch/x86/platform/efi/efi_stub_64.S
30566 +++ b/arch/x86/platform/efi/efi_stub_64.S
30567 @@ -7,6 +7,7 @@
30568 */
30569
30570 #include <linux/linkage.h>
30571 +#include <asm/alternative-asm.h>
30572
30573 #define SAVE_XMM \
30574 mov %rsp, %rax; \
30575 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30576 call *%rdi
30577 addq $32, %rsp
30578 RESTORE_XMM
30579 + pax_force_retaddr 0, 1
30580 ret
30581 ENDPROC(efi_call0)
30582
30583 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30584 call *%rdi
30585 addq $32, %rsp
30586 RESTORE_XMM
30587 + pax_force_retaddr 0, 1
30588 ret
30589 ENDPROC(efi_call1)
30590
30591 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30592 call *%rdi
30593 addq $32, %rsp
30594 RESTORE_XMM
30595 + pax_force_retaddr 0, 1
30596 ret
30597 ENDPROC(efi_call2)
30598
30599 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30600 call *%rdi
30601 addq $32, %rsp
30602 RESTORE_XMM
30603 + pax_force_retaddr 0, 1
30604 ret
30605 ENDPROC(efi_call3)
30606
30607 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30608 call *%rdi
30609 addq $32, %rsp
30610 RESTORE_XMM
30611 + pax_force_retaddr 0, 1
30612 ret
30613 ENDPROC(efi_call4)
30614
30615 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30616 call *%rdi
30617 addq $48, %rsp
30618 RESTORE_XMM
30619 + pax_force_retaddr 0, 1
30620 ret
30621 ENDPROC(efi_call5)
30622
30623 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30624 call *%rdi
30625 addq $48, %rsp
30626 RESTORE_XMM
30627 + pax_force_retaddr 0, 1
30628 ret
30629 ENDPROC(efi_call6)
30630 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30631 index e31bcd8..f12dc46 100644
30632 --- a/arch/x86/platform/mrst/mrst.c
30633 +++ b/arch/x86/platform/mrst/mrst.c
30634 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30635 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30636 int sfi_mrtc_num;
30637
30638 -static void mrst_power_off(void)
30639 +static __noreturn void mrst_power_off(void)
30640 {
30641 + BUG();
30642 }
30643
30644 -static void mrst_reboot(void)
30645 +static __noreturn void mrst_reboot(void)
30646 {
30647 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30648 + BUG();
30649 }
30650
30651 /* parse all the mtimer info to a static mtimer array */
30652 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30653 index d6ee929..3637cb5 100644
30654 --- a/arch/x86/platform/olpc/olpc_dt.c
30655 +++ b/arch/x86/platform/olpc/olpc_dt.c
30656 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30657 return res;
30658 }
30659
30660 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30661 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30662 .nextprop = olpc_dt_nextprop,
30663 .getproplen = olpc_dt_getproplen,
30664 .getproperty = olpc_dt_getproperty,
30665 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30666 index 3c68768..07e82b8 100644
30667 --- a/arch/x86/power/cpu.c
30668 +++ b/arch/x86/power/cpu.c
30669 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30670 static void fix_processor_context(void)
30671 {
30672 int cpu = smp_processor_id();
30673 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30674 + struct tss_struct *t = init_tss + cpu;
30675
30676 set_tss_desc(cpu, t); /*
30677 * This just modifies memory; should not be
30678 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30679 */
30680
30681 #ifdef CONFIG_X86_64
30682 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30683 -
30684 syscall_init(); /* This sets MSR_*STAR and related */
30685 #endif
30686 load_TR_desc(); /* This does ltr */
30687 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30688 index a44f457..9140171 100644
30689 --- a/arch/x86/realmode/init.c
30690 +++ b/arch/x86/realmode/init.c
30691 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30692 __va(real_mode_header->trampoline_header);
30693
30694 #ifdef CONFIG_X86_32
30695 - trampoline_header->start = __pa_symbol(startup_32_smp);
30696 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30697 +
30698 +#ifdef CONFIG_PAX_KERNEXEC
30699 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30700 +#endif
30701 +
30702 + trampoline_header->boot_cs = __BOOT_CS;
30703 trampoline_header->gdt_limit = __BOOT_DS + 7;
30704 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30705 #else
30706 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30707 *trampoline_cr4_features = read_cr4();
30708
30709 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30710 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30711 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30712 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30713 #endif
30714 }
30715 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30716 index 8869287..d577672 100644
30717 --- a/arch/x86/realmode/rm/Makefile
30718 +++ b/arch/x86/realmode/rm/Makefile
30719 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30720 $(call cc-option, -fno-unit-at-a-time)) \
30721 $(call cc-option, -fno-stack-protector) \
30722 $(call cc-option, -mpreferred-stack-boundary=2)
30723 +ifdef CONSTIFY_PLUGIN
30724 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30725 +endif
30726 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30727 GCOV_PROFILE := n
30728 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30729 index a28221d..93c40f1 100644
30730 --- a/arch/x86/realmode/rm/header.S
30731 +++ b/arch/x86/realmode/rm/header.S
30732 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30733 #endif
30734 /* APM/BIOS reboot */
30735 .long pa_machine_real_restart_asm
30736 -#ifdef CONFIG_X86_64
30737 +#ifdef CONFIG_X86_32
30738 + .long __KERNEL_CS
30739 +#else
30740 .long __KERNEL32_CS
30741 #endif
30742 END(real_mode_header)
30743 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30744 index c1b2791..f9e31c7 100644
30745 --- a/arch/x86/realmode/rm/trampoline_32.S
30746 +++ b/arch/x86/realmode/rm/trampoline_32.S
30747 @@ -25,6 +25,12 @@
30748 #include <asm/page_types.h>
30749 #include "realmode.h"
30750
30751 +#ifdef CONFIG_PAX_KERNEXEC
30752 +#define ta(X) (X)
30753 +#else
30754 +#define ta(X) (pa_ ## X)
30755 +#endif
30756 +
30757 .text
30758 .code16
30759
30760 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30761
30762 cli # We should be safe anyway
30763
30764 - movl tr_start, %eax # where we need to go
30765 -
30766 movl $0xA5A5A5A5, trampoline_status
30767 # write marker for master knows we're running
30768
30769 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30770 movw $1, %dx # protected mode (PE) bit
30771 lmsw %dx # into protected mode
30772
30773 - ljmpl $__BOOT_CS, $pa_startup_32
30774 + ljmpl *(trampoline_header)
30775
30776 .section ".text32","ax"
30777 .code32
30778 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30779 .balign 8
30780 GLOBAL(trampoline_header)
30781 tr_start: .space 4
30782 - tr_gdt_pad: .space 2
30783 + tr_boot_cs: .space 2
30784 tr_gdt: .space 6
30785 END(trampoline_header)
30786
30787 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30788 index bb360dc..3e5945f 100644
30789 --- a/arch/x86/realmode/rm/trampoline_64.S
30790 +++ b/arch/x86/realmode/rm/trampoline_64.S
30791 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30792 wrmsr
30793
30794 # Enable paging and in turn activate Long Mode
30795 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30796 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30797 movl %eax, %cr0
30798
30799 /*
30800 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30801 index 79d67bd..c7e1b90 100644
30802 --- a/arch/x86/tools/relocs.c
30803 +++ b/arch/x86/tools/relocs.c
30804 @@ -12,10 +12,13 @@
30805 #include <regex.h>
30806 #include <tools/le_byteshift.h>
30807
30808 +#include "../../../include/generated/autoconf.h"
30809 +
30810 static void die(char *fmt, ...);
30811
30812 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30813 static Elf32_Ehdr ehdr;
30814 +static Elf32_Phdr *phdr;
30815 static unsigned long reloc_count, reloc_idx;
30816 static unsigned long *relocs;
30817 static unsigned long reloc16_count, reloc16_idx;
30818 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30819 }
30820 }
30821
30822 +static void read_phdrs(FILE *fp)
30823 +{
30824 + unsigned int i;
30825 +
30826 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30827 + if (!phdr) {
30828 + die("Unable to allocate %d program headers\n",
30829 + ehdr.e_phnum);
30830 + }
30831 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30832 + die("Seek to %d failed: %s\n",
30833 + ehdr.e_phoff, strerror(errno));
30834 + }
30835 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30836 + die("Cannot read ELF program headers: %s\n",
30837 + strerror(errno));
30838 + }
30839 + for(i = 0; i < ehdr.e_phnum; i++) {
30840 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30841 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30842 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30843 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30844 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30845 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30846 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30847 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30848 + }
30849 +
30850 +}
30851 +
30852 static void read_shdrs(FILE *fp)
30853 {
30854 - int i;
30855 + unsigned int i;
30856 Elf32_Shdr shdr;
30857
30858 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30859 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30860
30861 static void read_strtabs(FILE *fp)
30862 {
30863 - int i;
30864 + unsigned int i;
30865 for (i = 0; i < ehdr.e_shnum; i++) {
30866 struct section *sec = &secs[i];
30867 if (sec->shdr.sh_type != SHT_STRTAB) {
30868 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30869
30870 static void read_symtabs(FILE *fp)
30871 {
30872 - int i,j;
30873 + unsigned int i,j;
30874 for (i = 0; i < ehdr.e_shnum; i++) {
30875 struct section *sec = &secs[i];
30876 if (sec->shdr.sh_type != SHT_SYMTAB) {
30877 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30878 }
30879
30880
30881 -static void read_relocs(FILE *fp)
30882 +static void read_relocs(FILE *fp, int use_real_mode)
30883 {
30884 - int i,j;
30885 + unsigned int i,j;
30886 + uint32_t base;
30887 +
30888 for (i = 0; i < ehdr.e_shnum; i++) {
30889 struct section *sec = &secs[i];
30890 if (sec->shdr.sh_type != SHT_REL) {
30891 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30892 die("Cannot read symbol table: %s\n",
30893 strerror(errno));
30894 }
30895 + base = 0;
30896 +
30897 +#ifdef CONFIG_X86_32
30898 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30899 + if (phdr[j].p_type != PT_LOAD )
30900 + continue;
30901 + 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)
30902 + continue;
30903 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30904 + break;
30905 + }
30906 +#endif
30907 +
30908 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30909 Elf32_Rel *rel = &sec->reltab[j];
30910 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30911 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30912 rel->r_info = elf32_to_cpu(rel->r_info);
30913 }
30914 }
30915 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30916
30917 static void print_absolute_symbols(void)
30918 {
30919 - int i;
30920 + unsigned int i;
30921 printf("Absolute symbols\n");
30922 printf(" Num: Value Size Type Bind Visibility Name\n");
30923 for (i = 0; i < ehdr.e_shnum; i++) {
30924 struct section *sec = &secs[i];
30925 char *sym_strtab;
30926 - int j;
30927 + unsigned int j;
30928
30929 if (sec->shdr.sh_type != SHT_SYMTAB) {
30930 continue;
30931 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30932
30933 static void print_absolute_relocs(void)
30934 {
30935 - int i, printed = 0;
30936 + unsigned int i, printed = 0;
30937
30938 for (i = 0; i < ehdr.e_shnum; i++) {
30939 struct section *sec = &secs[i];
30940 struct section *sec_applies, *sec_symtab;
30941 char *sym_strtab;
30942 Elf32_Sym *sh_symtab;
30943 - int j;
30944 + unsigned int j;
30945 if (sec->shdr.sh_type != SHT_REL) {
30946 continue;
30947 }
30948 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
30949 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30950 int use_real_mode)
30951 {
30952 - int i;
30953 + unsigned int i;
30954 /* Walk through the relocations */
30955 for (i = 0; i < ehdr.e_shnum; i++) {
30956 char *sym_strtab;
30957 Elf32_Sym *sh_symtab;
30958 struct section *sec_applies, *sec_symtab;
30959 - int j;
30960 + unsigned int j;
30961 struct section *sec = &secs[i];
30962
30963 if (sec->shdr.sh_type != SHT_REL) {
30964 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30965 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
30966 r_type = ELF32_R_TYPE(rel->r_info);
30967
30968 + if (!use_real_mode) {
30969 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
30970 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
30971 + continue;
30972 +
30973 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
30974 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
30975 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
30976 + continue;
30977 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
30978 + continue;
30979 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
30980 + continue;
30981 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
30982 + continue;
30983 +#endif
30984 + }
30985 +
30986 shn_abs = sym->st_shndx == SHN_ABS;
30987
30988 switch (r_type) {
30989 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
30990
30991 static void emit_relocs(int as_text, int use_real_mode)
30992 {
30993 - int i;
30994 + unsigned int i;
30995 /* Count how many relocations I have and allocate space for them. */
30996 reloc_count = 0;
30997 walk_relocs(count_reloc, use_real_mode);
30998 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
30999 fname, strerror(errno));
31000 }
31001 read_ehdr(fp);
31002 + read_phdrs(fp);
31003 read_shdrs(fp);
31004 read_strtabs(fp);
31005 read_symtabs(fp);
31006 - read_relocs(fp);
31007 + read_relocs(fp, use_real_mode);
31008 if (show_absolute_syms) {
31009 print_absolute_symbols();
31010 goto out;
31011 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31012 index fd14be1..e3c79c0 100644
31013 --- a/arch/x86/vdso/Makefile
31014 +++ b/arch/x86/vdso/Makefile
31015 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31016 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31017 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31018
31019 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31020 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31021 GCOV_PROFILE := n
31022
31023 #
31024 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31025 index 0faad64..39ef157 100644
31026 --- a/arch/x86/vdso/vdso32-setup.c
31027 +++ b/arch/x86/vdso/vdso32-setup.c
31028 @@ -25,6 +25,7 @@
31029 #include <asm/tlbflush.h>
31030 #include <asm/vdso.h>
31031 #include <asm/proto.h>
31032 +#include <asm/mman.h>
31033
31034 enum {
31035 VDSO_DISABLED = 0,
31036 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31037 void enable_sep_cpu(void)
31038 {
31039 int cpu = get_cpu();
31040 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31041 + struct tss_struct *tss = init_tss + cpu;
31042
31043 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31044 put_cpu();
31045 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31046 gate_vma.vm_start = FIXADDR_USER_START;
31047 gate_vma.vm_end = FIXADDR_USER_END;
31048 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31049 - gate_vma.vm_page_prot = __P101;
31050 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31051
31052 return 0;
31053 }
31054 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31055 if (compat)
31056 addr = VDSO_HIGH_BASE;
31057 else {
31058 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31059 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31060 if (IS_ERR_VALUE(addr)) {
31061 ret = addr;
31062 goto up_fail;
31063 }
31064 }
31065
31066 - current->mm->context.vdso = (void *)addr;
31067 + current->mm->context.vdso = addr;
31068
31069 if (compat_uses_vma || !compat) {
31070 /*
31071 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31072 }
31073
31074 current_thread_info()->sysenter_return =
31075 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31076 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31077
31078 up_fail:
31079 if (ret)
31080 - current->mm->context.vdso = NULL;
31081 + current->mm->context.vdso = 0;
31082
31083 up_write(&mm->mmap_sem);
31084
31085 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31086
31087 const char *arch_vma_name(struct vm_area_struct *vma)
31088 {
31089 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31090 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31091 return "[vdso]";
31092 +
31093 +#ifdef CONFIG_PAX_SEGMEXEC
31094 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31095 + return "[vdso]";
31096 +#endif
31097 +
31098 return NULL;
31099 }
31100
31101 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31102 * Check to see if the corresponding task was created in compat vdso
31103 * mode.
31104 */
31105 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31106 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31107 return &gate_vma;
31108 return NULL;
31109 }
31110 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31111 index 431e875..cbb23f3 100644
31112 --- a/arch/x86/vdso/vma.c
31113 +++ b/arch/x86/vdso/vma.c
31114 @@ -16,8 +16,6 @@
31115 #include <asm/vdso.h>
31116 #include <asm/page.h>
31117
31118 -unsigned int __read_mostly vdso_enabled = 1;
31119 -
31120 extern char vdso_start[], vdso_end[];
31121 extern unsigned short vdso_sync_cpuid;
31122
31123 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31124 * unaligned here as a result of stack start randomization.
31125 */
31126 addr = PAGE_ALIGN(addr);
31127 - addr = align_vdso_addr(addr);
31128
31129 return addr;
31130 }
31131 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31132 unsigned size)
31133 {
31134 struct mm_struct *mm = current->mm;
31135 - unsigned long addr;
31136 + unsigned long addr = 0;
31137 int ret;
31138
31139 - if (!vdso_enabled)
31140 - return 0;
31141 -
31142 down_write(&mm->mmap_sem);
31143 +
31144 +#ifdef CONFIG_PAX_RANDMMAP
31145 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31146 +#endif
31147 +
31148 addr = vdso_addr(mm->start_stack, size);
31149 + addr = align_vdso_addr(addr);
31150 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31151 if (IS_ERR_VALUE(addr)) {
31152 ret = addr;
31153 goto up_fail;
31154 }
31155
31156 - current->mm->context.vdso = (void *)addr;
31157 + mm->context.vdso = addr;
31158
31159 ret = install_special_mapping(mm, addr, size,
31160 VM_READ|VM_EXEC|
31161 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31162 pages);
31163 - if (ret) {
31164 - current->mm->context.vdso = NULL;
31165 - goto up_fail;
31166 - }
31167 + if (ret)
31168 + mm->context.vdso = 0;
31169
31170 up_fail:
31171 up_write(&mm->mmap_sem);
31172 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31173 vdsox32_size);
31174 }
31175 #endif
31176 -
31177 -static __init int vdso_setup(char *s)
31178 -{
31179 - vdso_enabled = simple_strtoul(s, NULL, 0);
31180 - return 0;
31181 -}
31182 -__setup("vdso=", vdso_setup);
31183 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31184 index cf95e19..17e9f50 100644
31185 --- a/arch/x86/xen/enlighten.c
31186 +++ b/arch/x86/xen/enlighten.c
31187 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31188
31189 struct shared_info xen_dummy_shared_info;
31190
31191 -void *xen_initial_gdt;
31192 -
31193 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31194 __read_mostly int xen_have_vector_callback;
31195 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31196 @@ -511,8 +509,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31197 {
31198 unsigned long va = dtr->address;
31199 unsigned int size = dtr->size + 1;
31200 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31201 - unsigned long frames[pages];
31202 + unsigned long frames[65536 / PAGE_SIZE];
31203 int f;
31204
31205 /*
31206 @@ -560,8 +557,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31207 {
31208 unsigned long va = dtr->address;
31209 unsigned int size = dtr->size + 1;
31210 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31211 - unsigned long frames[pages];
31212 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31213 int f;
31214
31215 /*
31216 @@ -569,7 +565,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31217 * 8-byte entries, or 16 4k pages..
31218 */
31219
31220 - BUG_ON(size > 65536);
31221 + BUG_ON(size > GDT_SIZE);
31222 BUG_ON(va & ~PAGE_MASK);
31223
31224 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31225 @@ -954,7 +950,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31226 return 0;
31227 }
31228
31229 -static void set_xen_basic_apic_ops(void)
31230 +static void __init set_xen_basic_apic_ops(void)
31231 {
31232 apic->read = xen_apic_read;
31233 apic->write = xen_apic_write;
31234 @@ -1260,30 +1256,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31235 #endif
31236 };
31237
31238 -static void xen_reboot(int reason)
31239 +static __noreturn void xen_reboot(int reason)
31240 {
31241 struct sched_shutdown r = { .reason = reason };
31242
31243 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31244 - BUG();
31245 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31246 + BUG();
31247 }
31248
31249 -static void xen_restart(char *msg)
31250 +static __noreturn void xen_restart(char *msg)
31251 {
31252 xen_reboot(SHUTDOWN_reboot);
31253 }
31254
31255 -static void xen_emergency_restart(void)
31256 +static __noreturn void xen_emergency_restart(void)
31257 {
31258 xen_reboot(SHUTDOWN_reboot);
31259 }
31260
31261 -static void xen_machine_halt(void)
31262 +static __noreturn void xen_machine_halt(void)
31263 {
31264 xen_reboot(SHUTDOWN_poweroff);
31265 }
31266
31267 -static void xen_machine_power_off(void)
31268 +static __noreturn void xen_machine_power_off(void)
31269 {
31270 if (pm_power_off)
31271 pm_power_off();
31272 @@ -1385,7 +1381,17 @@ asmlinkage void __init xen_start_kernel(void)
31273 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31274
31275 /* Work out if we support NX */
31276 - x86_configure_nx();
31277 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31278 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31279 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31280 + unsigned l, h;
31281 +
31282 + __supported_pte_mask |= _PAGE_NX;
31283 + rdmsr(MSR_EFER, l, h);
31284 + l |= EFER_NX;
31285 + wrmsr(MSR_EFER, l, h);
31286 + }
31287 +#endif
31288
31289 xen_setup_features();
31290
31291 @@ -1416,13 +1422,6 @@ asmlinkage void __init xen_start_kernel(void)
31292
31293 machine_ops = xen_machine_ops;
31294
31295 - /*
31296 - * The only reliable way to retain the initial address of the
31297 - * percpu gdt_page is to remember it here, so we can go and
31298 - * mark it RW later, when the initial percpu area is freed.
31299 - */
31300 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31301 -
31302 xen_smp_init();
31303
31304 #ifdef CONFIG_ACPI_NUMA
31305 @@ -1616,7 +1615,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31306 return NOTIFY_OK;
31307 }
31308
31309 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31310 +static struct notifier_block xen_hvm_cpu_notifier = {
31311 .notifier_call = xen_hvm_cpu_notify,
31312 };
31313
31314 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31315 index e006c18..b9a7d6c 100644
31316 --- a/arch/x86/xen/mmu.c
31317 +++ b/arch/x86/xen/mmu.c
31318 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31319 /* L3_k[510] -> level2_kernel_pgt
31320 * L3_i[511] -> level2_fixmap_pgt */
31321 convert_pfn_mfn(level3_kernel_pgt);
31322 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31323 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31324 + convert_pfn_mfn(level3_vmemmap_pgt);
31325
31326 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31327 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31328 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31329 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31330 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31331 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31332 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31333 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31334 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31335 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31336 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31337 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31338 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31339 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31340
31341 @@ -2110,6 +2117,7 @@ static void __init xen_post_allocator_init(void)
31342 pv_mmu_ops.set_pud = xen_set_pud;
31343 #if PAGETABLE_LEVELS == 4
31344 pv_mmu_ops.set_pgd = xen_set_pgd;
31345 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31346 #endif
31347
31348 /* This will work as long as patching hasn't happened yet
31349 @@ -2188,6 +2196,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31350 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31351 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31352 .set_pgd = xen_set_pgd_hyper,
31353 + .set_pgd_batched = xen_set_pgd_hyper,
31354
31355 .alloc_pud = xen_alloc_pmd_init,
31356 .release_pud = xen_release_pmd_init,
31357 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31358 index 96c4e85..284fded 100644
31359 --- a/arch/x86/xen/smp.c
31360 +++ b/arch/x86/xen/smp.c
31361 @@ -230,11 +230,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31362 {
31363 BUG_ON(smp_processor_id() != 0);
31364 native_smp_prepare_boot_cpu();
31365 -
31366 - /* We've switched to the "real" per-cpu gdt, so make sure the
31367 - old memory can be recycled */
31368 - make_lowmem_page_readwrite(xen_initial_gdt);
31369 -
31370 xen_filter_cpu_maps();
31371 xen_setup_vcpu_info_placement();
31372 }
31373 @@ -304,7 +299,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31374 ctxt->user_regs.ss = __KERNEL_DS;
31375 #ifdef CONFIG_X86_32
31376 ctxt->user_regs.fs = __KERNEL_PERCPU;
31377 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31378 + savesegment(gs, ctxt->user_regs.gs);
31379 #else
31380 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31381 #endif
31382 @@ -314,8 +309,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31383
31384 {
31385 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31386 - ctxt->user_regs.ds = __USER_DS;
31387 - ctxt->user_regs.es = __USER_DS;
31388 + ctxt->user_regs.ds = __KERNEL_DS;
31389 + ctxt->user_regs.es = __KERNEL_DS;
31390
31391 xen_copy_trap_info(ctxt->trap_ctxt);
31392
31393 @@ -360,13 +355,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31394 int rc;
31395
31396 per_cpu(current_task, cpu) = idle;
31397 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31398 #ifdef CONFIG_X86_32
31399 irq_ctx_init(cpu);
31400 #else
31401 clear_tsk_thread_flag(idle, TIF_FORK);
31402 - per_cpu(kernel_stack, cpu) =
31403 - (unsigned long)task_stack_page(idle) -
31404 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31405 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31406 #endif
31407 xen_setup_runstate_info(cpu);
31408 xen_setup_timer(cpu);
31409 @@ -642,7 +636,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31410
31411 void __init xen_smp_init(void)
31412 {
31413 - smp_ops = xen_smp_ops;
31414 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31415 xen_fill_possible_map();
31416 xen_init_spinlocks();
31417 }
31418 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31419 index 33ca6e4..0ded929 100644
31420 --- a/arch/x86/xen/xen-asm_32.S
31421 +++ b/arch/x86/xen/xen-asm_32.S
31422 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31423 ESP_OFFSET=4 # bytes pushed onto stack
31424
31425 /*
31426 - * Store vcpu_info pointer for easy access. Do it this way to
31427 - * avoid having to reload %fs
31428 + * Store vcpu_info pointer for easy access.
31429 */
31430 #ifdef CONFIG_SMP
31431 - GET_THREAD_INFO(%eax)
31432 - movl %ss:TI_cpu(%eax), %eax
31433 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31434 - mov %ss:xen_vcpu(%eax), %eax
31435 + push %fs
31436 + mov $(__KERNEL_PERCPU), %eax
31437 + mov %eax, %fs
31438 + mov PER_CPU_VAR(xen_vcpu), %eax
31439 + pop %fs
31440 #else
31441 movl %ss:xen_vcpu, %eax
31442 #endif
31443 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31444 index 7faed58..ba4427c 100644
31445 --- a/arch/x86/xen/xen-head.S
31446 +++ b/arch/x86/xen/xen-head.S
31447 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31448 #ifdef CONFIG_X86_32
31449 mov %esi,xen_start_info
31450 mov $init_thread_union+THREAD_SIZE,%esp
31451 +#ifdef CONFIG_SMP
31452 + movl $cpu_gdt_table,%edi
31453 + movl $__per_cpu_load,%eax
31454 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31455 + rorl $16,%eax
31456 + movb %al,__KERNEL_PERCPU + 4(%edi)
31457 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31458 + movl $__per_cpu_end - 1,%eax
31459 + subl $__per_cpu_start,%eax
31460 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31461 +#endif
31462 #else
31463 mov %rsi,xen_start_info
31464 mov $init_thread_union+THREAD_SIZE,%rsp
31465 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31466 index a95b417..b6dbd0b 100644
31467 --- a/arch/x86/xen/xen-ops.h
31468 +++ b/arch/x86/xen/xen-ops.h
31469 @@ -10,8 +10,6 @@
31470 extern const char xen_hypervisor_callback[];
31471 extern const char xen_failsafe_callback[];
31472
31473 -extern void *xen_initial_gdt;
31474 -
31475 struct trap_info;
31476 void xen_copy_trap_info(struct trap_info *traps);
31477
31478 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31479 index 525bd3d..ef888b1 100644
31480 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31481 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31482 @@ -119,9 +119,9 @@
31483 ----------------------------------------------------------------------*/
31484
31485 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31486 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31487 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31488 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31489 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31490
31491 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31492 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31493 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31494 index 2f33760..835e50a 100644
31495 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31496 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31497 @@ -11,6 +11,7 @@
31498 #ifndef _XTENSA_CORE_H
31499 #define _XTENSA_CORE_H
31500
31501 +#include <linux/const.h>
31502
31503 /****************************************************************************
31504 Parameters Useful for Any Code, USER or PRIVILEGED
31505 @@ -112,9 +113,9 @@
31506 ----------------------------------------------------------------------*/
31507
31508 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31509 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31510 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31511 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31512 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31513
31514 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31515 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31516 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31517 index af00795..2bb8105 100644
31518 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31519 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31520 @@ -11,6 +11,7 @@
31521 #ifndef _XTENSA_CORE_CONFIGURATION_H
31522 #define _XTENSA_CORE_CONFIGURATION_H
31523
31524 +#include <linux/const.h>
31525
31526 /****************************************************************************
31527 Parameters Useful for Any Code, USER or PRIVILEGED
31528 @@ -118,9 +119,9 @@
31529 ----------------------------------------------------------------------*/
31530
31531 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31532 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31533 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31534 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31535 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31536
31537 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31538 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31539 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31540 index 58916af..eb9dbcf6 100644
31541 --- a/block/blk-iopoll.c
31542 +++ b/block/blk-iopoll.c
31543 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31544 }
31545 EXPORT_SYMBOL(blk_iopoll_complete);
31546
31547 -static void blk_iopoll_softirq(struct softirq_action *h)
31548 +static void blk_iopoll_softirq(void)
31549 {
31550 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31551 int rearm = 0, budget = blk_iopoll_budget;
31552 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31553 return NOTIFY_OK;
31554 }
31555
31556 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31557 +static struct notifier_block blk_iopoll_cpu_notifier = {
31558 .notifier_call = blk_iopoll_cpu_notify,
31559 };
31560
31561 diff --git a/block/blk-map.c b/block/blk-map.c
31562 index 623e1cd..ca1e109 100644
31563 --- a/block/blk-map.c
31564 +++ b/block/blk-map.c
31565 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31566 if (!len || !kbuf)
31567 return -EINVAL;
31568
31569 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31570 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31571 if (do_copy)
31572 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31573 else
31574 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31575 index 467c8de..f3628c5 100644
31576 --- a/block/blk-softirq.c
31577 +++ b/block/blk-softirq.c
31578 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31579 * Softirq action handler - move entries to local list and loop over them
31580 * while passing them to the queue registered handler.
31581 */
31582 -static void blk_done_softirq(struct softirq_action *h)
31583 +static void blk_done_softirq(void)
31584 {
31585 struct list_head *cpu_list, local_list;
31586
31587 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31588 return NOTIFY_OK;
31589 }
31590
31591 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31592 +static struct notifier_block blk_cpu_notifier = {
31593 .notifier_call = blk_cpu_notify,
31594 };
31595
31596 diff --git a/block/bsg.c b/block/bsg.c
31597 index 420a5a9..23834aa 100644
31598 --- a/block/bsg.c
31599 +++ b/block/bsg.c
31600 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31601 struct sg_io_v4 *hdr, struct bsg_device *bd,
31602 fmode_t has_write_perm)
31603 {
31604 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31605 + unsigned char *cmdptr;
31606 +
31607 if (hdr->request_len > BLK_MAX_CDB) {
31608 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31609 if (!rq->cmd)
31610 return -ENOMEM;
31611 - }
31612 + cmdptr = rq->cmd;
31613 + } else
31614 + cmdptr = tmpcmd;
31615
31616 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31617 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31618 hdr->request_len))
31619 return -EFAULT;
31620
31621 + if (cmdptr != rq->cmd)
31622 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31623 +
31624 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31625 if (blk_verify_command(rq->cmd, has_write_perm))
31626 return -EPERM;
31627 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31628 index 7c668c8..db3521c 100644
31629 --- a/block/compat_ioctl.c
31630 +++ b/block/compat_ioctl.c
31631 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31632 err |= __get_user(f->spec1, &uf->spec1);
31633 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31634 err |= __get_user(name, &uf->name);
31635 - f->name = compat_ptr(name);
31636 + f->name = (void __force_kernel *)compat_ptr(name);
31637 if (err) {
31638 err = -EFAULT;
31639 goto out;
31640 diff --git a/block/genhd.c b/block/genhd.c
31641 index 3c001fb..d15a9e8 100644
31642 --- a/block/genhd.c
31643 +++ b/block/genhd.c
31644 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
31645
31646 /*
31647 * Register device numbers dev..(dev+range-1)
31648 - * range must be nonzero
31649 + * Noop if @range is zero.
31650 * The hash chain is sorted on range, so that subranges can override.
31651 */
31652 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
31653 struct kobject *(*probe)(dev_t, int *, void *),
31654 int (*lock)(dev_t, void *), void *data)
31655 {
31656 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
31657 + if (range)
31658 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
31659 }
31660
31661 EXPORT_SYMBOL(blk_register_region);
31662
31663 +/* undo blk_register_region(), noop if @range is zero */
31664 void blk_unregister_region(dev_t devt, unsigned long range)
31665 {
31666 - kobj_unmap(bdev_map, devt, range);
31667 + if (range)
31668 + kobj_unmap(bdev_map, devt, range);
31669 }
31670
31671 EXPORT_SYMBOL(blk_unregister_region);
31672 @@ -512,7 +515,7 @@ static void register_disk(struct gendisk *disk)
31673
31674 ddev->parent = disk->driverfs_dev;
31675
31676 - dev_set_name(ddev, disk->disk_name);
31677 + dev_set_name(ddev, "%s", disk->disk_name);
31678
31679 /* delay uevents, until we scanned partition table */
31680 dev_set_uevent_suppress(ddev, 1);
31681 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31682 index ff5804e..a88acad 100644
31683 --- a/block/partitions/efi.c
31684 +++ b/block/partitions/efi.c
31685 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31686 if (!gpt)
31687 return NULL;
31688
31689 + if (!le32_to_cpu(gpt->num_partition_entries))
31690 + return NULL;
31691 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31692 + if (!pte)
31693 + return NULL;
31694 +
31695 count = le32_to_cpu(gpt->num_partition_entries) *
31696 le32_to_cpu(gpt->sizeof_partition_entry);
31697 - if (!count)
31698 - return NULL;
31699 - pte = kzalloc(count, GFP_KERNEL);
31700 - if (!pte)
31701 - return NULL;
31702 -
31703 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31704 (u8 *) pte,
31705 count) < count) {
31706 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31707 index 9a87daa..fb17486 100644
31708 --- a/block/scsi_ioctl.c
31709 +++ b/block/scsi_ioctl.c
31710 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31711 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31712 struct sg_io_hdr *hdr, fmode_t mode)
31713 {
31714 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31715 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31716 + unsigned char *cmdptr;
31717 +
31718 + if (rq->cmd != rq->__cmd)
31719 + cmdptr = rq->cmd;
31720 + else
31721 + cmdptr = tmpcmd;
31722 +
31723 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31724 return -EFAULT;
31725 +
31726 + if (cmdptr != rq->cmd)
31727 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31728 +
31729 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31730 return -EPERM;
31731
31732 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31733 int err;
31734 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31735 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31736 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31737 + unsigned char *cmdptr;
31738
31739 if (!sic)
31740 return -EINVAL;
31741 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31742 */
31743 err = -EFAULT;
31744 rq->cmd_len = cmdlen;
31745 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31746 +
31747 + if (rq->cmd != rq->__cmd)
31748 + cmdptr = rq->cmd;
31749 + else
31750 + cmdptr = tmpcmd;
31751 +
31752 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31753 goto error;
31754
31755 + if (rq->cmd != cmdptr)
31756 + memcpy(rq->cmd, cmdptr, cmdlen);
31757 +
31758 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31759 goto error;
31760
31761 diff --git a/crypto/algapi.c b/crypto/algapi.c
31762 index 6149a6e..55ed50d 100644
31763 --- a/crypto/algapi.c
31764 +++ b/crypto/algapi.c
31765 @@ -495,7 +495,7 @@ static struct crypto_template *__crypto_lookup_template(const char *name)
31766
31767 struct crypto_template *crypto_lookup_template(const char *name)
31768 {
31769 - return try_then_request_module(__crypto_lookup_template(name), name);
31770 + return try_then_request_module(__crypto_lookup_template(name), "%s", name);
31771 }
31772 EXPORT_SYMBOL_GPL(crypto_lookup_template);
31773
31774 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31775 index 7bdd61b..afec999 100644
31776 --- a/crypto/cryptd.c
31777 +++ b/crypto/cryptd.c
31778 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31779
31780 struct cryptd_blkcipher_request_ctx {
31781 crypto_completion_t complete;
31782 -};
31783 +} __no_const;
31784
31785 struct cryptd_hash_ctx {
31786 struct crypto_shash *child;
31787 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31788
31789 struct cryptd_aead_request_ctx {
31790 crypto_completion_t complete;
31791 -};
31792 +} __no_const;
31793
31794 static void cryptd_queue_worker(struct work_struct *work);
31795
31796 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
31797 index b2c99dc..476c9fb 100644
31798 --- a/crypto/pcrypt.c
31799 +++ b/crypto/pcrypt.c
31800 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
31801 int ret;
31802
31803 pinst->kobj.kset = pcrypt_kset;
31804 - ret = kobject_add(&pinst->kobj, NULL, name);
31805 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
31806 if (!ret)
31807 kobject_uevent(&pinst->kobj, KOBJ_ADD);
31808
31809 @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
31810
31811 get_online_cpus();
31812
31813 - pcrypt->wq = alloc_workqueue(name,
31814 - WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
31815 + pcrypt->wq = alloc_workqueue("%s",
31816 + WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1, name);
31817 if (!pcrypt->wq)
31818 goto err;
31819
31820 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31821 index f220d64..d359ad6 100644
31822 --- a/drivers/acpi/apei/apei-internal.h
31823 +++ b/drivers/acpi/apei/apei-internal.h
31824 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31825 struct apei_exec_ins_type {
31826 u32 flags;
31827 apei_exec_ins_func_t run;
31828 -};
31829 +} __do_const;
31830
31831 struct apei_exec_context {
31832 u32 ip;
31833 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31834 index fefc2ca..12a535d 100644
31835 --- a/drivers/acpi/apei/cper.c
31836 +++ b/drivers/acpi/apei/cper.c
31837 @@ -39,12 +39,12 @@
31838 */
31839 u64 cper_next_record_id(void)
31840 {
31841 - static atomic64_t seq;
31842 + static atomic64_unchecked_t seq;
31843
31844 - if (!atomic64_read(&seq))
31845 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31846 + if (!atomic64_read_unchecked(&seq))
31847 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31848
31849 - return atomic64_inc_return(&seq);
31850 + return atomic64_inc_return_unchecked(&seq);
31851 }
31852 EXPORT_SYMBOL_GPL(cper_next_record_id);
31853
31854 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31855 index be60399..778b33e8 100644
31856 --- a/drivers/acpi/bgrt.c
31857 +++ b/drivers/acpi/bgrt.c
31858 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31859 return -ENODEV;
31860
31861 sysfs_bin_attr_init(&image_attr);
31862 - image_attr.private = bgrt_image;
31863 - image_attr.size = bgrt_image_size;
31864 + pax_open_kernel();
31865 + *(void **)&image_attr.private = bgrt_image;
31866 + *(size_t *)&image_attr.size = bgrt_image_size;
31867 + pax_close_kernel();
31868
31869 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31870 if (!bgrt_kobj)
31871 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31872 index cb96296..b81293b 100644
31873 --- a/drivers/acpi/blacklist.c
31874 +++ b/drivers/acpi/blacklist.c
31875 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31876 u32 is_critical_error;
31877 };
31878
31879 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31880 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31881
31882 /*
31883 * POLICY: If *anything* doesn't work, put it on the blacklist.
31884 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31885 return 0;
31886 }
31887
31888 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31889 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31890 {
31891 .callback = dmi_disable_osi_vista,
31892 .ident = "Fujitsu Siemens",
31893 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31894 index 7586544..636a2f0 100644
31895 --- a/drivers/acpi/ec_sys.c
31896 +++ b/drivers/acpi/ec_sys.c
31897 @@ -12,6 +12,7 @@
31898 #include <linux/acpi.h>
31899 #include <linux/debugfs.h>
31900 #include <linux/module.h>
31901 +#include <linux/uaccess.h>
31902 #include "internal.h"
31903
31904 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31905 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31906 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31907 */
31908 unsigned int size = EC_SPACE_SIZE;
31909 - u8 *data = (u8 *) buf;
31910 + u8 data;
31911 loff_t init_off = *off;
31912 int err = 0;
31913
31914 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31915 size = count;
31916
31917 while (size) {
31918 - err = ec_read(*off, &data[*off - init_off]);
31919 + err = ec_read(*off, &data);
31920 if (err)
31921 return err;
31922 + if (put_user(data, &buf[*off - init_off]))
31923 + return -EFAULT;
31924 *off += 1;
31925 size--;
31926 }
31927 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31928
31929 unsigned int size = count;
31930 loff_t init_off = *off;
31931 - u8 *data = (u8 *) buf;
31932 int err = 0;
31933
31934 if (*off >= EC_SPACE_SIZE)
31935 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31936 }
31937
31938 while (size) {
31939 - u8 byte_write = data[*off - init_off];
31940 + u8 byte_write;
31941 + if (get_user(byte_write, &buf[*off - init_off]))
31942 + return -EFAULT;
31943 err = ec_write(*off, byte_write);
31944 if (err)
31945 return err;
31946 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31947 index ee255c6..747c68b 100644
31948 --- a/drivers/acpi/processor_idle.c
31949 +++ b/drivers/acpi/processor_idle.c
31950 @@ -986,7 +986,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31951 {
31952 int i, count = CPUIDLE_DRIVER_STATE_START;
31953 struct acpi_processor_cx *cx;
31954 - struct cpuidle_state *state;
31955 + cpuidle_state_no_const *state;
31956 struct cpuidle_driver *drv = &acpi_idle_driver;
31957
31958 if (!pr->flags.power_setup_done)
31959 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
31960 index 41c0504..f8c0836 100644
31961 --- a/drivers/acpi/sysfs.c
31962 +++ b/drivers/acpi/sysfs.c
31963 @@ -420,11 +420,11 @@ static u32 num_counters;
31964 static struct attribute **all_attrs;
31965 static u32 acpi_gpe_count;
31966
31967 -static struct attribute_group interrupt_stats_attr_group = {
31968 +static attribute_group_no_const interrupt_stats_attr_group = {
31969 .name = "interrupts",
31970 };
31971
31972 -static struct kobj_attribute *counter_attrs;
31973 +static kobj_attribute_no_const *counter_attrs;
31974
31975 static void delete_gpe_attr_array(void)
31976 {
31977 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
31978 index 34c8216..f56c828 100644
31979 --- a/drivers/ata/libahci.c
31980 +++ b/drivers/ata/libahci.c
31981 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
31982 }
31983 EXPORT_SYMBOL_GPL(ahci_kick_engine);
31984
31985 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31986 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31987 struct ata_taskfile *tf, int is_cmd, u16 flags,
31988 unsigned long timeout_msec)
31989 {
31990 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
31991 index cf15aee..e0b7078 100644
31992 --- a/drivers/ata/libata-core.c
31993 +++ b/drivers/ata/libata-core.c
31994 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
31995 struct ata_port *ap;
31996 unsigned int tag;
31997
31998 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31999 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32000 ap = qc->ap;
32001
32002 qc->flags = 0;
32003 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32004 struct ata_port *ap;
32005 struct ata_link *link;
32006
32007 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32008 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32009 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32010 ap = qc->ap;
32011 link = qc->dev->link;
32012 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32013 return;
32014
32015 spin_lock(&lock);
32016 + pax_open_kernel();
32017
32018 for (cur = ops->inherits; cur; cur = cur->inherits) {
32019 void **inherit = (void **)cur;
32020 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32021 if (IS_ERR(*pp))
32022 *pp = NULL;
32023
32024 - ops->inherits = NULL;
32025 + *(struct ata_port_operations **)&ops->inherits = NULL;
32026
32027 + pax_close_kernel();
32028 spin_unlock(&lock);
32029 }
32030
32031 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32032 index 405022d..fb70e53 100644
32033 --- a/drivers/ata/pata_arasan_cf.c
32034 +++ b/drivers/ata/pata_arasan_cf.c
32035 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32036 /* Handle platform specific quirks */
32037 if (pdata->quirk) {
32038 if (pdata->quirk & CF_BROKEN_PIO) {
32039 - ap->ops->set_piomode = NULL;
32040 + pax_open_kernel();
32041 + *(void **)&ap->ops->set_piomode = NULL;
32042 + pax_close_kernel();
32043 ap->pio_mask = 0;
32044 }
32045 if (pdata->quirk & CF_BROKEN_MWDMA)
32046 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32047 index f9b983a..887b9d8 100644
32048 --- a/drivers/atm/adummy.c
32049 +++ b/drivers/atm/adummy.c
32050 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32051 vcc->pop(vcc, skb);
32052 else
32053 dev_kfree_skb_any(skb);
32054 - atomic_inc(&vcc->stats->tx);
32055 + atomic_inc_unchecked(&vcc->stats->tx);
32056
32057 return 0;
32058 }
32059 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32060 index 77a7480d..05cde58 100644
32061 --- a/drivers/atm/ambassador.c
32062 +++ b/drivers/atm/ambassador.c
32063 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32064 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32065
32066 // VC layer stats
32067 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32068 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32069
32070 // free the descriptor
32071 kfree (tx_descr);
32072 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32073 dump_skb ("<<<", vc, skb);
32074
32075 // VC layer stats
32076 - atomic_inc(&atm_vcc->stats->rx);
32077 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32078 __net_timestamp(skb);
32079 // end of our responsibility
32080 atm_vcc->push (atm_vcc, skb);
32081 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32082 } else {
32083 PRINTK (KERN_INFO, "dropped over-size frame");
32084 // should we count this?
32085 - atomic_inc(&atm_vcc->stats->rx_drop);
32086 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32087 }
32088
32089 } else {
32090 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32091 }
32092
32093 if (check_area (skb->data, skb->len)) {
32094 - atomic_inc(&atm_vcc->stats->tx_err);
32095 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32096 return -ENOMEM; // ?
32097 }
32098
32099 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32100 index 0e3f8f9..765a7a5 100644
32101 --- a/drivers/atm/atmtcp.c
32102 +++ b/drivers/atm/atmtcp.c
32103 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32104 if (vcc->pop) vcc->pop(vcc,skb);
32105 else dev_kfree_skb(skb);
32106 if (dev_data) return 0;
32107 - atomic_inc(&vcc->stats->tx_err);
32108 + atomic_inc_unchecked(&vcc->stats->tx_err);
32109 return -ENOLINK;
32110 }
32111 size = skb->len+sizeof(struct atmtcp_hdr);
32112 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32113 if (!new_skb) {
32114 if (vcc->pop) vcc->pop(vcc,skb);
32115 else dev_kfree_skb(skb);
32116 - atomic_inc(&vcc->stats->tx_err);
32117 + atomic_inc_unchecked(&vcc->stats->tx_err);
32118 return -ENOBUFS;
32119 }
32120 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32121 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32122 if (vcc->pop) vcc->pop(vcc,skb);
32123 else dev_kfree_skb(skb);
32124 out_vcc->push(out_vcc,new_skb);
32125 - atomic_inc(&vcc->stats->tx);
32126 - atomic_inc(&out_vcc->stats->rx);
32127 + atomic_inc_unchecked(&vcc->stats->tx);
32128 + atomic_inc_unchecked(&out_vcc->stats->rx);
32129 return 0;
32130 }
32131
32132 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32133 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32134 read_unlock(&vcc_sklist_lock);
32135 if (!out_vcc) {
32136 - atomic_inc(&vcc->stats->tx_err);
32137 + atomic_inc_unchecked(&vcc->stats->tx_err);
32138 goto done;
32139 }
32140 skb_pull(skb,sizeof(struct atmtcp_hdr));
32141 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32142 __net_timestamp(new_skb);
32143 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32144 out_vcc->push(out_vcc,new_skb);
32145 - atomic_inc(&vcc->stats->tx);
32146 - atomic_inc(&out_vcc->stats->rx);
32147 + atomic_inc_unchecked(&vcc->stats->tx);
32148 + atomic_inc_unchecked(&out_vcc->stats->rx);
32149 done:
32150 if (vcc->pop) vcc->pop(vcc,skb);
32151 else dev_kfree_skb(skb);
32152 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32153 index b1955ba..b179940 100644
32154 --- a/drivers/atm/eni.c
32155 +++ b/drivers/atm/eni.c
32156 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32157 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32158 vcc->dev->number);
32159 length = 0;
32160 - atomic_inc(&vcc->stats->rx_err);
32161 + atomic_inc_unchecked(&vcc->stats->rx_err);
32162 }
32163 else {
32164 length = ATM_CELL_SIZE-1; /* no HEC */
32165 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32166 size);
32167 }
32168 eff = length = 0;
32169 - atomic_inc(&vcc->stats->rx_err);
32170 + atomic_inc_unchecked(&vcc->stats->rx_err);
32171 }
32172 else {
32173 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32174 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32175 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32176 vcc->dev->number,vcc->vci,length,size << 2,descr);
32177 length = eff = 0;
32178 - atomic_inc(&vcc->stats->rx_err);
32179 + atomic_inc_unchecked(&vcc->stats->rx_err);
32180 }
32181 }
32182 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32183 @@ -767,7 +767,7 @@ rx_dequeued++;
32184 vcc->push(vcc,skb);
32185 pushed++;
32186 }
32187 - atomic_inc(&vcc->stats->rx);
32188 + atomic_inc_unchecked(&vcc->stats->rx);
32189 }
32190 wake_up(&eni_dev->rx_wait);
32191 }
32192 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32193 PCI_DMA_TODEVICE);
32194 if (vcc->pop) vcc->pop(vcc,skb);
32195 else dev_kfree_skb_irq(skb);
32196 - atomic_inc(&vcc->stats->tx);
32197 + atomic_inc_unchecked(&vcc->stats->tx);
32198 wake_up(&eni_dev->tx_wait);
32199 dma_complete++;
32200 }
32201 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32202 index b41c948..a002b17 100644
32203 --- a/drivers/atm/firestream.c
32204 +++ b/drivers/atm/firestream.c
32205 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32206 }
32207 }
32208
32209 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32210 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32211
32212 fs_dprintk (FS_DEBUG_TXMEM, "i");
32213 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32214 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32215 #endif
32216 skb_put (skb, qe->p1 & 0xffff);
32217 ATM_SKB(skb)->vcc = atm_vcc;
32218 - atomic_inc(&atm_vcc->stats->rx);
32219 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32220 __net_timestamp(skb);
32221 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32222 atm_vcc->push (atm_vcc, skb);
32223 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32224 kfree (pe);
32225 }
32226 if (atm_vcc)
32227 - atomic_inc(&atm_vcc->stats->rx_drop);
32228 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32229 break;
32230 case 0x1f: /* Reassembly abort: no buffers. */
32231 /* Silently increment error counter. */
32232 if (atm_vcc)
32233 - atomic_inc(&atm_vcc->stats->rx_drop);
32234 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32235 break;
32236 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32237 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32238 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32239 index 204814e..cede831 100644
32240 --- a/drivers/atm/fore200e.c
32241 +++ b/drivers/atm/fore200e.c
32242 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32243 #endif
32244 /* check error condition */
32245 if (*entry->status & STATUS_ERROR)
32246 - atomic_inc(&vcc->stats->tx_err);
32247 + atomic_inc_unchecked(&vcc->stats->tx_err);
32248 else
32249 - atomic_inc(&vcc->stats->tx);
32250 + atomic_inc_unchecked(&vcc->stats->tx);
32251 }
32252 }
32253
32254 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32255 if (skb == NULL) {
32256 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32257
32258 - atomic_inc(&vcc->stats->rx_drop);
32259 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32260 return -ENOMEM;
32261 }
32262
32263 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32264
32265 dev_kfree_skb_any(skb);
32266
32267 - atomic_inc(&vcc->stats->rx_drop);
32268 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32269 return -ENOMEM;
32270 }
32271
32272 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32273
32274 vcc->push(vcc, skb);
32275 - atomic_inc(&vcc->stats->rx);
32276 + atomic_inc_unchecked(&vcc->stats->rx);
32277
32278 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32279
32280 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32281 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32282 fore200e->atm_dev->number,
32283 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32284 - atomic_inc(&vcc->stats->rx_err);
32285 + atomic_inc_unchecked(&vcc->stats->rx_err);
32286 }
32287 }
32288
32289 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32290 goto retry_here;
32291 }
32292
32293 - atomic_inc(&vcc->stats->tx_err);
32294 + atomic_inc_unchecked(&vcc->stats->tx_err);
32295
32296 fore200e->tx_sat++;
32297 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32298 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32299 index d689126..e78e412 100644
32300 --- a/drivers/atm/he.c
32301 +++ b/drivers/atm/he.c
32302 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32303
32304 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32305 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32306 - atomic_inc(&vcc->stats->rx_drop);
32307 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32308 goto return_host_buffers;
32309 }
32310
32311 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32312 RBRQ_LEN_ERR(he_dev->rbrq_head)
32313 ? "LEN_ERR" : "",
32314 vcc->vpi, vcc->vci);
32315 - atomic_inc(&vcc->stats->rx_err);
32316 + atomic_inc_unchecked(&vcc->stats->rx_err);
32317 goto return_host_buffers;
32318 }
32319
32320 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32321 vcc->push(vcc, skb);
32322 spin_lock(&he_dev->global_lock);
32323
32324 - atomic_inc(&vcc->stats->rx);
32325 + atomic_inc_unchecked(&vcc->stats->rx);
32326
32327 return_host_buffers:
32328 ++pdus_assembled;
32329 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32330 tpd->vcc->pop(tpd->vcc, tpd->skb);
32331 else
32332 dev_kfree_skb_any(tpd->skb);
32333 - atomic_inc(&tpd->vcc->stats->tx_err);
32334 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32335 }
32336 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32337 return;
32338 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32339 vcc->pop(vcc, skb);
32340 else
32341 dev_kfree_skb_any(skb);
32342 - atomic_inc(&vcc->stats->tx_err);
32343 + atomic_inc_unchecked(&vcc->stats->tx_err);
32344 return -EINVAL;
32345 }
32346
32347 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32348 vcc->pop(vcc, skb);
32349 else
32350 dev_kfree_skb_any(skb);
32351 - atomic_inc(&vcc->stats->tx_err);
32352 + atomic_inc_unchecked(&vcc->stats->tx_err);
32353 return -EINVAL;
32354 }
32355 #endif
32356 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32357 vcc->pop(vcc, skb);
32358 else
32359 dev_kfree_skb_any(skb);
32360 - atomic_inc(&vcc->stats->tx_err);
32361 + atomic_inc_unchecked(&vcc->stats->tx_err);
32362 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32363 return -ENOMEM;
32364 }
32365 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32366 vcc->pop(vcc, skb);
32367 else
32368 dev_kfree_skb_any(skb);
32369 - atomic_inc(&vcc->stats->tx_err);
32370 + atomic_inc_unchecked(&vcc->stats->tx_err);
32371 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32372 return -ENOMEM;
32373 }
32374 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32375 __enqueue_tpd(he_dev, tpd, cid);
32376 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32377
32378 - atomic_inc(&vcc->stats->tx);
32379 + atomic_inc_unchecked(&vcc->stats->tx);
32380
32381 return 0;
32382 }
32383 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32384 index 1dc0519..1aadaf7 100644
32385 --- a/drivers/atm/horizon.c
32386 +++ b/drivers/atm/horizon.c
32387 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32388 {
32389 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32390 // VC layer stats
32391 - atomic_inc(&vcc->stats->rx);
32392 + atomic_inc_unchecked(&vcc->stats->rx);
32393 __net_timestamp(skb);
32394 // end of our responsibility
32395 vcc->push (vcc, skb);
32396 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32397 dev->tx_iovec = NULL;
32398
32399 // VC layer stats
32400 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32401 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32402
32403 // free the skb
32404 hrz_kfree_skb (skb);
32405 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32406 index 272f009..a18ba55 100644
32407 --- a/drivers/atm/idt77252.c
32408 +++ b/drivers/atm/idt77252.c
32409 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32410 else
32411 dev_kfree_skb(skb);
32412
32413 - atomic_inc(&vcc->stats->tx);
32414 + atomic_inc_unchecked(&vcc->stats->tx);
32415 }
32416
32417 atomic_dec(&scq->used);
32418 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32419 if ((sb = dev_alloc_skb(64)) == NULL) {
32420 printk("%s: Can't allocate buffers for aal0.\n",
32421 card->name);
32422 - atomic_add(i, &vcc->stats->rx_drop);
32423 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32424 break;
32425 }
32426 if (!atm_charge(vcc, sb->truesize)) {
32427 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32428 card->name);
32429 - atomic_add(i - 1, &vcc->stats->rx_drop);
32430 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32431 dev_kfree_skb(sb);
32432 break;
32433 }
32434 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32435 ATM_SKB(sb)->vcc = vcc;
32436 __net_timestamp(sb);
32437 vcc->push(vcc, sb);
32438 - atomic_inc(&vcc->stats->rx);
32439 + atomic_inc_unchecked(&vcc->stats->rx);
32440
32441 cell += ATM_CELL_PAYLOAD;
32442 }
32443 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32444 "(CDC: %08x)\n",
32445 card->name, len, rpp->len, readl(SAR_REG_CDC));
32446 recycle_rx_pool_skb(card, rpp);
32447 - atomic_inc(&vcc->stats->rx_err);
32448 + atomic_inc_unchecked(&vcc->stats->rx_err);
32449 return;
32450 }
32451 if (stat & SAR_RSQE_CRC) {
32452 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32453 recycle_rx_pool_skb(card, rpp);
32454 - atomic_inc(&vcc->stats->rx_err);
32455 + atomic_inc_unchecked(&vcc->stats->rx_err);
32456 return;
32457 }
32458 if (skb_queue_len(&rpp->queue) > 1) {
32459 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32460 RXPRINTK("%s: Can't alloc RX skb.\n",
32461 card->name);
32462 recycle_rx_pool_skb(card, rpp);
32463 - atomic_inc(&vcc->stats->rx_err);
32464 + atomic_inc_unchecked(&vcc->stats->rx_err);
32465 return;
32466 }
32467 if (!atm_charge(vcc, skb->truesize)) {
32468 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32469 __net_timestamp(skb);
32470
32471 vcc->push(vcc, skb);
32472 - atomic_inc(&vcc->stats->rx);
32473 + atomic_inc_unchecked(&vcc->stats->rx);
32474
32475 return;
32476 }
32477 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32478 __net_timestamp(skb);
32479
32480 vcc->push(vcc, skb);
32481 - atomic_inc(&vcc->stats->rx);
32482 + atomic_inc_unchecked(&vcc->stats->rx);
32483
32484 if (skb->truesize > SAR_FB_SIZE_3)
32485 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32486 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32487 if (vcc->qos.aal != ATM_AAL0) {
32488 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32489 card->name, vpi, vci);
32490 - atomic_inc(&vcc->stats->rx_drop);
32491 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32492 goto drop;
32493 }
32494
32495 if ((sb = dev_alloc_skb(64)) == NULL) {
32496 printk("%s: Can't allocate buffers for AAL0.\n",
32497 card->name);
32498 - atomic_inc(&vcc->stats->rx_err);
32499 + atomic_inc_unchecked(&vcc->stats->rx_err);
32500 goto drop;
32501 }
32502
32503 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32504 ATM_SKB(sb)->vcc = vcc;
32505 __net_timestamp(sb);
32506 vcc->push(vcc, sb);
32507 - atomic_inc(&vcc->stats->rx);
32508 + atomic_inc_unchecked(&vcc->stats->rx);
32509
32510 drop:
32511 skb_pull(queue, 64);
32512 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32513
32514 if (vc == NULL) {
32515 printk("%s: NULL connection in send().\n", card->name);
32516 - atomic_inc(&vcc->stats->tx_err);
32517 + atomic_inc_unchecked(&vcc->stats->tx_err);
32518 dev_kfree_skb(skb);
32519 return -EINVAL;
32520 }
32521 if (!test_bit(VCF_TX, &vc->flags)) {
32522 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32523 - atomic_inc(&vcc->stats->tx_err);
32524 + atomic_inc_unchecked(&vcc->stats->tx_err);
32525 dev_kfree_skb(skb);
32526 return -EINVAL;
32527 }
32528 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32529 break;
32530 default:
32531 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32532 - atomic_inc(&vcc->stats->tx_err);
32533 + atomic_inc_unchecked(&vcc->stats->tx_err);
32534 dev_kfree_skb(skb);
32535 return -EINVAL;
32536 }
32537
32538 if (skb_shinfo(skb)->nr_frags != 0) {
32539 printk("%s: No scatter-gather yet.\n", card->name);
32540 - atomic_inc(&vcc->stats->tx_err);
32541 + atomic_inc_unchecked(&vcc->stats->tx_err);
32542 dev_kfree_skb(skb);
32543 return -EINVAL;
32544 }
32545 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32546
32547 err = queue_skb(card, vc, skb, oam);
32548 if (err) {
32549 - atomic_inc(&vcc->stats->tx_err);
32550 + atomic_inc_unchecked(&vcc->stats->tx_err);
32551 dev_kfree_skb(skb);
32552 return err;
32553 }
32554 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32555 skb = dev_alloc_skb(64);
32556 if (!skb) {
32557 printk("%s: Out of memory in send_oam().\n", card->name);
32558 - atomic_inc(&vcc->stats->tx_err);
32559 + atomic_inc_unchecked(&vcc->stats->tx_err);
32560 return -ENOMEM;
32561 }
32562 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32563 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32564 index 4217f29..88f547a 100644
32565 --- a/drivers/atm/iphase.c
32566 +++ b/drivers/atm/iphase.c
32567 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32568 status = (u_short) (buf_desc_ptr->desc_mode);
32569 if (status & (RX_CER | RX_PTE | RX_OFL))
32570 {
32571 - atomic_inc(&vcc->stats->rx_err);
32572 + atomic_inc_unchecked(&vcc->stats->rx_err);
32573 IF_ERR(printk("IA: bad packet, dropping it");)
32574 if (status & RX_CER) {
32575 IF_ERR(printk(" cause: packet CRC error\n");)
32576 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32577 len = dma_addr - buf_addr;
32578 if (len > iadev->rx_buf_sz) {
32579 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32580 - atomic_inc(&vcc->stats->rx_err);
32581 + atomic_inc_unchecked(&vcc->stats->rx_err);
32582 goto out_free_desc;
32583 }
32584
32585 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32586 ia_vcc = INPH_IA_VCC(vcc);
32587 if (ia_vcc == NULL)
32588 {
32589 - atomic_inc(&vcc->stats->rx_err);
32590 + atomic_inc_unchecked(&vcc->stats->rx_err);
32591 atm_return(vcc, skb->truesize);
32592 dev_kfree_skb_any(skb);
32593 goto INCR_DLE;
32594 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32595 if ((length > iadev->rx_buf_sz) || (length >
32596 (skb->len - sizeof(struct cpcs_trailer))))
32597 {
32598 - atomic_inc(&vcc->stats->rx_err);
32599 + atomic_inc_unchecked(&vcc->stats->rx_err);
32600 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32601 length, skb->len);)
32602 atm_return(vcc, skb->truesize);
32603 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32604
32605 IF_RX(printk("rx_dle_intr: skb push");)
32606 vcc->push(vcc,skb);
32607 - atomic_inc(&vcc->stats->rx);
32608 + atomic_inc_unchecked(&vcc->stats->rx);
32609 iadev->rx_pkt_cnt++;
32610 }
32611 INCR_DLE:
32612 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32613 {
32614 struct k_sonet_stats *stats;
32615 stats = &PRIV(_ia_dev[board])->sonet_stats;
32616 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32617 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32618 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32619 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32620 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32621 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32622 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32623 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32624 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32625 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32626 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32627 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32628 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32629 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32630 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32631 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32632 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32633 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32634 }
32635 ia_cmds.status = 0;
32636 break;
32637 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32638 if ((desc == 0) || (desc > iadev->num_tx_desc))
32639 {
32640 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32641 - atomic_inc(&vcc->stats->tx);
32642 + atomic_inc_unchecked(&vcc->stats->tx);
32643 if (vcc->pop)
32644 vcc->pop(vcc, skb);
32645 else
32646 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32647 ATM_DESC(skb) = vcc->vci;
32648 skb_queue_tail(&iadev->tx_dma_q, skb);
32649
32650 - atomic_inc(&vcc->stats->tx);
32651 + atomic_inc_unchecked(&vcc->stats->tx);
32652 iadev->tx_pkt_cnt++;
32653 /* Increment transaction counter */
32654 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32655
32656 #if 0
32657 /* add flow control logic */
32658 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32659 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32660 if (iavcc->vc_desc_cnt > 10) {
32661 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32662 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32663 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32664 index fa7d701..1e404c7 100644
32665 --- a/drivers/atm/lanai.c
32666 +++ b/drivers/atm/lanai.c
32667 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32668 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32669 lanai_endtx(lanai, lvcc);
32670 lanai_free_skb(lvcc->tx.atmvcc, skb);
32671 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32672 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32673 }
32674
32675 /* Try to fill the buffer - don't call unless there is backlog */
32676 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32677 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32678 __net_timestamp(skb);
32679 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32680 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32681 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32682 out:
32683 lvcc->rx.buf.ptr = end;
32684 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32685 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32686 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32687 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32688 lanai->stats.service_rxnotaal5++;
32689 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32690 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32691 return 0;
32692 }
32693 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32694 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32695 int bytes;
32696 read_unlock(&vcc_sklist_lock);
32697 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32698 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32699 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32700 lvcc->stats.x.aal5.service_trash++;
32701 bytes = (SERVICE_GET_END(s) * 16) -
32702 (((unsigned long) lvcc->rx.buf.ptr) -
32703 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32704 }
32705 if (s & SERVICE_STREAM) {
32706 read_unlock(&vcc_sklist_lock);
32707 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32708 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32709 lvcc->stats.x.aal5.service_stream++;
32710 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32711 "PDU on VCI %d!\n", lanai->number, vci);
32712 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32713 return 0;
32714 }
32715 DPRINTK("got rx crc error on vci %d\n", vci);
32716 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32717 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32718 lvcc->stats.x.aal5.service_rxcrc++;
32719 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32720 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32721 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32722 index 6587dc2..149833d 100644
32723 --- a/drivers/atm/nicstar.c
32724 +++ b/drivers/atm/nicstar.c
32725 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32726 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32727 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32728 card->index);
32729 - atomic_inc(&vcc->stats->tx_err);
32730 + atomic_inc_unchecked(&vcc->stats->tx_err);
32731 dev_kfree_skb_any(skb);
32732 return -EINVAL;
32733 }
32734 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32735 if (!vc->tx) {
32736 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32737 card->index);
32738 - atomic_inc(&vcc->stats->tx_err);
32739 + atomic_inc_unchecked(&vcc->stats->tx_err);
32740 dev_kfree_skb_any(skb);
32741 return -EINVAL;
32742 }
32743 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32744 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32745 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32746 card->index);
32747 - atomic_inc(&vcc->stats->tx_err);
32748 + atomic_inc_unchecked(&vcc->stats->tx_err);
32749 dev_kfree_skb_any(skb);
32750 return -EINVAL;
32751 }
32752
32753 if (skb_shinfo(skb)->nr_frags != 0) {
32754 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32755 - atomic_inc(&vcc->stats->tx_err);
32756 + atomic_inc_unchecked(&vcc->stats->tx_err);
32757 dev_kfree_skb_any(skb);
32758 return -EINVAL;
32759 }
32760 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32761 }
32762
32763 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32764 - atomic_inc(&vcc->stats->tx_err);
32765 + atomic_inc_unchecked(&vcc->stats->tx_err);
32766 dev_kfree_skb_any(skb);
32767 return -EIO;
32768 }
32769 - atomic_inc(&vcc->stats->tx);
32770 + atomic_inc_unchecked(&vcc->stats->tx);
32771
32772 return 0;
32773 }
32774 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32775 printk
32776 ("nicstar%d: Can't allocate buffers for aal0.\n",
32777 card->index);
32778 - atomic_add(i, &vcc->stats->rx_drop);
32779 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32780 break;
32781 }
32782 if (!atm_charge(vcc, sb->truesize)) {
32783 RXPRINTK
32784 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32785 card->index);
32786 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32787 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32788 dev_kfree_skb_any(sb);
32789 break;
32790 }
32791 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32792 ATM_SKB(sb)->vcc = vcc;
32793 __net_timestamp(sb);
32794 vcc->push(vcc, sb);
32795 - atomic_inc(&vcc->stats->rx);
32796 + atomic_inc_unchecked(&vcc->stats->rx);
32797 cell += ATM_CELL_PAYLOAD;
32798 }
32799
32800 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32801 if (iovb == NULL) {
32802 printk("nicstar%d: Out of iovec buffers.\n",
32803 card->index);
32804 - atomic_inc(&vcc->stats->rx_drop);
32805 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32806 recycle_rx_buf(card, skb);
32807 return;
32808 }
32809 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32810 small or large buffer itself. */
32811 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32812 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32813 - atomic_inc(&vcc->stats->rx_err);
32814 + atomic_inc_unchecked(&vcc->stats->rx_err);
32815 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32816 NS_MAX_IOVECS);
32817 NS_PRV_IOVCNT(iovb) = 0;
32818 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32819 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32820 card->index);
32821 which_list(card, skb);
32822 - atomic_inc(&vcc->stats->rx_err);
32823 + atomic_inc_unchecked(&vcc->stats->rx_err);
32824 recycle_rx_buf(card, skb);
32825 vc->rx_iov = NULL;
32826 recycle_iov_buf(card, iovb);
32827 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32828 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32829 card->index);
32830 which_list(card, skb);
32831 - atomic_inc(&vcc->stats->rx_err);
32832 + atomic_inc_unchecked(&vcc->stats->rx_err);
32833 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32834 NS_PRV_IOVCNT(iovb));
32835 vc->rx_iov = NULL;
32836 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32837 printk(" - PDU size mismatch.\n");
32838 else
32839 printk(".\n");
32840 - atomic_inc(&vcc->stats->rx_err);
32841 + atomic_inc_unchecked(&vcc->stats->rx_err);
32842 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32843 NS_PRV_IOVCNT(iovb));
32844 vc->rx_iov = NULL;
32845 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32846 /* skb points to a small buffer */
32847 if (!atm_charge(vcc, skb->truesize)) {
32848 push_rxbufs(card, skb);
32849 - atomic_inc(&vcc->stats->rx_drop);
32850 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32851 } else {
32852 skb_put(skb, len);
32853 dequeue_sm_buf(card, skb);
32854 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32855 ATM_SKB(skb)->vcc = vcc;
32856 __net_timestamp(skb);
32857 vcc->push(vcc, skb);
32858 - atomic_inc(&vcc->stats->rx);
32859 + atomic_inc_unchecked(&vcc->stats->rx);
32860 }
32861 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32862 struct sk_buff *sb;
32863 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32864 if (len <= NS_SMBUFSIZE) {
32865 if (!atm_charge(vcc, sb->truesize)) {
32866 push_rxbufs(card, sb);
32867 - atomic_inc(&vcc->stats->rx_drop);
32868 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32869 } else {
32870 skb_put(sb, len);
32871 dequeue_sm_buf(card, sb);
32872 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32873 ATM_SKB(sb)->vcc = vcc;
32874 __net_timestamp(sb);
32875 vcc->push(vcc, sb);
32876 - atomic_inc(&vcc->stats->rx);
32877 + atomic_inc_unchecked(&vcc->stats->rx);
32878 }
32879
32880 push_rxbufs(card, skb);
32881 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32882
32883 if (!atm_charge(vcc, skb->truesize)) {
32884 push_rxbufs(card, skb);
32885 - atomic_inc(&vcc->stats->rx_drop);
32886 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32887 } else {
32888 dequeue_lg_buf(card, skb);
32889 #ifdef NS_USE_DESTRUCTORS
32890 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32891 ATM_SKB(skb)->vcc = vcc;
32892 __net_timestamp(skb);
32893 vcc->push(vcc, skb);
32894 - atomic_inc(&vcc->stats->rx);
32895 + atomic_inc_unchecked(&vcc->stats->rx);
32896 }
32897
32898 push_rxbufs(card, sb);
32899 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32900 printk
32901 ("nicstar%d: Out of huge buffers.\n",
32902 card->index);
32903 - atomic_inc(&vcc->stats->rx_drop);
32904 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32905 recycle_iovec_rx_bufs(card,
32906 (struct iovec *)
32907 iovb->data,
32908 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32909 card->hbpool.count++;
32910 } else
32911 dev_kfree_skb_any(hb);
32912 - atomic_inc(&vcc->stats->rx_drop);
32913 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32914 } else {
32915 /* Copy the small buffer to the huge buffer */
32916 sb = (struct sk_buff *)iov->iov_base;
32917 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32918 #endif /* NS_USE_DESTRUCTORS */
32919 __net_timestamp(hb);
32920 vcc->push(vcc, hb);
32921 - atomic_inc(&vcc->stats->rx);
32922 + atomic_inc_unchecked(&vcc->stats->rx);
32923 }
32924 }
32925
32926 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32927 index 32784d1..4a8434a 100644
32928 --- a/drivers/atm/solos-pci.c
32929 +++ b/drivers/atm/solos-pci.c
32930 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32931 }
32932 atm_charge(vcc, skb->truesize);
32933 vcc->push(vcc, skb);
32934 - atomic_inc(&vcc->stats->rx);
32935 + atomic_inc_unchecked(&vcc->stats->rx);
32936 break;
32937
32938 case PKT_STATUS:
32939 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32940 vcc = SKB_CB(oldskb)->vcc;
32941
32942 if (vcc) {
32943 - atomic_inc(&vcc->stats->tx);
32944 + atomic_inc_unchecked(&vcc->stats->tx);
32945 solos_pop(vcc, oldskb);
32946 } else {
32947 dev_kfree_skb_irq(oldskb);
32948 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32949 index 0215934..ce9f5b1 100644
32950 --- a/drivers/atm/suni.c
32951 +++ b/drivers/atm/suni.c
32952 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32953
32954
32955 #define ADD_LIMITED(s,v) \
32956 - atomic_add((v),&stats->s); \
32957 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
32958 + atomic_add_unchecked((v),&stats->s); \
32959 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
32960
32961
32962 static void suni_hz(unsigned long from_timer)
32963 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
32964 index 5120a96..e2572bd 100644
32965 --- a/drivers/atm/uPD98402.c
32966 +++ b/drivers/atm/uPD98402.c
32967 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
32968 struct sonet_stats tmp;
32969 int error = 0;
32970
32971 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32972 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32973 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
32974 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
32975 if (zero && !error) {
32976 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
32977
32978
32979 #define ADD_LIMITED(s,v) \
32980 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
32981 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
32982 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32983 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
32984 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
32985 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32986
32987
32988 static void stat_event(struct atm_dev *dev)
32989 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
32990 if (reason & uPD98402_INT_PFM) stat_event(dev);
32991 if (reason & uPD98402_INT_PCO) {
32992 (void) GET(PCOCR); /* clear interrupt cause */
32993 - atomic_add(GET(HECCT),
32994 + atomic_add_unchecked(GET(HECCT),
32995 &PRIV(dev)->sonet_stats.uncorr_hcs);
32996 }
32997 if ((reason & uPD98402_INT_RFO) &&
32998 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
32999 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33000 uPD98402_INT_LOS),PIMR); /* enable them */
33001 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33002 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33003 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33004 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33005 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33006 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33007 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33008 return 0;
33009 }
33010
33011 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33012 index 969c3c2..9b72956 100644
33013 --- a/drivers/atm/zatm.c
33014 +++ b/drivers/atm/zatm.c
33015 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33016 }
33017 if (!size) {
33018 dev_kfree_skb_irq(skb);
33019 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33020 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33021 continue;
33022 }
33023 if (!atm_charge(vcc,skb->truesize)) {
33024 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33025 skb->len = size;
33026 ATM_SKB(skb)->vcc = vcc;
33027 vcc->push(vcc,skb);
33028 - atomic_inc(&vcc->stats->rx);
33029 + atomic_inc_unchecked(&vcc->stats->rx);
33030 }
33031 zout(pos & 0xffff,MTA(mbx));
33032 #if 0 /* probably a stupid idea */
33033 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33034 skb_queue_head(&zatm_vcc->backlog,skb);
33035 break;
33036 }
33037 - atomic_inc(&vcc->stats->tx);
33038 + atomic_inc_unchecked(&vcc->stats->tx);
33039 wake_up(&zatm_vcc->tx_wait);
33040 }
33041
33042 diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
33043 index d78b204..ecc1929 100644
33044 --- a/drivers/base/attribute_container.c
33045 +++ b/drivers/base/attribute_container.c
33046 @@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
33047 ic->classdev.parent = get_device(dev);
33048 ic->classdev.class = cont->class;
33049 cont->class->dev_release = attribute_container_release;
33050 - dev_set_name(&ic->classdev, dev_name(dev));
33051 + dev_set_name(&ic->classdev, "%s", dev_name(dev));
33052 if (fn)
33053 fn(cont, dev, &ic->classdev);
33054 else
33055 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33056 index 519865b..e540db3 100644
33057 --- a/drivers/base/bus.c
33058 +++ b/drivers/base/bus.c
33059 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33060 return -EINVAL;
33061
33062 mutex_lock(&subsys->p->mutex);
33063 - list_add_tail(&sif->node, &subsys->p->interfaces);
33064 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33065 if (sif->add_dev) {
33066 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33067 while ((dev = subsys_dev_iter_next(&iter)))
33068 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33069 subsys = sif->subsys;
33070
33071 mutex_lock(&subsys->p->mutex);
33072 - list_del_init(&sif->node);
33073 + pax_list_del_init((struct list_head *)&sif->node);
33074 if (sif->remove_dev) {
33075 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33076 while ((dev = subsys_dev_iter_next(&iter)))
33077 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33078 index 01fc5b0..917801f 100644
33079 --- a/drivers/base/devtmpfs.c
33080 +++ b/drivers/base/devtmpfs.c
33081 @@ -348,7 +348,7 @@ int devtmpfs_mount(const char *mntdir)
33082 if (!thread)
33083 return 0;
33084
33085 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33086 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33087 if (err)
33088 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33089 else
33090 @@ -373,11 +373,11 @@ static int devtmpfsd(void *p)
33091 *err = sys_unshare(CLONE_NEWNS);
33092 if (*err)
33093 goto out;
33094 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
33095 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
33096 if (*err)
33097 goto out;
33098 - sys_chdir("/.."); /* will traverse into overmounted root */
33099 - sys_chroot(".");
33100 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
33101 + sys_chroot((char __force_user *)".");
33102 complete(&setup_done);
33103 while (1) {
33104 spin_lock(&req_lock);
33105 diff --git a/drivers/base/node.c b/drivers/base/node.c
33106 index fac124a..66bd4ab 100644
33107 --- a/drivers/base/node.c
33108 +++ b/drivers/base/node.c
33109 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33110 struct node_attr {
33111 struct device_attribute attr;
33112 enum node_states state;
33113 -};
33114 +} __do_const;
33115
33116 static ssize_t show_node_state(struct device *dev,
33117 struct device_attribute *attr, char *buf)
33118 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33119 index 9a6b05a..2fc8fb9 100644
33120 --- a/drivers/base/power/domain.c
33121 +++ b/drivers/base/power/domain.c
33122 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33123 {
33124 struct cpuidle_driver *cpuidle_drv;
33125 struct gpd_cpu_data *cpu_data;
33126 - struct cpuidle_state *idle_state;
33127 + cpuidle_state_no_const *idle_state;
33128 int ret = 0;
33129
33130 if (IS_ERR_OR_NULL(genpd) || state < 0)
33131 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33132 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33133 {
33134 struct gpd_cpu_data *cpu_data;
33135 - struct cpuidle_state *idle_state;
33136 + cpuidle_state_no_const *idle_state;
33137 int ret = 0;
33138
33139 if (IS_ERR_OR_NULL(genpd))
33140 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
33141 index a53ebd2..8f73eeb 100644
33142 --- a/drivers/base/power/sysfs.c
33143 +++ b/drivers/base/power/sysfs.c
33144 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
33145 return -EIO;
33146 }
33147 }
33148 - return sprintf(buf, p);
33149 + return sprintf(buf, "%s", p);
33150 }
33151
33152 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
33153 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33154 index 79715e7..df06b3b 100644
33155 --- a/drivers/base/power/wakeup.c
33156 +++ b/drivers/base/power/wakeup.c
33157 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33158 * They need to be modified together atomically, so it's better to use one
33159 * atomic variable to hold them both.
33160 */
33161 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33162 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33163
33164 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33165 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33166
33167 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33168 {
33169 - unsigned int comb = atomic_read(&combined_event_count);
33170 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33171
33172 *cnt = (comb >> IN_PROGRESS_BITS);
33173 *inpr = comb & MAX_IN_PROGRESS;
33174 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33175 ws->start_prevent_time = ws->last_time;
33176
33177 /* Increment the counter of events in progress. */
33178 - cec = atomic_inc_return(&combined_event_count);
33179 + cec = atomic_inc_return_unchecked(&combined_event_count);
33180
33181 trace_wakeup_source_activate(ws->name, cec);
33182 }
33183 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33184 * Increment the counter of registered wakeup events and decrement the
33185 * couter of wakeup events in progress simultaneously.
33186 */
33187 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33188 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33189 trace_wakeup_source_deactivate(ws->name, cec);
33190
33191 split_counters(&cnt, &inpr);
33192 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33193 index e8d11b6..7b1b36f 100644
33194 --- a/drivers/base/syscore.c
33195 +++ b/drivers/base/syscore.c
33196 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33197 void register_syscore_ops(struct syscore_ops *ops)
33198 {
33199 mutex_lock(&syscore_ops_lock);
33200 - list_add_tail(&ops->node, &syscore_ops_list);
33201 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33202 mutex_unlock(&syscore_ops_lock);
33203 }
33204 EXPORT_SYMBOL_GPL(register_syscore_ops);
33205 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33206 void unregister_syscore_ops(struct syscore_ops *ops)
33207 {
33208 mutex_lock(&syscore_ops_lock);
33209 - list_del(&ops->node);
33210 + pax_list_del((struct list_head *)&ops->node);
33211 mutex_unlock(&syscore_ops_lock);
33212 }
33213 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33214 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33215 index dadea48..a1f3835 100644
33216 --- a/drivers/block/cciss.c
33217 +++ b/drivers/block/cciss.c
33218 @@ -1184,6 +1184,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33219 int err;
33220 u32 cp;
33221
33222 + memset(&arg64, 0, sizeof(arg64));
33223 +
33224 err = 0;
33225 err |=
33226 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33227 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33228 while (!list_empty(&h->reqQ)) {
33229 c = list_entry(h->reqQ.next, CommandList_struct, list);
33230 /* can't do anything if fifo is full */
33231 - if ((h->access.fifo_full(h))) {
33232 + if ((h->access->fifo_full(h))) {
33233 dev_warn(&h->pdev->dev, "fifo full\n");
33234 break;
33235 }
33236 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33237 h->Qdepth--;
33238
33239 /* Tell the controller execute command */
33240 - h->access.submit_command(h, c);
33241 + h->access->submit_command(h, c);
33242
33243 /* Put job onto the completed Q */
33244 addQ(&h->cmpQ, c);
33245 @@ -3441,17 +3443,17 @@ startio:
33246
33247 static inline unsigned long get_next_completion(ctlr_info_t *h)
33248 {
33249 - return h->access.command_completed(h);
33250 + return h->access->command_completed(h);
33251 }
33252
33253 static inline int interrupt_pending(ctlr_info_t *h)
33254 {
33255 - return h->access.intr_pending(h);
33256 + return h->access->intr_pending(h);
33257 }
33258
33259 static inline long interrupt_not_for_us(ctlr_info_t *h)
33260 {
33261 - return ((h->access.intr_pending(h) == 0) ||
33262 + return ((h->access->intr_pending(h) == 0) ||
33263 (h->interrupts_enabled == 0));
33264 }
33265
33266 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33267 u32 a;
33268
33269 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33270 - return h->access.command_completed(h);
33271 + return h->access->command_completed(h);
33272
33273 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33274 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33275 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33276 trans_support & CFGTBL_Trans_use_short_tags);
33277
33278 /* Change the access methods to the performant access methods */
33279 - h->access = SA5_performant_access;
33280 + h->access = &SA5_performant_access;
33281 h->transMethod = CFGTBL_Trans_Performant;
33282
33283 return;
33284 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33285 if (prod_index < 0)
33286 return -ENODEV;
33287 h->product_name = products[prod_index].product_name;
33288 - h->access = *(products[prod_index].access);
33289 + h->access = products[prod_index].access;
33290
33291 if (cciss_board_disabled(h)) {
33292 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33293 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33294 }
33295
33296 /* make sure the board interrupts are off */
33297 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33298 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33299 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33300 if (rc)
33301 goto clean2;
33302 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33303 * fake ones to scoop up any residual completions.
33304 */
33305 spin_lock_irqsave(&h->lock, flags);
33306 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33307 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33308 spin_unlock_irqrestore(&h->lock, flags);
33309 free_irq(h->intr[h->intr_mode], h);
33310 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33311 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33312 dev_info(&h->pdev->dev, "Board READY.\n");
33313 dev_info(&h->pdev->dev,
33314 "Waiting for stale completions to drain.\n");
33315 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33316 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33317 msleep(10000);
33318 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33319 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33320
33321 rc = controller_reset_failed(h->cfgtable);
33322 if (rc)
33323 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33324 cciss_scsi_setup(h);
33325
33326 /* Turn the interrupts on so we can service requests */
33327 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33328 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33329
33330 /* Get the firmware version */
33331 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33332 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33333 kfree(flush_buf);
33334 if (return_code != IO_OK)
33335 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33336 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33337 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33338 free_irq(h->intr[h->intr_mode], h);
33339 }
33340
33341 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33342 index 7fda30e..eb5dfe0 100644
33343 --- a/drivers/block/cciss.h
33344 +++ b/drivers/block/cciss.h
33345 @@ -101,7 +101,7 @@ struct ctlr_info
33346 /* information about each logical volume */
33347 drive_info_struct *drv[CISS_MAX_LUN];
33348
33349 - struct access_method access;
33350 + struct access_method *access;
33351
33352 /* queue and queue Info */
33353 struct list_head reqQ;
33354 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33355 index 3f08713..87d4b4a 100644
33356 --- a/drivers/block/cpqarray.c
33357 +++ b/drivers/block/cpqarray.c
33358 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33359 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33360 goto Enomem4;
33361 }
33362 - hba[i]->access.set_intr_mask(hba[i], 0);
33363 + hba[i]->access->set_intr_mask(hba[i], 0);
33364 if (request_irq(hba[i]->intr, do_ida_intr,
33365 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33366 {
33367 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33368 add_timer(&hba[i]->timer);
33369
33370 /* Enable IRQ now that spinlock and rate limit timer are set up */
33371 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33372 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33373
33374 for(j=0; j<NWD; j++) {
33375 struct gendisk *disk = ida_gendisk[i][j];
33376 @@ -694,7 +694,7 @@ DBGINFO(
33377 for(i=0; i<NR_PRODUCTS; i++) {
33378 if (board_id == products[i].board_id) {
33379 c->product_name = products[i].product_name;
33380 - c->access = *(products[i].access);
33381 + c->access = products[i].access;
33382 break;
33383 }
33384 }
33385 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33386 hba[ctlr]->intr = intr;
33387 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33388 hba[ctlr]->product_name = products[j].product_name;
33389 - hba[ctlr]->access = *(products[j].access);
33390 + hba[ctlr]->access = products[j].access;
33391 hba[ctlr]->ctlr = ctlr;
33392 hba[ctlr]->board_id = board_id;
33393 hba[ctlr]->pci_dev = NULL; /* not PCI */
33394 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33395
33396 while((c = h->reqQ) != NULL) {
33397 /* Can't do anything if we're busy */
33398 - if (h->access.fifo_full(h) == 0)
33399 + if (h->access->fifo_full(h) == 0)
33400 return;
33401
33402 /* Get the first entry from the request Q */
33403 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33404 h->Qdepth--;
33405
33406 /* Tell the controller to do our bidding */
33407 - h->access.submit_command(h, c);
33408 + h->access->submit_command(h, c);
33409
33410 /* Get onto the completion Q */
33411 addQ(&h->cmpQ, c);
33412 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33413 unsigned long flags;
33414 __u32 a,a1;
33415
33416 - istat = h->access.intr_pending(h);
33417 + istat = h->access->intr_pending(h);
33418 /* Is this interrupt for us? */
33419 if (istat == 0)
33420 return IRQ_NONE;
33421 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33422 */
33423 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33424 if (istat & FIFO_NOT_EMPTY) {
33425 - while((a = h->access.command_completed(h))) {
33426 + while((a = h->access->command_completed(h))) {
33427 a1 = a; a &= ~3;
33428 if ((c = h->cmpQ) == NULL)
33429 {
33430 @@ -1195,6 +1195,7 @@ out_passthru:
33431 ida_pci_info_struct pciinfo;
33432
33433 if (!arg) return -EINVAL;
33434 + memset(&pciinfo, 0, sizeof(pciinfo));
33435 pciinfo.bus = host->pci_dev->bus->number;
33436 pciinfo.dev_fn = host->pci_dev->devfn;
33437 pciinfo.board_id = host->board_id;
33438 @@ -1449,11 +1450,11 @@ static int sendcmd(
33439 /*
33440 * Disable interrupt
33441 */
33442 - info_p->access.set_intr_mask(info_p, 0);
33443 + info_p->access->set_intr_mask(info_p, 0);
33444 /* Make sure there is room in the command FIFO */
33445 /* Actually it should be completely empty at this time. */
33446 for (i = 200000; i > 0; i--) {
33447 - temp = info_p->access.fifo_full(info_p);
33448 + temp = info_p->access->fifo_full(info_p);
33449 if (temp != 0) {
33450 break;
33451 }
33452 @@ -1466,7 +1467,7 @@ DBG(
33453 /*
33454 * Send the cmd
33455 */
33456 - info_p->access.submit_command(info_p, c);
33457 + info_p->access->submit_command(info_p, c);
33458 complete = pollcomplete(ctlr);
33459
33460 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33461 @@ -1549,9 +1550,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33462 * we check the new geometry. Then turn interrupts back on when
33463 * we're done.
33464 */
33465 - host->access.set_intr_mask(host, 0);
33466 + host->access->set_intr_mask(host, 0);
33467 getgeometry(ctlr);
33468 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33469 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33470
33471 for(i=0; i<NWD; i++) {
33472 struct gendisk *disk = ida_gendisk[ctlr][i];
33473 @@ -1591,7 +1592,7 @@ static int pollcomplete(int ctlr)
33474 /* Wait (up to 2 seconds) for a command to complete */
33475
33476 for (i = 200000; i > 0; i--) {
33477 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33478 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33479 if (done == 0) {
33480 udelay(10); /* a short fixed delay */
33481 } else
33482 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33483 index be73e9d..7fbf140 100644
33484 --- a/drivers/block/cpqarray.h
33485 +++ b/drivers/block/cpqarray.h
33486 @@ -99,7 +99,7 @@ struct ctlr_info {
33487 drv_info_t drv[NWD];
33488 struct proc_dir_entry *proc;
33489
33490 - struct access_method access;
33491 + struct access_method *access;
33492
33493 cmdlist_t *reqQ;
33494 cmdlist_t *cmpQ;
33495 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33496 index 6b51afa..17e1191 100644
33497 --- a/drivers/block/drbd/drbd_int.h
33498 +++ b/drivers/block/drbd/drbd_int.h
33499 @@ -582,7 +582,7 @@ struct drbd_epoch {
33500 struct drbd_tconn *tconn;
33501 struct list_head list;
33502 unsigned int barrier_nr;
33503 - atomic_t epoch_size; /* increased on every request added. */
33504 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33505 atomic_t active; /* increased on every req. added, and dec on every finished. */
33506 unsigned long flags;
33507 };
33508 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33509 int al_tr_cycle;
33510 int al_tr_pos; /* position of the next transaction in the journal */
33511 wait_queue_head_t seq_wait;
33512 - atomic_t packet_seq;
33513 + atomic_unchecked_t packet_seq;
33514 unsigned int peer_seq;
33515 spinlock_t peer_seq_lock;
33516 unsigned int minor;
33517 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33518 char __user *uoptval;
33519 int err;
33520
33521 - uoptval = (char __user __force *)optval;
33522 + uoptval = (char __force_user *)optval;
33523
33524 set_fs(KERNEL_DS);
33525 if (level == SOL_SOCKET)
33526 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33527 index 54d03d4..332f311 100644
33528 --- a/drivers/block/drbd/drbd_main.c
33529 +++ b/drivers/block/drbd/drbd_main.c
33530 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33531 p->sector = sector;
33532 p->block_id = block_id;
33533 p->blksize = blksize;
33534 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33535 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33536 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33537 }
33538
33539 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33540 return -EIO;
33541 p->sector = cpu_to_be64(req->i.sector);
33542 p->block_id = (unsigned long)req;
33543 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33544 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33545 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33546 if (mdev->state.conn >= C_SYNC_SOURCE &&
33547 mdev->state.conn <= C_PAUSED_SYNC_T)
33548 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33549 {
33550 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33551
33552 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33553 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33554 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33555 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33556 kfree(tconn->current_epoch);
33557
33558 idr_destroy(&tconn->volumes);
33559 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33560 index 2f5fffd..b22a1ae 100644
33561 --- a/drivers/block/drbd/drbd_receiver.c
33562 +++ b/drivers/block/drbd/drbd_receiver.c
33563 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33564 {
33565 int err;
33566
33567 - atomic_set(&mdev->packet_seq, 0);
33568 + atomic_set_unchecked(&mdev->packet_seq, 0);
33569 mdev->peer_seq = 0;
33570
33571 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33572 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33573 do {
33574 next_epoch = NULL;
33575
33576 - epoch_size = atomic_read(&epoch->epoch_size);
33577 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33578
33579 switch (ev & ~EV_CLEANUP) {
33580 case EV_PUT:
33581 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33582 rv = FE_DESTROYED;
33583 } else {
33584 epoch->flags = 0;
33585 - atomic_set(&epoch->epoch_size, 0);
33586 + atomic_set_unchecked(&epoch->epoch_size, 0);
33587 /* atomic_set(&epoch->active, 0); is already zero */
33588 if (rv == FE_STILL_LIVE)
33589 rv = FE_RECYCLED;
33590 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33591 conn_wait_active_ee_empty(tconn);
33592 drbd_flush(tconn);
33593
33594 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33595 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33596 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33597 if (epoch)
33598 break;
33599 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33600 }
33601
33602 epoch->flags = 0;
33603 - atomic_set(&epoch->epoch_size, 0);
33604 + atomic_set_unchecked(&epoch->epoch_size, 0);
33605 atomic_set(&epoch->active, 0);
33606
33607 spin_lock(&tconn->epoch_lock);
33608 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33609 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33610 list_add(&epoch->list, &tconn->current_epoch->list);
33611 tconn->current_epoch = epoch;
33612 tconn->epochs++;
33613 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33614
33615 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33616 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33617 - atomic_inc(&tconn->current_epoch->epoch_size);
33618 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33619 err2 = drbd_drain_block(mdev, pi->size);
33620 if (!err)
33621 err = err2;
33622 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33623
33624 spin_lock(&tconn->epoch_lock);
33625 peer_req->epoch = tconn->current_epoch;
33626 - atomic_inc(&peer_req->epoch->epoch_size);
33627 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33628 atomic_inc(&peer_req->epoch->active);
33629 spin_unlock(&tconn->epoch_lock);
33630
33631 @@ -4345,7 +4345,7 @@ struct data_cmd {
33632 int expect_payload;
33633 size_t pkt_size;
33634 int (*fn)(struct drbd_tconn *, struct packet_info *);
33635 -};
33636 +} __do_const;
33637
33638 static struct data_cmd drbd_cmd_handler[] = {
33639 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33640 @@ -4465,7 +4465,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33641 if (!list_empty(&tconn->current_epoch->list))
33642 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33643 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33644 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33645 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33646 tconn->send.seen_any_write_yet = false;
33647
33648 conn_info(tconn, "Connection closed\n");
33649 @@ -5221,7 +5221,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33650 struct asender_cmd {
33651 size_t pkt_size;
33652 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33653 -};
33654 +} __do_const;
33655
33656 static struct asender_cmd asender_tbl[] = {
33657 [P_PING] = { 0, got_Ping },
33658 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33659 index dfe7583..83768bb 100644
33660 --- a/drivers/block/loop.c
33661 +++ b/drivers/block/loop.c
33662 @@ -231,7 +231,7 @@ static int __do_lo_send_write(struct file *file,
33663 mm_segment_t old_fs = get_fs();
33664
33665 set_fs(get_ds());
33666 - bw = file->f_op->write(file, buf, len, &pos);
33667 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33668 set_fs(old_fs);
33669 if (likely(bw == len))
33670 return 0;
33671 diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
33672 index 7fecc78..84d217c 100644
33673 --- a/drivers/block/nbd.c
33674 +++ b/drivers/block/nbd.c
33675 @@ -714,7 +714,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
33676 else
33677 blk_queue_flush(nbd->disk->queue, 0);
33678
33679 - thread = kthread_create(nbd_thread, nbd, nbd->disk->disk_name);
33680 + thread = kthread_create(nbd_thread, nbd, "%s", nbd->disk->disk_name);
33681 if (IS_ERR(thread)) {
33682 mutex_lock(&nbd->tx_lock);
33683 return PTR_ERR(thread);
33684 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33685 index 2e7de7a..ed86dc0 100644
33686 --- a/drivers/block/pktcdvd.c
33687 +++ b/drivers/block/pktcdvd.c
33688 @@ -83,7 +83,7 @@
33689
33690 #define MAX_SPEED 0xffff
33691
33692 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33693 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33694
33695 static DEFINE_MUTEX(pktcdvd_mutex);
33696 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33697 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33698 index d620b44..d7538c2 100644
33699 --- a/drivers/cdrom/cdrom.c
33700 +++ b/drivers/cdrom/cdrom.c
33701 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33702 ENSURE(reset, CDC_RESET);
33703 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33704 cdi->mc_flags = 0;
33705 - cdo->n_minors = 0;
33706 cdi->options = CDO_USE_FFLAGS;
33707
33708 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33709 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33710 else
33711 cdi->cdda_method = CDDA_OLD;
33712
33713 - if (!cdo->generic_packet)
33714 - cdo->generic_packet = cdrom_dummy_generic_packet;
33715 + if (!cdo->generic_packet) {
33716 + pax_open_kernel();
33717 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33718 + pax_close_kernel();
33719 + }
33720
33721 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33722 mutex_lock(&cdrom_mutex);
33723 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33724 if (cdi->exit)
33725 cdi->exit(cdi);
33726
33727 - cdi->ops->n_minors--;
33728 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33729 }
33730
33731 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
33732 */
33733 nr = nframes;
33734 do {
33735 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33736 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33737 if (cgc.buffer)
33738 break;
33739
33740 @@ -2882,7 +2883,7 @@ static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi,
33741 if (lba < 0)
33742 return -EINVAL;
33743
33744 - cgc->buffer = kmalloc(blocksize, GFP_KERNEL);
33745 + cgc->buffer = kzalloc(blocksize, GFP_KERNEL);
33746 if (cgc->buffer == NULL)
33747 return -ENOMEM;
33748
33749 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
33750 struct cdrom_device_info *cdi;
33751 int ret;
33752
33753 - ret = scnprintf(info + *pos, max_size - *pos, header);
33754 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
33755 if (!ret)
33756 return 1;
33757
33758 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33759 index d59cdcb..11afddf 100644
33760 --- a/drivers/cdrom/gdrom.c
33761 +++ b/drivers/cdrom/gdrom.c
33762 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33763 .audio_ioctl = gdrom_audio_ioctl,
33764 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33765 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33766 - .n_minors = 1,
33767 };
33768
33769 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33770 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33771 index 3bb6fa3..34013fb 100644
33772 --- a/drivers/char/Kconfig
33773 +++ b/drivers/char/Kconfig
33774 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33775
33776 config DEVKMEM
33777 bool "/dev/kmem virtual device support"
33778 - default y
33779 + default n
33780 + depends on !GRKERNSEC_KMEM
33781 help
33782 Say Y here if you want to support the /dev/kmem device. The
33783 /dev/kmem device is rarely used, but can be used for certain
33784 @@ -582,6 +583,7 @@ config DEVPORT
33785 bool
33786 depends on !M68K
33787 depends on ISA || PCI
33788 + depends on !GRKERNSEC_KMEM
33789 default y
33790
33791 source "drivers/s390/char/Kconfig"
33792 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33793 index a48e05b..6bac831 100644
33794 --- a/drivers/char/agp/compat_ioctl.c
33795 +++ b/drivers/char/agp/compat_ioctl.c
33796 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33797 return -ENOMEM;
33798 }
33799
33800 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33801 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33802 sizeof(*usegment) * ureserve.seg_count)) {
33803 kfree(usegment);
33804 kfree(ksegment);
33805 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33806 index 2e04433..771f2cc 100644
33807 --- a/drivers/char/agp/frontend.c
33808 +++ b/drivers/char/agp/frontend.c
33809 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33810 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33811 return -EFAULT;
33812
33813 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33814 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33815 return -EFAULT;
33816
33817 client = agp_find_client_by_pid(reserve.pid);
33818 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33819 if (segment == NULL)
33820 return -ENOMEM;
33821
33822 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33823 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33824 sizeof(struct agp_segment) * reserve.seg_count)) {
33825 kfree(segment);
33826 return -EFAULT;
33827 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33828 index 21cb980..f15107c 100644
33829 --- a/drivers/char/genrtc.c
33830 +++ b/drivers/char/genrtc.c
33831 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33832 switch (cmd) {
33833
33834 case RTC_PLL_GET:
33835 + memset(&pll, 0, sizeof(pll));
33836 if (get_rtc_pll(&pll))
33837 return -EINVAL;
33838 else
33839 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33840 index d784650..e8bfd69 100644
33841 --- a/drivers/char/hpet.c
33842 +++ b/drivers/char/hpet.c
33843 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33844 }
33845
33846 static int
33847 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33848 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33849 struct hpet_info *info)
33850 {
33851 struct hpet_timer __iomem *timer;
33852 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
33853 index 86fe45c..c0ea948 100644
33854 --- a/drivers/char/hw_random/intel-rng.c
33855 +++ b/drivers/char/hw_random/intel-rng.c
33856 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
33857
33858 if (no_fwh_detect)
33859 return -ENODEV;
33860 - printk(warning);
33861 + printk("%s", warning);
33862 return -EBUSY;
33863 }
33864
33865 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33866 index 053201b0..8335cce 100644
33867 --- a/drivers/char/ipmi/ipmi_msghandler.c
33868 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33869 @@ -420,7 +420,7 @@ struct ipmi_smi {
33870 struct proc_dir_entry *proc_dir;
33871 char proc_dir_name[10];
33872
33873 - atomic_t stats[IPMI_NUM_STATS];
33874 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33875
33876 /*
33877 * run_to_completion duplicate of smb_info, smi_info
33878 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33879
33880
33881 #define ipmi_inc_stat(intf, stat) \
33882 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33883 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33884 #define ipmi_get_stat(intf, stat) \
33885 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33886 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33887
33888 static int is_lan_addr(struct ipmi_addr *addr)
33889 {
33890 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33891 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33892 init_waitqueue_head(&intf->waitq);
33893 for (i = 0; i < IPMI_NUM_STATS; i++)
33894 - atomic_set(&intf->stats[i], 0);
33895 + atomic_set_unchecked(&intf->stats[i], 0);
33896
33897 intf->proc_dir = NULL;
33898
33899 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33900 index 0ac9b45..6179fb5 100644
33901 --- a/drivers/char/ipmi/ipmi_si_intf.c
33902 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33903 @@ -275,7 +275,7 @@ struct smi_info {
33904 unsigned char slave_addr;
33905
33906 /* Counters and things for the proc filesystem. */
33907 - atomic_t stats[SI_NUM_STATS];
33908 + atomic_unchecked_t stats[SI_NUM_STATS];
33909
33910 struct task_struct *thread;
33911
33912 @@ -284,9 +284,9 @@ struct smi_info {
33913 };
33914
33915 #define smi_inc_stat(smi, stat) \
33916 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33917 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33918 #define smi_get_stat(smi, stat) \
33919 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33920 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33921
33922 #define SI_MAX_PARMS 4
33923
33924 @@ -3254,7 +3254,7 @@ static int try_smi_init(struct smi_info *new_smi)
33925 atomic_set(&new_smi->req_events, 0);
33926 new_smi->run_to_completion = 0;
33927 for (i = 0; i < SI_NUM_STATS; i++)
33928 - atomic_set(&new_smi->stats[i], 0);
33929 + atomic_set_unchecked(&new_smi->stats[i], 0);
33930
33931 new_smi->interrupt_disabled = 1;
33932 atomic_set(&new_smi->stop_operation, 0);
33933 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33934 index 2c644af..4b7aede 100644
33935 --- a/drivers/char/mem.c
33936 +++ b/drivers/char/mem.c
33937 @@ -18,6 +18,7 @@
33938 #include <linux/raw.h>
33939 #include <linux/tty.h>
33940 #include <linux/capability.h>
33941 +#include <linux/security.h>
33942 #include <linux/ptrace.h>
33943 #include <linux/device.h>
33944 #include <linux/highmem.h>
33945 @@ -37,6 +38,10 @@
33946
33947 #define DEVPORT_MINOR 4
33948
33949 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33950 +extern const struct file_operations grsec_fops;
33951 +#endif
33952 +
33953 static inline unsigned long size_inside_page(unsigned long start,
33954 unsigned long size)
33955 {
33956 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33957
33958 while (cursor < to) {
33959 if (!devmem_is_allowed(pfn)) {
33960 +#ifdef CONFIG_GRKERNSEC_KMEM
33961 + gr_handle_mem_readwrite(from, to);
33962 +#else
33963 printk(KERN_INFO
33964 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33965 current->comm, from, to);
33966 +#endif
33967 return 0;
33968 }
33969 cursor += PAGE_SIZE;
33970 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33971 }
33972 return 1;
33973 }
33974 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33975 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33976 +{
33977 + return 0;
33978 +}
33979 #else
33980 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33981 {
33982 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33983
33984 while (count > 0) {
33985 unsigned long remaining;
33986 + char *temp;
33987
33988 sz = size_inside_page(p, count);
33989
33990 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33991 if (!ptr)
33992 return -EFAULT;
33993
33994 - remaining = copy_to_user(buf, ptr, sz);
33995 +#ifdef CONFIG_PAX_USERCOPY
33996 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33997 + if (!temp) {
33998 + unxlate_dev_mem_ptr(p, ptr);
33999 + return -ENOMEM;
34000 + }
34001 + memcpy(temp, ptr, sz);
34002 +#else
34003 + temp = ptr;
34004 +#endif
34005 +
34006 + remaining = copy_to_user(buf, temp, sz);
34007 +
34008 +#ifdef CONFIG_PAX_USERCOPY
34009 + kfree(temp);
34010 +#endif
34011 +
34012 unxlate_dev_mem_ptr(p, ptr);
34013 if (remaining)
34014 return -EFAULT;
34015 @@ -378,7 +409,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
34016 else
34017 csize = count;
34018
34019 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
34020 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
34021 if (rc < 0)
34022 return rc;
34023 buf += csize;
34024 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34025 size_t count, loff_t *ppos)
34026 {
34027 unsigned long p = *ppos;
34028 - ssize_t low_count, read, sz;
34029 + ssize_t low_count, read, sz, err = 0;
34030 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34031 - int err = 0;
34032
34033 read = 0;
34034 if (p < (unsigned long) high_memory) {
34035 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34036 }
34037 #endif
34038 while (low_count > 0) {
34039 + char *temp;
34040 +
34041 sz = size_inside_page(p, low_count);
34042
34043 /*
34044 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34045 */
34046 kbuf = xlate_dev_kmem_ptr((char *)p);
34047
34048 - if (copy_to_user(buf, kbuf, sz))
34049 +#ifdef CONFIG_PAX_USERCOPY
34050 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34051 + if (!temp)
34052 + return -ENOMEM;
34053 + memcpy(temp, kbuf, sz);
34054 +#else
34055 + temp = kbuf;
34056 +#endif
34057 +
34058 + err = copy_to_user(buf, temp, sz);
34059 +
34060 +#ifdef CONFIG_PAX_USERCOPY
34061 + kfree(temp);
34062 +#endif
34063 +
34064 + if (err)
34065 return -EFAULT;
34066 buf += sz;
34067 p += sz;
34068 @@ -833,6 +880,9 @@ static const struct memdev {
34069 #ifdef CONFIG_CRASH_DUMP
34070 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34071 #endif
34072 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34073 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34074 +#endif
34075 };
34076
34077 static int memory_open(struct inode *inode, struct file *filp)
34078 @@ -904,7 +954,7 @@ static int __init chr_dev_init(void)
34079 continue;
34080
34081 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
34082 - NULL, devlist[minor].name);
34083 + NULL, "%s", devlist[minor].name);
34084 }
34085
34086 return tty_init();
34087 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
34088 index c689697..04e6d6a2 100644
34089 --- a/drivers/char/mwave/tp3780i.c
34090 +++ b/drivers/char/mwave/tp3780i.c
34091 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
34092 PRINTK_2(TRACE_TP3780I,
34093 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
34094
34095 + memset(pAbilities, 0, sizeof(*pAbilities));
34096 /* fill out standard constant fields */
34097 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
34098 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
34099 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34100 index 9df78e2..01ba9ae 100644
34101 --- a/drivers/char/nvram.c
34102 +++ b/drivers/char/nvram.c
34103 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34104
34105 spin_unlock_irq(&rtc_lock);
34106
34107 - if (copy_to_user(buf, contents, tmp - contents))
34108 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34109 return -EFAULT;
34110
34111 *ppos = i;
34112 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34113 index 5c5cc00..ac9edb7 100644
34114 --- a/drivers/char/pcmcia/synclink_cs.c
34115 +++ b/drivers/char/pcmcia/synclink_cs.c
34116 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34117
34118 if (debug_level >= DEBUG_LEVEL_INFO)
34119 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34120 - __FILE__, __LINE__, info->device_name, port->count);
34121 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
34122
34123 - WARN_ON(!port->count);
34124 + WARN_ON(!atomic_read(&port->count));
34125
34126 if (tty_port_close_start(port, tty, filp) == 0)
34127 goto cleanup;
34128 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34129 cleanup:
34130 if (debug_level >= DEBUG_LEVEL_INFO)
34131 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
34132 - tty->driver->name, port->count);
34133 + tty->driver->name, atomic_read(&port->count));
34134 }
34135
34136 /* Wait until the transmitter is empty.
34137 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34138
34139 if (debug_level >= DEBUG_LEVEL_INFO)
34140 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34141 - __FILE__, __LINE__, tty->driver->name, port->count);
34142 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
34143
34144 /* If port is closing, signal caller to try again */
34145 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34146 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34147 goto cleanup;
34148 }
34149 spin_lock(&port->lock);
34150 - port->count++;
34151 + atomic_inc(&port->count);
34152 spin_unlock(&port->lock);
34153 spin_unlock_irqrestore(&info->netlock, flags);
34154
34155 - if (port->count == 1) {
34156 + if (atomic_read(&port->count) == 1) {
34157 /* 1st open on this device, init hardware */
34158 retval = startup(info, tty);
34159 if (retval < 0)
34160 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34161 unsigned short new_crctype;
34162
34163 /* return error if TTY interface open */
34164 - if (info->port.count)
34165 + if (atomic_read(&info->port.count))
34166 return -EBUSY;
34167
34168 switch (encoding)
34169 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
34170
34171 /* arbitrate between network and tty opens */
34172 spin_lock_irqsave(&info->netlock, flags);
34173 - if (info->port.count != 0 || info->netcount != 0) {
34174 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34175 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34176 spin_unlock_irqrestore(&info->netlock, flags);
34177 return -EBUSY;
34178 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34179 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
34180
34181 /* return error if TTY interface open */
34182 - if (info->port.count)
34183 + if (atomic_read(&info->port.count))
34184 return -EBUSY;
34185
34186 if (cmd != SIOCWANDEV)
34187 diff --git a/drivers/char/random.c b/drivers/char/random.c
34188 index eccd7cc..98038d5 100644
34189 --- a/drivers/char/random.c
34190 +++ b/drivers/char/random.c
34191 @@ -272,8 +272,13 @@
34192 /*
34193 * Configuration information
34194 */
34195 +#ifdef CONFIG_GRKERNSEC_RANDNET
34196 +#define INPUT_POOL_WORDS 512
34197 +#define OUTPUT_POOL_WORDS 128
34198 +#else
34199 #define INPUT_POOL_WORDS 128
34200 #define OUTPUT_POOL_WORDS 32
34201 +#endif
34202 #define SEC_XFER_SIZE 512
34203 #define EXTRACT_SIZE 10
34204
34205 @@ -313,10 +318,17 @@ static struct poolinfo {
34206 int poolwords;
34207 int tap1, tap2, tap3, tap4, tap5;
34208 } poolinfo_table[] = {
34209 +#ifdef CONFIG_GRKERNSEC_RANDNET
34210 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34211 + { 512, 411, 308, 208, 104, 1 },
34212 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34213 + { 128, 103, 76, 51, 25, 1 },
34214 +#else
34215 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34216 { 128, 103, 76, 51, 25, 1 },
34217 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34218 { 32, 26, 20, 14, 7, 1 },
34219 +#endif
34220 #if 0
34221 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34222 { 2048, 1638, 1231, 819, 411, 1 },
34223 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34224 input_rotate += i ? 7 : 14;
34225 }
34226
34227 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34228 - ACCESS_ONCE(r->add_ptr) = i;
34229 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34230 + ACCESS_ONCE_RW(r->add_ptr) = i;
34231 smp_wmb();
34232
34233 if (out)
34234 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34235
34236 extract_buf(r, tmp);
34237 i = min_t(int, nbytes, EXTRACT_SIZE);
34238 - if (copy_to_user(buf, tmp, i)) {
34239 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34240 ret = -EFAULT;
34241 break;
34242 }
34243 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34244 #include <linux/sysctl.h>
34245
34246 static int min_read_thresh = 8, min_write_thresh;
34247 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34248 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34249 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34250 static char sysctl_bootid[16];
34251
34252 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
34253 static int proc_do_uuid(ctl_table *table, int write,
34254 void __user *buffer, size_t *lenp, loff_t *ppos)
34255 {
34256 - ctl_table fake_table;
34257 + ctl_table_no_const fake_table;
34258 unsigned char buf[64], tmp_uuid[16], *uuid;
34259
34260 uuid = table->data;
34261 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34262 index bf2349db..5456d53 100644
34263 --- a/drivers/char/sonypi.c
34264 +++ b/drivers/char/sonypi.c
34265 @@ -54,6 +54,7 @@
34266
34267 #include <asm/uaccess.h>
34268 #include <asm/io.h>
34269 +#include <asm/local.h>
34270
34271 #include <linux/sonypi.h>
34272
34273 @@ -490,7 +491,7 @@ static struct sonypi_device {
34274 spinlock_t fifo_lock;
34275 wait_queue_head_t fifo_proc_list;
34276 struct fasync_struct *fifo_async;
34277 - int open_count;
34278 + local_t open_count;
34279 int model;
34280 struct input_dev *input_jog_dev;
34281 struct input_dev *input_key_dev;
34282 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34283 static int sonypi_misc_release(struct inode *inode, struct file *file)
34284 {
34285 mutex_lock(&sonypi_device.lock);
34286 - sonypi_device.open_count--;
34287 + local_dec(&sonypi_device.open_count);
34288 mutex_unlock(&sonypi_device.lock);
34289 return 0;
34290 }
34291 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34292 {
34293 mutex_lock(&sonypi_device.lock);
34294 /* Flush input queue on first open */
34295 - if (!sonypi_device.open_count)
34296 + if (!local_read(&sonypi_device.open_count))
34297 kfifo_reset(&sonypi_device.fifo);
34298 - sonypi_device.open_count++;
34299 + local_inc(&sonypi_device.open_count);
34300 mutex_unlock(&sonypi_device.lock);
34301
34302 return 0;
34303 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34304 index 64420b3..5c40b56 100644
34305 --- a/drivers/char/tpm/tpm_acpi.c
34306 +++ b/drivers/char/tpm/tpm_acpi.c
34307 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34308 virt = acpi_os_map_memory(start, len);
34309 if (!virt) {
34310 kfree(log->bios_event_log);
34311 + log->bios_event_log = NULL;
34312 printk("%s: ERROR - Unable to map memory\n", __func__);
34313 return -EIO;
34314 }
34315
34316 - memcpy_fromio(log->bios_event_log, virt, len);
34317 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34318
34319 acpi_os_unmap_memory(virt, len);
34320 return 0;
34321 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34322 index 84ddc55..1d32f1e 100644
34323 --- a/drivers/char/tpm/tpm_eventlog.c
34324 +++ b/drivers/char/tpm/tpm_eventlog.c
34325 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34326 event = addr;
34327
34328 if ((event->event_type == 0 && event->event_size == 0) ||
34329 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34330 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34331 return NULL;
34332
34333 return addr;
34334 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34335 return NULL;
34336
34337 if ((event->event_type == 0 && event->event_size == 0) ||
34338 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34339 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34340 return NULL;
34341
34342 (*pos)++;
34343 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34344 int i;
34345
34346 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34347 - seq_putc(m, data[i]);
34348 + if (!seq_putc(m, data[i]))
34349 + return -EFAULT;
34350
34351 return 0;
34352 }
34353 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34354 index ce5f3fc..e2d3e55 100644
34355 --- a/drivers/char/virtio_console.c
34356 +++ b/drivers/char/virtio_console.c
34357 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34358 if (to_user) {
34359 ssize_t ret;
34360
34361 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34362 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34363 if (ret)
34364 return -EFAULT;
34365 } else {
34366 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34367 if (!port_has_data(port) && !port->host_connected)
34368 return 0;
34369
34370 - return fill_readbuf(port, ubuf, count, true);
34371 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34372 }
34373
34374 static int wait_port_writable(struct port *port, bool nonblock)
34375 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34376 index d7ad425..3e3f81f 100644
34377 --- a/drivers/clocksource/arm_arch_timer.c
34378 +++ b/drivers/clocksource/arm_arch_timer.c
34379 @@ -262,7 +262,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34380 return NOTIFY_OK;
34381 }
34382
34383 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34384 +static struct notifier_block arch_timer_cpu_nb = {
34385 .notifier_call = arch_timer_cpu_notify,
34386 };
34387
34388 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34389 index ade7513..069445f 100644
34390 --- a/drivers/clocksource/metag_generic.c
34391 +++ b/drivers/clocksource/metag_generic.c
34392 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34393 return NOTIFY_OK;
34394 }
34395
34396 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34397 +static struct notifier_block arch_timer_cpu_nb = {
34398 .notifier_call = arch_timer_cpu_notify,
34399 };
34400
34401 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34402 index bb5939b..d9accb7 100644
34403 --- a/drivers/cpufreq/acpi-cpufreq.c
34404 +++ b/drivers/cpufreq/acpi-cpufreq.c
34405 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34406 return sprintf(buf, "%u\n", boost_enabled);
34407 }
34408
34409 -static struct global_attr global_boost = __ATTR(boost, 0644,
34410 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34411 show_global_boost,
34412 store_global_boost);
34413
34414 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34415 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34416 per_cpu(acfreq_data, cpu) = data;
34417
34418 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34419 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34420 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34421 + pax_open_kernel();
34422 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34423 + pax_close_kernel();
34424 + }
34425
34426 result = acpi_processor_register_performance(data->acpi_data, cpu);
34427 if (result)
34428 @@ -839,7 +842,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34429 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34430 break;
34431 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34432 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34433 + pax_open_kernel();
34434 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34435 + pax_close_kernel();
34436 policy->cur = get_cur_freq_on_cpu(cpu);
34437 break;
34438 default:
34439 @@ -850,8 +855,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34440 acpi_processor_notify_smm(THIS_MODULE);
34441
34442 /* Check for APERF/MPERF support in hardware */
34443 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34444 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34445 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34446 + pax_open_kernel();
34447 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34448 + pax_close_kernel();
34449 + }
34450
34451 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34452 for (i = 0; i < perf->state_count; i++)
34453 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34454 index b02824d..51e44aa 100644
34455 --- a/drivers/cpufreq/cpufreq.c
34456 +++ b/drivers/cpufreq/cpufreq.c
34457 @@ -1813,7 +1813,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34458 return NOTIFY_OK;
34459 }
34460
34461 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34462 +static struct notifier_block cpufreq_cpu_notifier = {
34463 .notifier_call = cpufreq_cpu_callback,
34464 };
34465
34466 @@ -1845,8 +1845,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34467
34468 pr_debug("trying to register driver %s\n", driver_data->name);
34469
34470 - if (driver_data->setpolicy)
34471 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34472 + if (driver_data->setpolicy) {
34473 + pax_open_kernel();
34474 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34475 + pax_close_kernel();
34476 + }
34477
34478 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34479 if (cpufreq_driver) {
34480 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34481 index 5a76086..0f4d394 100644
34482 --- a/drivers/cpufreq/cpufreq_governor.c
34483 +++ b/drivers/cpufreq/cpufreq_governor.c
34484 @@ -201,8 +201,8 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34485 {
34486 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34487 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34488 - struct cs_ops *cs_ops = NULL;
34489 - struct od_ops *od_ops = NULL;
34490 + const struct cs_ops *cs_ops = NULL;
34491 + const struct od_ops *od_ops = NULL;
34492 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
34493 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
34494 struct cpu_dbs_common_info *cpu_cdbs;
34495 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34496 index cc4bd2f..ad142bc 100644
34497 --- a/drivers/cpufreq/cpufreq_governor.h
34498 +++ b/drivers/cpufreq/cpufreq_governor.h
34499 @@ -142,7 +142,7 @@ struct dbs_data {
34500 void (*gov_check_cpu)(int cpu, unsigned int load);
34501
34502 /* Governor specific ops, see below */
34503 - void *gov_ops;
34504 + const void *gov_ops;
34505 };
34506
34507 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34508 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34509 index bfd6273..e39dd63 100644
34510 --- a/drivers/cpufreq/cpufreq_stats.c
34511 +++ b/drivers/cpufreq/cpufreq_stats.c
34512 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34513 }
34514
34515 /* priority=1 so this will get called before cpufreq_remove_dev */
34516 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34517 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34518 .notifier_call = cpufreq_stat_cpu_callback,
34519 .priority = 1,
34520 };
34521 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34522 index 827629c9..0bc6a03 100644
34523 --- a/drivers/cpufreq/p4-clockmod.c
34524 +++ b/drivers/cpufreq/p4-clockmod.c
34525 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34526 case 0x0F: /* Core Duo */
34527 case 0x16: /* Celeron Core */
34528 case 0x1C: /* Atom */
34529 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34530 + pax_open_kernel();
34531 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34532 + pax_close_kernel();
34533 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34534 case 0x0D: /* Pentium M (Dothan) */
34535 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34536 + pax_open_kernel();
34537 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34538 + pax_close_kernel();
34539 /* fall through */
34540 case 0x09: /* Pentium M (Banias) */
34541 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34542 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34543
34544 /* on P-4s, the TSC runs with constant frequency independent whether
34545 * throttling is active or not. */
34546 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34547 + pax_open_kernel();
34548 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34549 + pax_close_kernel();
34550
34551 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34552 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34553 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34554 index 3a953d5..f5993f6 100644
34555 --- a/drivers/cpufreq/speedstep-centrino.c
34556 +++ b/drivers/cpufreq/speedstep-centrino.c
34557 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34558 !cpu_has(cpu, X86_FEATURE_EST))
34559 return -ENODEV;
34560
34561 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34562 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34563 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34564 + pax_open_kernel();
34565 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34566 + pax_close_kernel();
34567 + }
34568
34569 if (policy->cpu != 0)
34570 return -ENODEV;
34571 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34572 index eba6929..0f53baf 100644
34573 --- a/drivers/cpuidle/cpuidle.c
34574 +++ b/drivers/cpuidle/cpuidle.c
34575 @@ -277,7 +277,7 @@ static int poll_idle(struct cpuidle_device *dev,
34576
34577 static void poll_idle_init(struct cpuidle_driver *drv)
34578 {
34579 - struct cpuidle_state *state = &drv->states[0];
34580 + cpuidle_state_no_const *state = &drv->states[0];
34581
34582 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34583 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34584 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34585 index ea2f8e7..70ac501 100644
34586 --- a/drivers/cpuidle/governor.c
34587 +++ b/drivers/cpuidle/governor.c
34588 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34589 mutex_lock(&cpuidle_lock);
34590 if (__cpuidle_find_governor(gov->name) == NULL) {
34591 ret = 0;
34592 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34593 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34594 if (!cpuidle_curr_governor ||
34595 cpuidle_curr_governor->rating < gov->rating)
34596 cpuidle_switch_governor(gov);
34597 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34598 new_gov = cpuidle_replace_governor(gov->rating);
34599 cpuidle_switch_governor(new_gov);
34600 }
34601 - list_del(&gov->governor_list);
34602 + pax_list_del((struct list_head *)&gov->governor_list);
34603 mutex_unlock(&cpuidle_lock);
34604 }
34605
34606 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34607 index 428754a..8bdf9cc 100644
34608 --- a/drivers/cpuidle/sysfs.c
34609 +++ b/drivers/cpuidle/sysfs.c
34610 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34611 NULL
34612 };
34613
34614 -static struct attribute_group cpuidle_attr_group = {
34615 +static attribute_group_no_const cpuidle_attr_group = {
34616 .attrs = cpuidle_default_attrs,
34617 .name = "cpuidle",
34618 };
34619 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34620 index 3b36797..db0b0c0 100644
34621 --- a/drivers/devfreq/devfreq.c
34622 +++ b/drivers/devfreq/devfreq.c
34623 @@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
34624 GFP_KERNEL);
34625 devfreq->last_stat_updated = jiffies;
34626
34627 - dev_set_name(&devfreq->dev, dev_name(dev));
34628 + dev_set_name(&devfreq->dev, "%s", dev_name(dev));
34629 err = device_register(&devfreq->dev);
34630 if (err) {
34631 put_device(&devfreq->dev);
34632 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34633 goto err_out;
34634 }
34635
34636 - list_add(&governor->node, &devfreq_governor_list);
34637 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34638
34639 list_for_each_entry(devfreq, &devfreq_list, node) {
34640 int ret = 0;
34641 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34642 }
34643 }
34644
34645 - list_del(&governor->node);
34646 + pax_list_del((struct list_head *)&governor->node);
34647 err_out:
34648 mutex_unlock(&devfreq_list_lock);
34649
34650 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34651 index b70709b..1d8d02a 100644
34652 --- a/drivers/dma/sh/shdma.c
34653 +++ b/drivers/dma/sh/shdma.c
34654 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34655 return ret;
34656 }
34657
34658 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34659 +static struct notifier_block sh_dmae_nmi_notifier = {
34660 .notifier_call = sh_dmae_nmi_handler,
34661
34662 /* Run before NMI debug handler and KGDB */
34663 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34664 index 769d92e..a3dcc1e 100644
34665 --- a/drivers/edac/edac_mc_sysfs.c
34666 +++ b/drivers/edac/edac_mc_sysfs.c
34667 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34668 struct dev_ch_attribute {
34669 struct device_attribute attr;
34670 int channel;
34671 -};
34672 +} __do_const;
34673
34674 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34675 struct dev_ch_attribute dev_attr_legacy_##_name = \
34676 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34677 }
34678
34679 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34680 + pax_open_kernel();
34681 if (mci->get_sdram_scrub_rate) {
34682 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34683 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34684 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34685 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34686 }
34687 if (mci->set_sdram_scrub_rate) {
34688 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34689 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34690 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34691 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34692 }
34693 + pax_close_kernel();
34694 err = device_create_file(&mci->dev,
34695 &dev_attr_sdram_scrub_rate);
34696 if (err) {
34697 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34698 index e8658e4..22746d6 100644
34699 --- a/drivers/edac/edac_pci_sysfs.c
34700 +++ b/drivers/edac/edac_pci_sysfs.c
34701 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34702 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34703 static int edac_pci_poll_msec = 1000; /* one second workq period */
34704
34705 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34706 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34707 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34708 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34709
34710 static struct kobject *edac_pci_top_main_kobj;
34711 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34712 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34713 void *value;
34714 ssize_t(*show) (void *, char *);
34715 ssize_t(*store) (void *, const char *, size_t);
34716 -};
34717 +} __do_const;
34718
34719 /* Set of show/store abstract level functions for PCI Parity object */
34720 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34721 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34722 edac_printk(KERN_CRIT, EDAC_PCI,
34723 "Signaled System Error on %s\n",
34724 pci_name(dev));
34725 - atomic_inc(&pci_nonparity_count);
34726 + atomic_inc_unchecked(&pci_nonparity_count);
34727 }
34728
34729 if (status & (PCI_STATUS_PARITY)) {
34730 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34731 "Master Data Parity Error on %s\n",
34732 pci_name(dev));
34733
34734 - atomic_inc(&pci_parity_count);
34735 + atomic_inc_unchecked(&pci_parity_count);
34736 }
34737
34738 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34739 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34740 "Detected Parity Error on %s\n",
34741 pci_name(dev));
34742
34743 - atomic_inc(&pci_parity_count);
34744 + atomic_inc_unchecked(&pci_parity_count);
34745 }
34746 }
34747
34748 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34749 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34750 "Signaled System Error on %s\n",
34751 pci_name(dev));
34752 - atomic_inc(&pci_nonparity_count);
34753 + atomic_inc_unchecked(&pci_nonparity_count);
34754 }
34755
34756 if (status & (PCI_STATUS_PARITY)) {
34757 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34758 "Master Data Parity Error on "
34759 "%s\n", pci_name(dev));
34760
34761 - atomic_inc(&pci_parity_count);
34762 + atomic_inc_unchecked(&pci_parity_count);
34763 }
34764
34765 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34766 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34767 "Detected Parity Error on %s\n",
34768 pci_name(dev));
34769
34770 - atomic_inc(&pci_parity_count);
34771 + atomic_inc_unchecked(&pci_parity_count);
34772 }
34773 }
34774 }
34775 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34776 if (!check_pci_errors)
34777 return;
34778
34779 - before_count = atomic_read(&pci_parity_count);
34780 + before_count = atomic_read_unchecked(&pci_parity_count);
34781
34782 /* scan all PCI devices looking for a Parity Error on devices and
34783 * bridges.
34784 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34785 /* Only if operator has selected panic on PCI Error */
34786 if (edac_pci_get_panic_on_pe()) {
34787 /* If the count is different 'after' from 'before' */
34788 - if (before_count != atomic_read(&pci_parity_count))
34789 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34790 panic("EDAC: PCI Parity Error");
34791 }
34792 }
34793 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34794 index 51b7e3a..aa8a3e8 100644
34795 --- a/drivers/edac/mce_amd.h
34796 +++ b/drivers/edac/mce_amd.h
34797 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
34798 bool (*mc0_mce)(u16, u8);
34799 bool (*mc1_mce)(u16, u8);
34800 bool (*mc2_mce)(u16, u8);
34801 -};
34802 +} __no_const;
34803
34804 void amd_report_gart_errors(bool);
34805 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34806 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34807 index 57ea7f4..789e3c3 100644
34808 --- a/drivers/firewire/core-card.c
34809 +++ b/drivers/firewire/core-card.c
34810 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34811
34812 void fw_core_remove_card(struct fw_card *card)
34813 {
34814 - struct fw_card_driver dummy_driver = dummy_driver_template;
34815 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34816
34817 card->driver->update_phy_reg(card, 4,
34818 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34819 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34820 index 27ac423..13573e8 100644
34821 --- a/drivers/firewire/core-cdev.c
34822 +++ b/drivers/firewire/core-cdev.c
34823 @@ -1366,8 +1366,7 @@ static int init_iso_resource(struct client *client,
34824 int ret;
34825
34826 if ((request->channels == 0 && request->bandwidth == 0) ||
34827 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34828 - request->bandwidth < 0)
34829 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34830 return -EINVAL;
34831
34832 r = kmalloc(sizeof(*r), GFP_KERNEL);
34833 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34834 index 03ce7d9..b70f5da 100644
34835 --- a/drivers/firewire/core-device.c
34836 +++ b/drivers/firewire/core-device.c
34837 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34838 struct config_rom_attribute {
34839 struct device_attribute attr;
34840 u32 key;
34841 -};
34842 +} __do_const;
34843
34844 static ssize_t show_immediate(struct device *dev,
34845 struct device_attribute *dattr, char *buf)
34846 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34847 index 28a94c7..58da63a 100644
34848 --- a/drivers/firewire/core-transaction.c
34849 +++ b/drivers/firewire/core-transaction.c
34850 @@ -38,6 +38,7 @@
34851 #include <linux/timer.h>
34852 #include <linux/types.h>
34853 #include <linux/workqueue.h>
34854 +#include <linux/sched.h>
34855
34856 #include <asm/byteorder.h>
34857
34858 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34859 index 515a42c..5ecf3ba 100644
34860 --- a/drivers/firewire/core.h
34861 +++ b/drivers/firewire/core.h
34862 @@ -111,6 +111,7 @@ struct fw_card_driver {
34863
34864 int (*stop_iso)(struct fw_iso_context *ctx);
34865 };
34866 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34867
34868 void fw_card_initialize(struct fw_card *card,
34869 const struct fw_card_driver *driver, struct device *device);
34870 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34871 index 94a58a0..f5eba42 100644
34872 --- a/drivers/firmware/dmi-id.c
34873 +++ b/drivers/firmware/dmi-id.c
34874 @@ -16,7 +16,7 @@
34875 struct dmi_device_attribute{
34876 struct device_attribute dev_attr;
34877 int field;
34878 -};
34879 +} __do_const;
34880 #define to_dmi_dev_attr(_dev_attr) \
34881 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34882
34883 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34884 index 4cd392d..4b629e1 100644
34885 --- a/drivers/firmware/dmi_scan.c
34886 +++ b/drivers/firmware/dmi_scan.c
34887 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34888 }
34889 }
34890 else {
34891 - /*
34892 - * no iounmap() for that ioremap(); it would be a no-op, but
34893 - * it's so early in setup that sucker gets confused into doing
34894 - * what it shouldn't if we actually call it.
34895 - */
34896 p = dmi_ioremap(0xF0000, 0x10000);
34897 if (p == NULL)
34898 goto error;
34899 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34900 if (buf == NULL)
34901 return -1;
34902
34903 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34904 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34905
34906 iounmap(buf);
34907 return 0;
34908 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34909 index f4baa11..7970c3a 100644
34910 --- a/drivers/firmware/efivars.c
34911 +++ b/drivers/firmware/efivars.c
34912 @@ -139,7 +139,7 @@ struct efivar_attribute {
34913 };
34914
34915 static struct efivars __efivars;
34916 -static struct efivar_operations ops;
34917 +static efivar_operations_no_const ops __read_only;
34918
34919 #define PSTORE_EFI_ATTRIBUTES \
34920 (EFI_VARIABLE_NON_VOLATILE | \
34921 @@ -1844,7 +1844,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34922 static int
34923 create_efivars_bin_attributes(struct efivars *efivars)
34924 {
34925 - struct bin_attribute *attr;
34926 + bin_attribute_no_const *attr;
34927 int error;
34928
34929 /* new_var */
34930 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34931 index 2a90ba6..07f3733 100644
34932 --- a/drivers/firmware/google/memconsole.c
34933 +++ b/drivers/firmware/google/memconsole.c
34934 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34935 if (!found_memconsole())
34936 return -ENODEV;
34937
34938 - memconsole_bin_attr.size = memconsole_length;
34939 + pax_open_kernel();
34940 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34941 + pax_close_kernel();
34942
34943 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34944
34945 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34946 index de3c317..b7cd029 100644
34947 --- a/drivers/gpio/gpio-ich.c
34948 +++ b/drivers/gpio/gpio-ich.c
34949 @@ -69,7 +69,7 @@ struct ichx_desc {
34950 /* Some chipsets have quirks, let these use their own request/get */
34951 int (*request)(struct gpio_chip *chip, unsigned offset);
34952 int (*get)(struct gpio_chip *chip, unsigned offset);
34953 -};
34954 +} __do_const;
34955
34956 static struct {
34957 spinlock_t lock;
34958 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34959 index 9902732..64b62dd 100644
34960 --- a/drivers/gpio/gpio-vr41xx.c
34961 +++ b/drivers/gpio/gpio-vr41xx.c
34962 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34963 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34964 maskl, pendl, maskh, pendh);
34965
34966 - atomic_inc(&irq_err_count);
34967 + atomic_inc_unchecked(&irq_err_count);
34968
34969 return -EINVAL;
34970 }
34971 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34972 index 7b2d378..cc947ea 100644
34973 --- a/drivers/gpu/drm/drm_crtc_helper.c
34974 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34975 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34976 struct drm_crtc *tmp;
34977 int crtc_mask = 1;
34978
34979 - WARN(!crtc, "checking null crtc?\n");
34980 + BUG_ON(!crtc);
34981
34982 dev = crtc->dev;
34983
34984 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34985 index 25f91cd..a376f55 100644
34986 --- a/drivers/gpu/drm/drm_drv.c
34987 +++ b/drivers/gpu/drm/drm_drv.c
34988 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
34989 /**
34990 * Copy and IOCTL return string to user space
34991 */
34992 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34993 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34994 {
34995 int len;
34996
34997 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
34998 struct drm_file *file_priv = filp->private_data;
34999 struct drm_device *dev;
35000 struct drm_ioctl_desc *ioctl;
35001 - drm_ioctl_t *func;
35002 + drm_ioctl_no_const_t func;
35003 unsigned int nr = DRM_IOCTL_NR(cmd);
35004 int retcode = -EINVAL;
35005 char stack_kdata[128];
35006 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
35007 return -ENODEV;
35008
35009 atomic_inc(&dev->ioctl_count);
35010 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35011 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35012 ++file_priv->ioctl_count;
35013
35014 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
35015 diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c
35016 index 48c52f7..0cfb60f 100644
35017 --- a/drivers/gpu/drm/drm_encoder_slave.c
35018 +++ b/drivers/gpu/drm/drm_encoder_slave.c
35019 @@ -54,16 +54,12 @@ int drm_i2c_encoder_init(struct drm_device *dev,
35020 struct i2c_adapter *adap,
35021 const struct i2c_board_info *info)
35022 {
35023 - char modalias[sizeof(I2C_MODULE_PREFIX)
35024 - + I2C_NAME_SIZE];
35025 struct module *module = NULL;
35026 struct i2c_client *client;
35027 struct drm_i2c_encoder_driver *encoder_drv;
35028 int err = 0;
35029
35030 - snprintf(modalias, sizeof(modalias),
35031 - "%s%s", I2C_MODULE_PREFIX, info->type);
35032 - request_module(modalias);
35033 + request_module("%s%s", I2C_MODULE_PREFIX, info->type);
35034
35035 client = i2c_new_device(adap, info);
35036 if (!client) {
35037 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35038 index 429e07d..e681a2c 100644
35039 --- a/drivers/gpu/drm/drm_fops.c
35040 +++ b/drivers/gpu/drm/drm_fops.c
35041 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35042 }
35043
35044 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35045 - atomic_set(&dev->counts[i], 0);
35046 + atomic_set_unchecked(&dev->counts[i], 0);
35047
35048 dev->sigdata.lock = NULL;
35049
35050 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35051 if (drm_device_is_unplugged(dev))
35052 return -ENODEV;
35053
35054 - if (!dev->open_count++)
35055 + if (local_inc_return(&dev->open_count) == 1)
35056 need_setup = 1;
35057 mutex_lock(&dev->struct_mutex);
35058 old_imapping = inode->i_mapping;
35059 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35060 retcode = drm_open_helper(inode, filp, dev);
35061 if (retcode)
35062 goto err_undo;
35063 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35064 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35065 if (need_setup) {
35066 retcode = drm_setup(dev);
35067 if (retcode)
35068 @@ -166,7 +166,7 @@ err_undo:
35069 iput(container_of(dev->dev_mapping, struct inode, i_data));
35070 dev->dev_mapping = old_mapping;
35071 mutex_unlock(&dev->struct_mutex);
35072 - dev->open_count--;
35073 + local_dec(&dev->open_count);
35074 return retcode;
35075 }
35076 EXPORT_SYMBOL(drm_open);
35077 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
35078
35079 mutex_lock(&drm_global_mutex);
35080
35081 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35082 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35083
35084 if (dev->driver->preclose)
35085 dev->driver->preclose(dev, file_priv);
35086 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
35087 * Begin inline drm_release
35088 */
35089
35090 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35091 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35092 task_pid_nr(current),
35093 (long)old_encode_dev(file_priv->minor->device),
35094 - dev->open_count);
35095 + local_read(&dev->open_count));
35096
35097 /* Release any auth tokens that might point to this file_priv,
35098 (do that under the drm_global_mutex) */
35099 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
35100 * End inline drm_release
35101 */
35102
35103 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35104 - if (!--dev->open_count) {
35105 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35106 + if (local_dec_and_test(&dev->open_count)) {
35107 if (atomic_read(&dev->ioctl_count)) {
35108 DRM_ERROR("Device busy: %d\n",
35109 atomic_read(&dev->ioctl_count));
35110 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35111 index f731116..629842c 100644
35112 --- a/drivers/gpu/drm/drm_global.c
35113 +++ b/drivers/gpu/drm/drm_global.c
35114 @@ -36,7 +36,7 @@
35115 struct drm_global_item {
35116 struct mutex mutex;
35117 void *object;
35118 - int refcount;
35119 + atomic_t refcount;
35120 };
35121
35122 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35123 @@ -49,7 +49,7 @@ void drm_global_init(void)
35124 struct drm_global_item *item = &glob[i];
35125 mutex_init(&item->mutex);
35126 item->object = NULL;
35127 - item->refcount = 0;
35128 + atomic_set(&item->refcount, 0);
35129 }
35130 }
35131
35132 @@ -59,7 +59,7 @@ void drm_global_release(void)
35133 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35134 struct drm_global_item *item = &glob[i];
35135 BUG_ON(item->object != NULL);
35136 - BUG_ON(item->refcount != 0);
35137 + BUG_ON(atomic_read(&item->refcount) != 0);
35138 }
35139 }
35140
35141 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35142 void *object;
35143
35144 mutex_lock(&item->mutex);
35145 - if (item->refcount == 0) {
35146 + if (atomic_read(&item->refcount) == 0) {
35147 item->object = kzalloc(ref->size, GFP_KERNEL);
35148 if (unlikely(item->object == NULL)) {
35149 ret = -ENOMEM;
35150 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35151 goto out_err;
35152
35153 }
35154 - ++item->refcount;
35155 + atomic_inc(&item->refcount);
35156 ref->object = item->object;
35157 object = item->object;
35158 mutex_unlock(&item->mutex);
35159 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35160 struct drm_global_item *item = &glob[ref->global_type];
35161
35162 mutex_lock(&item->mutex);
35163 - BUG_ON(item->refcount == 0);
35164 + BUG_ON(atomic_read(&item->refcount) == 0);
35165 BUG_ON(ref->object != item->object);
35166 - if (--item->refcount == 0) {
35167 + if (atomic_dec_and_test(&item->refcount)) {
35168 ref->release(ref);
35169 item->object = NULL;
35170 }
35171 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35172 index d4b20ce..77a8d41 100644
35173 --- a/drivers/gpu/drm/drm_info.c
35174 +++ b/drivers/gpu/drm/drm_info.c
35175 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35176 struct drm_local_map *map;
35177 struct drm_map_list *r_list;
35178
35179 - /* Hardcoded from _DRM_FRAME_BUFFER,
35180 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35181 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35182 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35183 + static const char * const types[] = {
35184 + [_DRM_FRAME_BUFFER] = "FB",
35185 + [_DRM_REGISTERS] = "REG",
35186 + [_DRM_SHM] = "SHM",
35187 + [_DRM_AGP] = "AGP",
35188 + [_DRM_SCATTER_GATHER] = "SG",
35189 + [_DRM_CONSISTENT] = "PCI",
35190 + [_DRM_GEM] = "GEM" };
35191 const char *type;
35192 int i;
35193
35194 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35195 map = r_list->map;
35196 if (!map)
35197 continue;
35198 - if (map->type < 0 || map->type > 5)
35199 + if (map->type >= ARRAY_SIZE(types))
35200 type = "??";
35201 else
35202 type = types[map->type];
35203 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35204 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35205 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35206 vma->vm_flags & VM_IO ? 'i' : '-',
35207 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35208 + 0);
35209 +#else
35210 vma->vm_pgoff);
35211 +#endif
35212
35213 #if defined(__i386__)
35214 pgprot = pgprot_val(vma->vm_page_prot);
35215 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35216 index 2f4c434..dd12cd2 100644
35217 --- a/drivers/gpu/drm/drm_ioc32.c
35218 +++ b/drivers/gpu/drm/drm_ioc32.c
35219 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35220 request = compat_alloc_user_space(nbytes);
35221 if (!access_ok(VERIFY_WRITE, request, nbytes))
35222 return -EFAULT;
35223 - list = (struct drm_buf_desc *) (request + 1);
35224 + list = (struct drm_buf_desc __user *) (request + 1);
35225
35226 if (__put_user(count, &request->count)
35227 || __put_user(list, &request->list))
35228 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35229 request = compat_alloc_user_space(nbytes);
35230 if (!access_ok(VERIFY_WRITE, request, nbytes))
35231 return -EFAULT;
35232 - list = (struct drm_buf_pub *) (request + 1);
35233 + list = (struct drm_buf_pub __user *) (request + 1);
35234
35235 if (__put_user(count, &request->count)
35236 || __put_user(list, &request->list))
35237 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35238 return 0;
35239 }
35240
35241 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35242 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35243 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35244 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35245 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35246 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35247 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35248 {
35249 unsigned int nr = DRM_IOCTL_NR(cmd);
35250 - drm_ioctl_compat_t *fn;
35251 int ret;
35252
35253 /* Assume that ioctls without an explicit compat routine will just
35254 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35255 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35256 return drm_ioctl(filp, cmd, arg);
35257
35258 - fn = drm_compat_ioctls[nr];
35259 -
35260 - if (fn != NULL)
35261 - ret = (*fn) (filp, cmd, arg);
35262 + if (drm_compat_ioctls[nr] != NULL)
35263 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35264 else
35265 ret = drm_ioctl(filp, cmd, arg);
35266
35267 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35268 index e77bd8b..1571b85 100644
35269 --- a/drivers/gpu/drm/drm_ioctl.c
35270 +++ b/drivers/gpu/drm/drm_ioctl.c
35271 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35272 stats->data[i].value =
35273 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35274 else
35275 - stats->data[i].value = atomic_read(&dev->counts[i]);
35276 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35277 stats->data[i].type = dev->types[i];
35278 }
35279
35280 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35281 index d752c96..fe08455 100644
35282 --- a/drivers/gpu/drm/drm_lock.c
35283 +++ b/drivers/gpu/drm/drm_lock.c
35284 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35285 if (drm_lock_take(&master->lock, lock->context)) {
35286 master->lock.file_priv = file_priv;
35287 master->lock.lock_time = jiffies;
35288 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35289 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35290 break; /* Got lock */
35291 }
35292
35293 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35294 return -EINVAL;
35295 }
35296
35297 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35298 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35299
35300 if (drm_lock_free(&master->lock, lock->context)) {
35301 /* FIXME: Should really bail out here. */
35302 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35303 index 7d30802..42c6cbb 100644
35304 --- a/drivers/gpu/drm/drm_stub.c
35305 +++ b/drivers/gpu/drm/drm_stub.c
35306 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35307
35308 drm_device_set_unplugged(dev);
35309
35310 - if (dev->open_count == 0) {
35311 + if (local_read(&dev->open_count) == 0) {
35312 drm_put_dev(dev);
35313 }
35314 mutex_unlock(&drm_global_mutex);
35315 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
35316 index 0229665..f61329c 100644
35317 --- a/drivers/gpu/drm/drm_sysfs.c
35318 +++ b/drivers/gpu/drm/drm_sysfs.c
35319 @@ -499,7 +499,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
35320 int drm_sysfs_device_add(struct drm_minor *minor)
35321 {
35322 int err;
35323 - char *minor_str;
35324 + const char *minor_str;
35325
35326 minor->kdev.parent = minor->dev->dev;
35327
35328 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35329 index 004ecdf..db1f6e0 100644
35330 --- a/drivers/gpu/drm/i810/i810_dma.c
35331 +++ b/drivers/gpu/drm/i810/i810_dma.c
35332 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35333 dma->buflist[vertex->idx],
35334 vertex->discard, vertex->used);
35335
35336 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35337 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35338 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35339 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35340 sarea_priv->last_enqueue = dev_priv->counter - 1;
35341 sarea_priv->last_dispatch = (int)hw_status[5];
35342
35343 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35344 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35345 mc->last_render);
35346
35347 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35348 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35349 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35350 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35351 sarea_priv->last_enqueue = dev_priv->counter - 1;
35352 sarea_priv->last_dispatch = (int)hw_status[5];
35353
35354 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35355 index 6e0acad..93c8289 100644
35356 --- a/drivers/gpu/drm/i810/i810_drv.h
35357 +++ b/drivers/gpu/drm/i810/i810_drv.h
35358 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35359 int page_flipping;
35360
35361 wait_queue_head_t irq_queue;
35362 - atomic_t irq_received;
35363 - atomic_t irq_emitted;
35364 + atomic_unchecked_t irq_received;
35365 + atomic_unchecked_t irq_emitted;
35366
35367 int front_offset;
35368 } drm_i810_private_t;
35369 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35370 index 7299ea4..5314487 100644
35371 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35372 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35373 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35374 I915_READ(GTIMR));
35375 }
35376 seq_printf(m, "Interrupts received: %d\n",
35377 - atomic_read(&dev_priv->irq_received));
35378 + atomic_read_unchecked(&dev_priv->irq_received));
35379 for_each_ring(ring, dev_priv, i) {
35380 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35381 seq_printf(m,
35382 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35383 index 4fa6beb..f930fec 100644
35384 --- a/drivers/gpu/drm/i915/i915_dma.c
35385 +++ b/drivers/gpu/drm/i915/i915_dma.c
35386 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35387 bool can_switch;
35388
35389 spin_lock(&dev->count_lock);
35390 - can_switch = (dev->open_count == 0);
35391 + can_switch = (local_read(&dev->open_count) == 0);
35392 spin_unlock(&dev->count_lock);
35393 return can_switch;
35394 }
35395 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35396 index ef99b1c..09ce7fb 100644
35397 --- a/drivers/gpu/drm/i915/i915_drv.h
35398 +++ b/drivers/gpu/drm/i915/i915_drv.h
35399 @@ -893,7 +893,7 @@ typedef struct drm_i915_private {
35400 drm_dma_handle_t *status_page_dmah;
35401 struct resource mch_res;
35402
35403 - atomic_t irq_received;
35404 + atomic_unchecked_t irq_received;
35405
35406 /* protects the irq masks */
35407 spinlock_t irq_lock;
35408 @@ -1775,7 +1775,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35409 struct drm_i915_private *dev_priv, unsigned port);
35410 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35411 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35412 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35413 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35414 {
35415 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35416 }
35417 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35418 index 9a48e1a..f0cbc3e 100644
35419 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35420 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35421 @@ -729,9 +729,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35422
35423 static int
35424 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35425 - int count)
35426 + unsigned int count)
35427 {
35428 - int i;
35429 + unsigned int i;
35430 int relocs_total = 0;
35431 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35432
35433 @@ -1195,7 +1195,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35434 return -ENOMEM;
35435 }
35436 ret = copy_from_user(exec2_list,
35437 - (struct drm_i915_relocation_entry __user *)
35438 + (struct drm_i915_gem_exec_object2 __user *)
35439 (uintptr_t) args->buffers_ptr,
35440 sizeof(*exec2_list) * args->buffer_count);
35441 if (ret != 0) {
35442 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35443 index 3c59584..500f2e9 100644
35444 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35445 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35446 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35447 (unsigned long)request);
35448 }
35449
35450 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35451 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35452 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35453 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35454 [DRM_I915_GETPARAM] = compat_i915_getparam,
35455 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35456 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35457 {
35458 unsigned int nr = DRM_IOCTL_NR(cmd);
35459 - drm_ioctl_compat_t *fn = NULL;
35460 int ret;
35461
35462 if (nr < DRM_COMMAND_BASE)
35463 return drm_compat_ioctl(filp, cmd, arg);
35464
35465 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35466 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35467 -
35468 - if (fn != NULL)
35469 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35470 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35471 ret = (*fn) (filp, cmd, arg);
35472 - else
35473 + } else
35474 ret = drm_ioctl(filp, cmd, arg);
35475
35476 return ret;
35477 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35478 index 3c7bb04..182e049 100644
35479 --- a/drivers/gpu/drm/i915/i915_irq.c
35480 +++ b/drivers/gpu/drm/i915/i915_irq.c
35481 @@ -549,7 +549,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35482 int pipe;
35483 u32 pipe_stats[I915_MAX_PIPES];
35484
35485 - atomic_inc(&dev_priv->irq_received);
35486 + atomic_inc_unchecked(&dev_priv->irq_received);
35487
35488 while (true) {
35489 iir = I915_READ(VLV_IIR);
35490 @@ -705,7 +705,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35491 irqreturn_t ret = IRQ_NONE;
35492 int i;
35493
35494 - atomic_inc(&dev_priv->irq_received);
35495 + atomic_inc_unchecked(&dev_priv->irq_received);
35496
35497 /* disable master interrupt before clearing iir */
35498 de_ier = I915_READ(DEIER);
35499 @@ -791,7 +791,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35500 int ret = IRQ_NONE;
35501 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35502
35503 - atomic_inc(&dev_priv->irq_received);
35504 + atomic_inc_unchecked(&dev_priv->irq_received);
35505
35506 /* disable master interrupt before clearing iir */
35507 de_ier = I915_READ(DEIER);
35508 @@ -1886,7 +1886,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35509 {
35510 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35511
35512 - atomic_set(&dev_priv->irq_received, 0);
35513 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35514
35515 I915_WRITE(HWSTAM, 0xeffe);
35516
35517 @@ -1912,7 +1912,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35518 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35519 int pipe;
35520
35521 - atomic_set(&dev_priv->irq_received, 0);
35522 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35523
35524 /* VLV magic */
35525 I915_WRITE(VLV_IMR, 0);
35526 @@ -2208,7 +2208,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35527 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35528 int pipe;
35529
35530 - atomic_set(&dev_priv->irq_received, 0);
35531 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35532
35533 for_each_pipe(pipe)
35534 I915_WRITE(PIPESTAT(pipe), 0);
35535 @@ -2259,7 +2259,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35536 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35537 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35538
35539 - atomic_inc(&dev_priv->irq_received);
35540 + atomic_inc_unchecked(&dev_priv->irq_received);
35541
35542 iir = I915_READ16(IIR);
35543 if (iir == 0)
35544 @@ -2344,7 +2344,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35545 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35546 int pipe;
35547
35548 - atomic_set(&dev_priv->irq_received, 0);
35549 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35550
35551 if (I915_HAS_HOTPLUG(dev)) {
35552 I915_WRITE(PORT_HOTPLUG_EN, 0);
35553 @@ -2448,7 +2448,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35554 };
35555 int pipe, ret = IRQ_NONE;
35556
35557 - atomic_inc(&dev_priv->irq_received);
35558 + atomic_inc_unchecked(&dev_priv->irq_received);
35559
35560 iir = I915_READ(IIR);
35561 do {
35562 @@ -2574,7 +2574,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35563 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35564 int pipe;
35565
35566 - atomic_set(&dev_priv->irq_received, 0);
35567 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35568
35569 I915_WRITE(PORT_HOTPLUG_EN, 0);
35570 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35571 @@ -2690,7 +2690,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35572 int irq_received;
35573 int ret = IRQ_NONE, pipe;
35574
35575 - atomic_inc(&dev_priv->irq_received);
35576 + atomic_inc_unchecked(&dev_priv->irq_received);
35577
35578 iir = I915_READ(IIR);
35579
35580 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35581 index 2ab65b4..acbd821 100644
35582 --- a/drivers/gpu/drm/i915/intel_display.c
35583 +++ b/drivers/gpu/drm/i915/intel_display.c
35584 @@ -8742,13 +8742,13 @@ struct intel_quirk {
35585 int subsystem_vendor;
35586 int subsystem_device;
35587 void (*hook)(struct drm_device *dev);
35588 -};
35589 +} __do_const;
35590
35591 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35592 struct intel_dmi_quirk {
35593 void (*hook)(struct drm_device *dev);
35594 const struct dmi_system_id (*dmi_id_list)[];
35595 -};
35596 +} __do_const;
35597
35598 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35599 {
35600 @@ -8756,18 +8756,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35601 return 1;
35602 }
35603
35604 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35605 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35606 {
35607 - .dmi_id_list = &(const struct dmi_system_id[]) {
35608 - {
35609 - .callback = intel_dmi_reverse_brightness,
35610 - .ident = "NCR Corporation",
35611 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35612 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35613 - },
35614 - },
35615 - { } /* terminating entry */
35616 + .callback = intel_dmi_reverse_brightness,
35617 + .ident = "NCR Corporation",
35618 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35619 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35620 },
35621 + },
35622 + { } /* terminating entry */
35623 +};
35624 +
35625 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35626 + {
35627 + .dmi_id_list = &intel_dmi_quirks_table,
35628 .hook = quirk_invert_brightness,
35629 },
35630 };
35631 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35632 index 54558a0..2d97005 100644
35633 --- a/drivers/gpu/drm/mga/mga_drv.h
35634 +++ b/drivers/gpu/drm/mga/mga_drv.h
35635 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35636 u32 clear_cmd;
35637 u32 maccess;
35638
35639 - atomic_t vbl_received; /**< Number of vblanks received. */
35640 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35641 wait_queue_head_t fence_queue;
35642 - atomic_t last_fence_retired;
35643 + atomic_unchecked_t last_fence_retired;
35644 u32 next_fence_to_post;
35645
35646 unsigned int fb_cpp;
35647 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35648 index 709e90d..89a1c0d 100644
35649 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35650 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35651 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35652 return 0;
35653 }
35654
35655 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35656 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35657 [DRM_MGA_INIT] = compat_mga_init,
35658 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35659 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35660 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35661 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35662 {
35663 unsigned int nr = DRM_IOCTL_NR(cmd);
35664 - drm_ioctl_compat_t *fn = NULL;
35665 int ret;
35666
35667 if (nr < DRM_COMMAND_BASE)
35668 return drm_compat_ioctl(filp, cmd, arg);
35669
35670 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35671 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35672 -
35673 - if (fn != NULL)
35674 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35675 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35676 ret = (*fn) (filp, cmd, arg);
35677 - else
35678 + } else
35679 ret = drm_ioctl(filp, cmd, arg);
35680
35681 return ret;
35682 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35683 index 598c281..60d590e 100644
35684 --- a/drivers/gpu/drm/mga/mga_irq.c
35685 +++ b/drivers/gpu/drm/mga/mga_irq.c
35686 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35687 if (crtc != 0)
35688 return 0;
35689
35690 - return atomic_read(&dev_priv->vbl_received);
35691 + return atomic_read_unchecked(&dev_priv->vbl_received);
35692 }
35693
35694
35695 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35696 /* VBLANK interrupt */
35697 if (status & MGA_VLINEPEN) {
35698 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35699 - atomic_inc(&dev_priv->vbl_received);
35700 + atomic_inc_unchecked(&dev_priv->vbl_received);
35701 drm_handle_vblank(dev, 0);
35702 handled = 1;
35703 }
35704 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35705 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35706 MGA_WRITE(MGA_PRIMEND, prim_end);
35707
35708 - atomic_inc(&dev_priv->last_fence_retired);
35709 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35710 DRM_WAKEUP(&dev_priv->fence_queue);
35711 handled = 1;
35712 }
35713 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35714 * using fences.
35715 */
35716 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35717 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35718 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35719 - *sequence) <= (1 << 23)));
35720
35721 *sequence = cur_fence;
35722 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35723 index 50a6dd0..ea66ed8 100644
35724 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35725 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35726 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35727 struct bit_table {
35728 const char id;
35729 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35730 -};
35731 +} __no_const;
35732
35733 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35734
35735 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35736 index 9c39baf..30a22be 100644
35737 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35738 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35739 @@ -81,7 +81,7 @@ struct nouveau_drm {
35740 struct drm_global_reference mem_global_ref;
35741 struct ttm_bo_global_ref bo_global_ref;
35742 struct ttm_bo_device bdev;
35743 - atomic_t validate_sequence;
35744 + atomic_unchecked_t validate_sequence;
35745 int (*move)(struct nouveau_channel *,
35746 struct ttm_buffer_object *,
35747 struct ttm_mem_reg *, struct ttm_mem_reg *);
35748 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35749 index b4b4d0c..b7edc15 100644
35750 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35751 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35752 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35753 int ret, i;
35754 struct nouveau_bo *res_bo = NULL;
35755
35756 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35757 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35758 retry:
35759 if (++trycnt > 100000) {
35760 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35761 @@ -359,7 +359,7 @@ retry:
35762 if (ret) {
35763 validate_fini(op, NULL);
35764 if (unlikely(ret == -EAGAIN)) {
35765 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35766 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35767 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35768 sequence);
35769 if (!ret)
35770 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35771 index 08214bc..9208577 100644
35772 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35773 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35774 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35775 unsigned long arg)
35776 {
35777 unsigned int nr = DRM_IOCTL_NR(cmd);
35778 - drm_ioctl_compat_t *fn = NULL;
35779 + drm_ioctl_compat_t fn = NULL;
35780 int ret;
35781
35782 if (nr < DRM_COMMAND_BASE)
35783 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35784 index 25d3495..d81aaf6 100644
35785 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35786 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35787 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35788 bool can_switch;
35789
35790 spin_lock(&dev->count_lock);
35791 - can_switch = (dev->open_count == 0);
35792 + can_switch = (local_read(&dev->open_count) == 0);
35793 spin_unlock(&dev->count_lock);
35794 return can_switch;
35795 }
35796 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35797 index d4660cf..70dbe65 100644
35798 --- a/drivers/gpu/drm/r128/r128_cce.c
35799 +++ b/drivers/gpu/drm/r128/r128_cce.c
35800 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35801
35802 /* GH: Simple idle check.
35803 */
35804 - atomic_set(&dev_priv->idle_count, 0);
35805 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35806
35807 /* We don't support anything other than bus-mastering ring mode,
35808 * but the ring can be in either AGP or PCI space for the ring
35809 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35810 index 930c71b..499aded 100644
35811 --- a/drivers/gpu/drm/r128/r128_drv.h
35812 +++ b/drivers/gpu/drm/r128/r128_drv.h
35813 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35814 int is_pci;
35815 unsigned long cce_buffers_offset;
35816
35817 - atomic_t idle_count;
35818 + atomic_unchecked_t idle_count;
35819
35820 int page_flipping;
35821 int current_page;
35822 u32 crtc_offset;
35823 u32 crtc_offset_cntl;
35824
35825 - atomic_t vbl_received;
35826 + atomic_unchecked_t vbl_received;
35827
35828 u32 color_fmt;
35829 unsigned int front_offset;
35830 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35831 index a954c54..9cc595c 100644
35832 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35833 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35834 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35835 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35836 }
35837
35838 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35839 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35840 [DRM_R128_INIT] = compat_r128_init,
35841 [DRM_R128_DEPTH] = compat_r128_depth,
35842 [DRM_R128_STIPPLE] = compat_r128_stipple,
35843 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35844 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35845 {
35846 unsigned int nr = DRM_IOCTL_NR(cmd);
35847 - drm_ioctl_compat_t *fn = NULL;
35848 int ret;
35849
35850 if (nr < DRM_COMMAND_BASE)
35851 return drm_compat_ioctl(filp, cmd, arg);
35852
35853 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35854 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35855 -
35856 - if (fn != NULL)
35857 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35858 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35859 ret = (*fn) (filp, cmd, arg);
35860 - else
35861 + } else
35862 ret = drm_ioctl(filp, cmd, arg);
35863
35864 return ret;
35865 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35866 index 2ea4f09..d391371 100644
35867 --- a/drivers/gpu/drm/r128/r128_irq.c
35868 +++ b/drivers/gpu/drm/r128/r128_irq.c
35869 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35870 if (crtc != 0)
35871 return 0;
35872
35873 - return atomic_read(&dev_priv->vbl_received);
35874 + return atomic_read_unchecked(&dev_priv->vbl_received);
35875 }
35876
35877 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35878 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35879 /* VBLANK interrupt */
35880 if (status & R128_CRTC_VBLANK_INT) {
35881 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35882 - atomic_inc(&dev_priv->vbl_received);
35883 + atomic_inc_unchecked(&dev_priv->vbl_received);
35884 drm_handle_vblank(dev, 0);
35885 return IRQ_HANDLED;
35886 }
35887 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35888 index 19bb7e6..de7e2a2 100644
35889 --- a/drivers/gpu/drm/r128/r128_state.c
35890 +++ b/drivers/gpu/drm/r128/r128_state.c
35891 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35892
35893 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35894 {
35895 - if (atomic_read(&dev_priv->idle_count) == 0)
35896 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35897 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35898 else
35899 - atomic_set(&dev_priv->idle_count, 0);
35900 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35901 }
35902
35903 #endif
35904 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35905 index 5a82b6b..9e69c73 100644
35906 --- a/drivers/gpu/drm/radeon/mkregtable.c
35907 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35908 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35909 regex_t mask_rex;
35910 regmatch_t match[4];
35911 char buf[1024];
35912 - size_t end;
35913 + long end;
35914 int len;
35915 int done = 0;
35916 int r;
35917 unsigned o;
35918 struct offset *offset;
35919 char last_reg_s[10];
35920 - int last_reg;
35921 + unsigned long last_reg;
35922
35923 if (regcomp
35924 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35925 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35926 index 5073665..31d15a6 100644
35927 --- a/drivers/gpu/drm/radeon/radeon_device.c
35928 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35929 @@ -976,7 +976,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35930 bool can_switch;
35931
35932 spin_lock(&dev->count_lock);
35933 - can_switch = (dev->open_count == 0);
35934 + can_switch = (local_read(&dev->open_count) == 0);
35935 spin_unlock(&dev->count_lock);
35936 return can_switch;
35937 }
35938 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35939 index b369d42..8dd04eb 100644
35940 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35941 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35942 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
35943
35944 /* SW interrupt */
35945 wait_queue_head_t swi_queue;
35946 - atomic_t swi_emitted;
35947 + atomic_unchecked_t swi_emitted;
35948 int vblank_crtc;
35949 uint32_t irq_enable_reg;
35950 uint32_t r500_disp_irq_reg;
35951 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35952 index c180df8..5fd8186 100644
35953 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35954 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35955 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35956 request = compat_alloc_user_space(sizeof(*request));
35957 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35958 || __put_user(req32.param, &request->param)
35959 - || __put_user((void __user *)(unsigned long)req32.value,
35960 + || __put_user((unsigned long)req32.value,
35961 &request->value))
35962 return -EFAULT;
35963
35964 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35965 #define compat_radeon_cp_setparam NULL
35966 #endif /* X86_64 || IA64 */
35967
35968 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35969 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35970 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35971 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35972 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35973 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35974 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35975 {
35976 unsigned int nr = DRM_IOCTL_NR(cmd);
35977 - drm_ioctl_compat_t *fn = NULL;
35978 int ret;
35979
35980 if (nr < DRM_COMMAND_BASE)
35981 return drm_compat_ioctl(filp, cmd, arg);
35982
35983 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35984 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35985 -
35986 - if (fn != NULL)
35987 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35988 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35989 ret = (*fn) (filp, cmd, arg);
35990 - else
35991 + } else
35992 ret = drm_ioctl(filp, cmd, arg);
35993
35994 return ret;
35995 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35996 index 8d68e97..9dcfed8 100644
35997 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35998 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35999 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36000 unsigned int ret;
36001 RING_LOCALS;
36002
36003 - atomic_inc(&dev_priv->swi_emitted);
36004 - ret = atomic_read(&dev_priv->swi_emitted);
36005 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36006 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36007
36008 BEGIN_RING(4);
36009 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36010 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36011 drm_radeon_private_t *dev_priv =
36012 (drm_radeon_private_t *) dev->dev_private;
36013
36014 - atomic_set(&dev_priv->swi_emitted, 0);
36015 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36016 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36017
36018 dev->max_vblank_count = 0x001fffff;
36019 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36020 index 4d20910..6726b6d 100644
36021 --- a/drivers/gpu/drm/radeon/radeon_state.c
36022 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36023 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36024 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36025 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36026
36027 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36028 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36029 sarea_priv->nbox * sizeof(depth_boxes[0])))
36030 return -EFAULT;
36031
36032 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36033 {
36034 drm_radeon_private_t *dev_priv = dev->dev_private;
36035 drm_radeon_getparam_t *param = data;
36036 - int value;
36037 + int value = 0;
36038
36039 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36040
36041 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36042 index 6c0ce89..66f6d65 100644
36043 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36044 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36045 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36046 man->size = size >> PAGE_SHIFT;
36047 }
36048
36049 -static struct vm_operations_struct radeon_ttm_vm_ops;
36050 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36051 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36052
36053 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36054 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36055 }
36056 if (unlikely(ttm_vm_ops == NULL)) {
36057 ttm_vm_ops = vma->vm_ops;
36058 + pax_open_kernel();
36059 radeon_ttm_vm_ops = *ttm_vm_ops;
36060 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36061 + pax_close_kernel();
36062 }
36063 vma->vm_ops = &radeon_ttm_vm_ops;
36064 return 0;
36065 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36066 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36067 else
36068 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36069 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36070 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36071 - radeon_mem_types_list[i].driver_features = 0;
36072 + pax_open_kernel();
36073 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36074 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36075 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36076 if (i == 0)
36077 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36078 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36079 else
36080 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36081 -
36082 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36083 + pax_close_kernel();
36084 }
36085 /* Add ttm page pool to debugfs */
36086 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36087 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36088 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36089 - radeon_mem_types_list[i].driver_features = 0;
36090 - radeon_mem_types_list[i++].data = NULL;
36091 + pax_open_kernel();
36092 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36093 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36094 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36095 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36096 + pax_close_kernel();
36097 #ifdef CONFIG_SWIOTLB
36098 if (swiotlb_nr_tbl()) {
36099 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36100 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36101 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36102 - radeon_mem_types_list[i].driver_features = 0;
36103 - radeon_mem_types_list[i++].data = NULL;
36104 + pax_open_kernel();
36105 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36106 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36107 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36108 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36109 + pax_close_kernel();
36110 }
36111 #endif
36112 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36113 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36114 index fad6633..4ff94de 100644
36115 --- a/drivers/gpu/drm/radeon/rs690.c
36116 +++ b/drivers/gpu/drm/radeon/rs690.c
36117 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36118 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36119 rdev->pm.sideport_bandwidth.full)
36120 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36121 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36122 + read_delay_latency.full = dfixed_const(800 * 1000);
36123 read_delay_latency.full = dfixed_div(read_delay_latency,
36124 rdev->pm.igp_sideport_mclk);
36125 + a.full = dfixed_const(370);
36126 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36127 } else {
36128 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36129 rdev->pm.k8_bandwidth.full)
36130 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
36131 index dbc2def..0a9f710 100644
36132 --- a/drivers/gpu/drm/ttm/ttm_memory.c
36133 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
36134 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
36135 zone->glob = glob;
36136 glob->zone_kernel = zone;
36137 ret = kobject_init_and_add(
36138 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36139 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36140 if (unlikely(ret != 0)) {
36141 kobject_put(&zone->kobj);
36142 return ret;
36143 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
36144 zone->glob = glob;
36145 glob->zone_dma32 = zone;
36146 ret = kobject_init_and_add(
36147 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36148 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36149 if (unlikely(ret != 0)) {
36150 kobject_put(&zone->kobj);
36151 return ret;
36152 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36153 index bd2a3b4..122d9ad 100644
36154 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36155 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36156 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36157 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36158 struct shrink_control *sc)
36159 {
36160 - static atomic_t start_pool = ATOMIC_INIT(0);
36161 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36162 unsigned i;
36163 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36164 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36165 struct ttm_page_pool *pool;
36166 int shrink_pages = sc->nr_to_scan;
36167
36168 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36169 index 9f4be3d..cbc9fcc 100644
36170 --- a/drivers/gpu/drm/udl/udl_fb.c
36171 +++ b/drivers/gpu/drm/udl/udl_fb.c
36172 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36173 fb_deferred_io_cleanup(info);
36174 kfree(info->fbdefio);
36175 info->fbdefio = NULL;
36176 - info->fbops->fb_mmap = udl_fb_mmap;
36177 }
36178
36179 pr_warn("released /dev/fb%d user=%d count=%d\n",
36180 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36181 index 893a650..6190d3b 100644
36182 --- a/drivers/gpu/drm/via/via_drv.h
36183 +++ b/drivers/gpu/drm/via/via_drv.h
36184 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36185 typedef uint32_t maskarray_t[5];
36186
36187 typedef struct drm_via_irq {
36188 - atomic_t irq_received;
36189 + atomic_unchecked_t irq_received;
36190 uint32_t pending_mask;
36191 uint32_t enable_mask;
36192 wait_queue_head_t irq_queue;
36193 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36194 struct timeval last_vblank;
36195 int last_vblank_valid;
36196 unsigned usec_per_vblank;
36197 - atomic_t vbl_received;
36198 + atomic_unchecked_t vbl_received;
36199 drm_via_state_t hc_state;
36200 char pci_buf[VIA_PCI_BUF_SIZE];
36201 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36202 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36203 index ac98964..5dbf512 100644
36204 --- a/drivers/gpu/drm/via/via_irq.c
36205 +++ b/drivers/gpu/drm/via/via_irq.c
36206 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36207 if (crtc != 0)
36208 return 0;
36209
36210 - return atomic_read(&dev_priv->vbl_received);
36211 + return atomic_read_unchecked(&dev_priv->vbl_received);
36212 }
36213
36214 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36215 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36216
36217 status = VIA_READ(VIA_REG_INTERRUPT);
36218 if (status & VIA_IRQ_VBLANK_PENDING) {
36219 - atomic_inc(&dev_priv->vbl_received);
36220 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36221 + atomic_inc_unchecked(&dev_priv->vbl_received);
36222 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36223 do_gettimeofday(&cur_vblank);
36224 if (dev_priv->last_vblank_valid) {
36225 dev_priv->usec_per_vblank =
36226 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36227 dev_priv->last_vblank = cur_vblank;
36228 dev_priv->last_vblank_valid = 1;
36229 }
36230 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36231 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36232 DRM_DEBUG("US per vblank is: %u\n",
36233 dev_priv->usec_per_vblank);
36234 }
36235 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36236
36237 for (i = 0; i < dev_priv->num_irqs; ++i) {
36238 if (status & cur_irq->pending_mask) {
36239 - atomic_inc(&cur_irq->irq_received);
36240 + atomic_inc_unchecked(&cur_irq->irq_received);
36241 DRM_WAKEUP(&cur_irq->irq_queue);
36242 handled = 1;
36243 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36244 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36245 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36246 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36247 masks[irq][4]));
36248 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36249 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36250 } else {
36251 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36252 (((cur_irq_sequence =
36253 - atomic_read(&cur_irq->irq_received)) -
36254 + atomic_read_unchecked(&cur_irq->irq_received)) -
36255 *sequence) <= (1 << 23)));
36256 }
36257 *sequence = cur_irq_sequence;
36258 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36259 }
36260
36261 for (i = 0; i < dev_priv->num_irqs; ++i) {
36262 - atomic_set(&cur_irq->irq_received, 0);
36263 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36264 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36265 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36266 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36267 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36268 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36269 case VIA_IRQ_RELATIVE:
36270 irqwait->request.sequence +=
36271 - atomic_read(&cur_irq->irq_received);
36272 + atomic_read_unchecked(&cur_irq->irq_received);
36273 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36274 case VIA_IRQ_ABSOLUTE:
36275 break;
36276 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36277 index 13aeda7..4a952d1 100644
36278 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36279 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36280 @@ -290,7 +290,7 @@ struct vmw_private {
36281 * Fencing and IRQs.
36282 */
36283
36284 - atomic_t marker_seq;
36285 + atomic_unchecked_t marker_seq;
36286 wait_queue_head_t fence_queue;
36287 wait_queue_head_t fifo_queue;
36288 int fence_queue_waiters; /* Protected by hw_mutex */
36289 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36290 index 3eb1486..0a47ee9 100644
36291 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36292 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36293 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36294 (unsigned int) min,
36295 (unsigned int) fifo->capabilities);
36296
36297 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36298 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36299 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36300 vmw_marker_queue_init(&fifo->marker_queue);
36301 return vmw_fifo_send_fence(dev_priv, &dummy);
36302 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36303 if (reserveable)
36304 iowrite32(bytes, fifo_mem +
36305 SVGA_FIFO_RESERVED);
36306 - return fifo_mem + (next_cmd >> 2);
36307 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36308 } else {
36309 need_bounce = true;
36310 }
36311 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36312
36313 fm = vmw_fifo_reserve(dev_priv, bytes);
36314 if (unlikely(fm == NULL)) {
36315 - *seqno = atomic_read(&dev_priv->marker_seq);
36316 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36317 ret = -ENOMEM;
36318 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36319 false, 3*HZ);
36320 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36321 }
36322
36323 do {
36324 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36325 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36326 } while (*seqno == 0);
36327
36328 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36329 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36330 index c509d40..3b640c3 100644
36331 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36332 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36333 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36334 int ret;
36335
36336 num_clips = arg->num_clips;
36337 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36338 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36339
36340 if (unlikely(num_clips == 0))
36341 return 0;
36342 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36343 int ret;
36344
36345 num_clips = arg->num_clips;
36346 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36347 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36348
36349 if (unlikely(num_clips == 0))
36350 return 0;
36351 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36352 index 4640adb..e1384ed 100644
36353 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36354 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36355 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36356 * emitted. Then the fence is stale and signaled.
36357 */
36358
36359 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36360 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36361 > VMW_FENCE_WRAP);
36362
36363 return ret;
36364 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36365
36366 if (fifo_idle)
36367 down_read(&fifo_state->rwsem);
36368 - signal_seq = atomic_read(&dev_priv->marker_seq);
36369 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36370 ret = 0;
36371
36372 for (;;) {
36373 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36374 index 8a8725c2..afed796 100644
36375 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36376 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36377 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36378 while (!vmw_lag_lt(queue, us)) {
36379 spin_lock(&queue->lock);
36380 if (list_empty(&queue->head))
36381 - seqno = atomic_read(&dev_priv->marker_seq);
36382 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36383 else {
36384 marker = list_first_entry(&queue->head,
36385 struct vmw_marker, head);
36386 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36387 index e6dbf09..3dd2540 100644
36388 --- a/drivers/hid/hid-core.c
36389 +++ b/drivers/hid/hid-core.c
36390 @@ -2268,7 +2268,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36391
36392 int hid_add_device(struct hid_device *hdev)
36393 {
36394 - static atomic_t id = ATOMIC_INIT(0);
36395 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36396 int ret;
36397
36398 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36399 @@ -2302,7 +2302,7 @@ int hid_add_device(struct hid_device *hdev)
36400 /* XXX hack, any other cleaner solution after the driver core
36401 * is converted to allow more than 20 bytes as the device name? */
36402 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36403 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36404 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36405
36406 hid_debug_register(hdev, dev_name(&hdev->dev));
36407 ret = device_add(&hdev->dev);
36408 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36409 index 90124ff..3761764 100644
36410 --- a/drivers/hid/hid-wiimote-debug.c
36411 +++ b/drivers/hid/hid-wiimote-debug.c
36412 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36413 else if (size == 0)
36414 return -EIO;
36415
36416 - if (copy_to_user(u, buf, size))
36417 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36418 return -EFAULT;
36419
36420 *off += size;
36421 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36422 index 0b122f8..b1d8160 100644
36423 --- a/drivers/hv/channel.c
36424 +++ b/drivers/hv/channel.c
36425 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36426 int ret = 0;
36427 int t;
36428
36429 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36430 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36431 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36432 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36433
36434 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36435 if (ret)
36436 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36437 index 7311589..861e9ef 100644
36438 --- a/drivers/hv/hv.c
36439 +++ b/drivers/hv/hv.c
36440 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36441 u64 output_address = (output) ? virt_to_phys(output) : 0;
36442 u32 output_address_hi = output_address >> 32;
36443 u32 output_address_lo = output_address & 0xFFFFFFFF;
36444 - void *hypercall_page = hv_context.hypercall_page;
36445 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36446
36447 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36448 "=a"(hv_status_lo) : "d" (control_hi),
36449 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36450 index 12f2f9e..679603c 100644
36451 --- a/drivers/hv/hyperv_vmbus.h
36452 +++ b/drivers/hv/hyperv_vmbus.h
36453 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36454 struct vmbus_connection {
36455 enum vmbus_connect_state conn_state;
36456
36457 - atomic_t next_gpadl_handle;
36458 + atomic_unchecked_t next_gpadl_handle;
36459
36460 /*
36461 * Represents channel interrupts. Each bit position represents a
36462 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36463 index bf421e0..ce2c897 100644
36464 --- a/drivers/hv/vmbus_drv.c
36465 +++ b/drivers/hv/vmbus_drv.c
36466 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36467 {
36468 int ret = 0;
36469
36470 - static atomic_t device_num = ATOMIC_INIT(0);
36471 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36472
36473 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36474 - atomic_inc_return(&device_num));
36475 + atomic_inc_return_unchecked(&device_num));
36476
36477 child_device_obj->device.bus = &hv_bus;
36478 child_device_obj->device.parent = &hv_acpi_dev->dev;
36479 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36480 index 6351aba..dc4aaf4 100644
36481 --- a/drivers/hwmon/acpi_power_meter.c
36482 +++ b/drivers/hwmon/acpi_power_meter.c
36483 @@ -117,7 +117,7 @@ struct sensor_template {
36484 struct device_attribute *devattr,
36485 const char *buf, size_t count);
36486 int index;
36487 -};
36488 +} __do_const;
36489
36490 /* Averaging interval */
36491 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36492 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36493 struct sensor_template *attrs)
36494 {
36495 struct device *dev = &resource->acpi_dev->dev;
36496 - struct sensor_device_attribute *sensors =
36497 + sensor_device_attribute_no_const *sensors =
36498 &resource->sensors[resource->num_sensors];
36499 int res = 0;
36500
36501 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36502 index b41baff..4953e4d 100644
36503 --- a/drivers/hwmon/applesmc.c
36504 +++ b/drivers/hwmon/applesmc.c
36505 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36506 {
36507 struct applesmc_node_group *grp;
36508 struct applesmc_dev_attr *node;
36509 - struct attribute *attr;
36510 + attribute_no_const *attr;
36511 int ret, i;
36512
36513 for (grp = groups; grp->format; grp++) {
36514 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36515 index b25c643..a13460d 100644
36516 --- a/drivers/hwmon/asus_atk0110.c
36517 +++ b/drivers/hwmon/asus_atk0110.c
36518 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36519 struct atk_sensor_data {
36520 struct list_head list;
36521 struct atk_data *data;
36522 - struct device_attribute label_attr;
36523 - struct device_attribute input_attr;
36524 - struct device_attribute limit1_attr;
36525 - struct device_attribute limit2_attr;
36526 + device_attribute_no_const label_attr;
36527 + device_attribute_no_const input_attr;
36528 + device_attribute_no_const limit1_attr;
36529 + device_attribute_no_const limit2_attr;
36530 char label_attr_name[ATTR_NAME_SIZE];
36531 char input_attr_name[ATTR_NAME_SIZE];
36532 char limit1_attr_name[ATTR_NAME_SIZE];
36533 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36534 static struct device_attribute atk_name_attr =
36535 __ATTR(name, 0444, atk_name_show, NULL);
36536
36537 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36538 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36539 sysfs_show_func show)
36540 {
36541 sysfs_attr_init(&attr->attr);
36542 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36543 index 3f1e297..a6cafb5 100644
36544 --- a/drivers/hwmon/coretemp.c
36545 +++ b/drivers/hwmon/coretemp.c
36546 @@ -791,7 +791,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36547 return NOTIFY_OK;
36548 }
36549
36550 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36551 +static struct notifier_block coretemp_cpu_notifier = {
36552 .notifier_call = coretemp_cpu_callback,
36553 };
36554
36555 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36556 index a14f634..2916ee2 100644
36557 --- a/drivers/hwmon/ibmaem.c
36558 +++ b/drivers/hwmon/ibmaem.c
36559 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36560 struct aem_rw_sensor_template *rw)
36561 {
36562 struct device *dev = &data->pdev->dev;
36563 - struct sensor_device_attribute *sensors = data->sensors;
36564 + sensor_device_attribute_no_const *sensors = data->sensors;
36565 int err;
36566
36567 /* Set up read-only sensors */
36568 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36569 index 9add6092..ee7ba3f 100644
36570 --- a/drivers/hwmon/pmbus/pmbus_core.c
36571 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36572 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36573 return 0;
36574 }
36575
36576 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36577 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36578 const char *name,
36579 umode_t mode,
36580 ssize_t (*show)(struct device *dev,
36581 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36582 dev_attr->store = store;
36583 }
36584
36585 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36586 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36587 const char *name,
36588 umode_t mode,
36589 ssize_t (*show)(struct device *dev,
36590 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36591 u16 reg, u8 mask)
36592 {
36593 struct pmbus_boolean *boolean;
36594 - struct sensor_device_attribute *a;
36595 + sensor_device_attribute_no_const *a;
36596
36597 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36598 if (!boolean)
36599 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36600 bool update, bool readonly)
36601 {
36602 struct pmbus_sensor *sensor;
36603 - struct device_attribute *a;
36604 + device_attribute_no_const *a;
36605
36606 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36607 if (!sensor)
36608 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36609 const char *lstring, int index)
36610 {
36611 struct pmbus_label *label;
36612 - struct device_attribute *a;
36613 + device_attribute_no_const *a;
36614
36615 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36616 if (!label)
36617 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36618 index 2507f90..1645765 100644
36619 --- a/drivers/hwmon/sht15.c
36620 +++ b/drivers/hwmon/sht15.c
36621 @@ -169,7 +169,7 @@ struct sht15_data {
36622 int supply_uv;
36623 bool supply_uv_valid;
36624 struct work_struct update_supply_work;
36625 - atomic_t interrupt_handled;
36626 + atomic_unchecked_t interrupt_handled;
36627 };
36628
36629 /**
36630 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36631 ret = gpio_direction_input(data->pdata->gpio_data);
36632 if (ret)
36633 return ret;
36634 - atomic_set(&data->interrupt_handled, 0);
36635 + atomic_set_unchecked(&data->interrupt_handled, 0);
36636
36637 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36638 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36639 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36640 /* Only relevant if the interrupt hasn't occurred. */
36641 - if (!atomic_read(&data->interrupt_handled))
36642 + if (!atomic_read_unchecked(&data->interrupt_handled))
36643 schedule_work(&data->read_work);
36644 }
36645 ret = wait_event_timeout(data->wait_queue,
36646 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36647
36648 /* First disable the interrupt */
36649 disable_irq_nosync(irq);
36650 - atomic_inc(&data->interrupt_handled);
36651 + atomic_inc_unchecked(&data->interrupt_handled);
36652 /* Then schedule a reading work struct */
36653 if (data->state != SHT15_READING_NOTHING)
36654 schedule_work(&data->read_work);
36655 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36656 * If not, then start the interrupt again - care here as could
36657 * have gone low in meantime so verify it hasn't!
36658 */
36659 - atomic_set(&data->interrupt_handled, 0);
36660 + atomic_set_unchecked(&data->interrupt_handled, 0);
36661 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36662 /* If still not occurred or another handler was scheduled */
36663 if (gpio_get_value(data->pdata->gpio_data)
36664 - || atomic_read(&data->interrupt_handled))
36665 + || atomic_read_unchecked(&data->interrupt_handled))
36666 return;
36667 }
36668
36669 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36670 index 76f157b..9c0db1b 100644
36671 --- a/drivers/hwmon/via-cputemp.c
36672 +++ b/drivers/hwmon/via-cputemp.c
36673 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36674 return NOTIFY_OK;
36675 }
36676
36677 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36678 +static struct notifier_block via_cputemp_cpu_notifier = {
36679 .notifier_call = via_cputemp_cpu_callback,
36680 };
36681
36682 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36683 index 378fcb5..5e91fa8 100644
36684 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36685 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36686 @@ -43,7 +43,7 @@
36687 extern struct i2c_adapter amd756_smbus;
36688
36689 static struct i2c_adapter *s4882_adapter;
36690 -static struct i2c_algorithm *s4882_algo;
36691 +static i2c_algorithm_no_const *s4882_algo;
36692
36693 /* Wrapper access functions for multiplexed SMBus */
36694 static DEFINE_MUTEX(amd756_lock);
36695 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36696 index 29015eb..af2d8e9 100644
36697 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36698 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36699 @@ -41,7 +41,7 @@
36700 extern struct i2c_adapter *nforce2_smbus;
36701
36702 static struct i2c_adapter *s4985_adapter;
36703 -static struct i2c_algorithm *s4985_algo;
36704 +static i2c_algorithm_no_const *s4985_algo;
36705
36706 /* Wrapper access functions for multiplexed SMBus */
36707 static DEFINE_MUTEX(nforce2_lock);
36708 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
36709 index c3ccdea..5b3dc1a 100644
36710 --- a/drivers/i2c/i2c-dev.c
36711 +++ b/drivers/i2c/i2c-dev.c
36712 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
36713 break;
36714 }
36715
36716 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
36717 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
36718 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
36719 if (IS_ERR(rdwr_pa[i].buf)) {
36720 res = PTR_ERR(rdwr_pa[i].buf);
36721 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36722 index 8126824..55a2798 100644
36723 --- a/drivers/ide/ide-cd.c
36724 +++ b/drivers/ide/ide-cd.c
36725 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36726 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36727 if ((unsigned long)buf & alignment
36728 || blk_rq_bytes(rq) & q->dma_pad_mask
36729 - || object_is_on_stack(buf))
36730 + || object_starts_on_stack(buf))
36731 drive->dma = 0;
36732 }
36733 }
36734 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36735 index 8848f16..f8e6dd8 100644
36736 --- a/drivers/iio/industrialio-core.c
36737 +++ b/drivers/iio/industrialio-core.c
36738 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36739 }
36740
36741 static
36742 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36743 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36744 const char *postfix,
36745 struct iio_chan_spec const *chan,
36746 ssize_t (*readfunc)(struct device *dev,
36747 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36748 index 784b97c..c9ceadf 100644
36749 --- a/drivers/infiniband/core/cm.c
36750 +++ b/drivers/infiniband/core/cm.c
36751 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36752
36753 struct cm_counter_group {
36754 struct kobject obj;
36755 - atomic_long_t counter[CM_ATTR_COUNT];
36756 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36757 };
36758
36759 struct cm_counter_attribute {
36760 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36761 struct ib_mad_send_buf *msg = NULL;
36762 int ret;
36763
36764 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36765 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36766 counter[CM_REQ_COUNTER]);
36767
36768 /* Quick state check to discard duplicate REQs. */
36769 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36770 if (!cm_id_priv)
36771 return;
36772
36773 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36774 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36775 counter[CM_REP_COUNTER]);
36776 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36777 if (ret)
36778 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
36779 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36780 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36781 spin_unlock_irq(&cm_id_priv->lock);
36782 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36783 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36784 counter[CM_RTU_COUNTER]);
36785 goto out;
36786 }
36787 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
36788 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36789 dreq_msg->local_comm_id);
36790 if (!cm_id_priv) {
36791 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36792 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36793 counter[CM_DREQ_COUNTER]);
36794 cm_issue_drep(work->port, work->mad_recv_wc);
36795 return -EINVAL;
36796 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
36797 case IB_CM_MRA_REP_RCVD:
36798 break;
36799 case IB_CM_TIMEWAIT:
36800 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36801 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36802 counter[CM_DREQ_COUNTER]);
36803 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36804 goto unlock;
36805 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
36806 cm_free_msg(msg);
36807 goto deref;
36808 case IB_CM_DREQ_RCVD:
36809 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36810 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36811 counter[CM_DREQ_COUNTER]);
36812 goto unlock;
36813 default:
36814 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
36815 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36816 cm_id_priv->msg, timeout)) {
36817 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36818 - atomic_long_inc(&work->port->
36819 + atomic_long_inc_unchecked(&work->port->
36820 counter_group[CM_RECV_DUPLICATES].
36821 counter[CM_MRA_COUNTER]);
36822 goto out;
36823 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
36824 break;
36825 case IB_CM_MRA_REQ_RCVD:
36826 case IB_CM_MRA_REP_RCVD:
36827 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36828 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36829 counter[CM_MRA_COUNTER]);
36830 /* fall through */
36831 default:
36832 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
36833 case IB_CM_LAP_IDLE:
36834 break;
36835 case IB_CM_MRA_LAP_SENT:
36836 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36837 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36838 counter[CM_LAP_COUNTER]);
36839 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36840 goto unlock;
36841 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
36842 cm_free_msg(msg);
36843 goto deref;
36844 case IB_CM_LAP_RCVD:
36845 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36846 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36847 counter[CM_LAP_COUNTER]);
36848 goto unlock;
36849 default:
36850 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36851 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36852 if (cur_cm_id_priv) {
36853 spin_unlock_irq(&cm.lock);
36854 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36855 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36856 counter[CM_SIDR_REQ_COUNTER]);
36857 goto out; /* Duplicate message. */
36858 }
36859 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36860 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36861 msg->retries = 1;
36862
36863 - atomic_long_add(1 + msg->retries,
36864 + atomic_long_add_unchecked(1 + msg->retries,
36865 &port->counter_group[CM_XMIT].counter[attr_index]);
36866 if (msg->retries)
36867 - atomic_long_add(msg->retries,
36868 + atomic_long_add_unchecked(msg->retries,
36869 &port->counter_group[CM_XMIT_RETRIES].
36870 counter[attr_index]);
36871
36872 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36873 }
36874
36875 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36876 - atomic_long_inc(&port->counter_group[CM_RECV].
36877 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36878 counter[attr_id - CM_ATTR_ID_OFFSET]);
36879
36880 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36881 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36882 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36883
36884 return sprintf(buf, "%ld\n",
36885 - atomic_long_read(&group->counter[cm_attr->index]));
36886 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36887 }
36888
36889 static const struct sysfs_ops cm_counter_ops = {
36890 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36891 index 9f5ad7c..588cd84 100644
36892 --- a/drivers/infiniband/core/fmr_pool.c
36893 +++ b/drivers/infiniband/core/fmr_pool.c
36894 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36895
36896 struct task_struct *thread;
36897
36898 - atomic_t req_ser;
36899 - atomic_t flush_ser;
36900 + atomic_unchecked_t req_ser;
36901 + atomic_unchecked_t flush_ser;
36902
36903 wait_queue_head_t force_wait;
36904 };
36905 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36906 struct ib_fmr_pool *pool = pool_ptr;
36907
36908 do {
36909 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36910 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36911 ib_fmr_batch_release(pool);
36912
36913 - atomic_inc(&pool->flush_ser);
36914 + atomic_inc_unchecked(&pool->flush_ser);
36915 wake_up_interruptible(&pool->force_wait);
36916
36917 if (pool->flush_function)
36918 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36919 }
36920
36921 set_current_state(TASK_INTERRUPTIBLE);
36922 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36923 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36924 !kthread_should_stop())
36925 schedule();
36926 __set_current_state(TASK_RUNNING);
36927 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36928 pool->dirty_watermark = params->dirty_watermark;
36929 pool->dirty_len = 0;
36930 spin_lock_init(&pool->pool_lock);
36931 - atomic_set(&pool->req_ser, 0);
36932 - atomic_set(&pool->flush_ser, 0);
36933 + atomic_set_unchecked(&pool->req_ser, 0);
36934 + atomic_set_unchecked(&pool->flush_ser, 0);
36935 init_waitqueue_head(&pool->force_wait);
36936
36937 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36938 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36939 }
36940 spin_unlock_irq(&pool->pool_lock);
36941
36942 - serial = atomic_inc_return(&pool->req_ser);
36943 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36944 wake_up_process(pool->thread);
36945
36946 if (wait_event_interruptible(pool->force_wait,
36947 - atomic_read(&pool->flush_ser) - serial >= 0))
36948 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36949 return -EINTR;
36950
36951 return 0;
36952 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36953 } else {
36954 list_add_tail(&fmr->list, &pool->dirty_list);
36955 if (++pool->dirty_len >= pool->dirty_watermark) {
36956 - atomic_inc(&pool->req_ser);
36957 + atomic_inc_unchecked(&pool->req_ser);
36958 wake_up_process(pool->thread);
36959 }
36960 }
36961 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36962 index 903a92d..9262548 100644
36963 --- a/drivers/infiniband/hw/cxgb4/mem.c
36964 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36965 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36966 int err;
36967 struct fw_ri_tpte tpt;
36968 u32 stag_idx;
36969 - static atomic_t key;
36970 + static atomic_unchecked_t key;
36971
36972 if (c4iw_fatal_error(rdev))
36973 return -EIO;
36974 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36975 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36976 rdev->stats.stag.max = rdev->stats.stag.cur;
36977 mutex_unlock(&rdev->stats.lock);
36978 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36979 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36980 }
36981 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36982 __func__, stag_state, type, pdid, stag_idx);
36983 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36984 index 79b3dbc..96e5fcc 100644
36985 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36986 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36987 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36988 struct ib_atomic_eth *ateth;
36989 struct ipath_ack_entry *e;
36990 u64 vaddr;
36991 - atomic64_t *maddr;
36992 + atomic64_unchecked_t *maddr;
36993 u64 sdata;
36994 u32 rkey;
36995 u8 next;
36996 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36997 IB_ACCESS_REMOTE_ATOMIC)))
36998 goto nack_acc_unlck;
36999 /* Perform atomic OP and save result. */
37000 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37001 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37002 sdata = be64_to_cpu(ateth->swap_data);
37003 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37004 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37005 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37006 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37007 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37008 be64_to_cpu(ateth->compare_data),
37009 sdata);
37010 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37011 index 1f95bba..9530f87 100644
37012 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37013 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37014 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37015 unsigned long flags;
37016 struct ib_wc wc;
37017 u64 sdata;
37018 - atomic64_t *maddr;
37019 + atomic64_unchecked_t *maddr;
37020 enum ib_wc_status send_status;
37021
37022 /*
37023 @@ -382,11 +382,11 @@ again:
37024 IB_ACCESS_REMOTE_ATOMIC)))
37025 goto acc_err;
37026 /* Perform atomic OP and save result. */
37027 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37028 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37029 sdata = wqe->wr.wr.atomic.compare_add;
37030 *(u64 *) sqp->s_sge.sge.vaddr =
37031 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37032 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37033 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37034 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37035 sdata, wqe->wr.wr.atomic.swap);
37036 goto send_comp;
37037 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37038 index 9d3e5c1..d9afe4a 100644
37039 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37040 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37041 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37042 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37043 }
37044
37045 -int mthca_QUERY_FW(struct mthca_dev *dev)
37046 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37047 {
37048 struct mthca_mailbox *mailbox;
37049 u32 *outbox;
37050 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37051 index ed9a989..e0c5871 100644
37052 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37053 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37054 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37055 return key;
37056 }
37057
37058 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37059 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37060 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37061 {
37062 struct mthca_mailbox *mailbox;
37063 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37064 index 4291410..d2ab1fb 100644
37065 --- a/drivers/infiniband/hw/nes/nes.c
37066 +++ b/drivers/infiniband/hw/nes/nes.c
37067 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37068 LIST_HEAD(nes_adapter_list);
37069 static LIST_HEAD(nes_dev_list);
37070
37071 -atomic_t qps_destroyed;
37072 +atomic_unchecked_t qps_destroyed;
37073
37074 static unsigned int ee_flsh_adapter;
37075 static unsigned int sysfs_nonidx_addr;
37076 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37077 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37078 struct nes_adapter *nesadapter = nesdev->nesadapter;
37079
37080 - atomic_inc(&qps_destroyed);
37081 + atomic_inc_unchecked(&qps_destroyed);
37082
37083 /* Free the control structures */
37084
37085 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37086 index 33cc589..3bd6538 100644
37087 --- a/drivers/infiniband/hw/nes/nes.h
37088 +++ b/drivers/infiniband/hw/nes/nes.h
37089 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37090 extern unsigned int wqm_quanta;
37091 extern struct list_head nes_adapter_list;
37092
37093 -extern atomic_t cm_connects;
37094 -extern atomic_t cm_accepts;
37095 -extern atomic_t cm_disconnects;
37096 -extern atomic_t cm_closes;
37097 -extern atomic_t cm_connecteds;
37098 -extern atomic_t cm_connect_reqs;
37099 -extern atomic_t cm_rejects;
37100 -extern atomic_t mod_qp_timouts;
37101 -extern atomic_t qps_created;
37102 -extern atomic_t qps_destroyed;
37103 -extern atomic_t sw_qps_destroyed;
37104 +extern atomic_unchecked_t cm_connects;
37105 +extern atomic_unchecked_t cm_accepts;
37106 +extern atomic_unchecked_t cm_disconnects;
37107 +extern atomic_unchecked_t cm_closes;
37108 +extern atomic_unchecked_t cm_connecteds;
37109 +extern atomic_unchecked_t cm_connect_reqs;
37110 +extern atomic_unchecked_t cm_rejects;
37111 +extern atomic_unchecked_t mod_qp_timouts;
37112 +extern atomic_unchecked_t qps_created;
37113 +extern atomic_unchecked_t qps_destroyed;
37114 +extern atomic_unchecked_t sw_qps_destroyed;
37115 extern u32 mh_detected;
37116 extern u32 mh_pauses_sent;
37117 extern u32 cm_packets_sent;
37118 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37119 extern u32 cm_packets_received;
37120 extern u32 cm_packets_dropped;
37121 extern u32 cm_packets_retrans;
37122 -extern atomic_t cm_listens_created;
37123 -extern atomic_t cm_listens_destroyed;
37124 +extern atomic_unchecked_t cm_listens_created;
37125 +extern atomic_unchecked_t cm_listens_destroyed;
37126 extern u32 cm_backlog_drops;
37127 -extern atomic_t cm_loopbacks;
37128 -extern atomic_t cm_nodes_created;
37129 -extern atomic_t cm_nodes_destroyed;
37130 -extern atomic_t cm_accel_dropped_pkts;
37131 -extern atomic_t cm_resets_recvd;
37132 -extern atomic_t pau_qps_created;
37133 -extern atomic_t pau_qps_destroyed;
37134 +extern atomic_unchecked_t cm_loopbacks;
37135 +extern atomic_unchecked_t cm_nodes_created;
37136 +extern atomic_unchecked_t cm_nodes_destroyed;
37137 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37138 +extern atomic_unchecked_t cm_resets_recvd;
37139 +extern atomic_unchecked_t pau_qps_created;
37140 +extern atomic_unchecked_t pau_qps_destroyed;
37141
37142 extern u32 int_mod_timer_init;
37143 extern u32 int_mod_cq_depth_256;
37144 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37145 index 24b9f1a..00fd004 100644
37146 --- a/drivers/infiniband/hw/nes/nes_cm.c
37147 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37148 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37149 u32 cm_packets_retrans;
37150 u32 cm_packets_created;
37151 u32 cm_packets_received;
37152 -atomic_t cm_listens_created;
37153 -atomic_t cm_listens_destroyed;
37154 +atomic_unchecked_t cm_listens_created;
37155 +atomic_unchecked_t cm_listens_destroyed;
37156 u32 cm_backlog_drops;
37157 -atomic_t cm_loopbacks;
37158 -atomic_t cm_nodes_created;
37159 -atomic_t cm_nodes_destroyed;
37160 -atomic_t cm_accel_dropped_pkts;
37161 -atomic_t cm_resets_recvd;
37162 +atomic_unchecked_t cm_loopbacks;
37163 +atomic_unchecked_t cm_nodes_created;
37164 +atomic_unchecked_t cm_nodes_destroyed;
37165 +atomic_unchecked_t cm_accel_dropped_pkts;
37166 +atomic_unchecked_t cm_resets_recvd;
37167
37168 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37169 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37170 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37171
37172 static struct nes_cm_core *g_cm_core;
37173
37174 -atomic_t cm_connects;
37175 -atomic_t cm_accepts;
37176 -atomic_t cm_disconnects;
37177 -atomic_t cm_closes;
37178 -atomic_t cm_connecteds;
37179 -atomic_t cm_connect_reqs;
37180 -atomic_t cm_rejects;
37181 +atomic_unchecked_t cm_connects;
37182 +atomic_unchecked_t cm_accepts;
37183 +atomic_unchecked_t cm_disconnects;
37184 +atomic_unchecked_t cm_closes;
37185 +atomic_unchecked_t cm_connecteds;
37186 +atomic_unchecked_t cm_connect_reqs;
37187 +atomic_unchecked_t cm_rejects;
37188
37189 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37190 {
37191 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37192 kfree(listener);
37193 listener = NULL;
37194 ret = 0;
37195 - atomic_inc(&cm_listens_destroyed);
37196 + atomic_inc_unchecked(&cm_listens_destroyed);
37197 } else {
37198 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37199 }
37200 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37201 cm_node->rem_mac);
37202
37203 add_hte_node(cm_core, cm_node);
37204 - atomic_inc(&cm_nodes_created);
37205 + atomic_inc_unchecked(&cm_nodes_created);
37206
37207 return cm_node;
37208 }
37209 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37210 }
37211
37212 atomic_dec(&cm_core->node_cnt);
37213 - atomic_inc(&cm_nodes_destroyed);
37214 + atomic_inc_unchecked(&cm_nodes_destroyed);
37215 nesqp = cm_node->nesqp;
37216 if (nesqp) {
37217 nesqp->cm_node = NULL;
37218 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37219
37220 static void drop_packet(struct sk_buff *skb)
37221 {
37222 - atomic_inc(&cm_accel_dropped_pkts);
37223 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37224 dev_kfree_skb_any(skb);
37225 }
37226
37227 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37228 {
37229
37230 int reset = 0; /* whether to send reset in case of err.. */
37231 - atomic_inc(&cm_resets_recvd);
37232 + atomic_inc_unchecked(&cm_resets_recvd);
37233 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37234 " refcnt=%d\n", cm_node, cm_node->state,
37235 atomic_read(&cm_node->ref_count));
37236 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37237 rem_ref_cm_node(cm_node->cm_core, cm_node);
37238 return NULL;
37239 }
37240 - atomic_inc(&cm_loopbacks);
37241 + atomic_inc_unchecked(&cm_loopbacks);
37242 loopbackremotenode->loopbackpartner = cm_node;
37243 loopbackremotenode->tcp_cntxt.rcv_wscale =
37244 NES_CM_DEFAULT_RCV_WND_SCALE;
37245 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37246 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37247 else {
37248 rem_ref_cm_node(cm_core, cm_node);
37249 - atomic_inc(&cm_accel_dropped_pkts);
37250 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37251 dev_kfree_skb_any(skb);
37252 }
37253 break;
37254 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37255
37256 if ((cm_id) && (cm_id->event_handler)) {
37257 if (issue_disconn) {
37258 - atomic_inc(&cm_disconnects);
37259 + atomic_inc_unchecked(&cm_disconnects);
37260 cm_event.event = IW_CM_EVENT_DISCONNECT;
37261 cm_event.status = disconn_status;
37262 cm_event.local_addr = cm_id->local_addr;
37263 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37264 }
37265
37266 if (issue_close) {
37267 - atomic_inc(&cm_closes);
37268 + atomic_inc_unchecked(&cm_closes);
37269 nes_disconnect(nesqp, 1);
37270
37271 cm_id->provider_data = nesqp;
37272 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37273
37274 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37275 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37276 - atomic_inc(&cm_accepts);
37277 + atomic_inc_unchecked(&cm_accepts);
37278
37279 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37280 netdev_refcnt_read(nesvnic->netdev));
37281 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37282 struct nes_cm_core *cm_core;
37283 u8 *start_buff;
37284
37285 - atomic_inc(&cm_rejects);
37286 + atomic_inc_unchecked(&cm_rejects);
37287 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37288 loopback = cm_node->loopbackpartner;
37289 cm_core = cm_node->cm_core;
37290 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37291 ntohl(cm_id->local_addr.sin_addr.s_addr),
37292 ntohs(cm_id->local_addr.sin_port));
37293
37294 - atomic_inc(&cm_connects);
37295 + atomic_inc_unchecked(&cm_connects);
37296 nesqp->active_conn = 1;
37297
37298 /* cache the cm_id in the qp */
37299 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37300 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37301 return err;
37302 }
37303 - atomic_inc(&cm_listens_created);
37304 + atomic_inc_unchecked(&cm_listens_created);
37305 }
37306
37307 cm_id->add_ref(cm_id);
37308 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37309
37310 if (nesqp->destroyed)
37311 return;
37312 - atomic_inc(&cm_connecteds);
37313 + atomic_inc_unchecked(&cm_connecteds);
37314 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37315 " local port 0x%04X. jiffies = %lu.\n",
37316 nesqp->hwqp.qp_id,
37317 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37318
37319 cm_id->add_ref(cm_id);
37320 ret = cm_id->event_handler(cm_id, &cm_event);
37321 - atomic_inc(&cm_closes);
37322 + atomic_inc_unchecked(&cm_closes);
37323 cm_event.event = IW_CM_EVENT_CLOSE;
37324 cm_event.status = 0;
37325 cm_event.provider_data = cm_id->provider_data;
37326 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37327 return;
37328 cm_id = cm_node->cm_id;
37329
37330 - atomic_inc(&cm_connect_reqs);
37331 + atomic_inc_unchecked(&cm_connect_reqs);
37332 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37333 cm_node, cm_id, jiffies);
37334
37335 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37336 return;
37337 cm_id = cm_node->cm_id;
37338
37339 - atomic_inc(&cm_connect_reqs);
37340 + atomic_inc_unchecked(&cm_connect_reqs);
37341 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37342 cm_node, cm_id, jiffies);
37343
37344 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37345 index 4166452..fc952c3 100644
37346 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37347 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37348 @@ -40,8 +40,8 @@
37349 #include "nes.h"
37350 #include "nes_mgt.h"
37351
37352 -atomic_t pau_qps_created;
37353 -atomic_t pau_qps_destroyed;
37354 +atomic_unchecked_t pau_qps_created;
37355 +atomic_unchecked_t pau_qps_destroyed;
37356
37357 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37358 {
37359 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37360 {
37361 struct sk_buff *skb;
37362 unsigned long flags;
37363 - atomic_inc(&pau_qps_destroyed);
37364 + atomic_inc_unchecked(&pau_qps_destroyed);
37365
37366 /* Free packets that have not yet been forwarded */
37367 /* Lock is acquired by skb_dequeue when removing the skb */
37368 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37369 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37370 skb_queue_head_init(&nesqp->pau_list);
37371 spin_lock_init(&nesqp->pau_lock);
37372 - atomic_inc(&pau_qps_created);
37373 + atomic_inc_unchecked(&pau_qps_created);
37374 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37375 }
37376
37377 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37378 index 85cf4d1..05d8e71 100644
37379 --- a/drivers/infiniband/hw/nes/nes_nic.c
37380 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37381 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37382 target_stat_values[++index] = mh_detected;
37383 target_stat_values[++index] = mh_pauses_sent;
37384 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37385 - target_stat_values[++index] = atomic_read(&cm_connects);
37386 - target_stat_values[++index] = atomic_read(&cm_accepts);
37387 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37388 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37389 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37390 - target_stat_values[++index] = atomic_read(&cm_rejects);
37391 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37392 - target_stat_values[++index] = atomic_read(&qps_created);
37393 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37394 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37395 - target_stat_values[++index] = atomic_read(&cm_closes);
37396 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37397 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37398 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37399 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37400 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37401 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37402 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37403 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37404 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37405 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37406 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37407 target_stat_values[++index] = cm_packets_sent;
37408 target_stat_values[++index] = cm_packets_bounced;
37409 target_stat_values[++index] = cm_packets_created;
37410 target_stat_values[++index] = cm_packets_received;
37411 target_stat_values[++index] = cm_packets_dropped;
37412 target_stat_values[++index] = cm_packets_retrans;
37413 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37414 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37415 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37416 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37417 target_stat_values[++index] = cm_backlog_drops;
37418 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37419 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37420 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37421 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37422 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37423 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37424 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37425 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37426 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37427 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37428 target_stat_values[++index] = nesadapter->free_4kpbl;
37429 target_stat_values[++index] = nesadapter->free_256pbl;
37430 target_stat_values[++index] = int_mod_timer_init;
37431 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37432 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37433 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37434 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37435 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37436 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37437 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37438 }
37439
37440 /**
37441 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37442 index 8f67fe2..8960859 100644
37443 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37444 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37445 @@ -46,9 +46,9 @@
37446
37447 #include <rdma/ib_umem.h>
37448
37449 -atomic_t mod_qp_timouts;
37450 -atomic_t qps_created;
37451 -atomic_t sw_qps_destroyed;
37452 +atomic_unchecked_t mod_qp_timouts;
37453 +atomic_unchecked_t qps_created;
37454 +atomic_unchecked_t sw_qps_destroyed;
37455
37456 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37457
37458 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37459 if (init_attr->create_flags)
37460 return ERR_PTR(-EINVAL);
37461
37462 - atomic_inc(&qps_created);
37463 + atomic_inc_unchecked(&qps_created);
37464 switch (init_attr->qp_type) {
37465 case IB_QPT_RC:
37466 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37467 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37468 struct iw_cm_event cm_event;
37469 int ret = 0;
37470
37471 - atomic_inc(&sw_qps_destroyed);
37472 + atomic_inc_unchecked(&sw_qps_destroyed);
37473 nesqp->destroyed = 1;
37474
37475 /* Blow away the connection if it exists. */
37476 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37477 index 4d11575..3e890e5 100644
37478 --- a/drivers/infiniband/hw/qib/qib.h
37479 +++ b/drivers/infiniband/hw/qib/qib.h
37480 @@ -51,6 +51,7 @@
37481 #include <linux/completion.h>
37482 #include <linux/kref.h>
37483 #include <linux/sched.h>
37484 +#include <linux/slab.h>
37485
37486 #include "qib_common.h"
37487 #include "qib_verbs.h"
37488 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37489 index da739d9..da1c7f4 100644
37490 --- a/drivers/input/gameport/gameport.c
37491 +++ b/drivers/input/gameport/gameport.c
37492 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37493 */
37494 static void gameport_init_port(struct gameport *gameport)
37495 {
37496 - static atomic_t gameport_no = ATOMIC_INIT(0);
37497 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37498
37499 __module_get(THIS_MODULE);
37500
37501 mutex_init(&gameport->drv_mutex);
37502 device_initialize(&gameport->dev);
37503 dev_set_name(&gameport->dev, "gameport%lu",
37504 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37505 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37506 gameport->dev.bus = &gameport_bus;
37507 gameport->dev.release = gameport_release_port;
37508 if (gameport->parent)
37509 diff --git a/drivers/input/input.c b/drivers/input/input.c
37510 index c044699..174d71a 100644
37511 --- a/drivers/input/input.c
37512 +++ b/drivers/input/input.c
37513 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37514 */
37515 int input_register_device(struct input_dev *dev)
37516 {
37517 - static atomic_t input_no = ATOMIC_INIT(0);
37518 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37519 struct input_devres *devres = NULL;
37520 struct input_handler *handler;
37521 unsigned int packet_size;
37522 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37523 dev->setkeycode = input_default_setkeycode;
37524
37525 dev_set_name(&dev->dev, "input%ld",
37526 - (unsigned long) atomic_inc_return(&input_no) - 1);
37527 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37528
37529 error = device_add(&dev->dev);
37530 if (error)
37531 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37532 index 04c69af..5f92d00 100644
37533 --- a/drivers/input/joystick/sidewinder.c
37534 +++ b/drivers/input/joystick/sidewinder.c
37535 @@ -30,6 +30,7 @@
37536 #include <linux/kernel.h>
37537 #include <linux/module.h>
37538 #include <linux/slab.h>
37539 +#include <linux/sched.h>
37540 #include <linux/init.h>
37541 #include <linux/input.h>
37542 #include <linux/gameport.h>
37543 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37544 index fa061d4..4a6957c 100644
37545 --- a/drivers/input/joystick/xpad.c
37546 +++ b/drivers/input/joystick/xpad.c
37547 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37548
37549 static int xpad_led_probe(struct usb_xpad *xpad)
37550 {
37551 - static atomic_t led_seq = ATOMIC_INIT(0);
37552 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37553 long led_no;
37554 struct xpad_led *led;
37555 struct led_classdev *led_cdev;
37556 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37557 if (!led)
37558 return -ENOMEM;
37559
37560 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37561 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37562
37563 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37564 led->xpad = xpad;
37565 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37566 index 2f0b39d..7370f13 100644
37567 --- a/drivers/input/mouse/psmouse.h
37568 +++ b/drivers/input/mouse/psmouse.h
37569 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37570 ssize_t (*set)(struct psmouse *psmouse, void *data,
37571 const char *buf, size_t count);
37572 bool protect;
37573 -};
37574 +} __do_const;
37575 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37576
37577 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37578 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37579 index 4c842c3..590b0bf 100644
37580 --- a/drivers/input/mousedev.c
37581 +++ b/drivers/input/mousedev.c
37582 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37583
37584 spin_unlock_irq(&client->packet_lock);
37585
37586 - if (copy_to_user(buffer, data, count))
37587 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37588 return -EFAULT;
37589
37590 return count;
37591 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37592 index 25fc597..558bf3b3 100644
37593 --- a/drivers/input/serio/serio.c
37594 +++ b/drivers/input/serio/serio.c
37595 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37596 */
37597 static void serio_init_port(struct serio *serio)
37598 {
37599 - static atomic_t serio_no = ATOMIC_INIT(0);
37600 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37601
37602 __module_get(THIS_MODULE);
37603
37604 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37605 mutex_init(&serio->drv_mutex);
37606 device_initialize(&serio->dev);
37607 dev_set_name(&serio->dev, "serio%ld",
37608 - (long)atomic_inc_return(&serio_no) - 1);
37609 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37610 serio->dev.bus = &serio_bus;
37611 serio->dev.release = serio_release_port;
37612 serio->dev.groups = serio_device_attr_groups;
37613 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37614 index b972d43..8943713 100644
37615 --- a/drivers/iommu/iommu.c
37616 +++ b/drivers/iommu/iommu.c
37617 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37618 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37619 {
37620 bus_register_notifier(bus, &iommu_bus_nb);
37621 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37622 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37623 }
37624
37625 /**
37626 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37627 index 7c11ff3..a2a0457 100644
37628 --- a/drivers/iommu/irq_remapping.c
37629 +++ b/drivers/iommu/irq_remapping.c
37630 @@ -348,7 +348,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
37631 void panic_if_irq_remap(const char *msg)
37632 {
37633 if (irq_remapping_enabled)
37634 - panic(msg);
37635 + panic("%s", msg);
37636 }
37637
37638 static void ir_ack_apic_edge(struct irq_data *data)
37639 @@ -369,10 +369,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37640
37641 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37642 {
37643 - chip->irq_print_chip = ir_print_prefix;
37644 - chip->irq_ack = ir_ack_apic_edge;
37645 - chip->irq_eoi = ir_ack_apic_level;
37646 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37647 + pax_open_kernel();
37648 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37649 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37650 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37651 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37652 + pax_close_kernel();
37653 }
37654
37655 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37656 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37657 index fc6aebf..762c5f5 100644
37658 --- a/drivers/irqchip/irq-gic.c
37659 +++ b/drivers/irqchip/irq-gic.c
37660 @@ -83,7 +83,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37661 * Supported arch specific GIC irq extension.
37662 * Default make them NULL.
37663 */
37664 -struct irq_chip gic_arch_extn = {
37665 +irq_chip_no_const gic_arch_extn = {
37666 .irq_eoi = NULL,
37667 .irq_mask = NULL,
37668 .irq_unmask = NULL,
37669 @@ -332,7 +332,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37670 chained_irq_exit(chip, desc);
37671 }
37672
37673 -static struct irq_chip gic_chip = {
37674 +static irq_chip_no_const gic_chip __read_only = {
37675 .name = "GIC",
37676 .irq_mask = gic_mask_irq,
37677 .irq_unmask = gic_unmask_irq,
37678 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37679 index 89562a8..218999b 100644
37680 --- a/drivers/isdn/capi/capi.c
37681 +++ b/drivers/isdn/capi/capi.c
37682 @@ -81,8 +81,8 @@ struct capiminor {
37683
37684 struct capi20_appl *ap;
37685 u32 ncci;
37686 - atomic_t datahandle;
37687 - atomic_t msgid;
37688 + atomic_unchecked_t datahandle;
37689 + atomic_unchecked_t msgid;
37690
37691 struct tty_port port;
37692 int ttyinstop;
37693 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37694 capimsg_setu16(s, 2, mp->ap->applid);
37695 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37696 capimsg_setu8 (s, 5, CAPI_RESP);
37697 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37698 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37699 capimsg_setu32(s, 8, mp->ncci);
37700 capimsg_setu16(s, 12, datahandle);
37701 }
37702 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37703 mp->outbytes -= len;
37704 spin_unlock_bh(&mp->outlock);
37705
37706 - datahandle = atomic_inc_return(&mp->datahandle);
37707 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37708 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37709 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37710 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37711 capimsg_setu16(skb->data, 2, mp->ap->applid);
37712 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37713 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37714 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37715 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37716 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37717 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37718 capimsg_setu16(skb->data, 16, len); /* Data length */
37719 diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
37720 index 9b1b274..c123709 100644
37721 --- a/drivers/isdn/capi/kcapi.c
37722 +++ b/drivers/isdn/capi/kcapi.c
37723 @@ -93,7 +93,7 @@ capi_ctr_put(struct capi_ctr *ctr)
37724
37725 static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr)
37726 {
37727 - if (contr - 1 >= CAPI_MAXCONTR)
37728 + if (contr < 1 || contr - 1 >= CAPI_MAXCONTR)
37729 return NULL;
37730
37731 return capi_controller[contr - 1];
37732 @@ -103,7 +103,7 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)
37733 {
37734 lockdep_assert_held(&capi_controller_lock);
37735
37736 - if (applid - 1 >= CAPI_MAXAPPL)
37737 + if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)
37738 return NULL;
37739
37740 return capi_applications[applid - 1];
37741 @@ -111,7 +111,7 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)
37742
37743 static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid)
37744 {
37745 - if (applid - 1 >= CAPI_MAXAPPL)
37746 + if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)
37747 return NULL;
37748
37749 return rcu_dereference(capi_applications[applid - 1]);
37750 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37751 index e2b5396..c5486dc 100644
37752 --- a/drivers/isdn/gigaset/interface.c
37753 +++ b/drivers/isdn/gigaset/interface.c
37754 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37755 }
37756 tty->driver_data = cs;
37757
37758 - ++cs->port.count;
37759 + atomic_inc(&cs->port.count);
37760
37761 - if (cs->port.count == 1) {
37762 + if (atomic_read(&cs->port.count) == 1) {
37763 tty_port_tty_set(&cs->port, tty);
37764 cs->port.low_latency = 1;
37765 }
37766 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37767
37768 if (!cs->connected)
37769 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37770 - else if (!cs->port.count)
37771 + else if (!atomic_read(&cs->port.count))
37772 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37773 - else if (!--cs->port.count)
37774 + else if (!atomic_dec_return(&cs->port.count))
37775 tty_port_tty_set(&cs->port, NULL);
37776
37777 mutex_unlock(&cs->mutex);
37778 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37779 index 821f7ac..28d4030 100644
37780 --- a/drivers/isdn/hardware/avm/b1.c
37781 +++ b/drivers/isdn/hardware/avm/b1.c
37782 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37783 }
37784 if (left) {
37785 if (t4file->user) {
37786 - if (copy_from_user(buf, dp, left))
37787 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37788 return -EFAULT;
37789 } else {
37790 memcpy(buf, dp, left);
37791 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37792 }
37793 if (left) {
37794 if (config->user) {
37795 - if (copy_from_user(buf, dp, left))
37796 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37797 return -EFAULT;
37798 } else {
37799 memcpy(buf, dp, left);
37800 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37801 index ebaebdf..acd4405 100644
37802 --- a/drivers/isdn/i4l/isdn_tty.c
37803 +++ b/drivers/isdn/i4l/isdn_tty.c
37804 @@ -1511,9 +1511,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37805
37806 #ifdef ISDN_DEBUG_MODEM_OPEN
37807 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37808 - port->count);
37809 + atomic_read(&port->count));
37810 #endif
37811 - port->count++;
37812 + atomic_inc(&port->count);
37813 port->tty = tty;
37814 /*
37815 * Start up serial port
37816 @@ -1557,7 +1557,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37817 #endif
37818 return;
37819 }
37820 - if ((tty->count == 1) && (port->count != 1)) {
37821 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37822 /*
37823 * Uh, oh. tty->count is 1, which means that the tty
37824 * structure will be freed. Info->count should always
37825 @@ -1566,15 +1566,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37826 * serial port won't be shutdown.
37827 */
37828 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37829 - "info->count is %d\n", port->count);
37830 - port->count = 1;
37831 + "info->count is %d\n", atomic_read(&port->count));
37832 + atomic_set(&port->count, 1);
37833 }
37834 - if (--port->count < 0) {
37835 + if (atomic_dec_return(&port->count) < 0) {
37836 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37837 - info->line, port->count);
37838 - port->count = 0;
37839 + info->line, atomic_read(&port->count));
37840 + atomic_set(&port->count, 0);
37841 }
37842 - if (port->count) {
37843 + if (atomic_read(&port->count)) {
37844 #ifdef ISDN_DEBUG_MODEM_OPEN
37845 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37846 #endif
37847 @@ -1628,7 +1628,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37848 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37849 return;
37850 isdn_tty_shutdown(info);
37851 - port->count = 0;
37852 + atomic_set(&port->count, 0);
37853 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37854 port->tty = NULL;
37855 wake_up_interruptible(&port->open_wait);
37856 @@ -1973,7 +1973,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37857 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37858 modem_info *info = &dev->mdm.info[i];
37859
37860 - if (info->port.count == 0)
37861 + if (atomic_read(&info->port.count) == 0)
37862 continue;
37863 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37864 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37865 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37866 index e74df7c..03a03ba 100644
37867 --- a/drivers/isdn/icn/icn.c
37868 +++ b/drivers/isdn/icn/icn.c
37869 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37870 if (count > len)
37871 count = len;
37872 if (user) {
37873 - if (copy_from_user(msg, buf, count))
37874 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37875 return -EFAULT;
37876 } else
37877 memcpy(msg, buf, count);
37878 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37879 index 6a8405d..0bd1c7e 100644
37880 --- a/drivers/leds/leds-clevo-mail.c
37881 +++ b/drivers/leds/leds-clevo-mail.c
37882 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37883 * detected as working, but in reality it is not) as low as
37884 * possible.
37885 */
37886 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37887 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37888 {
37889 .callback = clevo_mail_led_dmi_callback,
37890 .ident = "Clevo D410J",
37891 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37892 index 64e204e..c6bf189 100644
37893 --- a/drivers/leds/leds-ss4200.c
37894 +++ b/drivers/leds/leds-ss4200.c
37895 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37896 * detected as working, but in reality it is not) as low as
37897 * possible.
37898 */
37899 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37900 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37901 {
37902 .callback = ss4200_led_dmi_callback,
37903 .ident = "Intel SS4200-E",
37904 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37905 index a5ebc00..3de3364 100644
37906 --- a/drivers/lguest/core.c
37907 +++ b/drivers/lguest/core.c
37908 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37909 * it's worked so far. The end address needs +1 because __get_vm_area
37910 * allocates an extra guard page, so we need space for that.
37911 */
37912 +
37913 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37914 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37915 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37916 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37917 +#else
37918 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37919 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37920 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37921 +#endif
37922 +
37923 if (!switcher_vma) {
37924 err = -ENOMEM;
37925 printk("lguest: could not map switcher pages high\n");
37926 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37927 * Now the Switcher is mapped at the right address, we can't fail!
37928 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37929 */
37930 - memcpy(switcher_vma->addr, start_switcher_text,
37931 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37932 end_switcher_text - start_switcher_text);
37933
37934 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37935 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37936 index 3b62be16..e33134a 100644
37937 --- a/drivers/lguest/page_tables.c
37938 +++ b/drivers/lguest/page_tables.c
37939 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37940 /*:*/
37941
37942 #ifdef CONFIG_X86_PAE
37943 -static void release_pmd(pmd_t *spmd)
37944 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37945 {
37946 /* If the entry's not present, there's nothing to release. */
37947 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37948 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37949 index 4af12e1..0e89afe 100644
37950 --- a/drivers/lguest/x86/core.c
37951 +++ b/drivers/lguest/x86/core.c
37952 @@ -59,7 +59,7 @@ static struct {
37953 /* Offset from where switcher.S was compiled to where we've copied it */
37954 static unsigned long switcher_offset(void)
37955 {
37956 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37957 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37958 }
37959
37960 /* This cpu's struct lguest_pages. */
37961 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37962 * These copies are pretty cheap, so we do them unconditionally: */
37963 /* Save the current Host top-level page directory.
37964 */
37965 +
37966 +#ifdef CONFIG_PAX_PER_CPU_PGD
37967 + pages->state.host_cr3 = read_cr3();
37968 +#else
37969 pages->state.host_cr3 = __pa(current->mm->pgd);
37970 +#endif
37971 +
37972 /*
37973 * Set up the Guest's page tables to see this CPU's pages (and no
37974 * other CPU's pages).
37975 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37976 * compiled-in switcher code and the high-mapped copy we just made.
37977 */
37978 for (i = 0; i < IDT_ENTRIES; i++)
37979 - default_idt_entries[i] += switcher_offset();
37980 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37981
37982 /*
37983 * Set up the Switcher's per-cpu areas.
37984 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37985 * it will be undisturbed when we switch. To change %cs and jump we
37986 * need this structure to feed to Intel's "lcall" instruction.
37987 */
37988 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37989 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37990 lguest_entry.segment = LGUEST_CS;
37991
37992 /*
37993 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37994 index 40634b0..4f5855e 100644
37995 --- a/drivers/lguest/x86/switcher_32.S
37996 +++ b/drivers/lguest/x86/switcher_32.S
37997 @@ -87,6 +87,7 @@
37998 #include <asm/page.h>
37999 #include <asm/segment.h>
38000 #include <asm/lguest.h>
38001 +#include <asm/processor-flags.h>
38002
38003 // We mark the start of the code to copy
38004 // It's placed in .text tho it's never run here
38005 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38006 // Changes type when we load it: damn Intel!
38007 // For after we switch over our page tables
38008 // That entry will be read-only: we'd crash.
38009 +
38010 +#ifdef CONFIG_PAX_KERNEXEC
38011 + mov %cr0, %edx
38012 + xor $X86_CR0_WP, %edx
38013 + mov %edx, %cr0
38014 +#endif
38015 +
38016 movl $(GDT_ENTRY_TSS*8), %edx
38017 ltr %dx
38018
38019 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38020 // Let's clear it again for our return.
38021 // The GDT descriptor of the Host
38022 // Points to the table after two "size" bytes
38023 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38024 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38025 // Clear "used" from type field (byte 5, bit 2)
38026 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38027 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38028 +
38029 +#ifdef CONFIG_PAX_KERNEXEC
38030 + mov %cr0, %eax
38031 + xor $X86_CR0_WP, %eax
38032 + mov %eax, %cr0
38033 +#endif
38034
38035 // Once our page table's switched, the Guest is live!
38036 // The Host fades as we run this final step.
38037 @@ -295,13 +309,12 @@ deliver_to_host:
38038 // I consulted gcc, and it gave
38039 // These instructions, which I gladly credit:
38040 leal (%edx,%ebx,8), %eax
38041 - movzwl (%eax),%edx
38042 - movl 4(%eax), %eax
38043 - xorw %ax, %ax
38044 - orl %eax, %edx
38045 + movl 4(%eax), %edx
38046 + movw (%eax), %dx
38047 // Now the address of the handler's in %edx
38048 // We call it now: its "iret" drops us home.
38049 - jmp *%edx
38050 + ljmp $__KERNEL_CS, $1f
38051 +1: jmp *%edx
38052
38053 // Every interrupt can come to us here
38054 // But we must truly tell each apart.
38055 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38056 index 4fd9d6a..834fa03 100644
38057 --- a/drivers/md/bitmap.c
38058 +++ b/drivers/md/bitmap.c
38059 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38060 chunk_kb ? "KB" : "B");
38061 if (bitmap->storage.file) {
38062 seq_printf(seq, ", file: ");
38063 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38064 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38065 }
38066
38067 seq_printf(seq, "\n");
38068 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38069 index aa04f02..2a1309e 100644
38070 --- a/drivers/md/dm-ioctl.c
38071 +++ b/drivers/md/dm-ioctl.c
38072 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38073 cmd == DM_LIST_VERSIONS_CMD)
38074 return 0;
38075
38076 - if ((cmd == DM_DEV_CREATE_CMD)) {
38077 + if (cmd == DM_DEV_CREATE_CMD) {
38078 if (!*param->name) {
38079 DMWARN("name not supplied when creating device");
38080 return -EINVAL;
38081 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38082 index d053098..05cc375 100644
38083 --- a/drivers/md/dm-raid1.c
38084 +++ b/drivers/md/dm-raid1.c
38085 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38086
38087 struct mirror {
38088 struct mirror_set *ms;
38089 - atomic_t error_count;
38090 + atomic_unchecked_t error_count;
38091 unsigned long error_type;
38092 struct dm_dev *dev;
38093 sector_t offset;
38094 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38095 struct mirror *m;
38096
38097 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38098 - if (!atomic_read(&m->error_count))
38099 + if (!atomic_read_unchecked(&m->error_count))
38100 return m;
38101
38102 return NULL;
38103 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38104 * simple way to tell if a device has encountered
38105 * errors.
38106 */
38107 - atomic_inc(&m->error_count);
38108 + atomic_inc_unchecked(&m->error_count);
38109
38110 if (test_and_set_bit(error_type, &m->error_type))
38111 return;
38112 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38113 struct mirror *m = get_default_mirror(ms);
38114
38115 do {
38116 - if (likely(!atomic_read(&m->error_count)))
38117 + if (likely(!atomic_read_unchecked(&m->error_count)))
38118 return m;
38119
38120 if (m-- == ms->mirror)
38121 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
38122 {
38123 struct mirror *default_mirror = get_default_mirror(m->ms);
38124
38125 - return !atomic_read(&default_mirror->error_count);
38126 + return !atomic_read_unchecked(&default_mirror->error_count);
38127 }
38128
38129 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38130 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38131 */
38132 if (likely(region_in_sync(ms, region, 1)))
38133 m = choose_mirror(ms, bio->bi_sector);
38134 - else if (m && atomic_read(&m->error_count))
38135 + else if (m && atomic_read_unchecked(&m->error_count))
38136 m = NULL;
38137
38138 if (likely(m))
38139 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38140 }
38141
38142 ms->mirror[mirror].ms = ms;
38143 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38144 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38145 ms->mirror[mirror].error_type = 0;
38146 ms->mirror[mirror].offset = offset;
38147
38148 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
38149 */
38150 static char device_status_char(struct mirror *m)
38151 {
38152 - if (!atomic_read(&(m->error_count)))
38153 + if (!atomic_read_unchecked(&(m->error_count)))
38154 return 'A';
38155
38156 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38157 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38158 index 7b8b2b9..9c7d145 100644
38159 --- a/drivers/md/dm-stripe.c
38160 +++ b/drivers/md/dm-stripe.c
38161 @@ -20,7 +20,7 @@ struct stripe {
38162 struct dm_dev *dev;
38163 sector_t physical_start;
38164
38165 - atomic_t error_count;
38166 + atomic_unchecked_t error_count;
38167 };
38168
38169 struct stripe_c {
38170 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38171 kfree(sc);
38172 return r;
38173 }
38174 - atomic_set(&(sc->stripe[i].error_count), 0);
38175 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38176 }
38177
38178 ti->private = sc;
38179 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38180 DMEMIT("%d ", sc->stripes);
38181 for (i = 0; i < sc->stripes; i++) {
38182 DMEMIT("%s ", sc->stripe[i].dev->name);
38183 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38184 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38185 'D' : 'A';
38186 }
38187 buffer[i] = '\0';
38188 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38189 */
38190 for (i = 0; i < sc->stripes; i++)
38191 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38192 - atomic_inc(&(sc->stripe[i].error_count));
38193 - if (atomic_read(&(sc->stripe[i].error_count)) <
38194 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38195 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38196 DM_IO_ERROR_THRESHOLD)
38197 schedule_work(&sc->trigger_event);
38198 }
38199 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38200 index 1ff252a..ee384c1 100644
38201 --- a/drivers/md/dm-table.c
38202 +++ b/drivers/md/dm-table.c
38203 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38204 if (!dev_size)
38205 return 0;
38206
38207 - if ((start >= dev_size) || (start + len > dev_size)) {
38208 + if ((start >= dev_size) || (len > dev_size - start)) {
38209 DMWARN("%s: %s too small for target: "
38210 "start=%llu, len=%llu, dev_size=%llu",
38211 dm_device_name(ti->table->md), bdevname(bdev, b),
38212 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38213 index 00cee02..b89a29d 100644
38214 --- a/drivers/md/dm-thin-metadata.c
38215 +++ b/drivers/md/dm-thin-metadata.c
38216 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38217 {
38218 pmd->info.tm = pmd->tm;
38219 pmd->info.levels = 2;
38220 - pmd->info.value_type.context = pmd->data_sm;
38221 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38222 pmd->info.value_type.size = sizeof(__le64);
38223 pmd->info.value_type.inc = data_block_inc;
38224 pmd->info.value_type.dec = data_block_dec;
38225 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38226
38227 pmd->bl_info.tm = pmd->tm;
38228 pmd->bl_info.levels = 1;
38229 - pmd->bl_info.value_type.context = pmd->data_sm;
38230 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38231 pmd->bl_info.value_type.size = sizeof(__le64);
38232 pmd->bl_info.value_type.inc = data_block_inc;
38233 pmd->bl_info.value_type.dec = data_block_dec;
38234 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38235 index 9a0bdad..4df9543 100644
38236 --- a/drivers/md/dm.c
38237 +++ b/drivers/md/dm.c
38238 @@ -169,9 +169,9 @@ struct mapped_device {
38239 /*
38240 * Event handling.
38241 */
38242 - atomic_t event_nr;
38243 + atomic_unchecked_t event_nr;
38244 wait_queue_head_t eventq;
38245 - atomic_t uevent_seq;
38246 + atomic_unchecked_t uevent_seq;
38247 struct list_head uevent_list;
38248 spinlock_t uevent_lock; /* Protect access to uevent_list */
38249
38250 @@ -1879,8 +1879,8 @@ static struct mapped_device *alloc_dev(int minor)
38251 rwlock_init(&md->map_lock);
38252 atomic_set(&md->holders, 1);
38253 atomic_set(&md->open_count, 0);
38254 - atomic_set(&md->event_nr, 0);
38255 - atomic_set(&md->uevent_seq, 0);
38256 + atomic_set_unchecked(&md->event_nr, 0);
38257 + atomic_set_unchecked(&md->uevent_seq, 0);
38258 INIT_LIST_HEAD(&md->uevent_list);
38259 spin_lock_init(&md->uevent_lock);
38260
38261 @@ -2028,7 +2028,7 @@ static void event_callback(void *context)
38262
38263 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38264
38265 - atomic_inc(&md->event_nr);
38266 + atomic_inc_unchecked(&md->event_nr);
38267 wake_up(&md->eventq);
38268 }
38269
38270 @@ -2685,18 +2685,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38271
38272 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38273 {
38274 - return atomic_add_return(1, &md->uevent_seq);
38275 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38276 }
38277
38278 uint32_t dm_get_event_nr(struct mapped_device *md)
38279 {
38280 - return atomic_read(&md->event_nr);
38281 + return atomic_read_unchecked(&md->event_nr);
38282 }
38283
38284 int dm_wait_event(struct mapped_device *md, int event_nr)
38285 {
38286 return wait_event_interruptible(md->eventq,
38287 - (event_nr != atomic_read(&md->event_nr)));
38288 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38289 }
38290
38291 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38292 diff --git a/drivers/md/md.c b/drivers/md/md.c
38293 index a4a93b9..4747b63 100644
38294 --- a/drivers/md/md.c
38295 +++ b/drivers/md/md.c
38296 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38297 * start build, activate spare
38298 */
38299 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38300 -static atomic_t md_event_count;
38301 +static atomic_unchecked_t md_event_count;
38302 void md_new_event(struct mddev *mddev)
38303 {
38304 - atomic_inc(&md_event_count);
38305 + atomic_inc_unchecked(&md_event_count);
38306 wake_up(&md_event_waiters);
38307 }
38308 EXPORT_SYMBOL_GPL(md_new_event);
38309 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38310 */
38311 static void md_new_event_inintr(struct mddev *mddev)
38312 {
38313 - atomic_inc(&md_event_count);
38314 + atomic_inc_unchecked(&md_event_count);
38315 wake_up(&md_event_waiters);
38316 }
38317
38318 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38319 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38320 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38321 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38322 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38323 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38324
38325 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38326 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38327 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38328 else
38329 sb->resync_offset = cpu_to_le64(0);
38330
38331 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38332 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38333
38334 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38335 sb->size = cpu_to_le64(mddev->dev_sectors);
38336 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38337 static ssize_t
38338 errors_show(struct md_rdev *rdev, char *page)
38339 {
38340 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38341 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38342 }
38343
38344 static ssize_t
38345 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38346 char *e;
38347 unsigned long n = simple_strtoul(buf, &e, 10);
38348 if (*buf && (*e == 0 || *e == '\n')) {
38349 - atomic_set(&rdev->corrected_errors, n);
38350 + atomic_set_unchecked(&rdev->corrected_errors, n);
38351 return len;
38352 }
38353 return -EINVAL;
38354 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38355 rdev->sb_loaded = 0;
38356 rdev->bb_page = NULL;
38357 atomic_set(&rdev->nr_pending, 0);
38358 - atomic_set(&rdev->read_errors, 0);
38359 - atomic_set(&rdev->corrected_errors, 0);
38360 + atomic_set_unchecked(&rdev->read_errors, 0);
38361 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38362
38363 INIT_LIST_HEAD(&rdev->same_set);
38364 init_waitqueue_head(&rdev->blocked_wait);
38365 @@ -6994,7 +6994,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38366
38367 spin_unlock(&pers_lock);
38368 seq_printf(seq, "\n");
38369 - seq->poll_event = atomic_read(&md_event_count);
38370 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38371 return 0;
38372 }
38373 if (v == (void*)2) {
38374 @@ -7097,7 +7097,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38375 return error;
38376
38377 seq = file->private_data;
38378 - seq->poll_event = atomic_read(&md_event_count);
38379 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38380 return error;
38381 }
38382
38383 @@ -7111,7 +7111,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38384 /* always allow read */
38385 mask = POLLIN | POLLRDNORM;
38386
38387 - if (seq->poll_event != atomic_read(&md_event_count))
38388 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38389 mask |= POLLERR | POLLPRI;
38390 return mask;
38391 }
38392 @@ -7155,7 +7155,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38393 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38394 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38395 (int)part_stat_read(&disk->part0, sectors[1]) -
38396 - atomic_read(&disk->sync_io);
38397 + atomic_read_unchecked(&disk->sync_io);
38398 /* sync IO will cause sync_io to increase before the disk_stats
38399 * as sync_io is counted when a request starts, and
38400 * disk_stats is counted when it completes.
38401 diff --git a/drivers/md/md.h b/drivers/md/md.h
38402 index d90fb1a..4174a2b 100644
38403 --- a/drivers/md/md.h
38404 +++ b/drivers/md/md.h
38405 @@ -94,13 +94,13 @@ struct md_rdev {
38406 * only maintained for arrays that
38407 * support hot removal
38408 */
38409 - atomic_t read_errors; /* number of consecutive read errors that
38410 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38411 * we have tried to ignore.
38412 */
38413 struct timespec last_read_error; /* monotonic time since our
38414 * last read error
38415 */
38416 - atomic_t corrected_errors; /* number of corrected read errors,
38417 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38418 * for reporting to userspace and storing
38419 * in superblock.
38420 */
38421 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38422
38423 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38424 {
38425 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38426 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38427 }
38428
38429 struct md_personality
38430 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38431 index 1cbfc6b..56e1dbb 100644
38432 --- a/drivers/md/persistent-data/dm-space-map.h
38433 +++ b/drivers/md/persistent-data/dm-space-map.h
38434 @@ -60,6 +60,7 @@ struct dm_space_map {
38435 int (*root_size)(struct dm_space_map *sm, size_t *result);
38436 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38437 };
38438 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38439
38440 /*----------------------------------------------------------------*/
38441
38442 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38443 index 7116798..c81390c 100644
38444 --- a/drivers/md/raid1.c
38445 +++ b/drivers/md/raid1.c
38446 @@ -1836,7 +1836,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38447 if (r1_sync_page_io(rdev, sect, s,
38448 bio->bi_io_vec[idx].bv_page,
38449 READ) != 0)
38450 - atomic_add(s, &rdev->corrected_errors);
38451 + atomic_add_unchecked(s, &rdev->corrected_errors);
38452 }
38453 sectors -= s;
38454 sect += s;
38455 @@ -2058,7 +2058,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38456 test_bit(In_sync, &rdev->flags)) {
38457 if (r1_sync_page_io(rdev, sect, s,
38458 conf->tmppage, READ)) {
38459 - atomic_add(s, &rdev->corrected_errors);
38460 + atomic_add_unchecked(s, &rdev->corrected_errors);
38461 printk(KERN_INFO
38462 "md/raid1:%s: read error corrected "
38463 "(%d sectors at %llu on %s)\n",
38464 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38465 index e4ea992..d234520 100644
38466 --- a/drivers/md/raid10.c
38467 +++ b/drivers/md/raid10.c
38468 @@ -1942,7 +1942,7 @@ static void end_sync_read(struct bio *bio, int error)
38469 /* The write handler will notice the lack of
38470 * R10BIO_Uptodate and record any errors etc
38471 */
38472 - atomic_add(r10_bio->sectors,
38473 + atomic_add_unchecked(r10_bio->sectors,
38474 &conf->mirrors[d].rdev->corrected_errors);
38475
38476 /* for reconstruct, we always reschedule after a read.
38477 @@ -2291,7 +2291,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38478 {
38479 struct timespec cur_time_mon;
38480 unsigned long hours_since_last;
38481 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38482 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38483
38484 ktime_get_ts(&cur_time_mon);
38485
38486 @@ -2313,9 +2313,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38487 * overflowing the shift of read_errors by hours_since_last.
38488 */
38489 if (hours_since_last >= 8 * sizeof(read_errors))
38490 - atomic_set(&rdev->read_errors, 0);
38491 + atomic_set_unchecked(&rdev->read_errors, 0);
38492 else
38493 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38494 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38495 }
38496
38497 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38498 @@ -2369,8 +2369,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38499 return;
38500
38501 check_decay_read_errors(mddev, rdev);
38502 - atomic_inc(&rdev->read_errors);
38503 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38504 + atomic_inc_unchecked(&rdev->read_errors);
38505 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38506 char b[BDEVNAME_SIZE];
38507 bdevname(rdev->bdev, b);
38508
38509 @@ -2378,7 +2378,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38510 "md/raid10:%s: %s: Raid device exceeded "
38511 "read_error threshold [cur %d:max %d]\n",
38512 mdname(mddev), b,
38513 - atomic_read(&rdev->read_errors), max_read_errors);
38514 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38515 printk(KERN_NOTICE
38516 "md/raid10:%s: %s: Failing raid device\n",
38517 mdname(mddev), b);
38518 @@ -2533,7 +2533,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38519 sect +
38520 choose_data_offset(r10_bio, rdev)),
38521 bdevname(rdev->bdev, b));
38522 - atomic_add(s, &rdev->corrected_errors);
38523 + atomic_add_unchecked(s, &rdev->corrected_errors);
38524 }
38525
38526 rdev_dec_pending(rdev, mddev);
38527 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38528 index 251ab64..ed23a18 100644
38529 --- a/drivers/md/raid5.c
38530 +++ b/drivers/md/raid5.c
38531 @@ -1763,21 +1763,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38532 mdname(conf->mddev), STRIPE_SECTORS,
38533 (unsigned long long)s,
38534 bdevname(rdev->bdev, b));
38535 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38536 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38537 clear_bit(R5_ReadError, &sh->dev[i].flags);
38538 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38539 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38540 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38541
38542 - if (atomic_read(&rdev->read_errors))
38543 - atomic_set(&rdev->read_errors, 0);
38544 + if (atomic_read_unchecked(&rdev->read_errors))
38545 + atomic_set_unchecked(&rdev->read_errors, 0);
38546 } else {
38547 const char *bdn = bdevname(rdev->bdev, b);
38548 int retry = 0;
38549 int set_bad = 0;
38550
38551 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38552 - atomic_inc(&rdev->read_errors);
38553 + atomic_inc_unchecked(&rdev->read_errors);
38554 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38555 printk_ratelimited(
38556 KERN_WARNING
38557 @@ -1805,7 +1805,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38558 mdname(conf->mddev),
38559 (unsigned long long)s,
38560 bdn);
38561 - } else if (atomic_read(&rdev->read_errors)
38562 + } else if (atomic_read_unchecked(&rdev->read_errors)
38563 > conf->max_nr_stripes)
38564 printk(KERN_WARNING
38565 "md/raid:%s: Too many read errors, failing device %s.\n",
38566 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38567 index 401ef64..836e563 100644
38568 --- a/drivers/media/dvb-core/dvbdev.c
38569 +++ b/drivers/media/dvb-core/dvbdev.c
38570 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38571 const struct dvb_device *template, void *priv, int type)
38572 {
38573 struct dvb_device *dvbdev;
38574 - struct file_operations *dvbdevfops;
38575 + file_operations_no_const *dvbdevfops;
38576 struct device *clsdev;
38577 int minor;
38578 int id;
38579 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38580 index 9b6c3bb..baeb5c7 100644
38581 --- a/drivers/media/dvb-frontends/dib3000.h
38582 +++ b/drivers/media/dvb-frontends/dib3000.h
38583 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38584 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38585 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38586 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38587 -};
38588 +} __no_const;
38589
38590 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38591 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38592 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38593 index bc78354..42c9459 100644
38594 --- a/drivers/media/pci/cx88/cx88-video.c
38595 +++ b/drivers/media/pci/cx88/cx88-video.c
38596 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38597
38598 /* ------------------------------------------------------------------ */
38599
38600 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38601 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38602 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38603 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38604 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38605 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38606
38607 module_param_array(video_nr, int, NULL, 0444);
38608 module_param_array(vbi_nr, int, NULL, 0444);
38609 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38610 index 96c4a17..1305a79 100644
38611 --- a/drivers/media/platform/omap/omap_vout.c
38612 +++ b/drivers/media/platform/omap/omap_vout.c
38613 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38614 OMAP_VIDEO2,
38615 };
38616
38617 -static struct videobuf_queue_ops video_vbq_ops;
38618 /* Variables configurable through module params*/
38619 static u32 video1_numbuffers = 3;
38620 static u32 video2_numbuffers = 3;
38621 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38622 {
38623 struct videobuf_queue *q;
38624 struct omap_vout_device *vout = NULL;
38625 + static struct videobuf_queue_ops video_vbq_ops = {
38626 + .buf_setup = omap_vout_buffer_setup,
38627 + .buf_prepare = omap_vout_buffer_prepare,
38628 + .buf_release = omap_vout_buffer_release,
38629 + .buf_queue = omap_vout_buffer_queue,
38630 + };
38631
38632 vout = video_drvdata(file);
38633 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38634 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38635 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38636
38637 q = &vout->vbq;
38638 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38639 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38640 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38641 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38642 spin_lock_init(&vout->vbq_lock);
38643
38644 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38645 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38646 index 04e6490..2df65bf 100644
38647 --- a/drivers/media/platform/s5p-tv/mixer.h
38648 +++ b/drivers/media/platform/s5p-tv/mixer.h
38649 @@ -156,7 +156,7 @@ struct mxr_layer {
38650 /** layer index (unique identifier) */
38651 int idx;
38652 /** callbacks for layer methods */
38653 - struct mxr_layer_ops ops;
38654 + struct mxr_layer_ops *ops;
38655 /** format array */
38656 const struct mxr_format **fmt_array;
38657 /** size of format array */
38658 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38659 index b93a21f..2535195 100644
38660 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38661 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38662 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38663 {
38664 struct mxr_layer *layer;
38665 int ret;
38666 - struct mxr_layer_ops ops = {
38667 + static struct mxr_layer_ops ops = {
38668 .release = mxr_graph_layer_release,
38669 .buffer_set = mxr_graph_buffer_set,
38670 .stream_set = mxr_graph_stream_set,
38671 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38672 index b713403..53cb5ad 100644
38673 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38674 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38675 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38676 layer->update_buf = next;
38677 }
38678
38679 - layer->ops.buffer_set(layer, layer->update_buf);
38680 + layer->ops->buffer_set(layer, layer->update_buf);
38681
38682 if (done && done != layer->shadow_buf)
38683 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38684 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38685 index 82142a2..6de47e8 100644
38686 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38687 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38688 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38689 layer->geo.src.height = layer->geo.src.full_height;
38690
38691 mxr_geometry_dump(mdev, &layer->geo);
38692 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38693 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38694 mxr_geometry_dump(mdev, &layer->geo);
38695 }
38696
38697 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38698 layer->geo.dst.full_width = mbus_fmt.width;
38699 layer->geo.dst.full_height = mbus_fmt.height;
38700 layer->geo.dst.field = mbus_fmt.field;
38701 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38702 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38703
38704 mxr_geometry_dump(mdev, &layer->geo);
38705 }
38706 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38707 /* set source size to highest accepted value */
38708 geo->src.full_width = max(geo->dst.full_width, pix->width);
38709 geo->src.full_height = max(geo->dst.full_height, pix->height);
38710 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38711 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38712 mxr_geometry_dump(mdev, &layer->geo);
38713 /* set cropping to total visible screen */
38714 geo->src.width = pix->width;
38715 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38716 geo->src.x_offset = 0;
38717 geo->src.y_offset = 0;
38718 /* assure consistency of geometry */
38719 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38720 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38721 mxr_geometry_dump(mdev, &layer->geo);
38722 /* set full size to lowest possible value */
38723 geo->src.full_width = 0;
38724 geo->src.full_height = 0;
38725 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38726 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38727 mxr_geometry_dump(mdev, &layer->geo);
38728
38729 /* returning results */
38730 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38731 target->width = s->r.width;
38732 target->height = s->r.height;
38733
38734 - layer->ops.fix_geometry(layer, stage, s->flags);
38735 + layer->ops->fix_geometry(layer, stage, s->flags);
38736
38737 /* retrieve update selection rectangle */
38738 res.left = target->x_offset;
38739 @@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38740 mxr_output_get(mdev);
38741
38742 mxr_layer_update_output(layer);
38743 - layer->ops.format_set(layer);
38744 + layer->ops->format_set(layer);
38745 /* enabling layer in hardware */
38746 spin_lock_irqsave(&layer->enq_slock, flags);
38747 layer->state = MXR_LAYER_STREAMING;
38748 spin_unlock_irqrestore(&layer->enq_slock, flags);
38749
38750 - layer->ops.stream_set(layer, MXR_ENABLE);
38751 + layer->ops->stream_set(layer, MXR_ENABLE);
38752 mxr_streamer_get(mdev);
38753
38754 return 0;
38755 @@ -1014,7 +1014,7 @@ static int stop_streaming(struct vb2_queue *vq)
38756 spin_unlock_irqrestore(&layer->enq_slock, flags);
38757
38758 /* disabling layer in hardware */
38759 - layer->ops.stream_set(layer, MXR_DISABLE);
38760 + layer->ops->stream_set(layer, MXR_DISABLE);
38761 /* remove one streamer */
38762 mxr_streamer_put(mdev);
38763 /* allow changes in output configuration */
38764 @@ -1053,8 +1053,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38765
38766 void mxr_layer_release(struct mxr_layer *layer)
38767 {
38768 - if (layer->ops.release)
38769 - layer->ops.release(layer);
38770 + if (layer->ops->release)
38771 + layer->ops->release(layer);
38772 }
38773
38774 void mxr_base_layer_release(struct mxr_layer *layer)
38775 @@ -1080,7 +1080,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38776
38777 layer->mdev = mdev;
38778 layer->idx = idx;
38779 - layer->ops = *ops;
38780 + layer->ops = ops;
38781
38782 spin_lock_init(&layer->enq_slock);
38783 INIT_LIST_HEAD(&layer->enq_list);
38784 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38785 index 3d13a63..da31bf1 100644
38786 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38787 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38788 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38789 {
38790 struct mxr_layer *layer;
38791 int ret;
38792 - struct mxr_layer_ops ops = {
38793 + static struct mxr_layer_ops ops = {
38794 .release = mxr_vp_layer_release,
38795 .buffer_set = mxr_vp_buffer_set,
38796 .stream_set = mxr_vp_stream_set,
38797 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38798 index 643d80a..56bb96b 100644
38799 --- a/drivers/media/radio/radio-cadet.c
38800 +++ b/drivers/media/radio/radio-cadet.c
38801 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38802 unsigned char readbuf[RDS_BUFFER];
38803 int i = 0;
38804
38805 + if (count > RDS_BUFFER)
38806 + return -EFAULT;
38807 mutex_lock(&dev->lock);
38808 if (dev->rdsstat == 0)
38809 cadet_start_rds(dev);
38810 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38811 while (i < count && dev->rdsin != dev->rdsout)
38812 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38813
38814 - if (i && copy_to_user(data, readbuf, i))
38815 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38816 i = -EFAULT;
38817 unlock:
38818 mutex_unlock(&dev->lock);
38819 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38820 index 3940bb0..fb3952a 100644
38821 --- a/drivers/media/usb/dvb-usb/cxusb.c
38822 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38823 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38824
38825 struct dib0700_adapter_state {
38826 int (*set_param_save) (struct dvb_frontend *);
38827 -};
38828 +} __no_const;
38829
38830 static int dib7070_set_param_override(struct dvb_frontend *fe)
38831 {
38832 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38833 index 9578a67..31aa652 100644
38834 --- a/drivers/media/usb/dvb-usb/dw2102.c
38835 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38836 @@ -115,7 +115,7 @@ struct su3000_state {
38837
38838 struct s6x0_state {
38839 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38840 -};
38841 +} __no_const;
38842
38843 /* debug */
38844 static int dvb_usb_dw2102_debug;
38845 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38846 index 7157af3..139e91a 100644
38847 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38848 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38849 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
38850 __u32 reserved;
38851 };
38852
38853 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38854 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38855 enum v4l2_memory memory)
38856 {
38857 void __user *up_pln;
38858 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38859 return 0;
38860 }
38861
38862 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38863 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38864 enum v4l2_memory memory)
38865 {
38866 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
38867 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
38868 put_user(kp->start_block, &up->start_block) ||
38869 put_user(kp->blocks, &up->blocks) ||
38870 put_user(tmp, &up->edid) ||
38871 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
38872 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
38873 return -EFAULT;
38874 return 0;
38875 }
38876 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38877 index aa6e7c7..cb5de87 100644
38878 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38879 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38880 @@ -236,7 +236,7 @@ static void v4l_print_format(const void *arg, bool write_only)
38881 const struct v4l2_vbi_format *vbi;
38882 const struct v4l2_sliced_vbi_format *sliced;
38883 const struct v4l2_window *win;
38884 - const struct v4l2_clip *clip;
38885 + const struct v4l2_clip __user *pclip;
38886 unsigned i;
38887
38888 pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
38889 @@ -284,12 +284,16 @@ static void v4l_print_format(const void *arg, bool write_only)
38890 win->w.left, win->w.top,
38891 prt_names(win->field, v4l2_field_names),
38892 win->chromakey, win->bitmap, win->global_alpha);
38893 - clip = win->clips;
38894 + pclip = win->clips;
38895 for (i = 0; i < win->clipcount; i++) {
38896 + struct v4l2_clip clip;
38897 +
38898 + if (copy_from_user(&clip, pclip, sizeof clip))
38899 + break;
38900 printk(KERN_DEBUG "clip %u: wxh=%dx%d, x,y=%d,%d\n",
38901 - i, clip->c.width, clip->c.height,
38902 - clip->c.left, clip->c.top);
38903 - clip = clip->next;
38904 + i, clip.c.width, clip.c.height,
38905 + clip.c.left, clip.c.top);
38906 + pclip = clip.next;
38907 }
38908 break;
38909 case V4L2_BUF_TYPE_VBI_CAPTURE:
38910 @@ -1923,7 +1927,8 @@ struct v4l2_ioctl_info {
38911 struct file *file, void *fh, void *p);
38912 } u;
38913 void (*debug)(const void *arg, bool write_only);
38914 -};
38915 +} __do_const;
38916 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38917
38918 /* This control needs a priority check */
38919 #define INFO_FL_PRIO (1 << 0)
38920 @@ -2108,7 +2113,7 @@ static long __video_do_ioctl(struct file *file,
38921 struct video_device *vfd = video_devdata(file);
38922 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38923 bool write_only = false;
38924 - struct v4l2_ioctl_info default_info;
38925 + v4l2_ioctl_info_no_const default_info;
38926 const struct v4l2_ioctl_info *info;
38927 void *fh = file->private_data;
38928 struct v4l2_fh *vfh = NULL;
38929 @@ -2193,7 +2198,7 @@ done:
38930 }
38931
38932 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38933 - void * __user *user_ptr, void ***kernel_ptr)
38934 + void __user **user_ptr, void ***kernel_ptr)
38935 {
38936 int ret = 0;
38937
38938 @@ -2209,7 +2214,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38939 ret = -EINVAL;
38940 break;
38941 }
38942 - *user_ptr = (void __user *)buf->m.planes;
38943 + *user_ptr = (void __force_user *)buf->m.planes;
38944 *kernel_ptr = (void *)&buf->m.planes;
38945 *array_size = sizeof(struct v4l2_plane) * buf->length;
38946 ret = 1;
38947 @@ -2244,7 +2249,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38948 ret = -EINVAL;
38949 break;
38950 }
38951 - *user_ptr = (void __user *)ctrls->controls;
38952 + *user_ptr = (void __force_user *)ctrls->controls;
38953 *kernel_ptr = (void *)&ctrls->controls;
38954 *array_size = sizeof(struct v4l2_ext_control)
38955 * ctrls->count;
38956 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38957 index fb69baa..3aeea2e 100644
38958 --- a/drivers/message/fusion/mptbase.c
38959 +++ b/drivers/message/fusion/mptbase.c
38960 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38961 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38962 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38963
38964 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38965 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38966 +#else
38967 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38968 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38969 +#endif
38970 +
38971 /*
38972 * Rounding UP to nearest 4-kB boundary here...
38973 */
38974 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38975 ioc->facts.GlobalCredits);
38976
38977 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38978 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38979 + NULL, NULL);
38980 +#else
38981 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38982 +#endif
38983 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38984 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38985 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38986 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38987 index fa43c39..daeb158 100644
38988 --- a/drivers/message/fusion/mptsas.c
38989 +++ b/drivers/message/fusion/mptsas.c
38990 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38991 return 0;
38992 }
38993
38994 +static inline void
38995 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38996 +{
38997 + if (phy_info->port_details) {
38998 + phy_info->port_details->rphy = rphy;
38999 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39000 + ioc->name, rphy));
39001 + }
39002 +
39003 + if (rphy) {
39004 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39005 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39006 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39007 + ioc->name, rphy, rphy->dev.release));
39008 + }
39009 +}
39010 +
39011 /* no mutex */
39012 static void
39013 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
39014 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
39015 return NULL;
39016 }
39017
39018 -static inline void
39019 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39020 -{
39021 - if (phy_info->port_details) {
39022 - phy_info->port_details->rphy = rphy;
39023 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39024 - ioc->name, rphy));
39025 - }
39026 -
39027 - if (rphy) {
39028 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39029 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39030 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39031 - ioc->name, rphy, rphy->dev.release));
39032 - }
39033 -}
39034 -
39035 static inline struct sas_port *
39036 mptsas_get_port(struct mptsas_phyinfo *phy_info)
39037 {
39038 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
39039 index 164afa7..b6b2e74 100644
39040 --- a/drivers/message/fusion/mptscsih.c
39041 +++ b/drivers/message/fusion/mptscsih.c
39042 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
39043
39044 h = shost_priv(SChost);
39045
39046 - if (h) {
39047 - if (h->info_kbuf == NULL)
39048 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39049 - return h->info_kbuf;
39050 - h->info_kbuf[0] = '\0';
39051 + if (!h)
39052 + return NULL;
39053
39054 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39055 - h->info_kbuf[size-1] = '\0';
39056 - }
39057 + if (h->info_kbuf == NULL)
39058 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39059 + return h->info_kbuf;
39060 + h->info_kbuf[0] = '\0';
39061 +
39062 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39063 + h->info_kbuf[size-1] = '\0';
39064
39065 return h->info_kbuf;
39066 }
39067 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39068 index 8001aa6..b137580 100644
39069 --- a/drivers/message/i2o/i2o_proc.c
39070 +++ b/drivers/message/i2o/i2o_proc.c
39071 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39072 "Array Controller Device"
39073 };
39074
39075 -static char *chtostr(char *tmp, u8 *chars, int n)
39076 -{
39077 - tmp[0] = 0;
39078 - return strncat(tmp, (char *)chars, n);
39079 -}
39080 -
39081 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39082 char *group)
39083 {
39084 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39085 } *result;
39086
39087 i2o_exec_execute_ddm_table ddm_table;
39088 - char tmp[28 + 1];
39089
39090 result = kmalloc(sizeof(*result), GFP_KERNEL);
39091 if (!result)
39092 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39093
39094 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39095 seq_printf(seq, "%-#8x", ddm_table.module_id);
39096 - seq_printf(seq, "%-29s",
39097 - chtostr(tmp, ddm_table.module_name_version, 28));
39098 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39099 seq_printf(seq, "%9d ", ddm_table.data_size);
39100 seq_printf(seq, "%8d", ddm_table.code_size);
39101
39102 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39103
39104 i2o_driver_result_table *result;
39105 i2o_driver_store_table *dst;
39106 - char tmp[28 + 1];
39107
39108 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39109 if (result == NULL)
39110 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39111
39112 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39113 seq_printf(seq, "%-#8x", dst->module_id);
39114 - seq_printf(seq, "%-29s",
39115 - chtostr(tmp, dst->module_name_version, 28));
39116 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39117 + seq_printf(seq, "%-.28s", dst->module_name_version);
39118 + seq_printf(seq, "%-.8s", dst->date);
39119 seq_printf(seq, "%8d ", dst->module_size);
39120 seq_printf(seq, "%8d ", dst->mpb_size);
39121 seq_printf(seq, "0x%04x", dst->module_flags);
39122 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39123 // == (allow) 512d bytes (max)
39124 static u16 *work16 = (u16 *) work32;
39125 int token;
39126 - char tmp[16 + 1];
39127
39128 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39129
39130 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39131 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39132 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39133 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39134 - seq_printf(seq, "Vendor info : %s\n",
39135 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39136 - seq_printf(seq, "Product info : %s\n",
39137 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39138 - seq_printf(seq, "Description : %s\n",
39139 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39140 - seq_printf(seq, "Product rev. : %s\n",
39141 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39142 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39143 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39144 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39145 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39146
39147 seq_printf(seq, "Serial number : ");
39148 print_serial_number(seq, (u8 *) (work32 + 16),
39149 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39150 u8 pad[256]; // allow up to 256 byte (max) serial number
39151 } result;
39152
39153 - char tmp[24 + 1];
39154 -
39155 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39156
39157 if (token < 0) {
39158 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39159 }
39160
39161 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39162 - seq_printf(seq, "Module name : %s\n",
39163 - chtostr(tmp, result.module_name, 24));
39164 - seq_printf(seq, "Module revision : %s\n",
39165 - chtostr(tmp, result.module_rev, 8));
39166 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39167 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39168
39169 seq_printf(seq, "Serial number : ");
39170 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39171 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39172 u8 instance_number[4];
39173 } result;
39174
39175 - char tmp[64 + 1];
39176 -
39177 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39178
39179 if (token < 0) {
39180 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39181 return 0;
39182 }
39183
39184 - seq_printf(seq, "Device name : %s\n",
39185 - chtostr(tmp, result.device_name, 64));
39186 - seq_printf(seq, "Service name : %s\n",
39187 - chtostr(tmp, result.service_name, 64));
39188 - seq_printf(seq, "Physical name : %s\n",
39189 - chtostr(tmp, result.physical_location, 64));
39190 - seq_printf(seq, "Instance number : %s\n",
39191 - chtostr(tmp, result.instance_number, 4));
39192 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39193 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39194 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39195 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39196
39197 return 0;
39198 }
39199 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39200 index a8c08f3..155fe3d 100644
39201 --- a/drivers/message/i2o/iop.c
39202 +++ b/drivers/message/i2o/iop.c
39203 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39204
39205 spin_lock_irqsave(&c->context_list_lock, flags);
39206
39207 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39208 - atomic_inc(&c->context_list_counter);
39209 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39210 + atomic_inc_unchecked(&c->context_list_counter);
39211
39212 - entry->context = atomic_read(&c->context_list_counter);
39213 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39214
39215 list_add(&entry->list, &c->context_list);
39216
39217 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39218
39219 #if BITS_PER_LONG == 64
39220 spin_lock_init(&c->context_list_lock);
39221 - atomic_set(&c->context_list_counter, 0);
39222 + atomic_set_unchecked(&c->context_list_counter, 0);
39223 INIT_LIST_HEAD(&c->context_list);
39224 #endif
39225
39226 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39227 index 45ece11..8efa218 100644
39228 --- a/drivers/mfd/janz-cmodio.c
39229 +++ b/drivers/mfd/janz-cmodio.c
39230 @@ -13,6 +13,7 @@
39231
39232 #include <linux/kernel.h>
39233 #include <linux/module.h>
39234 +#include <linux/slab.h>
39235 #include <linux/init.h>
39236 #include <linux/pci.h>
39237 #include <linux/interrupt.h>
39238 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39239 index a5f9888..1c0ed56 100644
39240 --- a/drivers/mfd/twl4030-irq.c
39241 +++ b/drivers/mfd/twl4030-irq.c
39242 @@ -35,6 +35,7 @@
39243 #include <linux/of.h>
39244 #include <linux/irqdomain.h>
39245 #include <linux/i2c/twl.h>
39246 +#include <asm/pgtable.h>
39247
39248 #include "twl-core.h"
39249
39250 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39251 * Install an irq handler for each of the SIH modules;
39252 * clone dummy irq_chip since PIH can't *do* anything
39253 */
39254 - twl4030_irq_chip = dummy_irq_chip;
39255 - twl4030_irq_chip.name = "twl4030";
39256 + pax_open_kernel();
39257 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39258 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39259
39260 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39261 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39262 + pax_close_kernel();
39263
39264 for (i = irq_base; i < irq_end; i++) {
39265 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39266 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39267 index 277a8db..0e0b754 100644
39268 --- a/drivers/mfd/twl6030-irq.c
39269 +++ b/drivers/mfd/twl6030-irq.c
39270 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39271 * install an irq handler for each of the modules;
39272 * clone dummy irq_chip since PIH can't *do* anything
39273 */
39274 - twl6030_irq_chip = dummy_irq_chip;
39275 - twl6030_irq_chip.name = "twl6030";
39276 - twl6030_irq_chip.irq_set_type = NULL;
39277 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39278 + pax_open_kernel();
39279 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39280 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39281 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39282 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39283 + pax_close_kernel();
39284
39285 for (i = irq_base; i < irq_end; i++) {
39286 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39287 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39288 index f32550a..e3e52a2 100644
39289 --- a/drivers/misc/c2port/core.c
39290 +++ b/drivers/misc/c2port/core.c
39291 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39292 mutex_init(&c2dev->mutex);
39293
39294 /* Create binary file */
39295 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39296 + pax_open_kernel();
39297 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39298 + pax_close_kernel();
39299 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39300 if (unlikely(ret))
39301 goto error_device_create_bin_file;
39302 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39303 index 36f5d52..32311c3 100644
39304 --- a/drivers/misc/kgdbts.c
39305 +++ b/drivers/misc/kgdbts.c
39306 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39307 char before[BREAK_INSTR_SIZE];
39308 char after[BREAK_INSTR_SIZE];
39309
39310 - probe_kernel_read(before, (char *)kgdbts_break_test,
39311 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39312 BREAK_INSTR_SIZE);
39313 init_simple_test();
39314 ts.tst = plant_and_detach_test;
39315 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39316 /* Activate test with initial breakpoint */
39317 if (!is_early)
39318 kgdb_breakpoint();
39319 - probe_kernel_read(after, (char *)kgdbts_break_test,
39320 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39321 BREAK_INSTR_SIZE);
39322 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39323 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39324 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39325 index 4a87e5c..76bdf5c 100644
39326 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39327 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39328 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39329 * the lid is closed. This leads to interrupts as soon as a little move
39330 * is done.
39331 */
39332 - atomic_inc(&lis3->count);
39333 + atomic_inc_unchecked(&lis3->count);
39334
39335 wake_up_interruptible(&lis3->misc_wait);
39336 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39337 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39338 if (lis3->pm_dev)
39339 pm_runtime_get_sync(lis3->pm_dev);
39340
39341 - atomic_set(&lis3->count, 0);
39342 + atomic_set_unchecked(&lis3->count, 0);
39343 return 0;
39344 }
39345
39346 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39347 add_wait_queue(&lis3->misc_wait, &wait);
39348 while (true) {
39349 set_current_state(TASK_INTERRUPTIBLE);
39350 - data = atomic_xchg(&lis3->count, 0);
39351 + data = atomic_xchg_unchecked(&lis3->count, 0);
39352 if (data)
39353 break;
39354
39355 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39356 struct lis3lv02d, miscdev);
39357
39358 poll_wait(file, &lis3->misc_wait, wait);
39359 - if (atomic_read(&lis3->count))
39360 + if (atomic_read_unchecked(&lis3->count))
39361 return POLLIN | POLLRDNORM;
39362 return 0;
39363 }
39364 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39365 index c439c82..1f20f57 100644
39366 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39367 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39368 @@ -297,7 +297,7 @@ struct lis3lv02d {
39369 struct input_polled_dev *idev; /* input device */
39370 struct platform_device *pdev; /* platform device */
39371 struct regulator_bulk_data regulators[2];
39372 - atomic_t count; /* interrupt count after last read */
39373 + atomic_unchecked_t count; /* interrupt count after last read */
39374 union axis_conversion ac; /* hw -> logical axis */
39375 int mapped_btns[3];
39376
39377 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39378 index 2f30bad..c4c13d0 100644
39379 --- a/drivers/misc/sgi-gru/gruhandles.c
39380 +++ b/drivers/misc/sgi-gru/gruhandles.c
39381 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39382 unsigned long nsec;
39383
39384 nsec = CLKS2NSEC(clks);
39385 - atomic_long_inc(&mcs_op_statistics[op].count);
39386 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39387 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39388 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39389 if (mcs_op_statistics[op].max < nsec)
39390 mcs_op_statistics[op].max = nsec;
39391 }
39392 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39393 index 950dbe9..eeef0f8 100644
39394 --- a/drivers/misc/sgi-gru/gruprocfs.c
39395 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39396 @@ -32,9 +32,9 @@
39397
39398 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39399
39400 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39401 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39402 {
39403 - unsigned long val = atomic_long_read(v);
39404 + unsigned long val = atomic_long_read_unchecked(v);
39405
39406 seq_printf(s, "%16lu %s\n", val, id);
39407 }
39408 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39409
39410 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39411 for (op = 0; op < mcsop_last; op++) {
39412 - count = atomic_long_read(&mcs_op_statistics[op].count);
39413 - total = atomic_long_read(&mcs_op_statistics[op].total);
39414 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39415 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39416 max = mcs_op_statistics[op].max;
39417 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39418 count ? total / count : 0, max);
39419 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39420 index 5c3ce24..4915ccb 100644
39421 --- a/drivers/misc/sgi-gru/grutables.h
39422 +++ b/drivers/misc/sgi-gru/grutables.h
39423 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39424 * GRU statistics.
39425 */
39426 struct gru_stats_s {
39427 - atomic_long_t vdata_alloc;
39428 - atomic_long_t vdata_free;
39429 - atomic_long_t gts_alloc;
39430 - atomic_long_t gts_free;
39431 - atomic_long_t gms_alloc;
39432 - atomic_long_t gms_free;
39433 - atomic_long_t gts_double_allocate;
39434 - atomic_long_t assign_context;
39435 - atomic_long_t assign_context_failed;
39436 - atomic_long_t free_context;
39437 - atomic_long_t load_user_context;
39438 - atomic_long_t load_kernel_context;
39439 - atomic_long_t lock_kernel_context;
39440 - atomic_long_t unlock_kernel_context;
39441 - atomic_long_t steal_user_context;
39442 - atomic_long_t steal_kernel_context;
39443 - atomic_long_t steal_context_failed;
39444 - atomic_long_t nopfn;
39445 - atomic_long_t asid_new;
39446 - atomic_long_t asid_next;
39447 - atomic_long_t asid_wrap;
39448 - atomic_long_t asid_reuse;
39449 - atomic_long_t intr;
39450 - atomic_long_t intr_cbr;
39451 - atomic_long_t intr_tfh;
39452 - atomic_long_t intr_spurious;
39453 - atomic_long_t intr_mm_lock_failed;
39454 - atomic_long_t call_os;
39455 - atomic_long_t call_os_wait_queue;
39456 - atomic_long_t user_flush_tlb;
39457 - atomic_long_t user_unload_context;
39458 - atomic_long_t user_exception;
39459 - atomic_long_t set_context_option;
39460 - atomic_long_t check_context_retarget_intr;
39461 - atomic_long_t check_context_unload;
39462 - atomic_long_t tlb_dropin;
39463 - atomic_long_t tlb_preload_page;
39464 - atomic_long_t tlb_dropin_fail_no_asid;
39465 - atomic_long_t tlb_dropin_fail_upm;
39466 - atomic_long_t tlb_dropin_fail_invalid;
39467 - atomic_long_t tlb_dropin_fail_range_active;
39468 - atomic_long_t tlb_dropin_fail_idle;
39469 - atomic_long_t tlb_dropin_fail_fmm;
39470 - atomic_long_t tlb_dropin_fail_no_exception;
39471 - atomic_long_t tfh_stale_on_fault;
39472 - atomic_long_t mmu_invalidate_range;
39473 - atomic_long_t mmu_invalidate_page;
39474 - atomic_long_t flush_tlb;
39475 - atomic_long_t flush_tlb_gru;
39476 - atomic_long_t flush_tlb_gru_tgh;
39477 - atomic_long_t flush_tlb_gru_zero_asid;
39478 + atomic_long_unchecked_t vdata_alloc;
39479 + atomic_long_unchecked_t vdata_free;
39480 + atomic_long_unchecked_t gts_alloc;
39481 + atomic_long_unchecked_t gts_free;
39482 + atomic_long_unchecked_t gms_alloc;
39483 + atomic_long_unchecked_t gms_free;
39484 + atomic_long_unchecked_t gts_double_allocate;
39485 + atomic_long_unchecked_t assign_context;
39486 + atomic_long_unchecked_t assign_context_failed;
39487 + atomic_long_unchecked_t free_context;
39488 + atomic_long_unchecked_t load_user_context;
39489 + atomic_long_unchecked_t load_kernel_context;
39490 + atomic_long_unchecked_t lock_kernel_context;
39491 + atomic_long_unchecked_t unlock_kernel_context;
39492 + atomic_long_unchecked_t steal_user_context;
39493 + atomic_long_unchecked_t steal_kernel_context;
39494 + atomic_long_unchecked_t steal_context_failed;
39495 + atomic_long_unchecked_t nopfn;
39496 + atomic_long_unchecked_t asid_new;
39497 + atomic_long_unchecked_t asid_next;
39498 + atomic_long_unchecked_t asid_wrap;
39499 + atomic_long_unchecked_t asid_reuse;
39500 + atomic_long_unchecked_t intr;
39501 + atomic_long_unchecked_t intr_cbr;
39502 + atomic_long_unchecked_t intr_tfh;
39503 + atomic_long_unchecked_t intr_spurious;
39504 + atomic_long_unchecked_t intr_mm_lock_failed;
39505 + atomic_long_unchecked_t call_os;
39506 + atomic_long_unchecked_t call_os_wait_queue;
39507 + atomic_long_unchecked_t user_flush_tlb;
39508 + atomic_long_unchecked_t user_unload_context;
39509 + atomic_long_unchecked_t user_exception;
39510 + atomic_long_unchecked_t set_context_option;
39511 + atomic_long_unchecked_t check_context_retarget_intr;
39512 + atomic_long_unchecked_t check_context_unload;
39513 + atomic_long_unchecked_t tlb_dropin;
39514 + atomic_long_unchecked_t tlb_preload_page;
39515 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39516 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39517 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39518 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39519 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39520 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39521 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39522 + atomic_long_unchecked_t tfh_stale_on_fault;
39523 + atomic_long_unchecked_t mmu_invalidate_range;
39524 + atomic_long_unchecked_t mmu_invalidate_page;
39525 + atomic_long_unchecked_t flush_tlb;
39526 + atomic_long_unchecked_t flush_tlb_gru;
39527 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39528 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39529
39530 - atomic_long_t copy_gpa;
39531 - atomic_long_t read_gpa;
39532 + atomic_long_unchecked_t copy_gpa;
39533 + atomic_long_unchecked_t read_gpa;
39534
39535 - atomic_long_t mesq_receive;
39536 - atomic_long_t mesq_receive_none;
39537 - atomic_long_t mesq_send;
39538 - atomic_long_t mesq_send_failed;
39539 - atomic_long_t mesq_noop;
39540 - atomic_long_t mesq_send_unexpected_error;
39541 - atomic_long_t mesq_send_lb_overflow;
39542 - atomic_long_t mesq_send_qlimit_reached;
39543 - atomic_long_t mesq_send_amo_nacked;
39544 - atomic_long_t mesq_send_put_nacked;
39545 - atomic_long_t mesq_page_overflow;
39546 - atomic_long_t mesq_qf_locked;
39547 - atomic_long_t mesq_qf_noop_not_full;
39548 - atomic_long_t mesq_qf_switch_head_failed;
39549 - atomic_long_t mesq_qf_unexpected_error;
39550 - atomic_long_t mesq_noop_unexpected_error;
39551 - atomic_long_t mesq_noop_lb_overflow;
39552 - atomic_long_t mesq_noop_qlimit_reached;
39553 - atomic_long_t mesq_noop_amo_nacked;
39554 - atomic_long_t mesq_noop_put_nacked;
39555 - atomic_long_t mesq_noop_page_overflow;
39556 + atomic_long_unchecked_t mesq_receive;
39557 + atomic_long_unchecked_t mesq_receive_none;
39558 + atomic_long_unchecked_t mesq_send;
39559 + atomic_long_unchecked_t mesq_send_failed;
39560 + atomic_long_unchecked_t mesq_noop;
39561 + atomic_long_unchecked_t mesq_send_unexpected_error;
39562 + atomic_long_unchecked_t mesq_send_lb_overflow;
39563 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39564 + atomic_long_unchecked_t mesq_send_amo_nacked;
39565 + atomic_long_unchecked_t mesq_send_put_nacked;
39566 + atomic_long_unchecked_t mesq_page_overflow;
39567 + atomic_long_unchecked_t mesq_qf_locked;
39568 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39569 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39570 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39571 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39572 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39573 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39574 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39575 + atomic_long_unchecked_t mesq_noop_put_nacked;
39576 + atomic_long_unchecked_t mesq_noop_page_overflow;
39577
39578 };
39579
39580 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39581 tghop_invalidate, mcsop_last};
39582
39583 struct mcs_op_statistic {
39584 - atomic_long_t count;
39585 - atomic_long_t total;
39586 + atomic_long_unchecked_t count;
39587 + atomic_long_unchecked_t total;
39588 unsigned long max;
39589 };
39590
39591 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39592
39593 #define STAT(id) do { \
39594 if (gru_options & OPT_STATS) \
39595 - atomic_long_inc(&gru_stats.id); \
39596 + atomic_long_inc_unchecked(&gru_stats.id); \
39597 } while (0)
39598
39599 #ifdef CONFIG_SGI_GRU_DEBUG
39600 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39601 index c862cd4..0d176fe 100644
39602 --- a/drivers/misc/sgi-xp/xp.h
39603 +++ b/drivers/misc/sgi-xp/xp.h
39604 @@ -288,7 +288,7 @@ struct xpc_interface {
39605 xpc_notify_func, void *);
39606 void (*received) (short, int, void *);
39607 enum xp_retval (*partid_to_nasids) (short, void *);
39608 -};
39609 +} __no_const;
39610
39611 extern struct xpc_interface xpc_interface;
39612
39613 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39614 index b94d5f7..7f494c5 100644
39615 --- a/drivers/misc/sgi-xp/xpc.h
39616 +++ b/drivers/misc/sgi-xp/xpc.h
39617 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39618 void (*received_payload) (struct xpc_channel *, void *);
39619 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39620 };
39621 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39622
39623 /* struct xpc_partition act_state values (for XPC HB) */
39624
39625 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39626 /* found in xpc_main.c */
39627 extern struct device *xpc_part;
39628 extern struct device *xpc_chan;
39629 -extern struct xpc_arch_operations xpc_arch_ops;
39630 +extern xpc_arch_operations_no_const xpc_arch_ops;
39631 extern int xpc_disengage_timelimit;
39632 extern int xpc_disengage_timedout;
39633 extern int xpc_activate_IRQ_rcvd;
39634 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39635 index d971817..33bdca5 100644
39636 --- a/drivers/misc/sgi-xp/xpc_main.c
39637 +++ b/drivers/misc/sgi-xp/xpc_main.c
39638 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39639 .notifier_call = xpc_system_die,
39640 };
39641
39642 -struct xpc_arch_operations xpc_arch_ops;
39643 +xpc_arch_operations_no_const xpc_arch_ops;
39644
39645 /*
39646 * Timer function to enforce the timelimit on the partition disengage.
39647 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39648
39649 if (((die_args->trapnr == X86_TRAP_MF) ||
39650 (die_args->trapnr == X86_TRAP_XF)) &&
39651 - !user_mode_vm(die_args->regs))
39652 + !user_mode(die_args->regs))
39653 xpc_die_deactivate();
39654
39655 break;
39656 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39657 index 49f04bc..65660c2 100644
39658 --- a/drivers/mmc/core/mmc_ops.c
39659 +++ b/drivers/mmc/core/mmc_ops.c
39660 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39661 void *data_buf;
39662 int is_on_stack;
39663
39664 - is_on_stack = object_is_on_stack(buf);
39665 + is_on_stack = object_starts_on_stack(buf);
39666 if (is_on_stack) {
39667 /*
39668 * dma onto stack is unsafe/nonportable, but callers to this
39669 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39670 index 53b8fd9..615b462 100644
39671 --- a/drivers/mmc/host/dw_mmc.h
39672 +++ b/drivers/mmc/host/dw_mmc.h
39673 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39674 int (*parse_dt)(struct dw_mci *host);
39675 int (*setup_bus)(struct dw_mci *host,
39676 struct device_node *slot_np, u8 bus_width);
39677 -};
39678 +} __do_const;
39679 #endif /* _DW_MMC_H_ */
39680 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39681 index 7363efe..681558e 100644
39682 --- a/drivers/mmc/host/sdhci-s3c.c
39683 +++ b/drivers/mmc/host/sdhci-s3c.c
39684 @@ -720,9 +720,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39685 * we can use overriding functions instead of default.
39686 */
39687 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39688 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39689 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39690 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39691 + pax_open_kernel();
39692 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39693 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39694 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39695 + pax_close_kernel();
39696 }
39697
39698 /* It supports additional host capabilities if needed */
39699 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39700 index a4eb8b5..8c0628f 100644
39701 --- a/drivers/mtd/devices/doc2000.c
39702 +++ b/drivers/mtd/devices/doc2000.c
39703 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39704
39705 /* The ECC will not be calculated correctly if less than 512 is written */
39706 /* DBB-
39707 - if (len != 0x200 && eccbuf)
39708 + if (len != 0x200)
39709 printk(KERN_WARNING
39710 "ECC needs a full sector write (adr: %lx size %lx)\n",
39711 (long) to, (long) len);
39712 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39713 index 0c8bb6b..6f35deb 100644
39714 --- a/drivers/mtd/nand/denali.c
39715 +++ b/drivers/mtd/nand/denali.c
39716 @@ -24,6 +24,7 @@
39717 #include <linux/slab.h>
39718 #include <linux/mtd/mtd.h>
39719 #include <linux/module.h>
39720 +#include <linux/slab.h>
39721
39722 #include "denali.h"
39723
39724 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39725 index 51b9d6a..52af9a7 100644
39726 --- a/drivers/mtd/nftlmount.c
39727 +++ b/drivers/mtd/nftlmount.c
39728 @@ -24,6 +24,7 @@
39729 #include <asm/errno.h>
39730 #include <linux/delay.h>
39731 #include <linux/slab.h>
39732 +#include <linux/sched.h>
39733 #include <linux/mtd/mtd.h>
39734 #include <linux/mtd/nand.h>
39735 #include <linux/mtd/nftl.h>
39736 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39737 index 8dd6ba5..419cc1d 100644
39738 --- a/drivers/mtd/sm_ftl.c
39739 +++ b/drivers/mtd/sm_ftl.c
39740 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39741 #define SM_CIS_VENDOR_OFFSET 0x59
39742 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39743 {
39744 - struct attribute_group *attr_group;
39745 + attribute_group_no_const *attr_group;
39746 struct attribute **attributes;
39747 struct sm_sysfs_attribute *vendor_attribute;
39748
39749 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39750 index dbbea0e..3f4a0b1 100644
39751 --- a/drivers/net/bonding/bond_main.c
39752 +++ b/drivers/net/bonding/bond_main.c
39753 @@ -4822,7 +4822,7 @@ static unsigned int bond_get_num_tx_queues(void)
39754 return tx_queues;
39755 }
39756
39757 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39758 +static struct rtnl_link_ops bond_link_ops = {
39759 .kind = "bond",
39760 .priv_size = sizeof(struct bonding),
39761 .setup = bond_setup,
39762 @@ -4947,8 +4947,8 @@ static void __exit bonding_exit(void)
39763
39764 bond_destroy_debugfs();
39765
39766 - rtnl_link_unregister(&bond_link_ops);
39767 unregister_pernet_subsys(&bond_net_ops);
39768 + rtnl_link_unregister(&bond_link_ops);
39769
39770 #ifdef CONFIG_NET_POLL_CONTROLLER
39771 /*
39772 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39773 index e1d2643..7f4133b 100644
39774 --- a/drivers/net/ethernet/8390/ax88796.c
39775 +++ b/drivers/net/ethernet/8390/ax88796.c
39776 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39777 if (ax->plat->reg_offsets)
39778 ei_local->reg_offset = ax->plat->reg_offsets;
39779 else {
39780 + resource_size_t _mem_size = mem_size;
39781 + do_div(_mem_size, 0x18);
39782 ei_local->reg_offset = ax->reg_offsets;
39783 for (ret = 0; ret < 0x18; ret++)
39784 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39785 + ax->reg_offsets[ret] = _mem_size * ret;
39786 }
39787
39788 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39789 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39790 index aee7671..3ca2651 100644
39791 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39792 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39793 @@ -1093,7 +1093,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39794 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39795 {
39796 /* RX_MODE controlling object */
39797 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39798 + bnx2x_init_rx_mode_obj(bp);
39799
39800 /* multicast configuration controlling object */
39801 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39802 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39803 index 7306416..5fb7fb5 100644
39804 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39805 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39806 @@ -2381,15 +2381,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39807 return rc;
39808 }
39809
39810 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39811 - struct bnx2x_rx_mode_obj *o)
39812 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39813 {
39814 if (CHIP_IS_E1x(bp)) {
39815 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39816 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39817 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39818 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39819 } else {
39820 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39821 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39822 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39823 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39824 }
39825 }
39826
39827 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39828 index ff90760..08d8aed 100644
39829 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39830 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39831 @@ -1306,8 +1306,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39832
39833 /********************* RX MODE ****************/
39834
39835 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39836 - struct bnx2x_rx_mode_obj *o);
39837 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39838
39839 /**
39840 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39841 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39842 index 25309bf..fcfd54c 100644
39843 --- a/drivers/net/ethernet/broadcom/tg3.h
39844 +++ b/drivers/net/ethernet/broadcom/tg3.h
39845 @@ -147,6 +147,7 @@
39846 #define CHIPREV_ID_5750_A0 0x4000
39847 #define CHIPREV_ID_5750_A1 0x4001
39848 #define CHIPREV_ID_5750_A3 0x4003
39849 +#define CHIPREV_ID_5750_C1 0x4201
39850 #define CHIPREV_ID_5750_C2 0x4202
39851 #define CHIPREV_ID_5752_A0_HW 0x5000
39852 #define CHIPREV_ID_5752_A0 0x6000
39853 diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
39854 index 6e8bc9d..94d957d 100644
39855 --- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
39856 +++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
39857 @@ -244,7 +244,7 @@ bnad_debugfs_lseek(struct file *file, loff_t offset, int orig)
39858 file->f_pos += offset;
39859 break;
39860 case 2:
39861 - file->f_pos = debug->buffer_len - offset;
39862 + file->f_pos = debug->buffer_len + offset;
39863 break;
39864 default:
39865 return -EINVAL;
39866 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39867 index 8cffcdf..aadf043 100644
39868 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39869 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39870 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39871 */
39872 struct l2t_skb_cb {
39873 arp_failure_handler_func arp_failure_handler;
39874 -};
39875 +} __no_const;
39876
39877 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39878
39879 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39880 index 4c83003..2a2a5b9 100644
39881 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39882 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39883 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39884 for (i=0; i<ETH_ALEN; i++) {
39885 tmp.addr[i] = dev->dev_addr[i];
39886 }
39887 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39888 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39889 break;
39890
39891 case DE4X5_SET_HWADDR: /* Set the hardware address */
39892 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39893 spin_lock_irqsave(&lp->lock, flags);
39894 memcpy(&statbuf, &lp->pktStats, ioc->len);
39895 spin_unlock_irqrestore(&lp->lock, flags);
39896 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39897 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39898 return -EFAULT;
39899 break;
39900 }
39901 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39902 index 2886c9b..db71673 100644
39903 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39904 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39905 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39906
39907 if (wrapped)
39908 newacc += 65536;
39909 - ACCESS_ONCE(*acc) = newacc;
39910 + ACCESS_ONCE_RW(*acc) = newacc;
39911 }
39912
39913 void be_parse_stats(struct be_adapter *adapter)
39914 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39915 index 7c361d1..57e3ff1 100644
39916 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39917 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39918 @@ -31,6 +31,8 @@
39919 #include <linux/netdevice.h>
39920 #include <linux/phy.h>
39921 #include <linux/platform_device.h>
39922 +#include <linux/interrupt.h>
39923 +#include <linux/irqreturn.h>
39924 #include <net/ip.h>
39925
39926 #include "ftgmac100.h"
39927 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39928 index b5ea8fb..bd25e9a 100644
39929 --- a/drivers/net/ethernet/faraday/ftmac100.c
39930 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39931 @@ -31,6 +31,8 @@
39932 #include <linux/module.h>
39933 #include <linux/netdevice.h>
39934 #include <linux/platform_device.h>
39935 +#include <linux/interrupt.h>
39936 +#include <linux/irqreturn.h>
39937
39938 #include "ftmac100.h"
39939
39940 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39941 index 331987d..3be1135 100644
39942 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39943 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39944 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39945 }
39946
39947 /* update the base incval used to calculate frequency adjustment */
39948 - ACCESS_ONCE(adapter->base_incval) = incval;
39949 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39950 smp_mb();
39951
39952 /* need lock to prevent incorrect read while modifying cyclecounter */
39953 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39954 index fbe5363..266b4e3 100644
39955 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39956 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39957 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39958 struct __vxge_hw_fifo *fifo;
39959 struct vxge_hw_fifo_config *config;
39960 u32 txdl_size, txdl_per_memblock;
39961 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39962 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39963 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39964 + };
39965 +
39966 struct __vxge_hw_virtualpath *vpath;
39967
39968 if ((vp == NULL) || (attr == NULL)) {
39969 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39970 goto exit;
39971 }
39972
39973 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39974 -
39975 fifo->mempool =
39976 __vxge_hw_mempool_create(vpath->hldev,
39977 fifo->config->memblock_size,
39978 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39979 index 5c033f2..7bbb0d8 100644
39980 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39981 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39982 @@ -1894,7 +1894,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
39983 op_mode = QLCRDX(ahw, QLC_83XX_DRV_OP_MODE);
39984
39985 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
39986 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39987 + pax_open_kernel();
39988 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39989 + pax_close_kernel();
39990 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39991 } else {
39992 return -EIO;
39993 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39994 index b0c3de9..fc5857e 100644
39995 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39996 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39997 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
39998 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
39999 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
40000 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40001 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40002 + pax_open_kernel();
40003 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40004 + pax_close_kernel();
40005 } else if (priv_level == QLCNIC_PRIV_FUNC) {
40006 ahw->op_mode = QLCNIC_PRIV_FUNC;
40007 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
40008 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40009 + pax_open_kernel();
40010 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40011 + pax_close_kernel();
40012 } else if (priv_level == QLCNIC_MGMT_FUNC) {
40013 ahw->op_mode = QLCNIC_MGMT_FUNC;
40014 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40015 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40016 + pax_open_kernel();
40017 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40018 + pax_close_kernel();
40019 } else {
40020 return -EIO;
40021 }
40022 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40023 index 54fd2ef..33c8a4f 100644
40024 --- a/drivers/net/ethernet/realtek/r8169.c
40025 +++ b/drivers/net/ethernet/realtek/r8169.c
40026 @@ -740,22 +740,22 @@ struct rtl8169_private {
40027 struct mdio_ops {
40028 void (*write)(struct rtl8169_private *, int, int);
40029 int (*read)(struct rtl8169_private *, int);
40030 - } mdio_ops;
40031 + } __no_const mdio_ops;
40032
40033 struct pll_power_ops {
40034 void (*down)(struct rtl8169_private *);
40035 void (*up)(struct rtl8169_private *);
40036 - } pll_power_ops;
40037 + } __no_const pll_power_ops;
40038
40039 struct jumbo_ops {
40040 void (*enable)(struct rtl8169_private *);
40041 void (*disable)(struct rtl8169_private *);
40042 - } jumbo_ops;
40043 + } __no_const jumbo_ops;
40044
40045 struct csi_ops {
40046 void (*write)(struct rtl8169_private *, int, int);
40047 u32 (*read)(struct rtl8169_private *, int);
40048 - } csi_ops;
40049 + } __no_const csi_ops;
40050
40051 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40052 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40053 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40054 index 3f93624..cf01144 100644
40055 --- a/drivers/net/ethernet/sfc/ptp.c
40056 +++ b/drivers/net/ethernet/sfc/ptp.c
40057 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40058 (u32)((u64)ptp->start.dma_addr >> 32));
40059
40060 /* Clear flag that signals MC ready */
40061 - ACCESS_ONCE(*start) = 0;
40062 + ACCESS_ONCE_RW(*start) = 0;
40063 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40064 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40065
40066 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40067 index 50617c5..b13724c 100644
40068 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40069 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40070 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40071
40072 writel(value, ioaddr + MMC_CNTRL);
40073
40074 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40075 - MMC_CNTRL, value);
40076 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40077 +// MMC_CNTRL, value);
40078 }
40079
40080 /* To mask all all interrupts.*/
40081 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40082 index e6fe0d8..2b7d752 100644
40083 --- a/drivers/net/hyperv/hyperv_net.h
40084 +++ b/drivers/net/hyperv/hyperv_net.h
40085 @@ -101,7 +101,7 @@ struct rndis_device {
40086
40087 enum rndis_device_state state;
40088 bool link_state;
40089 - atomic_t new_req_id;
40090 + atomic_unchecked_t new_req_id;
40091
40092 spinlock_t request_lock;
40093 struct list_head req_list;
40094 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40095 index 0775f0a..d4fb316 100644
40096 --- a/drivers/net/hyperv/rndis_filter.c
40097 +++ b/drivers/net/hyperv/rndis_filter.c
40098 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40099 * template
40100 */
40101 set = &rndis_msg->msg.set_req;
40102 - set->req_id = atomic_inc_return(&dev->new_req_id);
40103 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40104
40105 /* Add to the request list */
40106 spin_lock_irqsave(&dev->request_lock, flags);
40107 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40108
40109 /* Setup the rndis set */
40110 halt = &request->request_msg.msg.halt_req;
40111 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40112 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40113
40114 /* Ignore return since this msg is optional. */
40115 rndis_filter_send_request(dev, request);
40116 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40117 index 8f1c256..a2991d1 100644
40118 --- a/drivers/net/ieee802154/fakehard.c
40119 +++ b/drivers/net/ieee802154/fakehard.c
40120 @@ -385,7 +385,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40121 phy->transmit_power = 0xbf;
40122
40123 dev->netdev_ops = &fake_ops;
40124 - dev->ml_priv = &fake_mlme;
40125 + dev->ml_priv = (void *)&fake_mlme;
40126
40127 priv = netdev_priv(dev);
40128 priv->phy = phy;
40129 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40130 index 011062e..ada88e9 100644
40131 --- a/drivers/net/macvlan.c
40132 +++ b/drivers/net/macvlan.c
40133 @@ -892,13 +892,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40134 int macvlan_link_register(struct rtnl_link_ops *ops)
40135 {
40136 /* common fields */
40137 - ops->priv_size = sizeof(struct macvlan_dev);
40138 - ops->validate = macvlan_validate;
40139 - ops->maxtype = IFLA_MACVLAN_MAX;
40140 - ops->policy = macvlan_policy;
40141 - ops->changelink = macvlan_changelink;
40142 - ops->get_size = macvlan_get_size;
40143 - ops->fill_info = macvlan_fill_info;
40144 + pax_open_kernel();
40145 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40146 + *(void **)&ops->validate = macvlan_validate;
40147 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40148 + *(const void **)&ops->policy = macvlan_policy;
40149 + *(void **)&ops->changelink = macvlan_changelink;
40150 + *(void **)&ops->get_size = macvlan_get_size;
40151 + *(void **)&ops->fill_info = macvlan_fill_info;
40152 + pax_close_kernel();
40153
40154 return rtnl_link_register(ops);
40155 };
40156 @@ -954,7 +956,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40157 return NOTIFY_DONE;
40158 }
40159
40160 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40161 +static struct notifier_block macvlan_notifier_block = {
40162 .notifier_call = macvlan_device_event,
40163 };
40164
40165 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40166 index acf6450..8f771b7 100644
40167 --- a/drivers/net/macvtap.c
40168 +++ b/drivers/net/macvtap.c
40169 @@ -525,8 +525,10 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
40170 return -EMSGSIZE;
40171 num_pages = get_user_pages_fast(base, size, 0, &page[i]);
40172 if (num_pages != size) {
40173 - for (i = 0; i < num_pages; i++)
40174 - put_page(page[i]);
40175 + int j;
40176 +
40177 + for (j = 0; j < num_pages; j++)
40178 + put_page(page[i + j]);
40179 return -EFAULT;
40180 }
40181 truesize = size * PAGE_SIZE;
40182 @@ -1099,7 +1101,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40183 return NOTIFY_DONE;
40184 }
40185
40186 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40187 +static struct notifier_block macvtap_notifier_block = {
40188 .notifier_call = macvtap_device_event,
40189 };
40190
40191 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40192 index daec9b0..6428fcb 100644
40193 --- a/drivers/net/phy/mdio-bitbang.c
40194 +++ b/drivers/net/phy/mdio-bitbang.c
40195 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40196 struct mdiobb_ctrl *ctrl = bus->priv;
40197
40198 module_put(ctrl->ops->owner);
40199 + mdiobus_unregister(bus);
40200 mdiobus_free(bus);
40201 }
40202 EXPORT_SYMBOL(free_mdio_bitbang);
40203 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40204 index 72ff14b..11d442d 100644
40205 --- a/drivers/net/ppp/ppp_generic.c
40206 +++ b/drivers/net/ppp/ppp_generic.c
40207 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40208 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40209 struct ppp_stats stats;
40210 struct ppp_comp_stats cstats;
40211 - char *vers;
40212
40213 switch (cmd) {
40214 case SIOCGPPPSTATS:
40215 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40216 break;
40217
40218 case SIOCGPPPVER:
40219 - vers = PPP_VERSION;
40220 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40221 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40222 break;
40223 err = 0;
40224 break;
40225 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
40226 index 1252d9c..80e660b 100644
40227 --- a/drivers/net/slip/slhc.c
40228 +++ b/drivers/net/slip/slhc.c
40229 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
40230 register struct tcphdr *thp;
40231 register struct iphdr *ip;
40232 register struct cstate *cs;
40233 - int len, hdrlen;
40234 + long len, hdrlen;
40235 unsigned char *cp = icp;
40236
40237 /* We've got a compressed packet; read the change byte */
40238 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40239 index 0017b67..ab8f595 100644
40240 --- a/drivers/net/team/team.c
40241 +++ b/drivers/net/team/team.c
40242 @@ -2668,7 +2668,7 @@ static int team_device_event(struct notifier_block *unused,
40243 return NOTIFY_DONE;
40244 }
40245
40246 -static struct notifier_block team_notifier_block __read_mostly = {
40247 +static struct notifier_block team_notifier_block = {
40248 .notifier_call = team_device_event,
40249 };
40250
40251 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40252 index 8ad822e..eb895f1 100644
40253 --- a/drivers/net/tun.c
40254 +++ b/drivers/net/tun.c
40255 @@ -1013,8 +1013,10 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
40256 return -EMSGSIZE;
40257 num_pages = get_user_pages_fast(base, size, 0, &page[i]);
40258 if (num_pages != size) {
40259 - for (i = 0; i < num_pages; i++)
40260 - put_page(page[i]);
40261 + int j;
40262 +
40263 + for (j = 0; j < num_pages; j++)
40264 + put_page(page[i + j]);
40265 return -EFAULT;
40266 }
40267 truesize = size * PAGE_SIZE;
40268 @@ -1859,7 +1861,7 @@ unlock:
40269 }
40270
40271 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40272 - unsigned long arg, int ifreq_len)
40273 + unsigned long arg, size_t ifreq_len)
40274 {
40275 struct tun_file *tfile = file->private_data;
40276 struct tun_struct *tun;
40277 @@ -1871,6 +1873,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40278 int vnet_hdr_sz;
40279 int ret;
40280
40281 + if (ifreq_len > sizeof ifr)
40282 + return -EFAULT;
40283 +
40284 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40285 if (copy_from_user(&ifr, argp, ifreq_len))
40286 return -EFAULT;
40287 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40288 index e2dd324..be92fcf 100644
40289 --- a/drivers/net/usb/hso.c
40290 +++ b/drivers/net/usb/hso.c
40291 @@ -71,7 +71,7 @@
40292 #include <asm/byteorder.h>
40293 #include <linux/serial_core.h>
40294 #include <linux/serial.h>
40295 -
40296 +#include <asm/local.h>
40297
40298 #define MOD_AUTHOR "Option Wireless"
40299 #define MOD_DESCRIPTION "USB High Speed Option driver"
40300 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40301 struct urb *urb;
40302
40303 urb = serial->rx_urb[0];
40304 - if (serial->port.count > 0) {
40305 + if (atomic_read(&serial->port.count) > 0) {
40306 count = put_rxbuf_data(urb, serial);
40307 if (count == -1)
40308 return;
40309 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40310 DUMP1(urb->transfer_buffer, urb->actual_length);
40311
40312 /* Anyone listening? */
40313 - if (serial->port.count == 0)
40314 + if (atomic_read(&serial->port.count) == 0)
40315 return;
40316
40317 if (status == 0) {
40318 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40319 tty_port_tty_set(&serial->port, tty);
40320
40321 /* check for port already opened, if not set the termios */
40322 - serial->port.count++;
40323 - if (serial->port.count == 1) {
40324 + if (atomic_inc_return(&serial->port.count) == 1) {
40325 serial->rx_state = RX_IDLE;
40326 /* Force default termio settings */
40327 _hso_serial_set_termios(tty, NULL);
40328 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40329 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40330 if (result) {
40331 hso_stop_serial_device(serial->parent);
40332 - serial->port.count--;
40333 + atomic_dec(&serial->port.count);
40334 kref_put(&serial->parent->ref, hso_serial_ref_free);
40335 }
40336 } else {
40337 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40338
40339 /* reset the rts and dtr */
40340 /* do the actual close */
40341 - serial->port.count--;
40342 + atomic_dec(&serial->port.count);
40343
40344 - if (serial->port.count <= 0) {
40345 - serial->port.count = 0;
40346 + if (atomic_read(&serial->port.count) <= 0) {
40347 + atomic_set(&serial->port.count, 0);
40348 tty_port_tty_set(&serial->port, NULL);
40349 if (!usb_gone)
40350 hso_stop_serial_device(serial->parent);
40351 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40352
40353 /* the actual setup */
40354 spin_lock_irqsave(&serial->serial_lock, flags);
40355 - if (serial->port.count)
40356 + if (atomic_read(&serial->port.count))
40357 _hso_serial_set_termios(tty, old);
40358 else
40359 tty->termios = *old;
40360 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40361 D1("Pending read interrupt on port %d\n", i);
40362 spin_lock(&serial->serial_lock);
40363 if (serial->rx_state == RX_IDLE &&
40364 - serial->port.count > 0) {
40365 + atomic_read(&serial->port.count) > 0) {
40366 /* Setup and send a ctrl req read on
40367 * port i */
40368 if (!serial->rx_urb_filled[0]) {
40369 @@ -3066,7 +3065,7 @@ static int hso_resume(struct usb_interface *iface)
40370 /* Start all serial ports */
40371 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40372 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40373 - if (dev2ser(serial_table[i])->port.count) {
40374 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40375 result =
40376 hso_start_serial_device(serial_table[i], GFP_NOIO);
40377 hso_kick_transmit(dev2ser(serial_table[i]));
40378 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40379 index a4fe5f1..6c9e77f 100644
40380 --- a/drivers/net/vxlan.c
40381 +++ b/drivers/net/vxlan.c
40382 @@ -1454,7 +1454,7 @@ nla_put_failure:
40383 return -EMSGSIZE;
40384 }
40385
40386 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40387 +static struct rtnl_link_ops vxlan_link_ops = {
40388 .kind = "vxlan",
40389 .maxtype = IFLA_VXLAN_MAX,
40390 .policy = vxlan_policy,
40391 diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
40392 index 147614e..6a8a382 100644
40393 --- a/drivers/net/wan/dlci.c
40394 +++ b/drivers/net/wan/dlci.c
40395 @@ -384,21 +384,37 @@ static int dlci_del(struct dlci_add *dlci)
40396 struct frad_local *flp;
40397 struct net_device *master, *slave;
40398 int err;
40399 + bool found = false;
40400 +
40401 + rtnl_lock();
40402
40403 /* validate slave device */
40404 master = __dev_get_by_name(&init_net, dlci->devname);
40405 - if (!master)
40406 - return -ENODEV;
40407 + if (!master) {
40408 + err = -ENODEV;
40409 + goto out;
40410 + }
40411 +
40412 + list_for_each_entry(dlp, &dlci_devs, list) {
40413 + if (dlp->master == master) {
40414 + found = true;
40415 + break;
40416 + }
40417 + }
40418 + if (!found) {
40419 + err = -ENODEV;
40420 + goto out;
40421 + }
40422
40423 if (netif_running(master)) {
40424 - return -EBUSY;
40425 + err = -EBUSY;
40426 + goto out;
40427 }
40428
40429 dlp = netdev_priv(master);
40430 slave = dlp->slave;
40431 flp = netdev_priv(slave);
40432
40433 - rtnl_lock();
40434 err = (*flp->deassoc)(slave, master);
40435 if (!err) {
40436 list_del(&dlp->list);
40437 @@ -407,8 +423,8 @@ static int dlci_del(struct dlci_add *dlci)
40438
40439 dev_put(slave);
40440 }
40441 +out:
40442 rtnl_unlock();
40443 -
40444 return err;
40445 }
40446
40447 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40448 index 5ac5f7a..5f82012 100644
40449 --- a/drivers/net/wireless/at76c50x-usb.c
40450 +++ b/drivers/net/wireless/at76c50x-usb.c
40451 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40452 }
40453
40454 /* Convert timeout from the DFU status to jiffies */
40455 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40456 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40457 {
40458 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40459 | (s->poll_timeout[1] << 8)
40460 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40461 index 8d78253..bebbb68 100644
40462 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40463 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40464 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40465 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40466 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40467
40468 - ACCESS_ONCE(ads->ds_link) = i->link;
40469 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40470 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40471 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40472
40473 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40474 ctl6 = SM(i->keytype, AR_EncrType);
40475 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40476
40477 if ((i->is_first || i->is_last) &&
40478 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40479 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40480 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40481 | set11nTries(i->rates, 1)
40482 | set11nTries(i->rates, 2)
40483 | set11nTries(i->rates, 3)
40484 | (i->dur_update ? AR_DurUpdateEna : 0)
40485 | SM(0, AR_BurstDur);
40486
40487 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40488 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40489 | set11nRate(i->rates, 1)
40490 | set11nRate(i->rates, 2)
40491 | set11nRate(i->rates, 3);
40492 } else {
40493 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40494 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40495 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40496 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40497 }
40498
40499 if (!i->is_first) {
40500 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40501 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40502 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40503 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40504 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40505 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40506 return;
40507 }
40508
40509 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40510 break;
40511 }
40512
40513 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40514 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40515 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40516 | SM(i->txpower, AR_XmitPower)
40517 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40518 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40519 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40520 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40521
40522 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40523 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40524 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40525 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40526
40527 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40528 return;
40529
40530 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40531 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40532 | set11nPktDurRTSCTS(i->rates, 1);
40533
40534 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40535 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40536 | set11nPktDurRTSCTS(i->rates, 3);
40537
40538 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40539 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40540 | set11nRateFlags(i->rates, 1)
40541 | set11nRateFlags(i->rates, 2)
40542 | set11nRateFlags(i->rates, 3)
40543 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40544 index 301bf72..3f5654f 100644
40545 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40546 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40547 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40548 (i->qcu << AR_TxQcuNum_S) | desc_len;
40549
40550 checksum += val;
40551 - ACCESS_ONCE(ads->info) = val;
40552 + ACCESS_ONCE_RW(ads->info) = val;
40553
40554 checksum += i->link;
40555 - ACCESS_ONCE(ads->link) = i->link;
40556 + ACCESS_ONCE_RW(ads->link) = i->link;
40557
40558 checksum += i->buf_addr[0];
40559 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40560 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40561 checksum += i->buf_addr[1];
40562 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40563 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40564 checksum += i->buf_addr[2];
40565 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40566 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40567 checksum += i->buf_addr[3];
40568 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40569 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40570
40571 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40572 - ACCESS_ONCE(ads->ctl3) = val;
40573 + ACCESS_ONCE_RW(ads->ctl3) = val;
40574 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40575 - ACCESS_ONCE(ads->ctl5) = val;
40576 + ACCESS_ONCE_RW(ads->ctl5) = val;
40577 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40578 - ACCESS_ONCE(ads->ctl7) = val;
40579 + ACCESS_ONCE_RW(ads->ctl7) = val;
40580 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40581 - ACCESS_ONCE(ads->ctl9) = val;
40582 + ACCESS_ONCE_RW(ads->ctl9) = val;
40583
40584 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40585 - ACCESS_ONCE(ads->ctl10) = checksum;
40586 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40587
40588 if (i->is_first || i->is_last) {
40589 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40590 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40591 | set11nTries(i->rates, 1)
40592 | set11nTries(i->rates, 2)
40593 | set11nTries(i->rates, 3)
40594 | (i->dur_update ? AR_DurUpdateEna : 0)
40595 | SM(0, AR_BurstDur);
40596
40597 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40598 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40599 | set11nRate(i->rates, 1)
40600 | set11nRate(i->rates, 2)
40601 | set11nRate(i->rates, 3);
40602 } else {
40603 - ACCESS_ONCE(ads->ctl13) = 0;
40604 - ACCESS_ONCE(ads->ctl14) = 0;
40605 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40606 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40607 }
40608
40609 ads->ctl20 = 0;
40610 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40611
40612 ctl17 = SM(i->keytype, AR_EncrType);
40613 if (!i->is_first) {
40614 - ACCESS_ONCE(ads->ctl11) = 0;
40615 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40616 - ACCESS_ONCE(ads->ctl15) = 0;
40617 - ACCESS_ONCE(ads->ctl16) = 0;
40618 - ACCESS_ONCE(ads->ctl17) = ctl17;
40619 - ACCESS_ONCE(ads->ctl18) = 0;
40620 - ACCESS_ONCE(ads->ctl19) = 0;
40621 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40622 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40623 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40624 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40625 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40626 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40627 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40628 return;
40629 }
40630
40631 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40632 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40633 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40634 | SM(i->txpower, AR_XmitPower)
40635 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40636 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40637 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40638 ctl12 |= SM(val, AR_PAPRDChainMask);
40639
40640 - ACCESS_ONCE(ads->ctl12) = ctl12;
40641 - ACCESS_ONCE(ads->ctl17) = ctl17;
40642 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40643 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40644
40645 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40646 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40647 | set11nPktDurRTSCTS(i->rates, 1);
40648
40649 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40650 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40651 | set11nPktDurRTSCTS(i->rates, 3);
40652
40653 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40654 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40655 | set11nRateFlags(i->rates, 1)
40656 | set11nRateFlags(i->rates, 2)
40657 | set11nRateFlags(i->rates, 3)
40658 | SM(i->rtscts_rate, AR_RTSCTSRate);
40659
40660 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40661 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40662 }
40663
40664 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40665 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40666 index 784e81c..349e01e 100644
40667 --- a/drivers/net/wireless/ath/ath9k/hw.h
40668 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40669 @@ -653,7 +653,7 @@ struct ath_hw_private_ops {
40670
40671 /* ANI */
40672 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40673 -};
40674 +} __no_const;
40675
40676 /**
40677 * struct ath_spec_scan - parameters for Atheros spectral scan
40678 @@ -722,7 +722,7 @@ struct ath_hw_ops {
40679 struct ath_spec_scan *param);
40680 void (*spectral_scan_trigger)(struct ath_hw *ah);
40681 void (*spectral_scan_wait)(struct ath_hw *ah);
40682 -};
40683 +} __no_const;
40684
40685 struct ath_nf_limits {
40686 s16 max;
40687 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40688 index c353b5f..62aaca2 100644
40689 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40690 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40691 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40692 */
40693 if (il3945_mod_params.disable_hw_scan) {
40694 D_INFO("Disabling hw_scan\n");
40695 - il3945_mac_ops.hw_scan = NULL;
40696 + pax_open_kernel();
40697 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40698 + pax_close_kernel();
40699 }
40700
40701 D_INFO("*** LOAD DRIVER ***\n");
40702 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40703 index 81d4071..f2071ea 100644
40704 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40705 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40706 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40707 {
40708 struct iwl_priv *priv = file->private_data;
40709 char buf[64];
40710 - int buf_size;
40711 + size_t buf_size;
40712 u32 offset, len;
40713
40714 memset(buf, 0, sizeof(buf));
40715 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40716 struct iwl_priv *priv = file->private_data;
40717
40718 char buf[8];
40719 - int buf_size;
40720 + size_t buf_size;
40721 u32 reset_flag;
40722
40723 memset(buf, 0, sizeof(buf));
40724 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40725 {
40726 struct iwl_priv *priv = file->private_data;
40727 char buf[8];
40728 - int buf_size;
40729 + size_t buf_size;
40730 int ht40;
40731
40732 memset(buf, 0, sizeof(buf));
40733 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40734 {
40735 struct iwl_priv *priv = file->private_data;
40736 char buf[8];
40737 - int buf_size;
40738 + size_t buf_size;
40739 int value;
40740
40741 memset(buf, 0, sizeof(buf));
40742 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40743 {
40744 struct iwl_priv *priv = file->private_data;
40745 char buf[8];
40746 - int buf_size;
40747 + size_t buf_size;
40748 int clear;
40749
40750 memset(buf, 0, sizeof(buf));
40751 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40752 {
40753 struct iwl_priv *priv = file->private_data;
40754 char buf[8];
40755 - int buf_size;
40756 + size_t buf_size;
40757 int trace;
40758
40759 memset(buf, 0, sizeof(buf));
40760 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40761 {
40762 struct iwl_priv *priv = file->private_data;
40763 char buf[8];
40764 - int buf_size;
40765 + size_t buf_size;
40766 int missed;
40767
40768 memset(buf, 0, sizeof(buf));
40769 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40770
40771 struct iwl_priv *priv = file->private_data;
40772 char buf[8];
40773 - int buf_size;
40774 + size_t buf_size;
40775 int plcp;
40776
40777 memset(buf, 0, sizeof(buf));
40778 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40779
40780 struct iwl_priv *priv = file->private_data;
40781 char buf[8];
40782 - int buf_size;
40783 + size_t buf_size;
40784 int flush;
40785
40786 memset(buf, 0, sizeof(buf));
40787 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40788
40789 struct iwl_priv *priv = file->private_data;
40790 char buf[8];
40791 - int buf_size;
40792 + size_t buf_size;
40793 int rts;
40794
40795 if (!priv->cfg->ht_params)
40796 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40797 {
40798 struct iwl_priv *priv = file->private_data;
40799 char buf[8];
40800 - int buf_size;
40801 + size_t buf_size;
40802
40803 memset(buf, 0, sizeof(buf));
40804 buf_size = min(count, sizeof(buf) - 1);
40805 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40806 struct iwl_priv *priv = file->private_data;
40807 u32 event_log_flag;
40808 char buf[8];
40809 - int buf_size;
40810 + size_t buf_size;
40811
40812 /* check that the interface is up */
40813 if (!iwl_is_ready(priv))
40814 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40815 struct iwl_priv *priv = file->private_data;
40816 char buf[8];
40817 u32 calib_disabled;
40818 - int buf_size;
40819 + size_t buf_size;
40820
40821 memset(buf, 0, sizeof(buf));
40822 buf_size = min(count, sizeof(buf) - 1);
40823 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40824 index 12c4f31..484d948 100644
40825 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40826 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40827 @@ -1328,7 +1328,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40828 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40829
40830 char buf[8];
40831 - int buf_size;
40832 + size_t buf_size;
40833 u32 reset_flag;
40834
40835 memset(buf, 0, sizeof(buf));
40836 @@ -1349,7 +1349,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40837 {
40838 struct iwl_trans *trans = file->private_data;
40839 char buf[8];
40840 - int buf_size;
40841 + size_t buf_size;
40842 int csr;
40843
40844 memset(buf, 0, sizeof(buf));
40845 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40846 index 2b49f48..14fc244 100644
40847 --- a/drivers/net/wireless/mac80211_hwsim.c
40848 +++ b/drivers/net/wireless/mac80211_hwsim.c
40849 @@ -2143,25 +2143,19 @@ static int __init init_mac80211_hwsim(void)
40850
40851 if (channels > 1) {
40852 hwsim_if_comb.num_different_channels = channels;
40853 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40854 - mac80211_hwsim_ops.cancel_hw_scan =
40855 - mac80211_hwsim_cancel_hw_scan;
40856 - mac80211_hwsim_ops.sw_scan_start = NULL;
40857 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40858 - mac80211_hwsim_ops.remain_on_channel =
40859 - mac80211_hwsim_roc;
40860 - mac80211_hwsim_ops.cancel_remain_on_channel =
40861 - mac80211_hwsim_croc;
40862 - mac80211_hwsim_ops.add_chanctx =
40863 - mac80211_hwsim_add_chanctx;
40864 - mac80211_hwsim_ops.remove_chanctx =
40865 - mac80211_hwsim_remove_chanctx;
40866 - mac80211_hwsim_ops.change_chanctx =
40867 - mac80211_hwsim_change_chanctx;
40868 - mac80211_hwsim_ops.assign_vif_chanctx =
40869 - mac80211_hwsim_assign_vif_chanctx;
40870 - mac80211_hwsim_ops.unassign_vif_chanctx =
40871 - mac80211_hwsim_unassign_vif_chanctx;
40872 + pax_open_kernel();
40873 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40874 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40875 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40876 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40877 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40878 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40879 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40880 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40881 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40882 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40883 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40884 + pax_close_kernel();
40885 }
40886
40887 spin_lock_init(&hwsim_radio_lock);
40888 diff --git a/drivers/net/wireless/mwifiex/debugfs.c b/drivers/net/wireless/mwifiex/debugfs.c
40889 index 753b568..a5f9875 100644
40890 --- a/drivers/net/wireless/mwifiex/debugfs.c
40891 +++ b/drivers/net/wireless/mwifiex/debugfs.c
40892 @@ -26,10 +26,17 @@
40893 static struct dentry *mwifiex_dfs_dir;
40894
40895 static char *bss_modes[] = {
40896 - "Unknown",
40897 - "Ad-hoc",
40898 - "Managed",
40899 - "Auto"
40900 + "UNSPECIFIED",
40901 + "ADHOC",
40902 + "STATION",
40903 + "AP",
40904 + "AP_VLAN",
40905 + "WDS",
40906 + "MONITOR",
40907 + "MESH_POINT",
40908 + "P2P_CLIENT",
40909 + "P2P_GO",
40910 + "P2P_DEVICE",
40911 };
40912
40913 /* size/addr for mwifiex_debug_info */
40914 @@ -200,7 +207,12 @@ mwifiex_info_read(struct file *file, char __user *ubuf,
40915 p += sprintf(p, "driver_version = %s", fmt);
40916 p += sprintf(p, "\nverext = %s", priv->version_str);
40917 p += sprintf(p, "\ninterface_name=\"%s\"\n", netdev->name);
40918 - p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]);
40919 +
40920 + if (info.bss_mode >= ARRAY_SIZE(bss_modes))
40921 + p += sprintf(p, "bss_mode=\"%d\"\n", info.bss_mode);
40922 + else
40923 + p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]);
40924 +
40925 p += sprintf(p, "media_state=\"%s\"\n",
40926 (!priv->media_connected ? "Disconnected" : "Connected"));
40927 p += sprintf(p, "mac_address=\"%pM\"\n", netdev->dev_addr);
40928 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40929 index 525fd75..6c9f791 100644
40930 --- a/drivers/net/wireless/rndis_wlan.c
40931 +++ b/drivers/net/wireless/rndis_wlan.c
40932 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40933
40934 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40935
40936 - if (rts_threshold < 0 || rts_threshold > 2347)
40937 + if (rts_threshold > 2347)
40938 rts_threshold = 2347;
40939
40940 tmp = cpu_to_le32(rts_threshold);
40941 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40942 index 086abb4..8279c30 100644
40943 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40944 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40945 @@ -396,7 +396,7 @@ struct rt2x00_intf {
40946 * for hardware which doesn't support hardware
40947 * sequence counting.
40948 */
40949 - atomic_t seqno;
40950 + atomic_unchecked_t seqno;
40951 };
40952
40953 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40954 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40955 index 4d91795..62fccff 100644
40956 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40957 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40958 @@ -251,9 +251,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40959 * sequence counter given by mac80211.
40960 */
40961 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40962 - seqno = atomic_add_return(0x10, &intf->seqno);
40963 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40964 else
40965 - seqno = atomic_read(&intf->seqno);
40966 + seqno = atomic_read_unchecked(&intf->seqno);
40967
40968 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40969 hdr->seq_ctrl |= cpu_to_le16(seqno);
40970 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40971 index e57ee48..541cf6c 100644
40972 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40973 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40974 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40975
40976 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40977
40978 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40979 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40980 + pax_open_kernel();
40981 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40982 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40983 + pax_close_kernel();
40984
40985 wl1251_info("using dedicated interrupt line");
40986 } else {
40987 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40988 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40989 + pax_open_kernel();
40990 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40991 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40992 + pax_close_kernel();
40993
40994 wl1251_info("using SDIO interrupt");
40995 }
40996 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40997 index 09694e3..24ccec7 100644
40998 --- a/drivers/net/wireless/ti/wl12xx/main.c
40999 +++ b/drivers/net/wireless/ti/wl12xx/main.c
41000 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41001 sizeof(wl->conf.mem));
41002
41003 /* read data preparation is only needed by wl127x */
41004 - wl->ops->prepare_read = wl127x_prepare_read;
41005 + pax_open_kernel();
41006 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41007 + pax_close_kernel();
41008
41009 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41010 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41011 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41012 sizeof(wl->conf.mem));
41013
41014 /* read data preparation is only needed by wl127x */
41015 - wl->ops->prepare_read = wl127x_prepare_read;
41016 + pax_open_kernel();
41017 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41018 + pax_close_kernel();
41019
41020 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41021 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41022 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41023 index da3ef1b..4790b95 100644
41024 --- a/drivers/net/wireless/ti/wl18xx/main.c
41025 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41026 @@ -1664,8 +1664,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41027 }
41028
41029 if (!checksum_param) {
41030 - wl18xx_ops.set_rx_csum = NULL;
41031 - wl18xx_ops.init_vif = NULL;
41032 + pax_open_kernel();
41033 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41034 + *(void **)&wl18xx_ops.init_vif = NULL;
41035 + pax_close_kernel();
41036 }
41037
41038 /* Enable 11a Band only if we have 5G antennas */
41039 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41040 index 7ef0b4a..ff65c28 100644
41041 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41042 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41043 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
41044 {
41045 struct zd_usb *usb = urb->context;
41046 struct zd_usb_interrupt *intr = &usb->intr;
41047 - int len;
41048 + unsigned int len;
41049 u16 int_num;
41050
41051 ZD_ASSERT(in_interrupt());
41052 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41053 index d93b2b6..ae50401 100644
41054 --- a/drivers/oprofile/buffer_sync.c
41055 +++ b/drivers/oprofile/buffer_sync.c
41056 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41057 if (cookie == NO_COOKIE)
41058 offset = pc;
41059 if (cookie == INVALID_COOKIE) {
41060 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41061 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41062 offset = pc;
41063 }
41064 if (cookie != last_cookie) {
41065 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41066 /* add userspace sample */
41067
41068 if (!mm) {
41069 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41070 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41071 return 0;
41072 }
41073
41074 cookie = lookup_dcookie(mm, s->eip, &offset);
41075
41076 if (cookie == INVALID_COOKIE) {
41077 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41078 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41079 return 0;
41080 }
41081
41082 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41083 /* ignore backtraces if failed to add a sample */
41084 if (state == sb_bt_start) {
41085 state = sb_bt_ignore;
41086 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41087 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41088 }
41089 }
41090 release_mm(mm);
41091 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41092 index c0cc4e7..44d4e54 100644
41093 --- a/drivers/oprofile/event_buffer.c
41094 +++ b/drivers/oprofile/event_buffer.c
41095 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41096 }
41097
41098 if (buffer_pos == buffer_size) {
41099 - atomic_inc(&oprofile_stats.event_lost_overflow);
41100 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41101 return;
41102 }
41103
41104 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41105 index ed2c3ec..deda85a 100644
41106 --- a/drivers/oprofile/oprof.c
41107 +++ b/drivers/oprofile/oprof.c
41108 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41109 if (oprofile_ops.switch_events())
41110 return;
41111
41112 - atomic_inc(&oprofile_stats.multiplex_counter);
41113 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41114 start_switch_worker();
41115 }
41116
41117 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41118 index 84a208d..d61b0a1 100644
41119 --- a/drivers/oprofile/oprofile_files.c
41120 +++ b/drivers/oprofile/oprofile_files.c
41121 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41122
41123 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41124
41125 -static ssize_t timeout_read(struct file *file, char __user *buf,
41126 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41127 size_t count, loff_t *offset)
41128 {
41129 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41130 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41131 index 917d28e..d62d981 100644
41132 --- a/drivers/oprofile/oprofile_stats.c
41133 +++ b/drivers/oprofile/oprofile_stats.c
41134 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41135 cpu_buf->sample_invalid_eip = 0;
41136 }
41137
41138 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41139 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41140 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41141 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41142 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41143 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41144 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41145 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41146 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41147 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41148 }
41149
41150
41151 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41152 index 38b6fc0..b5cbfce 100644
41153 --- a/drivers/oprofile/oprofile_stats.h
41154 +++ b/drivers/oprofile/oprofile_stats.h
41155 @@ -13,11 +13,11 @@
41156 #include <linux/atomic.h>
41157
41158 struct oprofile_stat_struct {
41159 - atomic_t sample_lost_no_mm;
41160 - atomic_t sample_lost_no_mapping;
41161 - atomic_t bt_lost_no_mapping;
41162 - atomic_t event_lost_overflow;
41163 - atomic_t multiplex_counter;
41164 + atomic_unchecked_t sample_lost_no_mm;
41165 + atomic_unchecked_t sample_lost_no_mapping;
41166 + atomic_unchecked_t bt_lost_no_mapping;
41167 + atomic_unchecked_t event_lost_overflow;
41168 + atomic_unchecked_t multiplex_counter;
41169 };
41170
41171 extern struct oprofile_stat_struct oprofile_stats;
41172 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41173 index 7c12d9c..558bf3bb 100644
41174 --- a/drivers/oprofile/oprofilefs.c
41175 +++ b/drivers/oprofile/oprofilefs.c
41176 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
41177
41178
41179 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41180 - char const *name, atomic_t *val)
41181 + char const *name, atomic_unchecked_t *val)
41182 {
41183 return __oprofilefs_create_file(sb, root, name,
41184 &atomic_ro_fops, 0444, val);
41185 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41186 index 93404f7..4a313d8 100644
41187 --- a/drivers/oprofile/timer_int.c
41188 +++ b/drivers/oprofile/timer_int.c
41189 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41190 return NOTIFY_OK;
41191 }
41192
41193 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41194 +static struct notifier_block oprofile_cpu_notifier = {
41195 .notifier_call = oprofile_cpu_notify,
41196 };
41197
41198 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41199 index 3f56bc0..707d642 100644
41200 --- a/drivers/parport/procfs.c
41201 +++ b/drivers/parport/procfs.c
41202 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41203
41204 *ppos += len;
41205
41206 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41207 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41208 }
41209
41210 #ifdef CONFIG_PARPORT_1284
41211 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41212
41213 *ppos += len;
41214
41215 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41216 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41217 }
41218 #endif /* IEEE1284.3 support. */
41219
41220 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41221 index c35e8ad..fc33beb 100644
41222 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41223 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41224 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41225 goto init_cleanup;
41226 }
41227
41228 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41229 + pax_open_kernel();
41230 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41231 + pax_close_kernel();
41232 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41233
41234 return retval;
41235 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41236 index a6a71c4..c91097b 100644
41237 --- a/drivers/pci/hotplug/cpcihp_generic.c
41238 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41239 @@ -73,7 +73,6 @@ static u16 port;
41240 static unsigned int enum_bit;
41241 static u8 enum_mask;
41242
41243 -static struct cpci_hp_controller_ops generic_hpc_ops;
41244 static struct cpci_hp_controller generic_hpc;
41245
41246 static int __init validate_parameters(void)
41247 @@ -139,6 +138,10 @@ static int query_enum(void)
41248 return ((value & enum_mask) == enum_mask);
41249 }
41250
41251 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41252 + .query_enum = query_enum,
41253 +};
41254 +
41255 static int __init cpcihp_generic_init(void)
41256 {
41257 int status;
41258 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41259 pci_dev_put(dev);
41260
41261 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41262 - generic_hpc_ops.query_enum = query_enum;
41263 generic_hpc.ops = &generic_hpc_ops;
41264
41265 status = cpci_hp_register_controller(&generic_hpc);
41266 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41267 index 449b4bb..257e2e8 100644
41268 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41269 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41270 @@ -59,7 +59,6 @@
41271 /* local variables */
41272 static bool debug;
41273 static bool poll;
41274 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41275 static struct cpci_hp_controller zt5550_hpc;
41276
41277 /* Primary cPCI bus bridge device */
41278 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41279 return 0;
41280 }
41281
41282 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41283 + .query_enum = zt5550_hc_query_enum,
41284 +};
41285 +
41286 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41287 {
41288 int status;
41289 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41290 dbg("returned from zt5550_hc_config");
41291
41292 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41293 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41294 zt5550_hpc.ops = &zt5550_hpc_ops;
41295 if(!poll) {
41296 zt5550_hpc.irq = hc_dev->irq;
41297 zt5550_hpc.irq_flags = IRQF_SHARED;
41298 zt5550_hpc.dev_id = hc_dev;
41299
41300 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41301 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41302 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41303 + pax_open_kernel();
41304 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41305 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41306 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41307 + pax_open_kernel();
41308 } else {
41309 info("using ENUM# polling mode");
41310 }
41311 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41312 index 76ba8a1..20ca857 100644
41313 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41314 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41315 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41316
41317 void compaq_nvram_init (void __iomem *rom_start)
41318 {
41319 +
41320 +#ifndef CONFIG_PAX_KERNEXEC
41321 if (rom_start) {
41322 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41323 }
41324 +#endif
41325 +
41326 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41327
41328 /* initialize our int15 lock */
41329 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41330 index 202f4a9..8ee47d0 100644
41331 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41332 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41333 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41334 return -EINVAL;
41335 }
41336
41337 - slot->ops->owner = owner;
41338 - slot->ops->mod_name = mod_name;
41339 + pax_open_kernel();
41340 + *(struct module **)&slot->ops->owner = owner;
41341 + *(const char **)&slot->ops->mod_name = mod_name;
41342 + pax_close_kernel();
41343
41344 mutex_lock(&pci_hp_mutex);
41345 /*
41346 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41347 index 7d72c5e..edce02c 100644
41348 --- a/drivers/pci/hotplug/pciehp_core.c
41349 +++ b/drivers/pci/hotplug/pciehp_core.c
41350 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41351 struct slot *slot = ctrl->slot;
41352 struct hotplug_slot *hotplug = NULL;
41353 struct hotplug_slot_info *info = NULL;
41354 - struct hotplug_slot_ops *ops = NULL;
41355 + hotplug_slot_ops_no_const *ops = NULL;
41356 char name[SLOT_NAME_SIZE];
41357 int retval = -ENOMEM;
41358
41359 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41360 index 9c6e9bb..2916736 100644
41361 --- a/drivers/pci/pci-sysfs.c
41362 +++ b/drivers/pci/pci-sysfs.c
41363 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41364 {
41365 /* allocate attribute structure, piggyback attribute name */
41366 int name_len = write_combine ? 13 : 10;
41367 - struct bin_attribute *res_attr;
41368 + bin_attribute_no_const *res_attr;
41369 int retval;
41370
41371 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41372 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41373 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41374 {
41375 int retval;
41376 - struct bin_attribute *attr;
41377 + bin_attribute_no_const *attr;
41378
41379 /* If the device has VPD, try to expose it in sysfs. */
41380 if (dev->vpd) {
41381 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41382 {
41383 int retval;
41384 int rom_size = 0;
41385 - struct bin_attribute *attr;
41386 + bin_attribute_no_const *attr;
41387
41388 if (!sysfs_initialized)
41389 return -EACCES;
41390 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41391 index 7346ee6..41520eb 100644
41392 --- a/drivers/pci/pci.h
41393 +++ b/drivers/pci/pci.h
41394 @@ -93,7 +93,7 @@ struct pci_vpd_ops {
41395 struct pci_vpd {
41396 unsigned int len;
41397 const struct pci_vpd_ops *ops;
41398 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41399 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41400 };
41401
41402 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41403 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41404 index d320df6..ca9a8f6 100644
41405 --- a/drivers/pci/pcie/aspm.c
41406 +++ b/drivers/pci/pcie/aspm.c
41407 @@ -27,9 +27,9 @@
41408 #define MODULE_PARAM_PREFIX "pcie_aspm."
41409
41410 /* Note: those are not register definitions */
41411 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41412 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41413 -#define ASPM_STATE_L1 (4) /* L1 state */
41414 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41415 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41416 +#define ASPM_STATE_L1 (4U) /* L1 state */
41417 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41418 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41419
41420 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41421 index 563771f..4e3c368 100644
41422 --- a/drivers/pci/probe.c
41423 +++ b/drivers/pci/probe.c
41424 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41425 struct pci_bus_region region;
41426 bool bar_too_big = false, bar_disabled = false;
41427
41428 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41429 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41430
41431 /* No printks while decoding is disabled! */
41432 if (!dev->mmio_always_on) {
41433 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41434 index 0b00947..64f7c0a 100644
41435 --- a/drivers/pci/proc.c
41436 +++ b/drivers/pci/proc.c
41437 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41438 static int __init pci_proc_init(void)
41439 {
41440 struct pci_dev *dev = NULL;
41441 +
41442 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41443 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41444 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41445 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41446 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41447 +#endif
41448 +#else
41449 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41450 +#endif
41451 proc_create("devices", 0, proc_bus_pci_dir,
41452 &proc_bus_pci_dev_operations);
41453 proc_initialized = 1;
41454 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41455 index 3e5b4497..dcdfb70 100644
41456 --- a/drivers/platform/x86/chromeos_laptop.c
41457 +++ b/drivers/platform/x86/chromeos_laptop.c
41458 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41459 return 0;
41460 }
41461
41462 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41463 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41464 {
41465 .ident = "Samsung Series 5 550 - Touchpad",
41466 .matches = {
41467 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41468 index 6b22938..bc9700e 100644
41469 --- a/drivers/platform/x86/msi-laptop.c
41470 +++ b/drivers/platform/x86/msi-laptop.c
41471 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41472
41473 if (!quirks->ec_read_only) {
41474 /* allow userland write sysfs file */
41475 - dev_attr_bluetooth.store = store_bluetooth;
41476 - dev_attr_wlan.store = store_wlan;
41477 - dev_attr_threeg.store = store_threeg;
41478 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41479 - dev_attr_wlan.attr.mode |= S_IWUSR;
41480 - dev_attr_threeg.attr.mode |= S_IWUSR;
41481 + pax_open_kernel();
41482 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41483 + *(void **)&dev_attr_wlan.store = store_wlan;
41484 + *(void **)&dev_attr_threeg.store = store_threeg;
41485 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41486 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41487 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41488 + pax_close_kernel();
41489 }
41490
41491 /* disable hardware control by fn key */
41492 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41493 index 14d4dce..b129917 100644
41494 --- a/drivers/platform/x86/sony-laptop.c
41495 +++ b/drivers/platform/x86/sony-laptop.c
41496 @@ -2465,7 +2465,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41497 }
41498
41499 /* High speed charging function */
41500 -static struct device_attribute *hsc_handle;
41501 +static device_attribute_no_const *hsc_handle;
41502
41503 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41504 struct device_attribute *attr,
41505 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41506 index edec135..59a24a3 100644
41507 --- a/drivers/platform/x86/thinkpad_acpi.c
41508 +++ b/drivers/platform/x86/thinkpad_acpi.c
41509 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41510 return 0;
41511 }
41512
41513 -void static hotkey_mask_warn_incomplete_mask(void)
41514 +static void hotkey_mask_warn_incomplete_mask(void)
41515 {
41516 /* log only what the user can fix... */
41517 const u32 wantedmask = hotkey_driver_mask &
41518 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41519 }
41520 }
41521
41522 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41523 - struct tp_nvram_state *newn,
41524 - const u32 event_mask)
41525 -{
41526 -
41527 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41528 do { \
41529 if ((event_mask & (1 << __scancode)) && \
41530 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41531 tpacpi_hotkey_send_key(__scancode); \
41532 } while (0)
41533
41534 - void issue_volchange(const unsigned int oldvol,
41535 - const unsigned int newvol)
41536 - {
41537 - unsigned int i = oldvol;
41538 +static void issue_volchange(const unsigned int oldvol,
41539 + const unsigned int newvol,
41540 + const u32 event_mask)
41541 +{
41542 + unsigned int i = oldvol;
41543
41544 - while (i > newvol) {
41545 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41546 - i--;
41547 - }
41548 - while (i < newvol) {
41549 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41550 - i++;
41551 - }
41552 + while (i > newvol) {
41553 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41554 + i--;
41555 }
41556 + while (i < newvol) {
41557 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41558 + i++;
41559 + }
41560 +}
41561
41562 - void issue_brightnesschange(const unsigned int oldbrt,
41563 - const unsigned int newbrt)
41564 - {
41565 - unsigned int i = oldbrt;
41566 +static void issue_brightnesschange(const unsigned int oldbrt,
41567 + const unsigned int newbrt,
41568 + const u32 event_mask)
41569 +{
41570 + unsigned int i = oldbrt;
41571
41572 - while (i > newbrt) {
41573 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41574 - i--;
41575 - }
41576 - while (i < newbrt) {
41577 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41578 - i++;
41579 - }
41580 + while (i > newbrt) {
41581 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41582 + i--;
41583 + }
41584 + while (i < newbrt) {
41585 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41586 + i++;
41587 }
41588 +}
41589
41590 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41591 + struct tp_nvram_state *newn,
41592 + const u32 event_mask)
41593 +{
41594 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41595 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41596 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41597 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41598 oldn->volume_level != newn->volume_level) {
41599 /* recently muted, or repeated mute keypress, or
41600 * multiple presses ending in mute */
41601 - issue_volchange(oldn->volume_level, newn->volume_level);
41602 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41603 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41604 }
41605 } else {
41606 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41607 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41608 }
41609 if (oldn->volume_level != newn->volume_level) {
41610 - issue_volchange(oldn->volume_level, newn->volume_level);
41611 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41612 } else if (oldn->volume_toggle != newn->volume_toggle) {
41613 /* repeated vol up/down keypress at end of scale ? */
41614 if (newn->volume_level == 0)
41615 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41616 /* handle brightness */
41617 if (oldn->brightness_level != newn->brightness_level) {
41618 issue_brightnesschange(oldn->brightness_level,
41619 - newn->brightness_level);
41620 + newn->brightness_level,
41621 + event_mask);
41622 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41623 /* repeated key presses that didn't change state */
41624 if (newn->brightness_level == 0)
41625 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41626 && !tp_features.bright_unkfw)
41627 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41628 }
41629 +}
41630
41631 #undef TPACPI_COMPARE_KEY
41632 #undef TPACPI_MAY_SEND_KEY
41633 -}
41634
41635 /*
41636 * Polling driver
41637 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41638 index 769d265..a3a05ca 100644
41639 --- a/drivers/pnp/pnpbios/bioscalls.c
41640 +++ b/drivers/pnp/pnpbios/bioscalls.c
41641 @@ -58,7 +58,7 @@ do { \
41642 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41643 } while(0)
41644
41645 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41646 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41647 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41648
41649 /*
41650 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41651
41652 cpu = get_cpu();
41653 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41654 +
41655 + pax_open_kernel();
41656 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41657 + pax_close_kernel();
41658
41659 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41660 spin_lock_irqsave(&pnp_bios_lock, flags);
41661 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41662 :"memory");
41663 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41664
41665 + pax_open_kernel();
41666 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41667 + pax_close_kernel();
41668 +
41669 put_cpu();
41670
41671 /* If we get here and this is set then the PnP BIOS faulted on us. */
41672 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41673 return status;
41674 }
41675
41676 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41677 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41678 {
41679 int i;
41680
41681 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41682 pnp_bios_callpoint.offset = header->fields.pm16offset;
41683 pnp_bios_callpoint.segment = PNP_CS16;
41684
41685 + pax_open_kernel();
41686 +
41687 for_each_possible_cpu(i) {
41688 struct desc_struct *gdt = get_cpu_gdt_table(i);
41689 if (!gdt)
41690 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41691 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41692 (unsigned long)__va(header->fields.pm16dseg));
41693 }
41694 +
41695 + pax_close_kernel();
41696 }
41697 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41698 index 3e6db1c..1fbbdae 100644
41699 --- a/drivers/pnp/resource.c
41700 +++ b/drivers/pnp/resource.c
41701 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41702 return 1;
41703
41704 /* check if the resource is valid */
41705 - if (*irq < 0 || *irq > 15)
41706 + if (*irq > 15)
41707 return 0;
41708
41709 /* check if the resource is reserved */
41710 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41711 return 1;
41712
41713 /* check if the resource is valid */
41714 - if (*dma < 0 || *dma == 4 || *dma > 7)
41715 + if (*dma == 4 || *dma > 7)
41716 return 0;
41717
41718 /* check if the resource is reserved */
41719 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41720 index 7df7c5f..bd48c47 100644
41721 --- a/drivers/power/pda_power.c
41722 +++ b/drivers/power/pda_power.c
41723 @@ -37,7 +37,11 @@ static int polling;
41724
41725 #ifdef CONFIG_USB_OTG_UTILS
41726 static struct usb_phy *transceiver;
41727 -static struct notifier_block otg_nb;
41728 +static int otg_handle_notification(struct notifier_block *nb,
41729 + unsigned long event, void *unused);
41730 +static struct notifier_block otg_nb = {
41731 + .notifier_call = otg_handle_notification
41732 +};
41733 #endif
41734
41735 static struct regulator *ac_draw;
41736 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41737
41738 #ifdef CONFIG_USB_OTG_UTILS
41739 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41740 - otg_nb.notifier_call = otg_handle_notification;
41741 ret = usb_register_notifier(transceiver, &otg_nb);
41742 if (ret) {
41743 dev_err(dev, "failure to register otg notifier\n");
41744 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41745 index cc439fd..8fa30df 100644
41746 --- a/drivers/power/power_supply.h
41747 +++ b/drivers/power/power_supply.h
41748 @@ -16,12 +16,12 @@ struct power_supply;
41749
41750 #ifdef CONFIG_SYSFS
41751
41752 -extern void power_supply_init_attrs(struct device_type *dev_type);
41753 +extern void power_supply_init_attrs(void);
41754 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41755
41756 #else
41757
41758 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41759 +static inline void power_supply_init_attrs(void) {}
41760 #define power_supply_uevent NULL
41761
41762 #endif /* CONFIG_SYSFS */
41763 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41764 index 5deac43..608c5ff 100644
41765 --- a/drivers/power/power_supply_core.c
41766 +++ b/drivers/power/power_supply_core.c
41767 @@ -24,7 +24,10 @@
41768 struct class *power_supply_class;
41769 EXPORT_SYMBOL_GPL(power_supply_class);
41770
41771 -static struct device_type power_supply_dev_type;
41772 +extern const struct attribute_group *power_supply_attr_groups[];
41773 +static struct device_type power_supply_dev_type = {
41774 + .groups = power_supply_attr_groups,
41775 +};
41776
41777 static int __power_supply_changed_work(struct device *dev, void *data)
41778 {
41779 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41780 return PTR_ERR(power_supply_class);
41781
41782 power_supply_class->dev_uevent = power_supply_uevent;
41783 - power_supply_init_attrs(&power_supply_dev_type);
41784 + power_supply_init_attrs();
41785
41786 return 0;
41787 }
41788 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41789 index 29178f7..c65f324 100644
41790 --- a/drivers/power/power_supply_sysfs.c
41791 +++ b/drivers/power/power_supply_sysfs.c
41792 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
41793 .is_visible = power_supply_attr_is_visible,
41794 };
41795
41796 -static const struct attribute_group *power_supply_attr_groups[] = {
41797 +const struct attribute_group *power_supply_attr_groups[] = {
41798 &power_supply_attr_group,
41799 NULL,
41800 };
41801
41802 -void power_supply_init_attrs(struct device_type *dev_type)
41803 +void power_supply_init_attrs(void)
41804 {
41805 int i;
41806
41807 - dev_type->groups = power_supply_attr_groups;
41808 -
41809 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41810 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41811 }
41812 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41813 index 4d7c635..9860196 100644
41814 --- a/drivers/regulator/max8660.c
41815 +++ b/drivers/regulator/max8660.c
41816 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41817 max8660->shadow_regs[MAX8660_OVER1] = 5;
41818 } else {
41819 /* Otherwise devices can be toggled via software */
41820 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41821 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41822 + pax_open_kernel();
41823 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41824 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41825 + pax_close_kernel();
41826 }
41827
41828 /*
41829 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41830 index 9a8ea91..c483dd9 100644
41831 --- a/drivers/regulator/max8973-regulator.c
41832 +++ b/drivers/regulator/max8973-regulator.c
41833 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41834 if (!pdata->enable_ext_control) {
41835 max->desc.enable_reg = MAX8973_VOUT;
41836 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41837 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41838 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41839 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41840 + pax_open_kernel();
41841 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41842 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41843 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41844 + pax_close_kernel();
41845 }
41846
41847 max->enable_external_control = pdata->enable_ext_control;
41848 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41849 index 9891aec..beb3083 100644
41850 --- a/drivers/regulator/mc13892-regulator.c
41851 +++ b/drivers/regulator/mc13892-regulator.c
41852 @@ -583,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41853 }
41854 mc13xxx_unlock(mc13892);
41855
41856 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41857 + pax_open_kernel();
41858 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41859 = mc13892_vcam_set_mode;
41860 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41861 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41862 = mc13892_vcam_get_mode;
41863 + pax_close_kernel();
41864
41865 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41866 ARRAY_SIZE(mc13892_regulators),
41867 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41868 index cc5bea9..689f7d9 100644
41869 --- a/drivers/rtc/rtc-cmos.c
41870 +++ b/drivers/rtc/rtc-cmos.c
41871 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41872 hpet_rtc_timer_init();
41873
41874 /* export at least the first block of NVRAM */
41875 - nvram.size = address_space - NVRAM_OFFSET;
41876 + pax_open_kernel();
41877 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41878 + pax_close_kernel();
41879 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41880 if (retval < 0) {
41881 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41882 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41883 index d049393..bb20be0 100644
41884 --- a/drivers/rtc/rtc-dev.c
41885 +++ b/drivers/rtc/rtc-dev.c
41886 @@ -16,6 +16,7 @@
41887 #include <linux/module.h>
41888 #include <linux/rtc.h>
41889 #include <linux/sched.h>
41890 +#include <linux/grsecurity.h>
41891 #include "rtc-core.h"
41892
41893 static dev_t rtc_devt;
41894 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
41895 if (copy_from_user(&tm, uarg, sizeof(tm)))
41896 return -EFAULT;
41897
41898 + gr_log_timechange();
41899 +
41900 return rtc_set_time(rtc, &tm);
41901
41902 case RTC_PIE_ON:
41903 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41904 index 970a236..3613169 100644
41905 --- a/drivers/rtc/rtc-ds1307.c
41906 +++ b/drivers/rtc/rtc-ds1307.c
41907 @@ -106,7 +106,7 @@ struct ds1307 {
41908 u8 offset; /* register's offset */
41909 u8 regs[11];
41910 u16 nvram_offset;
41911 - struct bin_attribute *nvram;
41912 + bin_attribute_no_const *nvram;
41913 enum ds_type type;
41914 unsigned long flags;
41915 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41916 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41917 index 130f29a..6179d03 100644
41918 --- a/drivers/rtc/rtc-m48t59.c
41919 +++ b/drivers/rtc/rtc-m48t59.c
41920 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41921 goto out;
41922 }
41923
41924 - m48t59_nvram_attr.size = pdata->offset;
41925 + pax_open_kernel();
41926 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41927 + pax_close_kernel();
41928
41929 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41930 if (ret) {
41931 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41932 index e693af6..2e525b6 100644
41933 --- a/drivers/scsi/bfa/bfa_fcpim.h
41934 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41935 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41936
41937 struct bfa_itn_s {
41938 bfa_isr_func_t isr;
41939 -};
41940 +} __no_const;
41941
41942 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41943 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41944 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41945 index 23a90e7..9cf04ee 100644
41946 --- a/drivers/scsi/bfa/bfa_ioc.h
41947 +++ b/drivers/scsi/bfa/bfa_ioc.h
41948 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41949 bfa_ioc_disable_cbfn_t disable_cbfn;
41950 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41951 bfa_ioc_reset_cbfn_t reset_cbfn;
41952 -};
41953 +} __no_const;
41954
41955 /*
41956 * IOC event notification mechanism.
41957 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41958 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41959 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41960 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41961 -};
41962 +} __no_const;
41963
41964 /*
41965 * Queue element to wait for room in request queue. FIFO order is
41966 diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
41967 index 439c012..b63d534 100644
41968 --- a/drivers/scsi/bfa/bfad_debugfs.c
41969 +++ b/drivers/scsi/bfa/bfad_debugfs.c
41970 @@ -186,7 +186,7 @@ bfad_debugfs_lseek(struct file *file, loff_t offset, int orig)
41971 file->f_pos += offset;
41972 break;
41973 case 2:
41974 - file->f_pos = debug->buffer_len - offset;
41975 + file->f_pos = debug->buffer_len + offset;
41976 break;
41977 default:
41978 return -EINVAL;
41979 diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
41980 index adc1f7f..85e1ffd 100644
41981 --- a/drivers/scsi/fnic/fnic_debugfs.c
41982 +++ b/drivers/scsi/fnic/fnic_debugfs.c
41983 @@ -174,7 +174,7 @@ static loff_t fnic_trace_debugfs_lseek(struct file *file,
41984 pos = file->f_pos + offset;
41985 break;
41986 case 2:
41987 - pos = fnic_dbg_prt->buffer_len - offset;
41988 + pos = fnic_dbg_prt->buffer_len + offset;
41989 }
41990 return (pos < 0 || pos > fnic_dbg_prt->buffer_len) ?
41991 -EINVAL : (file->f_pos = pos);
41992 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41993 index df0c3c7..b00e1d0 100644
41994 --- a/drivers/scsi/hosts.c
41995 +++ b/drivers/scsi/hosts.c
41996 @@ -42,7 +42,7 @@
41997 #include "scsi_logging.h"
41998
41999
42000 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42001 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42002
42003
42004 static void scsi_host_cls_release(struct device *dev)
42005 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
42006 * subtract one because we increment first then return, but we need to
42007 * know what the next host number was before increment
42008 */
42009 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
42010 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
42011 shost->dma_channel = 0xff;
42012
42013 /* These three are default values which can be overridden */
42014 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
42015 index 7f4f790..b75b92a 100644
42016 --- a/drivers/scsi/hpsa.c
42017 +++ b/drivers/scsi/hpsa.c
42018 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
42019 unsigned long flags;
42020
42021 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
42022 - return h->access.command_completed(h, q);
42023 + return h->access->command_completed(h, q);
42024
42025 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
42026 a = rq->head[rq->current_entry];
42027 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
42028 while (!list_empty(&h->reqQ)) {
42029 c = list_entry(h->reqQ.next, struct CommandList, list);
42030 /* can't do anything if fifo is full */
42031 - if ((h->access.fifo_full(h))) {
42032 + if ((h->access->fifo_full(h))) {
42033 dev_warn(&h->pdev->dev, "fifo full\n");
42034 break;
42035 }
42036 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
42037
42038 /* Tell the controller execute command */
42039 spin_unlock_irqrestore(&h->lock, flags);
42040 - h->access.submit_command(h, c);
42041 + h->access->submit_command(h, c);
42042 spin_lock_irqsave(&h->lock, flags);
42043 }
42044 spin_unlock_irqrestore(&h->lock, flags);
42045 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
42046
42047 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42048 {
42049 - return h->access.command_completed(h, q);
42050 + return h->access->command_completed(h, q);
42051 }
42052
42053 static inline bool interrupt_pending(struct ctlr_info *h)
42054 {
42055 - return h->access.intr_pending(h);
42056 + return h->access->intr_pending(h);
42057 }
42058
42059 static inline long interrupt_not_for_us(struct ctlr_info *h)
42060 {
42061 - return (h->access.intr_pending(h) == 0) ||
42062 + return (h->access->intr_pending(h) == 0) ||
42063 (h->interrupts_enabled == 0);
42064 }
42065
42066 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42067 if (prod_index < 0)
42068 return -ENODEV;
42069 h->product_name = products[prod_index].product_name;
42070 - h->access = *(products[prod_index].access);
42071 + h->access = products[prod_index].access;
42072
42073 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42074 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42075 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42076
42077 assert_spin_locked(&lockup_detector_lock);
42078 remove_ctlr_from_lockup_detector_list(h);
42079 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42080 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42081 spin_lock_irqsave(&h->lock, flags);
42082 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42083 spin_unlock_irqrestore(&h->lock, flags);
42084 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
42085 }
42086
42087 /* make sure the board interrupts are off */
42088 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42089 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42090
42091 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42092 goto clean2;
42093 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
42094 * fake ones to scoop up any residual completions.
42095 */
42096 spin_lock_irqsave(&h->lock, flags);
42097 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42098 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42099 spin_unlock_irqrestore(&h->lock, flags);
42100 free_irqs(h);
42101 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42102 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
42103 dev_info(&h->pdev->dev, "Board READY.\n");
42104 dev_info(&h->pdev->dev,
42105 "Waiting for stale completions to drain.\n");
42106 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42107 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42108 msleep(10000);
42109 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42110 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42111
42112 rc = controller_reset_failed(h->cfgtable);
42113 if (rc)
42114 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
42115 }
42116
42117 /* Turn the interrupts on so we can service requests */
42118 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42119 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42120
42121 hpsa_hba_inquiry(h);
42122 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42123 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42124 * To write all data in the battery backed cache to disks
42125 */
42126 hpsa_flush_cache(h);
42127 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42128 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42129 hpsa_free_irqs_and_disable_msix(h);
42130 }
42131
42132 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42133 return;
42134 }
42135 /* Change the access methods to the performant access methods */
42136 - h->access = SA5_performant_access;
42137 + h->access = &SA5_performant_access;
42138 h->transMethod = CFGTBL_Trans_Performant;
42139 }
42140
42141 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42142 index 9816479..c5d4e97 100644
42143 --- a/drivers/scsi/hpsa.h
42144 +++ b/drivers/scsi/hpsa.h
42145 @@ -79,7 +79,7 @@ struct ctlr_info {
42146 unsigned int msix_vector;
42147 unsigned int msi_vector;
42148 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42149 - struct access_method access;
42150 + struct access_method *access;
42151
42152 /* queue and queue Info */
42153 struct list_head reqQ;
42154 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42155 index c772d8d..35c362c 100644
42156 --- a/drivers/scsi/libfc/fc_exch.c
42157 +++ b/drivers/scsi/libfc/fc_exch.c
42158 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42159 u16 pool_max_index;
42160
42161 struct {
42162 - atomic_t no_free_exch;
42163 - atomic_t no_free_exch_xid;
42164 - atomic_t xid_not_found;
42165 - atomic_t xid_busy;
42166 - atomic_t seq_not_found;
42167 - atomic_t non_bls_resp;
42168 + atomic_unchecked_t no_free_exch;
42169 + atomic_unchecked_t no_free_exch_xid;
42170 + atomic_unchecked_t xid_not_found;
42171 + atomic_unchecked_t xid_busy;
42172 + atomic_unchecked_t seq_not_found;
42173 + atomic_unchecked_t non_bls_resp;
42174 } stats;
42175 };
42176
42177 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42178 /* allocate memory for exchange */
42179 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42180 if (!ep) {
42181 - atomic_inc(&mp->stats.no_free_exch);
42182 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42183 goto out;
42184 }
42185 memset(ep, 0, sizeof(*ep));
42186 @@ -786,7 +786,7 @@ out:
42187 return ep;
42188 err:
42189 spin_unlock_bh(&pool->lock);
42190 - atomic_inc(&mp->stats.no_free_exch_xid);
42191 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42192 mempool_free(ep, mp->ep_pool);
42193 return NULL;
42194 }
42195 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42196 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42197 ep = fc_exch_find(mp, xid);
42198 if (!ep) {
42199 - atomic_inc(&mp->stats.xid_not_found);
42200 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42201 reject = FC_RJT_OX_ID;
42202 goto out;
42203 }
42204 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42205 ep = fc_exch_find(mp, xid);
42206 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42207 if (ep) {
42208 - atomic_inc(&mp->stats.xid_busy);
42209 + atomic_inc_unchecked(&mp->stats.xid_busy);
42210 reject = FC_RJT_RX_ID;
42211 goto rel;
42212 }
42213 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42214 }
42215 xid = ep->xid; /* get our XID */
42216 } else if (!ep) {
42217 - atomic_inc(&mp->stats.xid_not_found);
42218 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42219 reject = FC_RJT_RX_ID; /* XID not found */
42220 goto out;
42221 }
42222 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42223 } else {
42224 sp = &ep->seq;
42225 if (sp->id != fh->fh_seq_id) {
42226 - atomic_inc(&mp->stats.seq_not_found);
42227 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42228 if (f_ctl & FC_FC_END_SEQ) {
42229 /*
42230 * Update sequence_id based on incoming last
42231 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42232
42233 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42234 if (!ep) {
42235 - atomic_inc(&mp->stats.xid_not_found);
42236 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42237 goto out;
42238 }
42239 if (ep->esb_stat & ESB_ST_COMPLETE) {
42240 - atomic_inc(&mp->stats.xid_not_found);
42241 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42242 goto rel;
42243 }
42244 if (ep->rxid == FC_XID_UNKNOWN)
42245 ep->rxid = ntohs(fh->fh_rx_id);
42246 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42247 - atomic_inc(&mp->stats.xid_not_found);
42248 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42249 goto rel;
42250 }
42251 if (ep->did != ntoh24(fh->fh_s_id) &&
42252 ep->did != FC_FID_FLOGI) {
42253 - atomic_inc(&mp->stats.xid_not_found);
42254 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42255 goto rel;
42256 }
42257 sof = fr_sof(fp);
42258 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42259 sp->ssb_stat |= SSB_ST_RESP;
42260 sp->id = fh->fh_seq_id;
42261 } else if (sp->id != fh->fh_seq_id) {
42262 - atomic_inc(&mp->stats.seq_not_found);
42263 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42264 goto rel;
42265 }
42266
42267 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42268 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42269
42270 if (!sp)
42271 - atomic_inc(&mp->stats.xid_not_found);
42272 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42273 else
42274 - atomic_inc(&mp->stats.non_bls_resp);
42275 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42276
42277 fc_frame_free(fp);
42278 }
42279 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42280
42281 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42282 mp = ema->mp;
42283 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42284 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42285 st->fc_no_free_exch_xid +=
42286 - atomic_read(&mp->stats.no_free_exch_xid);
42287 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42288 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42289 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42290 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42291 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42292 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42293 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42294 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42295 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42296 }
42297 }
42298 EXPORT_SYMBOL(fc_exch_update_stats);
42299 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42300 index bdb81cd..d3c7c2c 100644
42301 --- a/drivers/scsi/libsas/sas_ata.c
42302 +++ b/drivers/scsi/libsas/sas_ata.c
42303 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42304 .postreset = ata_std_postreset,
42305 .error_handler = ata_std_error_handler,
42306 .post_internal_cmd = sas_ata_post_internal,
42307 - .qc_defer = ata_std_qc_defer,
42308 + .qc_defer = ata_std_qc_defer,
42309 .qc_prep = ata_noop_qc_prep,
42310 .qc_issue = sas_ata_qc_issue,
42311 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42312 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42313 index 7706c99..3b4fc0c 100644
42314 --- a/drivers/scsi/lpfc/lpfc.h
42315 +++ b/drivers/scsi/lpfc/lpfc.h
42316 @@ -424,7 +424,7 @@ struct lpfc_vport {
42317 struct dentry *debug_nodelist;
42318 struct dentry *vport_debugfs_root;
42319 struct lpfc_debugfs_trc *disc_trc;
42320 - atomic_t disc_trc_cnt;
42321 + atomic_unchecked_t disc_trc_cnt;
42322 #endif
42323 uint8_t stat_data_enabled;
42324 uint8_t stat_data_blocked;
42325 @@ -853,8 +853,8 @@ struct lpfc_hba {
42326 struct timer_list fabric_block_timer;
42327 unsigned long bit_flags;
42328 #define FABRIC_COMANDS_BLOCKED 0
42329 - atomic_t num_rsrc_err;
42330 - atomic_t num_cmd_success;
42331 + atomic_unchecked_t num_rsrc_err;
42332 + atomic_unchecked_t num_cmd_success;
42333 unsigned long last_rsrc_error_time;
42334 unsigned long last_ramp_down_time;
42335 unsigned long last_ramp_up_time;
42336 @@ -890,7 +890,7 @@ struct lpfc_hba {
42337
42338 struct dentry *debug_slow_ring_trc;
42339 struct lpfc_debugfs_trc *slow_ring_trc;
42340 - atomic_t slow_ring_trc_cnt;
42341 + atomic_unchecked_t slow_ring_trc_cnt;
42342 /* iDiag debugfs sub-directory */
42343 struct dentry *idiag_root;
42344 struct dentry *idiag_pci_cfg;
42345 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42346 index f63f5ff..32549a4 100644
42347 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42348 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42349 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42350
42351 #include <linux/debugfs.h>
42352
42353 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42354 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42355 static unsigned long lpfc_debugfs_start_time = 0L;
42356
42357 /* iDiag */
42358 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42359 lpfc_debugfs_enable = 0;
42360
42361 len = 0;
42362 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42363 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42364 (lpfc_debugfs_max_disc_trc - 1);
42365 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42366 dtp = vport->disc_trc + i;
42367 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42368 lpfc_debugfs_enable = 0;
42369
42370 len = 0;
42371 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42372 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42373 (lpfc_debugfs_max_slow_ring_trc - 1);
42374 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42375 dtp = phba->slow_ring_trc + i;
42376 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42377 !vport || !vport->disc_trc)
42378 return;
42379
42380 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42381 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42382 (lpfc_debugfs_max_disc_trc - 1);
42383 dtp = vport->disc_trc + index;
42384 dtp->fmt = fmt;
42385 dtp->data1 = data1;
42386 dtp->data2 = data2;
42387 dtp->data3 = data3;
42388 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42389 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42390 dtp->jif = jiffies;
42391 #endif
42392 return;
42393 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42394 !phba || !phba->slow_ring_trc)
42395 return;
42396
42397 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42398 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42399 (lpfc_debugfs_max_slow_ring_trc - 1);
42400 dtp = phba->slow_ring_trc + index;
42401 dtp->fmt = fmt;
42402 dtp->data1 = data1;
42403 dtp->data2 = data2;
42404 dtp->data3 = data3;
42405 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42406 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42407 dtp->jif = jiffies;
42408 #endif
42409 return;
42410 @@ -1178,7 +1178,7 @@ lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
42411 pos = file->f_pos + off;
42412 break;
42413 case 2:
42414 - pos = debug->len - off;
42415 + pos = debug->len + off;
42416 }
42417 return (pos < 0 || pos > debug->len) ? -EINVAL : (file->f_pos = pos);
42418 }
42419 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42420 "slow_ring buffer\n");
42421 goto debug_failed;
42422 }
42423 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42424 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42425 memset(phba->slow_ring_trc, 0,
42426 (sizeof(struct lpfc_debugfs_trc) *
42427 lpfc_debugfs_max_slow_ring_trc));
42428 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42429 "buffer\n");
42430 goto debug_failed;
42431 }
42432 - atomic_set(&vport->disc_trc_cnt, 0);
42433 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42434
42435 snprintf(name, sizeof(name), "discovery_trace");
42436 vport->debug_disc_trc =
42437 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42438 index 314b4f6..7005d10 100644
42439 --- a/drivers/scsi/lpfc/lpfc_init.c
42440 +++ b/drivers/scsi/lpfc/lpfc_init.c
42441 @@ -10551,8 +10551,10 @@ lpfc_init(void)
42442 "misc_register returned with status %d", error);
42443
42444 if (lpfc_enable_npiv) {
42445 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42446 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42447 + pax_open_kernel();
42448 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42449 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42450 + pax_close_kernel();
42451 }
42452 lpfc_transport_template =
42453 fc_attach_transport(&lpfc_transport_functions);
42454 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42455 index 98af07c..7625fb5 100644
42456 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42457 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42458 @@ -325,7 +325,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42459 uint32_t evt_posted;
42460
42461 spin_lock_irqsave(&phba->hbalock, flags);
42462 - atomic_inc(&phba->num_rsrc_err);
42463 + atomic_inc_unchecked(&phba->num_rsrc_err);
42464 phba->last_rsrc_error_time = jiffies;
42465
42466 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42467 @@ -366,7 +366,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42468 unsigned long flags;
42469 struct lpfc_hba *phba = vport->phba;
42470 uint32_t evt_posted;
42471 - atomic_inc(&phba->num_cmd_success);
42472 + atomic_inc_unchecked(&phba->num_cmd_success);
42473
42474 if (vport->cfg_lun_queue_depth <= queue_depth)
42475 return;
42476 @@ -410,8 +410,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42477 unsigned long num_rsrc_err, num_cmd_success;
42478 int i;
42479
42480 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42481 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42482 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42483 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42484
42485 /*
42486 * The error and success command counters are global per
42487 @@ -439,8 +439,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42488 }
42489 }
42490 lpfc_destroy_vport_work_array(phba, vports);
42491 - atomic_set(&phba->num_rsrc_err, 0);
42492 - atomic_set(&phba->num_cmd_success, 0);
42493 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42494 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42495 }
42496
42497 /**
42498 @@ -474,8 +474,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42499 }
42500 }
42501 lpfc_destroy_vport_work_array(phba, vports);
42502 - atomic_set(&phba->num_rsrc_err, 0);
42503 - atomic_set(&phba->num_cmd_success, 0);
42504 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42505 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42506 }
42507
42508 /**
42509 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42510 index b46f5e9..c4c4ccb 100644
42511 --- a/drivers/scsi/pmcraid.c
42512 +++ b/drivers/scsi/pmcraid.c
42513 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42514 res->scsi_dev = scsi_dev;
42515 scsi_dev->hostdata = res;
42516 res->change_detected = 0;
42517 - atomic_set(&res->read_failures, 0);
42518 - atomic_set(&res->write_failures, 0);
42519 + atomic_set_unchecked(&res->read_failures, 0);
42520 + atomic_set_unchecked(&res->write_failures, 0);
42521 rc = 0;
42522 }
42523 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42524 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42525
42526 /* If this was a SCSI read/write command keep count of errors */
42527 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42528 - atomic_inc(&res->read_failures);
42529 + atomic_inc_unchecked(&res->read_failures);
42530 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42531 - atomic_inc(&res->write_failures);
42532 + atomic_inc_unchecked(&res->write_failures);
42533
42534 if (!RES_IS_GSCSI(res->cfg_entry) &&
42535 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42536 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42537 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42538 * hrrq_id assigned here in queuecommand
42539 */
42540 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42541 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42542 pinstance->num_hrrq;
42543 cmd->cmd_done = pmcraid_io_done;
42544
42545 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42546 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42547 * hrrq_id assigned here in queuecommand
42548 */
42549 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42550 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42551 pinstance->num_hrrq;
42552
42553 if (request_size) {
42554 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42555
42556 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42557 /* add resources only after host is added into system */
42558 - if (!atomic_read(&pinstance->expose_resources))
42559 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42560 return;
42561
42562 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42563 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42564 init_waitqueue_head(&pinstance->reset_wait_q);
42565
42566 atomic_set(&pinstance->outstanding_cmds, 0);
42567 - atomic_set(&pinstance->last_message_id, 0);
42568 - atomic_set(&pinstance->expose_resources, 0);
42569 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42570 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42571
42572 INIT_LIST_HEAD(&pinstance->free_res_q);
42573 INIT_LIST_HEAD(&pinstance->used_res_q);
42574 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42575 /* Schedule worker thread to handle CCN and take care of adding and
42576 * removing devices to OS
42577 */
42578 - atomic_set(&pinstance->expose_resources, 1);
42579 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42580 schedule_work(&pinstance->worker_q);
42581 return rc;
42582
42583 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42584 index e1d150f..6c6df44 100644
42585 --- a/drivers/scsi/pmcraid.h
42586 +++ b/drivers/scsi/pmcraid.h
42587 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42588 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42589
42590 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42591 - atomic_t last_message_id;
42592 + atomic_unchecked_t last_message_id;
42593
42594 /* configuration table */
42595 struct pmcraid_config_table *cfg_table;
42596 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42597 atomic_t outstanding_cmds;
42598
42599 /* should add/delete resources to mid-layer now ?*/
42600 - atomic_t expose_resources;
42601 + atomic_unchecked_t expose_resources;
42602
42603
42604
42605 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42606 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42607 };
42608 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42609 - atomic_t read_failures; /* count of failed READ commands */
42610 - atomic_t write_failures; /* count of failed WRITE commands */
42611 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42612 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42613
42614 /* To indicate add/delete/modify during CCN */
42615 u8 change_detected;
42616 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42617 index b3db9dc..c3b1756 100644
42618 --- a/drivers/scsi/qla2xxx/qla_attr.c
42619 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42620 @@ -1971,7 +1971,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42621 return 0;
42622 }
42623
42624 -struct fc_function_template qla2xxx_transport_functions = {
42625 +fc_function_template_no_const qla2xxx_transport_functions = {
42626
42627 .show_host_node_name = 1,
42628 .show_host_port_name = 1,
42629 @@ -2018,7 +2018,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42630 .bsg_timeout = qla24xx_bsg_timeout,
42631 };
42632
42633 -struct fc_function_template qla2xxx_transport_vport_functions = {
42634 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42635
42636 .show_host_node_name = 1,
42637 .show_host_port_name = 1,
42638 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42639 index b310fa9..b9b3944 100644
42640 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42641 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42642 @@ -523,8 +523,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42643 struct device_attribute;
42644 extern struct device_attribute *qla2x00_host_attrs[];
42645 struct fc_function_template;
42646 -extern struct fc_function_template qla2xxx_transport_functions;
42647 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42648 +extern fc_function_template_no_const qla2xxx_transport_functions;
42649 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42650 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42651 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42652 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42653 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42654 index 2c6dd3d..e5ecd82 100644
42655 --- a/drivers/scsi/qla2xxx/qla_os.c
42656 +++ b/drivers/scsi/qla2xxx/qla_os.c
42657 @@ -1554,8 +1554,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42658 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42659 /* Ok, a 64bit DMA mask is applicable. */
42660 ha->flags.enable_64bit_addressing = 1;
42661 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42662 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42663 + pax_open_kernel();
42664 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42665 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42666 + pax_close_kernel();
42667 return;
42668 }
42669 }
42670 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42671 index 129f5dd..ade53e8 100644
42672 --- a/drivers/scsi/qla4xxx/ql4_def.h
42673 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42674 @@ -275,7 +275,7 @@ struct ddb_entry {
42675 * (4000 only) */
42676 atomic_t relogin_timer; /* Max Time to wait for
42677 * relogin to complete */
42678 - atomic_t relogin_retry_count; /* Num of times relogin has been
42679 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42680 * retried */
42681 uint32_t default_time2wait; /* Default Min time between
42682 * relogins (+aens) */
42683 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42684 index 6142729..b6a85c9 100644
42685 --- a/drivers/scsi/qla4xxx/ql4_os.c
42686 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42687 @@ -2622,12 +2622,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42688 */
42689 if (!iscsi_is_session_online(cls_sess)) {
42690 /* Reset retry relogin timer */
42691 - atomic_inc(&ddb_entry->relogin_retry_count);
42692 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42693 DEBUG2(ql4_printk(KERN_INFO, ha,
42694 "%s: index[%d] relogin timed out-retrying"
42695 " relogin (%d), retry (%d)\n", __func__,
42696 ddb_entry->fw_ddb_index,
42697 - atomic_read(&ddb_entry->relogin_retry_count),
42698 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42699 ddb_entry->default_time2wait + 4));
42700 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42701 atomic_set(&ddb_entry->retry_relogin_timer,
42702 @@ -4742,7 +4742,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42703
42704 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42705 atomic_set(&ddb_entry->relogin_timer, 0);
42706 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42707 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42708 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42709 ddb_entry->default_relogin_timeout =
42710 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42711 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42712 index 2c0d0ec..4e8681a 100644
42713 --- a/drivers/scsi/scsi.c
42714 +++ b/drivers/scsi/scsi.c
42715 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42716 unsigned long timeout;
42717 int rtn = 0;
42718
42719 - atomic_inc(&cmd->device->iorequest_cnt);
42720 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42721
42722 /* check if the device is still usable */
42723 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42724 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42725 index c31187d..0ead8c3 100644
42726 --- a/drivers/scsi/scsi_lib.c
42727 +++ b/drivers/scsi/scsi_lib.c
42728 @@ -1459,7 +1459,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42729 shost = sdev->host;
42730 scsi_init_cmd_errh(cmd);
42731 cmd->result = DID_NO_CONNECT << 16;
42732 - atomic_inc(&cmd->device->iorequest_cnt);
42733 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42734
42735 /*
42736 * SCSI request completion path will do scsi_device_unbusy(),
42737 @@ -1485,9 +1485,9 @@ static void scsi_softirq_done(struct request *rq)
42738
42739 INIT_LIST_HEAD(&cmd->eh_entry);
42740
42741 - atomic_inc(&cmd->device->iodone_cnt);
42742 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42743 if (cmd->result)
42744 - atomic_inc(&cmd->device->ioerr_cnt);
42745 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42746
42747 disposition = scsi_decide_disposition(cmd);
42748 if (disposition != SUCCESS &&
42749 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42750 index 931a7d9..0c2a754 100644
42751 --- a/drivers/scsi/scsi_sysfs.c
42752 +++ b/drivers/scsi/scsi_sysfs.c
42753 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42754 char *buf) \
42755 { \
42756 struct scsi_device *sdev = to_scsi_device(dev); \
42757 - unsigned long long count = atomic_read(&sdev->field); \
42758 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42759 return snprintf(buf, 20, "0x%llx\n", count); \
42760 } \
42761 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42762 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42763 index 84a1fdf..693b0d6 100644
42764 --- a/drivers/scsi/scsi_tgt_lib.c
42765 +++ b/drivers/scsi/scsi_tgt_lib.c
42766 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42767 int err;
42768
42769 dprintk("%lx %u\n", uaddr, len);
42770 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42771 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42772 if (err) {
42773 /*
42774 * TODO: need to fixup sg_tablesize, max_segment_size,
42775 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42776 index e894ca7..de9d7660 100644
42777 --- a/drivers/scsi/scsi_transport_fc.c
42778 +++ b/drivers/scsi/scsi_transport_fc.c
42779 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42780 * Netlink Infrastructure
42781 */
42782
42783 -static atomic_t fc_event_seq;
42784 +static atomic_unchecked_t fc_event_seq;
42785
42786 /**
42787 * fc_get_event_number - Obtain the next sequential FC event number
42788 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42789 u32
42790 fc_get_event_number(void)
42791 {
42792 - return atomic_add_return(1, &fc_event_seq);
42793 + return atomic_add_return_unchecked(1, &fc_event_seq);
42794 }
42795 EXPORT_SYMBOL(fc_get_event_number);
42796
42797 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42798 {
42799 int error;
42800
42801 - atomic_set(&fc_event_seq, 0);
42802 + atomic_set_unchecked(&fc_event_seq, 0);
42803
42804 error = transport_class_register(&fc_host_class);
42805 if (error)
42806 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42807 char *cp;
42808
42809 *val = simple_strtoul(buf, &cp, 0);
42810 - if ((*cp && (*cp != '\n')) || (*val < 0))
42811 + if (*cp && (*cp != '\n'))
42812 return -EINVAL;
42813 /*
42814 * Check for overflow; dev_loss_tmo is u32
42815 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42816 index 0a74b97..fa8d648 100644
42817 --- a/drivers/scsi/scsi_transport_iscsi.c
42818 +++ b/drivers/scsi/scsi_transport_iscsi.c
42819 @@ -79,7 +79,7 @@ struct iscsi_internal {
42820 struct transport_container session_cont;
42821 };
42822
42823 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42824 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42825 static struct workqueue_struct *iscsi_eh_timer_workq;
42826
42827 static DEFINE_IDA(iscsi_sess_ida);
42828 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42829 int err;
42830
42831 ihost = shost->shost_data;
42832 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42833 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42834
42835 if (target_id == ISCSI_MAX_TARGET) {
42836 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42837 @@ -2955,7 +2955,7 @@ static __init int iscsi_transport_init(void)
42838 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42839 ISCSI_TRANSPORT_VERSION);
42840
42841 - atomic_set(&iscsi_session_nr, 0);
42842 + atomic_set_unchecked(&iscsi_session_nr, 0);
42843
42844 err = class_register(&iscsi_transport_class);
42845 if (err)
42846 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42847 index f379c7f..e8fc69c 100644
42848 --- a/drivers/scsi/scsi_transport_srp.c
42849 +++ b/drivers/scsi/scsi_transport_srp.c
42850 @@ -33,7 +33,7 @@
42851 #include "scsi_transport_srp_internal.h"
42852
42853 struct srp_host_attrs {
42854 - atomic_t next_port_id;
42855 + atomic_unchecked_t next_port_id;
42856 };
42857 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42858
42859 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42860 struct Scsi_Host *shost = dev_to_shost(dev);
42861 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42862
42863 - atomic_set(&srp_host->next_port_id, 0);
42864 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42865 return 0;
42866 }
42867
42868 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42869 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42870 rport->roles = ids->roles;
42871
42872 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42873 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42874 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42875
42876 transport_setup_device(&rport->dev);
42877 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42878 index 82910cc..7c350ad 100644
42879 --- a/drivers/scsi/sd.c
42880 +++ b/drivers/scsi/sd.c
42881 @@ -2929,7 +2929,7 @@ static int sd_probe(struct device *dev)
42882 sdkp->disk = gd;
42883 sdkp->index = index;
42884 atomic_set(&sdkp->openers, 0);
42885 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42886 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42887
42888 if (!sdp->request_queue->rq_timeout) {
42889 if (sdp->type != TYPE_MOD)
42890 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42891 index 9f0c465..47194ee 100644
42892 --- a/drivers/scsi/sg.c
42893 +++ b/drivers/scsi/sg.c
42894 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42895 sdp->disk->disk_name,
42896 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42897 NULL,
42898 - (char *)arg);
42899 + (char __user *)arg);
42900 case BLKTRACESTART:
42901 return blk_trace_startstop(sdp->device->request_queue, 1);
42902 case BLKTRACESTOP:
42903 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42904 index 004b10f..7c98d51 100644
42905 --- a/drivers/spi/spi.c
42906 +++ b/drivers/spi/spi.c
42907 @@ -1620,7 +1620,7 @@ int spi_bus_unlock(struct spi_master *master)
42908 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42909
42910 /* portable code must never pass more than 32 bytes */
42911 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42912 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42913
42914 static u8 *buf;
42915
42916 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42917 index 93af756..a4bc5bf 100644
42918 --- a/drivers/staging/iio/iio_hwmon.c
42919 +++ b/drivers/staging/iio/iio_hwmon.c
42920 @@ -67,7 +67,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
42921 {
42922 struct device *dev = &pdev->dev;
42923 struct iio_hwmon_state *st;
42924 - struct sensor_device_attribute *a;
42925 + sensor_device_attribute_no_const *a;
42926 int ret, i;
42927 int in_i = 1, temp_i = 1, curr_i = 1;
42928 enum iio_chan_type type;
42929 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42930 index 34afc16..ffe44dd 100644
42931 --- a/drivers/staging/octeon/ethernet-rx.c
42932 +++ b/drivers/staging/octeon/ethernet-rx.c
42933 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42934 /* Increment RX stats for virtual ports */
42935 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42936 #ifdef CONFIG_64BIT
42937 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42938 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42939 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42940 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42941 #else
42942 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42943 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42944 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42945 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42946 #endif
42947 }
42948 netif_receive_skb(skb);
42949 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42950 dev->name);
42951 */
42952 #ifdef CONFIG_64BIT
42953 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42954 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42955 #else
42956 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42957 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42958 #endif
42959 dev_kfree_skb_irq(skb);
42960 }
42961 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42962 index c3a90e7..023619a 100644
42963 --- a/drivers/staging/octeon/ethernet.c
42964 +++ b/drivers/staging/octeon/ethernet.c
42965 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42966 * since the RX tasklet also increments it.
42967 */
42968 #ifdef CONFIG_64BIT
42969 - atomic64_add(rx_status.dropped_packets,
42970 - (atomic64_t *)&priv->stats.rx_dropped);
42971 + atomic64_add_unchecked(rx_status.dropped_packets,
42972 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42973 #else
42974 - atomic_add(rx_status.dropped_packets,
42975 - (atomic_t *)&priv->stats.rx_dropped);
42976 + atomic_add_unchecked(rx_status.dropped_packets,
42977 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42978 #endif
42979 }
42980
42981 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42982 index dc23395..cf7e9b1 100644
42983 --- a/drivers/staging/rtl8712/rtl871x_io.h
42984 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42985 @@ -108,7 +108,7 @@ struct _io_ops {
42986 u8 *pmem);
42987 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42988 u8 *pmem);
42989 -};
42990 +} __no_const;
42991
42992 struct io_req {
42993 struct list_head list;
42994 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42995 index 1f5088b..0e59820 100644
42996 --- a/drivers/staging/sbe-2t3e3/netdev.c
42997 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42998 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42999 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43000
43001 if (rlen)
43002 - if (copy_to_user(data, &resp, rlen))
43003 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43004 return -EFAULT;
43005
43006 return 0;
43007 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43008 index 5dddc4d..34fcb2f 100644
43009 --- a/drivers/staging/usbip/vhci.h
43010 +++ b/drivers/staging/usbip/vhci.h
43011 @@ -83,7 +83,7 @@ struct vhci_hcd {
43012 unsigned resuming:1;
43013 unsigned long re_timeout;
43014
43015 - atomic_t seqnum;
43016 + atomic_unchecked_t seqnum;
43017
43018 /*
43019 * NOTE:
43020 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43021 index f1ca084..7b5c0c3 100644
43022 --- a/drivers/staging/usbip/vhci_hcd.c
43023 +++ b/drivers/staging/usbip/vhci_hcd.c
43024 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
43025
43026 spin_lock(&vdev->priv_lock);
43027
43028 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43029 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43030 if (priv->seqnum == 0xffff)
43031 dev_info(&urb->dev->dev, "seqnum max\n");
43032
43033 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43034 return -ENOMEM;
43035 }
43036
43037 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43038 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43039 if (unlink->seqnum == 0xffff)
43040 pr_info("seqnum max\n");
43041
43042 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
43043 vdev->rhport = rhport;
43044 }
43045
43046 - atomic_set(&vhci->seqnum, 0);
43047 + atomic_set_unchecked(&vhci->seqnum, 0);
43048 spin_lock_init(&vhci->lock);
43049
43050 hcd->power_budget = 0; /* no limit */
43051 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43052 index faf8e60..c46f8ab 100644
43053 --- a/drivers/staging/usbip/vhci_rx.c
43054 +++ b/drivers/staging/usbip/vhci_rx.c
43055 @@ -76,7 +76,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43056 if (!urb) {
43057 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43058 pr_info("max seqnum %d\n",
43059 - atomic_read(&the_controller->seqnum));
43060 + atomic_read_unchecked(&the_controller->seqnum));
43061 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43062 return;
43063 }
43064 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43065 index 5f13890..36a044b 100644
43066 --- a/drivers/staging/vt6655/hostap.c
43067 +++ b/drivers/staging/vt6655/hostap.c
43068 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
43069 *
43070 */
43071
43072 +static net_device_ops_no_const apdev_netdev_ops;
43073 +
43074 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43075 {
43076 PSDevice apdev_priv;
43077 struct net_device *dev = pDevice->dev;
43078 int ret;
43079 - const struct net_device_ops apdev_netdev_ops = {
43080 - .ndo_start_xmit = pDevice->tx_80211,
43081 - };
43082
43083 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43084
43085 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43086 *apdev_priv = *pDevice;
43087 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43088
43089 + /* only half broken now */
43090 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43091 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43092
43093 pDevice->apdev->type = ARPHRD_IEEE80211;
43094 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43095 index a94e66f..31984d0 100644
43096 --- a/drivers/staging/vt6656/hostap.c
43097 +++ b/drivers/staging/vt6656/hostap.c
43098 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43099 *
43100 */
43101
43102 +static net_device_ops_no_const apdev_netdev_ops;
43103 +
43104 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43105 {
43106 struct vnt_private *apdev_priv;
43107 struct net_device *dev = pDevice->dev;
43108 int ret;
43109 - const struct net_device_ops apdev_netdev_ops = {
43110 - .ndo_start_xmit = pDevice->tx_80211,
43111 - };
43112
43113 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43114
43115 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43116 *apdev_priv = *pDevice;
43117 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43118
43119 + /* only half broken now */
43120 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43121 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43122
43123 pDevice->apdev->type = ARPHRD_IEEE80211;
43124 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43125 index a2b7e03..9ff4bbd 100644
43126 --- a/drivers/staging/zcache/tmem.c
43127 +++ b/drivers/staging/zcache/tmem.c
43128 @@ -50,7 +50,7 @@
43129 * A tmem host implementation must use this function to register callbacks
43130 * for memory allocation.
43131 */
43132 -static struct tmem_hostops tmem_hostops;
43133 +static tmem_hostops_no_const tmem_hostops;
43134
43135 static void tmem_objnode_tree_init(void);
43136
43137 @@ -64,7 +64,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43138 * A tmem host implementation must use this function to register
43139 * callbacks for a page-accessible memory (PAM) implementation.
43140 */
43141 -static struct tmem_pamops tmem_pamops;
43142 +static tmem_pamops_no_const tmem_pamops;
43143
43144 void tmem_register_pamops(struct tmem_pamops *m)
43145 {
43146 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43147 index adbe5a8..d387359 100644
43148 --- a/drivers/staging/zcache/tmem.h
43149 +++ b/drivers/staging/zcache/tmem.h
43150 @@ -226,6 +226,7 @@ struct tmem_pamops {
43151 int (*replace_in_obj)(void *, struct tmem_obj *);
43152 #endif
43153 };
43154 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43155 extern void tmem_register_pamops(struct tmem_pamops *m);
43156
43157 /* memory allocation methods provided by the host implementation */
43158 @@ -235,6 +236,7 @@ struct tmem_hostops {
43159 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43160 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43161 };
43162 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43163 extern void tmem_register_hostops(struct tmem_hostops *m);
43164
43165 /* core tmem accessor functions */
43166 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43167 index 2e4d655..fd72e68 100644
43168 --- a/drivers/target/target_core_device.c
43169 +++ b/drivers/target/target_core_device.c
43170 @@ -1414,7 +1414,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43171 spin_lock_init(&dev->se_port_lock);
43172 spin_lock_init(&dev->se_tmr_lock);
43173 spin_lock_init(&dev->qf_cmd_lock);
43174 - atomic_set(&dev->dev_ordered_id, 0);
43175 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43176 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43177 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43178 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43179 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43180 index fc9a5a0..1d5975e 100644
43181 --- a/drivers/target/target_core_transport.c
43182 +++ b/drivers/target/target_core_transport.c
43183 @@ -1081,7 +1081,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43184 * Used to determine when ORDERED commands should go from
43185 * Dormant to Active status.
43186 */
43187 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43188 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43189 smp_mb__after_atomic_inc();
43190 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43191 cmd->se_ordered_id, cmd->sam_task_attr,
43192 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43193 index 345bd0e..61d5375 100644
43194 --- a/drivers/tty/cyclades.c
43195 +++ b/drivers/tty/cyclades.c
43196 @@ -1576,10 +1576,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43197 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43198 info->port.count);
43199 #endif
43200 - info->port.count++;
43201 + atomic_inc(&info->port.count);
43202 #ifdef CY_DEBUG_COUNT
43203 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43204 - current->pid, info->port.count);
43205 + current->pid, atomic_read(&info->port.count));
43206 #endif
43207
43208 /*
43209 @@ -3978,7 +3978,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43210 for (j = 0; j < cy_card[i].nports; j++) {
43211 info = &cy_card[i].ports[j];
43212
43213 - if (info->port.count) {
43214 + if (atomic_read(&info->port.count)) {
43215 /* XXX is the ldisc num worth this? */
43216 struct tty_struct *tty;
43217 struct tty_ldisc *ld;
43218 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43219 index eb255e8..f637a57 100644
43220 --- a/drivers/tty/hvc/hvc_console.c
43221 +++ b/drivers/tty/hvc/hvc_console.c
43222 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43223
43224 spin_lock_irqsave(&hp->port.lock, flags);
43225 /* Check and then increment for fast path open. */
43226 - if (hp->port.count++ > 0) {
43227 + if (atomic_inc_return(&hp->port.count) > 1) {
43228 spin_unlock_irqrestore(&hp->port.lock, flags);
43229 hvc_kick();
43230 return 0;
43231 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43232
43233 spin_lock_irqsave(&hp->port.lock, flags);
43234
43235 - if (--hp->port.count == 0) {
43236 + if (atomic_dec_return(&hp->port.count) == 0) {
43237 spin_unlock_irqrestore(&hp->port.lock, flags);
43238 /* We are done with the tty pointer now. */
43239 tty_port_tty_set(&hp->port, NULL);
43240 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43241 */
43242 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43243 } else {
43244 - if (hp->port.count < 0)
43245 + if (atomic_read(&hp->port.count) < 0)
43246 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43247 - hp->vtermno, hp->port.count);
43248 + hp->vtermno, atomic_read(&hp->port.count));
43249 spin_unlock_irqrestore(&hp->port.lock, flags);
43250 }
43251 }
43252 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43253 * open->hangup case this can be called after the final close so prevent
43254 * that from happening for now.
43255 */
43256 - if (hp->port.count <= 0) {
43257 + if (atomic_read(&hp->port.count) <= 0) {
43258 spin_unlock_irqrestore(&hp->port.lock, flags);
43259 return;
43260 }
43261
43262 - hp->port.count = 0;
43263 + atomic_set(&hp->port.count, 0);
43264 spin_unlock_irqrestore(&hp->port.lock, flags);
43265 tty_port_tty_set(&hp->port, NULL);
43266
43267 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43268 return -EPIPE;
43269
43270 /* FIXME what's this (unprotected) check for? */
43271 - if (hp->port.count <= 0)
43272 + if (atomic_read(&hp->port.count) <= 0)
43273 return -EIO;
43274
43275 spin_lock_irqsave(&hp->lock, flags);
43276 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43277 index 81e939e..95ead10 100644
43278 --- a/drivers/tty/hvc/hvcs.c
43279 +++ b/drivers/tty/hvc/hvcs.c
43280 @@ -83,6 +83,7 @@
43281 #include <asm/hvcserver.h>
43282 #include <asm/uaccess.h>
43283 #include <asm/vio.h>
43284 +#include <asm/local.h>
43285
43286 /*
43287 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43288 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43289
43290 spin_lock_irqsave(&hvcsd->lock, flags);
43291
43292 - if (hvcsd->port.count > 0) {
43293 + if (atomic_read(&hvcsd->port.count) > 0) {
43294 spin_unlock_irqrestore(&hvcsd->lock, flags);
43295 printk(KERN_INFO "HVCS: vterm state unchanged. "
43296 "The hvcs device node is still in use.\n");
43297 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43298 }
43299 }
43300
43301 - hvcsd->port.count = 0;
43302 + atomic_set(&hvcsd->port.count, 0);
43303 hvcsd->port.tty = tty;
43304 tty->driver_data = hvcsd;
43305
43306 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43307 unsigned long flags;
43308
43309 spin_lock_irqsave(&hvcsd->lock, flags);
43310 - hvcsd->port.count++;
43311 + atomic_inc(&hvcsd->port.count);
43312 hvcsd->todo_mask |= HVCS_SCHED_READ;
43313 spin_unlock_irqrestore(&hvcsd->lock, flags);
43314
43315 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43316 hvcsd = tty->driver_data;
43317
43318 spin_lock_irqsave(&hvcsd->lock, flags);
43319 - if (--hvcsd->port.count == 0) {
43320 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43321
43322 vio_disable_interrupts(hvcsd->vdev);
43323
43324 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43325
43326 free_irq(irq, hvcsd);
43327 return;
43328 - } else if (hvcsd->port.count < 0) {
43329 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43330 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43331 " is missmanaged.\n",
43332 - hvcsd->vdev->unit_address, hvcsd->port.count);
43333 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43334 }
43335
43336 spin_unlock_irqrestore(&hvcsd->lock, flags);
43337 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43338
43339 spin_lock_irqsave(&hvcsd->lock, flags);
43340 /* Preserve this so that we know how many kref refs to put */
43341 - temp_open_count = hvcsd->port.count;
43342 + temp_open_count = atomic_read(&hvcsd->port.count);
43343
43344 /*
43345 * Don't kref put inside the spinlock because the destruction
43346 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43347 tty->driver_data = NULL;
43348 hvcsd->port.tty = NULL;
43349
43350 - hvcsd->port.count = 0;
43351 + atomic_set(&hvcsd->port.count, 0);
43352
43353 /* This will drop any buffered data on the floor which is OK in a hangup
43354 * scenario. */
43355 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
43356 * the middle of a write operation? This is a crummy place to do this
43357 * but we want to keep it all in the spinlock.
43358 */
43359 - if (hvcsd->port.count <= 0) {
43360 + if (atomic_read(&hvcsd->port.count) <= 0) {
43361 spin_unlock_irqrestore(&hvcsd->lock, flags);
43362 return -ENODEV;
43363 }
43364 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43365 {
43366 struct hvcs_struct *hvcsd = tty->driver_data;
43367
43368 - if (!hvcsd || hvcsd->port.count <= 0)
43369 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43370 return 0;
43371
43372 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43373 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43374 index 8fd72ff..34a0bed 100644
43375 --- a/drivers/tty/ipwireless/tty.c
43376 +++ b/drivers/tty/ipwireless/tty.c
43377 @@ -29,6 +29,7 @@
43378 #include <linux/tty_driver.h>
43379 #include <linux/tty_flip.h>
43380 #include <linux/uaccess.h>
43381 +#include <asm/local.h>
43382
43383 #include "tty.h"
43384 #include "network.h"
43385 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43386 mutex_unlock(&tty->ipw_tty_mutex);
43387 return -ENODEV;
43388 }
43389 - if (tty->port.count == 0)
43390 + if (atomic_read(&tty->port.count) == 0)
43391 tty->tx_bytes_queued = 0;
43392
43393 - tty->port.count++;
43394 + atomic_inc(&tty->port.count);
43395
43396 tty->port.tty = linux_tty;
43397 linux_tty->driver_data = tty;
43398 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43399
43400 static void do_ipw_close(struct ipw_tty *tty)
43401 {
43402 - tty->port.count--;
43403 -
43404 - if (tty->port.count == 0) {
43405 + if (atomic_dec_return(&tty->port.count) == 0) {
43406 struct tty_struct *linux_tty = tty->port.tty;
43407
43408 if (linux_tty != NULL) {
43409 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43410 return;
43411
43412 mutex_lock(&tty->ipw_tty_mutex);
43413 - if (tty->port.count == 0) {
43414 + if (atomic_read(&tty->port.count) == 0) {
43415 mutex_unlock(&tty->ipw_tty_mutex);
43416 return;
43417 }
43418 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43419
43420 mutex_lock(&tty->ipw_tty_mutex);
43421
43422 - if (!tty->port.count) {
43423 + if (!atomic_read(&tty->port.count)) {
43424 mutex_unlock(&tty->ipw_tty_mutex);
43425 return;
43426 }
43427 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43428 return -ENODEV;
43429
43430 mutex_lock(&tty->ipw_tty_mutex);
43431 - if (!tty->port.count) {
43432 + if (!atomic_read(&tty->port.count)) {
43433 mutex_unlock(&tty->ipw_tty_mutex);
43434 return -EINVAL;
43435 }
43436 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43437 if (!tty)
43438 return -ENODEV;
43439
43440 - if (!tty->port.count)
43441 + if (!atomic_read(&tty->port.count))
43442 return -EINVAL;
43443
43444 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43445 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43446 if (!tty)
43447 return 0;
43448
43449 - if (!tty->port.count)
43450 + if (!atomic_read(&tty->port.count))
43451 return 0;
43452
43453 return tty->tx_bytes_queued;
43454 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43455 if (!tty)
43456 return -ENODEV;
43457
43458 - if (!tty->port.count)
43459 + if (!atomic_read(&tty->port.count))
43460 return -EINVAL;
43461
43462 return get_control_lines(tty);
43463 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43464 if (!tty)
43465 return -ENODEV;
43466
43467 - if (!tty->port.count)
43468 + if (!atomic_read(&tty->port.count))
43469 return -EINVAL;
43470
43471 return set_control_lines(tty, set, clear);
43472 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43473 if (!tty)
43474 return -ENODEV;
43475
43476 - if (!tty->port.count)
43477 + if (!atomic_read(&tty->port.count))
43478 return -EINVAL;
43479
43480 /* FIXME: Exactly how is the tty object locked here .. */
43481 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43482 * are gone */
43483 mutex_lock(&ttyj->ipw_tty_mutex);
43484 }
43485 - while (ttyj->port.count)
43486 + while (atomic_read(&ttyj->port.count))
43487 do_ipw_close(ttyj);
43488 ipwireless_disassociate_network_ttys(network,
43489 ttyj->channel_idx);
43490 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43491 index adeac25..787a0a1 100644
43492 --- a/drivers/tty/moxa.c
43493 +++ b/drivers/tty/moxa.c
43494 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43495 }
43496
43497 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43498 - ch->port.count++;
43499 + atomic_inc(&ch->port.count);
43500 tty->driver_data = ch;
43501 tty_port_tty_set(&ch->port, tty);
43502 mutex_lock(&ch->port.mutex);
43503 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43504 index 4a43ef5d7..aa71f27 100644
43505 --- a/drivers/tty/n_gsm.c
43506 +++ b/drivers/tty/n_gsm.c
43507 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43508 spin_lock_init(&dlci->lock);
43509 mutex_init(&dlci->mutex);
43510 dlci->fifo = &dlci->_fifo;
43511 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43512 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43513 kfree(dlci);
43514 return NULL;
43515 }
43516 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43517 struct gsm_dlci *dlci = tty->driver_data;
43518 struct tty_port *port = &dlci->port;
43519
43520 - port->count++;
43521 + atomic_inc(&port->count);
43522 dlci_get(dlci);
43523 dlci_get(dlci->gsm->dlci[0]);
43524 mux_get(dlci->gsm);
43525 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43526 index 1f8cba6..47b06c2 100644
43527 --- a/drivers/tty/n_tty.c
43528 +++ b/drivers/tty/n_tty.c
43529 @@ -2205,6 +2205,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43530 {
43531 *ops = tty_ldisc_N_TTY;
43532 ops->owner = NULL;
43533 - ops->refcount = ops->flags = 0;
43534 + atomic_set(&ops->refcount, 0);
43535 + ops->flags = 0;
43536 }
43537 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43538 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43539 index 74a5e8b..40c36a7 100644
43540 --- a/drivers/tty/pty.c
43541 +++ b/drivers/tty/pty.c
43542 @@ -797,8 +797,10 @@ static void __init unix98_pty_init(void)
43543 panic("Couldn't register Unix98 pts driver");
43544
43545 /* Now create the /dev/ptmx special device */
43546 + pax_open_kernel();
43547 tty_default_fops(&ptmx_fops);
43548 - ptmx_fops.open = ptmx_open;
43549 + *(void **)&ptmx_fops.open = ptmx_open;
43550 + pax_close_kernel();
43551
43552 cdev_init(&ptmx_cdev, &ptmx_fops);
43553 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43554 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43555 index 1d27003..959f452 100644
43556 --- a/drivers/tty/rocket.c
43557 +++ b/drivers/tty/rocket.c
43558 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43559 tty->driver_data = info;
43560 tty_port_tty_set(port, tty);
43561
43562 - if (port->count++ == 0) {
43563 + if (atomic_inc_return(&port->count) == 1) {
43564 atomic_inc(&rp_num_ports_open);
43565
43566 #ifdef ROCKET_DEBUG_OPEN
43567 @@ -932,7 +932,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43568 #endif
43569 }
43570 #ifdef ROCKET_DEBUG_OPEN
43571 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43572 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43573 #endif
43574
43575 /*
43576 @@ -1527,7 +1527,7 @@ static void rp_hangup(struct tty_struct *tty)
43577 spin_unlock_irqrestore(&info->port.lock, flags);
43578 return;
43579 }
43580 - if (info->port.count)
43581 + if (atomic_read(&info->port.count))
43582 atomic_dec(&rp_num_ports_open);
43583 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43584 spin_unlock_irqrestore(&info->port.lock, flags);
43585 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43586 index 1002054..dd644a8 100644
43587 --- a/drivers/tty/serial/kgdboc.c
43588 +++ b/drivers/tty/serial/kgdboc.c
43589 @@ -24,8 +24,9 @@
43590 #define MAX_CONFIG_LEN 40
43591
43592 static struct kgdb_io kgdboc_io_ops;
43593 +static struct kgdb_io kgdboc_io_ops_console;
43594
43595 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43596 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43597 static int configured = -1;
43598
43599 static char config[MAX_CONFIG_LEN];
43600 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43601 kgdboc_unregister_kbd();
43602 if (configured == 1)
43603 kgdb_unregister_io_module(&kgdboc_io_ops);
43604 + else if (configured == 2)
43605 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43606 }
43607
43608 static int configure_kgdboc(void)
43609 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43610 int err;
43611 char *cptr = config;
43612 struct console *cons;
43613 + int is_console = 0;
43614
43615 err = kgdboc_option_setup(config);
43616 if (err || !strlen(config) || isspace(config[0]))
43617 goto noconfig;
43618
43619 err = -ENODEV;
43620 - kgdboc_io_ops.is_console = 0;
43621 kgdb_tty_driver = NULL;
43622
43623 kgdboc_use_kms = 0;
43624 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43625 int idx;
43626 if (cons->device && cons->device(cons, &idx) == p &&
43627 idx == tty_line) {
43628 - kgdboc_io_ops.is_console = 1;
43629 + is_console = 1;
43630 break;
43631 }
43632 cons = cons->next;
43633 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43634 kgdb_tty_line = tty_line;
43635
43636 do_register:
43637 - err = kgdb_register_io_module(&kgdboc_io_ops);
43638 + if (is_console) {
43639 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43640 + configured = 2;
43641 + } else {
43642 + err = kgdb_register_io_module(&kgdboc_io_ops);
43643 + configured = 1;
43644 + }
43645 if (err)
43646 goto noconfig;
43647
43648 @@ -205,8 +214,6 @@ do_register:
43649 if (err)
43650 goto nmi_con_failed;
43651
43652 - configured = 1;
43653 -
43654 return 0;
43655
43656 nmi_con_failed:
43657 @@ -223,7 +230,7 @@ noconfig:
43658 static int __init init_kgdboc(void)
43659 {
43660 /* Already configured? */
43661 - if (configured == 1)
43662 + if (configured >= 1)
43663 return 0;
43664
43665 return configure_kgdboc();
43666 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43667 if (config[len - 1] == '\n')
43668 config[len - 1] = '\0';
43669
43670 - if (configured == 1)
43671 + if (configured >= 1)
43672 cleanup_kgdboc();
43673
43674 /* Go and configure with the new params. */
43675 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43676 .post_exception = kgdboc_post_exp_handler,
43677 };
43678
43679 +static struct kgdb_io kgdboc_io_ops_console = {
43680 + .name = "kgdboc",
43681 + .read_char = kgdboc_get_char,
43682 + .write_char = kgdboc_put_char,
43683 + .pre_exception = kgdboc_pre_exp_handler,
43684 + .post_exception = kgdboc_post_exp_handler,
43685 + .is_console = 1
43686 +};
43687 +
43688 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43689 /* This is only available if kgdboc is a built in for early debugging */
43690 static int __init kgdboc_early_init(char *opt)
43691 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43692 index 2769a38..f3dbe48 100644
43693 --- a/drivers/tty/serial/samsung.c
43694 +++ b/drivers/tty/serial/samsung.c
43695 @@ -451,11 +451,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43696 }
43697 }
43698
43699 +static int s3c64xx_serial_startup(struct uart_port *port);
43700 static int s3c24xx_serial_startup(struct uart_port *port)
43701 {
43702 struct s3c24xx_uart_port *ourport = to_ourport(port);
43703 int ret;
43704
43705 + /* Startup sequence is different for s3c64xx and higher SoC's */
43706 + if (s3c24xx_serial_has_interrupt_mask(port))
43707 + return s3c64xx_serial_startup(port);
43708 +
43709 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43710 port->mapbase, port->membase);
43711
43712 @@ -1120,10 +1125,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43713 /* setup info for port */
43714 port->dev = &platdev->dev;
43715
43716 - /* Startup sequence is different for s3c64xx and higher SoC's */
43717 - if (s3c24xx_serial_has_interrupt_mask(port))
43718 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43719 -
43720 port->uartclk = 1;
43721
43722 if (cfg->uart_flags & UPF_CONS_FLOW) {
43723 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43724 index 8fbb6d2..822a9e6 100644
43725 --- a/drivers/tty/serial/serial_core.c
43726 +++ b/drivers/tty/serial/serial_core.c
43727 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43728 uart_flush_buffer(tty);
43729 uart_shutdown(tty, state);
43730 spin_lock_irqsave(&port->lock, flags);
43731 - port->count = 0;
43732 + atomic_set(&port->count, 0);
43733 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43734 spin_unlock_irqrestore(&port->lock, flags);
43735 tty_port_tty_set(port, NULL);
43736 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43737 goto end;
43738 }
43739
43740 - port->count++;
43741 + atomic_inc(&port->count);
43742 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43743 retval = -ENXIO;
43744 goto err_dec_count;
43745 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43746 /*
43747 * Make sure the device is in D0 state.
43748 */
43749 - if (port->count == 1)
43750 + if (atomic_read(&port->count) == 1)
43751 uart_change_pm(state, UART_PM_STATE_ON);
43752
43753 /*
43754 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43755 end:
43756 return retval;
43757 err_dec_count:
43758 - port->count--;
43759 + atomic_inc(&port->count);
43760 mutex_unlock(&port->mutex);
43761 goto end;
43762 }
43763 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43764 index 8983276..72a4090 100644
43765 --- a/drivers/tty/synclink.c
43766 +++ b/drivers/tty/synclink.c
43767 @@ -3093,7 +3093,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43768
43769 if (debug_level >= DEBUG_LEVEL_INFO)
43770 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43771 - __FILE__,__LINE__, info->device_name, info->port.count);
43772 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43773
43774 if (tty_port_close_start(&info->port, tty, filp) == 0)
43775 goto cleanup;
43776 @@ -3111,7 +3111,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43777 cleanup:
43778 if (debug_level >= DEBUG_LEVEL_INFO)
43779 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43780 - tty->driver->name, info->port.count);
43781 + tty->driver->name, atomic_read(&info->port.count));
43782
43783 } /* end of mgsl_close() */
43784
43785 @@ -3210,8 +3210,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43786
43787 mgsl_flush_buffer(tty);
43788 shutdown(info);
43789 -
43790 - info->port.count = 0;
43791 +
43792 + atomic_set(&info->port.count, 0);
43793 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43794 info->port.tty = NULL;
43795
43796 @@ -3300,12 +3300,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43797
43798 if (debug_level >= DEBUG_LEVEL_INFO)
43799 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43800 - __FILE__,__LINE__, tty->driver->name, port->count );
43801 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43802
43803 spin_lock_irqsave(&info->irq_spinlock, flags);
43804 if (!tty_hung_up_p(filp)) {
43805 extra_count = true;
43806 - port->count--;
43807 + atomic_dec(&port->count);
43808 }
43809 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43810 port->blocked_open++;
43811 @@ -3334,7 +3334,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43812
43813 if (debug_level >= DEBUG_LEVEL_INFO)
43814 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43815 - __FILE__,__LINE__, tty->driver->name, port->count );
43816 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43817
43818 tty_unlock(tty);
43819 schedule();
43820 @@ -3346,12 +3346,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43821
43822 /* FIXME: Racy on hangup during close wait */
43823 if (extra_count)
43824 - port->count++;
43825 + atomic_inc(&port->count);
43826 port->blocked_open--;
43827
43828 if (debug_level >= DEBUG_LEVEL_INFO)
43829 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43830 - __FILE__,__LINE__, tty->driver->name, port->count );
43831 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43832
43833 if (!retval)
43834 port->flags |= ASYNC_NORMAL_ACTIVE;
43835 @@ -3403,7 +3403,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43836
43837 if (debug_level >= DEBUG_LEVEL_INFO)
43838 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43839 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43840 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43841
43842 /* If port is closing, signal caller to try again */
43843 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43844 @@ -3422,10 +3422,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43845 spin_unlock_irqrestore(&info->netlock, flags);
43846 goto cleanup;
43847 }
43848 - info->port.count++;
43849 + atomic_inc(&info->port.count);
43850 spin_unlock_irqrestore(&info->netlock, flags);
43851
43852 - if (info->port.count == 1) {
43853 + if (atomic_read(&info->port.count) == 1) {
43854 /* 1st open on this device, init hardware */
43855 retval = startup(info);
43856 if (retval < 0)
43857 @@ -3449,8 +3449,8 @@ cleanup:
43858 if (retval) {
43859 if (tty->count == 1)
43860 info->port.tty = NULL; /* tty layer will release tty struct */
43861 - if(info->port.count)
43862 - info->port.count--;
43863 + if (atomic_read(&info->port.count))
43864 + atomic_dec(&info->port.count);
43865 }
43866
43867 return retval;
43868 @@ -7668,7 +7668,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43869 unsigned short new_crctype;
43870
43871 /* return error if TTY interface open */
43872 - if (info->port.count)
43873 + if (atomic_read(&info->port.count))
43874 return -EBUSY;
43875
43876 switch (encoding)
43877 @@ -7763,7 +7763,7 @@ static int hdlcdev_open(struct net_device *dev)
43878
43879 /* arbitrate between network and tty opens */
43880 spin_lock_irqsave(&info->netlock, flags);
43881 - if (info->port.count != 0 || info->netcount != 0) {
43882 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43883 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43884 spin_unlock_irqrestore(&info->netlock, flags);
43885 return -EBUSY;
43886 @@ -7849,7 +7849,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43887 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43888
43889 /* return error if TTY interface open */
43890 - if (info->port.count)
43891 + if (atomic_read(&info->port.count))
43892 return -EBUSY;
43893
43894 if (cmd != SIOCWANDEV)
43895 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43896 index aa9eece..d8baaec 100644
43897 --- a/drivers/tty/synclink_gt.c
43898 +++ b/drivers/tty/synclink_gt.c
43899 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43900 tty->driver_data = info;
43901 info->port.tty = tty;
43902
43903 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43904 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43905
43906 /* If port is closing, signal caller to try again */
43907 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43908 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43909 mutex_unlock(&info->port.mutex);
43910 goto cleanup;
43911 }
43912 - info->port.count++;
43913 + atomic_inc(&info->port.count);
43914 spin_unlock_irqrestore(&info->netlock, flags);
43915
43916 - if (info->port.count == 1) {
43917 + if (atomic_read(&info->port.count) == 1) {
43918 /* 1st open on this device, init hardware */
43919 retval = startup(info);
43920 if (retval < 0) {
43921 @@ -715,8 +715,8 @@ cleanup:
43922 if (retval) {
43923 if (tty->count == 1)
43924 info->port.tty = NULL; /* tty layer will release tty struct */
43925 - if(info->port.count)
43926 - info->port.count--;
43927 + if(atomic_read(&info->port.count))
43928 + atomic_dec(&info->port.count);
43929 }
43930
43931 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43932 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43933
43934 if (sanity_check(info, tty->name, "close"))
43935 return;
43936 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43937 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43938
43939 if (tty_port_close_start(&info->port, tty, filp) == 0)
43940 goto cleanup;
43941 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43942 tty_port_close_end(&info->port, tty);
43943 info->port.tty = NULL;
43944 cleanup:
43945 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43946 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43947 }
43948
43949 static void hangup(struct tty_struct *tty)
43950 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
43951 shutdown(info);
43952
43953 spin_lock_irqsave(&info->port.lock, flags);
43954 - info->port.count = 0;
43955 + atomic_set(&info->port.count, 0);
43956 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43957 info->port.tty = NULL;
43958 spin_unlock_irqrestore(&info->port.lock, flags);
43959 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43960 unsigned short new_crctype;
43961
43962 /* return error if TTY interface open */
43963 - if (info->port.count)
43964 + if (atomic_read(&info->port.count))
43965 return -EBUSY;
43966
43967 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43968 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
43969
43970 /* arbitrate between network and tty opens */
43971 spin_lock_irqsave(&info->netlock, flags);
43972 - if (info->port.count != 0 || info->netcount != 0) {
43973 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43974 DBGINFO(("%s hdlc_open busy\n", dev->name));
43975 spin_unlock_irqrestore(&info->netlock, flags);
43976 return -EBUSY;
43977 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43978 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43979
43980 /* return error if TTY interface open */
43981 - if (info->port.count)
43982 + if (atomic_read(&info->port.count))
43983 return -EBUSY;
43984
43985 if (cmd != SIOCWANDEV)
43986 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43987 if (port == NULL)
43988 continue;
43989 spin_lock(&port->lock);
43990 - if ((port->port.count || port->netcount) &&
43991 + if ((atomic_read(&port->port.count) || port->netcount) &&
43992 port->pending_bh && !port->bh_running &&
43993 !port->bh_requested) {
43994 DBGISR(("%s bh queued\n", port->device_name));
43995 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43996 spin_lock_irqsave(&info->lock, flags);
43997 if (!tty_hung_up_p(filp)) {
43998 extra_count = true;
43999 - port->count--;
44000 + atomic_dec(&port->count);
44001 }
44002 spin_unlock_irqrestore(&info->lock, flags);
44003 port->blocked_open++;
44004 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44005 remove_wait_queue(&port->open_wait, &wait);
44006
44007 if (extra_count)
44008 - port->count++;
44009 + atomic_inc(&port->count);
44010 port->blocked_open--;
44011
44012 if (!retval)
44013 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44014 index 6d5780c..aa4d8cd 100644
44015 --- a/drivers/tty/synclinkmp.c
44016 +++ b/drivers/tty/synclinkmp.c
44017 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44018
44019 if (debug_level >= DEBUG_LEVEL_INFO)
44020 printk("%s(%d):%s open(), old ref count = %d\n",
44021 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44022 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44023
44024 /* If port is closing, signal caller to try again */
44025 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44026 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44027 spin_unlock_irqrestore(&info->netlock, flags);
44028 goto cleanup;
44029 }
44030 - info->port.count++;
44031 + atomic_inc(&info->port.count);
44032 spin_unlock_irqrestore(&info->netlock, flags);
44033
44034 - if (info->port.count == 1) {
44035 + if (atomic_read(&info->port.count) == 1) {
44036 /* 1st open on this device, init hardware */
44037 retval = startup(info);
44038 if (retval < 0)
44039 @@ -796,8 +796,8 @@ cleanup:
44040 if (retval) {
44041 if (tty->count == 1)
44042 info->port.tty = NULL; /* tty layer will release tty struct */
44043 - if(info->port.count)
44044 - info->port.count--;
44045 + if(atomic_read(&info->port.count))
44046 + atomic_dec(&info->port.count);
44047 }
44048
44049 return retval;
44050 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44051
44052 if (debug_level >= DEBUG_LEVEL_INFO)
44053 printk("%s(%d):%s close() entry, count=%d\n",
44054 - __FILE__,__LINE__, info->device_name, info->port.count);
44055 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44056
44057 if (tty_port_close_start(&info->port, tty, filp) == 0)
44058 goto cleanup;
44059 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44060 cleanup:
44061 if (debug_level >= DEBUG_LEVEL_INFO)
44062 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44063 - tty->driver->name, info->port.count);
44064 + tty->driver->name, atomic_read(&info->port.count));
44065 }
44066
44067 /* Called by tty_hangup() when a hangup is signaled.
44068 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
44069 shutdown(info);
44070
44071 spin_lock_irqsave(&info->port.lock, flags);
44072 - info->port.count = 0;
44073 + atomic_set(&info->port.count, 0);
44074 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44075 info->port.tty = NULL;
44076 spin_unlock_irqrestore(&info->port.lock, flags);
44077 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44078 unsigned short new_crctype;
44079
44080 /* return error if TTY interface open */
44081 - if (info->port.count)
44082 + if (atomic_read(&info->port.count))
44083 return -EBUSY;
44084
44085 switch (encoding)
44086 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
44087
44088 /* arbitrate between network and tty opens */
44089 spin_lock_irqsave(&info->netlock, flags);
44090 - if (info->port.count != 0 || info->netcount != 0) {
44091 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44092 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44093 spin_unlock_irqrestore(&info->netlock, flags);
44094 return -EBUSY;
44095 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44096 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44097
44098 /* return error if TTY interface open */
44099 - if (info->port.count)
44100 + if (atomic_read(&info->port.count))
44101 return -EBUSY;
44102
44103 if (cmd != SIOCWANDEV)
44104 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44105 * do not request bottom half processing if the
44106 * device is not open in a normal mode.
44107 */
44108 - if ( port && (port->port.count || port->netcount) &&
44109 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44110 port->pending_bh && !port->bh_running &&
44111 !port->bh_requested ) {
44112 if ( debug_level >= DEBUG_LEVEL_ISR )
44113 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44114
44115 if (debug_level >= DEBUG_LEVEL_INFO)
44116 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44117 - __FILE__,__LINE__, tty->driver->name, port->count );
44118 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44119
44120 spin_lock_irqsave(&info->lock, flags);
44121 if (!tty_hung_up_p(filp)) {
44122 extra_count = true;
44123 - port->count--;
44124 + atomic_dec(&port->count);
44125 }
44126 spin_unlock_irqrestore(&info->lock, flags);
44127 port->blocked_open++;
44128 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44129
44130 if (debug_level >= DEBUG_LEVEL_INFO)
44131 printk("%s(%d):%s block_til_ready() count=%d\n",
44132 - __FILE__,__LINE__, tty->driver->name, port->count );
44133 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44134
44135 tty_unlock(tty);
44136 schedule();
44137 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44138 remove_wait_queue(&port->open_wait, &wait);
44139
44140 if (extra_count)
44141 - port->count++;
44142 + atomic_inc(&port->count);
44143 port->blocked_open--;
44144
44145 if (debug_level >= DEBUG_LEVEL_INFO)
44146 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44147 - __FILE__,__LINE__, tty->driver->name, port->count );
44148 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44149
44150 if (!retval)
44151 port->flags |= ASYNC_NORMAL_ACTIVE;
44152 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44153 index 3687f0c..6b9b808 100644
44154 --- a/drivers/tty/sysrq.c
44155 +++ b/drivers/tty/sysrq.c
44156 @@ -995,7 +995,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44157 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44158 size_t count, loff_t *ppos)
44159 {
44160 - if (count) {
44161 + if (count && capable(CAP_SYS_ADMIN)) {
44162 char c;
44163
44164 if (get_user(c, buf))
44165 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44166 index a9cd0b9..47b9336 100644
44167 --- a/drivers/tty/tty_io.c
44168 +++ b/drivers/tty/tty_io.c
44169 @@ -3398,7 +3398,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44170
44171 void tty_default_fops(struct file_operations *fops)
44172 {
44173 - *fops = tty_fops;
44174 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44175 }
44176
44177 /*
44178 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44179 index d794087..e4f49e5 100644
44180 --- a/drivers/tty/tty_ldisc.c
44181 +++ b/drivers/tty/tty_ldisc.c
44182 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
44183 if (atomic_dec_and_test(&ld->users)) {
44184 struct tty_ldisc_ops *ldo = ld->ops;
44185
44186 - ldo->refcount--;
44187 + atomic_dec(&ldo->refcount);
44188 module_put(ldo->owner);
44189 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44190
44191 @@ -93,7 +93,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44192 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44193 tty_ldiscs[disc] = new_ldisc;
44194 new_ldisc->num = disc;
44195 - new_ldisc->refcount = 0;
44196 + atomic_set(&new_ldisc->refcount, 0);
44197 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44198
44199 return ret;
44200 @@ -121,7 +121,7 @@ int tty_unregister_ldisc(int disc)
44201 return -EINVAL;
44202
44203 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44204 - if (tty_ldiscs[disc]->refcount)
44205 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44206 ret = -EBUSY;
44207 else
44208 tty_ldiscs[disc] = NULL;
44209 @@ -142,7 +142,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44210 if (ldops) {
44211 ret = ERR_PTR(-EAGAIN);
44212 if (try_module_get(ldops->owner)) {
44213 - ldops->refcount++;
44214 + atomic_inc(&ldops->refcount);
44215 ret = ldops;
44216 }
44217 }
44218 @@ -155,7 +155,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44219 unsigned long flags;
44220
44221 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44222 - ldops->refcount--;
44223 + atomic_dec(&ldops->refcount);
44224 module_put(ldops->owner);
44225 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44226 }
44227 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44228 index b7ff59d..7c6105e 100644
44229 --- a/drivers/tty/tty_port.c
44230 +++ b/drivers/tty/tty_port.c
44231 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44232 unsigned long flags;
44233
44234 spin_lock_irqsave(&port->lock, flags);
44235 - port->count = 0;
44236 + atomic_set(&port->count, 0);
44237 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44238 if (port->tty) {
44239 set_bit(TTY_IO_ERROR, &port->tty->flags);
44240 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44241 /* The port lock protects the port counts */
44242 spin_lock_irqsave(&port->lock, flags);
44243 if (!tty_hung_up_p(filp))
44244 - port->count--;
44245 + atomic_dec(&port->count);
44246 port->blocked_open++;
44247 spin_unlock_irqrestore(&port->lock, flags);
44248
44249 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44250 we must not mess that up further */
44251 spin_lock_irqsave(&port->lock, flags);
44252 if (!tty_hung_up_p(filp))
44253 - port->count++;
44254 + atomic_inc(&port->count);
44255 port->blocked_open--;
44256 if (retval == 0)
44257 port->flags |= ASYNC_NORMAL_ACTIVE;
44258 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
44259 return 0;
44260 }
44261
44262 - if (tty->count == 1 && port->count != 1) {
44263 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44264 printk(KERN_WARNING
44265 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44266 - port->count);
44267 - port->count = 1;
44268 + atomic_read(&port->count));
44269 + atomic_set(&port->count, 1);
44270 }
44271 - if (--port->count < 0) {
44272 + if (atomic_dec_return(&port->count) < 0) {
44273 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44274 - port->count);
44275 - port->count = 0;
44276 + atomic_read(&port->count));
44277 + atomic_set(&port->count, 0);
44278 }
44279
44280 - if (port->count) {
44281 + if (atomic_read(&port->count)) {
44282 spin_unlock_irqrestore(&port->lock, flags);
44283 if (port->ops->drop)
44284 port->ops->drop(port);
44285 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44286 {
44287 spin_lock_irq(&port->lock);
44288 if (!tty_hung_up_p(filp))
44289 - ++port->count;
44290 + atomic_inc(&port->count);
44291 spin_unlock_irq(&port->lock);
44292 tty_port_tty_set(port, tty);
44293
44294 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44295 index a9af1b9a..1e08e7f 100644
44296 --- a/drivers/tty/vt/keyboard.c
44297 +++ b/drivers/tty/vt/keyboard.c
44298 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44299 kbd->kbdmode == VC_OFF) &&
44300 value != KVAL(K_SAK))
44301 return; /* SAK is allowed even in raw mode */
44302 +
44303 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44304 + {
44305 + void *func = fn_handler[value];
44306 + if (func == fn_show_state || func == fn_show_ptregs ||
44307 + func == fn_show_mem)
44308 + return;
44309 + }
44310 +#endif
44311 +
44312 fn_handler[value](vc);
44313 }
44314
44315 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44316 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44317 return -EFAULT;
44318
44319 - if (!capable(CAP_SYS_TTY_CONFIG))
44320 - perm = 0;
44321 -
44322 switch (cmd) {
44323 case KDGKBENT:
44324 /* Ensure another thread doesn't free it under us */
44325 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44326 spin_unlock_irqrestore(&kbd_event_lock, flags);
44327 return put_user(val, &user_kbe->kb_value);
44328 case KDSKBENT:
44329 + if (!capable(CAP_SYS_TTY_CONFIG))
44330 + perm = 0;
44331 +
44332 if (!perm)
44333 return -EPERM;
44334 if (!i && v == K_NOSUCHMAP) {
44335 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44336 int i, j, k;
44337 int ret;
44338
44339 - if (!capable(CAP_SYS_TTY_CONFIG))
44340 - perm = 0;
44341 -
44342 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44343 if (!kbs) {
44344 ret = -ENOMEM;
44345 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44346 kfree(kbs);
44347 return ((p && *p) ? -EOVERFLOW : 0);
44348 case KDSKBSENT:
44349 + if (!capable(CAP_SYS_TTY_CONFIG))
44350 + perm = 0;
44351 +
44352 if (!perm) {
44353 ret = -EPERM;
44354 goto reterr;
44355 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44356 index b645c47..a55c182 100644
44357 --- a/drivers/uio/uio.c
44358 +++ b/drivers/uio/uio.c
44359 @@ -25,6 +25,7 @@
44360 #include <linux/kobject.h>
44361 #include <linux/cdev.h>
44362 #include <linux/uio_driver.h>
44363 +#include <asm/local.h>
44364
44365 #define UIO_MAX_DEVICES (1U << MINORBITS)
44366
44367 @@ -32,10 +33,10 @@ struct uio_device {
44368 struct module *owner;
44369 struct device *dev;
44370 int minor;
44371 - atomic_t event;
44372 + atomic_unchecked_t event;
44373 struct fasync_struct *async_queue;
44374 wait_queue_head_t wait;
44375 - int vma_count;
44376 + local_t vma_count;
44377 struct uio_info *info;
44378 struct kobject *map_dir;
44379 struct kobject *portio_dir;
44380 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44381 struct device_attribute *attr, char *buf)
44382 {
44383 struct uio_device *idev = dev_get_drvdata(dev);
44384 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44385 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44386 }
44387
44388 static struct device_attribute uio_class_attributes[] = {
44389 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
44390 {
44391 struct uio_device *idev = info->uio_dev;
44392
44393 - atomic_inc(&idev->event);
44394 + atomic_inc_unchecked(&idev->event);
44395 wake_up_interruptible(&idev->wait);
44396 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44397 }
44398 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44399 }
44400
44401 listener->dev = idev;
44402 - listener->event_count = atomic_read(&idev->event);
44403 + listener->event_count = atomic_read_unchecked(&idev->event);
44404 filep->private_data = listener;
44405
44406 if (idev->info->open) {
44407 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44408 return -EIO;
44409
44410 poll_wait(filep, &idev->wait, wait);
44411 - if (listener->event_count != atomic_read(&idev->event))
44412 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44413 return POLLIN | POLLRDNORM;
44414 return 0;
44415 }
44416 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44417 do {
44418 set_current_state(TASK_INTERRUPTIBLE);
44419
44420 - event_count = atomic_read(&idev->event);
44421 + event_count = atomic_read_unchecked(&idev->event);
44422 if (event_count != listener->event_count) {
44423 if (copy_to_user(buf, &event_count, count))
44424 retval = -EFAULT;
44425 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44426 static void uio_vma_open(struct vm_area_struct *vma)
44427 {
44428 struct uio_device *idev = vma->vm_private_data;
44429 - idev->vma_count++;
44430 + local_inc(&idev->vma_count);
44431 }
44432
44433 static void uio_vma_close(struct vm_area_struct *vma)
44434 {
44435 struct uio_device *idev = vma->vm_private_data;
44436 - idev->vma_count--;
44437 + local_dec(&idev->vma_count);
44438 }
44439
44440 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44441 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
44442 idev->owner = owner;
44443 idev->info = info;
44444 init_waitqueue_head(&idev->wait);
44445 - atomic_set(&idev->event, 0);
44446 + atomic_set_unchecked(&idev->event, 0);
44447
44448 ret = uio_get_minor(idev);
44449 if (ret)
44450 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44451 index 8a7eb77..c00402f 100644
44452 --- a/drivers/usb/atm/cxacru.c
44453 +++ b/drivers/usb/atm/cxacru.c
44454 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44455 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44456 if (ret < 2)
44457 return -EINVAL;
44458 - if (index < 0 || index > 0x7f)
44459 + if (index > 0x7f)
44460 return -EINVAL;
44461 pos += tmp;
44462
44463 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44464 index 35f10bf..6a38a0b 100644
44465 --- a/drivers/usb/atm/usbatm.c
44466 +++ b/drivers/usb/atm/usbatm.c
44467 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44468 if (printk_ratelimit())
44469 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44470 __func__, vpi, vci);
44471 - atomic_inc(&vcc->stats->rx_err);
44472 + atomic_inc_unchecked(&vcc->stats->rx_err);
44473 return;
44474 }
44475
44476 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44477 if (length > ATM_MAX_AAL5_PDU) {
44478 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44479 __func__, length, vcc);
44480 - atomic_inc(&vcc->stats->rx_err);
44481 + atomic_inc_unchecked(&vcc->stats->rx_err);
44482 goto out;
44483 }
44484
44485 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44486 if (sarb->len < pdu_length) {
44487 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44488 __func__, pdu_length, sarb->len, vcc);
44489 - atomic_inc(&vcc->stats->rx_err);
44490 + atomic_inc_unchecked(&vcc->stats->rx_err);
44491 goto out;
44492 }
44493
44494 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44495 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44496 __func__, vcc);
44497 - atomic_inc(&vcc->stats->rx_err);
44498 + atomic_inc_unchecked(&vcc->stats->rx_err);
44499 goto out;
44500 }
44501
44502 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44503 if (printk_ratelimit())
44504 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44505 __func__, length);
44506 - atomic_inc(&vcc->stats->rx_drop);
44507 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44508 goto out;
44509 }
44510
44511 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44512
44513 vcc->push(vcc, skb);
44514
44515 - atomic_inc(&vcc->stats->rx);
44516 + atomic_inc_unchecked(&vcc->stats->rx);
44517 out:
44518 skb_trim(sarb, 0);
44519 }
44520 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44521 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44522
44523 usbatm_pop(vcc, skb);
44524 - atomic_inc(&vcc->stats->tx);
44525 + atomic_inc_unchecked(&vcc->stats->tx);
44526
44527 skb = skb_dequeue(&instance->sndqueue);
44528 }
44529 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44530 if (!left--)
44531 return sprintf(page,
44532 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44533 - atomic_read(&atm_dev->stats.aal5.tx),
44534 - atomic_read(&atm_dev->stats.aal5.tx_err),
44535 - atomic_read(&atm_dev->stats.aal5.rx),
44536 - atomic_read(&atm_dev->stats.aal5.rx_err),
44537 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44538 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44539 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44540 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44541 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44542 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44543
44544 if (!left--) {
44545 if (instance->disconnected)
44546 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44547 index 2a3bbdf..91d72cf 100644
44548 --- a/drivers/usb/core/devices.c
44549 +++ b/drivers/usb/core/devices.c
44550 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44551 * time it gets called.
44552 */
44553 static struct device_connect_event {
44554 - atomic_t count;
44555 + atomic_unchecked_t count;
44556 wait_queue_head_t wait;
44557 } device_event = {
44558 .count = ATOMIC_INIT(1),
44559 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44560
44561 void usbfs_conn_disc_event(void)
44562 {
44563 - atomic_add(2, &device_event.count);
44564 + atomic_add_unchecked(2, &device_event.count);
44565 wake_up(&device_event.wait);
44566 }
44567
44568 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44569
44570 poll_wait(file, &device_event.wait, wait);
44571
44572 - event_count = atomic_read(&device_event.count);
44573 + event_count = atomic_read_unchecked(&device_event.count);
44574 if (file->f_version != event_count) {
44575 file->f_version = event_count;
44576 return POLLIN | POLLRDNORM;
44577 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44578 index f9ec44c..eb5779f 100644
44579 --- a/drivers/usb/core/hcd.c
44580 +++ b/drivers/usb/core/hcd.c
44581 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44582 */
44583 usb_get_urb(urb);
44584 atomic_inc(&urb->use_count);
44585 - atomic_inc(&urb->dev->urbnum);
44586 + atomic_inc_unchecked(&urb->dev->urbnum);
44587 usbmon_urb_submit(&hcd->self, urb);
44588
44589 /* NOTE requirements on root-hub callers (usbfs and the hub
44590 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44591 urb->hcpriv = NULL;
44592 INIT_LIST_HEAD(&urb->urb_list);
44593 atomic_dec(&urb->use_count);
44594 - atomic_dec(&urb->dev->urbnum);
44595 + atomic_dec_unchecked(&urb->dev->urbnum);
44596 if (atomic_read(&urb->reject))
44597 wake_up(&usb_kill_urb_queue);
44598 usb_put_urb(urb);
44599 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44600 index 444d30e..f15c850 100644
44601 --- a/drivers/usb/core/message.c
44602 +++ b/drivers/usb/core/message.c
44603 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44604 * method can wait for it to complete. Since you don't have a handle on the
44605 * URB used, you can't cancel the request.
44606 */
44607 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44608 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44609 __u8 requesttype, __u16 value, __u16 index, void *data,
44610 __u16 size, int timeout)
44611 {
44612 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44613 index 3f81a3d..a3aa993 100644
44614 --- a/drivers/usb/core/sysfs.c
44615 +++ b/drivers/usb/core/sysfs.c
44616 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44617 struct usb_device *udev;
44618
44619 udev = to_usb_device(dev);
44620 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44621 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44622 }
44623 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44624
44625 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44626 index f81b925..78d22ec 100644
44627 --- a/drivers/usb/core/usb.c
44628 +++ b/drivers/usb/core/usb.c
44629 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44630 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44631 dev->state = USB_STATE_ATTACHED;
44632 dev->lpm_disable_count = 1;
44633 - atomic_set(&dev->urbnum, 0);
44634 + atomic_set_unchecked(&dev->urbnum, 0);
44635
44636 INIT_LIST_HEAD(&dev->ep0.urb_list);
44637 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44638 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44639 index 5e29dde..eca992f 100644
44640 --- a/drivers/usb/early/ehci-dbgp.c
44641 +++ b/drivers/usb/early/ehci-dbgp.c
44642 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44643
44644 #ifdef CONFIG_KGDB
44645 static struct kgdb_io kgdbdbgp_io_ops;
44646 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44647 +static struct kgdb_io kgdbdbgp_io_ops_console;
44648 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44649 #else
44650 #define dbgp_kgdb_mode (0)
44651 #endif
44652 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44653 .write_char = kgdbdbgp_write_char,
44654 };
44655
44656 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44657 + .name = "kgdbdbgp",
44658 + .read_char = kgdbdbgp_read_char,
44659 + .write_char = kgdbdbgp_write_char,
44660 + .is_console = 1
44661 +};
44662 +
44663 static int kgdbdbgp_wait_time;
44664
44665 static int __init kgdbdbgp_parse_config(char *str)
44666 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44667 ptr++;
44668 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44669 }
44670 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44671 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44672 + if (early_dbgp_console.index != -1)
44673 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44674 + else
44675 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44676
44677 return 0;
44678 }
44679 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44680 index b369292..9f3ba40 100644
44681 --- a/drivers/usb/gadget/u_serial.c
44682 +++ b/drivers/usb/gadget/u_serial.c
44683 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44684 spin_lock_irq(&port->port_lock);
44685
44686 /* already open? Great. */
44687 - if (port->port.count) {
44688 + if (atomic_read(&port->port.count)) {
44689 status = 0;
44690 - port->port.count++;
44691 + atomic_inc(&port->port.count);
44692
44693 /* currently opening/closing? wait ... */
44694 } else if (port->openclose) {
44695 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44696 tty->driver_data = port;
44697 port->port.tty = tty;
44698
44699 - port->port.count = 1;
44700 + atomic_set(&port->port.count, 1);
44701 port->openclose = false;
44702
44703 /* if connected, start the I/O stream */
44704 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44705
44706 spin_lock_irq(&port->port_lock);
44707
44708 - if (port->port.count != 1) {
44709 - if (port->port.count == 0)
44710 + if (atomic_read(&port->port.count) != 1) {
44711 + if (atomic_read(&port->port.count) == 0)
44712 WARN_ON(1);
44713 else
44714 - --port->port.count;
44715 + atomic_dec(&port->port.count);
44716 goto exit;
44717 }
44718
44719 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44720 * and sleep if necessary
44721 */
44722 port->openclose = true;
44723 - port->port.count = 0;
44724 + atomic_set(&port->port.count, 0);
44725
44726 gser = port->port_usb;
44727 if (gser && gser->disconnect)
44728 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44729 int cond;
44730
44731 spin_lock_irq(&port->port_lock);
44732 - cond = (port->port.count == 0) && !port->openclose;
44733 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44734 spin_unlock_irq(&port->port_lock);
44735 return cond;
44736 }
44737 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44738 /* if it's already open, start I/O ... and notify the serial
44739 * protocol about open/close status (connect/disconnect).
44740 */
44741 - if (port->port.count) {
44742 + if (atomic_read(&port->port.count)) {
44743 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44744 gs_start_io(port);
44745 if (gser->connect)
44746 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44747
44748 port->port_usb = NULL;
44749 gser->ioport = NULL;
44750 - if (port->port.count > 0 || port->openclose) {
44751 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44752 wake_up_interruptible(&port->drain_wait);
44753 if (port->port.tty)
44754 tty_hangup(port->port.tty);
44755 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44756
44757 /* finally, free any unused/unusable I/O buffers */
44758 spin_lock_irqsave(&port->port_lock, flags);
44759 - if (port->port.count == 0 && !port->openclose)
44760 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44761 gs_buf_free(&port->port_write_buf);
44762 gs_free_requests(gser->out, &port->read_pool, NULL);
44763 gs_free_requests(gser->out, &port->read_queue, NULL);
44764 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44765 index 5f3bcd3..bfca43f 100644
44766 --- a/drivers/usb/serial/console.c
44767 +++ b/drivers/usb/serial/console.c
44768 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44769
44770 info->port = port;
44771
44772 - ++port->port.count;
44773 + atomic_inc(&port->port.count);
44774 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44775 if (serial->type->set_termios) {
44776 /*
44777 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44778 }
44779 /* Now that any required fake tty operations are completed restore
44780 * the tty port count */
44781 - --port->port.count;
44782 + atomic_dec(&port->port.count);
44783 /* The console is special in terms of closing the device so
44784 * indicate this port is now acting as a system console. */
44785 port->port.console = 1;
44786 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44787 free_tty:
44788 kfree(tty);
44789 reset_open_count:
44790 - port->port.count = 0;
44791 + atomic_set(&port->port.count, 0);
44792 usb_autopm_put_interface(serial->interface);
44793 error_get_interface:
44794 usb_serial_put(serial);
44795 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44796 index 6c3586a..a94e621 100644
44797 --- a/drivers/usb/storage/realtek_cr.c
44798 +++ b/drivers/usb/storage/realtek_cr.c
44799 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44800
44801 buf = kmalloc(len, GFP_NOIO);
44802 if (buf == NULL)
44803 - return USB_STOR_TRANSPORT_ERROR;
44804 + return -ENOMEM;
44805
44806 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44807
44808 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44809 index 75f70f0..d467e1a 100644
44810 --- a/drivers/usb/storage/usb.h
44811 +++ b/drivers/usb/storage/usb.h
44812 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44813 __u8 useProtocol;
44814 __u8 useTransport;
44815 int (*initFunction)(struct us_data *);
44816 -};
44817 +} __do_const;
44818
44819
44820 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44821 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44822 index d6bea3e..60b250e 100644
44823 --- a/drivers/usb/wusbcore/wa-hc.h
44824 +++ b/drivers/usb/wusbcore/wa-hc.h
44825 @@ -192,7 +192,7 @@ struct wahc {
44826 struct list_head xfer_delayed_list;
44827 spinlock_t xfer_list_lock;
44828 struct work_struct xfer_work;
44829 - atomic_t xfer_id_count;
44830 + atomic_unchecked_t xfer_id_count;
44831 };
44832
44833
44834 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44835 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44836 spin_lock_init(&wa->xfer_list_lock);
44837 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44838 - atomic_set(&wa->xfer_id_count, 1);
44839 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44840 }
44841
44842 /**
44843 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44844 index 6ef94bc..1b41265 100644
44845 --- a/drivers/usb/wusbcore/wa-xfer.c
44846 +++ b/drivers/usb/wusbcore/wa-xfer.c
44847 @@ -296,7 +296,7 @@ out:
44848 */
44849 static void wa_xfer_id_init(struct wa_xfer *xfer)
44850 {
44851 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44852 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44853 }
44854
44855 /*
44856 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44857 index 8c55011..eed4ae1a 100644
44858 --- a/drivers/video/aty/aty128fb.c
44859 +++ b/drivers/video/aty/aty128fb.c
44860 @@ -149,7 +149,7 @@ enum {
44861 };
44862
44863 /* Must match above enum */
44864 -static char * const r128_family[] = {
44865 +static const char * const r128_family[] = {
44866 "AGP",
44867 "PCI",
44868 "PRO AGP",
44869 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44870 index 4f27fdc..d3537e6 100644
44871 --- a/drivers/video/aty/atyfb_base.c
44872 +++ b/drivers/video/aty/atyfb_base.c
44873 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44874 par->accel_flags = var->accel_flags; /* hack */
44875
44876 if (var->accel_flags) {
44877 - info->fbops->fb_sync = atyfb_sync;
44878 + pax_open_kernel();
44879 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44880 + pax_close_kernel();
44881 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44882 } else {
44883 - info->fbops->fb_sync = NULL;
44884 + pax_open_kernel();
44885 + *(void **)&info->fbops->fb_sync = NULL;
44886 + pax_close_kernel();
44887 info->flags |= FBINFO_HWACCEL_DISABLED;
44888 }
44889
44890 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44891 index 95ec042..e6affdd 100644
44892 --- a/drivers/video/aty/mach64_cursor.c
44893 +++ b/drivers/video/aty/mach64_cursor.c
44894 @@ -7,6 +7,7 @@
44895 #include <linux/string.h>
44896
44897 #include <asm/io.h>
44898 +#include <asm/pgtable.h>
44899
44900 #ifdef __sparc__
44901 #include <asm/fbio.h>
44902 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44903 info->sprite.buf_align = 16; /* and 64 lines tall. */
44904 info->sprite.flags = FB_PIXMAP_IO;
44905
44906 - info->fbops->fb_cursor = atyfb_cursor;
44907 + pax_open_kernel();
44908 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44909 + pax_close_kernel();
44910
44911 return 0;
44912 }
44913 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44914 index 6c5ed6b..b727c88 100644
44915 --- a/drivers/video/backlight/kb3886_bl.c
44916 +++ b/drivers/video/backlight/kb3886_bl.c
44917 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44918 static unsigned long kb3886bl_flags;
44919 #define KB3886BL_SUSPENDED 0x01
44920
44921 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44922 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44923 {
44924 .ident = "Sahara Touch-iT",
44925 .matches = {
44926 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44927 index 900aa4e..6d49418 100644
44928 --- a/drivers/video/fb_defio.c
44929 +++ b/drivers/video/fb_defio.c
44930 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44931
44932 BUG_ON(!fbdefio);
44933 mutex_init(&fbdefio->lock);
44934 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44935 + pax_open_kernel();
44936 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44937 + pax_close_kernel();
44938 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44939 INIT_LIST_HEAD(&fbdefio->pagelist);
44940 if (fbdefio->delay == 0) /* set a default of 1 s */
44941 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44942 page->mapping = NULL;
44943 }
44944
44945 - info->fbops->fb_mmap = NULL;
44946 + *(void **)&info->fbops->fb_mmap = NULL;
44947 mutex_destroy(&fbdefio->lock);
44948 }
44949 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44950 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44951 index 5c3960d..15cf8fc 100644
44952 --- a/drivers/video/fbcmap.c
44953 +++ b/drivers/video/fbcmap.c
44954 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44955 rc = -ENODEV;
44956 goto out;
44957 }
44958 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44959 - !info->fbops->fb_setcmap)) {
44960 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44961 rc = -EINVAL;
44962 goto out1;
44963 }
44964 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44965 index 86291dc..7cc5962 100644
44966 --- a/drivers/video/fbmem.c
44967 +++ b/drivers/video/fbmem.c
44968 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44969 image->dx += image->width + 8;
44970 }
44971 } else if (rotate == FB_ROTATE_UD) {
44972 - for (x = 0; x < num && image->dx >= 0; x++) {
44973 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44974 info->fbops->fb_imageblit(info, image);
44975 image->dx -= image->width + 8;
44976 }
44977 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44978 image->dy += image->height + 8;
44979 }
44980 } else if (rotate == FB_ROTATE_CCW) {
44981 - for (x = 0; x < num && image->dy >= 0; x++) {
44982 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44983 info->fbops->fb_imageblit(info, image);
44984 image->dy -= image->height + 8;
44985 }
44986 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44987 return -EFAULT;
44988 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44989 return -EINVAL;
44990 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44991 + if (con2fb.framebuffer >= FB_MAX)
44992 return -EINVAL;
44993 if (!registered_fb[con2fb.framebuffer])
44994 request_module("fb%d", con2fb.framebuffer);
44995 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44996 index 7672d2e..b56437f 100644
44997 --- a/drivers/video/i810/i810_accel.c
44998 +++ b/drivers/video/i810/i810_accel.c
44999 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45000 }
45001 }
45002 printk("ringbuffer lockup!!!\n");
45003 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45004 i810_report_error(mmio);
45005 par->dev_flags |= LOCKUP;
45006 info->pixmap.scan_align = 1;
45007 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45008 index 3c14e43..eafa544 100644
45009 --- a/drivers/video/logo/logo_linux_clut224.ppm
45010 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45011 @@ -1,1604 +1,1123 @@
45012 P3
45013 -# Standard 224-color Linux logo
45014 80 80
45015 255
45016 - 0 0 0 0 0 0 0 0 0 0 0 0
45017 - 0 0 0 0 0 0 0 0 0 0 0 0
45018 - 0 0 0 0 0 0 0 0 0 0 0 0
45019 - 0 0 0 0 0 0 0 0 0 0 0 0
45020 - 0 0 0 0 0 0 0 0 0 0 0 0
45021 - 0 0 0 0 0 0 0 0 0 0 0 0
45022 - 0 0 0 0 0 0 0 0 0 0 0 0
45023 - 0 0 0 0 0 0 0 0 0 0 0 0
45024 - 0 0 0 0 0 0 0 0 0 0 0 0
45025 - 6 6 6 6 6 6 10 10 10 10 10 10
45026 - 10 10 10 6 6 6 6 6 6 6 6 6
45027 - 0 0 0 0 0 0 0 0 0 0 0 0
45028 - 0 0 0 0 0 0 0 0 0 0 0 0
45029 - 0 0 0 0 0 0 0 0 0 0 0 0
45030 - 0 0 0 0 0 0 0 0 0 0 0 0
45031 - 0 0 0 0 0 0 0 0 0 0 0 0
45032 - 0 0 0 0 0 0 0 0 0 0 0 0
45033 - 0 0 0 0 0 0 0 0 0 0 0 0
45034 - 0 0 0 0 0 0 0 0 0 0 0 0
45035 - 0 0 0 0 0 0 0 0 0 0 0 0
45036 - 0 0 0 0 0 0 0 0 0 0 0 0
45037 - 0 0 0 0 0 0 0 0 0 0 0 0
45038 - 0 0 0 0 0 0 0 0 0 0 0 0
45039 - 0 0 0 0 0 0 0 0 0 0 0 0
45040 - 0 0 0 0 0 0 0 0 0 0 0 0
45041 - 0 0 0 0 0 0 0 0 0 0 0 0
45042 - 0 0 0 0 0 0 0 0 0 0 0 0
45043 - 0 0 0 0 0 0 0 0 0 0 0 0
45044 - 0 0 0 6 6 6 10 10 10 14 14 14
45045 - 22 22 22 26 26 26 30 30 30 34 34 34
45046 - 30 30 30 30 30 30 26 26 26 18 18 18
45047 - 14 14 14 10 10 10 6 6 6 0 0 0
45048 - 0 0 0 0 0 0 0 0 0 0 0 0
45049 - 0 0 0 0 0 0 0 0 0 0 0 0
45050 - 0 0 0 0 0 0 0 0 0 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 1 0 0 1 0 0 0
45058 - 0 0 0 0 0 0 0 0 0 0 0 0
45059 - 0 0 0 0 0 0 0 0 0 0 0 0
45060 - 0 0 0 0 0 0 0 0 0 0 0 0
45061 - 0 0 0 0 0 0 0 0 0 0 0 0
45062 - 0 0 0 0 0 0 0 0 0 0 0 0
45063 - 0 0 0 0 0 0 0 0 0 0 0 0
45064 - 6 6 6 14 14 14 26 26 26 42 42 42
45065 - 54 54 54 66 66 66 78 78 78 78 78 78
45066 - 78 78 78 74 74 74 66 66 66 54 54 54
45067 - 42 42 42 26 26 26 18 18 18 10 10 10
45068 - 6 6 6 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 0 0 0 0
45075 - 0 0 0 0 0 0 0 0 0 0 0 0
45076 - 0 0 0 0 0 0 0 0 0 0 0 0
45077 - 0 0 1 0 0 0 0 0 0 0 0 0
45078 - 0 0 0 0 0 0 0 0 0 0 0 0
45079 - 0 0 0 0 0 0 0 0 0 0 0 0
45080 - 0 0 0 0 0 0 0 0 0 0 0 0
45081 - 0 0 0 0 0 0 0 0 0 0 0 0
45082 - 0 0 0 0 0 0 0 0 0 0 0 0
45083 - 0 0 0 0 0 0 0 0 0 10 10 10
45084 - 22 22 22 42 42 42 66 66 66 86 86 86
45085 - 66 66 66 38 38 38 38 38 38 22 22 22
45086 - 26 26 26 34 34 34 54 54 54 66 66 66
45087 - 86 86 86 70 70 70 46 46 46 26 26 26
45088 - 14 14 14 6 6 6 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 0 0 0 0
45095 - 0 0 0 0 0 0 0 0 0 0 0 0
45096 - 0 0 0 0 0 0 0 0 0 0 0 0
45097 - 0 0 1 0 0 1 0 0 1 0 0 0
45098 - 0 0 0 0 0 0 0 0 0 0 0 0
45099 - 0 0 0 0 0 0 0 0 0 0 0 0
45100 - 0 0 0 0 0 0 0 0 0 0 0 0
45101 - 0 0 0 0 0 0 0 0 0 0 0 0
45102 - 0 0 0 0 0 0 0 0 0 0 0 0
45103 - 0 0 0 0 0 0 10 10 10 26 26 26
45104 - 50 50 50 82 82 82 58 58 58 6 6 6
45105 - 2 2 6 2 2 6 2 2 6 2 2 6
45106 - 2 2 6 2 2 6 2 2 6 2 2 6
45107 - 6 6 6 54 54 54 86 86 86 66 66 66
45108 - 38 38 38 18 18 18 6 6 6 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 0 0 0 0
45115 - 0 0 0 0 0 0 0 0 0 0 0 0
45116 - 0 0 0 0 0 0 0 0 0 0 0 0
45117 - 0 0 0 0 0 0 0 0 0 0 0 0
45118 - 0 0 0 0 0 0 0 0 0 0 0 0
45119 - 0 0 0 0 0 0 0 0 0 0 0 0
45120 - 0 0 0 0 0 0 0 0 0 0 0 0
45121 - 0 0 0 0 0 0 0 0 0 0 0 0
45122 - 0 0 0 0 0 0 0 0 0 0 0 0
45123 - 0 0 0 6 6 6 22 22 22 50 50 50
45124 - 78 78 78 34 34 34 2 2 6 2 2 6
45125 - 2 2 6 2 2 6 2 2 6 2 2 6
45126 - 2 2 6 2 2 6 2 2 6 2 2 6
45127 - 2 2 6 2 2 6 6 6 6 70 70 70
45128 - 78 78 78 46 46 46 22 22 22 6 6 6
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 1 0 0 1 0 0 1 0 0 0
45138 - 0 0 0 0 0 0 0 0 0 0 0 0
45139 - 0 0 0 0 0 0 0 0 0 0 0 0
45140 - 0 0 0 0 0 0 0 0 0 0 0 0
45141 - 0 0 0 0 0 0 0 0 0 0 0 0
45142 - 0 0 0 0 0 0 0 0 0 0 0 0
45143 - 6 6 6 18 18 18 42 42 42 82 82 82
45144 - 26 26 26 2 2 6 2 2 6 2 2 6
45145 - 2 2 6 2 2 6 2 2 6 2 2 6
45146 - 2 2 6 2 2 6 2 2 6 14 14 14
45147 - 46 46 46 34 34 34 6 6 6 2 2 6
45148 - 42 42 42 78 78 78 42 42 42 18 18 18
45149 - 6 6 6 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 1 0 0 0 0 0 1 0 0 0
45158 - 0 0 0 0 0 0 0 0 0 0 0 0
45159 - 0 0 0 0 0 0 0 0 0 0 0 0
45160 - 0 0 0 0 0 0 0 0 0 0 0 0
45161 - 0 0 0 0 0 0 0 0 0 0 0 0
45162 - 0 0 0 0 0 0 0 0 0 0 0 0
45163 - 10 10 10 30 30 30 66 66 66 58 58 58
45164 - 2 2 6 2 2 6 2 2 6 2 2 6
45165 - 2 2 6 2 2 6 2 2 6 2 2 6
45166 - 2 2 6 2 2 6 2 2 6 26 26 26
45167 - 86 86 86 101 101 101 46 46 46 10 10 10
45168 - 2 2 6 58 58 58 70 70 70 34 34 34
45169 - 10 10 10 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 1 0 0 1 0 0 1 0 0 0
45178 - 0 0 0 0 0 0 0 0 0 0 0 0
45179 - 0 0 0 0 0 0 0 0 0 0 0 0
45180 - 0 0 0 0 0 0 0 0 0 0 0 0
45181 - 0 0 0 0 0 0 0 0 0 0 0 0
45182 - 0 0 0 0 0 0 0 0 0 0 0 0
45183 - 14 14 14 42 42 42 86 86 86 10 10 10
45184 - 2 2 6 2 2 6 2 2 6 2 2 6
45185 - 2 2 6 2 2 6 2 2 6 2 2 6
45186 - 2 2 6 2 2 6 2 2 6 30 30 30
45187 - 94 94 94 94 94 94 58 58 58 26 26 26
45188 - 2 2 6 6 6 6 78 78 78 54 54 54
45189 - 22 22 22 6 6 6 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 0 0 0
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 0 0 0 0 0 0 0 0 0 6 6 6
45203 - 22 22 22 62 62 62 62 62 62 2 2 6
45204 - 2 2 6 2 2 6 2 2 6 2 2 6
45205 - 2 2 6 2 2 6 2 2 6 2 2 6
45206 - 2 2 6 2 2 6 2 2 6 26 26 26
45207 - 54 54 54 38 38 38 18 18 18 10 10 10
45208 - 2 2 6 2 2 6 34 34 34 82 82 82
45209 - 38 38 38 14 14 14 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 1 0 0 1 0 0 0
45218 - 0 0 0 0 0 0 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 6 6 6
45223 - 30 30 30 78 78 78 30 30 30 2 2 6
45224 - 2 2 6 2 2 6 2 2 6 2 2 6
45225 - 2 2 6 2 2 6 2 2 6 2 2 6
45226 - 2 2 6 2 2 6 2 2 6 10 10 10
45227 - 10 10 10 2 2 6 2 2 6 2 2 6
45228 - 2 2 6 2 2 6 2 2 6 78 78 78
45229 - 50 50 50 18 18 18 6 6 6 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 1 0 0 0 0 0 0 0 0 0
45238 - 0 0 0 0 0 0 0 0 0 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 10 10 10
45243 - 38 38 38 86 86 86 14 14 14 2 2 6
45244 - 2 2 6 2 2 6 2 2 6 2 2 6
45245 - 2 2 6 2 2 6 2 2 6 2 2 6
45246 - 2 2 6 2 2 6 2 2 6 2 2 6
45247 - 2 2 6 2 2 6 2 2 6 2 2 6
45248 - 2 2 6 2 2 6 2 2 6 54 54 54
45249 - 66 66 66 26 26 26 6 6 6 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 1 0 0 1 0 0 0
45258 - 0 0 0 0 0 0 0 0 0 0 0 0
45259 - 0 0 0 0 0 0 0 0 0 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 0 0 0 0 0 0 0 14 14 14
45263 - 42 42 42 82 82 82 2 2 6 2 2 6
45264 - 2 2 6 6 6 6 10 10 10 2 2 6
45265 - 2 2 6 2 2 6 2 2 6 2 2 6
45266 - 2 2 6 2 2 6 2 2 6 6 6 6
45267 - 14 14 14 10 10 10 2 2 6 2 2 6
45268 - 2 2 6 2 2 6 2 2 6 18 18 18
45269 - 82 82 82 34 34 34 10 10 10 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 1 0 0 0 0 0 0 0 0 0
45278 - 0 0 0 0 0 0 0 0 0 0 0 0
45279 - 0 0 0 0 0 0 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 0 0 0 0 0 0 0 14 14 14
45283 - 46 46 46 86 86 86 2 2 6 2 2 6
45284 - 6 6 6 6 6 6 22 22 22 34 34 34
45285 - 6 6 6 2 2 6 2 2 6 2 2 6
45286 - 2 2 6 2 2 6 18 18 18 34 34 34
45287 - 10 10 10 50 50 50 22 22 22 2 2 6
45288 - 2 2 6 2 2 6 2 2 6 10 10 10
45289 - 86 86 86 42 42 42 14 14 14 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 1 0 0 1 0 0 1 0 0 0
45298 - 0 0 0 0 0 0 0 0 0 0 0 0
45299 - 0 0 0 0 0 0 0 0 0 0 0 0
45300 - 0 0 0 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 14 14 14
45303 - 46 46 46 86 86 86 2 2 6 2 2 6
45304 - 38 38 38 116 116 116 94 94 94 22 22 22
45305 - 22 22 22 2 2 6 2 2 6 2 2 6
45306 - 14 14 14 86 86 86 138 138 138 162 162 162
45307 -154 154 154 38 38 38 26 26 26 6 6 6
45308 - 2 2 6 2 2 6 2 2 6 2 2 6
45309 - 86 86 86 46 46 46 14 14 14 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 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 0 0 0
45322 - 0 0 0 0 0 0 0 0 0 14 14 14
45323 - 46 46 46 86 86 86 2 2 6 14 14 14
45324 -134 134 134 198 198 198 195 195 195 116 116 116
45325 - 10 10 10 2 2 6 2 2 6 6 6 6
45326 -101 98 89 187 187 187 210 210 210 218 218 218
45327 -214 214 214 134 134 134 14 14 14 6 6 6
45328 - 2 2 6 2 2 6 2 2 6 2 2 6
45329 - 86 86 86 50 50 50 18 18 18 6 6 6
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 1 0 0 0
45337 - 0 0 1 0 0 1 0 0 1 0 0 0
45338 - 0 0 0 0 0 0 0 0 0 0 0 0
45339 - 0 0 0 0 0 0 0 0 0 0 0 0
45340 - 0 0 0 0 0 0 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 0 0 0
45342 - 0 0 0 0 0 0 0 0 0 14 14 14
45343 - 46 46 46 86 86 86 2 2 6 54 54 54
45344 -218 218 218 195 195 195 226 226 226 246 246 246
45345 - 58 58 58 2 2 6 2 2 6 30 30 30
45346 -210 210 210 253 253 253 174 174 174 123 123 123
45347 -221 221 221 234 234 234 74 74 74 2 2 6
45348 - 2 2 6 2 2 6 2 2 6 2 2 6
45349 - 70 70 70 58 58 58 22 22 22 6 6 6
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 0 0 0
45360 - 0 0 0 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 0 0 0 0 14 14 14
45363 - 46 46 46 82 82 82 2 2 6 106 106 106
45364 -170 170 170 26 26 26 86 86 86 226 226 226
45365 -123 123 123 10 10 10 14 14 14 46 46 46
45366 -231 231 231 190 190 190 6 6 6 70 70 70
45367 - 90 90 90 238 238 238 158 158 158 2 2 6
45368 - 2 2 6 2 2 6 2 2 6 2 2 6
45369 - 70 70 70 58 58 58 22 22 22 6 6 6
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 1 0 0 0
45377 - 0 0 1 0 0 1 0 0 1 0 0 0
45378 - 0 0 0 0 0 0 0 0 0 0 0 0
45379 - 0 0 0 0 0 0 0 0 0 0 0 0
45380 - 0 0 0 0 0 0 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 0 0 0 0 0 0 0 14 14 14
45383 - 42 42 42 86 86 86 6 6 6 116 116 116
45384 -106 106 106 6 6 6 70 70 70 149 149 149
45385 -128 128 128 18 18 18 38 38 38 54 54 54
45386 -221 221 221 106 106 106 2 2 6 14 14 14
45387 - 46 46 46 190 190 190 198 198 198 2 2 6
45388 - 2 2 6 2 2 6 2 2 6 2 2 6
45389 - 74 74 74 62 62 62 22 22 22 6 6 6
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 1 0 0 0
45397 - 0 0 1 0 0 0 0 0 1 0 0 0
45398 - 0 0 0 0 0 0 0 0 0 0 0 0
45399 - 0 0 0 0 0 0 0 0 0 0 0 0
45400 - 0 0 0 0 0 0 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 0 0 0 0 14 14 14
45403 - 42 42 42 94 94 94 14 14 14 101 101 101
45404 -128 128 128 2 2 6 18 18 18 116 116 116
45405 -118 98 46 121 92 8 121 92 8 98 78 10
45406 -162 162 162 106 106 106 2 2 6 2 2 6
45407 - 2 2 6 195 195 195 195 195 195 6 6 6
45408 - 2 2 6 2 2 6 2 2 6 2 2 6
45409 - 74 74 74 62 62 62 22 22 22 6 6 6
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 1 0 0 1
45417 - 0 0 1 0 0 0 0 0 1 0 0 0
45418 - 0 0 0 0 0 0 0 0 0 0 0 0
45419 - 0 0 0 0 0 0 0 0 0 0 0 0
45420 - 0 0 0 0 0 0 0 0 0 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 10 10 10
45423 - 38 38 38 90 90 90 14 14 14 58 58 58
45424 -210 210 210 26 26 26 54 38 6 154 114 10
45425 -226 170 11 236 186 11 225 175 15 184 144 12
45426 -215 174 15 175 146 61 37 26 9 2 2 6
45427 - 70 70 70 246 246 246 138 138 138 2 2 6
45428 - 2 2 6 2 2 6 2 2 6 2 2 6
45429 - 70 70 70 66 66 66 26 26 26 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45440 - 0 0 0 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 0 0 0 0 10 10 10
45443 - 38 38 38 86 86 86 14 14 14 10 10 10
45444 -195 195 195 188 164 115 192 133 9 225 175 15
45445 -239 182 13 234 190 10 232 195 16 232 200 30
45446 -245 207 45 241 208 19 232 195 16 184 144 12
45447 -218 194 134 211 206 186 42 42 42 2 2 6
45448 - 2 2 6 2 2 6 2 2 6 2 2 6
45449 - 50 50 50 74 74 74 30 30 30 6 6 6
45450 - 0 0 0 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45460 - 0 0 0 0 0 0 0 0 0 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 10 10 10
45463 - 34 34 34 86 86 86 14 14 14 2 2 6
45464 -121 87 25 192 133 9 219 162 10 239 182 13
45465 -236 186 11 232 195 16 241 208 19 244 214 54
45466 -246 218 60 246 218 38 246 215 20 241 208 19
45467 -241 208 19 226 184 13 121 87 25 2 2 6
45468 - 2 2 6 2 2 6 2 2 6 2 2 6
45469 - 50 50 50 82 82 82 34 34 34 10 10 10
45470 - 0 0 0 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45480 - 0 0 0 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 0 0 0 0 0 0 0 10 10 10
45483 - 34 34 34 82 82 82 30 30 30 61 42 6
45484 -180 123 7 206 145 10 230 174 11 239 182 13
45485 -234 190 10 238 202 15 241 208 19 246 218 74
45486 -246 218 38 246 215 20 246 215 20 246 215 20
45487 -226 184 13 215 174 15 184 144 12 6 6 6
45488 - 2 2 6 2 2 6 2 2 6 2 2 6
45489 - 26 26 26 94 94 94 42 42 42 14 14 14
45490 - 0 0 0 0 0 0 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 0 0 0
45499 - 0 0 0 0 0 0 0 0 0 0 0 0
45500 - 0 0 0 0 0 0 0 0 0 0 0 0
45501 - 0 0 0 0 0 0 0 0 0 0 0 0
45502 - 0 0 0 0 0 0 0 0 0 10 10 10
45503 - 30 30 30 78 78 78 50 50 50 104 69 6
45504 -192 133 9 216 158 10 236 178 12 236 186 11
45505 -232 195 16 241 208 19 244 214 54 245 215 43
45506 -246 215 20 246 215 20 241 208 19 198 155 10
45507 -200 144 11 216 158 10 156 118 10 2 2 6
45508 - 2 2 6 2 2 6 2 2 6 2 2 6
45509 - 6 6 6 90 90 90 54 54 54 18 18 18
45510 - 6 6 6 0 0 0 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 0 0 0
45519 - 0 0 0 0 0 0 0 0 0 0 0 0
45520 - 0 0 0 0 0 0 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 0 0 0 0
45522 - 0 0 0 0 0 0 0 0 0 10 10 10
45523 - 30 30 30 78 78 78 46 46 46 22 22 22
45524 -137 92 6 210 162 10 239 182 13 238 190 10
45525 -238 202 15 241 208 19 246 215 20 246 215 20
45526 -241 208 19 203 166 17 185 133 11 210 150 10
45527 -216 158 10 210 150 10 102 78 10 2 2 6
45528 - 6 6 6 54 54 54 14 14 14 2 2 6
45529 - 2 2 6 62 62 62 74 74 74 30 30 30
45530 - 10 10 10 0 0 0 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 0 0 0
45539 - 0 0 0 0 0 0 0 0 0 0 0 0
45540 - 0 0 0 0 0 0 0 0 0 0 0 0
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 10 10 10
45543 - 34 34 34 78 78 78 50 50 50 6 6 6
45544 - 94 70 30 139 102 15 190 146 13 226 184 13
45545 -232 200 30 232 195 16 215 174 15 190 146 13
45546 -168 122 10 192 133 9 210 150 10 213 154 11
45547 -202 150 34 182 157 106 101 98 89 2 2 6
45548 - 2 2 6 78 78 78 116 116 116 58 58 58
45549 - 2 2 6 22 22 22 90 90 90 46 46 46
45550 - 18 18 18 6 6 6 0 0 0 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 0 0 0 0 0 0
45559 - 0 0 0 0 0 0 0 0 0 0 0 0
45560 - 0 0 0 0 0 0 0 0 0 0 0 0
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 0 0 0 10 10 10
45563 - 38 38 38 86 86 86 50 50 50 6 6 6
45564 -128 128 128 174 154 114 156 107 11 168 122 10
45565 -198 155 10 184 144 12 197 138 11 200 144 11
45566 -206 145 10 206 145 10 197 138 11 188 164 115
45567 -195 195 195 198 198 198 174 174 174 14 14 14
45568 - 2 2 6 22 22 22 116 116 116 116 116 116
45569 - 22 22 22 2 2 6 74 74 74 70 70 70
45570 - 30 30 30 10 10 10 0 0 0 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 0 0 0 0 0 0
45579 - 0 0 0 0 0 0 0 0 0 0 0 0
45580 - 0 0 0 0 0 0 0 0 0 0 0 0
45581 - 0 0 0 0 0 0 0 0 0 0 0 0
45582 - 0 0 0 0 0 0 6 6 6 18 18 18
45583 - 50 50 50 101 101 101 26 26 26 10 10 10
45584 -138 138 138 190 190 190 174 154 114 156 107 11
45585 -197 138 11 200 144 11 197 138 11 192 133 9
45586 -180 123 7 190 142 34 190 178 144 187 187 187
45587 -202 202 202 221 221 221 214 214 214 66 66 66
45588 - 2 2 6 2 2 6 50 50 50 62 62 62
45589 - 6 6 6 2 2 6 10 10 10 90 90 90
45590 - 50 50 50 18 18 18 6 6 6 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 0 0 0 0 0 0 0 0 0
45599 - 0 0 0 0 0 0 0 0 0 0 0 0
45600 - 0 0 0 0 0 0 0 0 0 0 0 0
45601 - 0 0 0 0 0 0 0 0 0 0 0 0
45602 - 0 0 0 0 0 0 10 10 10 34 34 34
45603 - 74 74 74 74 74 74 2 2 6 6 6 6
45604 -144 144 144 198 198 198 190 190 190 178 166 146
45605 -154 121 60 156 107 11 156 107 11 168 124 44
45606 -174 154 114 187 187 187 190 190 190 210 210 210
45607 -246 246 246 253 253 253 253 253 253 182 182 182
45608 - 6 6 6 2 2 6 2 2 6 2 2 6
45609 - 2 2 6 2 2 6 2 2 6 62 62 62
45610 - 74 74 74 34 34 34 14 14 14 0 0 0
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 0 0 0 0 0 0 0 0 0
45619 - 0 0 0 0 0 0 0 0 0 0 0 0
45620 - 0 0 0 0 0 0 0 0 0 0 0 0
45621 - 0 0 0 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 10 10 10 22 22 22 54 54 54
45623 - 94 94 94 18 18 18 2 2 6 46 46 46
45624 -234 234 234 221 221 221 190 190 190 190 190 190
45625 -190 190 190 187 187 187 187 187 187 190 190 190
45626 -190 190 190 195 195 195 214 214 214 242 242 242
45627 -253 253 253 253 253 253 253 253 253 253 253 253
45628 - 82 82 82 2 2 6 2 2 6 2 2 6
45629 - 2 2 6 2 2 6 2 2 6 14 14 14
45630 - 86 86 86 54 54 54 22 22 22 6 6 6
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 - 0 0 0 0 0 0 0 0 0 0 0 0
45639 - 0 0 0 0 0 0 0 0 0 0 0 0
45640 - 0 0 0 0 0 0 0 0 0 0 0 0
45641 - 0 0 0 0 0 0 0 0 0 0 0 0
45642 - 6 6 6 18 18 18 46 46 46 90 90 90
45643 - 46 46 46 18 18 18 6 6 6 182 182 182
45644 -253 253 253 246 246 246 206 206 206 190 190 190
45645 -190 190 190 190 190 190 190 190 190 190 190 190
45646 -206 206 206 231 231 231 250 250 250 253 253 253
45647 -253 253 253 253 253 253 253 253 253 253 253 253
45648 -202 202 202 14 14 14 2 2 6 2 2 6
45649 - 2 2 6 2 2 6 2 2 6 2 2 6
45650 - 42 42 42 86 86 86 42 42 42 18 18 18
45651 - 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45659 - 0 0 0 0 0 0 0 0 0 0 0 0
45660 - 0 0 0 0 0 0 0 0 0 0 0 0
45661 - 0 0 0 0 0 0 0 0 0 6 6 6
45662 - 14 14 14 38 38 38 74 74 74 66 66 66
45663 - 2 2 6 6 6 6 90 90 90 250 250 250
45664 -253 253 253 253 253 253 238 238 238 198 198 198
45665 -190 190 190 190 190 190 195 195 195 221 221 221
45666 -246 246 246 253 253 253 253 253 253 253 253 253
45667 -253 253 253 253 253 253 253 253 253 253 253 253
45668 -253 253 253 82 82 82 2 2 6 2 2 6
45669 - 2 2 6 2 2 6 2 2 6 2 2 6
45670 - 2 2 6 78 78 78 70 70 70 34 34 34
45671 - 14 14 14 6 6 6 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 0 0 0
45678 - 0 0 0 0 0 0 0 0 0 0 0 0
45679 - 0 0 0 0 0 0 0 0 0 0 0 0
45680 - 0 0 0 0 0 0 0 0 0 0 0 0
45681 - 0 0 0 0 0 0 0 0 0 14 14 14
45682 - 34 34 34 66 66 66 78 78 78 6 6 6
45683 - 2 2 6 18 18 18 218 218 218 253 253 253
45684 -253 253 253 253 253 253 253 253 253 246 246 246
45685 -226 226 226 231 231 231 246 246 246 253 253 253
45686 -253 253 253 253 253 253 253 253 253 253 253 253
45687 -253 253 253 253 253 253 253 253 253 253 253 253
45688 -253 253 253 178 178 178 2 2 6 2 2 6
45689 - 2 2 6 2 2 6 2 2 6 2 2 6
45690 - 2 2 6 18 18 18 90 90 90 62 62 62
45691 - 30 30 30 10 10 10 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 0 0 0
45698 - 0 0 0 0 0 0 0 0 0 0 0 0
45699 - 0 0 0 0 0 0 0 0 0 0 0 0
45700 - 0 0 0 0 0 0 0 0 0 0 0 0
45701 - 0 0 0 0 0 0 10 10 10 26 26 26
45702 - 58 58 58 90 90 90 18 18 18 2 2 6
45703 - 2 2 6 110 110 110 253 253 253 253 253 253
45704 -253 253 253 253 253 253 253 253 253 253 253 253
45705 -250 250 250 253 253 253 253 253 253 253 253 253
45706 -253 253 253 253 253 253 253 253 253 253 253 253
45707 -253 253 253 253 253 253 253 253 253 253 253 253
45708 -253 253 253 231 231 231 18 18 18 2 2 6
45709 - 2 2 6 2 2 6 2 2 6 2 2 6
45710 - 2 2 6 2 2 6 18 18 18 94 94 94
45711 - 54 54 54 26 26 26 10 10 10 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 0 0 0
45718 - 0 0 0 0 0 0 0 0 0 0 0 0
45719 - 0 0 0 0 0 0 0 0 0 0 0 0
45720 - 0 0 0 0 0 0 0 0 0 0 0 0
45721 - 0 0 0 6 6 6 22 22 22 50 50 50
45722 - 90 90 90 26 26 26 2 2 6 2 2 6
45723 - 14 14 14 195 195 195 250 250 250 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 253 253 253 253 253 253
45728 -250 250 250 242 242 242 54 54 54 2 2 6
45729 - 2 2 6 2 2 6 2 2 6 2 2 6
45730 - 2 2 6 2 2 6 2 2 6 38 38 38
45731 - 86 86 86 50 50 50 22 22 22 6 6 6
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 0 0 0 0 0 0
45738 - 0 0 0 0 0 0 0 0 0 0 0 0
45739 - 0 0 0 0 0 0 0 0 0 0 0 0
45740 - 0 0 0 0 0 0 0 0 0 0 0 0
45741 - 6 6 6 14 14 14 38 38 38 82 82 82
45742 - 34 34 34 2 2 6 2 2 6 2 2 6
45743 - 42 42 42 195 195 195 246 246 246 253 253 253
45744 -253 253 253 253 253 253 253 253 253 250 250 250
45745 -242 242 242 242 242 242 250 250 250 253 253 253
45746 -253 253 253 253 253 253 253 253 253 253 253 253
45747 -253 253 253 250 250 250 246 246 246 238 238 238
45748 -226 226 226 231 231 231 101 101 101 6 6 6
45749 - 2 2 6 2 2 6 2 2 6 2 2 6
45750 - 2 2 6 2 2 6 2 2 6 2 2 6
45751 - 38 38 38 82 82 82 42 42 42 14 14 14
45752 - 6 6 6 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 0 0 0 0 0 0
45758 - 0 0 0 0 0 0 0 0 0 0 0 0
45759 - 0 0 0 0 0 0 0 0 0 0 0 0
45760 - 0 0 0 0 0 0 0 0 0 0 0 0
45761 - 10 10 10 26 26 26 62 62 62 66 66 66
45762 - 2 2 6 2 2 6 2 2 6 6 6 6
45763 - 70 70 70 170 170 170 206 206 206 234 234 234
45764 -246 246 246 250 250 250 250 250 250 238 238 238
45765 -226 226 226 231 231 231 238 238 238 250 250 250
45766 -250 250 250 250 250 250 246 246 246 231 231 231
45767 -214 214 214 206 206 206 202 202 202 202 202 202
45768 -198 198 198 202 202 202 182 182 182 18 18 18
45769 - 2 2 6 2 2 6 2 2 6 2 2 6
45770 - 2 2 6 2 2 6 2 2 6 2 2 6
45771 - 2 2 6 62 62 62 66 66 66 30 30 30
45772 - 10 10 10 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 0 0 0 0 0 0
45778 - 0 0 0 0 0 0 0 0 0 0 0 0
45779 - 0 0 0 0 0 0 0 0 0 0 0 0
45780 - 0 0 0 0 0 0 0 0 0 0 0 0
45781 - 14 14 14 42 42 42 82 82 82 18 18 18
45782 - 2 2 6 2 2 6 2 2 6 10 10 10
45783 - 94 94 94 182 182 182 218 218 218 242 242 242
45784 -250 250 250 253 253 253 253 253 253 250 250 250
45785 -234 234 234 253 253 253 253 253 253 253 253 253
45786 -253 253 253 253 253 253 253 253 253 246 246 246
45787 -238 238 238 226 226 226 210 210 210 202 202 202
45788 -195 195 195 195 195 195 210 210 210 158 158 158
45789 - 6 6 6 14 14 14 50 50 50 14 14 14
45790 - 2 2 6 2 2 6 2 2 6 2 2 6
45791 - 2 2 6 6 6 6 86 86 86 46 46 46
45792 - 18 18 18 6 6 6 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 0 0 0 0 0 0
45798 - 0 0 0 0 0 0 0 0 0 0 0 0
45799 - 0 0 0 0 0 0 0 0 0 0 0 0
45800 - 0 0 0 0 0 0 0 0 0 6 6 6
45801 - 22 22 22 54 54 54 70 70 70 2 2 6
45802 - 2 2 6 10 10 10 2 2 6 22 22 22
45803 -166 166 166 231 231 231 250 250 250 253 253 253
45804 -253 253 253 253 253 253 253 253 253 250 250 250
45805 -242 242 242 253 253 253 253 253 253 253 253 253
45806 -253 253 253 253 253 253 253 253 253 253 253 253
45807 -253 253 253 253 253 253 253 253 253 246 246 246
45808 -231 231 231 206 206 206 198 198 198 226 226 226
45809 - 94 94 94 2 2 6 6 6 6 38 38 38
45810 - 30 30 30 2 2 6 2 2 6 2 2 6
45811 - 2 2 6 2 2 6 62 62 62 66 66 66
45812 - 26 26 26 10 10 10 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 0 0 0
45817 - 0 0 0 0 0 0 0 0 0 0 0 0
45818 - 0 0 0 0 0 0 0 0 0 0 0 0
45819 - 0 0 0 0 0 0 0 0 0 0 0 0
45820 - 0 0 0 0 0 0 0 0 0 10 10 10
45821 - 30 30 30 74 74 74 50 50 50 2 2 6
45822 - 26 26 26 26 26 26 2 2 6 106 106 106
45823 -238 238 238 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 253 253 253
45827 -253 253 253 253 253 253 253 253 253 253 253 253
45828 -253 253 253 246 246 246 218 218 218 202 202 202
45829 -210 210 210 14 14 14 2 2 6 2 2 6
45830 - 30 30 30 22 22 22 2 2 6 2 2 6
45831 - 2 2 6 2 2 6 18 18 18 86 86 86
45832 - 42 42 42 14 14 14 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 0 0 0 0 0 0 0 0 0
45837 - 0 0 0 0 0 0 0 0 0 0 0 0
45838 - 0 0 0 0 0 0 0 0 0 0 0 0
45839 - 0 0 0 0 0 0 0 0 0 0 0 0
45840 - 0 0 0 0 0 0 0 0 0 14 14 14
45841 - 42 42 42 90 90 90 22 22 22 2 2 6
45842 - 42 42 42 2 2 6 18 18 18 218 218 218
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 253 253 253
45847 -253 253 253 253 253 253 253 253 253 253 253 253
45848 -253 253 253 253 253 253 250 250 250 221 221 221
45849 -218 218 218 101 101 101 2 2 6 14 14 14
45850 - 18 18 18 38 38 38 10 10 10 2 2 6
45851 - 2 2 6 2 2 6 2 2 6 78 78 78
45852 - 58 58 58 22 22 22 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45857 - 0 0 0 0 0 0 0 0 0 0 0 0
45858 - 0 0 0 0 0 0 0 0 0 0 0 0
45859 - 0 0 0 0 0 0 0 0 0 0 0 0
45860 - 0 0 0 0 0 0 6 6 6 18 18 18
45861 - 54 54 54 82 82 82 2 2 6 26 26 26
45862 - 22 22 22 2 2 6 123 123 123 253 253 253
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 253 253 253
45867 -253 253 253 253 253 253 253 253 253 253 253 253
45868 -253 253 253 253 253 253 253 253 253 250 250 250
45869 -238 238 238 198 198 198 6 6 6 38 38 38
45870 - 58 58 58 26 26 26 38 38 38 2 2 6
45871 - 2 2 6 2 2 6 2 2 6 46 46 46
45872 - 78 78 78 30 30 30 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45877 - 0 0 0 0 0 0 0 0 0 0 0 0
45878 - 0 0 0 0 0 0 0 0 0 0 0 0
45879 - 0 0 0 0 0 0 0 0 0 0 0 0
45880 - 0 0 0 0 0 0 10 10 10 30 30 30
45881 - 74 74 74 58 58 58 2 2 6 42 42 42
45882 - 2 2 6 22 22 22 231 231 231 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 250 250 250
45885 -253 253 253 253 253 253 253 253 253 253 253 253
45886 -253 253 253 253 253 253 253 253 253 253 253 253
45887 -253 253 253 253 253 253 253 253 253 253 253 253
45888 -253 253 253 253 253 253 253 253 253 253 253 253
45889 -253 253 253 246 246 246 46 46 46 38 38 38
45890 - 42 42 42 14 14 14 38 38 38 14 14 14
45891 - 2 2 6 2 2 6 2 2 6 6 6 6
45892 - 86 86 86 46 46 46 14 14 14 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 0 0 0
45896 - 0 0 0 0 0 0 0 0 0 0 0 0
45897 - 0 0 0 0 0 0 0 0 0 0 0 0
45898 - 0 0 0 0 0 0 0 0 0 0 0 0
45899 - 0 0 0 0 0 0 0 0 0 0 0 0
45900 - 0 0 0 6 6 6 14 14 14 42 42 42
45901 - 90 90 90 18 18 18 18 18 18 26 26 26
45902 - 2 2 6 116 116 116 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 250 250 250 238 238 238
45905 -253 253 253 253 253 253 253 253 253 253 253 253
45906 -253 253 253 253 253 253 253 253 253 253 253 253
45907 -253 253 253 253 253 253 253 253 253 253 253 253
45908 -253 253 253 253 253 253 253 253 253 253 253 253
45909 -253 253 253 253 253 253 94 94 94 6 6 6
45910 - 2 2 6 2 2 6 10 10 10 34 34 34
45911 - 2 2 6 2 2 6 2 2 6 2 2 6
45912 - 74 74 74 58 58 58 22 22 22 6 6 6
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 0 0 0
45916 - 0 0 0 0 0 0 0 0 0 0 0 0
45917 - 0 0 0 0 0 0 0 0 0 0 0 0
45918 - 0 0 0 0 0 0 0 0 0 0 0 0
45919 - 0 0 0 0 0 0 0 0 0 0 0 0
45920 - 0 0 0 10 10 10 26 26 26 66 66 66
45921 - 82 82 82 2 2 6 38 38 38 6 6 6
45922 - 14 14 14 210 210 210 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 246 246 246 242 242 242
45925 -253 253 253 253 253 253 253 253 253 253 253 253
45926 -253 253 253 253 253 253 253 253 253 253 253 253
45927 -253 253 253 253 253 253 253 253 253 253 253 253
45928 -253 253 253 253 253 253 253 253 253 253 253 253
45929 -253 253 253 253 253 253 144 144 144 2 2 6
45930 - 2 2 6 2 2 6 2 2 6 46 46 46
45931 - 2 2 6 2 2 6 2 2 6 2 2 6
45932 - 42 42 42 74 74 74 30 30 30 10 10 10
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 0 0 0
45936 - 0 0 0 0 0 0 0 0 0 0 0 0
45937 - 0 0 0 0 0 0 0 0 0 0 0 0
45938 - 0 0 0 0 0 0 0 0 0 0 0 0
45939 - 0 0 0 0 0 0 0 0 0 0 0 0
45940 - 6 6 6 14 14 14 42 42 42 90 90 90
45941 - 26 26 26 6 6 6 42 42 42 2 2 6
45942 - 74 74 74 250 250 250 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 242 242 242 242 242 242
45945 -253 253 253 253 253 253 253 253 253 253 253 253
45946 -253 253 253 253 253 253 253 253 253 253 253 253
45947 -253 253 253 253 253 253 253 253 253 253 253 253
45948 -253 253 253 253 253 253 253 253 253 253 253 253
45949 -253 253 253 253 253 253 182 182 182 2 2 6
45950 - 2 2 6 2 2 6 2 2 6 46 46 46
45951 - 2 2 6 2 2 6 2 2 6 2 2 6
45952 - 10 10 10 86 86 86 38 38 38 10 10 10
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 0 0 0
45956 - 0 0 0 0 0 0 0 0 0 0 0 0
45957 - 0 0 0 0 0 0 0 0 0 0 0 0
45958 - 0 0 0 0 0 0 0 0 0 0 0 0
45959 - 0 0 0 0 0 0 0 0 0 0 0 0
45960 - 10 10 10 26 26 26 66 66 66 82 82 82
45961 - 2 2 6 22 22 22 18 18 18 2 2 6
45962 -149 149 149 253 253 253 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 234 234 234 242 242 242
45965 -253 253 253 253 253 253 253 253 253 253 253 253
45966 -253 253 253 253 253 253 253 253 253 253 253 253
45967 -253 253 253 253 253 253 253 253 253 253 253 253
45968 -253 253 253 253 253 253 253 253 253 253 253 253
45969 -253 253 253 253 253 253 206 206 206 2 2 6
45970 - 2 2 6 2 2 6 2 2 6 38 38 38
45971 - 2 2 6 2 2 6 2 2 6 2 2 6
45972 - 6 6 6 86 86 86 46 46 46 14 14 14
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 0 0 0
45976 - 0 0 0 0 0 0 0 0 0 0 0 0
45977 - 0 0 0 0 0 0 0 0 0 0 0 0
45978 - 0 0 0 0 0 0 0 0 0 0 0 0
45979 - 0 0 0 0 0 0 0 0 0 6 6 6
45980 - 18 18 18 46 46 46 86 86 86 18 18 18
45981 - 2 2 6 34 34 34 10 10 10 6 6 6
45982 -210 210 210 253 253 253 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 234 234 234 242 242 242
45985 -253 253 253 253 253 253 253 253 253 253 253 253
45986 -253 253 253 253 253 253 253 253 253 253 253 253
45987 -253 253 253 253 253 253 253 253 253 253 253 253
45988 -253 253 253 253 253 253 253 253 253 253 253 253
45989 -253 253 253 253 253 253 221 221 221 6 6 6
45990 - 2 2 6 2 2 6 6 6 6 30 30 30
45991 - 2 2 6 2 2 6 2 2 6 2 2 6
45992 - 2 2 6 82 82 82 54 54 54 18 18 18
45993 - 6 6 6 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 0 0 0
45996 - 0 0 0 0 0 0 0 0 0 0 0 0
45997 - 0 0 0 0 0 0 0 0 0 0 0 0
45998 - 0 0 0 0 0 0 0 0 0 0 0 0
45999 - 0 0 0 0 0 0 0 0 0 10 10 10
46000 - 26 26 26 66 66 66 62 62 62 2 2 6
46001 - 2 2 6 38 38 38 10 10 10 26 26 26
46002 -238 238 238 253 253 253 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 231 231 231 238 238 238
46005 -253 253 253 253 253 253 253 253 253 253 253 253
46006 -253 253 253 253 253 253 253 253 253 253 253 253
46007 -253 253 253 253 253 253 253 253 253 253 253 253
46008 -253 253 253 253 253 253 253 253 253 253 253 253
46009 -253 253 253 253 253 253 231 231 231 6 6 6
46010 - 2 2 6 2 2 6 10 10 10 30 30 30
46011 - 2 2 6 2 2 6 2 2 6 2 2 6
46012 - 2 2 6 66 66 66 58 58 58 22 22 22
46013 - 6 6 6 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 0 0 0
46016 - 0 0 0 0 0 0 0 0 0 0 0 0
46017 - 0 0 0 0 0 0 0 0 0 0 0 0
46018 - 0 0 0 0 0 0 0 0 0 0 0 0
46019 - 0 0 0 0 0 0 0 0 0 10 10 10
46020 - 38 38 38 78 78 78 6 6 6 2 2 6
46021 - 2 2 6 46 46 46 14 14 14 42 42 42
46022 -246 246 246 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 231 231 231 242 242 242
46025 -253 253 253 253 253 253 253 253 253 253 253 253
46026 -253 253 253 253 253 253 253 253 253 253 253 253
46027 -253 253 253 253 253 253 253 253 253 253 253 253
46028 -253 253 253 253 253 253 253 253 253 253 253 253
46029 -253 253 253 253 253 253 234 234 234 10 10 10
46030 - 2 2 6 2 2 6 22 22 22 14 14 14
46031 - 2 2 6 2 2 6 2 2 6 2 2 6
46032 - 2 2 6 66 66 66 62 62 62 22 22 22
46033 - 6 6 6 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 0 0 0
46036 - 0 0 0 0 0 0 0 0 0 0 0 0
46037 - 0 0 0 0 0 0 0 0 0 0 0 0
46038 - 0 0 0 0 0 0 0 0 0 0 0 0
46039 - 0 0 0 0 0 0 6 6 6 18 18 18
46040 - 50 50 50 74 74 74 2 2 6 2 2 6
46041 - 14 14 14 70 70 70 34 34 34 62 62 62
46042 -250 250 250 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 231 231 231 246 246 246
46045 -253 253 253 253 253 253 253 253 253 253 253 253
46046 -253 253 253 253 253 253 253 253 253 253 253 253
46047 -253 253 253 253 253 253 253 253 253 253 253 253
46048 -253 253 253 253 253 253 253 253 253 253 253 253
46049 -253 253 253 253 253 253 234 234 234 14 14 14
46050 - 2 2 6 2 2 6 30 30 30 2 2 6
46051 - 2 2 6 2 2 6 2 2 6 2 2 6
46052 - 2 2 6 66 66 66 62 62 62 22 22 22
46053 - 6 6 6 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 0 0 0
46056 - 0 0 0 0 0 0 0 0 0 0 0 0
46057 - 0 0 0 0 0 0 0 0 0 0 0 0
46058 - 0 0 0 0 0 0 0 0 0 0 0 0
46059 - 0 0 0 0 0 0 6 6 6 18 18 18
46060 - 54 54 54 62 62 62 2 2 6 2 2 6
46061 - 2 2 6 30 30 30 46 46 46 70 70 70
46062 -250 250 250 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 231 231 231 246 246 246
46065 -253 253 253 253 253 253 253 253 253 253 253 253
46066 -253 253 253 253 253 253 253 253 253 253 253 253
46067 -253 253 253 253 253 253 253 253 253 253 253 253
46068 -253 253 253 253 253 253 253 253 253 253 253 253
46069 -253 253 253 253 253 253 226 226 226 10 10 10
46070 - 2 2 6 6 6 6 30 30 30 2 2 6
46071 - 2 2 6 2 2 6 2 2 6 2 2 6
46072 - 2 2 6 66 66 66 58 58 58 22 22 22
46073 - 6 6 6 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 0 0 0 0 0 0
46076 - 0 0 0 0 0 0 0 0 0 0 0 0
46077 - 0 0 0 0 0 0 0 0 0 0 0 0
46078 - 0 0 0 0 0 0 0 0 0 0 0 0
46079 - 0 0 0 0 0 0 6 6 6 22 22 22
46080 - 58 58 58 62 62 62 2 2 6 2 2 6
46081 - 2 2 6 2 2 6 30 30 30 78 78 78
46082 -250 250 250 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 231 231 231 246 246 246
46085 -253 253 253 253 253 253 253 253 253 253 253 253
46086 -253 253 253 253 253 253 253 253 253 253 253 253
46087 -253 253 253 253 253 253 253 253 253 253 253 253
46088 -253 253 253 253 253 253 253 253 253 253 253 253
46089 -253 253 253 253 253 253 206 206 206 2 2 6
46090 - 22 22 22 34 34 34 18 14 6 22 22 22
46091 - 26 26 26 18 18 18 6 6 6 2 2 6
46092 - 2 2 6 82 82 82 54 54 54 18 18 18
46093 - 6 6 6 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 0 0 0 0 0 0
46096 - 0 0 0 0 0 0 0 0 0 0 0 0
46097 - 0 0 0 0 0 0 0 0 0 0 0 0
46098 - 0 0 0 0 0 0 0 0 0 0 0 0
46099 - 0 0 0 0 0 0 6 6 6 26 26 26
46100 - 62 62 62 106 106 106 74 54 14 185 133 11
46101 -210 162 10 121 92 8 6 6 6 62 62 62
46102 -238 238 238 253 253 253 253 253 253 253 253 253
46103 -253 253 253 253 253 253 253 253 253 253 253 253
46104 -253 253 253 253 253 253 231 231 231 246 246 246
46105 -253 253 253 253 253 253 253 253 253 253 253 253
46106 -253 253 253 253 253 253 253 253 253 253 253 253
46107 -253 253 253 253 253 253 253 253 253 253 253 253
46108 -253 253 253 253 253 253 253 253 253 253 253 253
46109 -253 253 253 253 253 253 158 158 158 18 18 18
46110 - 14 14 14 2 2 6 2 2 6 2 2 6
46111 - 6 6 6 18 18 18 66 66 66 38 38 38
46112 - 6 6 6 94 94 94 50 50 50 18 18 18
46113 - 6 6 6 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 0 0 0 0 0 0
46116 - 0 0 0 0 0 0 0 0 0 0 0 0
46117 - 0 0 0 0 0 0 0 0 0 0 0 0
46118 - 0 0 0 0 0 0 0 0 0 6 6 6
46119 - 10 10 10 10 10 10 18 18 18 38 38 38
46120 - 78 78 78 142 134 106 216 158 10 242 186 14
46121 -246 190 14 246 190 14 156 118 10 10 10 10
46122 - 90 90 90 238 238 238 253 253 253 253 253 253
46123 -253 253 253 253 253 253 253 253 253 253 253 253
46124 -253 253 253 253 253 253 231 231 231 250 250 250
46125 -253 253 253 253 253 253 253 253 253 253 253 253
46126 -253 253 253 253 253 253 253 253 253 253 253 253
46127 -253 253 253 253 253 253 253 253 253 253 253 253
46128 -253 253 253 253 253 253 253 253 253 246 230 190
46129 -238 204 91 238 204 91 181 142 44 37 26 9
46130 - 2 2 6 2 2 6 2 2 6 2 2 6
46131 - 2 2 6 2 2 6 38 38 38 46 46 46
46132 - 26 26 26 106 106 106 54 54 54 18 18 18
46133 - 6 6 6 0 0 0 0 0 0 0 0 0
46134 - 0 0 0 0 0 0 0 0 0 0 0 0
46135 - 0 0 0 0 0 0 0 0 0 0 0 0
46136 - 0 0 0 0 0 0 0 0 0 0 0 0
46137 - 0 0 0 0 0 0 0 0 0 0 0 0
46138 - 0 0 0 6 6 6 14 14 14 22 22 22
46139 - 30 30 30 38 38 38 50 50 50 70 70 70
46140 -106 106 106 190 142 34 226 170 11 242 186 14
46141 -246 190 14 246 190 14 246 190 14 154 114 10
46142 - 6 6 6 74 74 74 226 226 226 253 253 253
46143 -253 253 253 253 253 253 253 253 253 253 253 253
46144 -253 253 253 253 253 253 231 231 231 250 250 250
46145 -253 253 253 253 253 253 253 253 253 253 253 253
46146 -253 253 253 253 253 253 253 253 253 253 253 253
46147 -253 253 253 253 253 253 253 253 253 253 253 253
46148 -253 253 253 253 253 253 253 253 253 228 184 62
46149 -241 196 14 241 208 19 232 195 16 38 30 10
46150 - 2 2 6 2 2 6 2 2 6 2 2 6
46151 - 2 2 6 6 6 6 30 30 30 26 26 26
46152 -203 166 17 154 142 90 66 66 66 26 26 26
46153 - 6 6 6 0 0 0 0 0 0 0 0 0
46154 - 0 0 0 0 0 0 0 0 0 0 0 0
46155 - 0 0 0 0 0 0 0 0 0 0 0 0
46156 - 0 0 0 0 0 0 0 0 0 0 0 0
46157 - 0 0 0 0 0 0 0 0 0 0 0 0
46158 - 6 6 6 18 18 18 38 38 38 58 58 58
46159 - 78 78 78 86 86 86 101 101 101 123 123 123
46160 -175 146 61 210 150 10 234 174 13 246 186 14
46161 -246 190 14 246 190 14 246 190 14 238 190 10
46162 -102 78 10 2 2 6 46 46 46 198 198 198
46163 -253 253 253 253 253 253 253 253 253 253 253 253
46164 -253 253 253 253 253 253 234 234 234 242 242 242
46165 -253 253 253 253 253 253 253 253 253 253 253 253
46166 -253 253 253 253 253 253 253 253 253 253 253 253
46167 -253 253 253 253 253 253 253 253 253 253 253 253
46168 -253 253 253 253 253 253 253 253 253 224 178 62
46169 -242 186 14 241 196 14 210 166 10 22 18 6
46170 - 2 2 6 2 2 6 2 2 6 2 2 6
46171 - 2 2 6 2 2 6 6 6 6 121 92 8
46172 -238 202 15 232 195 16 82 82 82 34 34 34
46173 - 10 10 10 0 0 0 0 0 0 0 0 0
46174 - 0 0 0 0 0 0 0 0 0 0 0 0
46175 - 0 0 0 0 0 0 0 0 0 0 0 0
46176 - 0 0 0 0 0 0 0 0 0 0 0 0
46177 - 0 0 0 0 0 0 0 0 0 0 0 0
46178 - 14 14 14 38 38 38 70 70 70 154 122 46
46179 -190 142 34 200 144 11 197 138 11 197 138 11
46180 -213 154 11 226 170 11 242 186 14 246 190 14
46181 -246 190 14 246 190 14 246 190 14 246 190 14
46182 -225 175 15 46 32 6 2 2 6 22 22 22
46183 -158 158 158 250 250 250 253 253 253 253 253 253
46184 -253 253 253 253 253 253 253 253 253 253 253 253
46185 -253 253 253 253 253 253 253 253 253 253 253 253
46186 -253 253 253 253 253 253 253 253 253 253 253 253
46187 -253 253 253 253 253 253 253 253 253 253 253 253
46188 -253 253 253 250 250 250 242 242 242 224 178 62
46189 -239 182 13 236 186 11 213 154 11 46 32 6
46190 - 2 2 6 2 2 6 2 2 6 2 2 6
46191 - 2 2 6 2 2 6 61 42 6 225 175 15
46192 -238 190 10 236 186 11 112 100 78 42 42 42
46193 - 14 14 14 0 0 0 0 0 0 0 0 0
46194 - 0 0 0 0 0 0 0 0 0 0 0 0
46195 - 0 0 0 0 0 0 0 0 0 0 0 0
46196 - 0 0 0 0 0 0 0 0 0 0 0 0
46197 - 0 0 0 0 0 0 0 0 0 6 6 6
46198 - 22 22 22 54 54 54 154 122 46 213 154 11
46199 -226 170 11 230 174 11 226 170 11 226 170 11
46200 -236 178 12 242 186 14 246 190 14 246 190 14
46201 -246 190 14 246 190 14 246 190 14 246 190 14
46202 -241 196 14 184 144 12 10 10 10 2 2 6
46203 - 6 6 6 116 116 116 242 242 242 253 253 253
46204 -253 253 253 253 253 253 253 253 253 253 253 253
46205 -253 253 253 253 253 253 253 253 253 253 253 253
46206 -253 253 253 253 253 253 253 253 253 253 253 253
46207 -253 253 253 253 253 253 253 253 253 253 253 253
46208 -253 253 253 231 231 231 198 198 198 214 170 54
46209 -236 178 12 236 178 12 210 150 10 137 92 6
46210 - 18 14 6 2 2 6 2 2 6 2 2 6
46211 - 6 6 6 70 47 6 200 144 11 236 178 12
46212 -239 182 13 239 182 13 124 112 88 58 58 58
46213 - 22 22 22 6 6 6 0 0 0 0 0 0
46214 - 0 0 0 0 0 0 0 0 0 0 0 0
46215 - 0 0 0 0 0 0 0 0 0 0 0 0
46216 - 0 0 0 0 0 0 0 0 0 0 0 0
46217 - 0 0 0 0 0 0 0 0 0 10 10 10
46218 - 30 30 30 70 70 70 180 133 36 226 170 11
46219 -239 182 13 242 186 14 242 186 14 246 186 14
46220 -246 190 14 246 190 14 246 190 14 246 190 14
46221 -246 190 14 246 190 14 246 190 14 246 190 14
46222 -246 190 14 232 195 16 98 70 6 2 2 6
46223 - 2 2 6 2 2 6 66 66 66 221 221 221
46224 -253 253 253 253 253 253 253 253 253 253 253 253
46225 -253 253 253 253 253 253 253 253 253 253 253 253
46226 -253 253 253 253 253 253 253 253 253 253 253 253
46227 -253 253 253 253 253 253 253 253 253 253 253 253
46228 -253 253 253 206 206 206 198 198 198 214 166 58
46229 -230 174 11 230 174 11 216 158 10 192 133 9
46230 -163 110 8 116 81 8 102 78 10 116 81 8
46231 -167 114 7 197 138 11 226 170 11 239 182 13
46232 -242 186 14 242 186 14 162 146 94 78 78 78
46233 - 34 34 34 14 14 14 6 6 6 0 0 0
46234 - 0 0 0 0 0 0 0 0 0 0 0 0
46235 - 0 0 0 0 0 0 0 0 0 0 0 0
46236 - 0 0 0 0 0 0 0 0 0 0 0 0
46237 - 0 0 0 0 0 0 0 0 0 6 6 6
46238 - 30 30 30 78 78 78 190 142 34 226 170 11
46239 -239 182 13 246 190 14 246 190 14 246 190 14
46240 -246 190 14 246 190 14 246 190 14 246 190 14
46241 -246 190 14 246 190 14 246 190 14 246 190 14
46242 -246 190 14 241 196 14 203 166 17 22 18 6
46243 - 2 2 6 2 2 6 2 2 6 38 38 38
46244 -218 218 218 253 253 253 253 253 253 253 253 253
46245 -253 253 253 253 253 253 253 253 253 253 253 253
46246 -253 253 253 253 253 253 253 253 253 253 253 253
46247 -253 253 253 253 253 253 253 253 253 253 253 253
46248 -250 250 250 206 206 206 198 198 198 202 162 69
46249 -226 170 11 236 178 12 224 166 10 210 150 10
46250 -200 144 11 197 138 11 192 133 9 197 138 11
46251 -210 150 10 226 170 11 242 186 14 246 190 14
46252 -246 190 14 246 186 14 225 175 15 124 112 88
46253 - 62 62 62 30 30 30 14 14 14 6 6 6
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 10 10 10
46258 - 30 30 30 78 78 78 174 135 50 224 166 10
46259 -239 182 13 246 190 14 246 190 14 246 190 14
46260 -246 190 14 246 190 14 246 190 14 246 190 14
46261 -246 190 14 246 190 14 246 190 14 246 190 14
46262 -246 190 14 246 190 14 241 196 14 139 102 15
46263 - 2 2 6 2 2 6 2 2 6 2 2 6
46264 - 78 78 78 250 250 250 253 253 253 253 253 253
46265 -253 253 253 253 253 253 253 253 253 253 253 253
46266 -253 253 253 253 253 253 253 253 253 253 253 253
46267 -253 253 253 253 253 253 253 253 253 253 253 253
46268 -250 250 250 214 214 214 198 198 198 190 150 46
46269 -219 162 10 236 178 12 234 174 13 224 166 10
46270 -216 158 10 213 154 11 213 154 11 216 158 10
46271 -226 170 11 239 182 13 246 190 14 246 190 14
46272 -246 190 14 246 190 14 242 186 14 206 162 42
46273 -101 101 101 58 58 58 30 30 30 14 14 14
46274 - 6 6 6 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 10 10 10
46278 - 30 30 30 74 74 74 174 135 50 216 158 10
46279 -236 178 12 246 190 14 246 190 14 246 190 14
46280 -246 190 14 246 190 14 246 190 14 246 190 14
46281 -246 190 14 246 190 14 246 190 14 246 190 14
46282 -246 190 14 246 190 14 241 196 14 226 184 13
46283 - 61 42 6 2 2 6 2 2 6 2 2 6
46284 - 22 22 22 238 238 238 253 253 253 253 253 253
46285 -253 253 253 253 253 253 253 253 253 253 253 253
46286 -253 253 253 253 253 253 253 253 253 253 253 253
46287 -253 253 253 253 253 253 253 253 253 253 253 253
46288 -253 253 253 226 226 226 187 187 187 180 133 36
46289 -216 158 10 236 178 12 239 182 13 236 178 12
46290 -230 174 11 226 170 11 226 170 11 230 174 11
46291 -236 178 12 242 186 14 246 190 14 246 190 14
46292 -246 190 14 246 190 14 246 186 14 239 182 13
46293 -206 162 42 106 106 106 66 66 66 34 34 34
46294 - 14 14 14 6 6 6 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 6 6 6
46298 - 26 26 26 70 70 70 163 133 67 213 154 11
46299 -236 178 12 246 190 14 246 190 14 246 190 14
46300 -246 190 14 246 190 14 246 190 14 246 190 14
46301 -246 190 14 246 190 14 246 190 14 246 190 14
46302 -246 190 14 246 190 14 246 190 14 241 196 14
46303 -190 146 13 18 14 6 2 2 6 2 2 6
46304 - 46 46 46 246 246 246 253 253 253 253 253 253
46305 -253 253 253 253 253 253 253 253 253 253 253 253
46306 -253 253 253 253 253 253 253 253 253 253 253 253
46307 -253 253 253 253 253 253 253 253 253 253 253 253
46308 -253 253 253 221 221 221 86 86 86 156 107 11
46309 -216 158 10 236 178 12 242 186 14 246 186 14
46310 -242 186 14 239 182 13 239 182 13 242 186 14
46311 -242 186 14 246 186 14 246 190 14 246 190 14
46312 -246 190 14 246 190 14 246 190 14 246 190 14
46313 -242 186 14 225 175 15 142 122 72 66 66 66
46314 - 30 30 30 10 10 10 0 0 0 0 0 0
46315 - 0 0 0 0 0 0 0 0 0 0 0 0
46316 - 0 0 0 0 0 0 0 0 0 0 0 0
46317 - 0 0 0 0 0 0 0 0 0 6 6 6
46318 - 26 26 26 70 70 70 163 133 67 210 150 10
46319 -236 178 12 246 190 14 246 190 14 246 190 14
46320 -246 190 14 246 190 14 246 190 14 246 190 14
46321 -246 190 14 246 190 14 246 190 14 246 190 14
46322 -246 190 14 246 190 14 246 190 14 246 190 14
46323 -232 195 16 121 92 8 34 34 34 106 106 106
46324 -221 221 221 253 253 253 253 253 253 253 253 253
46325 -253 253 253 253 253 253 253 253 253 253 253 253
46326 -253 253 253 253 253 253 253 253 253 253 253 253
46327 -253 253 253 253 253 253 253 253 253 253 253 253
46328 -242 242 242 82 82 82 18 14 6 163 110 8
46329 -216 158 10 236 178 12 242 186 14 246 190 14
46330 -246 190 14 246 190 14 246 190 14 246 190 14
46331 -246 190 14 246 190 14 246 190 14 246 190 14
46332 -246 190 14 246 190 14 246 190 14 246 190 14
46333 -246 190 14 246 190 14 242 186 14 163 133 67
46334 - 46 46 46 18 18 18 6 6 6 0 0 0
46335 - 0 0 0 0 0 0 0 0 0 0 0 0
46336 - 0 0 0 0 0 0 0 0 0 0 0 0
46337 - 0 0 0 0 0 0 0 0 0 10 10 10
46338 - 30 30 30 78 78 78 163 133 67 210 150 10
46339 -236 178 12 246 186 14 246 190 14 246 190 14
46340 -246 190 14 246 190 14 246 190 14 246 190 14
46341 -246 190 14 246 190 14 246 190 14 246 190 14
46342 -246 190 14 246 190 14 246 190 14 246 190 14
46343 -241 196 14 215 174 15 190 178 144 253 253 253
46344 -253 253 253 253 253 253 253 253 253 253 253 253
46345 -253 253 253 253 253 253 253 253 253 253 253 253
46346 -253 253 253 253 253 253 253 253 253 253 253 253
46347 -253 253 253 253 253 253 253 253 253 218 218 218
46348 - 58 58 58 2 2 6 22 18 6 167 114 7
46349 -216 158 10 236 178 12 246 186 14 246 190 14
46350 -246 190 14 246 190 14 246 190 14 246 190 14
46351 -246 190 14 246 190 14 246 190 14 246 190 14
46352 -246 190 14 246 190 14 246 190 14 246 190 14
46353 -246 190 14 246 186 14 242 186 14 190 150 46
46354 - 54 54 54 22 22 22 6 6 6 0 0 0
46355 - 0 0 0 0 0 0 0 0 0 0 0 0
46356 - 0 0 0 0 0 0 0 0 0 0 0 0
46357 - 0 0 0 0 0 0 0 0 0 14 14 14
46358 - 38 38 38 86 86 86 180 133 36 213 154 11
46359 -236 178 12 246 186 14 246 190 14 246 190 14
46360 -246 190 14 246 190 14 246 190 14 246 190 14
46361 -246 190 14 246 190 14 246 190 14 246 190 14
46362 -246 190 14 246 190 14 246 190 14 246 190 14
46363 -246 190 14 232 195 16 190 146 13 214 214 214
46364 -253 253 253 253 253 253 253 253 253 253 253 253
46365 -253 253 253 253 253 253 253 253 253 253 253 253
46366 -253 253 253 253 253 253 253 253 253 253 253 253
46367 -253 253 253 250 250 250 170 170 170 26 26 26
46368 - 2 2 6 2 2 6 37 26 9 163 110 8
46369 -219 162 10 239 182 13 246 186 14 246 190 14
46370 -246 190 14 246 190 14 246 190 14 246 190 14
46371 -246 190 14 246 190 14 246 190 14 246 190 14
46372 -246 190 14 246 190 14 246 190 14 246 190 14
46373 -246 186 14 236 178 12 224 166 10 142 122 72
46374 - 46 46 46 18 18 18 6 6 6 0 0 0
46375 - 0 0 0 0 0 0 0 0 0 0 0 0
46376 - 0 0 0 0 0 0 0 0 0 0 0 0
46377 - 0 0 0 0 0 0 6 6 6 18 18 18
46378 - 50 50 50 109 106 95 192 133 9 224 166 10
46379 -242 186 14 246 190 14 246 190 14 246 190 14
46380 -246 190 14 246 190 14 246 190 14 246 190 14
46381 -246 190 14 246 190 14 246 190 14 246 190 14
46382 -246 190 14 246 190 14 246 190 14 246 190 14
46383 -242 186 14 226 184 13 210 162 10 142 110 46
46384 -226 226 226 253 253 253 253 253 253 253 253 253
46385 -253 253 253 253 253 253 253 253 253 253 253 253
46386 -253 253 253 253 253 253 253 253 253 253 253 253
46387 -198 198 198 66 66 66 2 2 6 2 2 6
46388 - 2 2 6 2 2 6 50 34 6 156 107 11
46389 -219 162 10 239 182 13 246 186 14 246 190 14
46390 -246 190 14 246 190 14 246 190 14 246 190 14
46391 -246 190 14 246 190 14 246 190 14 246 190 14
46392 -246 190 14 246 190 14 246 190 14 242 186 14
46393 -234 174 13 213 154 11 154 122 46 66 66 66
46394 - 30 30 30 10 10 10 0 0 0 0 0 0
46395 - 0 0 0 0 0 0 0 0 0 0 0 0
46396 - 0 0 0 0 0 0 0 0 0 0 0 0
46397 - 0 0 0 0 0 0 6 6 6 22 22 22
46398 - 58 58 58 154 121 60 206 145 10 234 174 13
46399 -242 186 14 246 186 14 246 190 14 246 190 14
46400 -246 190 14 246 190 14 246 190 14 246 190 14
46401 -246 190 14 246 190 14 246 190 14 246 190 14
46402 -246 190 14 246 190 14 246 190 14 246 190 14
46403 -246 186 14 236 178 12 210 162 10 163 110 8
46404 - 61 42 6 138 138 138 218 218 218 250 250 250
46405 -253 253 253 253 253 253 253 253 253 250 250 250
46406 -242 242 242 210 210 210 144 144 144 66 66 66
46407 - 6 6 6 2 2 6 2 2 6 2 2 6
46408 - 2 2 6 2 2 6 61 42 6 163 110 8
46409 -216 158 10 236 178 12 246 190 14 246 190 14
46410 -246 190 14 246 190 14 246 190 14 246 190 14
46411 -246 190 14 246 190 14 246 190 14 246 190 14
46412 -246 190 14 239 182 13 230 174 11 216 158 10
46413 -190 142 34 124 112 88 70 70 70 38 38 38
46414 - 18 18 18 6 6 6 0 0 0 0 0 0
46415 - 0 0 0 0 0 0 0 0 0 0 0 0
46416 - 0 0 0 0 0 0 0 0 0 0 0 0
46417 - 0 0 0 0 0 0 6 6 6 22 22 22
46418 - 62 62 62 168 124 44 206 145 10 224 166 10
46419 -236 178 12 239 182 13 242 186 14 242 186 14
46420 -246 186 14 246 190 14 246 190 14 246 190 14
46421 -246 190 14 246 190 14 246 190 14 246 190 14
46422 -246 190 14 246 190 14 246 190 14 246 190 14
46423 -246 190 14 236 178 12 216 158 10 175 118 6
46424 - 80 54 7 2 2 6 6 6 6 30 30 30
46425 - 54 54 54 62 62 62 50 50 50 38 38 38
46426 - 14 14 14 2 2 6 2 2 6 2 2 6
46427 - 2 2 6 2 2 6 2 2 6 2 2 6
46428 - 2 2 6 6 6 6 80 54 7 167 114 7
46429 -213 154 11 236 178 12 246 190 14 246 190 14
46430 -246 190 14 246 190 14 246 190 14 246 190 14
46431 -246 190 14 242 186 14 239 182 13 239 182 13
46432 -230 174 11 210 150 10 174 135 50 124 112 88
46433 - 82 82 82 54 54 54 34 34 34 18 18 18
46434 - 6 6 6 0 0 0 0 0 0 0 0 0
46435 - 0 0 0 0 0 0 0 0 0 0 0 0
46436 - 0 0 0 0 0 0 0 0 0 0 0 0
46437 - 0 0 0 0 0 0 6 6 6 18 18 18
46438 - 50 50 50 158 118 36 192 133 9 200 144 11
46439 -216 158 10 219 162 10 224 166 10 226 170 11
46440 -230 174 11 236 178 12 239 182 13 239 182 13
46441 -242 186 14 246 186 14 246 190 14 246 190 14
46442 -246 190 14 246 190 14 246 190 14 246 190 14
46443 -246 186 14 230 174 11 210 150 10 163 110 8
46444 -104 69 6 10 10 10 2 2 6 2 2 6
46445 - 2 2 6 2 2 6 2 2 6 2 2 6
46446 - 2 2 6 2 2 6 2 2 6 2 2 6
46447 - 2 2 6 2 2 6 2 2 6 2 2 6
46448 - 2 2 6 6 6 6 91 60 6 167 114 7
46449 -206 145 10 230 174 11 242 186 14 246 190 14
46450 -246 190 14 246 190 14 246 186 14 242 186 14
46451 -239 182 13 230 174 11 224 166 10 213 154 11
46452 -180 133 36 124 112 88 86 86 86 58 58 58
46453 - 38 38 38 22 22 22 10 10 10 6 6 6
46454 - 0 0 0 0 0 0 0 0 0 0 0 0
46455 - 0 0 0 0 0 0 0 0 0 0 0 0
46456 - 0 0 0 0 0 0 0 0 0 0 0 0
46457 - 0 0 0 0 0 0 0 0 0 14 14 14
46458 - 34 34 34 70 70 70 138 110 50 158 118 36
46459 -167 114 7 180 123 7 192 133 9 197 138 11
46460 -200 144 11 206 145 10 213 154 11 219 162 10
46461 -224 166 10 230 174 11 239 182 13 242 186 14
46462 -246 186 14 246 186 14 246 186 14 246 186 14
46463 -239 182 13 216 158 10 185 133 11 152 99 6
46464 -104 69 6 18 14 6 2 2 6 2 2 6
46465 - 2 2 6 2 2 6 2 2 6 2 2 6
46466 - 2 2 6 2 2 6 2 2 6 2 2 6
46467 - 2 2 6 2 2 6 2 2 6 2 2 6
46468 - 2 2 6 6 6 6 80 54 7 152 99 6
46469 -192 133 9 219 162 10 236 178 12 239 182 13
46470 -246 186 14 242 186 14 239 182 13 236 178 12
46471 -224 166 10 206 145 10 192 133 9 154 121 60
46472 - 94 94 94 62 62 62 42 42 42 22 22 22
46473 - 14 14 14 6 6 6 0 0 0 0 0 0
46474 - 0 0 0 0 0 0 0 0 0 0 0 0
46475 - 0 0 0 0 0 0 0 0 0 0 0 0
46476 - 0 0 0 0 0 0 0 0 0 0 0 0
46477 - 0 0 0 0 0 0 0 0 0 6 6 6
46478 - 18 18 18 34 34 34 58 58 58 78 78 78
46479 -101 98 89 124 112 88 142 110 46 156 107 11
46480 -163 110 8 167 114 7 175 118 6 180 123 7
46481 -185 133 11 197 138 11 210 150 10 219 162 10
46482 -226 170 11 236 178 12 236 178 12 234 174 13
46483 -219 162 10 197 138 11 163 110 8 130 83 6
46484 - 91 60 6 10 10 10 2 2 6 2 2 6
46485 - 18 18 18 38 38 38 38 38 38 38 38 38
46486 - 38 38 38 38 38 38 38 38 38 38 38 38
46487 - 38 38 38 38 38 38 26 26 26 2 2 6
46488 - 2 2 6 6 6 6 70 47 6 137 92 6
46489 -175 118 6 200 144 11 219 162 10 230 174 11
46490 -234 174 13 230 174 11 219 162 10 210 150 10
46491 -192 133 9 163 110 8 124 112 88 82 82 82
46492 - 50 50 50 30 30 30 14 14 14 6 6 6
46493 - 0 0 0 0 0 0 0 0 0 0 0 0
46494 - 0 0 0 0 0 0 0 0 0 0 0 0
46495 - 0 0 0 0 0 0 0 0 0 0 0 0
46496 - 0 0 0 0 0 0 0 0 0 0 0 0
46497 - 0 0 0 0 0 0 0 0 0 0 0 0
46498 - 6 6 6 14 14 14 22 22 22 34 34 34
46499 - 42 42 42 58 58 58 74 74 74 86 86 86
46500 -101 98 89 122 102 70 130 98 46 121 87 25
46501 -137 92 6 152 99 6 163 110 8 180 123 7
46502 -185 133 11 197 138 11 206 145 10 200 144 11
46503 -180 123 7 156 107 11 130 83 6 104 69 6
46504 - 50 34 6 54 54 54 110 110 110 101 98 89
46505 - 86 86 86 82 82 82 78 78 78 78 78 78
46506 - 78 78 78 78 78 78 78 78 78 78 78 78
46507 - 78 78 78 82 82 82 86 86 86 94 94 94
46508 -106 106 106 101 101 101 86 66 34 124 80 6
46509 -156 107 11 180 123 7 192 133 9 200 144 11
46510 -206 145 10 200 144 11 192 133 9 175 118 6
46511 -139 102 15 109 106 95 70 70 70 42 42 42
46512 - 22 22 22 10 10 10 0 0 0 0 0 0
46513 - 0 0 0 0 0 0 0 0 0 0 0 0
46514 - 0 0 0 0 0 0 0 0 0 0 0 0
46515 - 0 0 0 0 0 0 0 0 0 0 0 0
46516 - 0 0 0 0 0 0 0 0 0 0 0 0
46517 - 0 0 0 0 0 0 0 0 0 0 0 0
46518 - 0 0 0 0 0 0 6 6 6 10 10 10
46519 - 14 14 14 22 22 22 30 30 30 38 38 38
46520 - 50 50 50 62 62 62 74 74 74 90 90 90
46521 -101 98 89 112 100 78 121 87 25 124 80 6
46522 -137 92 6 152 99 6 152 99 6 152 99 6
46523 -138 86 6 124 80 6 98 70 6 86 66 30
46524 -101 98 89 82 82 82 58 58 58 46 46 46
46525 - 38 38 38 34 34 34 34 34 34 34 34 34
46526 - 34 34 34 34 34 34 34 34 34 34 34 34
46527 - 34 34 34 34 34 34 38 38 38 42 42 42
46528 - 54 54 54 82 82 82 94 86 76 91 60 6
46529 -134 86 6 156 107 11 167 114 7 175 118 6
46530 -175 118 6 167 114 7 152 99 6 121 87 25
46531 -101 98 89 62 62 62 34 34 34 18 18 18
46532 - 6 6 6 0 0 0 0 0 0 0 0 0
46533 - 0 0 0 0 0 0 0 0 0 0 0 0
46534 - 0 0 0 0 0 0 0 0 0 0 0 0
46535 - 0 0 0 0 0 0 0 0 0 0 0 0
46536 - 0 0 0 0 0 0 0 0 0 0 0 0
46537 - 0 0 0 0 0 0 0 0 0 0 0 0
46538 - 0 0 0 0 0 0 0 0 0 0 0 0
46539 - 0 0 0 6 6 6 6 6 6 10 10 10
46540 - 18 18 18 22 22 22 30 30 30 42 42 42
46541 - 50 50 50 66 66 66 86 86 86 101 98 89
46542 -106 86 58 98 70 6 104 69 6 104 69 6
46543 -104 69 6 91 60 6 82 62 34 90 90 90
46544 - 62 62 62 38 38 38 22 22 22 14 14 14
46545 - 10 10 10 10 10 10 10 10 10 10 10 10
46546 - 10 10 10 10 10 10 6 6 6 10 10 10
46547 - 10 10 10 10 10 10 10 10 10 14 14 14
46548 - 22 22 22 42 42 42 70 70 70 89 81 66
46549 - 80 54 7 104 69 6 124 80 6 137 92 6
46550 -134 86 6 116 81 8 100 82 52 86 86 86
46551 - 58 58 58 30 30 30 14 14 14 6 6 6
46552 - 0 0 0 0 0 0 0 0 0 0 0 0
46553 - 0 0 0 0 0 0 0 0 0 0 0 0
46554 - 0 0 0 0 0 0 0 0 0 0 0 0
46555 - 0 0 0 0 0 0 0 0 0 0 0 0
46556 - 0 0 0 0 0 0 0 0 0 0 0 0
46557 - 0 0 0 0 0 0 0 0 0 0 0 0
46558 - 0 0 0 0 0 0 0 0 0 0 0 0
46559 - 0 0 0 0 0 0 0 0 0 0 0 0
46560 - 0 0 0 6 6 6 10 10 10 14 14 14
46561 - 18 18 18 26 26 26 38 38 38 54 54 54
46562 - 70 70 70 86 86 86 94 86 76 89 81 66
46563 - 89 81 66 86 86 86 74 74 74 50 50 50
46564 - 30 30 30 14 14 14 6 6 6 0 0 0
46565 - 0 0 0 0 0 0 0 0 0 0 0 0
46566 - 0 0 0 0 0 0 0 0 0 0 0 0
46567 - 0 0 0 0 0 0 0 0 0 0 0 0
46568 - 6 6 6 18 18 18 34 34 34 58 58 58
46569 - 82 82 82 89 81 66 89 81 66 89 81 66
46570 - 94 86 66 94 86 76 74 74 74 50 50 50
46571 - 26 26 26 14 14 14 6 6 6 0 0 0
46572 - 0 0 0 0 0 0 0 0 0 0 0 0
46573 - 0 0 0 0 0 0 0 0 0 0 0 0
46574 - 0 0 0 0 0 0 0 0 0 0 0 0
46575 - 0 0 0 0 0 0 0 0 0 0 0 0
46576 - 0 0 0 0 0 0 0 0 0 0 0 0
46577 - 0 0 0 0 0 0 0 0 0 0 0 0
46578 - 0 0 0 0 0 0 0 0 0 0 0 0
46579 - 0 0 0 0 0 0 0 0 0 0 0 0
46580 - 0 0 0 0 0 0 0 0 0 0 0 0
46581 - 6 6 6 6 6 6 14 14 14 18 18 18
46582 - 30 30 30 38 38 38 46 46 46 54 54 54
46583 - 50 50 50 42 42 42 30 30 30 18 18 18
46584 - 10 10 10 0 0 0 0 0 0 0 0 0
46585 - 0 0 0 0 0 0 0 0 0 0 0 0
46586 - 0 0 0 0 0 0 0 0 0 0 0 0
46587 - 0 0 0 0 0 0 0 0 0 0 0 0
46588 - 0 0 0 6 6 6 14 14 14 26 26 26
46589 - 38 38 38 50 50 50 58 58 58 58 58 58
46590 - 54 54 54 42 42 42 30 30 30 18 18 18
46591 - 10 10 10 0 0 0 0 0 0 0 0 0
46592 - 0 0 0 0 0 0 0 0 0 0 0 0
46593 - 0 0 0 0 0 0 0 0 0 0 0 0
46594 - 0 0 0 0 0 0 0 0 0 0 0 0
46595 - 0 0 0 0 0 0 0 0 0 0 0 0
46596 - 0 0 0 0 0 0 0 0 0 0 0 0
46597 - 0 0 0 0 0 0 0 0 0 0 0 0
46598 - 0 0 0 0 0 0 0 0 0 0 0 0
46599 - 0 0 0 0 0 0 0 0 0 0 0 0
46600 - 0 0 0 0 0 0 0 0 0 0 0 0
46601 - 0 0 0 0 0 0 0 0 0 6 6 6
46602 - 6 6 6 10 10 10 14 14 14 18 18 18
46603 - 18 18 18 14 14 14 10 10 10 6 6 6
46604 - 0 0 0 0 0 0 0 0 0 0 0 0
46605 - 0 0 0 0 0 0 0 0 0 0 0 0
46606 - 0 0 0 0 0 0 0 0 0 0 0 0
46607 - 0 0 0 0 0 0 0 0 0 0 0 0
46608 - 0 0 0 0 0 0 0 0 0 6 6 6
46609 - 14 14 14 18 18 18 22 22 22 22 22 22
46610 - 18 18 18 14 14 14 10 10 10 6 6 6
46611 - 0 0 0 0 0 0 0 0 0 0 0 0
46612 - 0 0 0 0 0 0 0 0 0 0 0 0
46613 - 0 0 0 0 0 0 0 0 0 0 0 0
46614 - 0 0 0 0 0 0 0 0 0 0 0 0
46615 - 0 0 0 0 0 0 0 0 0 0 0 0
46616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46618 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46628 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46629 +4 4 4 4 4 4
46630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46632 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46634 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46642 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46643 +4 4 4 4 4 4
46644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46646 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46647 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46657 +4 4 4 4 4 4
46658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46671 +4 4 4 4 4 4
46672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46685 +4 4 4 4 4 4
46686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46699 +4 4 4 4 4 4
46700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46704 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46705 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46709 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46710 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46711 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46713 +4 4 4 4 4 4
46714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46718 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46719 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46720 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46723 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46724 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46725 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46726 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46727 +4 4 4 4 4 4
46728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46732 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46733 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46734 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46737 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46738 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46739 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46740 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46741 +4 4 4 4 4 4
46742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46745 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46746 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46747 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46748 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46750 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46751 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46752 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46753 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46754 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46755 +4 4 4 4 4 4
46756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46759 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46760 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46761 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46762 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46763 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46764 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46765 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46766 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46767 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46768 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46769 +4 4 4 4 4 4
46770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46773 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46774 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46775 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46776 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46777 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46778 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46779 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46780 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46781 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46782 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46783 +4 4 4 4 4 4
46784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46786 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46787 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46788 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46789 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46790 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46791 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46792 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46793 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46794 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46795 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46796 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46797 +4 4 4 4 4 4
46798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46800 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46801 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46802 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46803 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46804 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46805 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46806 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46807 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46808 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46809 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46810 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46811 +4 4 4 4 4 4
46812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46814 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46815 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46816 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46817 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46818 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46819 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46820 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46821 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46822 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46823 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46824 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46825 +4 4 4 4 4 4
46826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46828 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46829 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46830 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46831 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46832 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46833 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46834 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46835 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46836 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46837 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46838 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46839 +4 4 4 4 4 4
46840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46841 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46842 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46843 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46844 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46845 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46846 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46847 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46848 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46849 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46850 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46851 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46852 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46853 +4 4 4 4 4 4
46854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46855 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46856 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46857 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46858 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46859 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46860 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46861 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46862 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46863 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46864 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46865 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46866 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46867 +0 0 0 4 4 4
46868 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46869 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46870 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46871 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46872 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46873 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46874 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46875 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46876 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46877 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46878 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46879 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46880 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46881 +2 0 0 0 0 0
46882 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46883 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46884 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46885 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46886 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46887 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46888 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46889 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46890 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46891 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46892 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46893 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46894 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46895 +37 38 37 0 0 0
46896 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46897 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46898 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46899 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46900 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46901 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46902 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46903 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46904 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46905 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46906 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46907 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46908 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46909 +85 115 134 4 0 0
46910 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46911 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46912 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46913 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46914 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46915 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46916 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46917 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46918 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46919 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46920 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46921 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46922 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46923 +60 73 81 4 0 0
46924 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46925 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46926 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46927 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46928 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46929 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46930 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46931 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46932 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46933 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46934 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46935 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46936 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46937 +16 19 21 4 0 0
46938 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46939 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46940 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46941 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46942 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46943 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46944 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46945 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46946 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46947 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46948 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46949 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46950 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46951 +4 0 0 4 3 3
46952 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46953 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46954 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46956 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46957 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46958 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46959 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46960 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46961 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46962 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46963 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46964 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46965 +3 2 2 4 4 4
46966 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46967 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46968 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46969 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46970 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46971 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46972 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46973 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46974 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46975 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46976 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46977 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46978 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46979 +4 4 4 4 4 4
46980 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46981 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46982 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46983 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46984 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46985 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46986 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46987 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46988 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46989 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46990 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46991 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46992 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46993 +4 4 4 4 4 4
46994 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46995 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46996 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46997 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46998 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46999 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47000 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47001 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47002 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47003 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47004 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47005 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47006 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47007 +5 5 5 5 5 5
47008 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47009 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47010 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47011 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47012 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47013 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47014 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47015 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47016 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47017 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47018 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47019 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47020 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47021 +5 5 5 4 4 4
47022 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47023 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47024 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47025 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47026 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47027 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47028 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47029 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47030 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47031 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47032 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47033 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47034 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47035 +4 4 4 4 4 4
47036 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47037 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47038 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47039 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47040 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47041 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47042 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47043 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47044 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47045 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47046 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47047 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47048 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47049 +4 4 4 4 4 4
47050 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47051 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47052 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47053 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47054 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47055 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47056 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47057 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47058 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47059 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47060 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47061 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47062 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47063 +4 4 4 4 4 4
47064 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47065 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47066 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47067 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47068 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47069 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47070 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47071 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47072 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47073 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47074 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47075 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47076 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47077 +4 4 4 4 4 4
47078 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47079 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47080 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47081 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47082 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47083 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47084 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47085 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47086 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47087 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47088 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47089 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47090 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47091 +4 4 4 4 4 4
47092 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47093 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47094 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47095 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47096 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47097 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47098 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47099 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47100 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47101 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47102 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47103 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47104 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47105 +4 4 4 4 4 4
47106 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47107 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47108 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47109 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47110 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47111 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47112 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47113 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47114 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47115 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47116 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47117 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47118 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47119 +4 4 4 4 4 4
47120 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47121 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47122 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47123 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47124 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47125 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47126 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47127 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47128 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47129 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47130 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47131 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47132 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47133 +4 4 4 4 4 4
47134 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47135 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47136 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47137 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47138 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47139 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47140 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47141 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47142 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47143 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47144 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47145 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47146 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47147 +4 4 4 4 4 4
47148 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47149 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47150 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47151 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47152 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47153 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47154 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47155 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47156 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47157 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47158 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47159 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47160 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47161 +4 4 4 4 4 4
47162 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47163 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47164 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47165 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47166 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47167 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47168 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47169 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47170 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47171 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47172 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47173 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47174 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47175 +4 4 4 4 4 4
47176 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47177 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47178 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47179 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47180 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47181 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47182 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47183 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47184 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47185 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47186 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47187 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47188 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47189 +4 4 4 4 4 4
47190 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47191 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47192 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47193 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47194 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47195 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47196 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47197 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47198 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47199 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47200 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47201 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47202 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47203 +4 4 4 4 4 4
47204 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47205 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47206 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47207 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47208 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47209 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47210 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47211 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47212 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47213 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47214 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47215 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47216 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47217 +4 4 4 4 4 4
47218 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47219 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47220 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47221 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47222 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47223 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47224 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47225 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47226 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47227 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47228 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47229 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47230 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47231 +4 4 4 4 4 4
47232 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47233 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47234 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47235 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47236 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47237 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47238 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47239 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47240 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47241 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47242 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47243 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47244 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47245 +4 4 4 4 4 4
47246 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47247 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47248 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47249 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47250 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47251 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47252 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47253 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47254 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47255 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47256 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47257 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47258 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47259 +4 4 4 4 4 4
47260 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47261 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47262 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47263 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47264 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47265 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47266 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47267 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47268 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47269 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47270 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47271 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47272 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47273 +4 4 4 4 4 4
47274 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47275 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47276 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47277 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47278 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47279 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47280 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47281 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47282 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47283 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47284 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47285 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47286 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47287 +4 4 4 4 4 4
47288 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47289 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47290 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47291 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47292 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47293 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47294 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47295 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47296 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47297 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47298 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47299 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47300 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47301 +4 4 4 4 4 4
47302 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47303 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47304 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47305 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47306 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47307 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47308 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47309 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47310 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47311 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47312 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47313 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47314 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47315 +4 4 4 4 4 4
47316 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47317 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47318 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47319 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47320 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47321 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47322 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47323 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47324 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47325 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47326 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47327 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47328 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47329 +4 4 4 4 4 4
47330 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47331 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47332 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47333 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47334 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47335 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47336 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47337 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47338 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47339 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47340 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47341 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47342 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47343 +4 4 4 4 4 4
47344 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47345 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47346 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47347 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47348 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47349 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47350 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47351 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47352 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47353 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47354 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47355 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47356 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47357 +4 4 4 4 4 4
47358 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47359 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47360 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47361 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47362 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47363 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47364 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47365 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47366 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47367 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47368 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47369 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47370 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47371 +4 4 4 4 4 4
47372 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47373 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47374 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47375 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47376 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47377 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47378 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47379 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47380 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47381 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47382 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47383 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47385 +4 4 4 4 4 4
47386 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47387 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47388 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47389 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47390 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47391 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47392 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47393 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47394 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47395 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47396 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47397 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47399 +4 4 4 4 4 4
47400 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47401 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47402 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47403 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47404 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47405 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47406 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47407 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47408 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47409 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47410 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47411 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
47414 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47415 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47416 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47417 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47418 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47419 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47420 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47421 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47422 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47423 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47424 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47425 +4 4 4 4 4 4 4 4 4 4 4 4 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
47428 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47429 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47430 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47431 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47432 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47433 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47434 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47435 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47436 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47437 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47441 +4 4 4 4 4 4
47442 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47443 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47444 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47445 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47446 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47447 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47448 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47449 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47450 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47451 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47455 +4 4 4 4 4 4
47456 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47457 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47458 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47459 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47460 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47461 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47462 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47463 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47464 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47465 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47469 +4 4 4 4 4 4
47470 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47471 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47472 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47473 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47474 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47475 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47476 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47477 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47478 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47479 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47483 +4 4 4 4 4 4
47484 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47485 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47486 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47487 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47488 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47489 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47490 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47491 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47492 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47497 +4 4 4 4 4 4
47498 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47499 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47500 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47501 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47502 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47503 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47504 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47505 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47506 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47511 +4 4 4 4 4 4
47512 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47513 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47514 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47515 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47516 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47517 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47518 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47519 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47520 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47525 +4 4 4 4 4 4
47526 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47527 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47528 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47529 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47530 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47531 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47532 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47533 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47539 +4 4 4 4 4 4
47540 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47541 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47542 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47543 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47544 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47545 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47546 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47547 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47553 +4 4 4 4 4 4
47554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47555 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47556 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47557 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47558 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47559 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47560 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47561 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47567 +4 4 4 4 4 4
47568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47569 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47570 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47571 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47572 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47573 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47574 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47575 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47577 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47581 +4 4 4 4 4 4
47582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47583 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47584 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47585 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47586 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47587 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47588 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47589 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47590 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47595 +4 4 4 4 4 4
47596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47598 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47599 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47600 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47601 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47602 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47603 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47604 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47609 +4 4 4 4 4 4
47610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47613 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47614 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47615 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47616 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47618 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47623 +4 4 4 4 4 4
47624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47627 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47628 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47629 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47630 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47632 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47634 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47637 +4 4 4 4 4 4
47638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47641 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47642 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47643 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47644 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47646 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47647 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47651 +4 4 4 4 4 4
47652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47655 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47656 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47657 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47658 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47665 +4 4 4 4 4 4
47666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47670 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47671 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47672 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47679 +4 4 4 4 4 4
47680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47684 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47685 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47686 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47693 +4 4 4 4 4 4
47694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47698 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47699 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47700 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47707 +4 4 4 4 4 4
47708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47712 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47713 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47721 +4 4 4 4 4 4
47722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47726 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47727 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47735 +4 4 4 4 4 4
47736 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47737 index fe92eed..106e085 100644
47738 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47739 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47740 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47741 struct mb862xxfb_par *par = info->par;
47742
47743 if (info->var.bits_per_pixel == 32) {
47744 - info->fbops->fb_fillrect = cfb_fillrect;
47745 - info->fbops->fb_copyarea = cfb_copyarea;
47746 - info->fbops->fb_imageblit = cfb_imageblit;
47747 + pax_open_kernel();
47748 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47749 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47750 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47751 + pax_close_kernel();
47752 } else {
47753 outreg(disp, GC_L0EM, 3);
47754 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47755 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47756 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47757 + pax_open_kernel();
47758 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47759 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47760 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47761 + pax_close_kernel();
47762 }
47763 outreg(draw, GDC_REG_DRAW_BASE, 0);
47764 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47765 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47766 index ff22871..b129bed 100644
47767 --- a/drivers/video/nvidia/nvidia.c
47768 +++ b/drivers/video/nvidia/nvidia.c
47769 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47770 info->fix.line_length = (info->var.xres_virtual *
47771 info->var.bits_per_pixel) >> 3;
47772 if (info->var.accel_flags) {
47773 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47774 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47775 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47776 - info->fbops->fb_sync = nvidiafb_sync;
47777 + pax_open_kernel();
47778 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47779 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47780 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47781 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47782 + pax_close_kernel();
47783 info->pixmap.scan_align = 4;
47784 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47785 info->flags |= FBINFO_READS_FAST;
47786 NVResetGraphics(info);
47787 } else {
47788 - info->fbops->fb_imageblit = cfb_imageblit;
47789 - info->fbops->fb_fillrect = cfb_fillrect;
47790 - info->fbops->fb_copyarea = cfb_copyarea;
47791 - info->fbops->fb_sync = NULL;
47792 + pax_open_kernel();
47793 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47794 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47795 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47796 + *(void **)&info->fbops->fb_sync = NULL;
47797 + pax_close_kernel();
47798 info->pixmap.scan_align = 1;
47799 info->flags |= FBINFO_HWACCEL_DISABLED;
47800 info->flags &= ~FBINFO_READS_FAST;
47801 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47802 info->pixmap.size = 8 * 1024;
47803 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47804
47805 - if (!hwcur)
47806 - info->fbops->fb_cursor = NULL;
47807 + if (!hwcur) {
47808 + pax_open_kernel();
47809 + *(void **)&info->fbops->fb_cursor = NULL;
47810 + pax_close_kernel();
47811 + }
47812
47813 info->var.accel_flags = (!noaccel);
47814
47815 diff --git a/drivers/video/output.c b/drivers/video/output.c
47816 index 0d6f2cd..6285b97 100644
47817 --- a/drivers/video/output.c
47818 +++ b/drivers/video/output.c
47819 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
47820 new_dev->props = op;
47821 new_dev->dev.class = &video_output_class;
47822 new_dev->dev.parent = dev;
47823 - dev_set_name(&new_dev->dev, name);
47824 + dev_set_name(&new_dev->dev, "%s", name);
47825 dev_set_drvdata(&new_dev->dev, devdata);
47826 ret_code = device_register(&new_dev->dev);
47827 if (ret_code) {
47828 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47829 index 76d9053..dec2bfd 100644
47830 --- a/drivers/video/s1d13xxxfb.c
47831 +++ b/drivers/video/s1d13xxxfb.c
47832 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47833
47834 switch(prod_id) {
47835 case S1D13506_PROD_ID: /* activate acceleration */
47836 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47837 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47838 + pax_open_kernel();
47839 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47840 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47841 + pax_close_kernel();
47842 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47843 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47844 break;
47845 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47846 index 97bd662..39fab85 100644
47847 --- a/drivers/video/smscufx.c
47848 +++ b/drivers/video/smscufx.c
47849 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47850 fb_deferred_io_cleanup(info);
47851 kfree(info->fbdefio);
47852 info->fbdefio = NULL;
47853 - info->fbops->fb_mmap = ufx_ops_mmap;
47854 + pax_open_kernel();
47855 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47856 + pax_close_kernel();
47857 }
47858
47859 pr_debug("released /dev/fb%d user=%d count=%d",
47860 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47861 index 86d449e..8e04dc5 100644
47862 --- a/drivers/video/udlfb.c
47863 +++ b/drivers/video/udlfb.c
47864 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47865 dlfb_urb_completion(urb);
47866
47867 error:
47868 - atomic_add(bytes_sent, &dev->bytes_sent);
47869 - atomic_add(bytes_identical, &dev->bytes_identical);
47870 - atomic_add(width*height*2, &dev->bytes_rendered);
47871 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47872 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47873 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47874 end_cycles = get_cycles();
47875 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47876 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47877 >> 10)), /* Kcycles */
47878 &dev->cpu_kcycles_used);
47879
47880 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47881 dlfb_urb_completion(urb);
47882
47883 error:
47884 - atomic_add(bytes_sent, &dev->bytes_sent);
47885 - atomic_add(bytes_identical, &dev->bytes_identical);
47886 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47887 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47888 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47889 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47890 end_cycles = get_cycles();
47891 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47892 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47893 >> 10)), /* Kcycles */
47894 &dev->cpu_kcycles_used);
47895 }
47896 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47897 fb_deferred_io_cleanup(info);
47898 kfree(info->fbdefio);
47899 info->fbdefio = NULL;
47900 - info->fbops->fb_mmap = dlfb_ops_mmap;
47901 + pax_open_kernel();
47902 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47903 + pax_close_kernel();
47904 }
47905
47906 pr_warn("released /dev/fb%d user=%d count=%d\n",
47907 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47908 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47909 struct dlfb_data *dev = fb_info->par;
47910 return snprintf(buf, PAGE_SIZE, "%u\n",
47911 - atomic_read(&dev->bytes_rendered));
47912 + atomic_read_unchecked(&dev->bytes_rendered));
47913 }
47914
47915 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47916 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47917 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47918 struct dlfb_data *dev = fb_info->par;
47919 return snprintf(buf, PAGE_SIZE, "%u\n",
47920 - atomic_read(&dev->bytes_identical));
47921 + atomic_read_unchecked(&dev->bytes_identical));
47922 }
47923
47924 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47925 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47926 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47927 struct dlfb_data *dev = fb_info->par;
47928 return snprintf(buf, PAGE_SIZE, "%u\n",
47929 - atomic_read(&dev->bytes_sent));
47930 + atomic_read_unchecked(&dev->bytes_sent));
47931 }
47932
47933 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47934 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47935 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47936 struct dlfb_data *dev = fb_info->par;
47937 return snprintf(buf, PAGE_SIZE, "%u\n",
47938 - atomic_read(&dev->cpu_kcycles_used));
47939 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47940 }
47941
47942 static ssize_t edid_show(
47943 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47944 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47945 struct dlfb_data *dev = fb_info->par;
47946
47947 - atomic_set(&dev->bytes_rendered, 0);
47948 - atomic_set(&dev->bytes_identical, 0);
47949 - atomic_set(&dev->bytes_sent, 0);
47950 - atomic_set(&dev->cpu_kcycles_used, 0);
47951 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47952 + atomic_set_unchecked(&dev->bytes_identical, 0);
47953 + atomic_set_unchecked(&dev->bytes_sent, 0);
47954 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47955
47956 return count;
47957 }
47958 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47959 index d428445..79a78df 100644
47960 --- a/drivers/video/uvesafb.c
47961 +++ b/drivers/video/uvesafb.c
47962 @@ -19,6 +19,7 @@
47963 #include <linux/io.h>
47964 #include <linux/mutex.h>
47965 #include <linux/slab.h>
47966 +#include <linux/moduleloader.h>
47967 #include <video/edid.h>
47968 #include <video/uvesafb.h>
47969 #ifdef CONFIG_X86
47970 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47971 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47972 par->pmi_setpal = par->ypan = 0;
47973 } else {
47974 +
47975 +#ifdef CONFIG_PAX_KERNEXEC
47976 +#ifdef CONFIG_MODULES
47977 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47978 +#endif
47979 + if (!par->pmi_code) {
47980 + par->pmi_setpal = par->ypan = 0;
47981 + return 0;
47982 + }
47983 +#endif
47984 +
47985 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47986 + task->t.regs.edi);
47987 +
47988 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47989 + pax_open_kernel();
47990 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47991 + pax_close_kernel();
47992 +
47993 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47994 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47995 +#else
47996 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47997 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47998 +#endif
47999 +
48000 printk(KERN_INFO "uvesafb: protected mode interface info at "
48001 "%04x:%04x\n",
48002 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48003 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48004 par->ypan = ypan;
48005
48006 if (par->pmi_setpal || par->ypan) {
48007 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48008 if (__supported_pte_mask & _PAGE_NX) {
48009 par->pmi_setpal = par->ypan = 0;
48010 printk(KERN_WARNING "uvesafb: NX protection is actively."
48011 "We have better not to use the PMI.\n");
48012 - } else {
48013 + } else
48014 +#endif
48015 uvesafb_vbe_getpmi(task, par);
48016 - }
48017 }
48018 #else
48019 /* The protected mode interface is not available on non-x86. */
48020 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48021 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48022
48023 /* Disable blanking if the user requested so. */
48024 - if (!blank)
48025 - info->fbops->fb_blank = NULL;
48026 + if (!blank) {
48027 + pax_open_kernel();
48028 + *(void **)&info->fbops->fb_blank = NULL;
48029 + pax_close_kernel();
48030 + }
48031
48032 /*
48033 * Find out how much IO memory is required for the mode with
48034 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48035 info->flags = FBINFO_FLAG_DEFAULT |
48036 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48037
48038 - if (!par->ypan)
48039 - info->fbops->fb_pan_display = NULL;
48040 + if (!par->ypan) {
48041 + pax_open_kernel();
48042 + *(void **)&info->fbops->fb_pan_display = NULL;
48043 + pax_close_kernel();
48044 + }
48045 }
48046
48047 static void uvesafb_init_mtrr(struct fb_info *info)
48048 @@ -1836,6 +1866,11 @@ out:
48049 if (par->vbe_modes)
48050 kfree(par->vbe_modes);
48051
48052 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48053 + if (par->pmi_code)
48054 + module_free_exec(NULL, par->pmi_code);
48055 +#endif
48056 +
48057 framebuffer_release(info);
48058 return err;
48059 }
48060 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48061 kfree(par->vbe_state_orig);
48062 if (par->vbe_state_saved)
48063 kfree(par->vbe_state_saved);
48064 +
48065 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48066 + if (par->pmi_code)
48067 + module_free_exec(NULL, par->pmi_code);
48068 +#endif
48069 +
48070 }
48071
48072 framebuffer_release(info);
48073 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48074 index 501b340..d80aa17 100644
48075 --- a/drivers/video/vesafb.c
48076 +++ b/drivers/video/vesafb.c
48077 @@ -9,6 +9,7 @@
48078 */
48079
48080 #include <linux/module.h>
48081 +#include <linux/moduleloader.h>
48082 #include <linux/kernel.h>
48083 #include <linux/errno.h>
48084 #include <linux/string.h>
48085 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48086 static int vram_total __initdata; /* Set total amount of memory */
48087 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48088 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48089 -static void (*pmi_start)(void) __read_mostly;
48090 -static void (*pmi_pal) (void) __read_mostly;
48091 +static void (*pmi_start)(void) __read_only;
48092 +static void (*pmi_pal) (void) __read_only;
48093 static int depth __read_mostly;
48094 static int vga_compat __read_mostly;
48095 /* --------------------------------------------------------------------- */
48096 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48097 unsigned int size_vmode;
48098 unsigned int size_remap;
48099 unsigned int size_total;
48100 + void *pmi_code = NULL;
48101
48102 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48103 return -ENODEV;
48104 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48105 size_remap = size_total;
48106 vesafb_fix.smem_len = size_remap;
48107
48108 -#ifndef __i386__
48109 - screen_info.vesapm_seg = 0;
48110 -#endif
48111 -
48112 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48113 printk(KERN_WARNING
48114 "vesafb: cannot reserve video memory at 0x%lx\n",
48115 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48116 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48117 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48118
48119 +#ifdef __i386__
48120 +
48121 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48122 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48123 + if (!pmi_code)
48124 +#elif !defined(CONFIG_PAX_KERNEXEC)
48125 + if (0)
48126 +#endif
48127 +
48128 +#endif
48129 + screen_info.vesapm_seg = 0;
48130 +
48131 if (screen_info.vesapm_seg) {
48132 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48133 - screen_info.vesapm_seg,screen_info.vesapm_off);
48134 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48135 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48136 }
48137
48138 if (screen_info.vesapm_seg < 0xc000)
48139 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48140
48141 if (ypan || pmi_setpal) {
48142 unsigned short *pmi_base;
48143 +
48144 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48145 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48146 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48147 +
48148 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48149 + pax_open_kernel();
48150 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48151 +#else
48152 + pmi_code = pmi_base;
48153 +#endif
48154 +
48155 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48156 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48157 +
48158 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48159 + pmi_start = ktva_ktla(pmi_start);
48160 + pmi_pal = ktva_ktla(pmi_pal);
48161 + pax_close_kernel();
48162 +#endif
48163 +
48164 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48165 if (pmi_base[3]) {
48166 printk(KERN_INFO "vesafb: pmi: ports = ");
48167 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48168 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48169 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48170
48171 - if (!ypan)
48172 - info->fbops->fb_pan_display = NULL;
48173 + if (!ypan) {
48174 + pax_open_kernel();
48175 + *(void **)&info->fbops->fb_pan_display = NULL;
48176 + pax_close_kernel();
48177 + }
48178
48179 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48180 err = -ENOMEM;
48181 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48182 info->node, info->fix.id);
48183 return 0;
48184 err:
48185 +
48186 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48187 + module_free_exec(NULL, pmi_code);
48188 +#endif
48189 +
48190 if (info->screen_base)
48191 iounmap(info->screen_base);
48192 framebuffer_release(info);
48193 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48194 index 88714ae..16c2e11 100644
48195 --- a/drivers/video/via/via_clock.h
48196 +++ b/drivers/video/via/via_clock.h
48197 @@ -56,7 +56,7 @@ struct via_clock {
48198
48199 void (*set_engine_pll_state)(u8 state);
48200 void (*set_engine_pll)(struct via_pll_config config);
48201 -};
48202 +} __no_const;
48203
48204
48205 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48206 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48207 index fef20db..d28b1ab 100644
48208 --- a/drivers/xen/xenfs/xenstored.c
48209 +++ b/drivers/xen/xenfs/xenstored.c
48210 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48211 static int xsd_kva_open(struct inode *inode, struct file *file)
48212 {
48213 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48214 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48215 + NULL);
48216 +#else
48217 xen_store_interface);
48218 +#endif
48219 +
48220 if (!file->private_data)
48221 return -ENOMEM;
48222 return 0;
48223 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
48224 index 0ad61c6..f198bd7 100644
48225 --- a/fs/9p/vfs_addr.c
48226 +++ b/fs/9p/vfs_addr.c
48227 @@ -185,7 +185,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
48228
48229 retval = v9fs_file_write_internal(inode,
48230 v9inode->writeback_fid,
48231 - (__force const char __user *)buffer,
48232 + (const char __force_user *)buffer,
48233 len, &offset, 0);
48234 if (retval > 0)
48235 retval = 0;
48236 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48237 index d86edc8..40ff2fb 100644
48238 --- a/fs/9p/vfs_inode.c
48239 +++ b/fs/9p/vfs_inode.c
48240 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48241 void
48242 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48243 {
48244 - char *s = nd_get_link(nd);
48245 + const char *s = nd_get_link(nd);
48246
48247 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48248 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48249 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48250 index 0efd152..b5802ad 100644
48251 --- a/fs/Kconfig.binfmt
48252 +++ b/fs/Kconfig.binfmt
48253 @@ -89,7 +89,7 @@ config HAVE_AOUT
48254
48255 config BINFMT_AOUT
48256 tristate "Kernel support for a.out and ECOFF binaries"
48257 - depends on HAVE_AOUT
48258 + depends on HAVE_AOUT && BROKEN
48259 ---help---
48260 A.out (Assembler.OUTput) is a set of formats for libraries and
48261 executables used in the earliest versions of UNIX. Linux used
48262 diff --git a/fs/aio.c b/fs/aio.c
48263 index 1dc8786..d3b29e8 100644
48264 --- a/fs/aio.c
48265 +++ b/fs/aio.c
48266 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48267 size += sizeof(struct io_event) * nr_events;
48268 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48269
48270 - if (nr_pages < 0)
48271 + if (nr_pages <= 0)
48272 return -EINVAL;
48273
48274 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48275 @@ -1375,18 +1375,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
48276 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48277 {
48278 ssize_t ret;
48279 + struct iovec iovstack;
48280
48281 #ifdef CONFIG_COMPAT
48282 if (compat)
48283 ret = compat_rw_copy_check_uvector(type,
48284 (struct compat_iovec __user *)kiocb->ki_buf,
48285 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48286 + kiocb->ki_nbytes, 1, &iovstack,
48287 &kiocb->ki_iovec);
48288 else
48289 #endif
48290 ret = rw_copy_check_uvector(type,
48291 (struct iovec __user *)kiocb->ki_buf,
48292 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48293 + kiocb->ki_nbytes, 1, &iovstack,
48294 &kiocb->ki_iovec);
48295 if (ret < 0)
48296 goto out;
48297 @@ -1395,6 +1396,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48298 if (ret < 0)
48299 goto out;
48300
48301 + if (kiocb->ki_iovec == &iovstack) {
48302 + kiocb->ki_inline_vec = iovstack;
48303 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48304 + }
48305 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48306 kiocb->ki_cur_seg = 0;
48307 /* ki_nbytes/left now reflect bytes instead of segs */
48308 diff --git a/fs/attr.c b/fs/attr.c
48309 index 1449adb..a2038c2 100644
48310 --- a/fs/attr.c
48311 +++ b/fs/attr.c
48312 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48313 unsigned long limit;
48314
48315 limit = rlimit(RLIMIT_FSIZE);
48316 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48317 if (limit != RLIM_INFINITY && offset > limit)
48318 goto out_sig;
48319 if (offset > inode->i_sb->s_maxbytes)
48320 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48321 index 3db70da..7aeec5b 100644
48322 --- a/fs/autofs4/waitq.c
48323 +++ b/fs/autofs4/waitq.c
48324 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48325 {
48326 unsigned long sigpipe, flags;
48327 mm_segment_t fs;
48328 - const char *data = (const char *)addr;
48329 + const char __user *data = (const char __force_user *)addr;
48330 ssize_t wr = 0;
48331
48332 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48333 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48334 return 1;
48335 }
48336
48337 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48338 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48339 +#endif
48340 +
48341 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48342 enum autofs_notify notify)
48343 {
48344 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48345
48346 /* If this is a direct mount request create a dummy name */
48347 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48348 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48349 + /* this name does get written to userland via autofs4_write() */
48350 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48351 +#else
48352 qstr.len = sprintf(name, "%p", dentry);
48353 +#endif
48354 else {
48355 qstr.len = autofs4_getpath(sbi, dentry, &name);
48356 if (!qstr.len) {
48357 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48358 index 2722387..c8dd2a7 100644
48359 --- a/fs/befs/endian.h
48360 +++ b/fs/befs/endian.h
48361 @@ -11,7 +11,7 @@
48362
48363 #include <asm/byteorder.h>
48364
48365 -static inline u64
48366 +static inline u64 __intentional_overflow(-1)
48367 fs64_to_cpu(const struct super_block *sb, fs64 n)
48368 {
48369 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48370 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48371 return (__force fs64)cpu_to_be64(n);
48372 }
48373
48374 -static inline u32
48375 +static inline u32 __intentional_overflow(-1)
48376 fs32_to_cpu(const struct super_block *sb, fs32 n)
48377 {
48378 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48379 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48380 index 8615ee8..388ed68 100644
48381 --- a/fs/befs/linuxvfs.c
48382 +++ b/fs/befs/linuxvfs.c
48383 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48384 {
48385 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48386 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48387 - char *link = nd_get_link(nd);
48388 + const char *link = nd_get_link(nd);
48389 if (!IS_ERR(link))
48390 kfree(link);
48391 }
48392 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48393 index bbc8f88..7c7ac97 100644
48394 --- a/fs/binfmt_aout.c
48395 +++ b/fs/binfmt_aout.c
48396 @@ -16,6 +16,7 @@
48397 #include <linux/string.h>
48398 #include <linux/fs.h>
48399 #include <linux/file.h>
48400 +#include <linux/security.h>
48401 #include <linux/stat.h>
48402 #include <linux/fcntl.h>
48403 #include <linux/ptrace.h>
48404 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48405 #endif
48406 # define START_STACK(u) ((void __user *)u.start_stack)
48407
48408 + memset(&dump, 0, sizeof(dump));
48409 +
48410 fs = get_fs();
48411 set_fs(KERNEL_DS);
48412 has_dumped = 1;
48413 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48414
48415 /* If the size of the dump file exceeds the rlimit, then see what would happen
48416 if we wrote the stack, but not the data area. */
48417 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48418 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48419 dump.u_dsize = 0;
48420
48421 /* Make sure we have enough room to write the stack and data areas. */
48422 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48423 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48424 dump.u_ssize = 0;
48425
48426 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48427 rlim = rlimit(RLIMIT_DATA);
48428 if (rlim >= RLIM_INFINITY)
48429 rlim = ~0;
48430 +
48431 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48432 if (ex.a_data + ex.a_bss > rlim)
48433 return -ENOMEM;
48434
48435 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48436
48437 install_exec_creds(bprm);
48438
48439 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48440 + current->mm->pax_flags = 0UL;
48441 +#endif
48442 +
48443 +#ifdef CONFIG_PAX_PAGEEXEC
48444 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48445 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48446 +
48447 +#ifdef CONFIG_PAX_EMUTRAMP
48448 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48449 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48450 +#endif
48451 +
48452 +#ifdef CONFIG_PAX_MPROTECT
48453 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48454 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48455 +#endif
48456 +
48457 + }
48458 +#endif
48459 +
48460 if (N_MAGIC(ex) == OMAGIC) {
48461 unsigned long text_addr, map_size;
48462 loff_t pos;
48463 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48464 }
48465
48466 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48467 - PROT_READ | PROT_WRITE | PROT_EXEC,
48468 + PROT_READ | PROT_WRITE,
48469 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48470 fd_offset + ex.a_text);
48471 if (error != N_DATADDR(ex)) {
48472 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48473 index 86af964..5d53bf6 100644
48474 --- a/fs/binfmt_elf.c
48475 +++ b/fs/binfmt_elf.c
48476 @@ -34,6 +34,7 @@
48477 #include <linux/utsname.h>
48478 #include <linux/coredump.h>
48479 #include <linux/sched.h>
48480 +#include <linux/xattr.h>
48481 #include <asm/uaccess.h>
48482 #include <asm/param.h>
48483 #include <asm/page.h>
48484 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48485 #define elf_core_dump NULL
48486 #endif
48487
48488 +#ifdef CONFIG_PAX_MPROTECT
48489 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48490 +#endif
48491 +
48492 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48493 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48494 #else
48495 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
48496 .load_binary = load_elf_binary,
48497 .load_shlib = load_elf_library,
48498 .core_dump = elf_core_dump,
48499 +
48500 +#ifdef CONFIG_PAX_MPROTECT
48501 + .handle_mprotect= elf_handle_mprotect,
48502 +#endif
48503 +
48504 .min_coredump = ELF_EXEC_PAGESIZE,
48505 };
48506
48507 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
48508
48509 static int set_brk(unsigned long start, unsigned long end)
48510 {
48511 + unsigned long e = end;
48512 +
48513 start = ELF_PAGEALIGN(start);
48514 end = ELF_PAGEALIGN(end);
48515 if (end > start) {
48516 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
48517 if (BAD_ADDR(addr))
48518 return addr;
48519 }
48520 - current->mm->start_brk = current->mm->brk = end;
48521 + current->mm->start_brk = current->mm->brk = e;
48522 return 0;
48523 }
48524
48525 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48526 elf_addr_t __user *u_rand_bytes;
48527 const char *k_platform = ELF_PLATFORM;
48528 const char *k_base_platform = ELF_BASE_PLATFORM;
48529 - unsigned char k_rand_bytes[16];
48530 + u32 k_rand_bytes[4];
48531 int items;
48532 elf_addr_t *elf_info;
48533 int ei_index = 0;
48534 const struct cred *cred = current_cred();
48535 struct vm_area_struct *vma;
48536 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48537
48538 /*
48539 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48540 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48541 * Generate 16 random bytes for userspace PRNG seeding.
48542 */
48543 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48544 - u_rand_bytes = (elf_addr_t __user *)
48545 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48546 + srandom32(k_rand_bytes[0] ^ random32());
48547 + srandom32(k_rand_bytes[1] ^ random32());
48548 + srandom32(k_rand_bytes[2] ^ random32());
48549 + srandom32(k_rand_bytes[3] ^ random32());
48550 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48551 + u_rand_bytes = (elf_addr_t __user *) p;
48552 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48553 return -EFAULT;
48554
48555 @@ -315,9 +332,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48556 return -EFAULT;
48557 current->mm->env_end = p;
48558
48559 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48560 +
48561 /* Put the elf_info on the stack in the right place. */
48562 sp = (elf_addr_t __user *)envp + 1;
48563 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48564 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48565 return -EFAULT;
48566 return 0;
48567 }
48568 @@ -385,15 +404,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48569 an ELF header */
48570
48571 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48572 - struct file *interpreter, unsigned long *interp_map_addr,
48573 - unsigned long no_base)
48574 + struct file *interpreter, unsigned long no_base)
48575 {
48576 struct elf_phdr *elf_phdata;
48577 struct elf_phdr *eppnt;
48578 - unsigned long load_addr = 0;
48579 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48580 int load_addr_set = 0;
48581 unsigned long last_bss = 0, elf_bss = 0;
48582 - unsigned long error = ~0UL;
48583 + unsigned long error = -EINVAL;
48584 unsigned long total_size;
48585 int retval, i, size;
48586
48587 @@ -439,6 +457,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48588 goto out_close;
48589 }
48590
48591 +#ifdef CONFIG_PAX_SEGMEXEC
48592 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48593 + pax_task_size = SEGMEXEC_TASK_SIZE;
48594 +#endif
48595 +
48596 eppnt = elf_phdata;
48597 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48598 if (eppnt->p_type == PT_LOAD) {
48599 @@ -462,8 +485,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48600 map_addr = elf_map(interpreter, load_addr + vaddr,
48601 eppnt, elf_prot, elf_type, total_size);
48602 total_size = 0;
48603 - if (!*interp_map_addr)
48604 - *interp_map_addr = map_addr;
48605 error = map_addr;
48606 if (BAD_ADDR(map_addr))
48607 goto out_close;
48608 @@ -482,8 +503,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48609 k = load_addr + eppnt->p_vaddr;
48610 if (BAD_ADDR(k) ||
48611 eppnt->p_filesz > eppnt->p_memsz ||
48612 - eppnt->p_memsz > TASK_SIZE ||
48613 - TASK_SIZE - eppnt->p_memsz < k) {
48614 + eppnt->p_memsz > pax_task_size ||
48615 + pax_task_size - eppnt->p_memsz < k) {
48616 error = -ENOMEM;
48617 goto out_close;
48618 }
48619 @@ -535,6 +556,315 @@ out:
48620 return error;
48621 }
48622
48623 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48624 +#ifdef CONFIG_PAX_SOFTMODE
48625 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48626 +{
48627 + unsigned long pax_flags = 0UL;
48628 +
48629 +#ifdef CONFIG_PAX_PAGEEXEC
48630 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48631 + pax_flags |= MF_PAX_PAGEEXEC;
48632 +#endif
48633 +
48634 +#ifdef CONFIG_PAX_SEGMEXEC
48635 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48636 + pax_flags |= MF_PAX_SEGMEXEC;
48637 +#endif
48638 +
48639 +#ifdef CONFIG_PAX_EMUTRAMP
48640 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48641 + pax_flags |= MF_PAX_EMUTRAMP;
48642 +#endif
48643 +
48644 +#ifdef CONFIG_PAX_MPROTECT
48645 + if (elf_phdata->p_flags & PF_MPROTECT)
48646 + pax_flags |= MF_PAX_MPROTECT;
48647 +#endif
48648 +
48649 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48650 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48651 + pax_flags |= MF_PAX_RANDMMAP;
48652 +#endif
48653 +
48654 + return pax_flags;
48655 +}
48656 +#endif
48657 +
48658 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48659 +{
48660 + unsigned long pax_flags = 0UL;
48661 +
48662 +#ifdef CONFIG_PAX_PAGEEXEC
48663 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48664 + pax_flags |= MF_PAX_PAGEEXEC;
48665 +#endif
48666 +
48667 +#ifdef CONFIG_PAX_SEGMEXEC
48668 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48669 + pax_flags |= MF_PAX_SEGMEXEC;
48670 +#endif
48671 +
48672 +#ifdef CONFIG_PAX_EMUTRAMP
48673 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48674 + pax_flags |= MF_PAX_EMUTRAMP;
48675 +#endif
48676 +
48677 +#ifdef CONFIG_PAX_MPROTECT
48678 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48679 + pax_flags |= MF_PAX_MPROTECT;
48680 +#endif
48681 +
48682 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48683 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48684 + pax_flags |= MF_PAX_RANDMMAP;
48685 +#endif
48686 +
48687 + return pax_flags;
48688 +}
48689 +#endif
48690 +
48691 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48692 +#ifdef CONFIG_PAX_SOFTMODE
48693 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48694 +{
48695 + unsigned long pax_flags = 0UL;
48696 +
48697 +#ifdef CONFIG_PAX_PAGEEXEC
48698 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48699 + pax_flags |= MF_PAX_PAGEEXEC;
48700 +#endif
48701 +
48702 +#ifdef CONFIG_PAX_SEGMEXEC
48703 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48704 + pax_flags |= MF_PAX_SEGMEXEC;
48705 +#endif
48706 +
48707 +#ifdef CONFIG_PAX_EMUTRAMP
48708 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48709 + pax_flags |= MF_PAX_EMUTRAMP;
48710 +#endif
48711 +
48712 +#ifdef CONFIG_PAX_MPROTECT
48713 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48714 + pax_flags |= MF_PAX_MPROTECT;
48715 +#endif
48716 +
48717 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48718 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48719 + pax_flags |= MF_PAX_RANDMMAP;
48720 +#endif
48721 +
48722 + return pax_flags;
48723 +}
48724 +#endif
48725 +
48726 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48727 +{
48728 + unsigned long pax_flags = 0UL;
48729 +
48730 +#ifdef CONFIG_PAX_PAGEEXEC
48731 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48732 + pax_flags |= MF_PAX_PAGEEXEC;
48733 +#endif
48734 +
48735 +#ifdef CONFIG_PAX_SEGMEXEC
48736 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48737 + pax_flags |= MF_PAX_SEGMEXEC;
48738 +#endif
48739 +
48740 +#ifdef CONFIG_PAX_EMUTRAMP
48741 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48742 + pax_flags |= MF_PAX_EMUTRAMP;
48743 +#endif
48744 +
48745 +#ifdef CONFIG_PAX_MPROTECT
48746 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48747 + pax_flags |= MF_PAX_MPROTECT;
48748 +#endif
48749 +
48750 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48751 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48752 + pax_flags |= MF_PAX_RANDMMAP;
48753 +#endif
48754 +
48755 + return pax_flags;
48756 +}
48757 +#endif
48758 +
48759 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48760 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48761 +{
48762 + unsigned long pax_flags = 0UL;
48763 +
48764 +#ifdef CONFIG_PAX_EI_PAX
48765 +
48766 +#ifdef CONFIG_PAX_PAGEEXEC
48767 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48768 + pax_flags |= MF_PAX_PAGEEXEC;
48769 +#endif
48770 +
48771 +#ifdef CONFIG_PAX_SEGMEXEC
48772 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48773 + pax_flags |= MF_PAX_SEGMEXEC;
48774 +#endif
48775 +
48776 +#ifdef CONFIG_PAX_EMUTRAMP
48777 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48778 + pax_flags |= MF_PAX_EMUTRAMP;
48779 +#endif
48780 +
48781 +#ifdef CONFIG_PAX_MPROTECT
48782 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48783 + pax_flags |= MF_PAX_MPROTECT;
48784 +#endif
48785 +
48786 +#ifdef CONFIG_PAX_ASLR
48787 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48788 + pax_flags |= MF_PAX_RANDMMAP;
48789 +#endif
48790 +
48791 +#else
48792 +
48793 +#ifdef CONFIG_PAX_PAGEEXEC
48794 + pax_flags |= MF_PAX_PAGEEXEC;
48795 +#endif
48796 +
48797 +#ifdef CONFIG_PAX_SEGMEXEC
48798 + pax_flags |= MF_PAX_SEGMEXEC;
48799 +#endif
48800 +
48801 +#ifdef CONFIG_PAX_MPROTECT
48802 + pax_flags |= MF_PAX_MPROTECT;
48803 +#endif
48804 +
48805 +#ifdef CONFIG_PAX_RANDMMAP
48806 + if (randomize_va_space)
48807 + pax_flags |= MF_PAX_RANDMMAP;
48808 +#endif
48809 +
48810 +#endif
48811 +
48812 + return pax_flags;
48813 +}
48814 +
48815 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48816 +{
48817 +
48818 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48819 + unsigned long i;
48820 +
48821 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48822 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48823 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48824 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48825 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48826 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48827 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48828 + return ~0UL;
48829 +
48830 +#ifdef CONFIG_PAX_SOFTMODE
48831 + if (pax_softmode)
48832 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48833 + else
48834 +#endif
48835 +
48836 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48837 + break;
48838 + }
48839 +#endif
48840 +
48841 + return ~0UL;
48842 +}
48843 +
48844 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48845 +{
48846 +
48847 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48848 + ssize_t xattr_size, i;
48849 + unsigned char xattr_value[sizeof("pemrs") - 1];
48850 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48851 +
48852 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
48853 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
48854 + return ~0UL;
48855 +
48856 + for (i = 0; i < xattr_size; i++)
48857 + switch (xattr_value[i]) {
48858 + default:
48859 + return ~0UL;
48860 +
48861 +#define parse_flag(option1, option2, flag) \
48862 + case option1: \
48863 + if (pax_flags_hardmode & MF_PAX_##flag) \
48864 + return ~0UL; \
48865 + pax_flags_hardmode |= MF_PAX_##flag; \
48866 + break; \
48867 + case option2: \
48868 + if (pax_flags_softmode & MF_PAX_##flag) \
48869 + return ~0UL; \
48870 + pax_flags_softmode |= MF_PAX_##flag; \
48871 + break;
48872 +
48873 + parse_flag('p', 'P', PAGEEXEC);
48874 + parse_flag('e', 'E', EMUTRAMP);
48875 + parse_flag('m', 'M', MPROTECT);
48876 + parse_flag('r', 'R', RANDMMAP);
48877 + parse_flag('s', 'S', SEGMEXEC);
48878 +
48879 +#undef parse_flag
48880 + }
48881 +
48882 + if (pax_flags_hardmode & pax_flags_softmode)
48883 + return ~0UL;
48884 +
48885 +#ifdef CONFIG_PAX_SOFTMODE
48886 + if (pax_softmode)
48887 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48888 + else
48889 +#endif
48890 +
48891 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48892 +#else
48893 + return ~0UL;
48894 +#endif
48895 +
48896 +}
48897 +
48898 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48899 +{
48900 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48901 +
48902 + pax_flags = pax_parse_ei_pax(elf_ex);
48903 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48904 + xattr_pax_flags = pax_parse_xattr_pax(file);
48905 +
48906 + if (pt_pax_flags == ~0UL)
48907 + pt_pax_flags = xattr_pax_flags;
48908 + else if (xattr_pax_flags == ~0UL)
48909 + xattr_pax_flags = pt_pax_flags;
48910 + if (pt_pax_flags != xattr_pax_flags)
48911 + return -EINVAL;
48912 + if (pt_pax_flags != ~0UL)
48913 + pax_flags = pt_pax_flags;
48914 +
48915 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48916 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48917 + if ((__supported_pte_mask & _PAGE_NX))
48918 + pax_flags &= ~MF_PAX_SEGMEXEC;
48919 + else
48920 + pax_flags &= ~MF_PAX_PAGEEXEC;
48921 + }
48922 +#endif
48923 +
48924 + if (0 > pax_check_flags(&pax_flags))
48925 + return -EINVAL;
48926 +
48927 + current->mm->pax_flags = pax_flags;
48928 + return 0;
48929 +}
48930 +#endif
48931 +
48932 /*
48933 * These are the functions used to load ELF style executables and shared
48934 * libraries. There is no binary dependent code anywhere else.
48935 @@ -551,6 +881,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48936 {
48937 unsigned int random_variable = 0;
48938
48939 +#ifdef CONFIG_PAX_RANDUSTACK
48940 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48941 + return stack_top - current->mm->delta_stack;
48942 +#endif
48943 +
48944 if ((current->flags & PF_RANDOMIZE) &&
48945 !(current->personality & ADDR_NO_RANDOMIZE)) {
48946 random_variable = get_random_int() & STACK_RND_MASK;
48947 @@ -569,7 +904,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48948 unsigned long load_addr = 0, load_bias = 0;
48949 int load_addr_set = 0;
48950 char * elf_interpreter = NULL;
48951 - unsigned long error;
48952 + unsigned long error = 0;
48953 struct elf_phdr *elf_ppnt, *elf_phdata;
48954 unsigned long elf_bss, elf_brk;
48955 int retval, i;
48956 @@ -579,12 +914,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48957 unsigned long start_code, end_code, start_data, end_data;
48958 unsigned long reloc_func_desc __maybe_unused = 0;
48959 int executable_stack = EXSTACK_DEFAULT;
48960 - unsigned long def_flags = 0;
48961 struct pt_regs *regs = current_pt_regs();
48962 struct {
48963 struct elfhdr elf_ex;
48964 struct elfhdr interp_elf_ex;
48965 } *loc;
48966 + unsigned long pax_task_size = TASK_SIZE;
48967
48968 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48969 if (!loc) {
48970 @@ -720,11 +1055,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48971 goto out_free_dentry;
48972
48973 /* OK, This is the point of no return */
48974 - current->mm->def_flags = def_flags;
48975 +
48976 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48977 + current->mm->pax_flags = 0UL;
48978 +#endif
48979 +
48980 +#ifdef CONFIG_PAX_DLRESOLVE
48981 + current->mm->call_dl_resolve = 0UL;
48982 +#endif
48983 +
48984 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48985 + current->mm->call_syscall = 0UL;
48986 +#endif
48987 +
48988 +#ifdef CONFIG_PAX_ASLR
48989 + current->mm->delta_mmap = 0UL;
48990 + current->mm->delta_stack = 0UL;
48991 +#endif
48992 +
48993 + current->mm->def_flags = 0;
48994 +
48995 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48996 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48997 + send_sig(SIGKILL, current, 0);
48998 + goto out_free_dentry;
48999 + }
49000 +#endif
49001 +
49002 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49003 + pax_set_initial_flags(bprm);
49004 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49005 + if (pax_set_initial_flags_func)
49006 + (pax_set_initial_flags_func)(bprm);
49007 +#endif
49008 +
49009 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49010 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49011 + current->mm->context.user_cs_limit = PAGE_SIZE;
49012 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49013 + }
49014 +#endif
49015 +
49016 +#ifdef CONFIG_PAX_SEGMEXEC
49017 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49018 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49019 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49020 + pax_task_size = SEGMEXEC_TASK_SIZE;
49021 + current->mm->def_flags |= VM_NOHUGEPAGE;
49022 + }
49023 +#endif
49024 +
49025 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49026 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49027 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49028 + put_cpu();
49029 + }
49030 +#endif
49031
49032 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49033 may depend on the personality. */
49034 SET_PERSONALITY(loc->elf_ex);
49035 +
49036 +#ifdef CONFIG_PAX_ASLR
49037 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49038 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49039 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49040 + }
49041 +#endif
49042 +
49043 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49044 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49045 + executable_stack = EXSTACK_DISABLE_X;
49046 + current->personality &= ~READ_IMPLIES_EXEC;
49047 + } else
49048 +#endif
49049 +
49050 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49051 current->personality |= READ_IMPLIES_EXEC;
49052
49053 @@ -815,6 +1220,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49054 #else
49055 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49056 #endif
49057 +
49058 +#ifdef CONFIG_PAX_RANDMMAP
49059 + /* PaX: randomize base address at the default exe base if requested */
49060 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49061 +#ifdef CONFIG_SPARC64
49062 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49063 +#else
49064 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49065 +#endif
49066 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49067 + elf_flags |= MAP_FIXED;
49068 + }
49069 +#endif
49070 +
49071 }
49072
49073 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49074 @@ -847,9 +1266,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49075 * allowed task size. Note that p_filesz must always be
49076 * <= p_memsz so it is only necessary to check p_memsz.
49077 */
49078 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49079 - elf_ppnt->p_memsz > TASK_SIZE ||
49080 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49081 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49082 + elf_ppnt->p_memsz > pax_task_size ||
49083 + pax_task_size - elf_ppnt->p_memsz < k) {
49084 /* set_brk can never work. Avoid overflows. */
49085 send_sig(SIGKILL, current, 0);
49086 retval = -EINVAL;
49087 @@ -888,17 +1307,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
49088 goto out_free_dentry;
49089 }
49090 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49091 - send_sig(SIGSEGV, current, 0);
49092 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49093 - goto out_free_dentry;
49094 + /*
49095 + * This bss-zeroing can fail if the ELF
49096 + * file specifies odd protections. So
49097 + * we don't check the return value
49098 + */
49099 }
49100
49101 +#ifdef CONFIG_PAX_RANDMMAP
49102 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49103 + unsigned long start, size, flags;
49104 + vm_flags_t vm_flags;
49105 +
49106 + start = ELF_PAGEALIGN(elf_brk);
49107 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49108 + flags = MAP_FIXED | MAP_PRIVATE;
49109 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49110 +
49111 + down_write(&current->mm->mmap_sem);
49112 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49113 + retval = -ENOMEM;
49114 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49115 +// if (current->personality & ADDR_NO_RANDOMIZE)
49116 +// vm_flags |= VM_READ | VM_MAYREAD;
49117 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
49118 + retval = IS_ERR_VALUE(start) ? start : 0;
49119 + }
49120 + up_write(&current->mm->mmap_sem);
49121 + if (retval == 0)
49122 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49123 + if (retval < 0) {
49124 + send_sig(SIGKILL, current, 0);
49125 + goto out_free_dentry;
49126 + }
49127 + }
49128 +#endif
49129 +
49130 if (elf_interpreter) {
49131 - unsigned long interp_map_addr = 0;
49132 -
49133 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49134 interpreter,
49135 - &interp_map_addr,
49136 load_bias);
49137 if (!IS_ERR((void *)elf_entry)) {
49138 /*
49139 @@ -1120,7 +1567,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49140 * Decide what to dump of a segment, part, all or none.
49141 */
49142 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49143 - unsigned long mm_flags)
49144 + unsigned long mm_flags, long signr)
49145 {
49146 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49147
49148 @@ -1158,7 +1605,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49149 if (vma->vm_file == NULL)
49150 return 0;
49151
49152 - if (FILTER(MAPPED_PRIVATE))
49153 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49154 goto whole;
49155
49156 /*
49157 @@ -1383,9 +1830,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49158 {
49159 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49160 int i = 0;
49161 - do
49162 + do {
49163 i += 2;
49164 - while (auxv[i - 2] != AT_NULL);
49165 + } while (auxv[i - 2] != AT_NULL);
49166 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49167 }
49168
49169 @@ -1394,7 +1841,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
49170 {
49171 mm_segment_t old_fs = get_fs();
49172 set_fs(KERNEL_DS);
49173 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
49174 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
49175 set_fs(old_fs);
49176 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
49177 }
49178 @@ -2015,14 +2462,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49179 }
49180
49181 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49182 - unsigned long mm_flags)
49183 + struct coredump_params *cprm)
49184 {
49185 struct vm_area_struct *vma;
49186 size_t size = 0;
49187
49188 for (vma = first_vma(current, gate_vma); vma != NULL;
49189 vma = next_vma(vma, gate_vma))
49190 - size += vma_dump_size(vma, mm_flags);
49191 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49192 return size;
49193 }
49194
49195 @@ -2116,7 +2563,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49196
49197 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49198
49199 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49200 + offset += elf_core_vma_data_size(gate_vma, cprm);
49201 offset += elf_core_extra_data_size();
49202 e_shoff = offset;
49203
49204 @@ -2130,10 +2577,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49205 offset = dataoff;
49206
49207 size += sizeof(*elf);
49208 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49209 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49210 goto end_coredump;
49211
49212 size += sizeof(*phdr4note);
49213 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49214 if (size > cprm->limit
49215 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49216 goto end_coredump;
49217 @@ -2147,7 +2596,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49218 phdr.p_offset = offset;
49219 phdr.p_vaddr = vma->vm_start;
49220 phdr.p_paddr = 0;
49221 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49222 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49223 phdr.p_memsz = vma->vm_end - vma->vm_start;
49224 offset += phdr.p_filesz;
49225 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49226 @@ -2158,6 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49227 phdr.p_align = ELF_EXEC_PAGESIZE;
49228
49229 size += sizeof(phdr);
49230 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49231 if (size > cprm->limit
49232 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49233 goto end_coredump;
49234 @@ -2182,7 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49235 unsigned long addr;
49236 unsigned long end;
49237
49238 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49239 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49240
49241 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49242 struct page *page;
49243 @@ -2191,6 +2641,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49244 page = get_dump_page(addr);
49245 if (page) {
49246 void *kaddr = kmap(page);
49247 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49248 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49249 !dump_write(cprm->file, kaddr,
49250 PAGE_SIZE);
49251 @@ -2208,6 +2659,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49252
49253 if (e_phnum == PN_XNUM) {
49254 size += sizeof(*shdr4extnum);
49255 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49256 if (size > cprm->limit
49257 || !dump_write(cprm->file, shdr4extnum,
49258 sizeof(*shdr4extnum)))
49259 @@ -2228,6 +2680,97 @@ out:
49260
49261 #endif /* CONFIG_ELF_CORE */
49262
49263 +#ifdef CONFIG_PAX_MPROTECT
49264 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49265 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49266 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49267 + *
49268 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49269 + * basis because we want to allow the common case and not the special ones.
49270 + */
49271 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49272 +{
49273 + struct elfhdr elf_h;
49274 + struct elf_phdr elf_p;
49275 + unsigned long i;
49276 + unsigned long oldflags;
49277 + bool is_textrel_rw, is_textrel_rx, is_relro;
49278 +
49279 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49280 + return;
49281 +
49282 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49283 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49284 +
49285 +#ifdef CONFIG_PAX_ELFRELOCS
49286 + /* possible TEXTREL */
49287 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49288 + 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);
49289 +#else
49290 + is_textrel_rw = false;
49291 + is_textrel_rx = false;
49292 +#endif
49293 +
49294 + /* possible RELRO */
49295 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49296 +
49297 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49298 + return;
49299 +
49300 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49301 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49302 +
49303 +#ifdef CONFIG_PAX_ETEXECRELOCS
49304 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49305 +#else
49306 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49307 +#endif
49308 +
49309 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49310 + !elf_check_arch(&elf_h) ||
49311 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49312 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49313 + return;
49314 +
49315 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49316 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49317 + return;
49318 + switch (elf_p.p_type) {
49319 + case PT_DYNAMIC:
49320 + if (!is_textrel_rw && !is_textrel_rx)
49321 + continue;
49322 + i = 0UL;
49323 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49324 + elf_dyn dyn;
49325 +
49326 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49327 + return;
49328 + if (dyn.d_tag == DT_NULL)
49329 + return;
49330 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49331 + gr_log_textrel(vma);
49332 + if (is_textrel_rw)
49333 + vma->vm_flags |= VM_MAYWRITE;
49334 + else
49335 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49336 + vma->vm_flags &= ~VM_MAYWRITE;
49337 + return;
49338 + }
49339 + i++;
49340 + }
49341 + return;
49342 +
49343 + case PT_GNU_RELRO:
49344 + if (!is_relro)
49345 + continue;
49346 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49347 + vma->vm_flags &= ~VM_MAYWRITE;
49348 + return;
49349 + }
49350 + }
49351 +}
49352 +#endif
49353 +
49354 static int __init init_elf_binfmt(void)
49355 {
49356 register_binfmt(&elf_format);
49357 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49358 index 2036d21..b0430d0 100644
49359 --- a/fs/binfmt_flat.c
49360 +++ b/fs/binfmt_flat.c
49361 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49362 realdatastart = (unsigned long) -ENOMEM;
49363 printk("Unable to allocate RAM for process data, errno %d\n",
49364 (int)-realdatastart);
49365 + down_write(&current->mm->mmap_sem);
49366 vm_munmap(textpos, text_len);
49367 + up_write(&current->mm->mmap_sem);
49368 ret = realdatastart;
49369 goto err;
49370 }
49371 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49372 }
49373 if (IS_ERR_VALUE(result)) {
49374 printk("Unable to read data+bss, errno %d\n", (int)-result);
49375 + down_write(&current->mm->mmap_sem);
49376 vm_munmap(textpos, text_len);
49377 vm_munmap(realdatastart, len);
49378 + up_write(&current->mm->mmap_sem);
49379 ret = result;
49380 goto err;
49381 }
49382 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49383 }
49384 if (IS_ERR_VALUE(result)) {
49385 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49386 + down_write(&current->mm->mmap_sem);
49387 vm_munmap(textpos, text_len + data_len + extra +
49388 MAX_SHARED_LIBS * sizeof(unsigned long));
49389 + up_write(&current->mm->mmap_sem);
49390 ret = result;
49391 goto err;
49392 }
49393 diff --git a/fs/bio.c b/fs/bio.c
49394 index b96fc6c..431d628 100644
49395 --- a/fs/bio.c
49396 +++ b/fs/bio.c
49397 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49398 /*
49399 * Overflow, abort
49400 */
49401 - if (end < start)
49402 + if (end < start || end - start > INT_MAX - nr_pages)
49403 return ERR_PTR(-EINVAL);
49404
49405 nr_pages += end - start;
49406 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49407 /*
49408 * Overflow, abort
49409 */
49410 - if (end < start)
49411 + if (end < start || end - start > INT_MAX - nr_pages)
49412 return ERR_PTR(-EINVAL);
49413
49414 nr_pages += end - start;
49415 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49416 const int read = bio_data_dir(bio) == READ;
49417 struct bio_map_data *bmd = bio->bi_private;
49418 int i;
49419 - char *p = bmd->sgvecs[0].iov_base;
49420 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49421
49422 __bio_for_each_segment(bvec, bio, i, 0) {
49423 char *addr = page_address(bvec->bv_page);
49424 diff --git a/fs/block_dev.c b/fs/block_dev.c
49425 index aae187a..fd790ba 100644
49426 --- a/fs/block_dev.c
49427 +++ b/fs/block_dev.c
49428 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49429 else if (bdev->bd_contains == bdev)
49430 return true; /* is a whole device which isn't held */
49431
49432 - else if (whole->bd_holder == bd_may_claim)
49433 + else if (whole->bd_holder == (void *)bd_may_claim)
49434 return true; /* is a partition of a device that is being partitioned */
49435 else if (whole->bd_holder != NULL)
49436 return false; /* is a partition of a held device */
49437 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49438 index ca9d8f1..8c0142d 100644
49439 --- a/fs/btrfs/ctree.c
49440 +++ b/fs/btrfs/ctree.c
49441 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49442 free_extent_buffer(buf);
49443 add_root_to_dirty_list(root);
49444 } else {
49445 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49446 - parent_start = parent->start;
49447 - else
49448 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49449 + if (parent)
49450 + parent_start = parent->start;
49451 + else
49452 + parent_start = 0;
49453 + } else
49454 parent_start = 0;
49455
49456 WARN_ON(trans->transid != btrfs_header_generation(parent));
49457 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49458 index f49b62f..07834ab 100644
49459 --- a/fs/btrfs/ioctl.c
49460 +++ b/fs/btrfs/ioctl.c
49461 @@ -3077,9 +3077,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49462 for (i = 0; i < num_types; i++) {
49463 struct btrfs_space_info *tmp;
49464
49465 + /* Don't copy in more than we allocated */
49466 if (!slot_count)
49467 break;
49468
49469 + slot_count--;
49470 +
49471 info = NULL;
49472 rcu_read_lock();
49473 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49474 @@ -3101,10 +3104,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49475 memcpy(dest, &space, sizeof(space));
49476 dest++;
49477 space_args.total_spaces++;
49478 - slot_count--;
49479 }
49480 - if (!slot_count)
49481 - break;
49482 }
49483 up_read(&info->groups_sem);
49484 }
49485 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49486 index f6b8859..54fe8c5 100644
49487 --- a/fs/btrfs/super.c
49488 +++ b/fs/btrfs/super.c
49489 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49490 function, line, errstr);
49491 return;
49492 }
49493 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49494 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49495 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49496 }
49497 /*
49498 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49499 index 622f469..e8d2d55 100644
49500 --- a/fs/cachefiles/bind.c
49501 +++ b/fs/cachefiles/bind.c
49502 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49503 args);
49504
49505 /* start by checking things over */
49506 - ASSERT(cache->fstop_percent >= 0 &&
49507 - cache->fstop_percent < cache->fcull_percent &&
49508 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49509 cache->fcull_percent < cache->frun_percent &&
49510 cache->frun_percent < 100);
49511
49512 - ASSERT(cache->bstop_percent >= 0 &&
49513 - cache->bstop_percent < cache->bcull_percent &&
49514 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49515 cache->bcull_percent < cache->brun_percent &&
49516 cache->brun_percent < 100);
49517
49518 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49519 index 0a1467b..6a53245 100644
49520 --- a/fs/cachefiles/daemon.c
49521 +++ b/fs/cachefiles/daemon.c
49522 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49523 if (n > buflen)
49524 return -EMSGSIZE;
49525
49526 - if (copy_to_user(_buffer, buffer, n) != 0)
49527 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49528 return -EFAULT;
49529
49530 return n;
49531 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49532 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49533 return -EIO;
49534
49535 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49536 + if (datalen > PAGE_SIZE - 1)
49537 return -EOPNOTSUPP;
49538
49539 /* drag the command string into the kernel so we can parse it */
49540 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49541 if (args[0] != '%' || args[1] != '\0')
49542 return -EINVAL;
49543
49544 - if (fstop < 0 || fstop >= cache->fcull_percent)
49545 + if (fstop >= cache->fcull_percent)
49546 return cachefiles_daemon_range_error(cache, args);
49547
49548 cache->fstop_percent = fstop;
49549 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49550 if (args[0] != '%' || args[1] != '\0')
49551 return -EINVAL;
49552
49553 - if (bstop < 0 || bstop >= cache->bcull_percent)
49554 + if (bstop >= cache->bcull_percent)
49555 return cachefiles_daemon_range_error(cache, args);
49556
49557 cache->bstop_percent = bstop;
49558 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49559 index 4938251..7e01445 100644
49560 --- a/fs/cachefiles/internal.h
49561 +++ b/fs/cachefiles/internal.h
49562 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49563 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49564 struct rb_root active_nodes; /* active nodes (can't be culled) */
49565 rwlock_t active_lock; /* lock for active_nodes */
49566 - atomic_t gravecounter; /* graveyard uniquifier */
49567 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49568 unsigned frun_percent; /* when to stop culling (% files) */
49569 unsigned fcull_percent; /* when to start culling (% files) */
49570 unsigned fstop_percent; /* when to stop allocating (% files) */
49571 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49572 * proc.c
49573 */
49574 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49575 -extern atomic_t cachefiles_lookup_histogram[HZ];
49576 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49577 -extern atomic_t cachefiles_create_histogram[HZ];
49578 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49579 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49580 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49581
49582 extern int __init cachefiles_proc_init(void);
49583 extern void cachefiles_proc_cleanup(void);
49584 static inline
49585 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49586 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49587 {
49588 unsigned long jif = jiffies - start_jif;
49589 if (jif >= HZ)
49590 jif = HZ - 1;
49591 - atomic_inc(&histogram[jif]);
49592 + atomic_inc_unchecked(&histogram[jif]);
49593 }
49594
49595 #else
49596 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49597 index 8c01c5fc..15f982e 100644
49598 --- a/fs/cachefiles/namei.c
49599 +++ b/fs/cachefiles/namei.c
49600 @@ -317,7 +317,7 @@ try_again:
49601 /* first step is to make up a grave dentry in the graveyard */
49602 sprintf(nbuffer, "%08x%08x",
49603 (uint32_t) get_seconds(),
49604 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49605 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49606
49607 /* do the multiway lock magic */
49608 trap = lock_rename(cache->graveyard, dir);
49609 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49610 index eccd339..4c1d995 100644
49611 --- a/fs/cachefiles/proc.c
49612 +++ b/fs/cachefiles/proc.c
49613 @@ -14,9 +14,9 @@
49614 #include <linux/seq_file.h>
49615 #include "internal.h"
49616
49617 -atomic_t cachefiles_lookup_histogram[HZ];
49618 -atomic_t cachefiles_mkdir_histogram[HZ];
49619 -atomic_t cachefiles_create_histogram[HZ];
49620 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49621 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49622 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49623
49624 /*
49625 * display the latency histogram
49626 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49627 return 0;
49628 default:
49629 index = (unsigned long) v - 3;
49630 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49631 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49632 - z = atomic_read(&cachefiles_create_histogram[index]);
49633 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49634 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49635 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49636 if (x == 0 && y == 0 && z == 0)
49637 return 0;
49638
49639 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49640 index 4809922..aab2c39 100644
49641 --- a/fs/cachefiles/rdwr.c
49642 +++ b/fs/cachefiles/rdwr.c
49643 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49644 old_fs = get_fs();
49645 set_fs(KERNEL_DS);
49646 ret = file->f_op->write(
49647 - file, (const void __user *) data, len, &pos);
49648 + file, (const void __force_user *) data, len, &pos);
49649 set_fs(old_fs);
49650 kunmap(page);
49651 if (ret != len)
49652 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49653 index 6d797f4..0ace2e5 100644
49654 --- a/fs/ceph/dir.c
49655 +++ b/fs/ceph/dir.c
49656 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49657 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49658 struct ceph_mds_client *mdsc = fsc->mdsc;
49659 unsigned frag = fpos_frag(filp->f_pos);
49660 - int off = fpos_off(filp->f_pos);
49661 + unsigned int off = fpos_off(filp->f_pos);
49662 int err;
49663 u32 ftype;
49664 struct ceph_mds_reply_info_parsed *rinfo;
49665 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49666 index d9ea6ed..1e6c8ac 100644
49667 --- a/fs/cifs/cifs_debug.c
49668 +++ b/fs/cifs/cifs_debug.c
49669 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49670
49671 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49672 #ifdef CONFIG_CIFS_STATS2
49673 - atomic_set(&totBufAllocCount, 0);
49674 - atomic_set(&totSmBufAllocCount, 0);
49675 + atomic_set_unchecked(&totBufAllocCount, 0);
49676 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49677 #endif /* CONFIG_CIFS_STATS2 */
49678 spin_lock(&cifs_tcp_ses_lock);
49679 list_for_each(tmp1, &cifs_tcp_ses_list) {
49680 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49681 tcon = list_entry(tmp3,
49682 struct cifs_tcon,
49683 tcon_list);
49684 - atomic_set(&tcon->num_smbs_sent, 0);
49685 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49686 if (server->ops->clear_stats)
49687 server->ops->clear_stats(tcon);
49688 }
49689 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49690 smBufAllocCount.counter, cifs_min_small);
49691 #ifdef CONFIG_CIFS_STATS2
49692 seq_printf(m, "Total Large %d Small %d Allocations\n",
49693 - atomic_read(&totBufAllocCount),
49694 - atomic_read(&totSmBufAllocCount));
49695 + atomic_read_unchecked(&totBufAllocCount),
49696 + atomic_read_unchecked(&totSmBufAllocCount));
49697 #endif /* CONFIG_CIFS_STATS2 */
49698
49699 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49700 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49701 if (tcon->need_reconnect)
49702 seq_puts(m, "\tDISCONNECTED ");
49703 seq_printf(m, "\nSMBs: %d",
49704 - atomic_read(&tcon->num_smbs_sent));
49705 + atomic_read_unchecked(&tcon->num_smbs_sent));
49706 if (server->ops->print_stats)
49707 server->ops->print_stats(m, tcon);
49708 }
49709 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49710 index 345fc89..b2acae5 100644
49711 --- a/fs/cifs/cifsfs.c
49712 +++ b/fs/cifs/cifsfs.c
49713 @@ -1033,7 +1033,7 @@ cifs_init_request_bufs(void)
49714 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49715 cifs_req_cachep = kmem_cache_create("cifs_request",
49716 CIFSMaxBufSize + max_hdr_size, 0,
49717 - SLAB_HWCACHE_ALIGN, NULL);
49718 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49719 if (cifs_req_cachep == NULL)
49720 return -ENOMEM;
49721
49722 @@ -1060,7 +1060,7 @@ cifs_init_request_bufs(void)
49723 efficient to alloc 1 per page off the slab compared to 17K (5page)
49724 alloc of large cifs buffers even when page debugging is on */
49725 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49726 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49727 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49728 NULL);
49729 if (cifs_sm_req_cachep == NULL) {
49730 mempool_destroy(cifs_req_poolp);
49731 @@ -1145,8 +1145,8 @@ init_cifs(void)
49732 atomic_set(&bufAllocCount, 0);
49733 atomic_set(&smBufAllocCount, 0);
49734 #ifdef CONFIG_CIFS_STATS2
49735 - atomic_set(&totBufAllocCount, 0);
49736 - atomic_set(&totSmBufAllocCount, 0);
49737 + atomic_set_unchecked(&totBufAllocCount, 0);
49738 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49739 #endif /* CONFIG_CIFS_STATS2 */
49740
49741 atomic_set(&midCount, 0);
49742 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49743 index 4f07f6f..55de8ce 100644
49744 --- a/fs/cifs/cifsglob.h
49745 +++ b/fs/cifs/cifsglob.h
49746 @@ -751,35 +751,35 @@ struct cifs_tcon {
49747 __u16 Flags; /* optional support bits */
49748 enum statusEnum tidStatus;
49749 #ifdef CONFIG_CIFS_STATS
49750 - atomic_t num_smbs_sent;
49751 + atomic_unchecked_t num_smbs_sent;
49752 union {
49753 struct {
49754 - atomic_t num_writes;
49755 - atomic_t num_reads;
49756 - atomic_t num_flushes;
49757 - atomic_t num_oplock_brks;
49758 - atomic_t num_opens;
49759 - atomic_t num_closes;
49760 - atomic_t num_deletes;
49761 - atomic_t num_mkdirs;
49762 - atomic_t num_posixopens;
49763 - atomic_t num_posixmkdirs;
49764 - atomic_t num_rmdirs;
49765 - atomic_t num_renames;
49766 - atomic_t num_t2renames;
49767 - atomic_t num_ffirst;
49768 - atomic_t num_fnext;
49769 - atomic_t num_fclose;
49770 - atomic_t num_hardlinks;
49771 - atomic_t num_symlinks;
49772 - atomic_t num_locks;
49773 - atomic_t num_acl_get;
49774 - atomic_t num_acl_set;
49775 + atomic_unchecked_t num_writes;
49776 + atomic_unchecked_t num_reads;
49777 + atomic_unchecked_t num_flushes;
49778 + atomic_unchecked_t num_oplock_brks;
49779 + atomic_unchecked_t num_opens;
49780 + atomic_unchecked_t num_closes;
49781 + atomic_unchecked_t num_deletes;
49782 + atomic_unchecked_t num_mkdirs;
49783 + atomic_unchecked_t num_posixopens;
49784 + atomic_unchecked_t num_posixmkdirs;
49785 + atomic_unchecked_t num_rmdirs;
49786 + atomic_unchecked_t num_renames;
49787 + atomic_unchecked_t num_t2renames;
49788 + atomic_unchecked_t num_ffirst;
49789 + atomic_unchecked_t num_fnext;
49790 + atomic_unchecked_t num_fclose;
49791 + atomic_unchecked_t num_hardlinks;
49792 + atomic_unchecked_t num_symlinks;
49793 + atomic_unchecked_t num_locks;
49794 + atomic_unchecked_t num_acl_get;
49795 + atomic_unchecked_t num_acl_set;
49796 } cifs_stats;
49797 #ifdef CONFIG_CIFS_SMB2
49798 struct {
49799 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49800 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49801 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49802 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49803 } smb2_stats;
49804 #endif /* CONFIG_CIFS_SMB2 */
49805 } stats;
49806 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49807 }
49808
49809 #ifdef CONFIG_CIFS_STATS
49810 -#define cifs_stats_inc atomic_inc
49811 +#define cifs_stats_inc atomic_inc_unchecked
49812
49813 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49814 unsigned int bytes)
49815 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49816 /* Various Debug counters */
49817 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49818 #ifdef CONFIG_CIFS_STATS2
49819 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49820 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49821 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49822 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49823 #endif
49824 GLOBAL_EXTERN atomic_t smBufAllocCount;
49825 GLOBAL_EXTERN atomic_t midCount;
49826 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49827 index 9f6c4c4..8de307a 100644
49828 --- a/fs/cifs/link.c
49829 +++ b/fs/cifs/link.c
49830 @@ -616,7 +616,7 @@ symlink_exit:
49831
49832 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49833 {
49834 - char *p = nd_get_link(nd);
49835 + const char *p = nd_get_link(nd);
49836 if (!IS_ERR(p))
49837 kfree(p);
49838 }
49839 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49840 index 1b15bf8..1ce489e 100644
49841 --- a/fs/cifs/misc.c
49842 +++ b/fs/cifs/misc.c
49843 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49844 memset(ret_buf, 0, buf_size + 3);
49845 atomic_inc(&bufAllocCount);
49846 #ifdef CONFIG_CIFS_STATS2
49847 - atomic_inc(&totBufAllocCount);
49848 + atomic_inc_unchecked(&totBufAllocCount);
49849 #endif /* CONFIG_CIFS_STATS2 */
49850 }
49851
49852 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49853 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49854 atomic_inc(&smBufAllocCount);
49855 #ifdef CONFIG_CIFS_STATS2
49856 - atomic_inc(&totSmBufAllocCount);
49857 + atomic_inc_unchecked(&totSmBufAllocCount);
49858 #endif /* CONFIG_CIFS_STATS2 */
49859
49860 }
49861 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49862 index 47bc5a8..10decbe 100644
49863 --- a/fs/cifs/smb1ops.c
49864 +++ b/fs/cifs/smb1ops.c
49865 @@ -586,27 +586,27 @@ static void
49866 cifs_clear_stats(struct cifs_tcon *tcon)
49867 {
49868 #ifdef CONFIG_CIFS_STATS
49869 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49870 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49871 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49872 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49873 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49874 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49875 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49876 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49877 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49878 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49879 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49880 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49881 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49882 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49883 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49884 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49885 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49886 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49887 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49888 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49889 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49890 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49891 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49892 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49893 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49894 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49895 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49896 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49897 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49898 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49899 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49900 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49901 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49902 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49903 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49904 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49905 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49906 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49907 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49908 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49909 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49910 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49911 #endif
49912 }
49913
49914 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49915 {
49916 #ifdef CONFIG_CIFS_STATS
49917 seq_printf(m, " Oplocks breaks: %d",
49918 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49919 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49920 seq_printf(m, "\nReads: %d Bytes: %llu",
49921 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49922 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49923 (long long)(tcon->bytes_read));
49924 seq_printf(m, "\nWrites: %d Bytes: %llu",
49925 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49926 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49927 (long long)(tcon->bytes_written));
49928 seq_printf(m, "\nFlushes: %d",
49929 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49930 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49931 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49932 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49933 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49934 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49935 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49936 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49937 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49938 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49939 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49940 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49941 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49942 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49943 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49944 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49945 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49946 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49947 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49948 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49949 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49950 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49951 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49952 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49953 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49954 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49955 seq_printf(m, "\nRenames: %d T2 Renames %d",
49956 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49957 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49958 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49959 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49960 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49961 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49962 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49963 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49964 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49965 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49966 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49967 #endif
49968 }
49969
49970 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49971 index bceffe7..cd1ae59 100644
49972 --- a/fs/cifs/smb2ops.c
49973 +++ b/fs/cifs/smb2ops.c
49974 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49975 #ifdef CONFIG_CIFS_STATS
49976 int i;
49977 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49978 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49979 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49980 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49981 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49982 }
49983 #endif
49984 }
49985 @@ -284,66 +284,66 @@ static void
49986 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49987 {
49988 #ifdef CONFIG_CIFS_STATS
49989 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49990 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49991 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49992 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49993 seq_printf(m, "\nNegotiates: %d sent %d failed",
49994 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49995 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49996 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49997 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49998 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49999 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50000 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50001 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50002 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50003 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50004 seq_printf(m, "\nLogoffs: %d sent %d failed",
50005 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50006 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50007 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50008 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50009 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50010 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50011 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50012 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50013 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50014 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50015 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50016 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50017 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50018 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50019 seq_printf(m, "\nCreates: %d sent %d failed",
50020 - atomic_read(&sent[SMB2_CREATE_HE]),
50021 - atomic_read(&failed[SMB2_CREATE_HE]));
50022 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50023 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50024 seq_printf(m, "\nCloses: %d sent %d failed",
50025 - atomic_read(&sent[SMB2_CLOSE_HE]),
50026 - atomic_read(&failed[SMB2_CLOSE_HE]));
50027 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50028 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50029 seq_printf(m, "\nFlushes: %d sent %d failed",
50030 - atomic_read(&sent[SMB2_FLUSH_HE]),
50031 - atomic_read(&failed[SMB2_FLUSH_HE]));
50032 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50033 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50034 seq_printf(m, "\nReads: %d sent %d failed",
50035 - atomic_read(&sent[SMB2_READ_HE]),
50036 - atomic_read(&failed[SMB2_READ_HE]));
50037 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50038 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50039 seq_printf(m, "\nWrites: %d sent %d failed",
50040 - atomic_read(&sent[SMB2_WRITE_HE]),
50041 - atomic_read(&failed[SMB2_WRITE_HE]));
50042 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50043 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50044 seq_printf(m, "\nLocks: %d sent %d failed",
50045 - atomic_read(&sent[SMB2_LOCK_HE]),
50046 - atomic_read(&failed[SMB2_LOCK_HE]));
50047 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50048 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50049 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50050 - atomic_read(&sent[SMB2_IOCTL_HE]),
50051 - atomic_read(&failed[SMB2_IOCTL_HE]));
50052 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50053 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50054 seq_printf(m, "\nCancels: %d sent %d failed",
50055 - atomic_read(&sent[SMB2_CANCEL_HE]),
50056 - atomic_read(&failed[SMB2_CANCEL_HE]));
50057 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50058 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50059 seq_printf(m, "\nEchos: %d sent %d failed",
50060 - atomic_read(&sent[SMB2_ECHO_HE]),
50061 - atomic_read(&failed[SMB2_ECHO_HE]));
50062 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50063 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50064 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50065 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50066 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50067 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50068 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50069 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50070 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50071 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50072 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50073 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50074 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50075 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50076 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50077 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50078 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50079 seq_printf(m, "\nSetInfos: %d sent %d failed",
50080 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50081 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50082 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50083 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50084 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50085 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50086 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50087 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50088 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50089 #endif
50090 }
50091
50092 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50093 index 41d9d07..dbb4772 100644
50094 --- a/fs/cifs/smb2pdu.c
50095 +++ b/fs/cifs/smb2pdu.c
50096 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50097 default:
50098 cERROR(1, "info level %u isn't supported",
50099 srch_inf->info_level);
50100 - rc = -EINVAL;
50101 - goto qdir_exit;
50102 + return -EINVAL;
50103 }
50104
50105 req->FileIndex = cpu_to_le32(index);
50106 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50107 index 1da168c..8bc7ff6 100644
50108 --- a/fs/coda/cache.c
50109 +++ b/fs/coda/cache.c
50110 @@ -24,7 +24,7 @@
50111 #include "coda_linux.h"
50112 #include "coda_cache.h"
50113
50114 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50115 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50116
50117 /* replace or extend an acl cache hit */
50118 void coda_cache_enter(struct inode *inode, int mask)
50119 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50120 struct coda_inode_info *cii = ITOC(inode);
50121
50122 spin_lock(&cii->c_lock);
50123 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50124 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50125 if (!uid_eq(cii->c_uid, current_fsuid())) {
50126 cii->c_uid = current_fsuid();
50127 cii->c_cached_perm = mask;
50128 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50129 {
50130 struct coda_inode_info *cii = ITOC(inode);
50131 spin_lock(&cii->c_lock);
50132 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50133 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50134 spin_unlock(&cii->c_lock);
50135 }
50136
50137 /* remove all acl caches */
50138 void coda_cache_clear_all(struct super_block *sb)
50139 {
50140 - atomic_inc(&permission_epoch);
50141 + atomic_inc_unchecked(&permission_epoch);
50142 }
50143
50144
50145 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50146 spin_lock(&cii->c_lock);
50147 hit = (mask & cii->c_cached_perm) == mask &&
50148 uid_eq(cii->c_uid, current_fsuid()) &&
50149 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50150 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50151 spin_unlock(&cii->c_lock);
50152
50153 return hit;
50154 diff --git a/fs/compat.c b/fs/compat.c
50155 index d487985..c9e04b1 100644
50156 --- a/fs/compat.c
50157 +++ b/fs/compat.c
50158 @@ -54,7 +54,7 @@
50159 #include <asm/ioctls.h>
50160 #include "internal.h"
50161
50162 -int compat_log = 1;
50163 +int compat_log = 0;
50164
50165 int compat_printk(const char *fmt, ...)
50166 {
50167 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50168
50169 set_fs(KERNEL_DS);
50170 /* The __user pointer cast is valid because of the set_fs() */
50171 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50172 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50173 set_fs(oldfs);
50174 /* truncating is ok because it's a user address */
50175 if (!ret)
50176 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50177 goto out;
50178
50179 ret = -EINVAL;
50180 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50181 + if (nr_segs > UIO_MAXIOV)
50182 goto out;
50183 if (nr_segs > fast_segs) {
50184 ret = -ENOMEM;
50185 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50186
50187 struct compat_readdir_callback {
50188 struct compat_old_linux_dirent __user *dirent;
50189 + struct file * file;
50190 int result;
50191 };
50192
50193 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50194 buf->result = -EOVERFLOW;
50195 return -EOVERFLOW;
50196 }
50197 +
50198 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50199 + return 0;
50200 +
50201 buf->result++;
50202 dirent = buf->dirent;
50203 if (!access_ok(VERIFY_WRITE, dirent,
50204 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50205
50206 buf.result = 0;
50207 buf.dirent = dirent;
50208 + buf.file = f.file;
50209
50210 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50211 if (buf.result)
50212 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50213 struct compat_getdents_callback {
50214 struct compat_linux_dirent __user *current_dir;
50215 struct compat_linux_dirent __user *previous;
50216 + struct file * file;
50217 int count;
50218 int error;
50219 };
50220 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50221 buf->error = -EOVERFLOW;
50222 return -EOVERFLOW;
50223 }
50224 +
50225 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50226 + return 0;
50227 +
50228 dirent = buf->previous;
50229 if (dirent) {
50230 if (__put_user(offset, &dirent->d_off))
50231 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50232 buf.previous = NULL;
50233 buf.count = count;
50234 buf.error = 0;
50235 + buf.file = f.file;
50236
50237 error = vfs_readdir(f.file, compat_filldir, &buf);
50238 if (error >= 0)
50239 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50240 struct compat_getdents_callback64 {
50241 struct linux_dirent64 __user *current_dir;
50242 struct linux_dirent64 __user *previous;
50243 + struct file * file;
50244 int count;
50245 int error;
50246 };
50247 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50248 buf->error = -EINVAL; /* only used if we fail.. */
50249 if (reclen > buf->count)
50250 return -EINVAL;
50251 +
50252 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50253 + return 0;
50254 +
50255 dirent = buf->previous;
50256
50257 if (dirent) {
50258 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50259 buf.previous = NULL;
50260 buf.count = count;
50261 buf.error = 0;
50262 + buf.file = f.file;
50263
50264 error = vfs_readdir(f.file, compat_filldir64, &buf);
50265 if (error >= 0)
50266 error = buf.error;
50267 lastdirent = buf.previous;
50268 if (lastdirent) {
50269 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50270 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50271 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50272 error = -EFAULT;
50273 else
50274 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50275 index a81147e..20bf2b5 100644
50276 --- a/fs/compat_binfmt_elf.c
50277 +++ b/fs/compat_binfmt_elf.c
50278 @@ -30,11 +30,13 @@
50279 #undef elf_phdr
50280 #undef elf_shdr
50281 #undef elf_note
50282 +#undef elf_dyn
50283 #undef elf_addr_t
50284 #define elfhdr elf32_hdr
50285 #define elf_phdr elf32_phdr
50286 #define elf_shdr elf32_shdr
50287 #define elf_note elf32_note
50288 +#define elf_dyn Elf32_Dyn
50289 #define elf_addr_t Elf32_Addr
50290
50291 /*
50292 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50293 index 3ced75f..b28d192 100644
50294 --- a/fs/compat_ioctl.c
50295 +++ b/fs/compat_ioctl.c
50296 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50297 return -EFAULT;
50298 if (__get_user(udata, &ss32->iomem_base))
50299 return -EFAULT;
50300 - ss.iomem_base = compat_ptr(udata);
50301 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50302 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50303 __get_user(ss.port_high, &ss32->port_high))
50304 return -EFAULT;
50305 @@ -704,8 +704,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
50306 for (i = 0; i < nmsgs; i++) {
50307 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
50308 return -EFAULT;
50309 - if (get_user(datap, &umsgs[i].buf) ||
50310 - put_user(compat_ptr(datap), &tmsgs[i].buf))
50311 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
50312 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
50313 return -EFAULT;
50314 }
50315 return sys_ioctl(fd, cmd, (unsigned long)tdata);
50316 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50317 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50318 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50319 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50320 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50321 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50322 return -EFAULT;
50323
50324 return ioctl_preallocate(file, p);
50325 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50326 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50327 {
50328 unsigned int a, b;
50329 - a = *(unsigned int *)p;
50330 - b = *(unsigned int *)q;
50331 + a = *(const unsigned int *)p;
50332 + b = *(const unsigned int *)q;
50333 if (a > b)
50334 return 1;
50335 if (a < b)
50336 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50337 index 7aabc6a..34c1197 100644
50338 --- a/fs/configfs/dir.c
50339 +++ b/fs/configfs/dir.c
50340 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50341 }
50342 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50343 struct configfs_dirent *next;
50344 - const char * name;
50345 + const unsigned char * name;
50346 + char d_name[sizeof(next->s_dentry->d_iname)];
50347 int len;
50348 struct inode *inode = NULL;
50349
50350 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50351 continue;
50352
50353 name = configfs_get_name(next);
50354 - len = strlen(name);
50355 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50356 + len = next->s_dentry->d_name.len;
50357 + memcpy(d_name, name, len);
50358 + name = d_name;
50359 + } else
50360 + len = strlen(name);
50361
50362 /*
50363 * We'll have a dentry and an inode for
50364 diff --git a/fs/coredump.c b/fs/coredump.c
50365 index c647965..a77bff3 100644
50366 --- a/fs/coredump.c
50367 +++ b/fs/coredump.c
50368 @@ -52,7 +52,7 @@ struct core_name {
50369 char *corename;
50370 int used, size;
50371 };
50372 -static atomic_t call_count = ATOMIC_INIT(1);
50373 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50374
50375 /* The maximal length of core_pattern is also specified in sysctl.c */
50376
50377 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50378 {
50379 char *old_corename = cn->corename;
50380
50381 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50382 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50383 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50384
50385 if (!cn->corename) {
50386 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50387 int pid_in_pattern = 0;
50388 int err = 0;
50389
50390 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50391 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50392 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50393 cn->used = 0;
50394
50395 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50396 pipe = file_inode(file)->i_pipe;
50397
50398 pipe_lock(pipe);
50399 - pipe->readers++;
50400 - pipe->writers--;
50401 + atomic_inc(&pipe->readers);
50402 + atomic_dec(&pipe->writers);
50403
50404 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50405 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50406 wake_up_interruptible_sync(&pipe->wait);
50407 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50408 pipe_wait(pipe);
50409 }
50410
50411 - pipe->readers--;
50412 - pipe->writers++;
50413 + atomic_dec(&pipe->readers);
50414 + atomic_inc(&pipe->writers);
50415 pipe_unlock(pipe);
50416
50417 }
50418 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50419 int ispipe;
50420 struct files_struct *displaced;
50421 bool need_nonrelative = false;
50422 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50423 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50424 + long signr = siginfo->si_signo;
50425 struct coredump_params cprm = {
50426 .siginfo = siginfo,
50427 .regs = signal_pt_regs(),
50428 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50429 .mm_flags = mm->flags,
50430 };
50431
50432 - audit_core_dumps(siginfo->si_signo);
50433 + audit_core_dumps(signr);
50434 +
50435 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50436 + gr_handle_brute_attach(cprm.mm_flags);
50437
50438 binfmt = mm->binfmt;
50439 if (!binfmt || !binfmt->core_dump)
50440 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50441 need_nonrelative = true;
50442 }
50443
50444 - retval = coredump_wait(siginfo->si_signo, &core_state);
50445 + retval = coredump_wait(signr, &core_state);
50446 if (retval < 0)
50447 goto fail_creds;
50448
50449 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50450 }
50451 cprm.limit = RLIM_INFINITY;
50452
50453 - dump_count = atomic_inc_return(&core_dump_count);
50454 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50455 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50456 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50457 task_tgid_vnr(current), current->comm);
50458 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50459 } else {
50460 struct inode *inode;
50461
50462 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50463 +
50464 if (cprm.limit < binfmt->min_coredump)
50465 goto fail_unlock;
50466
50467 @@ -640,7 +646,7 @@ close_fail:
50468 filp_close(cprm.file, NULL);
50469 fail_dropcount:
50470 if (ispipe)
50471 - atomic_dec(&core_dump_count);
50472 + atomic_dec_unchecked(&core_dump_count);
50473 fail_unlock:
50474 kfree(cn.corename);
50475 fail_corename:
50476 @@ -659,7 +665,7 @@ fail:
50477 */
50478 int dump_write(struct file *file, const void *addr, int nr)
50479 {
50480 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50481 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50482 }
50483 EXPORT_SYMBOL(dump_write);
50484
50485 diff --git a/fs/dcache.c b/fs/dcache.c
50486 index e689268..f36956e 100644
50487 --- a/fs/dcache.c
50488 +++ b/fs/dcache.c
50489 @@ -3100,7 +3100,7 @@ void __init vfs_caches_init(unsigned long mempages)
50490 mempages -= reserve;
50491
50492 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50493 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50494 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50495
50496 dcache_init();
50497 inode_init();
50498 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50499 index 4888cb3..e0f7cf8 100644
50500 --- a/fs/debugfs/inode.c
50501 +++ b/fs/debugfs/inode.c
50502 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50503 */
50504 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50505 {
50506 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50507 + return __create_file(name, S_IFDIR | S_IRWXU,
50508 +#else
50509 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50510 +#endif
50511 parent, NULL, NULL);
50512 }
50513 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50514 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50515 index 5eab400..810a3f5 100644
50516 --- a/fs/ecryptfs/inode.c
50517 +++ b/fs/ecryptfs/inode.c
50518 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50519 old_fs = get_fs();
50520 set_fs(get_ds());
50521 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50522 - (char __user *)lower_buf,
50523 + (char __force_user *)lower_buf,
50524 PATH_MAX);
50525 set_fs(old_fs);
50526 if (rc < 0)
50527 @@ -706,7 +706,7 @@ out:
50528 static void
50529 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50530 {
50531 - char *buf = nd_get_link(nd);
50532 + const char *buf = nd_get_link(nd);
50533 if (!IS_ERR(buf)) {
50534 /* Free the char* */
50535 kfree(buf);
50536 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50537 index e4141f2..d8263e8 100644
50538 --- a/fs/ecryptfs/miscdev.c
50539 +++ b/fs/ecryptfs/miscdev.c
50540 @@ -304,7 +304,7 @@ check_list:
50541 goto out_unlock_msg_ctx;
50542 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50543 if (msg_ctx->msg) {
50544 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50545 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50546 goto out_unlock_msg_ctx;
50547 i += packet_length_size;
50548 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50549 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50550 index 6a16053..2155147 100644
50551 --- a/fs/ecryptfs/read_write.c
50552 +++ b/fs/ecryptfs/read_write.c
50553 @@ -240,7 +240,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50554 return -EIO;
50555 fs_save = get_fs();
50556 set_fs(get_ds());
50557 - rc = vfs_read(lower_file, data, size, &offset);
50558 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50559 set_fs(fs_save);
50560 return rc;
50561 }
50562 diff --git a/fs/exec.c b/fs/exec.c
50563 index 6d56ff2..3bc6638 100644
50564 --- a/fs/exec.c
50565 +++ b/fs/exec.c
50566 @@ -55,8 +55,20 @@
50567 #include <linux/pipe_fs_i.h>
50568 #include <linux/oom.h>
50569 #include <linux/compat.h>
50570 +#include <linux/random.h>
50571 +#include <linux/seq_file.h>
50572 +#include <linux/coredump.h>
50573 +#include <linux/mman.h>
50574 +
50575 +#ifdef CONFIG_PAX_REFCOUNT
50576 +#include <linux/kallsyms.h>
50577 +#include <linux/kdebug.h>
50578 +#endif
50579 +
50580 +#include <trace/events/fs.h>
50581
50582 #include <asm/uaccess.h>
50583 +#include <asm/sections.h>
50584 #include <asm/mmu_context.h>
50585 #include <asm/tlb.h>
50586
50587 @@ -66,6 +78,18 @@
50588
50589 #include <trace/events/sched.h>
50590
50591 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50592 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50593 +{
50594 + 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");
50595 +}
50596 +#endif
50597 +
50598 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50599 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50600 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50601 +#endif
50602 +
50603 int suid_dumpable = 0;
50604
50605 static LIST_HEAD(formats);
50606 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50607 {
50608 BUG_ON(!fmt);
50609 write_lock(&binfmt_lock);
50610 - insert ? list_add(&fmt->lh, &formats) :
50611 - list_add_tail(&fmt->lh, &formats);
50612 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50613 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50614 write_unlock(&binfmt_lock);
50615 }
50616
50617 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
50618 void unregister_binfmt(struct linux_binfmt * fmt)
50619 {
50620 write_lock(&binfmt_lock);
50621 - list_del(&fmt->lh);
50622 + pax_list_del((struct list_head *)&fmt->lh);
50623 write_unlock(&binfmt_lock);
50624 }
50625
50626 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50627 int write)
50628 {
50629 struct page *page;
50630 - int ret;
50631
50632 -#ifdef CONFIG_STACK_GROWSUP
50633 - if (write) {
50634 - ret = expand_downwards(bprm->vma, pos);
50635 - if (ret < 0)
50636 - return NULL;
50637 - }
50638 -#endif
50639 - ret = get_user_pages(current, bprm->mm, pos,
50640 - 1, write, 1, &page, NULL);
50641 - if (ret <= 0)
50642 + if (0 > expand_downwards(bprm->vma, pos))
50643 + return NULL;
50644 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50645 return NULL;
50646
50647 if (write) {
50648 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50649 if (size <= ARG_MAX)
50650 return page;
50651
50652 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50653 + // only allow 512KB for argv+env on suid/sgid binaries
50654 + // to prevent easy ASLR exhaustion
50655 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50656 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50657 + (size > (512 * 1024))) {
50658 + put_page(page);
50659 + return NULL;
50660 + }
50661 +#endif
50662 +
50663 /*
50664 * Limit to 1/4-th the stack size for the argv+env strings.
50665 * This ensures that:
50666 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50667 vma->vm_end = STACK_TOP_MAX;
50668 vma->vm_start = vma->vm_end - PAGE_SIZE;
50669 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50670 +
50671 +#ifdef CONFIG_PAX_SEGMEXEC
50672 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50673 +#endif
50674 +
50675 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50676 INIT_LIST_HEAD(&vma->anon_vma_chain);
50677
50678 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50679 mm->stack_vm = mm->total_vm = 1;
50680 up_write(&mm->mmap_sem);
50681 bprm->p = vma->vm_end - sizeof(void *);
50682 +
50683 +#ifdef CONFIG_PAX_RANDUSTACK
50684 + if (randomize_va_space)
50685 + bprm->p ^= random32() & ~PAGE_MASK;
50686 +#endif
50687 +
50688 return 0;
50689 err:
50690 up_write(&mm->mmap_sem);
50691 @@ -396,7 +434,7 @@ struct user_arg_ptr {
50692 } ptr;
50693 };
50694
50695 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50696 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50697 {
50698 const char __user *native;
50699
50700 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50701 compat_uptr_t compat;
50702
50703 if (get_user(compat, argv.ptr.compat + nr))
50704 - return ERR_PTR(-EFAULT);
50705 + return (const char __force_user *)ERR_PTR(-EFAULT);
50706
50707 return compat_ptr(compat);
50708 }
50709 #endif
50710
50711 if (get_user(native, argv.ptr.native + nr))
50712 - return ERR_PTR(-EFAULT);
50713 + return (const char __force_user *)ERR_PTR(-EFAULT);
50714
50715 return native;
50716 }
50717 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
50718 if (!p)
50719 break;
50720
50721 - if (IS_ERR(p))
50722 + if (IS_ERR((const char __force_kernel *)p))
50723 return -EFAULT;
50724
50725 if (i >= max)
50726 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50727
50728 ret = -EFAULT;
50729 str = get_user_arg_ptr(argv, argc);
50730 - if (IS_ERR(str))
50731 + if (IS_ERR((const char __force_kernel *)str))
50732 goto out;
50733
50734 len = strnlen_user(str, MAX_ARG_STRLEN);
50735 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50736 int r;
50737 mm_segment_t oldfs = get_fs();
50738 struct user_arg_ptr argv = {
50739 - .ptr.native = (const char __user *const __user *)__argv,
50740 + .ptr.native = (const char __force_user * const __force_user *)__argv,
50741 };
50742
50743 set_fs(KERNEL_DS);
50744 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50745 unsigned long new_end = old_end - shift;
50746 struct mmu_gather tlb;
50747
50748 - BUG_ON(new_start > new_end);
50749 + if (new_start >= new_end || new_start < mmap_min_addr)
50750 + return -ENOMEM;
50751
50752 /*
50753 * ensure there are no vmas between where we want to go
50754 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50755 if (vma != find_vma(mm, new_start))
50756 return -EFAULT;
50757
50758 +#ifdef CONFIG_PAX_SEGMEXEC
50759 + BUG_ON(pax_find_mirror_vma(vma));
50760 +#endif
50761 +
50762 /*
50763 * cover the whole range: [new_start, old_end)
50764 */
50765 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50766 stack_top = arch_align_stack(stack_top);
50767 stack_top = PAGE_ALIGN(stack_top);
50768
50769 - if (unlikely(stack_top < mmap_min_addr) ||
50770 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50771 - return -ENOMEM;
50772 -
50773 stack_shift = vma->vm_end - stack_top;
50774
50775 bprm->p -= stack_shift;
50776 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50777 bprm->exec -= stack_shift;
50778
50779 down_write(&mm->mmap_sem);
50780 +
50781 + /* Move stack pages down in memory. */
50782 + if (stack_shift) {
50783 + ret = shift_arg_pages(vma, stack_shift);
50784 + if (ret)
50785 + goto out_unlock;
50786 + }
50787 +
50788 vm_flags = VM_STACK_FLAGS;
50789
50790 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50791 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50792 + vm_flags &= ~VM_EXEC;
50793 +
50794 +#ifdef CONFIG_PAX_MPROTECT
50795 + if (mm->pax_flags & MF_PAX_MPROTECT)
50796 + vm_flags &= ~VM_MAYEXEC;
50797 +#endif
50798 +
50799 + }
50800 +#endif
50801 +
50802 /*
50803 * Adjust stack execute permissions; explicitly enable for
50804 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50805 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50806 goto out_unlock;
50807 BUG_ON(prev != vma);
50808
50809 - /* Move stack pages down in memory. */
50810 - if (stack_shift) {
50811 - ret = shift_arg_pages(vma, stack_shift);
50812 - if (ret)
50813 - goto out_unlock;
50814 - }
50815 -
50816 /* mprotect_fixup is overkill to remove the temporary stack flags */
50817 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50818
50819 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50820 #endif
50821 current->mm->start_stack = bprm->p;
50822 ret = expand_stack(vma, stack_base);
50823 +
50824 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50825 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50826 + unsigned long size;
50827 + vm_flags_t vm_flags;
50828 +
50829 + size = STACK_TOP - vma->vm_end;
50830 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50831 +
50832 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
50833 +
50834 +#ifdef CONFIG_X86
50835 + if (!ret) {
50836 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50837 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
50838 + }
50839 +#endif
50840 +
50841 + }
50842 +#endif
50843 +
50844 if (ret)
50845 ret = -EFAULT;
50846
50847 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
50848
50849 fsnotify_open(file);
50850
50851 + trace_open_exec(name);
50852 +
50853 err = deny_write_access(file);
50854 if (err)
50855 goto exit;
50856 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
50857 old_fs = get_fs();
50858 set_fs(get_ds());
50859 /* The cast to a user pointer is valid due to the set_fs() */
50860 - result = vfs_read(file, (void __user *)addr, count, &pos);
50861 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50862 set_fs(old_fs);
50863 return result;
50864 }
50865 @@ -1250,7 +1325,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50866 }
50867 rcu_read_unlock();
50868
50869 - if (p->fs->users > n_fs) {
50870 + if (atomic_read(&p->fs->users) > n_fs) {
50871 bprm->unsafe |= LSM_UNSAFE_SHARE;
50872 } else {
50873 res = -EAGAIN;
50874 @@ -1450,6 +1525,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50875
50876 EXPORT_SYMBOL(search_binary_handler);
50877
50878 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50879 +static DEFINE_PER_CPU(u64, exec_counter);
50880 +static int __init init_exec_counters(void)
50881 +{
50882 + unsigned int cpu;
50883 +
50884 + for_each_possible_cpu(cpu) {
50885 + per_cpu(exec_counter, cpu) = (u64)cpu;
50886 + }
50887 +
50888 + return 0;
50889 +}
50890 +early_initcall(init_exec_counters);
50891 +static inline void increment_exec_counter(void)
50892 +{
50893 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50894 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50895 +}
50896 +#else
50897 +static inline void increment_exec_counter(void) {}
50898 +#endif
50899 +
50900 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50901 + struct user_arg_ptr argv);
50902 +
50903 /*
50904 * sys_execve() executes a new program.
50905 */
50906 @@ -1457,6 +1557,11 @@ static int do_execve_common(const char *filename,
50907 struct user_arg_ptr argv,
50908 struct user_arg_ptr envp)
50909 {
50910 +#ifdef CONFIG_GRKERNSEC
50911 + struct file *old_exec_file;
50912 + struct acl_subject_label *old_acl;
50913 + struct rlimit old_rlim[RLIM_NLIMITS];
50914 +#endif
50915 struct linux_binprm *bprm;
50916 struct file *file;
50917 struct files_struct *displaced;
50918 @@ -1464,6 +1569,8 @@ static int do_execve_common(const char *filename,
50919 int retval;
50920 const struct cred *cred = current_cred();
50921
50922 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
50923 +
50924 /*
50925 * We move the actual failure in case of RLIMIT_NPROC excess from
50926 * set*uid() to execve() because too many poorly written programs
50927 @@ -1504,12 +1611,27 @@ static int do_execve_common(const char *filename,
50928 if (IS_ERR(file))
50929 goto out_unmark;
50930
50931 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50932 + retval = -EPERM;
50933 + goto out_file;
50934 + }
50935 +
50936 sched_exec();
50937
50938 bprm->file = file;
50939 bprm->filename = filename;
50940 bprm->interp = filename;
50941
50942 + if (gr_process_user_ban()) {
50943 + retval = -EPERM;
50944 + goto out_file;
50945 + }
50946 +
50947 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
50948 + retval = -EACCES;
50949 + goto out_file;
50950 + }
50951 +
50952 retval = bprm_mm_init(bprm);
50953 if (retval)
50954 goto out_file;
50955 @@ -1526,24 +1648,65 @@ static int do_execve_common(const char *filename,
50956 if (retval < 0)
50957 goto out;
50958
50959 +#ifdef CONFIG_GRKERNSEC
50960 + old_acl = current->acl;
50961 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50962 + old_exec_file = current->exec_file;
50963 + get_file(file);
50964 + current->exec_file = file;
50965 +#endif
50966 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50967 + /* limit suid stack to 8MB
50968 + * we saved the old limits above and will restore them if this exec fails
50969 + */
50970 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50971 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50972 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50973 +#endif
50974 +
50975 + if (!gr_tpe_allow(file)) {
50976 + retval = -EACCES;
50977 + goto out_fail;
50978 + }
50979 +
50980 + if (gr_check_crash_exec(file)) {
50981 + retval = -EACCES;
50982 + goto out_fail;
50983 + }
50984 +
50985 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
50986 + bprm->unsafe);
50987 + if (retval < 0)
50988 + goto out_fail;
50989 +
50990 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50991 if (retval < 0)
50992 - goto out;
50993 + goto out_fail;
50994
50995 bprm->exec = bprm->p;
50996 retval = copy_strings(bprm->envc, envp, bprm);
50997 if (retval < 0)
50998 - goto out;
50999 + goto out_fail;
51000
51001 retval = copy_strings(bprm->argc, argv, bprm);
51002 if (retval < 0)
51003 - goto out;
51004 + goto out_fail;
51005 +
51006 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
51007 +
51008 + gr_handle_exec_args(bprm, argv);
51009
51010 retval = search_binary_handler(bprm);
51011 if (retval < 0)
51012 - goto out;
51013 + goto out_fail;
51014 +#ifdef CONFIG_GRKERNSEC
51015 + if (old_exec_file)
51016 + fput(old_exec_file);
51017 +#endif
51018
51019 /* execve succeeded */
51020 +
51021 + increment_exec_counter();
51022 current->fs->in_exec = 0;
51023 current->in_execve = 0;
51024 acct_update_integrals(current);
51025 @@ -1552,6 +1715,14 @@ static int do_execve_common(const char *filename,
51026 put_files_struct(displaced);
51027 return retval;
51028
51029 +out_fail:
51030 +#ifdef CONFIG_GRKERNSEC
51031 + current->acl = old_acl;
51032 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51033 + fput(current->exec_file);
51034 + current->exec_file = old_exec_file;
51035 +#endif
51036 +
51037 out:
51038 if (bprm->mm) {
51039 acct_arg_size(bprm, 0);
51040 @@ -1700,3 +1871,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51041 return error;
51042 }
51043 #endif
51044 +
51045 +int pax_check_flags(unsigned long *flags)
51046 +{
51047 + int retval = 0;
51048 +
51049 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51050 + if (*flags & MF_PAX_SEGMEXEC)
51051 + {
51052 + *flags &= ~MF_PAX_SEGMEXEC;
51053 + retval = -EINVAL;
51054 + }
51055 +#endif
51056 +
51057 + if ((*flags & MF_PAX_PAGEEXEC)
51058 +
51059 +#ifdef CONFIG_PAX_PAGEEXEC
51060 + && (*flags & MF_PAX_SEGMEXEC)
51061 +#endif
51062 +
51063 + )
51064 + {
51065 + *flags &= ~MF_PAX_PAGEEXEC;
51066 + retval = -EINVAL;
51067 + }
51068 +
51069 + if ((*flags & MF_PAX_MPROTECT)
51070 +
51071 +#ifdef CONFIG_PAX_MPROTECT
51072 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51073 +#endif
51074 +
51075 + )
51076 + {
51077 + *flags &= ~MF_PAX_MPROTECT;
51078 + retval = -EINVAL;
51079 + }
51080 +
51081 + if ((*flags & MF_PAX_EMUTRAMP)
51082 +
51083 +#ifdef CONFIG_PAX_EMUTRAMP
51084 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51085 +#endif
51086 +
51087 + )
51088 + {
51089 + *flags &= ~MF_PAX_EMUTRAMP;
51090 + retval = -EINVAL;
51091 + }
51092 +
51093 + return retval;
51094 +}
51095 +
51096 +EXPORT_SYMBOL(pax_check_flags);
51097 +
51098 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51099 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51100 +{
51101 + struct task_struct *tsk = current;
51102 + struct mm_struct *mm = current->mm;
51103 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51104 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51105 + char *path_exec = NULL;
51106 + char *path_fault = NULL;
51107 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51108 + siginfo_t info = { };
51109 +
51110 + if (buffer_exec && buffer_fault) {
51111 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51112 +
51113 + down_read(&mm->mmap_sem);
51114 + vma = mm->mmap;
51115 + while (vma && (!vma_exec || !vma_fault)) {
51116 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51117 + vma_exec = vma;
51118 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51119 + vma_fault = vma;
51120 + vma = vma->vm_next;
51121 + }
51122 + if (vma_exec) {
51123 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51124 + if (IS_ERR(path_exec))
51125 + path_exec = "<path too long>";
51126 + else {
51127 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51128 + if (path_exec) {
51129 + *path_exec = 0;
51130 + path_exec = buffer_exec;
51131 + } else
51132 + path_exec = "<path too long>";
51133 + }
51134 + }
51135 + if (vma_fault) {
51136 + start = vma_fault->vm_start;
51137 + end = vma_fault->vm_end;
51138 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51139 + if (vma_fault->vm_file) {
51140 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51141 + if (IS_ERR(path_fault))
51142 + path_fault = "<path too long>";
51143 + else {
51144 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51145 + if (path_fault) {
51146 + *path_fault = 0;
51147 + path_fault = buffer_fault;
51148 + } else
51149 + path_fault = "<path too long>";
51150 + }
51151 + } else
51152 + path_fault = "<anonymous mapping>";
51153 + }
51154 + up_read(&mm->mmap_sem);
51155 + }
51156 + if (tsk->signal->curr_ip)
51157 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51158 + else
51159 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51160 + 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),
51161 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51162 + free_page((unsigned long)buffer_exec);
51163 + free_page((unsigned long)buffer_fault);
51164 + pax_report_insns(regs, pc, sp);
51165 + info.si_signo = SIGKILL;
51166 + info.si_errno = 0;
51167 + info.si_code = SI_KERNEL;
51168 + info.si_pid = 0;
51169 + info.si_uid = 0;
51170 + do_coredump(&info);
51171 +}
51172 +#endif
51173 +
51174 +#ifdef CONFIG_PAX_REFCOUNT
51175 +void pax_report_refcount_overflow(struct pt_regs *regs)
51176 +{
51177 + if (current->signal->curr_ip)
51178 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51179 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51180 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51181 + else
51182 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51183 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51184 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51185 + show_regs(regs);
51186 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51187 +}
51188 +#endif
51189 +
51190 +#ifdef CONFIG_PAX_USERCOPY
51191 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51192 +static noinline int check_stack_object(const void *obj, unsigned long len)
51193 +{
51194 + const void * const stack = task_stack_page(current);
51195 + const void * const stackend = stack + THREAD_SIZE;
51196 +
51197 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51198 + const void *frame = NULL;
51199 + const void *oldframe;
51200 +#endif
51201 +
51202 + if (obj + len < obj)
51203 + return -1;
51204 +
51205 + if (obj + len <= stack || stackend <= obj)
51206 + return 0;
51207 +
51208 + if (obj < stack || stackend < obj + len)
51209 + return -1;
51210 +
51211 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51212 + oldframe = __builtin_frame_address(1);
51213 + if (oldframe)
51214 + frame = __builtin_frame_address(2);
51215 + /*
51216 + low ----------------------------------------------> high
51217 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51218 + ^----------------^
51219 + allow copies only within here
51220 + */
51221 + while (stack <= frame && frame < stackend) {
51222 + /* if obj + len extends past the last frame, this
51223 + check won't pass and the next frame will be 0,
51224 + causing us to bail out and correctly report
51225 + the copy as invalid
51226 + */
51227 + if (obj + len <= frame)
51228 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51229 + oldframe = frame;
51230 + frame = *(const void * const *)frame;
51231 + }
51232 + return -1;
51233 +#else
51234 + return 1;
51235 +#endif
51236 +}
51237 +
51238 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51239 +{
51240 + if (current->signal->curr_ip)
51241 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51242 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51243 + else
51244 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51245 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51246 + dump_stack();
51247 + gr_handle_kernel_exploit();
51248 + do_group_exit(SIGKILL);
51249 +}
51250 +#endif
51251 +
51252 +#ifdef CONFIG_PAX_USERCOPY
51253 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51254 +{
51255 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51256 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51257 +#ifdef CONFIG_MODULES
51258 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
51259 +#else
51260 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51261 +#endif
51262 +
51263 +#else
51264 + unsigned long textlow = (unsigned long)_stext;
51265 + unsigned long texthigh = (unsigned long)_etext;
51266 +#endif
51267 +
51268 + if (high <= textlow || low > texthigh)
51269 + return false;
51270 + else
51271 + return true;
51272 +}
51273 +#endif
51274 +
51275 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51276 +{
51277 +
51278 +#ifdef CONFIG_PAX_USERCOPY
51279 + const char *type;
51280 +
51281 + if (!n)
51282 + return;
51283 +
51284 + type = check_heap_object(ptr, n);
51285 + if (!type) {
51286 + int ret = check_stack_object(ptr, n);
51287 + if (ret == 1 || ret == 2)
51288 + return;
51289 + if (ret == 0) {
51290 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51291 + type = "<kernel text>";
51292 + else
51293 + return;
51294 + } else
51295 + type = "<process stack>";
51296 + }
51297 +
51298 + pax_report_usercopy(ptr, n, to_user, type);
51299 +#endif
51300 +
51301 +}
51302 +EXPORT_SYMBOL(__check_object_size);
51303 +
51304 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51305 +void pax_track_stack(void)
51306 +{
51307 + unsigned long sp = (unsigned long)&sp;
51308 + if (sp < current_thread_info()->lowest_stack &&
51309 + sp > (unsigned long)task_stack_page(current))
51310 + current_thread_info()->lowest_stack = sp;
51311 +}
51312 +EXPORT_SYMBOL(pax_track_stack);
51313 +#endif
51314 +
51315 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51316 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51317 +{
51318 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51319 + dump_stack();
51320 + do_group_exit(SIGKILL);
51321 +}
51322 +EXPORT_SYMBOL(report_size_overflow);
51323 +#endif
51324 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51325 index 9f9992b..8b59411 100644
51326 --- a/fs/ext2/balloc.c
51327 +++ b/fs/ext2/balloc.c
51328 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51329
51330 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51331 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51332 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51333 + if (free_blocks < root_blocks + 1 &&
51334 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51335 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51336 - !in_group_p (sbi->s_resgid))) {
51337 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51338 return 0;
51339 }
51340 return 1;
51341 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51342 index 22548f5..41521d8 100644
51343 --- a/fs/ext3/balloc.c
51344 +++ b/fs/ext3/balloc.c
51345 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51346
51347 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51348 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51349 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51350 + if (free_blocks < root_blocks + 1 &&
51351 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51352 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51353 - !in_group_p (sbi->s_resgid))) {
51354 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51355 return 0;
51356 }
51357 return 1;
51358 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51359 index 92e68b3..115d987 100644
51360 --- a/fs/ext4/balloc.c
51361 +++ b/fs/ext4/balloc.c
51362 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51363 /* Hm, nope. Are (enough) root reserved clusters available? */
51364 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51365 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51366 - capable(CAP_SYS_RESOURCE) ||
51367 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51368 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51369 + capable_nolog(CAP_SYS_RESOURCE)) {
51370
51371 if (free_clusters >= (nclusters + dirty_clusters))
51372 return 1;
51373 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51374 index 3b83cd6..0f34dcd 100644
51375 --- a/fs/ext4/ext4.h
51376 +++ b/fs/ext4/ext4.h
51377 @@ -1254,19 +1254,19 @@ struct ext4_sb_info {
51378 unsigned long s_mb_last_start;
51379
51380 /* stats for buddy allocator */
51381 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51382 - atomic_t s_bal_success; /* we found long enough chunks */
51383 - atomic_t s_bal_allocated; /* in blocks */
51384 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51385 - atomic_t s_bal_goals; /* goal hits */
51386 - atomic_t s_bal_breaks; /* too long searches */
51387 - atomic_t s_bal_2orders; /* 2^order hits */
51388 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51389 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51390 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51391 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51392 + atomic_unchecked_t s_bal_goals; /* goal hits */
51393 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51394 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51395 spinlock_t s_bal_lock;
51396 unsigned long s_mb_buddies_generated;
51397 unsigned long long s_mb_generation_time;
51398 - atomic_t s_mb_lost_chunks;
51399 - atomic_t s_mb_preallocated;
51400 - atomic_t s_mb_discarded;
51401 + atomic_unchecked_t s_mb_lost_chunks;
51402 + atomic_unchecked_t s_mb_preallocated;
51403 + atomic_unchecked_t s_mb_discarded;
51404 atomic_t s_lock_busy;
51405
51406 /* locality groups */
51407 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51408 index f3190ab..84ffb21 100644
51409 --- a/fs/ext4/mballoc.c
51410 +++ b/fs/ext4/mballoc.c
51411 @@ -1754,7 +1754,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51412 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51413
51414 if (EXT4_SB(sb)->s_mb_stats)
51415 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51416 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51417
51418 break;
51419 }
51420 @@ -2059,7 +2059,7 @@ repeat:
51421 ac->ac_status = AC_STATUS_CONTINUE;
51422 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51423 cr = 3;
51424 - atomic_inc(&sbi->s_mb_lost_chunks);
51425 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51426 goto repeat;
51427 }
51428 }
51429 @@ -2567,25 +2567,25 @@ int ext4_mb_release(struct super_block *sb)
51430 if (sbi->s_mb_stats) {
51431 ext4_msg(sb, KERN_INFO,
51432 "mballoc: %u blocks %u reqs (%u success)",
51433 - atomic_read(&sbi->s_bal_allocated),
51434 - atomic_read(&sbi->s_bal_reqs),
51435 - atomic_read(&sbi->s_bal_success));
51436 + atomic_read_unchecked(&sbi->s_bal_allocated),
51437 + atomic_read_unchecked(&sbi->s_bal_reqs),
51438 + atomic_read_unchecked(&sbi->s_bal_success));
51439 ext4_msg(sb, KERN_INFO,
51440 "mballoc: %u extents scanned, %u goal hits, "
51441 "%u 2^N hits, %u breaks, %u lost",
51442 - atomic_read(&sbi->s_bal_ex_scanned),
51443 - atomic_read(&sbi->s_bal_goals),
51444 - atomic_read(&sbi->s_bal_2orders),
51445 - atomic_read(&sbi->s_bal_breaks),
51446 - atomic_read(&sbi->s_mb_lost_chunks));
51447 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51448 + atomic_read_unchecked(&sbi->s_bal_goals),
51449 + atomic_read_unchecked(&sbi->s_bal_2orders),
51450 + atomic_read_unchecked(&sbi->s_bal_breaks),
51451 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51452 ext4_msg(sb, KERN_INFO,
51453 "mballoc: %lu generated and it took %Lu",
51454 sbi->s_mb_buddies_generated,
51455 sbi->s_mb_generation_time);
51456 ext4_msg(sb, KERN_INFO,
51457 "mballoc: %u preallocated, %u discarded",
51458 - atomic_read(&sbi->s_mb_preallocated),
51459 - atomic_read(&sbi->s_mb_discarded));
51460 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51461 + atomic_read_unchecked(&sbi->s_mb_discarded));
51462 }
51463
51464 free_percpu(sbi->s_locality_groups);
51465 @@ -3039,16 +3039,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51466 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51467
51468 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51469 - atomic_inc(&sbi->s_bal_reqs);
51470 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51471 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51472 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51473 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51474 - atomic_inc(&sbi->s_bal_success);
51475 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51476 + atomic_inc_unchecked(&sbi->s_bal_success);
51477 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51478 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51479 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51480 - atomic_inc(&sbi->s_bal_goals);
51481 + atomic_inc_unchecked(&sbi->s_bal_goals);
51482 if (ac->ac_found > sbi->s_mb_max_to_scan)
51483 - atomic_inc(&sbi->s_bal_breaks);
51484 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51485 }
51486
51487 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51488 @@ -3448,7 +3448,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51489 trace_ext4_mb_new_inode_pa(ac, pa);
51490
51491 ext4_mb_use_inode_pa(ac, pa);
51492 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51493 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51494
51495 ei = EXT4_I(ac->ac_inode);
51496 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51497 @@ -3508,7 +3508,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51498 trace_ext4_mb_new_group_pa(ac, pa);
51499
51500 ext4_mb_use_group_pa(ac, pa);
51501 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51502 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51503
51504 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51505 lg = ac->ac_lg;
51506 @@ -3597,7 +3597,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51507 * from the bitmap and continue.
51508 */
51509 }
51510 - atomic_add(free, &sbi->s_mb_discarded);
51511 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51512
51513 return err;
51514 }
51515 @@ -3615,7 +3615,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51516 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51517 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51518 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51519 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51520 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51521 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51522
51523 return 0;
51524 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
51525 index b3b1f7d..cff51d5 100644
51526 --- a/fs/ext4/mmp.c
51527 +++ b/fs/ext4/mmp.c
51528 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
51529 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
51530 const char *function, unsigned int line, const char *msg)
51531 {
51532 - __ext4_warning(sb, function, line, msg);
51533 + __ext4_warning(sb, function, line, "%s", msg);
51534 __ext4_warning(sb, function, line,
51535 "MMP failure info: last update time: %llu, last update "
51536 "node: %s, last update device: %s\n",
51537 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
51538 index 3beae6a..8cc5637 100644
51539 --- a/fs/ext4/resize.c
51540 +++ b/fs/ext4/resize.c
51541 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
51542 ext4_fsblk_t end = start + input->blocks_count;
51543 ext4_group_t group = input->group;
51544 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
51545 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
51546 - ext4_fsblk_t metaend = start + overhead;
51547 + unsigned overhead;
51548 + ext4_fsblk_t metaend;
51549 struct buffer_head *bh = NULL;
51550 ext4_grpblk_t free_blocks_count, offset;
51551 int err = -EINVAL;
51552
51553 + if (group != sbi->s_groups_count) {
51554 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51555 + input->group, sbi->s_groups_count);
51556 + return -EINVAL;
51557 + }
51558 +
51559 + overhead = ext4_group_overhead_blocks(sb, group);
51560 + metaend = start + overhead;
51561 input->free_blocks_count = free_blocks_count =
51562 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
51563
51564 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
51565 free_blocks_count, input->reserved_blocks);
51566
51567 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
51568 - if (group != sbi->s_groups_count)
51569 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51570 - input->group, sbi->s_groups_count);
51571 - else if (offset != 0)
51572 + if (offset != 0)
51573 ext4_warning(sb, "Last group not full");
51574 else if (input->reserved_blocks > input->blocks_count / 5)
51575 ext4_warning(sb, "Reserved blocks too high (%u)",
51576 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51577 index febbe0e..d0cdc02 100644
51578 --- a/fs/ext4/super.c
51579 +++ b/fs/ext4/super.c
51580 @@ -1238,7 +1238,7 @@ static ext4_fsblk_t get_sb_block(void **data)
51581 }
51582
51583 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
51584 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51585 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51586 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
51587
51588 #ifdef CONFIG_QUOTA
51589 @@ -2380,7 +2380,7 @@ struct ext4_attr {
51590 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51591 const char *, size_t);
51592 int offset;
51593 -};
51594 +} __do_const;
51595
51596 static int parse_strtoul(const char *buf,
51597 unsigned long max, unsigned long *value)
51598 diff --git a/fs/fcntl.c b/fs/fcntl.c
51599 index 6599222..e7bf0de 100644
51600 --- a/fs/fcntl.c
51601 +++ b/fs/fcntl.c
51602 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51603 if (err)
51604 return err;
51605
51606 + if (gr_handle_chroot_fowner(pid, type))
51607 + return -ENOENT;
51608 + if (gr_check_protected_task_fowner(pid, type))
51609 + return -EACCES;
51610 +
51611 f_modown(filp, pid, type, force);
51612 return 0;
51613 }
51614 diff --git a/fs/fhandle.c b/fs/fhandle.c
51615 index 999ff5c..41f4109 100644
51616 --- a/fs/fhandle.c
51617 +++ b/fs/fhandle.c
51618 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51619 } else
51620 retval = 0;
51621 /* copy the mount id */
51622 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51623 - sizeof(*mnt_id)) ||
51624 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51625 copy_to_user(ufh, handle,
51626 sizeof(struct file_handle) + handle_bytes))
51627 retval = -EFAULT;
51628 diff --git a/fs/fifo.c b/fs/fifo.c
51629 index cf6f434..3d7942c 100644
51630 --- a/fs/fifo.c
51631 +++ b/fs/fifo.c
51632 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51633 */
51634 filp->f_op = &read_pipefifo_fops;
51635 pipe->r_counter++;
51636 - if (pipe->readers++ == 0)
51637 + if (atomic_inc_return(&pipe->readers) == 1)
51638 wake_up_partner(inode);
51639
51640 - if (!pipe->writers) {
51641 + if (!atomic_read(&pipe->writers)) {
51642 if ((filp->f_flags & O_NONBLOCK)) {
51643 /* suppress POLLHUP until we have
51644 * seen a writer */
51645 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51646 * errno=ENXIO when there is no process reading the FIFO.
51647 */
51648 ret = -ENXIO;
51649 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51650 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51651 goto err;
51652
51653 filp->f_op = &write_pipefifo_fops;
51654 pipe->w_counter++;
51655 - if (!pipe->writers++)
51656 + if (atomic_inc_return(&pipe->writers) == 1)
51657 wake_up_partner(inode);
51658
51659 - if (!pipe->readers) {
51660 + if (!atomic_read(&pipe->readers)) {
51661 if (wait_for_partner(inode, &pipe->r_counter))
51662 goto err_wr;
51663 }
51664 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51665 */
51666 filp->f_op = &rdwr_pipefifo_fops;
51667
51668 - pipe->readers++;
51669 - pipe->writers++;
51670 + atomic_inc(&pipe->readers);
51671 + atomic_inc(&pipe->writers);
51672 pipe->r_counter++;
51673 pipe->w_counter++;
51674 - if (pipe->readers == 1 || pipe->writers == 1)
51675 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51676 wake_up_partner(inode);
51677 break;
51678
51679 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51680 return 0;
51681
51682 err_rd:
51683 - if (!--pipe->readers)
51684 + if (atomic_dec_and_test(&pipe->readers))
51685 wake_up_interruptible(&pipe->wait);
51686 ret = -ERESTARTSYS;
51687 goto err;
51688
51689 err_wr:
51690 - if (!--pipe->writers)
51691 + if (atomic_dec_and_test(&pipe->writers))
51692 wake_up_interruptible(&pipe->wait);
51693 ret = -ERESTARTSYS;
51694 goto err;
51695
51696 err:
51697 - if (!pipe->readers && !pipe->writers)
51698 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51699 free_pipe_info(inode);
51700
51701 err_nocleanup:
51702 diff --git a/fs/file.c b/fs/file.c
51703 index 3906d95..5fe379b 100644
51704 --- a/fs/file.c
51705 +++ b/fs/file.c
51706 @@ -16,6 +16,7 @@
51707 #include <linux/slab.h>
51708 #include <linux/vmalloc.h>
51709 #include <linux/file.h>
51710 +#include <linux/security.h>
51711 #include <linux/fdtable.h>
51712 #include <linux/bitops.h>
51713 #include <linux/interrupt.h>
51714 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51715 if (!file)
51716 return __close_fd(files, fd);
51717
51718 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51719 if (fd >= rlimit(RLIMIT_NOFILE))
51720 return -EBADF;
51721
51722 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51723 if (unlikely(oldfd == newfd))
51724 return -EINVAL;
51725
51726 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51727 if (newfd >= rlimit(RLIMIT_NOFILE))
51728 return -EBADF;
51729
51730 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51731 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51732 {
51733 int err;
51734 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51735 if (from >= rlimit(RLIMIT_NOFILE))
51736 return -EINVAL;
51737 err = alloc_fd(from, flags);
51738 diff --git a/fs/filesystems.c b/fs/filesystems.c
51739 index 92567d9..fcd8cbf 100644
51740 --- a/fs/filesystems.c
51741 +++ b/fs/filesystems.c
51742 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
51743 int len = dot ? dot - name : strlen(name);
51744
51745 fs = __get_fs_type(name, len);
51746 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51747 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
51748 +#else
51749 if (!fs && (request_module("fs-%.*s", len, name) == 0))
51750 +#endif
51751 fs = __get_fs_type(name, len);
51752
51753 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51754 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51755 index d8ac61d..79a36f0 100644
51756 --- a/fs/fs_struct.c
51757 +++ b/fs/fs_struct.c
51758 @@ -4,6 +4,7 @@
51759 #include <linux/path.h>
51760 #include <linux/slab.h>
51761 #include <linux/fs_struct.h>
51762 +#include <linux/grsecurity.h>
51763 #include "internal.h"
51764
51765 /*
51766 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
51767 write_seqcount_begin(&fs->seq);
51768 old_root = fs->root;
51769 fs->root = *path;
51770 + gr_set_chroot_entries(current, path);
51771 write_seqcount_end(&fs->seq);
51772 spin_unlock(&fs->lock);
51773 if (old_root.dentry)
51774 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
51775 int hits = 0;
51776 spin_lock(&fs->lock);
51777 write_seqcount_begin(&fs->seq);
51778 + /* this root replacement is only done by pivot_root,
51779 + leave grsec's chroot tagging alone for this task
51780 + so that a pivoted root isn't treated as a chroot
51781 + */
51782 hits += replace_path(&fs->root, old_root, new_root);
51783 hits += replace_path(&fs->pwd, old_root, new_root);
51784 write_seqcount_end(&fs->seq);
51785 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
51786 task_lock(tsk);
51787 spin_lock(&fs->lock);
51788 tsk->fs = NULL;
51789 - kill = !--fs->users;
51790 + gr_clear_chroot_entries(tsk);
51791 + kill = !atomic_dec_return(&fs->users);
51792 spin_unlock(&fs->lock);
51793 task_unlock(tsk);
51794 if (kill)
51795 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51796 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51797 /* We don't need to lock fs - think why ;-) */
51798 if (fs) {
51799 - fs->users = 1;
51800 + atomic_set(&fs->users, 1);
51801 fs->in_exec = 0;
51802 spin_lock_init(&fs->lock);
51803 seqcount_init(&fs->seq);
51804 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51805 spin_lock(&old->lock);
51806 fs->root = old->root;
51807 path_get(&fs->root);
51808 + /* instead of calling gr_set_chroot_entries here,
51809 + we call it from every caller of this function
51810 + */
51811 fs->pwd = old->pwd;
51812 path_get(&fs->pwd);
51813 spin_unlock(&old->lock);
51814 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
51815
51816 task_lock(current);
51817 spin_lock(&fs->lock);
51818 - kill = !--fs->users;
51819 + kill = !atomic_dec_return(&fs->users);
51820 current->fs = new_fs;
51821 + gr_set_chroot_entries(current, &new_fs->root);
51822 spin_unlock(&fs->lock);
51823 task_unlock(current);
51824
51825 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51826
51827 int current_umask(void)
51828 {
51829 - return current->fs->umask;
51830 + return current->fs->umask | gr_acl_umask();
51831 }
51832 EXPORT_SYMBOL(current_umask);
51833
51834 /* to be mentioned only in INIT_TASK */
51835 struct fs_struct init_fs = {
51836 - .users = 1,
51837 + .users = ATOMIC_INIT(1),
51838 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51839 .seq = SEQCNT_ZERO,
51840 .umask = 0022,
51841 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51842 index e2cba1f..17a25bb 100644
51843 --- a/fs/fscache/cookie.c
51844 +++ b/fs/fscache/cookie.c
51845 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51846 parent ? (char *) parent->def->name : "<no-parent>",
51847 def->name, netfs_data);
51848
51849 - fscache_stat(&fscache_n_acquires);
51850 + fscache_stat_unchecked(&fscache_n_acquires);
51851
51852 /* if there's no parent cookie, then we don't create one here either */
51853 if (!parent) {
51854 - fscache_stat(&fscache_n_acquires_null);
51855 + fscache_stat_unchecked(&fscache_n_acquires_null);
51856 _leave(" [no parent]");
51857 return NULL;
51858 }
51859 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51860 /* allocate and initialise a cookie */
51861 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51862 if (!cookie) {
51863 - fscache_stat(&fscache_n_acquires_oom);
51864 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51865 _leave(" [ENOMEM]");
51866 return NULL;
51867 }
51868 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51869
51870 switch (cookie->def->type) {
51871 case FSCACHE_COOKIE_TYPE_INDEX:
51872 - fscache_stat(&fscache_n_cookie_index);
51873 + fscache_stat_unchecked(&fscache_n_cookie_index);
51874 break;
51875 case FSCACHE_COOKIE_TYPE_DATAFILE:
51876 - fscache_stat(&fscache_n_cookie_data);
51877 + fscache_stat_unchecked(&fscache_n_cookie_data);
51878 break;
51879 default:
51880 - fscache_stat(&fscache_n_cookie_special);
51881 + fscache_stat_unchecked(&fscache_n_cookie_special);
51882 break;
51883 }
51884
51885 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51886 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51887 atomic_dec(&parent->n_children);
51888 __fscache_cookie_put(cookie);
51889 - fscache_stat(&fscache_n_acquires_nobufs);
51890 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51891 _leave(" = NULL");
51892 return NULL;
51893 }
51894 }
51895
51896 - fscache_stat(&fscache_n_acquires_ok);
51897 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51898 _leave(" = %p", cookie);
51899 return cookie;
51900 }
51901 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51902 cache = fscache_select_cache_for_object(cookie->parent);
51903 if (!cache) {
51904 up_read(&fscache_addremove_sem);
51905 - fscache_stat(&fscache_n_acquires_no_cache);
51906 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51907 _leave(" = -ENOMEDIUM [no cache]");
51908 return -ENOMEDIUM;
51909 }
51910 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51911 object = cache->ops->alloc_object(cache, cookie);
51912 fscache_stat_d(&fscache_n_cop_alloc_object);
51913 if (IS_ERR(object)) {
51914 - fscache_stat(&fscache_n_object_no_alloc);
51915 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51916 ret = PTR_ERR(object);
51917 goto error;
51918 }
51919
51920 - fscache_stat(&fscache_n_object_alloc);
51921 + fscache_stat_unchecked(&fscache_n_object_alloc);
51922
51923 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51924
51925 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51926
51927 _enter("{%s}", cookie->def->name);
51928
51929 - fscache_stat(&fscache_n_invalidates);
51930 + fscache_stat_unchecked(&fscache_n_invalidates);
51931
51932 /* Only permit invalidation of data files. Invalidating an index will
51933 * require the caller to release all its attachments to the tree rooted
51934 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51935 {
51936 struct fscache_object *object;
51937
51938 - fscache_stat(&fscache_n_updates);
51939 + fscache_stat_unchecked(&fscache_n_updates);
51940
51941 if (!cookie) {
51942 - fscache_stat(&fscache_n_updates_null);
51943 + fscache_stat_unchecked(&fscache_n_updates_null);
51944 _leave(" [no cookie]");
51945 return;
51946 }
51947 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51948 struct fscache_object *object;
51949 unsigned long event;
51950
51951 - fscache_stat(&fscache_n_relinquishes);
51952 + fscache_stat_unchecked(&fscache_n_relinquishes);
51953 if (retire)
51954 - fscache_stat(&fscache_n_relinquishes_retire);
51955 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51956
51957 if (!cookie) {
51958 - fscache_stat(&fscache_n_relinquishes_null);
51959 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51960 _leave(" [no cookie]");
51961 return;
51962 }
51963 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51964
51965 /* wait for the cookie to finish being instantiated (or to fail) */
51966 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51967 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51968 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51969 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51970 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51971 }
51972 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51973 index ee38fef..0a326d4 100644
51974 --- a/fs/fscache/internal.h
51975 +++ b/fs/fscache/internal.h
51976 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51977 * stats.c
51978 */
51979 #ifdef CONFIG_FSCACHE_STATS
51980 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51981 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51982 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51983 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51984
51985 -extern atomic_t fscache_n_op_pend;
51986 -extern atomic_t fscache_n_op_run;
51987 -extern atomic_t fscache_n_op_enqueue;
51988 -extern atomic_t fscache_n_op_deferred_release;
51989 -extern atomic_t fscache_n_op_release;
51990 -extern atomic_t fscache_n_op_gc;
51991 -extern atomic_t fscache_n_op_cancelled;
51992 -extern atomic_t fscache_n_op_rejected;
51993 +extern atomic_unchecked_t fscache_n_op_pend;
51994 +extern atomic_unchecked_t fscache_n_op_run;
51995 +extern atomic_unchecked_t fscache_n_op_enqueue;
51996 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51997 +extern atomic_unchecked_t fscache_n_op_release;
51998 +extern atomic_unchecked_t fscache_n_op_gc;
51999 +extern atomic_unchecked_t fscache_n_op_cancelled;
52000 +extern atomic_unchecked_t fscache_n_op_rejected;
52001
52002 -extern atomic_t fscache_n_attr_changed;
52003 -extern atomic_t fscache_n_attr_changed_ok;
52004 -extern atomic_t fscache_n_attr_changed_nobufs;
52005 -extern atomic_t fscache_n_attr_changed_nomem;
52006 -extern atomic_t fscache_n_attr_changed_calls;
52007 +extern atomic_unchecked_t fscache_n_attr_changed;
52008 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52009 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52010 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52011 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52012
52013 -extern atomic_t fscache_n_allocs;
52014 -extern atomic_t fscache_n_allocs_ok;
52015 -extern atomic_t fscache_n_allocs_wait;
52016 -extern atomic_t fscache_n_allocs_nobufs;
52017 -extern atomic_t fscache_n_allocs_intr;
52018 -extern atomic_t fscache_n_allocs_object_dead;
52019 -extern atomic_t fscache_n_alloc_ops;
52020 -extern atomic_t fscache_n_alloc_op_waits;
52021 +extern atomic_unchecked_t fscache_n_allocs;
52022 +extern atomic_unchecked_t fscache_n_allocs_ok;
52023 +extern atomic_unchecked_t fscache_n_allocs_wait;
52024 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52025 +extern atomic_unchecked_t fscache_n_allocs_intr;
52026 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52027 +extern atomic_unchecked_t fscache_n_alloc_ops;
52028 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52029
52030 -extern atomic_t fscache_n_retrievals;
52031 -extern atomic_t fscache_n_retrievals_ok;
52032 -extern atomic_t fscache_n_retrievals_wait;
52033 -extern atomic_t fscache_n_retrievals_nodata;
52034 -extern atomic_t fscache_n_retrievals_nobufs;
52035 -extern atomic_t fscache_n_retrievals_intr;
52036 -extern atomic_t fscache_n_retrievals_nomem;
52037 -extern atomic_t fscache_n_retrievals_object_dead;
52038 -extern atomic_t fscache_n_retrieval_ops;
52039 -extern atomic_t fscache_n_retrieval_op_waits;
52040 +extern atomic_unchecked_t fscache_n_retrievals;
52041 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52042 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52043 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52044 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52045 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52046 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52047 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52048 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52049 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52050
52051 -extern atomic_t fscache_n_stores;
52052 -extern atomic_t fscache_n_stores_ok;
52053 -extern atomic_t fscache_n_stores_again;
52054 -extern atomic_t fscache_n_stores_nobufs;
52055 -extern atomic_t fscache_n_stores_oom;
52056 -extern atomic_t fscache_n_store_ops;
52057 -extern atomic_t fscache_n_store_calls;
52058 -extern atomic_t fscache_n_store_pages;
52059 -extern atomic_t fscache_n_store_radix_deletes;
52060 -extern atomic_t fscache_n_store_pages_over_limit;
52061 +extern atomic_unchecked_t fscache_n_stores;
52062 +extern atomic_unchecked_t fscache_n_stores_ok;
52063 +extern atomic_unchecked_t fscache_n_stores_again;
52064 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52065 +extern atomic_unchecked_t fscache_n_stores_oom;
52066 +extern atomic_unchecked_t fscache_n_store_ops;
52067 +extern atomic_unchecked_t fscache_n_store_calls;
52068 +extern atomic_unchecked_t fscache_n_store_pages;
52069 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52070 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52071
52072 -extern atomic_t fscache_n_store_vmscan_not_storing;
52073 -extern atomic_t fscache_n_store_vmscan_gone;
52074 -extern atomic_t fscache_n_store_vmscan_busy;
52075 -extern atomic_t fscache_n_store_vmscan_cancelled;
52076 -extern atomic_t fscache_n_store_vmscan_wait;
52077 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52078 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52079 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52080 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52081 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52082
52083 -extern atomic_t fscache_n_marks;
52084 -extern atomic_t fscache_n_uncaches;
52085 +extern atomic_unchecked_t fscache_n_marks;
52086 +extern atomic_unchecked_t fscache_n_uncaches;
52087
52088 -extern atomic_t fscache_n_acquires;
52089 -extern atomic_t fscache_n_acquires_null;
52090 -extern atomic_t fscache_n_acquires_no_cache;
52091 -extern atomic_t fscache_n_acquires_ok;
52092 -extern atomic_t fscache_n_acquires_nobufs;
52093 -extern atomic_t fscache_n_acquires_oom;
52094 +extern atomic_unchecked_t fscache_n_acquires;
52095 +extern atomic_unchecked_t fscache_n_acquires_null;
52096 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52097 +extern atomic_unchecked_t fscache_n_acquires_ok;
52098 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52099 +extern atomic_unchecked_t fscache_n_acquires_oom;
52100
52101 -extern atomic_t fscache_n_invalidates;
52102 -extern atomic_t fscache_n_invalidates_run;
52103 +extern atomic_unchecked_t fscache_n_invalidates;
52104 +extern atomic_unchecked_t fscache_n_invalidates_run;
52105
52106 -extern atomic_t fscache_n_updates;
52107 -extern atomic_t fscache_n_updates_null;
52108 -extern atomic_t fscache_n_updates_run;
52109 +extern atomic_unchecked_t fscache_n_updates;
52110 +extern atomic_unchecked_t fscache_n_updates_null;
52111 +extern atomic_unchecked_t fscache_n_updates_run;
52112
52113 -extern atomic_t fscache_n_relinquishes;
52114 -extern atomic_t fscache_n_relinquishes_null;
52115 -extern atomic_t fscache_n_relinquishes_waitcrt;
52116 -extern atomic_t fscache_n_relinquishes_retire;
52117 +extern atomic_unchecked_t fscache_n_relinquishes;
52118 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52119 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52120 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52121
52122 -extern atomic_t fscache_n_cookie_index;
52123 -extern atomic_t fscache_n_cookie_data;
52124 -extern atomic_t fscache_n_cookie_special;
52125 +extern atomic_unchecked_t fscache_n_cookie_index;
52126 +extern atomic_unchecked_t fscache_n_cookie_data;
52127 +extern atomic_unchecked_t fscache_n_cookie_special;
52128
52129 -extern atomic_t fscache_n_object_alloc;
52130 -extern atomic_t fscache_n_object_no_alloc;
52131 -extern atomic_t fscache_n_object_lookups;
52132 -extern atomic_t fscache_n_object_lookups_negative;
52133 -extern atomic_t fscache_n_object_lookups_positive;
52134 -extern atomic_t fscache_n_object_lookups_timed_out;
52135 -extern atomic_t fscache_n_object_created;
52136 -extern atomic_t fscache_n_object_avail;
52137 -extern atomic_t fscache_n_object_dead;
52138 +extern atomic_unchecked_t fscache_n_object_alloc;
52139 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52140 +extern atomic_unchecked_t fscache_n_object_lookups;
52141 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52142 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52143 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52144 +extern atomic_unchecked_t fscache_n_object_created;
52145 +extern atomic_unchecked_t fscache_n_object_avail;
52146 +extern atomic_unchecked_t fscache_n_object_dead;
52147
52148 -extern atomic_t fscache_n_checkaux_none;
52149 -extern atomic_t fscache_n_checkaux_okay;
52150 -extern atomic_t fscache_n_checkaux_update;
52151 -extern atomic_t fscache_n_checkaux_obsolete;
52152 +extern atomic_unchecked_t fscache_n_checkaux_none;
52153 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52154 +extern atomic_unchecked_t fscache_n_checkaux_update;
52155 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52156
52157 extern atomic_t fscache_n_cop_alloc_object;
52158 extern atomic_t fscache_n_cop_lookup_object;
52159 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52160 atomic_inc(stat);
52161 }
52162
52163 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52164 +{
52165 + atomic_inc_unchecked(stat);
52166 +}
52167 +
52168 static inline void fscache_stat_d(atomic_t *stat)
52169 {
52170 atomic_dec(stat);
52171 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52172
52173 #define __fscache_stat(stat) (NULL)
52174 #define fscache_stat(stat) do {} while (0)
52175 +#define fscache_stat_unchecked(stat) do {} while (0)
52176 #define fscache_stat_d(stat) do {} while (0)
52177 #endif
52178
52179 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52180 index 50d41c1..10ee117 100644
52181 --- a/fs/fscache/object.c
52182 +++ b/fs/fscache/object.c
52183 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52184 /* Invalidate an object on disk */
52185 case FSCACHE_OBJECT_INVALIDATING:
52186 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52187 - fscache_stat(&fscache_n_invalidates_run);
52188 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52189 fscache_stat(&fscache_n_cop_invalidate_object);
52190 fscache_invalidate_object(object);
52191 fscache_stat_d(&fscache_n_cop_invalidate_object);
52192 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52193 /* update the object metadata on disk */
52194 case FSCACHE_OBJECT_UPDATING:
52195 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52196 - fscache_stat(&fscache_n_updates_run);
52197 + fscache_stat_unchecked(&fscache_n_updates_run);
52198 fscache_stat(&fscache_n_cop_update_object);
52199 object->cache->ops->update_object(object);
52200 fscache_stat_d(&fscache_n_cop_update_object);
52201 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52202 spin_lock(&object->lock);
52203 object->state = FSCACHE_OBJECT_DEAD;
52204 spin_unlock(&object->lock);
52205 - fscache_stat(&fscache_n_object_dead);
52206 + fscache_stat_unchecked(&fscache_n_object_dead);
52207 goto terminal_transit;
52208
52209 /* handle the parent cache of this object being withdrawn from
52210 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52211 spin_lock(&object->lock);
52212 object->state = FSCACHE_OBJECT_DEAD;
52213 spin_unlock(&object->lock);
52214 - fscache_stat(&fscache_n_object_dead);
52215 + fscache_stat_unchecked(&fscache_n_object_dead);
52216 goto terminal_transit;
52217
52218 /* complain about the object being woken up once it is
52219 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52220 parent->cookie->def->name, cookie->def->name,
52221 object->cache->tag->name);
52222
52223 - fscache_stat(&fscache_n_object_lookups);
52224 + fscache_stat_unchecked(&fscache_n_object_lookups);
52225 fscache_stat(&fscache_n_cop_lookup_object);
52226 ret = object->cache->ops->lookup_object(object);
52227 fscache_stat_d(&fscache_n_cop_lookup_object);
52228 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52229 if (ret == -ETIMEDOUT) {
52230 /* probably stuck behind another object, so move this one to
52231 * the back of the queue */
52232 - fscache_stat(&fscache_n_object_lookups_timed_out);
52233 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52234 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52235 }
52236
52237 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52238
52239 spin_lock(&object->lock);
52240 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52241 - fscache_stat(&fscache_n_object_lookups_negative);
52242 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52243
52244 /* transit here to allow write requests to begin stacking up
52245 * and read requests to begin returning ENODATA */
52246 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52247 * result, in which case there may be data available */
52248 spin_lock(&object->lock);
52249 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52250 - fscache_stat(&fscache_n_object_lookups_positive);
52251 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52252
52253 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52254
52255 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52256 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52257 } else {
52258 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52259 - fscache_stat(&fscache_n_object_created);
52260 + fscache_stat_unchecked(&fscache_n_object_created);
52261
52262 object->state = FSCACHE_OBJECT_AVAILABLE;
52263 spin_unlock(&object->lock);
52264 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52265 fscache_enqueue_dependents(object);
52266
52267 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52268 - fscache_stat(&fscache_n_object_avail);
52269 + fscache_stat_unchecked(&fscache_n_object_avail);
52270
52271 _leave("");
52272 }
52273 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52274 enum fscache_checkaux result;
52275
52276 if (!object->cookie->def->check_aux) {
52277 - fscache_stat(&fscache_n_checkaux_none);
52278 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52279 return FSCACHE_CHECKAUX_OKAY;
52280 }
52281
52282 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52283 switch (result) {
52284 /* entry okay as is */
52285 case FSCACHE_CHECKAUX_OKAY:
52286 - fscache_stat(&fscache_n_checkaux_okay);
52287 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52288 break;
52289
52290 /* entry requires update */
52291 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52292 - fscache_stat(&fscache_n_checkaux_update);
52293 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52294 break;
52295
52296 /* entry requires deletion */
52297 case FSCACHE_CHECKAUX_OBSOLETE:
52298 - fscache_stat(&fscache_n_checkaux_obsolete);
52299 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52300 break;
52301
52302 default:
52303 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52304 index 762a9ec..2023284 100644
52305 --- a/fs/fscache/operation.c
52306 +++ b/fs/fscache/operation.c
52307 @@ -17,7 +17,7 @@
52308 #include <linux/slab.h>
52309 #include "internal.h"
52310
52311 -atomic_t fscache_op_debug_id;
52312 +atomic_unchecked_t fscache_op_debug_id;
52313 EXPORT_SYMBOL(fscache_op_debug_id);
52314
52315 /**
52316 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52317 ASSERTCMP(atomic_read(&op->usage), >, 0);
52318 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52319
52320 - fscache_stat(&fscache_n_op_enqueue);
52321 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52322 switch (op->flags & FSCACHE_OP_TYPE) {
52323 case FSCACHE_OP_ASYNC:
52324 _debug("queue async");
52325 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52326 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52327 if (op->processor)
52328 fscache_enqueue_operation(op);
52329 - fscache_stat(&fscache_n_op_run);
52330 + fscache_stat_unchecked(&fscache_n_op_run);
52331 }
52332
52333 /*
52334 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52335 if (object->n_in_progress > 0) {
52336 atomic_inc(&op->usage);
52337 list_add_tail(&op->pend_link, &object->pending_ops);
52338 - fscache_stat(&fscache_n_op_pend);
52339 + fscache_stat_unchecked(&fscache_n_op_pend);
52340 } else if (!list_empty(&object->pending_ops)) {
52341 atomic_inc(&op->usage);
52342 list_add_tail(&op->pend_link, &object->pending_ops);
52343 - fscache_stat(&fscache_n_op_pend);
52344 + fscache_stat_unchecked(&fscache_n_op_pend);
52345 fscache_start_operations(object);
52346 } else {
52347 ASSERTCMP(object->n_in_progress, ==, 0);
52348 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52349 object->n_exclusive++; /* reads and writes must wait */
52350 atomic_inc(&op->usage);
52351 list_add_tail(&op->pend_link, &object->pending_ops);
52352 - fscache_stat(&fscache_n_op_pend);
52353 + fscache_stat_unchecked(&fscache_n_op_pend);
52354 ret = 0;
52355 } else {
52356 /* If we're in any other state, there must have been an I/O
52357 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52358 if (object->n_exclusive > 0) {
52359 atomic_inc(&op->usage);
52360 list_add_tail(&op->pend_link, &object->pending_ops);
52361 - fscache_stat(&fscache_n_op_pend);
52362 + fscache_stat_unchecked(&fscache_n_op_pend);
52363 } else if (!list_empty(&object->pending_ops)) {
52364 atomic_inc(&op->usage);
52365 list_add_tail(&op->pend_link, &object->pending_ops);
52366 - fscache_stat(&fscache_n_op_pend);
52367 + fscache_stat_unchecked(&fscache_n_op_pend);
52368 fscache_start_operations(object);
52369 } else {
52370 ASSERTCMP(object->n_exclusive, ==, 0);
52371 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52372 object->n_ops++;
52373 atomic_inc(&op->usage);
52374 list_add_tail(&op->pend_link, &object->pending_ops);
52375 - fscache_stat(&fscache_n_op_pend);
52376 + fscache_stat_unchecked(&fscache_n_op_pend);
52377 ret = 0;
52378 } else if (object->state == FSCACHE_OBJECT_DYING ||
52379 object->state == FSCACHE_OBJECT_LC_DYING ||
52380 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52381 - fscache_stat(&fscache_n_op_rejected);
52382 + fscache_stat_unchecked(&fscache_n_op_rejected);
52383 op->state = FSCACHE_OP_ST_CANCELLED;
52384 ret = -ENOBUFS;
52385 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52386 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52387 ret = -EBUSY;
52388 if (op->state == FSCACHE_OP_ST_PENDING) {
52389 ASSERT(!list_empty(&op->pend_link));
52390 - fscache_stat(&fscache_n_op_cancelled);
52391 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52392 list_del_init(&op->pend_link);
52393 if (do_cancel)
52394 do_cancel(op);
52395 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52396 while (!list_empty(&object->pending_ops)) {
52397 op = list_entry(object->pending_ops.next,
52398 struct fscache_operation, pend_link);
52399 - fscache_stat(&fscache_n_op_cancelled);
52400 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52401 list_del_init(&op->pend_link);
52402
52403 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52404 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52405 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52406 op->state = FSCACHE_OP_ST_DEAD;
52407
52408 - fscache_stat(&fscache_n_op_release);
52409 + fscache_stat_unchecked(&fscache_n_op_release);
52410
52411 if (op->release) {
52412 op->release(op);
52413 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52414 * lock, and defer it otherwise */
52415 if (!spin_trylock(&object->lock)) {
52416 _debug("defer put");
52417 - fscache_stat(&fscache_n_op_deferred_release);
52418 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52419
52420 cache = object->cache;
52421 spin_lock(&cache->op_gc_list_lock);
52422 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52423
52424 _debug("GC DEFERRED REL OBJ%x OP%x",
52425 object->debug_id, op->debug_id);
52426 - fscache_stat(&fscache_n_op_gc);
52427 + fscache_stat_unchecked(&fscache_n_op_gc);
52428
52429 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52430 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52431 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52432 index ff000e5..c44ec6d 100644
52433 --- a/fs/fscache/page.c
52434 +++ b/fs/fscache/page.c
52435 @@ -61,7 +61,7 @@ try_again:
52436 val = radix_tree_lookup(&cookie->stores, page->index);
52437 if (!val) {
52438 rcu_read_unlock();
52439 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52440 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52441 __fscache_uncache_page(cookie, page);
52442 return true;
52443 }
52444 @@ -91,11 +91,11 @@ try_again:
52445 spin_unlock(&cookie->stores_lock);
52446
52447 if (xpage) {
52448 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52449 - fscache_stat(&fscache_n_store_radix_deletes);
52450 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52451 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52452 ASSERTCMP(xpage, ==, page);
52453 } else {
52454 - fscache_stat(&fscache_n_store_vmscan_gone);
52455 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52456 }
52457
52458 wake_up_bit(&cookie->flags, 0);
52459 @@ -110,11 +110,11 @@ page_busy:
52460 * sleeping on memory allocation, so we may need to impose a timeout
52461 * too. */
52462 if (!(gfp & __GFP_WAIT)) {
52463 - fscache_stat(&fscache_n_store_vmscan_busy);
52464 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52465 return false;
52466 }
52467
52468 - fscache_stat(&fscache_n_store_vmscan_wait);
52469 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52470 __fscache_wait_on_page_write(cookie, page);
52471 gfp &= ~__GFP_WAIT;
52472 goto try_again;
52473 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52474 FSCACHE_COOKIE_STORING_TAG);
52475 if (!radix_tree_tag_get(&cookie->stores, page->index,
52476 FSCACHE_COOKIE_PENDING_TAG)) {
52477 - fscache_stat(&fscache_n_store_radix_deletes);
52478 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52479 xpage = radix_tree_delete(&cookie->stores, page->index);
52480 }
52481 spin_unlock(&cookie->stores_lock);
52482 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52483
52484 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52485
52486 - fscache_stat(&fscache_n_attr_changed_calls);
52487 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52488
52489 if (fscache_object_is_active(object)) {
52490 fscache_stat(&fscache_n_cop_attr_changed);
52491 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52492
52493 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52494
52495 - fscache_stat(&fscache_n_attr_changed);
52496 + fscache_stat_unchecked(&fscache_n_attr_changed);
52497
52498 op = kzalloc(sizeof(*op), GFP_KERNEL);
52499 if (!op) {
52500 - fscache_stat(&fscache_n_attr_changed_nomem);
52501 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52502 _leave(" = -ENOMEM");
52503 return -ENOMEM;
52504 }
52505 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52506 if (fscache_submit_exclusive_op(object, op) < 0)
52507 goto nobufs;
52508 spin_unlock(&cookie->lock);
52509 - fscache_stat(&fscache_n_attr_changed_ok);
52510 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52511 fscache_put_operation(op);
52512 _leave(" = 0");
52513 return 0;
52514 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52515 nobufs:
52516 spin_unlock(&cookie->lock);
52517 kfree(op);
52518 - fscache_stat(&fscache_n_attr_changed_nobufs);
52519 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52520 _leave(" = %d", -ENOBUFS);
52521 return -ENOBUFS;
52522 }
52523 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52524 /* allocate a retrieval operation and attempt to submit it */
52525 op = kzalloc(sizeof(*op), GFP_NOIO);
52526 if (!op) {
52527 - fscache_stat(&fscache_n_retrievals_nomem);
52528 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52529 return NULL;
52530 }
52531
52532 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52533 return 0;
52534 }
52535
52536 - fscache_stat(&fscache_n_retrievals_wait);
52537 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52538
52539 jif = jiffies;
52540 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52541 fscache_wait_bit_interruptible,
52542 TASK_INTERRUPTIBLE) != 0) {
52543 - fscache_stat(&fscache_n_retrievals_intr);
52544 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52545 _leave(" = -ERESTARTSYS");
52546 return -ERESTARTSYS;
52547 }
52548 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52549 */
52550 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52551 struct fscache_retrieval *op,
52552 - atomic_t *stat_op_waits,
52553 - atomic_t *stat_object_dead)
52554 + atomic_unchecked_t *stat_op_waits,
52555 + atomic_unchecked_t *stat_object_dead)
52556 {
52557 int ret;
52558
52559 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52560 goto check_if_dead;
52561
52562 _debug(">>> WT");
52563 - fscache_stat(stat_op_waits);
52564 + fscache_stat_unchecked(stat_op_waits);
52565 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52566 fscache_wait_bit_interruptible,
52567 TASK_INTERRUPTIBLE) != 0) {
52568 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52569
52570 check_if_dead:
52571 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52572 - fscache_stat(stat_object_dead);
52573 + fscache_stat_unchecked(stat_object_dead);
52574 _leave(" = -ENOBUFS [cancelled]");
52575 return -ENOBUFS;
52576 }
52577 if (unlikely(fscache_object_is_dead(object))) {
52578 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52579 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52580 - fscache_stat(stat_object_dead);
52581 + fscache_stat_unchecked(stat_object_dead);
52582 return -ENOBUFS;
52583 }
52584 return 0;
52585 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52586
52587 _enter("%p,%p,,,", cookie, page);
52588
52589 - fscache_stat(&fscache_n_retrievals);
52590 + fscache_stat_unchecked(&fscache_n_retrievals);
52591
52592 if (hlist_empty(&cookie->backing_objects))
52593 goto nobufs;
52594 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52595 goto nobufs_unlock_dec;
52596 spin_unlock(&cookie->lock);
52597
52598 - fscache_stat(&fscache_n_retrieval_ops);
52599 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52600
52601 /* pin the netfs read context in case we need to do the actual netfs
52602 * read because we've encountered a cache read failure */
52603 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52604
52605 error:
52606 if (ret == -ENOMEM)
52607 - fscache_stat(&fscache_n_retrievals_nomem);
52608 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52609 else if (ret == -ERESTARTSYS)
52610 - fscache_stat(&fscache_n_retrievals_intr);
52611 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52612 else if (ret == -ENODATA)
52613 - fscache_stat(&fscache_n_retrievals_nodata);
52614 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52615 else if (ret < 0)
52616 - fscache_stat(&fscache_n_retrievals_nobufs);
52617 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52618 else
52619 - fscache_stat(&fscache_n_retrievals_ok);
52620 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52621
52622 fscache_put_retrieval(op);
52623 _leave(" = %d", ret);
52624 @@ -467,7 +467,7 @@ nobufs_unlock:
52625 spin_unlock(&cookie->lock);
52626 kfree(op);
52627 nobufs:
52628 - fscache_stat(&fscache_n_retrievals_nobufs);
52629 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52630 _leave(" = -ENOBUFS");
52631 return -ENOBUFS;
52632 }
52633 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52634
52635 _enter("%p,,%d,,,", cookie, *nr_pages);
52636
52637 - fscache_stat(&fscache_n_retrievals);
52638 + fscache_stat_unchecked(&fscache_n_retrievals);
52639
52640 if (hlist_empty(&cookie->backing_objects))
52641 goto nobufs;
52642 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52643 goto nobufs_unlock_dec;
52644 spin_unlock(&cookie->lock);
52645
52646 - fscache_stat(&fscache_n_retrieval_ops);
52647 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52648
52649 /* pin the netfs read context in case we need to do the actual netfs
52650 * read because we've encountered a cache read failure */
52651 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52652
52653 error:
52654 if (ret == -ENOMEM)
52655 - fscache_stat(&fscache_n_retrievals_nomem);
52656 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52657 else if (ret == -ERESTARTSYS)
52658 - fscache_stat(&fscache_n_retrievals_intr);
52659 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52660 else if (ret == -ENODATA)
52661 - fscache_stat(&fscache_n_retrievals_nodata);
52662 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52663 else if (ret < 0)
52664 - fscache_stat(&fscache_n_retrievals_nobufs);
52665 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52666 else
52667 - fscache_stat(&fscache_n_retrievals_ok);
52668 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52669
52670 fscache_put_retrieval(op);
52671 _leave(" = %d", ret);
52672 @@ -591,7 +591,7 @@ nobufs_unlock:
52673 spin_unlock(&cookie->lock);
52674 kfree(op);
52675 nobufs:
52676 - fscache_stat(&fscache_n_retrievals_nobufs);
52677 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52678 _leave(" = -ENOBUFS");
52679 return -ENOBUFS;
52680 }
52681 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52682
52683 _enter("%p,%p,,,", cookie, page);
52684
52685 - fscache_stat(&fscache_n_allocs);
52686 + fscache_stat_unchecked(&fscache_n_allocs);
52687
52688 if (hlist_empty(&cookie->backing_objects))
52689 goto nobufs;
52690 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52691 goto nobufs_unlock;
52692 spin_unlock(&cookie->lock);
52693
52694 - fscache_stat(&fscache_n_alloc_ops);
52695 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52696
52697 ret = fscache_wait_for_retrieval_activation(
52698 object, op,
52699 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52700
52701 error:
52702 if (ret == -ERESTARTSYS)
52703 - fscache_stat(&fscache_n_allocs_intr);
52704 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52705 else if (ret < 0)
52706 - fscache_stat(&fscache_n_allocs_nobufs);
52707 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52708 else
52709 - fscache_stat(&fscache_n_allocs_ok);
52710 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52711
52712 fscache_put_retrieval(op);
52713 _leave(" = %d", ret);
52714 @@ -677,7 +677,7 @@ nobufs_unlock:
52715 spin_unlock(&cookie->lock);
52716 kfree(op);
52717 nobufs:
52718 - fscache_stat(&fscache_n_allocs_nobufs);
52719 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52720 _leave(" = -ENOBUFS");
52721 return -ENOBUFS;
52722 }
52723 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52724
52725 spin_lock(&cookie->stores_lock);
52726
52727 - fscache_stat(&fscache_n_store_calls);
52728 + fscache_stat_unchecked(&fscache_n_store_calls);
52729
52730 /* find a page to store */
52731 page = NULL;
52732 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52733 page = results[0];
52734 _debug("gang %d [%lx]", n, page->index);
52735 if (page->index > op->store_limit) {
52736 - fscache_stat(&fscache_n_store_pages_over_limit);
52737 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52738 goto superseded;
52739 }
52740
52741 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52742 spin_unlock(&cookie->stores_lock);
52743 spin_unlock(&object->lock);
52744
52745 - fscache_stat(&fscache_n_store_pages);
52746 + fscache_stat_unchecked(&fscache_n_store_pages);
52747 fscache_stat(&fscache_n_cop_write_page);
52748 ret = object->cache->ops->write_page(op, page);
52749 fscache_stat_d(&fscache_n_cop_write_page);
52750 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52751 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52752 ASSERT(PageFsCache(page));
52753
52754 - fscache_stat(&fscache_n_stores);
52755 + fscache_stat_unchecked(&fscache_n_stores);
52756
52757 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52758 _leave(" = -ENOBUFS [invalidating]");
52759 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52760 spin_unlock(&cookie->stores_lock);
52761 spin_unlock(&object->lock);
52762
52763 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52764 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52765 op->store_limit = object->store_limit;
52766
52767 if (fscache_submit_op(object, &op->op) < 0)
52768 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52769
52770 spin_unlock(&cookie->lock);
52771 radix_tree_preload_end();
52772 - fscache_stat(&fscache_n_store_ops);
52773 - fscache_stat(&fscache_n_stores_ok);
52774 + fscache_stat_unchecked(&fscache_n_store_ops);
52775 + fscache_stat_unchecked(&fscache_n_stores_ok);
52776
52777 /* the work queue now carries its own ref on the object */
52778 fscache_put_operation(&op->op);
52779 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52780 return 0;
52781
52782 already_queued:
52783 - fscache_stat(&fscache_n_stores_again);
52784 + fscache_stat_unchecked(&fscache_n_stores_again);
52785 already_pending:
52786 spin_unlock(&cookie->stores_lock);
52787 spin_unlock(&object->lock);
52788 spin_unlock(&cookie->lock);
52789 radix_tree_preload_end();
52790 kfree(op);
52791 - fscache_stat(&fscache_n_stores_ok);
52792 + fscache_stat_unchecked(&fscache_n_stores_ok);
52793 _leave(" = 0");
52794 return 0;
52795
52796 @@ -959,14 +959,14 @@ nobufs:
52797 spin_unlock(&cookie->lock);
52798 radix_tree_preload_end();
52799 kfree(op);
52800 - fscache_stat(&fscache_n_stores_nobufs);
52801 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52802 _leave(" = -ENOBUFS");
52803 return -ENOBUFS;
52804
52805 nomem_free:
52806 kfree(op);
52807 nomem:
52808 - fscache_stat(&fscache_n_stores_oom);
52809 + fscache_stat_unchecked(&fscache_n_stores_oom);
52810 _leave(" = -ENOMEM");
52811 return -ENOMEM;
52812 }
52813 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52814 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52815 ASSERTCMP(page, !=, NULL);
52816
52817 - fscache_stat(&fscache_n_uncaches);
52818 + fscache_stat_unchecked(&fscache_n_uncaches);
52819
52820 /* cache withdrawal may beat us to it */
52821 if (!PageFsCache(page))
52822 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52823 struct fscache_cookie *cookie = op->op.object->cookie;
52824
52825 #ifdef CONFIG_FSCACHE_STATS
52826 - atomic_inc(&fscache_n_marks);
52827 + atomic_inc_unchecked(&fscache_n_marks);
52828 #endif
52829
52830 _debug("- mark %p{%lx}", page, page->index);
52831 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52832 index 40d13c7..ddf52b9 100644
52833 --- a/fs/fscache/stats.c
52834 +++ b/fs/fscache/stats.c
52835 @@ -18,99 +18,99 @@
52836 /*
52837 * operation counters
52838 */
52839 -atomic_t fscache_n_op_pend;
52840 -atomic_t fscache_n_op_run;
52841 -atomic_t fscache_n_op_enqueue;
52842 -atomic_t fscache_n_op_requeue;
52843 -atomic_t fscache_n_op_deferred_release;
52844 -atomic_t fscache_n_op_release;
52845 -atomic_t fscache_n_op_gc;
52846 -atomic_t fscache_n_op_cancelled;
52847 -atomic_t fscache_n_op_rejected;
52848 +atomic_unchecked_t fscache_n_op_pend;
52849 +atomic_unchecked_t fscache_n_op_run;
52850 +atomic_unchecked_t fscache_n_op_enqueue;
52851 +atomic_unchecked_t fscache_n_op_requeue;
52852 +atomic_unchecked_t fscache_n_op_deferred_release;
52853 +atomic_unchecked_t fscache_n_op_release;
52854 +atomic_unchecked_t fscache_n_op_gc;
52855 +atomic_unchecked_t fscache_n_op_cancelled;
52856 +atomic_unchecked_t fscache_n_op_rejected;
52857
52858 -atomic_t fscache_n_attr_changed;
52859 -atomic_t fscache_n_attr_changed_ok;
52860 -atomic_t fscache_n_attr_changed_nobufs;
52861 -atomic_t fscache_n_attr_changed_nomem;
52862 -atomic_t fscache_n_attr_changed_calls;
52863 +atomic_unchecked_t fscache_n_attr_changed;
52864 +atomic_unchecked_t fscache_n_attr_changed_ok;
52865 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52866 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52867 +atomic_unchecked_t fscache_n_attr_changed_calls;
52868
52869 -atomic_t fscache_n_allocs;
52870 -atomic_t fscache_n_allocs_ok;
52871 -atomic_t fscache_n_allocs_wait;
52872 -atomic_t fscache_n_allocs_nobufs;
52873 -atomic_t fscache_n_allocs_intr;
52874 -atomic_t fscache_n_allocs_object_dead;
52875 -atomic_t fscache_n_alloc_ops;
52876 -atomic_t fscache_n_alloc_op_waits;
52877 +atomic_unchecked_t fscache_n_allocs;
52878 +atomic_unchecked_t fscache_n_allocs_ok;
52879 +atomic_unchecked_t fscache_n_allocs_wait;
52880 +atomic_unchecked_t fscache_n_allocs_nobufs;
52881 +atomic_unchecked_t fscache_n_allocs_intr;
52882 +atomic_unchecked_t fscache_n_allocs_object_dead;
52883 +atomic_unchecked_t fscache_n_alloc_ops;
52884 +atomic_unchecked_t fscache_n_alloc_op_waits;
52885
52886 -atomic_t fscache_n_retrievals;
52887 -atomic_t fscache_n_retrievals_ok;
52888 -atomic_t fscache_n_retrievals_wait;
52889 -atomic_t fscache_n_retrievals_nodata;
52890 -atomic_t fscache_n_retrievals_nobufs;
52891 -atomic_t fscache_n_retrievals_intr;
52892 -atomic_t fscache_n_retrievals_nomem;
52893 -atomic_t fscache_n_retrievals_object_dead;
52894 -atomic_t fscache_n_retrieval_ops;
52895 -atomic_t fscache_n_retrieval_op_waits;
52896 +atomic_unchecked_t fscache_n_retrievals;
52897 +atomic_unchecked_t fscache_n_retrievals_ok;
52898 +atomic_unchecked_t fscache_n_retrievals_wait;
52899 +atomic_unchecked_t fscache_n_retrievals_nodata;
52900 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52901 +atomic_unchecked_t fscache_n_retrievals_intr;
52902 +atomic_unchecked_t fscache_n_retrievals_nomem;
52903 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52904 +atomic_unchecked_t fscache_n_retrieval_ops;
52905 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52906
52907 -atomic_t fscache_n_stores;
52908 -atomic_t fscache_n_stores_ok;
52909 -atomic_t fscache_n_stores_again;
52910 -atomic_t fscache_n_stores_nobufs;
52911 -atomic_t fscache_n_stores_oom;
52912 -atomic_t fscache_n_store_ops;
52913 -atomic_t fscache_n_store_calls;
52914 -atomic_t fscache_n_store_pages;
52915 -atomic_t fscache_n_store_radix_deletes;
52916 -atomic_t fscache_n_store_pages_over_limit;
52917 +atomic_unchecked_t fscache_n_stores;
52918 +atomic_unchecked_t fscache_n_stores_ok;
52919 +atomic_unchecked_t fscache_n_stores_again;
52920 +atomic_unchecked_t fscache_n_stores_nobufs;
52921 +atomic_unchecked_t fscache_n_stores_oom;
52922 +atomic_unchecked_t fscache_n_store_ops;
52923 +atomic_unchecked_t fscache_n_store_calls;
52924 +atomic_unchecked_t fscache_n_store_pages;
52925 +atomic_unchecked_t fscache_n_store_radix_deletes;
52926 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52927
52928 -atomic_t fscache_n_store_vmscan_not_storing;
52929 -atomic_t fscache_n_store_vmscan_gone;
52930 -atomic_t fscache_n_store_vmscan_busy;
52931 -atomic_t fscache_n_store_vmscan_cancelled;
52932 -atomic_t fscache_n_store_vmscan_wait;
52933 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52934 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52935 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52936 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52937 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52938
52939 -atomic_t fscache_n_marks;
52940 -atomic_t fscache_n_uncaches;
52941 +atomic_unchecked_t fscache_n_marks;
52942 +atomic_unchecked_t fscache_n_uncaches;
52943
52944 -atomic_t fscache_n_acquires;
52945 -atomic_t fscache_n_acquires_null;
52946 -atomic_t fscache_n_acquires_no_cache;
52947 -atomic_t fscache_n_acquires_ok;
52948 -atomic_t fscache_n_acquires_nobufs;
52949 -atomic_t fscache_n_acquires_oom;
52950 +atomic_unchecked_t fscache_n_acquires;
52951 +atomic_unchecked_t fscache_n_acquires_null;
52952 +atomic_unchecked_t fscache_n_acquires_no_cache;
52953 +atomic_unchecked_t fscache_n_acquires_ok;
52954 +atomic_unchecked_t fscache_n_acquires_nobufs;
52955 +atomic_unchecked_t fscache_n_acquires_oom;
52956
52957 -atomic_t fscache_n_invalidates;
52958 -atomic_t fscache_n_invalidates_run;
52959 +atomic_unchecked_t fscache_n_invalidates;
52960 +atomic_unchecked_t fscache_n_invalidates_run;
52961
52962 -atomic_t fscache_n_updates;
52963 -atomic_t fscache_n_updates_null;
52964 -atomic_t fscache_n_updates_run;
52965 +atomic_unchecked_t fscache_n_updates;
52966 +atomic_unchecked_t fscache_n_updates_null;
52967 +atomic_unchecked_t fscache_n_updates_run;
52968
52969 -atomic_t fscache_n_relinquishes;
52970 -atomic_t fscache_n_relinquishes_null;
52971 -atomic_t fscache_n_relinquishes_waitcrt;
52972 -atomic_t fscache_n_relinquishes_retire;
52973 +atomic_unchecked_t fscache_n_relinquishes;
52974 +atomic_unchecked_t fscache_n_relinquishes_null;
52975 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52976 +atomic_unchecked_t fscache_n_relinquishes_retire;
52977
52978 -atomic_t fscache_n_cookie_index;
52979 -atomic_t fscache_n_cookie_data;
52980 -atomic_t fscache_n_cookie_special;
52981 +atomic_unchecked_t fscache_n_cookie_index;
52982 +atomic_unchecked_t fscache_n_cookie_data;
52983 +atomic_unchecked_t fscache_n_cookie_special;
52984
52985 -atomic_t fscache_n_object_alloc;
52986 -atomic_t fscache_n_object_no_alloc;
52987 -atomic_t fscache_n_object_lookups;
52988 -atomic_t fscache_n_object_lookups_negative;
52989 -atomic_t fscache_n_object_lookups_positive;
52990 -atomic_t fscache_n_object_lookups_timed_out;
52991 -atomic_t fscache_n_object_created;
52992 -atomic_t fscache_n_object_avail;
52993 -atomic_t fscache_n_object_dead;
52994 +atomic_unchecked_t fscache_n_object_alloc;
52995 +atomic_unchecked_t fscache_n_object_no_alloc;
52996 +atomic_unchecked_t fscache_n_object_lookups;
52997 +atomic_unchecked_t fscache_n_object_lookups_negative;
52998 +atomic_unchecked_t fscache_n_object_lookups_positive;
52999 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53000 +atomic_unchecked_t fscache_n_object_created;
53001 +atomic_unchecked_t fscache_n_object_avail;
53002 +atomic_unchecked_t fscache_n_object_dead;
53003
53004 -atomic_t fscache_n_checkaux_none;
53005 -atomic_t fscache_n_checkaux_okay;
53006 -atomic_t fscache_n_checkaux_update;
53007 -atomic_t fscache_n_checkaux_obsolete;
53008 +atomic_unchecked_t fscache_n_checkaux_none;
53009 +atomic_unchecked_t fscache_n_checkaux_okay;
53010 +atomic_unchecked_t fscache_n_checkaux_update;
53011 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53012
53013 atomic_t fscache_n_cop_alloc_object;
53014 atomic_t fscache_n_cop_lookup_object;
53015 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53016 seq_puts(m, "FS-Cache statistics\n");
53017
53018 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53019 - atomic_read(&fscache_n_cookie_index),
53020 - atomic_read(&fscache_n_cookie_data),
53021 - atomic_read(&fscache_n_cookie_special));
53022 + atomic_read_unchecked(&fscache_n_cookie_index),
53023 + atomic_read_unchecked(&fscache_n_cookie_data),
53024 + atomic_read_unchecked(&fscache_n_cookie_special));
53025
53026 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53027 - atomic_read(&fscache_n_object_alloc),
53028 - atomic_read(&fscache_n_object_no_alloc),
53029 - atomic_read(&fscache_n_object_avail),
53030 - atomic_read(&fscache_n_object_dead));
53031 + atomic_read_unchecked(&fscache_n_object_alloc),
53032 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53033 + atomic_read_unchecked(&fscache_n_object_avail),
53034 + atomic_read_unchecked(&fscache_n_object_dead));
53035 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53036 - atomic_read(&fscache_n_checkaux_none),
53037 - atomic_read(&fscache_n_checkaux_okay),
53038 - atomic_read(&fscache_n_checkaux_update),
53039 - atomic_read(&fscache_n_checkaux_obsolete));
53040 + atomic_read_unchecked(&fscache_n_checkaux_none),
53041 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53042 + atomic_read_unchecked(&fscache_n_checkaux_update),
53043 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53044
53045 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53046 - atomic_read(&fscache_n_marks),
53047 - atomic_read(&fscache_n_uncaches));
53048 + atomic_read_unchecked(&fscache_n_marks),
53049 + atomic_read_unchecked(&fscache_n_uncaches));
53050
53051 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53052 " oom=%u\n",
53053 - atomic_read(&fscache_n_acquires),
53054 - atomic_read(&fscache_n_acquires_null),
53055 - atomic_read(&fscache_n_acquires_no_cache),
53056 - atomic_read(&fscache_n_acquires_ok),
53057 - atomic_read(&fscache_n_acquires_nobufs),
53058 - atomic_read(&fscache_n_acquires_oom));
53059 + atomic_read_unchecked(&fscache_n_acquires),
53060 + atomic_read_unchecked(&fscache_n_acquires_null),
53061 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53062 + atomic_read_unchecked(&fscache_n_acquires_ok),
53063 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53064 + atomic_read_unchecked(&fscache_n_acquires_oom));
53065
53066 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53067 - atomic_read(&fscache_n_object_lookups),
53068 - atomic_read(&fscache_n_object_lookups_negative),
53069 - atomic_read(&fscache_n_object_lookups_positive),
53070 - atomic_read(&fscache_n_object_created),
53071 - atomic_read(&fscache_n_object_lookups_timed_out));
53072 + atomic_read_unchecked(&fscache_n_object_lookups),
53073 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53074 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53075 + atomic_read_unchecked(&fscache_n_object_created),
53076 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53077
53078 seq_printf(m, "Invals : n=%u run=%u\n",
53079 - atomic_read(&fscache_n_invalidates),
53080 - atomic_read(&fscache_n_invalidates_run));
53081 + atomic_read_unchecked(&fscache_n_invalidates),
53082 + atomic_read_unchecked(&fscache_n_invalidates_run));
53083
53084 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53085 - atomic_read(&fscache_n_updates),
53086 - atomic_read(&fscache_n_updates_null),
53087 - atomic_read(&fscache_n_updates_run));
53088 + atomic_read_unchecked(&fscache_n_updates),
53089 + atomic_read_unchecked(&fscache_n_updates_null),
53090 + atomic_read_unchecked(&fscache_n_updates_run));
53091
53092 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53093 - atomic_read(&fscache_n_relinquishes),
53094 - atomic_read(&fscache_n_relinquishes_null),
53095 - atomic_read(&fscache_n_relinquishes_waitcrt),
53096 - atomic_read(&fscache_n_relinquishes_retire));
53097 + atomic_read_unchecked(&fscache_n_relinquishes),
53098 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53099 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53100 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53101
53102 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53103 - atomic_read(&fscache_n_attr_changed),
53104 - atomic_read(&fscache_n_attr_changed_ok),
53105 - atomic_read(&fscache_n_attr_changed_nobufs),
53106 - atomic_read(&fscache_n_attr_changed_nomem),
53107 - atomic_read(&fscache_n_attr_changed_calls));
53108 + atomic_read_unchecked(&fscache_n_attr_changed),
53109 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53110 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53111 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53112 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53113
53114 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53115 - atomic_read(&fscache_n_allocs),
53116 - atomic_read(&fscache_n_allocs_ok),
53117 - atomic_read(&fscache_n_allocs_wait),
53118 - atomic_read(&fscache_n_allocs_nobufs),
53119 - atomic_read(&fscache_n_allocs_intr));
53120 + atomic_read_unchecked(&fscache_n_allocs),
53121 + atomic_read_unchecked(&fscache_n_allocs_ok),
53122 + atomic_read_unchecked(&fscache_n_allocs_wait),
53123 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53124 + atomic_read_unchecked(&fscache_n_allocs_intr));
53125 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53126 - atomic_read(&fscache_n_alloc_ops),
53127 - atomic_read(&fscache_n_alloc_op_waits),
53128 - atomic_read(&fscache_n_allocs_object_dead));
53129 + atomic_read_unchecked(&fscache_n_alloc_ops),
53130 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53131 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53132
53133 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53134 " int=%u oom=%u\n",
53135 - atomic_read(&fscache_n_retrievals),
53136 - atomic_read(&fscache_n_retrievals_ok),
53137 - atomic_read(&fscache_n_retrievals_wait),
53138 - atomic_read(&fscache_n_retrievals_nodata),
53139 - atomic_read(&fscache_n_retrievals_nobufs),
53140 - atomic_read(&fscache_n_retrievals_intr),
53141 - atomic_read(&fscache_n_retrievals_nomem));
53142 + atomic_read_unchecked(&fscache_n_retrievals),
53143 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53144 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53145 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53146 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53147 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53148 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53149 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53150 - atomic_read(&fscache_n_retrieval_ops),
53151 - atomic_read(&fscache_n_retrieval_op_waits),
53152 - atomic_read(&fscache_n_retrievals_object_dead));
53153 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53154 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53155 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53156
53157 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53158 - atomic_read(&fscache_n_stores),
53159 - atomic_read(&fscache_n_stores_ok),
53160 - atomic_read(&fscache_n_stores_again),
53161 - atomic_read(&fscache_n_stores_nobufs),
53162 - atomic_read(&fscache_n_stores_oom));
53163 + atomic_read_unchecked(&fscache_n_stores),
53164 + atomic_read_unchecked(&fscache_n_stores_ok),
53165 + atomic_read_unchecked(&fscache_n_stores_again),
53166 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53167 + atomic_read_unchecked(&fscache_n_stores_oom));
53168 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53169 - atomic_read(&fscache_n_store_ops),
53170 - atomic_read(&fscache_n_store_calls),
53171 - atomic_read(&fscache_n_store_pages),
53172 - atomic_read(&fscache_n_store_radix_deletes),
53173 - atomic_read(&fscache_n_store_pages_over_limit));
53174 + atomic_read_unchecked(&fscache_n_store_ops),
53175 + atomic_read_unchecked(&fscache_n_store_calls),
53176 + atomic_read_unchecked(&fscache_n_store_pages),
53177 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53178 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53179
53180 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53181 - atomic_read(&fscache_n_store_vmscan_not_storing),
53182 - atomic_read(&fscache_n_store_vmscan_gone),
53183 - atomic_read(&fscache_n_store_vmscan_busy),
53184 - atomic_read(&fscache_n_store_vmscan_cancelled),
53185 - atomic_read(&fscache_n_store_vmscan_wait));
53186 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53187 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53188 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53189 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53190 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53191
53192 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53193 - atomic_read(&fscache_n_op_pend),
53194 - atomic_read(&fscache_n_op_run),
53195 - atomic_read(&fscache_n_op_enqueue),
53196 - atomic_read(&fscache_n_op_cancelled),
53197 - atomic_read(&fscache_n_op_rejected));
53198 + atomic_read_unchecked(&fscache_n_op_pend),
53199 + atomic_read_unchecked(&fscache_n_op_run),
53200 + atomic_read_unchecked(&fscache_n_op_enqueue),
53201 + atomic_read_unchecked(&fscache_n_op_cancelled),
53202 + atomic_read_unchecked(&fscache_n_op_rejected));
53203 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53204 - atomic_read(&fscache_n_op_deferred_release),
53205 - atomic_read(&fscache_n_op_release),
53206 - atomic_read(&fscache_n_op_gc));
53207 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53208 + atomic_read_unchecked(&fscache_n_op_release),
53209 + atomic_read_unchecked(&fscache_n_op_gc));
53210
53211 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53212 atomic_read(&fscache_n_cop_alloc_object),
53213 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53214 index 6f96a8d..6019bb9 100644
53215 --- a/fs/fuse/cuse.c
53216 +++ b/fs/fuse/cuse.c
53217 @@ -597,10 +597,12 @@ static int __init cuse_init(void)
53218 INIT_LIST_HEAD(&cuse_conntbl[i]);
53219
53220 /* inherit and extend fuse_dev_operations */
53221 - cuse_channel_fops = fuse_dev_operations;
53222 - cuse_channel_fops.owner = THIS_MODULE;
53223 - cuse_channel_fops.open = cuse_channel_open;
53224 - cuse_channel_fops.release = cuse_channel_release;
53225 + pax_open_kernel();
53226 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53227 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53228 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53229 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53230 + pax_close_kernel();
53231
53232 cuse_class = class_create(THIS_MODULE, "cuse");
53233 if (IS_ERR(cuse_class))
53234 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53235 index 11dfa0c..6f64416 100644
53236 --- a/fs/fuse/dev.c
53237 +++ b/fs/fuse/dev.c
53238 @@ -1294,7 +1294,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53239 ret = 0;
53240 pipe_lock(pipe);
53241
53242 - if (!pipe->readers) {
53243 + if (!atomic_read(&pipe->readers)) {
53244 send_sig(SIGPIPE, current, 0);
53245 if (!ret)
53246 ret = -EPIPE;
53247 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53248 index 185c479..51b9986 100644
53249 --- a/fs/fuse/dir.c
53250 +++ b/fs/fuse/dir.c
53251 @@ -1415,7 +1415,7 @@ static char *read_link(struct dentry *dentry)
53252 return link;
53253 }
53254
53255 -static void free_link(char *link)
53256 +static void free_link(const char *link)
53257 {
53258 if (!IS_ERR(link))
53259 free_page((unsigned long) link);
53260 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53261 index cc00bd1..3edb692 100644
53262 --- a/fs/gfs2/inode.c
53263 +++ b/fs/gfs2/inode.c
53264 @@ -1500,7 +1500,7 @@ out:
53265
53266 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53267 {
53268 - char *s = nd_get_link(nd);
53269 + const char *s = nd_get_link(nd);
53270 if (!IS_ERR(s))
53271 kfree(s);
53272 }
53273 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53274 index a3f868a..bb308ae 100644
53275 --- a/fs/hugetlbfs/inode.c
53276 +++ b/fs/hugetlbfs/inode.c
53277 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53278 struct mm_struct *mm = current->mm;
53279 struct vm_area_struct *vma;
53280 struct hstate *h = hstate_file(file);
53281 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53282 struct vm_unmapped_area_info info;
53283
53284 if (len & ~huge_page_mask(h))
53285 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53286 return addr;
53287 }
53288
53289 +#ifdef CONFIG_PAX_RANDMMAP
53290 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53291 +#endif
53292 +
53293 if (addr) {
53294 addr = ALIGN(addr, huge_page_size(h));
53295 vma = find_vma(mm, addr);
53296 - if (TASK_SIZE - len >= addr &&
53297 - (!vma || addr + len <= vma->vm_start))
53298 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53299 return addr;
53300 }
53301
53302 info.flags = 0;
53303 info.length = len;
53304 info.low_limit = TASK_UNMAPPED_BASE;
53305 +
53306 +#ifdef CONFIG_PAX_RANDMMAP
53307 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53308 + info.low_limit += mm->delta_mmap;
53309 +#endif
53310 +
53311 info.high_limit = TASK_SIZE;
53312 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53313 info.align_offset = 0;
53314 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53315 };
53316 MODULE_ALIAS_FS("hugetlbfs");
53317
53318 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53319 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53320
53321 static int can_do_hugetlb_shm(void)
53322 {
53323 diff --git a/fs/inode.c b/fs/inode.c
53324 index a898b3d..9b5a214 100644
53325 --- a/fs/inode.c
53326 +++ b/fs/inode.c
53327 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
53328
53329 #ifdef CONFIG_SMP
53330 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53331 - static atomic_t shared_last_ino;
53332 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53333 + static atomic_unchecked_t shared_last_ino;
53334 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53335
53336 res = next - LAST_INO_BATCH;
53337 }
53338 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53339 index 4a6cf28..d3a29d3 100644
53340 --- a/fs/jffs2/erase.c
53341 +++ b/fs/jffs2/erase.c
53342 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53343 struct jffs2_unknown_node marker = {
53344 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53345 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53346 - .totlen = cpu_to_je32(c->cleanmarker_size)
53347 + .totlen = cpu_to_je32(c->cleanmarker_size),
53348 + .hdr_crc = cpu_to_je32(0)
53349 };
53350
53351 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53352 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53353 index a6597d6..41b30ec 100644
53354 --- a/fs/jffs2/wbuf.c
53355 +++ b/fs/jffs2/wbuf.c
53356 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53357 {
53358 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53359 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53360 - .totlen = constant_cpu_to_je32(8)
53361 + .totlen = constant_cpu_to_je32(8),
53362 + .hdr_crc = constant_cpu_to_je32(0)
53363 };
53364
53365 /*
53366 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53367 index 2003e83..40db287 100644
53368 --- a/fs/jfs/super.c
53369 +++ b/fs/jfs/super.c
53370 @@ -856,7 +856,7 @@ static int __init init_jfs_fs(void)
53371
53372 jfs_inode_cachep =
53373 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53374 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53375 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53376 init_once);
53377 if (jfs_inode_cachep == NULL)
53378 return -ENOMEM;
53379 diff --git a/fs/libfs.c b/fs/libfs.c
53380 index 916da8c..1588998 100644
53381 --- a/fs/libfs.c
53382 +++ b/fs/libfs.c
53383 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53384
53385 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53386 struct dentry *next;
53387 + char d_name[sizeof(next->d_iname)];
53388 + const unsigned char *name;
53389 +
53390 next = list_entry(p, struct dentry, d_u.d_child);
53391 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53392 if (!simple_positive(next)) {
53393 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53394
53395 spin_unlock(&next->d_lock);
53396 spin_unlock(&dentry->d_lock);
53397 - if (filldir(dirent, next->d_name.name,
53398 + name = next->d_name.name;
53399 + if (name == next->d_iname) {
53400 + memcpy(d_name, name, next->d_name.len);
53401 + name = d_name;
53402 + }
53403 + if (filldir(dirent, name,
53404 next->d_name.len, filp->f_pos,
53405 next->d_inode->i_ino,
53406 dt_type(next->d_inode)) < 0)
53407 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53408 index 9760ecb..9b838ef 100644
53409 --- a/fs/lockd/clntproc.c
53410 +++ b/fs/lockd/clntproc.c
53411 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53412 /*
53413 * Cookie counter for NLM requests
53414 */
53415 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53416 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53417
53418 void nlmclnt_next_cookie(struct nlm_cookie *c)
53419 {
53420 - u32 cookie = atomic_inc_return(&nlm_cookie);
53421 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53422
53423 memcpy(c->data, &cookie, 4);
53424 c->len=4;
53425 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
53426 index a2aa97d..10d6c41 100644
53427 --- a/fs/lockd/svc.c
53428 +++ b/fs/lockd/svc.c
53429 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
53430 svc_sock_update_bufs(serv);
53431 serv->sv_maxconn = nlm_max_connections;
53432
53433 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
53434 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
53435 if (IS_ERR(nlmsvc_task)) {
53436 error = PTR_ERR(nlmsvc_task);
53437 printk(KERN_WARNING
53438 diff --git a/fs/locks.c b/fs/locks.c
53439 index cb424a4..850e4dd 100644
53440 --- a/fs/locks.c
53441 +++ b/fs/locks.c
53442 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53443 return;
53444
53445 if (filp->f_op && filp->f_op->flock) {
53446 - struct file_lock fl = {
53447 + struct file_lock flock = {
53448 .fl_pid = current->tgid,
53449 .fl_file = filp,
53450 .fl_flags = FL_FLOCK,
53451 .fl_type = F_UNLCK,
53452 .fl_end = OFFSET_MAX,
53453 };
53454 - filp->f_op->flock(filp, F_SETLKW, &fl);
53455 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53456 - fl.fl_ops->fl_release_private(&fl);
53457 + filp->f_op->flock(filp, F_SETLKW, &flock);
53458 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53459 + flock.fl_ops->fl_release_private(&flock);
53460 }
53461
53462 lock_flocks();
53463 diff --git a/fs/namei.c b/fs/namei.c
53464 index 85e40d1..b66744e 100644
53465 --- a/fs/namei.c
53466 +++ b/fs/namei.c
53467 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53468 if (ret != -EACCES)
53469 return ret;
53470
53471 +#ifdef CONFIG_GRKERNSEC
53472 + /* we'll block if we have to log due to a denied capability use */
53473 + if (mask & MAY_NOT_BLOCK)
53474 + return -ECHILD;
53475 +#endif
53476 +
53477 if (S_ISDIR(inode->i_mode)) {
53478 /* DACs are overridable for directories */
53479 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53480 - return 0;
53481 if (!(mask & MAY_WRITE))
53482 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53483 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53484 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53485 return 0;
53486 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53487 + return 0;
53488 return -EACCES;
53489 }
53490 /*
53491 + * Searching includes executable on directories, else just read.
53492 + */
53493 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53494 + if (mask == MAY_READ)
53495 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53496 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53497 + return 0;
53498 +
53499 + /*
53500 * Read/write DACs are always overridable.
53501 * Executable DACs are overridable when there is
53502 * at least one exec bit set.
53503 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53504 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53505 return 0;
53506
53507 - /*
53508 - * Searching includes executable on directories, else just read.
53509 - */
53510 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53511 - if (mask == MAY_READ)
53512 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53513 - return 0;
53514 -
53515 return -EACCES;
53516 }
53517
53518 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53519 {
53520 struct dentry *dentry = link->dentry;
53521 int error;
53522 - char *s;
53523 + const char *s;
53524
53525 BUG_ON(nd->flags & LOOKUP_RCU);
53526
53527 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53528 if (error)
53529 goto out_put_nd_path;
53530
53531 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53532 + dentry->d_inode, dentry, nd->path.mnt)) {
53533 + error = -EACCES;
53534 + goto out_put_nd_path;
53535 + }
53536 +
53537 nd->last_type = LAST_BIND;
53538 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53539 error = PTR_ERR(*p);
53540 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53541 if (res)
53542 break;
53543 res = walk_component(nd, path, LOOKUP_FOLLOW);
53544 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53545 + res = -EACCES;
53546 put_link(nd, &link, cookie);
53547 } while (res > 0);
53548
53549 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53550 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53551 {
53552 unsigned long a, b, adata, bdata, mask, hash, len;
53553 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53554 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53555
53556 hash = a = 0;
53557 len = -sizeof(unsigned long);
53558 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53559 if (err)
53560 break;
53561 err = lookup_last(nd, &path);
53562 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53563 + err = -EACCES;
53564 put_link(nd, &link, cookie);
53565 }
53566 }
53567 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53568 if (!err)
53569 err = complete_walk(nd);
53570
53571 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53572 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53573 + path_put(&nd->path);
53574 + err = -ENOENT;
53575 + }
53576 + }
53577 +
53578 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53579 if (!nd->inode->i_op->lookup) {
53580 path_put(&nd->path);
53581 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53582 retval = path_lookupat(dfd, name->name,
53583 flags | LOOKUP_REVAL, nd);
53584
53585 - if (likely(!retval))
53586 + if (likely(!retval)) {
53587 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53588 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53589 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53590 + path_put(&nd->path);
53591 + return -ENOENT;
53592 + }
53593 + }
53594 + }
53595 return retval;
53596 }
53597
53598 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53599 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53600 return -EPERM;
53601
53602 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53603 + return -EPERM;
53604 + if (gr_handle_rawio(inode))
53605 + return -EPERM;
53606 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53607 + return -EACCES;
53608 +
53609 return 0;
53610 }
53611
53612 @@ -2602,7 +2641,7 @@ looked_up:
53613 * cleared otherwise prior to returning.
53614 */
53615 static int lookup_open(struct nameidata *nd, struct path *path,
53616 - struct file *file,
53617 + struct path *link, struct file *file,
53618 const struct open_flags *op,
53619 bool got_write, int *opened)
53620 {
53621 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53622 /* Negative dentry, just create the file */
53623 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53624 umode_t mode = op->mode;
53625 +
53626 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53627 + error = -EACCES;
53628 + goto out_dput;
53629 + }
53630 +
53631 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53632 + error = -EACCES;
53633 + goto out_dput;
53634 + }
53635 +
53636 if (!IS_POSIXACL(dir->d_inode))
53637 mode &= ~current_umask();
53638 /*
53639 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53640 nd->flags & LOOKUP_EXCL);
53641 if (error)
53642 goto out_dput;
53643 + else
53644 + gr_handle_create(dentry, nd->path.mnt);
53645 }
53646 out_no_open:
53647 path->dentry = dentry;
53648 @@ -2672,7 +2724,7 @@ out_dput:
53649 /*
53650 * Handle the last step of open()
53651 */
53652 -static int do_last(struct nameidata *nd, struct path *path,
53653 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53654 struct file *file, const struct open_flags *op,
53655 int *opened, struct filename *name)
53656 {
53657 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53658 error = complete_walk(nd);
53659 if (error)
53660 return error;
53661 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53662 + error = -ENOENT;
53663 + goto out;
53664 + }
53665 audit_inode(name, nd->path.dentry, 0);
53666 if (open_flag & O_CREAT) {
53667 error = -EISDIR;
53668 goto out;
53669 }
53670 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53671 + error = -EACCES;
53672 + goto out;
53673 + }
53674 goto finish_open;
53675 case LAST_BIND:
53676 error = complete_walk(nd);
53677 if (error)
53678 return error;
53679 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53680 + error = -ENOENT;
53681 + goto out;
53682 + }
53683 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53684 + error = -EACCES;
53685 + goto out;
53686 + }
53687 audit_inode(name, dir, 0);
53688 goto finish_open;
53689 }
53690 @@ -2759,7 +2827,7 @@ retry_lookup:
53691 */
53692 }
53693 mutex_lock(&dir->d_inode->i_mutex);
53694 - error = lookup_open(nd, path, file, op, got_write, opened);
53695 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53696 mutex_unlock(&dir->d_inode->i_mutex);
53697
53698 if (error <= 0) {
53699 @@ -2783,11 +2851,28 @@ retry_lookup:
53700 goto finish_open_created;
53701 }
53702
53703 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53704 + error = -ENOENT;
53705 + goto exit_dput;
53706 + }
53707 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53708 + error = -EACCES;
53709 + goto exit_dput;
53710 + }
53711 +
53712 /*
53713 * create/update audit record if it already exists.
53714 */
53715 - if (path->dentry->d_inode)
53716 + if (path->dentry->d_inode) {
53717 + /* only check if O_CREAT is specified, all other checks need to go
53718 + into may_open */
53719 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53720 + error = -EACCES;
53721 + goto exit_dput;
53722 + }
53723 +
53724 audit_inode(name, path->dentry, 0);
53725 + }
53726
53727 /*
53728 * If atomic_open() acquired write access it is dropped now due to
53729 @@ -2828,6 +2913,11 @@ finish_lookup:
53730 }
53731 }
53732 BUG_ON(inode != path->dentry->d_inode);
53733 + /* if we're resolving a symlink to another symlink */
53734 + if (link && gr_handle_symlink_owner(link, inode)) {
53735 + error = -EACCES;
53736 + goto out;
53737 + }
53738 return 1;
53739 }
53740
53741 @@ -2837,7 +2927,6 @@ finish_lookup:
53742 save_parent.dentry = nd->path.dentry;
53743 save_parent.mnt = mntget(path->mnt);
53744 nd->path.dentry = path->dentry;
53745 -
53746 }
53747 nd->inode = inode;
53748 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53749 @@ -2846,6 +2935,16 @@ finish_lookup:
53750 path_put(&save_parent);
53751 return error;
53752 }
53753 +
53754 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53755 + error = -ENOENT;
53756 + goto out;
53757 + }
53758 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53759 + error = -EACCES;
53760 + goto out;
53761 + }
53762 +
53763 error = -EISDIR;
53764 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53765 goto out;
53766 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53767 if (unlikely(error))
53768 goto out;
53769
53770 - error = do_last(nd, &path, file, op, &opened, pathname);
53771 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53772 while (unlikely(error > 0)) { /* trailing symlink */
53773 struct path link = path;
53774 void *cookie;
53775 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53776 error = follow_link(&link, nd, &cookie);
53777 if (unlikely(error))
53778 break;
53779 - error = do_last(nd, &path, file, op, &opened, pathname);
53780 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53781 put_link(nd, &link, cookie);
53782 }
53783 out:
53784 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53785 goto unlock;
53786
53787 error = -EEXIST;
53788 - if (dentry->d_inode)
53789 + if (dentry->d_inode) {
53790 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53791 + error = -ENOENT;
53792 + }
53793 goto fail;
53794 + }
53795 /*
53796 * Special case - lookup gave negative, but... we had foo/bar/
53797 * From the vfs_mknod() POV we just have a negative dentry -
53798 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53799 }
53800 EXPORT_SYMBOL(user_path_create);
53801
53802 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53803 +{
53804 + struct filename *tmp = getname(pathname);
53805 + struct dentry *res;
53806 + if (IS_ERR(tmp))
53807 + return ERR_CAST(tmp);
53808 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53809 + if (IS_ERR(res))
53810 + putname(tmp);
53811 + else
53812 + *to = tmp;
53813 + return res;
53814 +}
53815 +
53816 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53817 {
53818 int error = may_create(dir, dentry);
53819 @@ -3177,6 +3294,17 @@ retry:
53820
53821 if (!IS_POSIXACL(path.dentry->d_inode))
53822 mode &= ~current_umask();
53823 +
53824 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53825 + error = -EPERM;
53826 + goto out;
53827 + }
53828 +
53829 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53830 + error = -EACCES;
53831 + goto out;
53832 + }
53833 +
53834 error = security_path_mknod(&path, dentry, mode, dev);
53835 if (error)
53836 goto out;
53837 @@ -3193,6 +3321,8 @@ retry:
53838 break;
53839 }
53840 out:
53841 + if (!error)
53842 + gr_handle_create(dentry, path.mnt);
53843 done_path_create(&path, dentry);
53844 if (retry_estale(error, lookup_flags)) {
53845 lookup_flags |= LOOKUP_REVAL;
53846 @@ -3245,9 +3375,16 @@ retry:
53847
53848 if (!IS_POSIXACL(path.dentry->d_inode))
53849 mode &= ~current_umask();
53850 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53851 + error = -EACCES;
53852 + goto out;
53853 + }
53854 error = security_path_mkdir(&path, dentry, mode);
53855 if (!error)
53856 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53857 + if (!error)
53858 + gr_handle_create(dentry, path.mnt);
53859 +out:
53860 done_path_create(&path, dentry);
53861 if (retry_estale(error, lookup_flags)) {
53862 lookup_flags |= LOOKUP_REVAL;
53863 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53864 struct filename *name;
53865 struct dentry *dentry;
53866 struct nameidata nd;
53867 + ino_t saved_ino = 0;
53868 + dev_t saved_dev = 0;
53869 unsigned int lookup_flags = 0;
53870 retry:
53871 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53872 @@ -3360,10 +3499,21 @@ retry:
53873 error = -ENOENT;
53874 goto exit3;
53875 }
53876 +
53877 + saved_ino = dentry->d_inode->i_ino;
53878 + saved_dev = gr_get_dev_from_dentry(dentry);
53879 +
53880 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53881 + error = -EACCES;
53882 + goto exit3;
53883 + }
53884 +
53885 error = security_path_rmdir(&nd.path, dentry);
53886 if (error)
53887 goto exit3;
53888 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53889 + if (!error && (saved_dev || saved_ino))
53890 + gr_handle_delete(saved_ino, saved_dev);
53891 exit3:
53892 dput(dentry);
53893 exit2:
53894 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53895 struct dentry *dentry;
53896 struct nameidata nd;
53897 struct inode *inode = NULL;
53898 + ino_t saved_ino = 0;
53899 + dev_t saved_dev = 0;
53900 unsigned int lookup_flags = 0;
53901 retry:
53902 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53903 @@ -3455,10 +3607,22 @@ retry:
53904 if (!inode)
53905 goto slashes;
53906 ihold(inode);
53907 +
53908 + if (inode->i_nlink <= 1) {
53909 + saved_ino = inode->i_ino;
53910 + saved_dev = gr_get_dev_from_dentry(dentry);
53911 + }
53912 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53913 + error = -EACCES;
53914 + goto exit2;
53915 + }
53916 +
53917 error = security_path_unlink(&nd.path, dentry);
53918 if (error)
53919 goto exit2;
53920 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53921 + if (!error && (saved_ino || saved_dev))
53922 + gr_handle_delete(saved_ino, saved_dev);
53923 exit2:
53924 dput(dentry);
53925 }
53926 @@ -3536,9 +3700,17 @@ retry:
53927 if (IS_ERR(dentry))
53928 goto out_putname;
53929
53930 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53931 + error = -EACCES;
53932 + goto out;
53933 + }
53934 +
53935 error = security_path_symlink(&path, dentry, from->name);
53936 if (!error)
53937 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53938 + if (!error)
53939 + gr_handle_create(dentry, path.mnt);
53940 +out:
53941 done_path_create(&path, dentry);
53942 if (retry_estale(error, lookup_flags)) {
53943 lookup_flags |= LOOKUP_REVAL;
53944 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53945 {
53946 struct dentry *new_dentry;
53947 struct path old_path, new_path;
53948 + struct filename *to = NULL;
53949 int how = 0;
53950 int error;
53951
53952 @@ -3635,7 +3808,7 @@ retry:
53953 if (error)
53954 return error;
53955
53956 - new_dentry = user_path_create(newdfd, newname, &new_path,
53957 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53958 (how & LOOKUP_REVAL));
53959 error = PTR_ERR(new_dentry);
53960 if (IS_ERR(new_dentry))
53961 @@ -3647,11 +3820,28 @@ retry:
53962 error = may_linkat(&old_path);
53963 if (unlikely(error))
53964 goto out_dput;
53965 +
53966 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53967 + old_path.dentry->d_inode,
53968 + old_path.dentry->d_inode->i_mode, to)) {
53969 + error = -EACCES;
53970 + goto out_dput;
53971 + }
53972 +
53973 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53974 + old_path.dentry, old_path.mnt, to)) {
53975 + error = -EACCES;
53976 + goto out_dput;
53977 + }
53978 +
53979 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53980 if (error)
53981 goto out_dput;
53982 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53983 + if (!error)
53984 + gr_handle_create(new_dentry, new_path.mnt);
53985 out_dput:
53986 + putname(to);
53987 done_path_create(&new_path, new_dentry);
53988 if (retry_estale(error, how)) {
53989 how |= LOOKUP_REVAL;
53990 @@ -3897,12 +4087,21 @@ retry:
53991 if (new_dentry == trap)
53992 goto exit5;
53993
53994 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53995 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53996 + to);
53997 + if (error)
53998 + goto exit5;
53999 +
54000 error = security_path_rename(&oldnd.path, old_dentry,
54001 &newnd.path, new_dentry);
54002 if (error)
54003 goto exit5;
54004 error = vfs_rename(old_dir->d_inode, old_dentry,
54005 new_dir->d_inode, new_dentry);
54006 + if (!error)
54007 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54008 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54009 exit5:
54010 dput(new_dentry);
54011 exit4:
54012 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54013
54014 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54015 {
54016 + char tmpbuf[64];
54017 + const char *newlink;
54018 int len;
54019
54020 len = PTR_ERR(link);
54021 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54022 len = strlen(link);
54023 if (len > (unsigned) buflen)
54024 len = buflen;
54025 - if (copy_to_user(buffer, link, len))
54026 +
54027 + if (len < sizeof(tmpbuf)) {
54028 + memcpy(tmpbuf, link, len);
54029 + newlink = tmpbuf;
54030 + } else
54031 + newlink = link;
54032 +
54033 + if (copy_to_user(buffer, newlink, len))
54034 len = -EFAULT;
54035 out:
54036 return len;
54037 diff --git a/fs/namespace.c b/fs/namespace.c
54038 index e945b81..fc018e2 100644
54039 --- a/fs/namespace.c
54040 +++ b/fs/namespace.c
54041 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
54042 if (!(sb->s_flags & MS_RDONLY))
54043 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54044 up_write(&sb->s_umount);
54045 +
54046 + gr_log_remount(mnt->mnt_devname, retval);
54047 +
54048 return retval;
54049 }
54050
54051 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
54052 br_write_unlock(&vfsmount_lock);
54053 up_write(&namespace_sem);
54054 release_mounts(&umount_list);
54055 +
54056 + gr_log_unmount(mnt->mnt_devname, retval);
54057 +
54058 return retval;
54059 }
54060
54061 @@ -1257,7 +1263,7 @@ static inline bool may_mount(void)
54062 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
54063 */
54064
54065 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
54066 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
54067 {
54068 struct path path;
54069 struct mount *mnt;
54070 @@ -1297,7 +1303,7 @@ out:
54071 /*
54072 * The 2.0 compatible umount. No flags.
54073 */
54074 -SYSCALL_DEFINE1(oldumount, char __user *, name)
54075 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
54076 {
54077 return sys_umount(name, 0);
54078 }
54079 @@ -2267,6 +2273,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54080 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54081 MS_STRICTATIME);
54082
54083 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54084 + retval = -EPERM;
54085 + goto dput_out;
54086 + }
54087 +
54088 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54089 + retval = -EPERM;
54090 + goto dput_out;
54091 + }
54092 +
54093 if (flags & MS_REMOUNT)
54094 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54095 data_page);
54096 @@ -2281,6 +2297,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54097 dev_name, data_page);
54098 dput_out:
54099 path_put(&path);
54100 +
54101 + gr_log_mount(dev_name, dir_name, retval);
54102 +
54103 return retval;
54104 }
54105
54106 @@ -2454,8 +2473,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
54107 }
54108 EXPORT_SYMBOL(mount_subtree);
54109
54110 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
54111 - char __user *, type, unsigned long, flags, void __user *, data)
54112 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
54113 + const char __user *, type, unsigned long, flags, void __user *, data)
54114 {
54115 int ret;
54116 char *kernel_type;
54117 @@ -2567,6 +2586,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54118 if (error)
54119 goto out2;
54120
54121 + if (gr_handle_chroot_pivot()) {
54122 + error = -EPERM;
54123 + goto out2;
54124 + }
54125 +
54126 get_fs_root(current->fs, &root);
54127 error = lock_mount(&old);
54128 if (error)
54129 @@ -2815,7 +2839,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54130 !nsown_capable(CAP_SYS_ADMIN))
54131 return -EPERM;
54132
54133 - if (fs->users != 1)
54134 + if (atomic_read(&fs->users) != 1)
54135 return -EINVAL;
54136
54137 get_mnt_ns(mnt_ns);
54138 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
54139 index 5088b57..eabd719 100644
54140 --- a/fs/nfs/callback.c
54141 +++ b/fs/nfs/callback.c
54142 @@ -208,7 +208,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54143 struct svc_rqst *rqstp;
54144 int (*callback_svc)(void *vrqstp);
54145 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
54146 - char svc_name[12];
54147 int ret;
54148
54149 nfs_callback_bc_serv(minorversion, xprt, serv);
54150 @@ -232,10 +231,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54151
54152 svc_sock_update_bufs(serv);
54153
54154 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
54155 cb_info->serv = serv;
54156 cb_info->rqst = rqstp;
54157 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
54158 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
54159 if (IS_ERR(cb_info->task)) {
54160 ret = PTR_ERR(cb_info->task);
54161 svc_exit_thread(cb_info->rqst);
54162 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54163 index 59461c9..b17c57e 100644
54164 --- a/fs/nfs/callback_xdr.c
54165 +++ b/fs/nfs/callback_xdr.c
54166 @@ -51,7 +51,7 @@ struct callback_op {
54167 callback_decode_arg_t decode_args;
54168 callback_encode_res_t encode_res;
54169 long res_maxsize;
54170 -};
54171 +} __do_const;
54172
54173 static struct callback_op callback_ops[];
54174
54175 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54176 index 1f94167..79c4ce4 100644
54177 --- a/fs/nfs/inode.c
54178 +++ b/fs/nfs/inode.c
54179 @@ -1041,16 +1041,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54180 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54181 }
54182
54183 -static atomic_long_t nfs_attr_generation_counter;
54184 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54185
54186 static unsigned long nfs_read_attr_generation_counter(void)
54187 {
54188 - return atomic_long_read(&nfs_attr_generation_counter);
54189 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54190 }
54191
54192 unsigned long nfs_inc_attr_generation_counter(void)
54193 {
54194 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54195 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54196 }
54197
54198 void nfs_fattr_init(struct nfs_fattr *fattr)
54199 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
54200 index d41a351..7899577 100644
54201 --- a/fs/nfs/nfs4state.c
54202 +++ b/fs/nfs/nfs4state.c
54203 @@ -1182,7 +1182,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
54204 snprintf(buf, sizeof(buf), "%s-manager",
54205 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
54206 rcu_read_unlock();
54207 - task = kthread_run(nfs4_run_state_manager, clp, buf);
54208 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
54209 if (IS_ERR(task)) {
54210 printk(KERN_ERR "%s: kthread_run: %ld\n",
54211 __func__, PTR_ERR(task));
54212 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54213 index d401d01..10b3e62 100644
54214 --- a/fs/nfsd/nfs4proc.c
54215 +++ b/fs/nfsd/nfs4proc.c
54216 @@ -1109,7 +1109,7 @@ struct nfsd4_operation {
54217 nfsd4op_rsize op_rsize_bop;
54218 stateid_getter op_get_currentstateid;
54219 stateid_setter op_set_currentstateid;
54220 -};
54221 +} __do_const;
54222
54223 static struct nfsd4_operation nfsd4_ops[];
54224
54225 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54226 index 6eb0dc5..29067a9 100644
54227 --- a/fs/nfsd/nfs4xdr.c
54228 +++ b/fs/nfsd/nfs4xdr.c
54229 @@ -1457,7 +1457,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54230
54231 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54232
54233 -static nfsd4_dec nfsd4_dec_ops[] = {
54234 +static const nfsd4_dec nfsd4_dec_ops[] = {
54235 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54236 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54237 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54238 @@ -1497,7 +1497,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54239 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54240 };
54241
54242 -static nfsd4_dec nfsd41_dec_ops[] = {
54243 +static const nfsd4_dec nfsd41_dec_ops[] = {
54244 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54245 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54246 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54247 @@ -1559,7 +1559,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54248 };
54249
54250 struct nfsd4_minorversion_ops {
54251 - nfsd4_dec *decoders;
54252 + const nfsd4_dec *decoders;
54253 int nops;
54254 };
54255
54256 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
54257 index ca05f6d..b88c3a7 100644
54258 --- a/fs/nfsd/nfscache.c
54259 +++ b/fs/nfsd/nfscache.c
54260 @@ -461,13 +461,16 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
54261 {
54262 struct svc_cacherep *rp = rqstp->rq_cacherep;
54263 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
54264 - int len;
54265 + long len;
54266
54267 if (!rp)
54268 return;
54269
54270 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54271 - len >>= 2;
54272 + if (statp) {
54273 + len = (char*)statp - (char*)resv->iov_base;
54274 + len = resv->iov_len - len;
54275 + len >>= 2;
54276 + }
54277
54278 /* Don't cache excessive amounts of data and XDR failures */
54279 if (!statp || len > (256 >> 2)) {
54280 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54281 index 2b2e239..c915b48 100644
54282 --- a/fs/nfsd/vfs.c
54283 +++ b/fs/nfsd/vfs.c
54284 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54285 } else {
54286 oldfs = get_fs();
54287 set_fs(KERNEL_DS);
54288 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54289 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54290 set_fs(oldfs);
54291 }
54292
54293 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54294
54295 /* Write the data. */
54296 oldfs = get_fs(); set_fs(KERNEL_DS);
54297 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54298 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54299 set_fs(oldfs);
54300 if (host_err < 0)
54301 goto out_nfserr;
54302 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54303 */
54304
54305 oldfs = get_fs(); set_fs(KERNEL_DS);
54306 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54307 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54308 set_fs(oldfs);
54309
54310 if (host_err < 0)
54311 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54312 index fea6bd5..8ee9d81 100644
54313 --- a/fs/nls/nls_base.c
54314 +++ b/fs/nls/nls_base.c
54315 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54316
54317 int register_nls(struct nls_table * nls)
54318 {
54319 - struct nls_table ** tmp = &tables;
54320 + struct nls_table *tmp = tables;
54321
54322 if (nls->next)
54323 return -EBUSY;
54324
54325 spin_lock(&nls_lock);
54326 - while (*tmp) {
54327 - if (nls == *tmp) {
54328 + while (tmp) {
54329 + if (nls == tmp) {
54330 spin_unlock(&nls_lock);
54331 return -EBUSY;
54332 }
54333 - tmp = &(*tmp)->next;
54334 + tmp = tmp->next;
54335 }
54336 - nls->next = tables;
54337 + pax_open_kernel();
54338 + *(struct nls_table **)&nls->next = tables;
54339 + pax_close_kernel();
54340 tables = nls;
54341 spin_unlock(&nls_lock);
54342 return 0;
54343 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54344
54345 int unregister_nls(struct nls_table * nls)
54346 {
54347 - struct nls_table ** tmp = &tables;
54348 + struct nls_table * const * tmp = &tables;
54349
54350 spin_lock(&nls_lock);
54351 while (*tmp) {
54352 if (nls == *tmp) {
54353 - *tmp = nls->next;
54354 + pax_open_kernel();
54355 + *(struct nls_table **)tmp = nls->next;
54356 + pax_close_kernel();
54357 spin_unlock(&nls_lock);
54358 return 0;
54359 }
54360 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54361 index 7424929..35f6be5 100644
54362 --- a/fs/nls/nls_euc-jp.c
54363 +++ b/fs/nls/nls_euc-jp.c
54364 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54365 p_nls = load_nls("cp932");
54366
54367 if (p_nls) {
54368 - table.charset2upper = p_nls->charset2upper;
54369 - table.charset2lower = p_nls->charset2lower;
54370 + pax_open_kernel();
54371 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54372 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54373 + pax_close_kernel();
54374 return register_nls(&table);
54375 }
54376
54377 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54378 index e7bc1d7..06bd4bb 100644
54379 --- a/fs/nls/nls_koi8-ru.c
54380 +++ b/fs/nls/nls_koi8-ru.c
54381 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54382 p_nls = load_nls("koi8-u");
54383
54384 if (p_nls) {
54385 - table.charset2upper = p_nls->charset2upper;
54386 - table.charset2lower = p_nls->charset2lower;
54387 + pax_open_kernel();
54388 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54389 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54390 + pax_close_kernel();
54391 return register_nls(&table);
54392 }
54393
54394 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54395 index 5d84442..2c034ba 100644
54396 --- a/fs/notify/fanotify/fanotify_user.c
54397 +++ b/fs/notify/fanotify/fanotify_user.c
54398 @@ -121,6 +121,7 @@ static int fill_event_metadata(struct fsnotify_group *group,
54399 metadata->event_len = FAN_EVENT_METADATA_LEN;
54400 metadata->metadata_len = FAN_EVENT_METADATA_LEN;
54401 metadata->vers = FANOTIFY_METADATA_VERSION;
54402 + metadata->reserved = 0;
54403 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;
54404 metadata->pid = pid_vnr(event->tgid);
54405 if (unlikely(event->mask & FAN_Q_OVERFLOW))
54406 @@ -251,8 +252,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54407
54408 fd = fanotify_event_metadata.fd;
54409 ret = -EFAULT;
54410 - if (copy_to_user(buf, &fanotify_event_metadata,
54411 - fanotify_event_metadata.event_len))
54412 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54413 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54414 goto out_close_fd;
54415
54416 ret = prepare_for_access_response(group, event, fd);
54417 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54418 index 7b51b05..5ea5ef6 100644
54419 --- a/fs/notify/notification.c
54420 +++ b/fs/notify/notification.c
54421 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54422 * get set to 0 so it will never get 'freed'
54423 */
54424 static struct fsnotify_event *q_overflow_event;
54425 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54426 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54427
54428 /**
54429 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54430 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54431 */
54432 u32 fsnotify_get_cookie(void)
54433 {
54434 - return atomic_inc_return(&fsnotify_sync_cookie);
54435 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54436 }
54437 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54438
54439 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54440 index aa411c3..c260a84 100644
54441 --- a/fs/ntfs/dir.c
54442 +++ b/fs/ntfs/dir.c
54443 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54444 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54445 ~(s64)(ndir->itype.index.block_size - 1)));
54446 /* Bounds checks. */
54447 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54448 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54449 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54450 "inode 0x%lx or driver bug.", vdir->i_ino);
54451 goto err_out;
54452 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54453 index 5b2d4f0..c6de396 100644
54454 --- a/fs/ntfs/file.c
54455 +++ b/fs/ntfs/file.c
54456 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54457 #endif /* NTFS_RW */
54458 };
54459
54460 -const struct file_operations ntfs_empty_file_ops = {};
54461 +const struct file_operations ntfs_empty_file_ops __read_only;
54462
54463 -const struct inode_operations ntfs_empty_inode_ops = {};
54464 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54465 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54466 index aebeacd..0dcdd26 100644
54467 --- a/fs/ocfs2/localalloc.c
54468 +++ b/fs/ocfs2/localalloc.c
54469 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54470 goto bail;
54471 }
54472
54473 - atomic_inc(&osb->alloc_stats.moves);
54474 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54475
54476 bail:
54477 if (handle)
54478 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54479 index d355e6e..578d905 100644
54480 --- a/fs/ocfs2/ocfs2.h
54481 +++ b/fs/ocfs2/ocfs2.h
54482 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54483
54484 struct ocfs2_alloc_stats
54485 {
54486 - atomic_t moves;
54487 - atomic_t local_data;
54488 - atomic_t bitmap_data;
54489 - atomic_t bg_allocs;
54490 - atomic_t bg_extends;
54491 + atomic_unchecked_t moves;
54492 + atomic_unchecked_t local_data;
54493 + atomic_unchecked_t bitmap_data;
54494 + atomic_unchecked_t bg_allocs;
54495 + atomic_unchecked_t bg_extends;
54496 };
54497
54498 enum ocfs2_local_alloc_state
54499 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54500 index b7e74b5..19c6536 100644
54501 --- a/fs/ocfs2/suballoc.c
54502 +++ b/fs/ocfs2/suballoc.c
54503 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54504 mlog_errno(status);
54505 goto bail;
54506 }
54507 - atomic_inc(&osb->alloc_stats.bg_extends);
54508 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54509
54510 /* You should never ask for this much metadata */
54511 BUG_ON(bits_wanted >
54512 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54513 mlog_errno(status);
54514 goto bail;
54515 }
54516 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54517 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54518
54519 *suballoc_loc = res.sr_bg_blkno;
54520 *suballoc_bit_start = res.sr_bit_offset;
54521 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54522 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54523 res->sr_bits);
54524
54525 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54526 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54527
54528 BUG_ON(res->sr_bits != 1);
54529
54530 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54531 mlog_errno(status);
54532 goto bail;
54533 }
54534 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54535 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54536
54537 BUG_ON(res.sr_bits != 1);
54538
54539 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54540 cluster_start,
54541 num_clusters);
54542 if (!status)
54543 - atomic_inc(&osb->alloc_stats.local_data);
54544 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54545 } else {
54546 if (min_clusters > (osb->bitmap_cpg - 1)) {
54547 /* The only paths asking for contiguousness
54548 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54549 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54550 res.sr_bg_blkno,
54551 res.sr_bit_offset);
54552 - atomic_inc(&osb->alloc_stats.bitmap_data);
54553 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54554 *num_clusters = res.sr_bits;
54555 }
54556 }
54557 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54558 index 01b8516..579c4df 100644
54559 --- a/fs/ocfs2/super.c
54560 +++ b/fs/ocfs2/super.c
54561 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54562 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54563 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54564 "Stats",
54565 - atomic_read(&osb->alloc_stats.bitmap_data),
54566 - atomic_read(&osb->alloc_stats.local_data),
54567 - atomic_read(&osb->alloc_stats.bg_allocs),
54568 - atomic_read(&osb->alloc_stats.moves),
54569 - atomic_read(&osb->alloc_stats.bg_extends));
54570 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54571 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54572 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54573 + atomic_read_unchecked(&osb->alloc_stats.moves),
54574 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54575
54576 out += snprintf(buf + out, len - out,
54577 "%10s => State: %u Descriptor: %llu Size: %u bits "
54578 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54579 spin_lock_init(&osb->osb_xattr_lock);
54580 ocfs2_init_steal_slots(osb);
54581
54582 - atomic_set(&osb->alloc_stats.moves, 0);
54583 - atomic_set(&osb->alloc_stats.local_data, 0);
54584 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54585 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54586 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54587 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54588 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54589 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54590 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54591 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54592
54593 /* Copy the blockcheck stats from the superblock probe */
54594 osb->osb_ecc_stats = *stats;
54595 diff --git a/fs/open.c b/fs/open.c
54596 index 6835446..eadf09f 100644
54597 --- a/fs/open.c
54598 +++ b/fs/open.c
54599 @@ -32,6 +32,8 @@
54600 #include <linux/dnotify.h>
54601 #include <linux/compat.h>
54602
54603 +#define CREATE_TRACE_POINTS
54604 +#include <trace/events/fs.h>
54605 #include "internal.h"
54606
54607 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54608 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54609 error = locks_verify_truncate(inode, NULL, length);
54610 if (!error)
54611 error = security_path_truncate(path);
54612 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54613 + error = -EACCES;
54614 if (!error)
54615 error = do_truncate(path->dentry, length, 0, NULL);
54616
54617 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54618 error = locks_verify_truncate(inode, f.file, length);
54619 if (!error)
54620 error = security_path_truncate(&f.file->f_path);
54621 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54622 + error = -EACCES;
54623 if (!error)
54624 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54625 sb_end_write(inode->i_sb);
54626 @@ -388,6 +394,9 @@ retry:
54627 if (__mnt_is_readonly(path.mnt))
54628 res = -EROFS;
54629
54630 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54631 + res = -EACCES;
54632 +
54633 out_path_release:
54634 path_put(&path);
54635 if (retry_estale(res, lookup_flags)) {
54636 @@ -419,6 +428,8 @@ retry:
54637 if (error)
54638 goto dput_and_out;
54639
54640 + gr_log_chdir(path.dentry, path.mnt);
54641 +
54642 set_fs_pwd(current->fs, &path);
54643
54644 dput_and_out:
54645 @@ -448,6 +459,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54646 goto out_putf;
54647
54648 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54649 +
54650 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54651 + error = -EPERM;
54652 +
54653 + if (!error)
54654 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54655 +
54656 if (!error)
54657 set_fs_pwd(current->fs, &f.file->f_path);
54658 out_putf:
54659 @@ -477,7 +495,13 @@ retry:
54660 if (error)
54661 goto dput_and_out;
54662
54663 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54664 + goto dput_and_out;
54665 +
54666 set_fs_root(current->fs, &path);
54667 +
54668 + gr_handle_chroot_chdir(&path);
54669 +
54670 error = 0;
54671 dput_and_out:
54672 path_put(&path);
54673 @@ -499,6 +523,16 @@ static int chmod_common(struct path *path, umode_t mode)
54674 if (error)
54675 return error;
54676 mutex_lock(&inode->i_mutex);
54677 +
54678 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54679 + error = -EACCES;
54680 + goto out_unlock;
54681 + }
54682 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54683 + error = -EACCES;
54684 + goto out_unlock;
54685 + }
54686 +
54687 error = security_path_chmod(path, mode);
54688 if (error)
54689 goto out_unlock;
54690 @@ -559,6 +593,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54691 uid = make_kuid(current_user_ns(), user);
54692 gid = make_kgid(current_user_ns(), group);
54693
54694 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54695 + return -EACCES;
54696 +
54697 newattrs.ia_valid = ATTR_CTIME;
54698 if (user != (uid_t) -1) {
54699 if (!uid_valid(uid))
54700 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54701 } else {
54702 fsnotify_open(f);
54703 fd_install(fd, f);
54704 + trace_do_sys_open(tmp->name, flags, mode);
54705 }
54706 }
54707 putname(tmp);
54708 diff --git a/fs/pipe.c b/fs/pipe.c
54709 index 2234f3f..f9083a1 100644
54710 --- a/fs/pipe.c
54711 +++ b/fs/pipe.c
54712 @@ -438,9 +438,9 @@ redo:
54713 }
54714 if (bufs) /* More to do? */
54715 continue;
54716 - if (!pipe->writers)
54717 + if (!atomic_read(&pipe->writers))
54718 break;
54719 - if (!pipe->waiting_writers) {
54720 + if (!atomic_read(&pipe->waiting_writers)) {
54721 /* syscall merging: Usually we must not sleep
54722 * if O_NONBLOCK is set, or if we got some data.
54723 * But if a writer sleeps in kernel space, then
54724 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54725 mutex_lock(&inode->i_mutex);
54726 pipe = inode->i_pipe;
54727
54728 - if (!pipe->readers) {
54729 + if (!atomic_read(&pipe->readers)) {
54730 send_sig(SIGPIPE, current, 0);
54731 ret = -EPIPE;
54732 goto out;
54733 @@ -553,7 +553,7 @@ redo1:
54734 for (;;) {
54735 int bufs;
54736
54737 - if (!pipe->readers) {
54738 + if (!atomic_read(&pipe->readers)) {
54739 send_sig(SIGPIPE, current, 0);
54740 if (!ret)
54741 ret = -EPIPE;
54742 @@ -644,9 +644,9 @@ redo2:
54743 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54744 do_wakeup = 0;
54745 }
54746 - pipe->waiting_writers++;
54747 + atomic_inc(&pipe->waiting_writers);
54748 pipe_wait(pipe);
54749 - pipe->waiting_writers--;
54750 + atomic_dec(&pipe->waiting_writers);
54751 }
54752 out:
54753 mutex_unlock(&inode->i_mutex);
54754 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54755 mask = 0;
54756 if (filp->f_mode & FMODE_READ) {
54757 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54758 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54759 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54760 mask |= POLLHUP;
54761 }
54762
54763 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54764 * Most Unices do not set POLLERR for FIFOs but on Linux they
54765 * behave exactly like pipes for poll().
54766 */
54767 - if (!pipe->readers)
54768 + if (!atomic_read(&pipe->readers))
54769 mask |= POLLERR;
54770 }
54771
54772 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54773
54774 mutex_lock(&inode->i_mutex);
54775 pipe = inode->i_pipe;
54776 - pipe->readers -= decr;
54777 - pipe->writers -= decw;
54778 + atomic_sub(decr, &pipe->readers);
54779 + atomic_sub(decw, &pipe->writers);
54780
54781 - if (!pipe->readers && !pipe->writers) {
54782 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54783 free_pipe_info(inode);
54784 } else {
54785 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54786 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54787
54788 if (inode->i_pipe) {
54789 ret = 0;
54790 - inode->i_pipe->readers++;
54791 + atomic_inc(&inode->i_pipe->readers);
54792 }
54793
54794 mutex_unlock(&inode->i_mutex);
54795 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54796
54797 if (inode->i_pipe) {
54798 ret = 0;
54799 - inode->i_pipe->writers++;
54800 + atomic_inc(&inode->i_pipe->writers);
54801 }
54802
54803 mutex_unlock(&inode->i_mutex);
54804 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54805 if (inode->i_pipe) {
54806 ret = 0;
54807 if (filp->f_mode & FMODE_READ)
54808 - inode->i_pipe->readers++;
54809 + atomic_inc(&inode->i_pipe->readers);
54810 if (filp->f_mode & FMODE_WRITE)
54811 - inode->i_pipe->writers++;
54812 + atomic_inc(&inode->i_pipe->writers);
54813 }
54814
54815 mutex_unlock(&inode->i_mutex);
54816 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54817 inode->i_pipe = NULL;
54818 }
54819
54820 -static struct vfsmount *pipe_mnt __read_mostly;
54821 +struct vfsmount *pipe_mnt __read_mostly;
54822
54823 /*
54824 * pipefs_dname() is called from d_path().
54825 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54826 goto fail_iput;
54827 inode->i_pipe = pipe;
54828
54829 - pipe->readers = pipe->writers = 1;
54830 + atomic_set(&pipe->readers, 1);
54831 + atomic_set(&pipe->writers, 1);
54832 inode->i_fop = &rdwr_pipefifo_fops;
54833
54834 /*
54835 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54836 index 15af622..0e9f4467 100644
54837 --- a/fs/proc/Kconfig
54838 +++ b/fs/proc/Kconfig
54839 @@ -30,12 +30,12 @@ config PROC_FS
54840
54841 config PROC_KCORE
54842 bool "/proc/kcore support" if !ARM
54843 - depends on PROC_FS && MMU
54844 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54845
54846 config PROC_VMCORE
54847 bool "/proc/vmcore support"
54848 - depends on PROC_FS && CRASH_DUMP
54849 - default y
54850 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54851 + default n
54852 help
54853 Exports the dump image of crashed kernel in ELF format.
54854
54855 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54856 limited in memory.
54857
54858 config PROC_PAGE_MONITOR
54859 - default y
54860 - depends on PROC_FS && MMU
54861 + default n
54862 + depends on PROC_FS && MMU && !GRKERNSEC
54863 bool "Enable /proc page monitoring" if EXPERT
54864 help
54865 Various /proc files exist to monitor process memory utilization:
54866 diff --git a/fs/proc/array.c b/fs/proc/array.c
54867 index cbd0f1b..adec3f0 100644
54868 --- a/fs/proc/array.c
54869 +++ b/fs/proc/array.c
54870 @@ -60,6 +60,7 @@
54871 #include <linux/tty.h>
54872 #include <linux/string.h>
54873 #include <linux/mman.h>
54874 +#include <linux/grsecurity.h>
54875 #include <linux/proc_fs.h>
54876 #include <linux/ioport.h>
54877 #include <linux/uaccess.h>
54878 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54879 seq_putc(m, '\n');
54880 }
54881
54882 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54883 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54884 +{
54885 + if (p->mm)
54886 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54887 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54888 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54889 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54890 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54891 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54892 + else
54893 + seq_printf(m, "PaX:\t-----\n");
54894 +}
54895 +#endif
54896 +
54897 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54898 struct pid *pid, struct task_struct *task)
54899 {
54900 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54901 task_cpus_allowed(m, task);
54902 cpuset_task_status_allowed(m, task);
54903 task_context_switch_counts(m, task);
54904 +
54905 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54906 + task_pax(m, task);
54907 +#endif
54908 +
54909 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54910 + task_grsec_rbac(m, task);
54911 +#endif
54912 +
54913 return 0;
54914 }
54915
54916 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54917 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54918 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54919 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54920 +#endif
54921 +
54922 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54923 struct pid *pid, struct task_struct *task, int whole)
54924 {
54925 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54926 char tcomm[sizeof(task->comm)];
54927 unsigned long flags;
54928
54929 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54930 + if (current->exec_id != m->exec_id) {
54931 + gr_log_badprocpid("stat");
54932 + return 0;
54933 + }
54934 +#endif
54935 +
54936 state = *get_task_state(task);
54937 vsize = eip = esp = 0;
54938 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54939 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54940 gtime = task_gtime(task);
54941 }
54942
54943 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54944 + if (PAX_RAND_FLAGS(mm)) {
54945 + eip = 0;
54946 + esp = 0;
54947 + wchan = 0;
54948 + }
54949 +#endif
54950 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54951 + wchan = 0;
54952 + eip =0;
54953 + esp =0;
54954 +#endif
54955 +
54956 /* scale priority and nice values from timeslices to -20..20 */
54957 /* to make it look like a "normal" Unix priority/nice value */
54958 priority = task_prio(task);
54959 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54960 seq_put_decimal_ull(m, ' ', vsize);
54961 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54962 seq_put_decimal_ull(m, ' ', rsslim);
54963 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54964 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54965 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54966 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54967 +#else
54968 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54969 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54970 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54971 +#endif
54972 seq_put_decimal_ull(m, ' ', esp);
54973 seq_put_decimal_ull(m, ' ', eip);
54974 /* The signal information here is obsolete.
54975 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54976 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54977 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54978
54979 - if (mm && permitted) {
54980 + if (mm && permitted
54981 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54982 + && !PAX_RAND_FLAGS(mm)
54983 +#endif
54984 + ) {
54985 seq_put_decimal_ull(m, ' ', mm->start_data);
54986 seq_put_decimal_ull(m, ' ', mm->end_data);
54987 seq_put_decimal_ull(m, ' ', mm->start_brk);
54988 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54989 struct pid *pid, struct task_struct *task)
54990 {
54991 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54992 - struct mm_struct *mm = get_task_mm(task);
54993 + struct mm_struct *mm;
54994
54995 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54996 + if (current->exec_id != m->exec_id) {
54997 + gr_log_badprocpid("statm");
54998 + return 0;
54999 + }
55000 +#endif
55001 + mm = get_task_mm(task);
55002 if (mm) {
55003 size = task_statm(mm, &shared, &text, &data, &resident);
55004 mmput(mm);
55005 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55006 return 0;
55007 }
55008
55009 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55010 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55011 +{
55012 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55013 +}
55014 +#endif
55015 +
55016 #ifdef CONFIG_CHECKPOINT_RESTORE
55017 static struct pid *
55018 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55019 diff --git a/fs/proc/base.c b/fs/proc/base.c
55020 index 69078c7..3e12a75 100644
55021 --- a/fs/proc/base.c
55022 +++ b/fs/proc/base.c
55023 @@ -112,6 +112,14 @@ struct pid_entry {
55024 union proc_op op;
55025 };
55026
55027 +struct getdents_callback {
55028 + struct linux_dirent __user * current_dir;
55029 + struct linux_dirent __user * previous;
55030 + struct file * file;
55031 + int count;
55032 + int error;
55033 +};
55034 +
55035 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55036 .name = (NAME), \
55037 .len = sizeof(NAME) - 1, \
55038 @@ -209,6 +217,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55039 if (!mm->arg_end)
55040 goto out_mm; /* Shh! No looking before we're done */
55041
55042 + if (gr_acl_handle_procpidmem(task))
55043 + goto out_mm;
55044 +
55045 len = mm->arg_end - mm->arg_start;
55046
55047 if (len > PAGE_SIZE)
55048 @@ -236,12 +247,28 @@ out:
55049 return res;
55050 }
55051
55052 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55053 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55054 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55055 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55056 +#endif
55057 +
55058 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55059 {
55060 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55061 int res = PTR_ERR(mm);
55062 if (mm && !IS_ERR(mm)) {
55063 unsigned int nwords = 0;
55064 +
55065 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55066 + /* allow if we're currently ptracing this task */
55067 + if (PAX_RAND_FLAGS(mm) &&
55068 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55069 + mmput(mm);
55070 + return 0;
55071 + }
55072 +#endif
55073 +
55074 do {
55075 nwords += 2;
55076 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55077 @@ -255,7 +282,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55078 }
55079
55080
55081 -#ifdef CONFIG_KALLSYMS
55082 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55083 /*
55084 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55085 * Returns the resolved symbol. If that fails, simply return the address.
55086 @@ -294,7 +321,7 @@ static void unlock_trace(struct task_struct *task)
55087 mutex_unlock(&task->signal->cred_guard_mutex);
55088 }
55089
55090 -#ifdef CONFIG_STACKTRACE
55091 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55092
55093 #define MAX_STACK_TRACE_DEPTH 64
55094
55095 @@ -486,7 +513,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55096 return count;
55097 }
55098
55099 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55100 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55101 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55102 {
55103 long nr;
55104 @@ -515,7 +542,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55105 /************************************************************************/
55106
55107 /* permission checks */
55108 -static int proc_fd_access_allowed(struct inode *inode)
55109 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55110 {
55111 struct task_struct *task;
55112 int allowed = 0;
55113 @@ -525,7 +552,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55114 */
55115 task = get_proc_task(inode);
55116 if (task) {
55117 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55118 + if (log)
55119 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55120 + else
55121 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55122 put_task_struct(task);
55123 }
55124 return allowed;
55125 @@ -556,10 +586,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55126 struct task_struct *task,
55127 int hide_pid_min)
55128 {
55129 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55130 + return false;
55131 +
55132 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55133 + rcu_read_lock();
55134 + {
55135 + const struct cred *tmpcred = current_cred();
55136 + const struct cred *cred = __task_cred(task);
55137 +
55138 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55139 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55140 + || in_group_p(grsec_proc_gid)
55141 +#endif
55142 + ) {
55143 + rcu_read_unlock();
55144 + return true;
55145 + }
55146 + }
55147 + rcu_read_unlock();
55148 +
55149 + if (!pid->hide_pid)
55150 + return false;
55151 +#endif
55152 +
55153 if (pid->hide_pid < hide_pid_min)
55154 return true;
55155 if (in_group_p(pid->pid_gid))
55156 return true;
55157 +
55158 return ptrace_may_access(task, PTRACE_MODE_READ);
55159 }
55160
55161 @@ -577,7 +632,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55162 put_task_struct(task);
55163
55164 if (!has_perms) {
55165 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55166 + {
55167 +#else
55168 if (pid->hide_pid == 2) {
55169 +#endif
55170 /*
55171 * Let's make getdents(), stat(), and open()
55172 * consistent with each other. If a process
55173 @@ -675,6 +734,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55174 if (!task)
55175 return -ESRCH;
55176
55177 + if (gr_acl_handle_procpidmem(task)) {
55178 + put_task_struct(task);
55179 + return -EPERM;
55180 + }
55181 +
55182 mm = mm_access(task, mode);
55183 put_task_struct(task);
55184
55185 @@ -690,6 +754,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55186
55187 file->private_data = mm;
55188
55189 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55190 + file->f_version = current->exec_id;
55191 +#endif
55192 +
55193 return 0;
55194 }
55195
55196 @@ -711,6 +779,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55197 ssize_t copied;
55198 char *page;
55199
55200 +#ifdef CONFIG_GRKERNSEC
55201 + if (write)
55202 + return -EPERM;
55203 +#endif
55204 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55205 + if (file->f_version != current->exec_id) {
55206 + gr_log_badprocpid("mem");
55207 + return 0;
55208 + }
55209 +#endif
55210 +
55211 if (!mm)
55212 return 0;
55213
55214 @@ -723,7 +802,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55215 goto free;
55216
55217 while (count > 0) {
55218 - int this_len = min_t(int, count, PAGE_SIZE);
55219 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55220
55221 if (write && copy_from_user(page, buf, this_len)) {
55222 copied = -EFAULT;
55223 @@ -815,6 +894,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55224 if (!mm)
55225 return 0;
55226
55227 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55228 + if (file->f_version != current->exec_id) {
55229 + gr_log_badprocpid("environ");
55230 + return 0;
55231 + }
55232 +#endif
55233 +
55234 page = (char *)__get_free_page(GFP_TEMPORARY);
55235 if (!page)
55236 return -ENOMEM;
55237 @@ -824,7 +910,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55238 goto free;
55239 while (count > 0) {
55240 size_t this_len, max_len;
55241 - int retval;
55242 + ssize_t retval;
55243
55244 if (src >= (mm->env_end - mm->env_start))
55245 break;
55246 @@ -1430,7 +1516,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55247 int error = -EACCES;
55248
55249 /* Are we allowed to snoop on the tasks file descriptors? */
55250 - if (!proc_fd_access_allowed(inode))
55251 + if (!proc_fd_access_allowed(inode, 0))
55252 goto out;
55253
55254 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55255 @@ -1474,8 +1560,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55256 struct path path;
55257
55258 /* Are we allowed to snoop on the tasks file descriptors? */
55259 - if (!proc_fd_access_allowed(inode))
55260 - goto out;
55261 + /* logging this is needed for learning on chromium to work properly,
55262 + but we don't want to flood the logs from 'ps' which does a readlink
55263 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55264 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55265 + */
55266 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55267 + if (!proc_fd_access_allowed(inode,0))
55268 + goto out;
55269 + } else {
55270 + if (!proc_fd_access_allowed(inode,1))
55271 + goto out;
55272 + }
55273
55274 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55275 if (error)
55276 @@ -1525,7 +1621,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55277 rcu_read_lock();
55278 cred = __task_cred(task);
55279 inode->i_uid = cred->euid;
55280 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55281 + inode->i_gid = grsec_proc_gid;
55282 +#else
55283 inode->i_gid = cred->egid;
55284 +#endif
55285 rcu_read_unlock();
55286 }
55287 security_task_to_inode(task, inode);
55288 @@ -1561,10 +1661,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55289 return -ENOENT;
55290 }
55291 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55292 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55293 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55294 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55295 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55296 +#endif
55297 task_dumpable(task)) {
55298 cred = __task_cred(task);
55299 stat->uid = cred->euid;
55300 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55301 + stat->gid = grsec_proc_gid;
55302 +#else
55303 stat->gid = cred->egid;
55304 +#endif
55305 }
55306 }
55307 rcu_read_unlock();
55308 @@ -1602,11 +1711,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55309
55310 if (task) {
55311 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55312 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55313 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55314 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55315 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55316 +#endif
55317 task_dumpable(task)) {
55318 rcu_read_lock();
55319 cred = __task_cred(task);
55320 inode->i_uid = cred->euid;
55321 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55322 + inode->i_gid = grsec_proc_gid;
55323 +#else
55324 inode->i_gid = cred->egid;
55325 +#endif
55326 rcu_read_unlock();
55327 } else {
55328 inode->i_uid = GLOBAL_ROOT_UID;
55329 @@ -2059,6 +2177,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55330 if (!task)
55331 goto out_no_task;
55332
55333 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55334 + goto out;
55335 +
55336 /*
55337 * Yes, it does not scale. And it should not. Don't add
55338 * new entries into /proc/<tgid>/ without very good reasons.
55339 @@ -2103,6 +2224,9 @@ static int proc_pident_readdir(struct file *filp,
55340 if (!task)
55341 goto out_no_task;
55342
55343 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55344 + goto out;
55345 +
55346 ret = 0;
55347 i = filp->f_pos;
55348 switch (i) {
55349 @@ -2516,7 +2640,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55350 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55351 #endif
55352 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55353 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55354 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55355 INF("syscall", S_IRUGO, proc_pid_syscall),
55356 #endif
55357 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55358 @@ -2541,10 +2665,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55359 #ifdef CONFIG_SECURITY
55360 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55361 #endif
55362 -#ifdef CONFIG_KALLSYMS
55363 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55364 INF("wchan", S_IRUGO, proc_pid_wchan),
55365 #endif
55366 -#ifdef CONFIG_STACKTRACE
55367 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55368 ONE("stack", S_IRUGO, proc_pid_stack),
55369 #endif
55370 #ifdef CONFIG_SCHEDSTATS
55371 @@ -2578,6 +2702,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55372 #ifdef CONFIG_HARDWALL
55373 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55374 #endif
55375 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55376 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55377 +#endif
55378 #ifdef CONFIG_USER_NS
55379 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55380 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55381 @@ -2707,7 +2834,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55382 if (!inode)
55383 goto out;
55384
55385 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55386 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55387 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55388 + inode->i_gid = grsec_proc_gid;
55389 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55390 +#else
55391 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55392 +#endif
55393 inode->i_op = &proc_tgid_base_inode_operations;
55394 inode->i_fop = &proc_tgid_base_operations;
55395 inode->i_flags|=S_IMMUTABLE;
55396 @@ -2745,7 +2879,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55397 if (!task)
55398 goto out;
55399
55400 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55401 + goto out_put_task;
55402 +
55403 result = proc_pid_instantiate(dir, dentry, task, NULL);
55404 +out_put_task:
55405 put_task_struct(task);
55406 out:
55407 return result;
55408 @@ -2808,6 +2946,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55409 static int fake_filldir(void *buf, const char *name, int namelen,
55410 loff_t offset, u64 ino, unsigned d_type)
55411 {
55412 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55413 + __buf->error = -EINVAL;
55414 return 0;
55415 }
55416
55417 @@ -2859,7 +2999,7 @@ static const struct pid_entry tid_base_stuff[] = {
55418 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55419 #endif
55420 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55421 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55422 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55423 INF("syscall", S_IRUGO, proc_pid_syscall),
55424 #endif
55425 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55426 @@ -2886,10 +3026,10 @@ static const struct pid_entry tid_base_stuff[] = {
55427 #ifdef CONFIG_SECURITY
55428 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55429 #endif
55430 -#ifdef CONFIG_KALLSYMS
55431 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55432 INF("wchan", S_IRUGO, proc_pid_wchan),
55433 #endif
55434 -#ifdef CONFIG_STACKTRACE
55435 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55436 ONE("stack", S_IRUGO, proc_pid_stack),
55437 #endif
55438 #ifdef CONFIG_SCHEDSTATS
55439 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55440 index 82676e3..5f8518a 100644
55441 --- a/fs/proc/cmdline.c
55442 +++ b/fs/proc/cmdline.c
55443 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55444
55445 static int __init proc_cmdline_init(void)
55446 {
55447 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55448 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55449 +#else
55450 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55451 +#endif
55452 return 0;
55453 }
55454 module_init(proc_cmdline_init);
55455 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55456 index b143471..bb105e5 100644
55457 --- a/fs/proc/devices.c
55458 +++ b/fs/proc/devices.c
55459 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55460
55461 static int __init proc_devices_init(void)
55462 {
55463 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55464 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55465 +#else
55466 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55467 +#endif
55468 return 0;
55469 }
55470 module_init(proc_devices_init);
55471 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55472 index d7a4a28..0201742 100644
55473 --- a/fs/proc/fd.c
55474 +++ b/fs/proc/fd.c
55475 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55476 if (!task)
55477 return -ENOENT;
55478
55479 - files = get_files_struct(task);
55480 + if (!gr_acl_handle_procpidmem(task))
55481 + files = get_files_struct(task);
55482 put_task_struct(task);
55483
55484 if (files) {
55485 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55486 */
55487 int proc_fd_permission(struct inode *inode, int mask)
55488 {
55489 + struct task_struct *task;
55490 int rv = generic_permission(inode, mask);
55491 - if (rv == 0)
55492 - return 0;
55493 +
55494 if (task_pid(current) == proc_pid(inode))
55495 rv = 0;
55496 +
55497 + task = get_proc_task(inode);
55498 + if (task == NULL)
55499 + return rv;
55500 +
55501 + if (gr_acl_handle_procpidmem(task))
55502 + rv = -EACCES;
55503 +
55504 + put_task_struct(task);
55505 +
55506 return rv;
55507 }
55508
55509 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55510 index 869116c..820cb27 100644
55511 --- a/fs/proc/inode.c
55512 +++ b/fs/proc/inode.c
55513 @@ -22,11 +22,17 @@
55514 #include <linux/seq_file.h>
55515 #include <linux/slab.h>
55516 #include <linux/mount.h>
55517 +#include <linux/grsecurity.h>
55518
55519 #include <asm/uaccess.h>
55520
55521 #include "internal.h"
55522
55523 +#ifdef CONFIG_PROC_SYSCTL
55524 +extern const struct inode_operations proc_sys_inode_operations;
55525 +extern const struct inode_operations proc_sys_dir_operations;
55526 +#endif
55527 +
55528 static void proc_evict_inode(struct inode *inode)
55529 {
55530 struct proc_dir_entry *de;
55531 @@ -54,6 +60,13 @@ static void proc_evict_inode(struct inode *inode)
55532 ns = PROC_I(inode)->ns;
55533 if (ns_ops && ns)
55534 ns_ops->put(ns);
55535 +
55536 +#ifdef CONFIG_PROC_SYSCTL
55537 + if (inode->i_op == &proc_sys_inode_operations ||
55538 + inode->i_op == &proc_sys_dir_operations)
55539 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55540 +#endif
55541 +
55542 }
55543
55544 static struct kmem_cache * proc_inode_cachep;
55545 @@ -456,7 +469,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55546 if (de->mode) {
55547 inode->i_mode = de->mode;
55548 inode->i_uid = de->uid;
55549 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55550 + inode->i_gid = grsec_proc_gid;
55551 +#else
55552 inode->i_gid = de->gid;
55553 +#endif
55554 }
55555 if (de->size)
55556 inode->i_size = de->size;
55557 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55558 index 85ff3a4..a512bd8 100644
55559 --- a/fs/proc/internal.h
55560 +++ b/fs/proc/internal.h
55561 @@ -56,6 +56,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55562 struct pid *pid, struct task_struct *task);
55563 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55564 struct pid *pid, struct task_struct *task);
55565 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55566 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55567 +#endif
55568 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55569
55570 extern const struct file_operations proc_tid_children_operations;
55571 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55572 index eda6f01..006ae24 100644
55573 --- a/fs/proc/kcore.c
55574 +++ b/fs/proc/kcore.c
55575 @@ -481,9 +481,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55576 * the addresses in the elf_phdr on our list.
55577 */
55578 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55579 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55580 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55581 + if (tsz > buflen)
55582 tsz = buflen;
55583 -
55584 +
55585 while (buflen) {
55586 struct kcore_list *m;
55587
55588 @@ -512,20 +513,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55589 kfree(elf_buf);
55590 } else {
55591 if (kern_addr_valid(start)) {
55592 - unsigned long n;
55593 + char *elf_buf;
55594 + mm_segment_t oldfs;
55595
55596 - n = copy_to_user(buffer, (char *)start, tsz);
55597 - /*
55598 - * We cannot distinguish between fault on source
55599 - * and fault on destination. When this happens
55600 - * we clear too and hope it will trigger the
55601 - * EFAULT again.
55602 - */
55603 - if (n) {
55604 - if (clear_user(buffer + tsz - n,
55605 - n))
55606 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55607 + if (!elf_buf)
55608 + return -ENOMEM;
55609 + oldfs = get_fs();
55610 + set_fs(KERNEL_DS);
55611 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55612 + set_fs(oldfs);
55613 + if (copy_to_user(buffer, elf_buf, tsz)) {
55614 + kfree(elf_buf);
55615 return -EFAULT;
55616 + }
55617 }
55618 + set_fs(oldfs);
55619 + kfree(elf_buf);
55620 } else {
55621 if (clear_user(buffer, tsz))
55622 return -EFAULT;
55623 @@ -545,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55624
55625 static int open_kcore(struct inode *inode, struct file *filp)
55626 {
55627 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55628 + return -EPERM;
55629 +#endif
55630 if (!capable(CAP_SYS_RAWIO))
55631 return -EPERM;
55632 if (kcore_need_update)
55633 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55634 index 1efaaa1..834e49a 100644
55635 --- a/fs/proc/meminfo.c
55636 +++ b/fs/proc/meminfo.c
55637 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55638 vmi.used >> 10,
55639 vmi.largest_chunk >> 10
55640 #ifdef CONFIG_MEMORY_FAILURE
55641 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55642 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55643 #endif
55644 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55645 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55646 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55647 index ccfd99b..1b7e255 100644
55648 --- a/fs/proc/nommu.c
55649 +++ b/fs/proc/nommu.c
55650 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55651 if (len < 1)
55652 len = 1;
55653 seq_printf(m, "%*c", len, ' ');
55654 - seq_path(m, &file->f_path, "");
55655 + seq_path(m, &file->f_path, "\n\\");
55656 }
55657
55658 seq_putc(m, '\n');
55659 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55660 index b4ac657..0842bd2 100644
55661 --- a/fs/proc/proc_net.c
55662 +++ b/fs/proc/proc_net.c
55663 @@ -23,6 +23,7 @@
55664 #include <linux/nsproxy.h>
55665 #include <net/net_namespace.h>
55666 #include <linux/seq_file.h>
55667 +#include <linux/grsecurity.h>
55668
55669 #include "internal.h"
55670
55671 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55672 struct task_struct *task;
55673 struct nsproxy *ns;
55674 struct net *net = NULL;
55675 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55676 + const struct cred *cred = current_cred();
55677 +#endif
55678 +
55679 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55680 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55681 + return net;
55682 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55683 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55684 + return net;
55685 +#endif
55686
55687 rcu_read_lock();
55688 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55689 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55690 index ac05f33..1e6dc7e 100644
55691 --- a/fs/proc/proc_sysctl.c
55692 +++ b/fs/proc/proc_sysctl.c
55693 @@ -13,11 +13,15 @@
55694 #include <linux/module.h>
55695 #include "internal.h"
55696
55697 +extern int gr_handle_chroot_sysctl(const int op);
55698 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55699 + const int op);
55700 +
55701 static const struct dentry_operations proc_sys_dentry_operations;
55702 static const struct file_operations proc_sys_file_operations;
55703 -static const struct inode_operations proc_sys_inode_operations;
55704 +const struct inode_operations proc_sys_inode_operations;
55705 static const struct file_operations proc_sys_dir_file_operations;
55706 -static const struct inode_operations proc_sys_dir_operations;
55707 +const struct inode_operations proc_sys_dir_operations;
55708
55709 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55710 {
55711 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55712
55713 err = NULL;
55714 d_set_d_op(dentry, &proc_sys_dentry_operations);
55715 +
55716 + gr_handle_proc_create(dentry, inode);
55717 +
55718 d_add(dentry, inode);
55719
55720 out:
55721 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55722 struct inode *inode = file_inode(filp);
55723 struct ctl_table_header *head = grab_header(inode);
55724 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55725 + int op = write ? MAY_WRITE : MAY_READ;
55726 ssize_t error;
55727 size_t res;
55728
55729 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55730 * and won't be until we finish.
55731 */
55732 error = -EPERM;
55733 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55734 + if (sysctl_perm(head, table, op))
55735 goto out;
55736
55737 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55738 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55739 if (!table->proc_handler)
55740 goto out;
55741
55742 +#ifdef CONFIG_GRKERNSEC
55743 + error = -EPERM;
55744 + if (gr_handle_chroot_sysctl(op))
55745 + goto out;
55746 + dget(filp->f_path.dentry);
55747 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55748 + dput(filp->f_path.dentry);
55749 + goto out;
55750 + }
55751 + dput(filp->f_path.dentry);
55752 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55753 + goto out;
55754 + if (write && !capable(CAP_SYS_ADMIN))
55755 + goto out;
55756 +#endif
55757 +
55758 /* careful: calling conventions are nasty here */
55759 res = count;
55760 error = table->proc_handler(table, write, buf, &res, ppos);
55761 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55762 return -ENOMEM;
55763 } else {
55764 d_set_d_op(child, &proc_sys_dentry_operations);
55765 +
55766 + gr_handle_proc_create(child, inode);
55767 +
55768 d_add(child, inode);
55769 }
55770 } else {
55771 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55772 if ((*pos)++ < file->f_pos)
55773 return 0;
55774
55775 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55776 + return 0;
55777 +
55778 if (unlikely(S_ISLNK(table->mode)))
55779 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55780 else
55781 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55782 if (IS_ERR(head))
55783 return PTR_ERR(head);
55784
55785 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55786 + return -ENOENT;
55787 +
55788 generic_fillattr(inode, stat);
55789 if (table)
55790 stat->mode = (stat->mode & S_IFMT) | table->mode;
55791 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55792 .llseek = generic_file_llseek,
55793 };
55794
55795 -static const struct inode_operations proc_sys_inode_operations = {
55796 +const struct inode_operations proc_sys_inode_operations = {
55797 .permission = proc_sys_permission,
55798 .setattr = proc_sys_setattr,
55799 .getattr = proc_sys_getattr,
55800 };
55801
55802 -static const struct inode_operations proc_sys_dir_operations = {
55803 +const struct inode_operations proc_sys_dir_operations = {
55804 .lookup = proc_sys_lookup,
55805 .permission = proc_sys_permission,
55806 .setattr = proc_sys_setattr,
55807 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55808 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55809 const char *name, int namelen)
55810 {
55811 - struct ctl_table *table;
55812 + ctl_table_no_const *table;
55813 struct ctl_dir *new;
55814 struct ctl_node *node;
55815 char *new_name;
55816 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55817 return NULL;
55818
55819 node = (struct ctl_node *)(new + 1);
55820 - table = (struct ctl_table *)(node + 1);
55821 + table = (ctl_table_no_const *)(node + 1);
55822 new_name = (char *)(table + 2);
55823 memcpy(new_name, name, namelen);
55824 new_name[namelen] = '\0';
55825 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55826 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55827 struct ctl_table_root *link_root)
55828 {
55829 - struct ctl_table *link_table, *entry, *link;
55830 + ctl_table_no_const *link_table, *link;
55831 + struct ctl_table *entry;
55832 struct ctl_table_header *links;
55833 struct ctl_node *node;
55834 char *link_name;
55835 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55836 return NULL;
55837
55838 node = (struct ctl_node *)(links + 1);
55839 - link_table = (struct ctl_table *)(node + nr_entries);
55840 + link_table = (ctl_table_no_const *)(node + nr_entries);
55841 link_name = (char *)&link_table[nr_entries + 1];
55842
55843 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55844 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55845 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55846 struct ctl_table *table)
55847 {
55848 - struct ctl_table *ctl_table_arg = NULL;
55849 - struct ctl_table *entry, *files;
55850 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55851 + struct ctl_table *entry;
55852 int nr_files = 0;
55853 int nr_dirs = 0;
55854 int err = -ENOMEM;
55855 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55856 nr_files++;
55857 }
55858
55859 - files = table;
55860 /* If there are mixed files and directories we need a new table */
55861 if (nr_dirs && nr_files) {
55862 - struct ctl_table *new;
55863 + ctl_table_no_const *new;
55864 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55865 GFP_KERNEL);
55866 if (!files)
55867 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55868 /* Register everything except a directory full of subdirectories */
55869 if (nr_files || !nr_dirs) {
55870 struct ctl_table_header *header;
55871 - header = __register_sysctl_table(set, path, files);
55872 + header = __register_sysctl_table(set, path, files ? files : table);
55873 if (!header) {
55874 kfree(ctl_table_arg);
55875 goto out;
55876 diff --git a/fs/proc/root.c b/fs/proc/root.c
55877 index 9c7fab1..ed1c8e0 100644
55878 --- a/fs/proc/root.c
55879 +++ b/fs/proc/root.c
55880 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55881 #ifdef CONFIG_PROC_DEVICETREE
55882 proc_device_tree_init();
55883 #endif
55884 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55885 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55886 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55887 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55888 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55889 +#endif
55890 +#else
55891 proc_mkdir("bus", NULL);
55892 +#endif
55893 proc_sys_init();
55894 }
55895
55896 diff --git a/fs/proc/self.c b/fs/proc/self.c
55897 index aa5cc3b..c91a5d0 100644
55898 --- a/fs/proc/self.c
55899 +++ b/fs/proc/self.c
55900 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55901 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55902 void *cookie)
55903 {
55904 - char *s = nd_get_link(nd);
55905 + const char *s = nd_get_link(nd);
55906 if (!IS_ERR(s))
55907 kfree(s);
55908 }
55909 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55910 index 3e636d8..83e3b71 100644
55911 --- a/fs/proc/task_mmu.c
55912 +++ b/fs/proc/task_mmu.c
55913 @@ -11,12 +11,19 @@
55914 #include <linux/rmap.h>
55915 #include <linux/swap.h>
55916 #include <linux/swapops.h>
55917 +#include <linux/grsecurity.h>
55918
55919 #include <asm/elf.h>
55920 #include <asm/uaccess.h>
55921 #include <asm/tlbflush.h>
55922 #include "internal.h"
55923
55924 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55925 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55926 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55927 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55928 +#endif
55929 +
55930 void task_mem(struct seq_file *m, struct mm_struct *mm)
55931 {
55932 unsigned long data, text, lib, swap;
55933 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55934 "VmExe:\t%8lu kB\n"
55935 "VmLib:\t%8lu kB\n"
55936 "VmPTE:\t%8lu kB\n"
55937 - "VmSwap:\t%8lu kB\n",
55938 - hiwater_vm << (PAGE_SHIFT-10),
55939 + "VmSwap:\t%8lu kB\n"
55940 +
55941 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55942 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55943 +#endif
55944 +
55945 + ,hiwater_vm << (PAGE_SHIFT-10),
55946 total_vm << (PAGE_SHIFT-10),
55947 mm->locked_vm << (PAGE_SHIFT-10),
55948 mm->pinned_vm << (PAGE_SHIFT-10),
55949 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55950 data << (PAGE_SHIFT-10),
55951 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55952 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55953 - swap << (PAGE_SHIFT-10));
55954 + swap << (PAGE_SHIFT-10)
55955 +
55956 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55957 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55958 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55959 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55960 +#else
55961 + , mm->context.user_cs_base
55962 + , mm->context.user_cs_limit
55963 +#endif
55964 +#endif
55965 +
55966 + );
55967 }
55968
55969 unsigned long task_vsize(struct mm_struct *mm)
55970 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55971 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55972 }
55973
55974 - /* We don't show the stack guard page in /proc/maps */
55975 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55976 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55977 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55978 +#else
55979 start = vma->vm_start;
55980 - if (stack_guard_page_start(vma, start))
55981 - start += PAGE_SIZE;
55982 end = vma->vm_end;
55983 - if (stack_guard_page_end(vma, end))
55984 - end -= PAGE_SIZE;
55985 +#endif
55986
55987 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55988 start,
55989 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55990 flags & VM_WRITE ? 'w' : '-',
55991 flags & VM_EXEC ? 'x' : '-',
55992 flags & VM_MAYSHARE ? 's' : 'p',
55993 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55994 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55995 +#else
55996 pgoff,
55997 +#endif
55998 MAJOR(dev), MINOR(dev), ino, &len);
55999
56000 /*
56001 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56002 */
56003 if (file) {
56004 pad_len_spaces(m, len);
56005 - seq_path(m, &file->f_path, "\n");
56006 + seq_path(m, &file->f_path, "\n\\");
56007 goto done;
56008 }
56009
56010 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56011 * Thread stack in /proc/PID/task/TID/maps or
56012 * the main process stack.
56013 */
56014 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56015 - vma->vm_end >= mm->start_stack)) {
56016 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56017 + (vma->vm_start <= mm->start_stack &&
56018 + vma->vm_end >= mm->start_stack)) {
56019 name = "[stack]";
56020 } else {
56021 /* Thread stack in /proc/PID/maps */
56022 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56023 struct proc_maps_private *priv = m->private;
56024 struct task_struct *task = priv->task;
56025
56026 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56027 + if (current->exec_id != m->exec_id) {
56028 + gr_log_badprocpid("maps");
56029 + return 0;
56030 + }
56031 +#endif
56032 +
56033 show_map_vma(m, vma, is_pid);
56034
56035 if (m->count < m->size) /* vma is copied successfully */
56036 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56037 .private = &mss,
56038 };
56039
56040 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56041 + if (current->exec_id != m->exec_id) {
56042 + gr_log_badprocpid("smaps");
56043 + return 0;
56044 + }
56045 +#endif
56046 memset(&mss, 0, sizeof mss);
56047 - mss.vma = vma;
56048 - /* mmap_sem is held in m_start */
56049 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56050 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56051 -
56052 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56053 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56054 +#endif
56055 + mss.vma = vma;
56056 + /* mmap_sem is held in m_start */
56057 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56058 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56059 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56060 + }
56061 +#endif
56062 show_map_vma(m, vma, is_pid);
56063
56064 seq_printf(m,
56065 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56066 "KernelPageSize: %8lu kB\n"
56067 "MMUPageSize: %8lu kB\n"
56068 "Locked: %8lu kB\n",
56069 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56070 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56071 +#else
56072 (vma->vm_end - vma->vm_start) >> 10,
56073 +#endif
56074 mss.resident >> 10,
56075 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56076 mss.shared_clean >> 10,
56077 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56078 int n;
56079 char buffer[50];
56080
56081 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56082 + if (current->exec_id != m->exec_id) {
56083 + gr_log_badprocpid("numa_maps");
56084 + return 0;
56085 + }
56086 +#endif
56087 +
56088 if (!mm)
56089 return 0;
56090
56091 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56092 mpol_to_str(buffer, sizeof(buffer), pol);
56093 mpol_cond_put(pol);
56094
56095 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56096 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56097 +#else
56098 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56099 +#endif
56100
56101 if (file) {
56102 seq_printf(m, " file=");
56103 - seq_path(m, &file->f_path, "\n\t= ");
56104 + seq_path(m, &file->f_path, "\n\t\\= ");
56105 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56106 seq_printf(m, " heap");
56107 } else {
56108 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56109 index 56123a6..5a2f6ec 100644
56110 --- a/fs/proc/task_nommu.c
56111 +++ b/fs/proc/task_nommu.c
56112 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56113 else
56114 bytes += kobjsize(mm);
56115
56116 - if (current->fs && current->fs->users > 1)
56117 + if (current->fs && atomic_read(&current->fs->users) > 1)
56118 sbytes += kobjsize(current->fs);
56119 else
56120 bytes += kobjsize(current->fs);
56121 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56122
56123 if (file) {
56124 pad_len_spaces(m, len);
56125 - seq_path(m, &file->f_path, "");
56126 + seq_path(m, &file->f_path, "\n\\");
56127 } else if (mm) {
56128 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56129
56130 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
56131 index b870f74..e9048df 100644
56132 --- a/fs/proc/vmcore.c
56133 +++ b/fs/proc/vmcore.c
56134 @@ -98,9 +98,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
56135 nr_bytes = count;
56136
56137 /* If pfn is not ram, return zeros for sparse dump files */
56138 - if (pfn_is_ram(pfn) == 0)
56139 - memset(buf, 0, nr_bytes);
56140 - else {
56141 + if (pfn_is_ram(pfn) == 0) {
56142 + if (userbuf) {
56143 + if (clear_user((char __force_user *)buf, nr_bytes))
56144 + return -EFAULT;
56145 + } else
56146 + memset(buf, 0, nr_bytes);
56147 + } else {
56148 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
56149 offset, userbuf);
56150 if (tmp < 0)
56151 @@ -185,7 +189,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
56152 if (tsz > nr_bytes)
56153 tsz = nr_bytes;
56154
56155 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
56156 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
56157 if (tmp < 0)
56158 return tmp;
56159 buflen -= tsz;
56160 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56161 index b00fcc9..e0c6381 100644
56162 --- a/fs/qnx6/qnx6.h
56163 +++ b/fs/qnx6/qnx6.h
56164 @@ -74,7 +74,7 @@ enum {
56165 BYTESEX_BE,
56166 };
56167
56168 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56169 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56170 {
56171 if (sbi->s_bytesex == BYTESEX_LE)
56172 return le64_to_cpu((__force __le64)n);
56173 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56174 return (__force __fs64)cpu_to_be64(n);
56175 }
56176
56177 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56178 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56179 {
56180 if (sbi->s_bytesex == BYTESEX_LE)
56181 return le32_to_cpu((__force __le32)n);
56182 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56183 index 16e8abb..2dcf914 100644
56184 --- a/fs/quota/netlink.c
56185 +++ b/fs/quota/netlink.c
56186 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56187 void quota_send_warning(struct kqid qid, dev_t dev,
56188 const char warntype)
56189 {
56190 - static atomic_t seq;
56191 + static atomic_unchecked_t seq;
56192 struct sk_buff *skb;
56193 void *msg_head;
56194 int ret;
56195 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56196 "VFS: Not enough memory to send quota warning.\n");
56197 return;
56198 }
56199 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56200 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56201 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56202 if (!msg_head) {
56203 printk(KERN_ERR
56204 diff --git a/fs/read_write.c b/fs/read_write.c
56205 index e6ddc8d..9155227 100644
56206 --- a/fs/read_write.c
56207 +++ b/fs/read_write.c
56208 @@ -429,7 +429,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
56209
56210 old_fs = get_fs();
56211 set_fs(get_ds());
56212 - p = (__force const char __user *)buf;
56213 + p = (const char __force_user *)buf;
56214 if (count > MAX_RW_COUNT)
56215 count = MAX_RW_COUNT;
56216 if (file->f_op->write)
56217 diff --git a/fs/readdir.c b/fs/readdir.c
56218 index fee38e0..12fdf47 100644
56219 --- a/fs/readdir.c
56220 +++ b/fs/readdir.c
56221 @@ -17,6 +17,7 @@
56222 #include <linux/security.h>
56223 #include <linux/syscalls.h>
56224 #include <linux/unistd.h>
56225 +#include <linux/namei.h>
56226
56227 #include <asm/uaccess.h>
56228
56229 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56230
56231 struct readdir_callback {
56232 struct old_linux_dirent __user * dirent;
56233 + struct file * file;
56234 int result;
56235 };
56236
56237 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56238 buf->result = -EOVERFLOW;
56239 return -EOVERFLOW;
56240 }
56241 +
56242 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56243 + return 0;
56244 +
56245 buf->result++;
56246 dirent = buf->dirent;
56247 if (!access_ok(VERIFY_WRITE, dirent,
56248 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56249
56250 buf.result = 0;
56251 buf.dirent = dirent;
56252 + buf.file = f.file;
56253
56254 error = vfs_readdir(f.file, fillonedir, &buf);
56255 if (buf.result)
56256 @@ -139,6 +146,7 @@ struct linux_dirent {
56257 struct getdents_callback {
56258 struct linux_dirent __user * current_dir;
56259 struct linux_dirent __user * previous;
56260 + struct file * file;
56261 int count;
56262 int error;
56263 };
56264 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56265 buf->error = -EOVERFLOW;
56266 return -EOVERFLOW;
56267 }
56268 +
56269 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56270 + return 0;
56271 +
56272 dirent = buf->previous;
56273 if (dirent) {
56274 if (__put_user(offset, &dirent->d_off))
56275 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56276 buf.previous = NULL;
56277 buf.count = count;
56278 buf.error = 0;
56279 + buf.file = f.file;
56280
56281 error = vfs_readdir(f.file, filldir, &buf);
56282 if (error >= 0)
56283 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56284 struct getdents_callback64 {
56285 struct linux_dirent64 __user * current_dir;
56286 struct linux_dirent64 __user * previous;
56287 + struct file *file;
56288 int count;
56289 int error;
56290 };
56291 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56292 buf->error = -EINVAL; /* only used if we fail.. */
56293 if (reclen > buf->count)
56294 return -EINVAL;
56295 +
56296 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56297 + return 0;
56298 +
56299 dirent = buf->previous;
56300 if (dirent) {
56301 if (__put_user(offset, &dirent->d_off))
56302 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56303
56304 buf.current_dir = dirent;
56305 buf.previous = NULL;
56306 + buf.file = f.file;
56307 buf.count = count;
56308 buf.error = 0;
56309
56310 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56311 error = buf.error;
56312 lastdirent = buf.previous;
56313 if (lastdirent) {
56314 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56315 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56316 if (__put_user(d_off, &lastdirent->d_off))
56317 error = -EFAULT;
56318 else
56319 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56320 index 2b7882b..1c5ef48 100644
56321 --- a/fs/reiserfs/do_balan.c
56322 +++ b/fs/reiserfs/do_balan.c
56323 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56324 return;
56325 }
56326
56327 - atomic_inc(&(fs_generation(tb->tb_sb)));
56328 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56329 do_balance_starts(tb);
56330
56331 /* balance leaf returns 0 except if combining L R and S into
56332 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56333 index 9cc0740a..46bf953 100644
56334 --- a/fs/reiserfs/procfs.c
56335 +++ b/fs/reiserfs/procfs.c
56336 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56337 "SMALL_TAILS " : "NO_TAILS ",
56338 replay_only(sb) ? "REPLAY_ONLY " : "",
56339 convert_reiserfs(sb) ? "CONV " : "",
56340 - atomic_read(&r->s_generation_counter),
56341 + atomic_read_unchecked(&r->s_generation_counter),
56342 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56343 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56344 SF(s_good_search_by_key_reada), SF(s_bmaps),
56345 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56346 index 157e474..65a6114 100644
56347 --- a/fs/reiserfs/reiserfs.h
56348 +++ b/fs/reiserfs/reiserfs.h
56349 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56350 /* Comment? -Hans */
56351 wait_queue_head_t s_wait;
56352 /* To be obsoleted soon by per buffer seals.. -Hans */
56353 - atomic_t s_generation_counter; // increased by one every time the
56354 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56355 // tree gets re-balanced
56356 unsigned long s_properties; /* File system properties. Currently holds
56357 on-disk FS format */
56358 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56359 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56360
56361 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56362 -#define get_generation(s) atomic_read (&fs_generation(s))
56363 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56364 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56365 #define __fs_changed(gen,s) (gen != get_generation (s))
56366 #define fs_changed(gen,s) \
56367 diff --git a/fs/select.c b/fs/select.c
56368 index 8c1c96c..a0f9b6d 100644
56369 --- a/fs/select.c
56370 +++ b/fs/select.c
56371 @@ -20,6 +20,7 @@
56372 #include <linux/export.h>
56373 #include <linux/slab.h>
56374 #include <linux/poll.h>
56375 +#include <linux/security.h>
56376 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56377 #include <linux/file.h>
56378 #include <linux/fdtable.h>
56379 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56380 struct poll_list *walk = head;
56381 unsigned long todo = nfds;
56382
56383 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56384 if (nfds > rlimit(RLIMIT_NOFILE))
56385 return -EINVAL;
56386
56387 diff --git a/fs/seq_file.c b/fs/seq_file.c
56388 index 38bb59f..a304f9d 100644
56389 --- a/fs/seq_file.c
56390 +++ b/fs/seq_file.c
56391 @@ -10,6 +10,7 @@
56392 #include <linux/seq_file.h>
56393 #include <linux/slab.h>
56394 #include <linux/cred.h>
56395 +#include <linux/sched.h>
56396
56397 #include <asm/uaccess.h>
56398 #include <asm/page.h>
56399 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56400 #ifdef CONFIG_USER_NS
56401 p->user_ns = file->f_cred->user_ns;
56402 #endif
56403 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56404 + p->exec_id = current->exec_id;
56405 +#endif
56406
56407 /*
56408 * Wrappers around seq_open(e.g. swaps_open) need to be
56409 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56410 return 0;
56411 }
56412 if (!m->buf) {
56413 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56414 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56415 if (!m->buf)
56416 return -ENOMEM;
56417 }
56418 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56419 Eoverflow:
56420 m->op->stop(m, p);
56421 kfree(m->buf);
56422 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56423 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56424 return !m->buf ? -ENOMEM : -EAGAIN;
56425 }
56426
56427 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56428
56429 /* grab buffer if we didn't have one */
56430 if (!m->buf) {
56431 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56432 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56433 if (!m->buf)
56434 goto Enomem;
56435 }
56436 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56437 goto Fill;
56438 m->op->stop(m, p);
56439 kfree(m->buf);
56440 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56441 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56442 if (!m->buf)
56443 goto Enomem;
56444 m->count = 0;
56445 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56446 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56447 void *data)
56448 {
56449 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56450 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56451 int res = -ENOMEM;
56452
56453 if (op) {
56454 diff --git a/fs/splice.c b/fs/splice.c
56455 index 29e394e..b13c247 100644
56456 --- a/fs/splice.c
56457 +++ b/fs/splice.c
56458 @@ -195,7 +195,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56459 pipe_lock(pipe);
56460
56461 for (;;) {
56462 - if (!pipe->readers) {
56463 + if (!atomic_read(&pipe->readers)) {
56464 send_sig(SIGPIPE, current, 0);
56465 if (!ret)
56466 ret = -EPIPE;
56467 @@ -249,9 +249,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56468 do_wakeup = 0;
56469 }
56470
56471 - pipe->waiting_writers++;
56472 + atomic_inc(&pipe->waiting_writers);
56473 pipe_wait(pipe);
56474 - pipe->waiting_writers--;
56475 + atomic_dec(&pipe->waiting_writers);
56476 }
56477
56478 pipe_unlock(pipe);
56479 @@ -564,7 +564,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56480 old_fs = get_fs();
56481 set_fs(get_ds());
56482 /* The cast to a user pointer is valid due to the set_fs() */
56483 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56484 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56485 set_fs(old_fs);
56486
56487 return res;
56488 @@ -579,7 +579,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56489 old_fs = get_fs();
56490 set_fs(get_ds());
56491 /* The cast to a user pointer is valid due to the set_fs() */
56492 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
56493 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56494 set_fs(old_fs);
56495
56496 return res;
56497 @@ -632,7 +632,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56498 goto err;
56499
56500 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56501 - vec[i].iov_base = (void __user *) page_address(page);
56502 + vec[i].iov_base = (void __force_user *) page_address(page);
56503 vec[i].iov_len = this_len;
56504 spd.pages[i] = page;
56505 spd.nr_pages++;
56506 @@ -853,10 +853,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56507 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56508 {
56509 while (!pipe->nrbufs) {
56510 - if (!pipe->writers)
56511 + if (!atomic_read(&pipe->writers))
56512 return 0;
56513
56514 - if (!pipe->waiting_writers && sd->num_spliced)
56515 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56516 return 0;
56517
56518 if (sd->flags & SPLICE_F_NONBLOCK)
56519 @@ -1192,7 +1192,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56520 * out of the pipe right after the splice_to_pipe(). So set
56521 * PIPE_READERS appropriately.
56522 */
56523 - pipe->readers = 1;
56524 + atomic_set(&pipe->readers, 1);
56525
56526 current->splice_pipe = pipe;
56527 }
56528 @@ -1741,9 +1741,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56529 ret = -ERESTARTSYS;
56530 break;
56531 }
56532 - if (!pipe->writers)
56533 + if (!atomic_read(&pipe->writers))
56534 break;
56535 - if (!pipe->waiting_writers) {
56536 + if (!atomic_read(&pipe->waiting_writers)) {
56537 if (flags & SPLICE_F_NONBLOCK) {
56538 ret = -EAGAIN;
56539 break;
56540 @@ -1775,7 +1775,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56541 pipe_lock(pipe);
56542
56543 while (pipe->nrbufs >= pipe->buffers) {
56544 - if (!pipe->readers) {
56545 + if (!atomic_read(&pipe->readers)) {
56546 send_sig(SIGPIPE, current, 0);
56547 ret = -EPIPE;
56548 break;
56549 @@ -1788,9 +1788,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56550 ret = -ERESTARTSYS;
56551 break;
56552 }
56553 - pipe->waiting_writers++;
56554 + atomic_inc(&pipe->waiting_writers);
56555 pipe_wait(pipe);
56556 - pipe->waiting_writers--;
56557 + atomic_dec(&pipe->waiting_writers);
56558 }
56559
56560 pipe_unlock(pipe);
56561 @@ -1826,14 +1826,14 @@ retry:
56562 pipe_double_lock(ipipe, opipe);
56563
56564 do {
56565 - if (!opipe->readers) {
56566 + if (!atomic_read(&opipe->readers)) {
56567 send_sig(SIGPIPE, current, 0);
56568 if (!ret)
56569 ret = -EPIPE;
56570 break;
56571 }
56572
56573 - if (!ipipe->nrbufs && !ipipe->writers)
56574 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56575 break;
56576
56577 /*
56578 @@ -1930,7 +1930,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56579 pipe_double_lock(ipipe, opipe);
56580
56581 do {
56582 - if (!opipe->readers) {
56583 + if (!atomic_read(&opipe->readers)) {
56584 send_sig(SIGPIPE, current, 0);
56585 if (!ret)
56586 ret = -EPIPE;
56587 @@ -1975,7 +1975,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56588 * return EAGAIN if we have the potential of some data in the
56589 * future, otherwise just return 0
56590 */
56591 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56592 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56593 ret = -EAGAIN;
56594
56595 pipe_unlock(ipipe);
56596 diff --git a/fs/stat.c b/fs/stat.c
56597 index 04ce1ac..a13dd1e 100644
56598 --- a/fs/stat.c
56599 +++ b/fs/stat.c
56600 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56601 stat->gid = inode->i_gid;
56602 stat->rdev = inode->i_rdev;
56603 stat->size = i_size_read(inode);
56604 - stat->atime = inode->i_atime;
56605 - stat->mtime = inode->i_mtime;
56606 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56607 + stat->atime = inode->i_ctime;
56608 + stat->mtime = inode->i_ctime;
56609 + } else {
56610 + stat->atime = inode->i_atime;
56611 + stat->mtime = inode->i_mtime;
56612 + }
56613 stat->ctime = inode->i_ctime;
56614 stat->blksize = (1 << inode->i_blkbits);
56615 stat->blocks = inode->i_blocks;
56616 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
56617 if (retval)
56618 return retval;
56619
56620 - if (inode->i_op->getattr)
56621 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
56622 + if (inode->i_op->getattr) {
56623 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
56624 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56625 + stat->atime = stat->ctime;
56626 + stat->mtime = stat->ctime;
56627 + }
56628 + return retval;
56629 + }
56630
56631 generic_fillattr(inode, stat);
56632 return 0;
56633 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56634 index 15c68f9..36a8b3e 100644
56635 --- a/fs/sysfs/bin.c
56636 +++ b/fs/sysfs/bin.c
56637 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56638 return ret;
56639 }
56640
56641 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56642 - void *buf, int len, int write)
56643 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56644 + void *buf, size_t len, int write)
56645 {
56646 struct file *file = vma->vm_file;
56647 struct bin_buffer *bb = file->private_data;
56648 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56649 - int ret;
56650 + ssize_t ret;
56651
56652 if (!bb->vm_ops)
56653 return -EINVAL;
56654 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56655 index 6f31590..3c87c8a 100644
56656 --- a/fs/sysfs/dir.c
56657 +++ b/fs/sysfs/dir.c
56658 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56659 *
56660 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56661 */
56662 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56663 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56664 {
56665 unsigned long hash = init_name_hash();
56666 unsigned int len = strlen(name);
56667 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56668 struct sysfs_dirent *sd;
56669 int rc;
56670
56671 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56672 + const char *parent_name = parent_sd->s_name;
56673 +
56674 + mode = S_IFDIR | S_IRWXU;
56675 +
56676 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56677 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56678 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56679 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56680 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56681 +#endif
56682 +
56683 /* allocate */
56684 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56685 if (!sd)
56686 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56687 index 602f56d..6853db8 100644
56688 --- a/fs/sysfs/file.c
56689 +++ b/fs/sysfs/file.c
56690 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56691
56692 struct sysfs_open_dirent {
56693 atomic_t refcnt;
56694 - atomic_t event;
56695 + atomic_unchecked_t event;
56696 wait_queue_head_t poll;
56697 struct list_head buffers; /* goes through sysfs_buffer.list */
56698 };
56699 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56700 if (!sysfs_get_active(attr_sd))
56701 return -ENODEV;
56702
56703 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56704 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56705 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56706
56707 sysfs_put_active(attr_sd);
56708 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56709 return -ENOMEM;
56710
56711 atomic_set(&new_od->refcnt, 0);
56712 - atomic_set(&new_od->event, 1);
56713 + atomic_set_unchecked(&new_od->event, 1);
56714 init_waitqueue_head(&new_od->poll);
56715 INIT_LIST_HEAD(&new_od->buffers);
56716 goto retry;
56717 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56718
56719 sysfs_put_active(attr_sd);
56720
56721 - if (buffer->event != atomic_read(&od->event))
56722 + if (buffer->event != atomic_read_unchecked(&od->event))
56723 goto trigger;
56724
56725 return DEFAULT_POLLMASK;
56726 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56727
56728 od = sd->s_attr.open;
56729 if (od) {
56730 - atomic_inc(&od->event);
56731 + atomic_inc_unchecked(&od->event);
56732 wake_up_interruptible(&od->poll);
56733 }
56734
56735 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56736 index 8c940df..25b733e 100644
56737 --- a/fs/sysfs/symlink.c
56738 +++ b/fs/sysfs/symlink.c
56739 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56740
56741 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56742 {
56743 - char *page = nd_get_link(nd);
56744 + const char *page = nd_get_link(nd);
56745 if (!IS_ERR(page))
56746 free_page((unsigned long)page);
56747 }
56748 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56749 index 69d4889..a810bd4 100644
56750 --- a/fs/sysv/sysv.h
56751 +++ b/fs/sysv/sysv.h
56752 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56753 #endif
56754 }
56755
56756 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56757 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56758 {
56759 if (sbi->s_bytesex == BYTESEX_PDP)
56760 return PDP_swab((__force __u32)n);
56761 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56762 index e18b988..f1d4ad0f 100644
56763 --- a/fs/ubifs/io.c
56764 +++ b/fs/ubifs/io.c
56765 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56766 return err;
56767 }
56768
56769 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56770 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56771 {
56772 int err;
56773
56774 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56775 index c175b4d..8f36a16 100644
56776 --- a/fs/udf/misc.c
56777 +++ b/fs/udf/misc.c
56778 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56779
56780 u8 udf_tag_checksum(const struct tag *t)
56781 {
56782 - u8 *data = (u8 *)t;
56783 + const u8 *data = (const u8 *)t;
56784 u8 checksum = 0;
56785 int i;
56786 for (i = 0; i < sizeof(struct tag); ++i)
56787 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56788 index 8d974c4..b82f6ec 100644
56789 --- a/fs/ufs/swab.h
56790 +++ b/fs/ufs/swab.h
56791 @@ -22,7 +22,7 @@ enum {
56792 BYTESEX_BE
56793 };
56794
56795 -static inline u64
56796 +static inline u64 __intentional_overflow(-1)
56797 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56798 {
56799 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56800 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56801 return (__force __fs64)cpu_to_be64(n);
56802 }
56803
56804 -static inline u32
56805 +static inline u32 __intentional_overflow(-1)
56806 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56807 {
56808 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56809 diff --git a/fs/utimes.c b/fs/utimes.c
56810 index f4fb7ec..3fe03c0 100644
56811 --- a/fs/utimes.c
56812 +++ b/fs/utimes.c
56813 @@ -1,6 +1,7 @@
56814 #include <linux/compiler.h>
56815 #include <linux/file.h>
56816 #include <linux/fs.h>
56817 +#include <linux/security.h>
56818 #include <linux/linkage.h>
56819 #include <linux/mount.h>
56820 #include <linux/namei.h>
56821 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56822 goto mnt_drop_write_and_out;
56823 }
56824 }
56825 +
56826 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56827 + error = -EACCES;
56828 + goto mnt_drop_write_and_out;
56829 + }
56830 +
56831 mutex_lock(&inode->i_mutex);
56832 error = notify_change(path->dentry, &newattrs);
56833 mutex_unlock(&inode->i_mutex);
56834 diff --git a/fs/xattr.c b/fs/xattr.c
56835 index 3377dff..4d074d9 100644
56836 --- a/fs/xattr.c
56837 +++ b/fs/xattr.c
56838 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
56839 return rc;
56840 }
56841
56842 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
56843 +ssize_t
56844 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
56845 +{
56846 + struct inode *inode = dentry->d_inode;
56847 + ssize_t error;
56848 +
56849 + error = inode_permission(inode, MAY_EXEC);
56850 + if (error)
56851 + return error;
56852 +
56853 + if (inode->i_op->getxattr)
56854 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
56855 + else
56856 + error = -EOPNOTSUPP;
56857 +
56858 + return error;
56859 +}
56860 +EXPORT_SYMBOL(pax_getxattr);
56861 +#endif
56862 +
56863 ssize_t
56864 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
56865 {
56866 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56867 * Extended attribute SET operations
56868 */
56869 static long
56870 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56871 +setxattr(struct path *path, const char __user *name, const void __user *value,
56872 size_t size, int flags)
56873 {
56874 int error;
56875 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56876 posix_acl_fix_xattr_from_user(kvalue, size);
56877 }
56878
56879 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56880 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56881 + error = -EACCES;
56882 + goto out;
56883 + }
56884 +
56885 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56886 out:
56887 if (vvalue)
56888 vfree(vvalue);
56889 @@ -377,7 +403,7 @@ retry:
56890 return error;
56891 error = mnt_want_write(path.mnt);
56892 if (!error) {
56893 - error = setxattr(path.dentry, name, value, size, flags);
56894 + error = setxattr(&path, name, value, size, flags);
56895 mnt_drop_write(path.mnt);
56896 }
56897 path_put(&path);
56898 @@ -401,7 +427,7 @@ retry:
56899 return error;
56900 error = mnt_want_write(path.mnt);
56901 if (!error) {
56902 - error = setxattr(path.dentry, name, value, size, flags);
56903 + error = setxattr(&path, name, value, size, flags);
56904 mnt_drop_write(path.mnt);
56905 }
56906 path_put(&path);
56907 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56908 const void __user *,value, size_t, size, int, flags)
56909 {
56910 struct fd f = fdget(fd);
56911 - struct dentry *dentry;
56912 int error = -EBADF;
56913
56914 if (!f.file)
56915 return error;
56916 - dentry = f.file->f_path.dentry;
56917 - audit_inode(NULL, dentry, 0);
56918 + audit_inode(NULL, f.file->f_path.dentry, 0);
56919 error = mnt_want_write_file(f.file);
56920 if (!error) {
56921 - error = setxattr(dentry, name, value, size, flags);
56922 + error = setxattr(&f.file->f_path, name, value, size, flags);
56923 mnt_drop_write_file(f.file);
56924 }
56925 fdput(f);
56926 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56927 index 9fbea87..6b19972 100644
56928 --- a/fs/xattr_acl.c
56929 +++ b/fs/xattr_acl.c
56930 @@ -76,8 +76,8 @@ struct posix_acl *
56931 posix_acl_from_xattr(struct user_namespace *user_ns,
56932 const void *value, size_t size)
56933 {
56934 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56935 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56936 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56937 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56938 int count;
56939 struct posix_acl *acl;
56940 struct posix_acl_entry *acl_e;
56941 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56942 index b44af92..06073da 100644
56943 --- a/fs/xfs/xfs_bmap.c
56944 +++ b/fs/xfs/xfs_bmap.c
56945 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56946 int nmap,
56947 int ret_nmap);
56948 #else
56949 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56950 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56951 #endif /* DEBUG */
56952
56953 STATIC int
56954 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56955 index 1b9fc3e..e1bdde0 100644
56956 --- a/fs/xfs/xfs_dir2_sf.c
56957 +++ b/fs/xfs/xfs_dir2_sf.c
56958 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56959 }
56960
56961 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56962 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56963 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56964 + char name[sfep->namelen];
56965 + memcpy(name, sfep->name, sfep->namelen);
56966 + if (filldir(dirent, name, sfep->namelen,
56967 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56968 + *offset = off & 0x7fffffff;
56969 + return 0;
56970 + }
56971 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56972 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56973 *offset = off & 0x7fffffff;
56974 return 0;
56975 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56976 index d681e34..2a3f5ab 100644
56977 --- a/fs/xfs/xfs_ioctl.c
56978 +++ b/fs/xfs/xfs_ioctl.c
56979 @@ -127,7 +127,7 @@ xfs_find_handle(
56980 }
56981
56982 error = -EFAULT;
56983 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56984 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56985 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56986 goto out_put;
56987
56988 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56989 index ca9ecaa..60100c7 100644
56990 --- a/fs/xfs/xfs_iops.c
56991 +++ b/fs/xfs/xfs_iops.c
56992 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56993 struct nameidata *nd,
56994 void *p)
56995 {
56996 - char *s = nd_get_link(nd);
56997 + const char *s = nd_get_link(nd);
56998
56999 if (!IS_ERR(s))
57000 kfree(s);
57001 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57002 new file mode 100644
57003 index 0000000..4fb1dde
57004 --- /dev/null
57005 +++ b/grsecurity/Kconfig
57006 @@ -0,0 +1,1053 @@
57007 +#
57008 +# grecurity configuration
57009 +#
57010 +menu "Memory Protections"
57011 +depends on GRKERNSEC
57012 +
57013 +config GRKERNSEC_KMEM
57014 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57015 + default y if GRKERNSEC_CONFIG_AUTO
57016 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57017 + help
57018 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57019 + be written to or read from to modify or leak the contents of the running
57020 + kernel. /dev/port will also not be allowed to be opened and support
57021 + for /dev/cpu/*/msr will be removed. If you have module
57022 + support disabled, enabling this will close up five ways that are
57023 + currently used to insert malicious code into the running kernel.
57024 +
57025 + Even with all these features enabled, we still highly recommend that
57026 + you use the RBAC system, as it is still possible for an attacker to
57027 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57028 +
57029 + If you are not using XFree86, you may be able to stop this additional
57030 + case by enabling the 'Disable privileged I/O' option. Though nothing
57031 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57032 + but only to video memory, which is the only writing we allow in this
57033 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57034 + not be allowed to mprotect it with PROT_WRITE later.
57035 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57036 + from working.
57037 +
57038 + It is highly recommended that you say Y here if you meet all the
57039 + conditions above.
57040 +
57041 +config GRKERNSEC_VM86
57042 + bool "Restrict VM86 mode"
57043 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57044 + depends on X86_32
57045 +
57046 + help
57047 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57048 + make use of a special execution mode on 32bit x86 processors called
57049 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57050 + video cards and will still work with this option enabled. The purpose
57051 + of the option is to prevent exploitation of emulation errors in
57052 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57053 + Nearly all users should be able to enable this option.
57054 +
57055 +config GRKERNSEC_IO
57056 + bool "Disable privileged I/O"
57057 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57058 + depends on X86
57059 + select RTC_CLASS
57060 + select RTC_INTF_DEV
57061 + select RTC_DRV_CMOS
57062 +
57063 + help
57064 + If you say Y here, all ioperm and iopl calls will return an error.
57065 + Ioperm and iopl can be used to modify the running kernel.
57066 + Unfortunately, some programs need this access to operate properly,
57067 + the most notable of which are XFree86 and hwclock. hwclock can be
57068 + remedied by having RTC support in the kernel, so real-time
57069 + clock support is enabled if this option is enabled, to ensure
57070 + that hwclock operates correctly. XFree86 still will not
57071 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57072 + IF YOU USE XFree86. If you use XFree86 and you still want to
57073 + protect your kernel against modification, use the RBAC system.
57074 +
57075 +config GRKERNSEC_JIT_HARDEN
57076 + bool "Harden BPF JIT against spray attacks"
57077 + default y if GRKERNSEC_CONFIG_AUTO
57078 + depends on BPF_JIT
57079 + help
57080 + If you say Y here, the native code generated by the kernel's Berkeley
57081 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57082 + attacks that attempt to fit attacker-beneficial instructions in
57083 + 32bit immediate fields of JIT-generated native instructions. The
57084 + attacker will generally aim to cause an unintended instruction sequence
57085 + of JIT-generated native code to execute by jumping into the middle of
57086 + a generated instruction. This feature effectively randomizes the 32bit
57087 + immediate constants present in the generated code to thwart such attacks.
57088 +
57089 + If you're using KERNEXEC, it's recommended that you enable this option
57090 + to supplement the hardening of the kernel.
57091 +
57092 +config GRKERNSEC_PERF_HARDEN
57093 + bool "Disable unprivileged PERF_EVENTS usage by default"
57094 + default y if GRKERNSEC_CONFIG_AUTO
57095 + depends on PERF_EVENTS
57096 + help
57097 + If you say Y here, the range of acceptable values for the
57098 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
57099 + default to a new value: 3. When the sysctl is set to this value, no
57100 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
57101 +
57102 + Though PERF_EVENTS can be used legitimately for performance monitoring
57103 + and low-level application profiling, it is forced on regardless of
57104 + configuration, has been at fault for several vulnerabilities, and
57105 + creates new opportunities for side channels and other information leaks.
57106 +
57107 + This feature puts PERF_EVENTS into a secure default state and permits
57108 + the administrator to change out of it temporarily if unprivileged
57109 + application profiling is needed.
57110 +
57111 +config GRKERNSEC_RAND_THREADSTACK
57112 + bool "Insert random gaps between thread stacks"
57113 + default y if GRKERNSEC_CONFIG_AUTO
57114 + depends on PAX_RANDMMAP && !PPC
57115 + help
57116 + If you say Y here, a random-sized gap will be enforced between allocated
57117 + thread stacks. Glibc's NPTL and other threading libraries that
57118 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57119 + The implementation currently provides 8 bits of entropy for the gap.
57120 +
57121 + Many distributions do not compile threaded remote services with the
57122 + -fstack-check argument to GCC, causing the variable-sized stack-based
57123 + allocator, alloca(), to not probe the stack on allocation. This
57124 + permits an unbounded alloca() to skip over any guard page and potentially
57125 + modify another thread's stack reliably. An enforced random gap
57126 + reduces the reliability of such an attack and increases the chance
57127 + that such a read/write to another thread's stack instead lands in
57128 + an unmapped area, causing a crash and triggering grsecurity's
57129 + anti-bruteforcing logic.
57130 +
57131 +config GRKERNSEC_PROC_MEMMAP
57132 + bool "Harden ASLR against information leaks and entropy reduction"
57133 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57134 + depends on PAX_NOEXEC || PAX_ASLR
57135 + help
57136 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57137 + give no information about the addresses of its mappings if
57138 + PaX features that rely on random addresses are enabled on the task.
57139 + In addition to sanitizing this information and disabling other
57140 + dangerous sources of information, this option causes reads of sensitive
57141 + /proc/<pid> entries where the file descriptor was opened in a different
57142 + task than the one performing the read. Such attempts are logged.
57143 + This option also limits argv/env strings for suid/sgid binaries
57144 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57145 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57146 + binaries to prevent alternative mmap layouts from being abused.
57147 +
57148 + If you use PaX it is essential that you say Y here as it closes up
57149 + several holes that make full ASLR useless locally.
57150 +
57151 +config GRKERNSEC_BRUTE
57152 + bool "Deter exploit bruteforcing"
57153 + default y if GRKERNSEC_CONFIG_AUTO
57154 + help
57155 + If you say Y here, attempts to bruteforce exploits against forking
57156 + daemons such as apache or sshd, as well as against suid/sgid binaries
57157 + will be deterred. When a child of a forking daemon is killed by PaX
57158 + or crashes due to an illegal instruction or other suspicious signal,
57159 + the parent process will be delayed 30 seconds upon every subsequent
57160 + fork until the administrator is able to assess the situation and
57161 + restart the daemon.
57162 + In the suid/sgid case, the attempt is logged, the user has all their
57163 + processes terminated, and they are prevented from executing any further
57164 + processes for 15 minutes.
57165 + It is recommended that you also enable signal logging in the auditing
57166 + section so that logs are generated when a process triggers a suspicious
57167 + signal.
57168 + If the sysctl option is enabled, a sysctl option with name
57169 + "deter_bruteforce" is created.
57170 +
57171 +
57172 +config GRKERNSEC_MODHARDEN
57173 + bool "Harden module auto-loading"
57174 + default y if GRKERNSEC_CONFIG_AUTO
57175 + depends on MODULES
57176 + help
57177 + If you say Y here, module auto-loading in response to use of some
57178 + feature implemented by an unloaded module will be restricted to
57179 + root users. Enabling this option helps defend against attacks
57180 + by unprivileged users who abuse the auto-loading behavior to
57181 + cause a vulnerable module to load that is then exploited.
57182 +
57183 + If this option prevents a legitimate use of auto-loading for a
57184 + non-root user, the administrator can execute modprobe manually
57185 + with the exact name of the module mentioned in the alert log.
57186 + Alternatively, the administrator can add the module to the list
57187 + of modules loaded at boot by modifying init scripts.
57188 +
57189 + Modification of init scripts will most likely be needed on
57190 + Ubuntu servers with encrypted home directory support enabled,
57191 + as the first non-root user logging in will cause the ecb(aes),
57192 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57193 +
57194 +config GRKERNSEC_HIDESYM
57195 + bool "Hide kernel symbols"
57196 + default y if GRKERNSEC_CONFIG_AUTO
57197 + select PAX_USERCOPY_SLABS
57198 + help
57199 + If you say Y here, getting information on loaded modules, and
57200 + displaying all kernel symbols through a syscall will be restricted
57201 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57202 + /proc/kallsyms will be restricted to the root user. The RBAC
57203 + system can hide that entry even from root.
57204 +
57205 + This option also prevents leaking of kernel addresses through
57206 + several /proc entries.
57207 +
57208 + Note that this option is only effective provided the following
57209 + conditions are met:
57210 + 1) The kernel using grsecurity is not precompiled by some distribution
57211 + 2) You have also enabled GRKERNSEC_DMESG
57212 + 3) You are using the RBAC system and hiding other files such as your
57213 + kernel image and System.map. Alternatively, enabling this option
57214 + causes the permissions on /boot, /lib/modules, and the kernel
57215 + source directory to change at compile time to prevent
57216 + reading by non-root users.
57217 + If the above conditions are met, this option will aid in providing a
57218 + useful protection against local kernel exploitation of overflows
57219 + and arbitrary read/write vulnerabilities.
57220 +
57221 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
57222 + in addition to this feature.
57223 +
57224 +config GRKERNSEC_KERN_LOCKOUT
57225 + bool "Active kernel exploit response"
57226 + default y if GRKERNSEC_CONFIG_AUTO
57227 + depends on X86 || ARM || PPC || SPARC
57228 + help
57229 + If you say Y here, when a PaX alert is triggered due to suspicious
57230 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57231 + or an OOPS occurs due to bad memory accesses, instead of just
57232 + terminating the offending process (and potentially allowing
57233 + a subsequent exploit from the same user), we will take one of two
57234 + actions:
57235 + If the user was root, we will panic the system
57236 + If the user was non-root, we will log the attempt, terminate
57237 + all processes owned by the user, then prevent them from creating
57238 + any new processes until the system is restarted
57239 + This deters repeated kernel exploitation/bruteforcing attempts
57240 + and is useful for later forensics.
57241 +
57242 +endmenu
57243 +menu "Role Based Access Control Options"
57244 +depends on GRKERNSEC
57245 +
57246 +config GRKERNSEC_RBAC_DEBUG
57247 + bool
57248 +
57249 +config GRKERNSEC_NO_RBAC
57250 + bool "Disable RBAC system"
57251 + help
57252 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57253 + preventing the RBAC system from being enabled. You should only say Y
57254 + here if you have no intention of using the RBAC system, so as to prevent
57255 + an attacker with root access from misusing the RBAC system to hide files
57256 + and processes when loadable module support and /dev/[k]mem have been
57257 + locked down.
57258 +
57259 +config GRKERNSEC_ACL_HIDEKERN
57260 + bool "Hide kernel processes"
57261 + help
57262 + If you say Y here, all kernel threads will be hidden to all
57263 + processes but those whose subject has the "view hidden processes"
57264 + flag.
57265 +
57266 +config GRKERNSEC_ACL_MAXTRIES
57267 + int "Maximum tries before password lockout"
57268 + default 3
57269 + help
57270 + This option enforces the maximum number of times a user can attempt
57271 + to authorize themselves with the grsecurity RBAC system before being
57272 + denied the ability to attempt authorization again for a specified time.
57273 + The lower the number, the harder it will be to brute-force a password.
57274 +
57275 +config GRKERNSEC_ACL_TIMEOUT
57276 + int "Time to wait after max password tries, in seconds"
57277 + default 30
57278 + help
57279 + This option specifies the time the user must wait after attempting to
57280 + authorize to the RBAC system with the maximum number of invalid
57281 + passwords. The higher the number, the harder it will be to brute-force
57282 + a password.
57283 +
57284 +endmenu
57285 +menu "Filesystem Protections"
57286 +depends on GRKERNSEC
57287 +
57288 +config GRKERNSEC_PROC
57289 + bool "Proc restrictions"
57290 + default y if GRKERNSEC_CONFIG_AUTO
57291 + help
57292 + If you say Y here, the permissions of the /proc filesystem
57293 + will be altered to enhance system security and privacy. You MUST
57294 + choose either a user only restriction or a user and group restriction.
57295 + Depending upon the option you choose, you can either restrict users to
57296 + see only the processes they themselves run, or choose a group that can
57297 + view all processes and files normally restricted to root if you choose
57298 + the "restrict to user only" option. NOTE: If you're running identd or
57299 + ntpd as a non-root user, you will have to run it as the group you
57300 + specify here.
57301 +
57302 +config GRKERNSEC_PROC_USER
57303 + bool "Restrict /proc to user only"
57304 + depends on GRKERNSEC_PROC
57305 + help
57306 + If you say Y here, non-root users will only be able to view their own
57307 + processes, and restricts them from viewing network-related information,
57308 + and viewing kernel symbol and module information.
57309 +
57310 +config GRKERNSEC_PROC_USERGROUP
57311 + bool "Allow special group"
57312 + default y if GRKERNSEC_CONFIG_AUTO
57313 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57314 + help
57315 + If you say Y here, you will be able to select a group that will be
57316 + able to view all processes and network-related information. If you've
57317 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57318 + remain hidden. This option is useful if you want to run identd as
57319 + a non-root user. The group you select may also be chosen at boot time
57320 + via "grsec_proc_gid=" on the kernel commandline.
57321 +
57322 +config GRKERNSEC_PROC_GID
57323 + int "GID for special group"
57324 + depends on GRKERNSEC_PROC_USERGROUP
57325 + default 1001
57326 +
57327 +config GRKERNSEC_PROC_ADD
57328 + bool "Additional restrictions"
57329 + default y if GRKERNSEC_CONFIG_AUTO
57330 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57331 + help
57332 + If you say Y here, additional restrictions will be placed on
57333 + /proc that keep normal users from viewing device information and
57334 + slabinfo information that could be useful for exploits.
57335 +
57336 +config GRKERNSEC_LINK
57337 + bool "Linking restrictions"
57338 + default y if GRKERNSEC_CONFIG_AUTO
57339 + help
57340 + If you say Y here, /tmp race exploits will be prevented, since users
57341 + will no longer be able to follow symlinks owned by other users in
57342 + world-writable +t directories (e.g. /tmp), unless the owner of the
57343 + symlink is the owner of the directory. users will also not be
57344 + able to hardlink to files they do not own. If the sysctl option is
57345 + enabled, a sysctl option with name "linking_restrictions" is created.
57346 +
57347 +config GRKERNSEC_SYMLINKOWN
57348 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57349 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57350 + help
57351 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57352 + that prevents it from being used as a security feature. As Apache
57353 + verifies the symlink by performing a stat() against the target of
57354 + the symlink before it is followed, an attacker can setup a symlink
57355 + to point to a same-owned file, then replace the symlink with one
57356 + that targets another user's file just after Apache "validates" the
57357 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57358 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57359 + will be in place for the group you specify. If the sysctl option
57360 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57361 + created.
57362 +
57363 +config GRKERNSEC_SYMLINKOWN_GID
57364 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57365 + depends on GRKERNSEC_SYMLINKOWN
57366 + default 1006
57367 + help
57368 + Setting this GID determines what group kernel-enforced
57369 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57370 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57371 +
57372 +config GRKERNSEC_FIFO
57373 + bool "FIFO restrictions"
57374 + default y if GRKERNSEC_CONFIG_AUTO
57375 + help
57376 + If you say Y here, users will not be able to write to FIFOs they don't
57377 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57378 + the FIFO is the same owner of the directory it's held in. If the sysctl
57379 + option is enabled, a sysctl option with name "fifo_restrictions" is
57380 + created.
57381 +
57382 +config GRKERNSEC_SYSFS_RESTRICT
57383 + bool "Sysfs/debugfs restriction"
57384 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57385 + depends on SYSFS
57386 + help
57387 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57388 + any filesystem normally mounted under it (e.g. debugfs) will be
57389 + mostly accessible only by root. These filesystems generally provide access
57390 + to hardware and debug information that isn't appropriate for unprivileged
57391 + users of the system. Sysfs and debugfs have also become a large source
57392 + of new vulnerabilities, ranging from infoleaks to local compromise.
57393 + There has been very little oversight with an eye toward security involved
57394 + in adding new exporters of information to these filesystems, so their
57395 + use is discouraged.
57396 + For reasons of compatibility, a few directories have been whitelisted
57397 + for access by non-root users:
57398 + /sys/fs/selinux
57399 + /sys/fs/fuse
57400 + /sys/devices/system/cpu
57401 +
57402 +config GRKERNSEC_ROFS
57403 + bool "Runtime read-only mount protection"
57404 + help
57405 + If you say Y here, a sysctl option with name "romount_protect" will
57406 + be created. By setting this option to 1 at runtime, filesystems
57407 + will be protected in the following ways:
57408 + * No new writable mounts will be allowed
57409 + * Existing read-only mounts won't be able to be remounted read/write
57410 + * Write operations will be denied on all block devices
57411 + This option acts independently of grsec_lock: once it is set to 1,
57412 + it cannot be turned off. Therefore, please be mindful of the resulting
57413 + behavior if this option is enabled in an init script on a read-only
57414 + filesystem. This feature is mainly intended for secure embedded systems.
57415 +
57416 +config GRKERNSEC_DEVICE_SIDECHANNEL
57417 + bool "Eliminate stat/notify-based device sidechannels"
57418 + default y if GRKERNSEC_CONFIG_AUTO
57419 + help
57420 + If you say Y here, timing analyses on block or character
57421 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57422 + will be thwarted for unprivileged users. If a process without
57423 + CAP_MKNOD stats such a device, the last access and last modify times
57424 + will match the device's create time. No access or modify events
57425 + will be triggered through inotify/dnotify/fanotify for such devices.
57426 + This feature will prevent attacks that may at a minimum
57427 + allow an attacker to determine the administrator's password length.
57428 +
57429 +config GRKERNSEC_CHROOT
57430 + bool "Chroot jail restrictions"
57431 + default y if GRKERNSEC_CONFIG_AUTO
57432 + help
57433 + If you say Y here, you will be able to choose several options that will
57434 + make breaking out of a chrooted jail much more difficult. If you
57435 + encounter no software incompatibilities with the following options, it
57436 + is recommended that you enable each one.
57437 +
57438 +config GRKERNSEC_CHROOT_MOUNT
57439 + bool "Deny mounts"
57440 + default y if GRKERNSEC_CONFIG_AUTO
57441 + depends on GRKERNSEC_CHROOT
57442 + help
57443 + If you say Y here, processes inside a chroot will not be able to
57444 + mount or remount filesystems. If the sysctl option is enabled, a
57445 + sysctl option with name "chroot_deny_mount" is created.
57446 +
57447 +config GRKERNSEC_CHROOT_DOUBLE
57448 + bool "Deny double-chroots"
57449 + default y if GRKERNSEC_CONFIG_AUTO
57450 + depends on GRKERNSEC_CHROOT
57451 + help
57452 + If you say Y here, processes inside a chroot will not be able to chroot
57453 + again outside the chroot. This is a widely used method of breaking
57454 + out of a chroot jail and should not be allowed. If the sysctl
57455 + option is enabled, a sysctl option with name
57456 + "chroot_deny_chroot" is created.
57457 +
57458 +config GRKERNSEC_CHROOT_PIVOT
57459 + bool "Deny pivot_root in chroot"
57460 + default y if GRKERNSEC_CONFIG_AUTO
57461 + depends on GRKERNSEC_CHROOT
57462 + help
57463 + If you say Y here, processes inside a chroot will not be able to use
57464 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57465 + works similar to chroot in that it changes the root filesystem. This
57466 + function could be misused in a chrooted process to attempt to break out
57467 + of the chroot, and therefore should not be allowed. If the sysctl
57468 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57469 + created.
57470 +
57471 +config GRKERNSEC_CHROOT_CHDIR
57472 + bool "Enforce chdir(\"/\") on all chroots"
57473 + default y if GRKERNSEC_CONFIG_AUTO
57474 + depends on GRKERNSEC_CHROOT
57475 + help
57476 + If you say Y here, the current working directory of all newly-chrooted
57477 + applications will be set to the the root directory of the chroot.
57478 + The man page on chroot(2) states:
57479 + Note that this call does not change the current working
57480 + directory, so that `.' can be outside the tree rooted at
57481 + `/'. In particular, the super-user can escape from a
57482 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57483 +
57484 + It is recommended that you say Y here, since it's not known to break
57485 + any software. If the sysctl option is enabled, a sysctl option with
57486 + name "chroot_enforce_chdir" is created.
57487 +
57488 +config GRKERNSEC_CHROOT_CHMOD
57489 + bool "Deny (f)chmod +s"
57490 + default y if GRKERNSEC_CONFIG_AUTO
57491 + depends on GRKERNSEC_CHROOT
57492 + help
57493 + If you say Y here, processes inside a chroot will not be able to chmod
57494 + or fchmod files to make them have suid or sgid bits. This protects
57495 + against another published method of breaking a chroot. If the sysctl
57496 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57497 + created.
57498 +
57499 +config GRKERNSEC_CHROOT_FCHDIR
57500 + bool "Deny fchdir out of chroot"
57501 + default y if GRKERNSEC_CONFIG_AUTO
57502 + depends on GRKERNSEC_CHROOT
57503 + help
57504 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57505 + to a file descriptor of the chrooting process that points to a directory
57506 + outside the filesystem will be stopped. If the sysctl option
57507 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57508 +
57509 +config GRKERNSEC_CHROOT_MKNOD
57510 + bool "Deny mknod"
57511 + default y if GRKERNSEC_CONFIG_AUTO
57512 + depends on GRKERNSEC_CHROOT
57513 + help
57514 + If you say Y here, processes inside a chroot will not be allowed to
57515 + mknod. The problem with using mknod inside a chroot is that it
57516 + would allow an attacker to create a device entry that is the same
57517 + as one on the physical root of your system, which could range from
57518 + anything from the console device to a device for your harddrive (which
57519 + they could then use to wipe the drive or steal data). It is recommended
57520 + that you say Y here, unless you run into software incompatibilities.
57521 + If the sysctl option is enabled, a sysctl option with name
57522 + "chroot_deny_mknod" is created.
57523 +
57524 +config GRKERNSEC_CHROOT_SHMAT
57525 + bool "Deny shmat() out of chroot"
57526 + default y if GRKERNSEC_CONFIG_AUTO
57527 + depends on GRKERNSEC_CHROOT
57528 + help
57529 + If you say Y here, processes inside a chroot will not be able to attach
57530 + to shared memory segments that were created outside of the chroot jail.
57531 + It is recommended that you say Y here. If the sysctl option is enabled,
57532 + a sysctl option with name "chroot_deny_shmat" is created.
57533 +
57534 +config GRKERNSEC_CHROOT_UNIX
57535 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57536 + default y if GRKERNSEC_CONFIG_AUTO
57537 + depends on GRKERNSEC_CHROOT
57538 + help
57539 + If you say Y here, processes inside a chroot will not be able to
57540 + connect to abstract (meaning not belonging to a filesystem) Unix
57541 + domain sockets that were bound outside of a chroot. It is recommended
57542 + that you say Y here. If the sysctl option is enabled, a sysctl option
57543 + with name "chroot_deny_unix" is created.
57544 +
57545 +config GRKERNSEC_CHROOT_FINDTASK
57546 + bool "Protect outside processes"
57547 + default y if GRKERNSEC_CONFIG_AUTO
57548 + depends on GRKERNSEC_CHROOT
57549 + help
57550 + If you say Y here, processes inside a chroot will not be able to
57551 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57552 + getsid, or view any process outside of the chroot. If the sysctl
57553 + option is enabled, a sysctl option with name "chroot_findtask" is
57554 + created.
57555 +
57556 +config GRKERNSEC_CHROOT_NICE
57557 + bool "Restrict priority changes"
57558 + default y if GRKERNSEC_CONFIG_AUTO
57559 + depends on GRKERNSEC_CHROOT
57560 + help
57561 + If you say Y here, processes inside a chroot will not be able to raise
57562 + the priority of processes in the chroot, or alter the priority of
57563 + processes outside the chroot. This provides more security than simply
57564 + removing CAP_SYS_NICE from the process' capability set. If the
57565 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57566 + is created.
57567 +
57568 +config GRKERNSEC_CHROOT_SYSCTL
57569 + bool "Deny sysctl writes"
57570 + default y if GRKERNSEC_CONFIG_AUTO
57571 + depends on GRKERNSEC_CHROOT
57572 + help
57573 + If you say Y here, an attacker in a chroot will not be able to
57574 + write to sysctl entries, either by sysctl(2) or through a /proc
57575 + interface. It is strongly recommended that you say Y here. If the
57576 + sysctl option is enabled, a sysctl option with name
57577 + "chroot_deny_sysctl" is created.
57578 +
57579 +config GRKERNSEC_CHROOT_CAPS
57580 + bool "Capability restrictions"
57581 + default y if GRKERNSEC_CONFIG_AUTO
57582 + depends on GRKERNSEC_CHROOT
57583 + help
57584 + If you say Y here, the capabilities on all processes within a
57585 + chroot jail will be lowered to stop module insertion, raw i/o,
57586 + system and net admin tasks, rebooting the system, modifying immutable
57587 + files, modifying IPC owned by another, and changing the system time.
57588 + This is left an option because it can break some apps. Disable this
57589 + if your chrooted apps are having problems performing those kinds of
57590 + tasks. If the sysctl option is enabled, a sysctl option with
57591 + name "chroot_caps" is created.
57592 +
57593 +config GRKERNSEC_CHROOT_INITRD
57594 + bool "Exempt initrd tasks from restrictions"
57595 + default y if GRKERNSEC_CONFIG_AUTO
57596 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57597 + help
57598 + If you say Y here, tasks started prior to init will be exempted from
57599 + grsecurity's chroot restrictions. This option is mainly meant to
57600 + resolve Plymouth's performing privileged operations unnecessarily
57601 + in a chroot.
57602 +
57603 +endmenu
57604 +menu "Kernel Auditing"
57605 +depends on GRKERNSEC
57606 +
57607 +config GRKERNSEC_AUDIT_GROUP
57608 + bool "Single group for auditing"
57609 + help
57610 + If you say Y here, the exec and chdir logging features will only operate
57611 + on a group you specify. This option is recommended if you only want to
57612 + watch certain users instead of having a large amount of logs from the
57613 + entire system. If the sysctl option is enabled, a sysctl option with
57614 + name "audit_group" is created.
57615 +
57616 +config GRKERNSEC_AUDIT_GID
57617 + int "GID for auditing"
57618 + depends on GRKERNSEC_AUDIT_GROUP
57619 + default 1007
57620 +
57621 +config GRKERNSEC_EXECLOG
57622 + bool "Exec logging"
57623 + help
57624 + If you say Y here, all execve() calls will be logged (since the
57625 + other exec*() calls are frontends to execve(), all execution
57626 + will be logged). Useful for shell-servers that like to keep track
57627 + of their users. If the sysctl option is enabled, a sysctl option with
57628 + name "exec_logging" is created.
57629 + WARNING: This option when enabled will produce a LOT of logs, especially
57630 + on an active system.
57631 +
57632 +config GRKERNSEC_RESLOG
57633 + bool "Resource logging"
57634 + default y if GRKERNSEC_CONFIG_AUTO
57635 + help
57636 + If you say Y here, all attempts to overstep resource limits will
57637 + be logged with the resource name, the requested size, and the current
57638 + limit. It is highly recommended that you say Y here. If the sysctl
57639 + option is enabled, a sysctl option with name "resource_logging" is
57640 + created. If the RBAC system is enabled, the sysctl value is ignored.
57641 +
57642 +config GRKERNSEC_CHROOT_EXECLOG
57643 + bool "Log execs within chroot"
57644 + help
57645 + If you say Y here, all executions inside a chroot jail will be logged
57646 + to syslog. This can cause a large amount of logs if certain
57647 + applications (eg. djb's daemontools) are installed on the system, and
57648 + is therefore left as an option. If the sysctl option is enabled, a
57649 + sysctl option with name "chroot_execlog" is created.
57650 +
57651 +config GRKERNSEC_AUDIT_PTRACE
57652 + bool "Ptrace logging"
57653 + help
57654 + If you say Y here, all attempts to attach to a process via ptrace
57655 + will be logged. If the sysctl option is enabled, a sysctl option
57656 + with name "audit_ptrace" is created.
57657 +
57658 +config GRKERNSEC_AUDIT_CHDIR
57659 + bool "Chdir logging"
57660 + help
57661 + If you say Y here, all chdir() calls will be logged. If the sysctl
57662 + option is enabled, a sysctl option with name "audit_chdir" is created.
57663 +
57664 +config GRKERNSEC_AUDIT_MOUNT
57665 + bool "(Un)Mount logging"
57666 + help
57667 + If you say Y here, all mounts and unmounts will be logged. If the
57668 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57669 + created.
57670 +
57671 +config GRKERNSEC_SIGNAL
57672 + bool "Signal logging"
57673 + default y if GRKERNSEC_CONFIG_AUTO
57674 + help
57675 + If you say Y here, certain important signals will be logged, such as
57676 + SIGSEGV, which will as a result inform you of when a error in a program
57677 + occurred, which in some cases could mean a possible exploit attempt.
57678 + If the sysctl option is enabled, a sysctl option with name
57679 + "signal_logging" is created.
57680 +
57681 +config GRKERNSEC_FORKFAIL
57682 + bool "Fork failure logging"
57683 + help
57684 + If you say Y here, all failed fork() attempts will be logged.
57685 + This could suggest a fork bomb, or someone attempting to overstep
57686 + their process limit. If the sysctl option is enabled, a sysctl option
57687 + with name "forkfail_logging" is created.
57688 +
57689 +config GRKERNSEC_TIME
57690 + bool "Time change logging"
57691 + default y if GRKERNSEC_CONFIG_AUTO
57692 + help
57693 + If you say Y here, any changes of the system clock will be logged.
57694 + If the sysctl option is enabled, a sysctl option with name
57695 + "timechange_logging" is created.
57696 +
57697 +config GRKERNSEC_PROC_IPADDR
57698 + bool "/proc/<pid>/ipaddr support"
57699 + default y if GRKERNSEC_CONFIG_AUTO
57700 + help
57701 + If you say Y here, a new entry will be added to each /proc/<pid>
57702 + directory that contains the IP address of the person using the task.
57703 + The IP is carried across local TCP and AF_UNIX stream sockets.
57704 + This information can be useful for IDS/IPSes to perform remote response
57705 + to a local attack. The entry is readable by only the owner of the
57706 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57707 + the RBAC system), and thus does not create privacy concerns.
57708 +
57709 +config GRKERNSEC_RWXMAP_LOG
57710 + bool 'Denied RWX mmap/mprotect logging'
57711 + default y if GRKERNSEC_CONFIG_AUTO
57712 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57713 + help
57714 + If you say Y here, calls to mmap() and mprotect() with explicit
57715 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57716 + denied by the PAX_MPROTECT feature. If the sysctl option is
57717 + enabled, a sysctl option with name "rwxmap_logging" is created.
57718 +
57719 +config GRKERNSEC_AUDIT_TEXTREL
57720 + bool 'ELF text relocations logging (READ HELP)'
57721 + depends on PAX_MPROTECT
57722 + help
57723 + If you say Y here, text relocations will be logged with the filename
57724 + of the offending library or binary. The purpose of the feature is
57725 + to help Linux distribution developers get rid of libraries and
57726 + binaries that need text relocations which hinder the future progress
57727 + of PaX. Only Linux distribution developers should say Y here, and
57728 + never on a production machine, as this option creates an information
57729 + leak that could aid an attacker in defeating the randomization of
57730 + a single memory region. If the sysctl option is enabled, a sysctl
57731 + option with name "audit_textrel" is created.
57732 +
57733 +endmenu
57734 +
57735 +menu "Executable Protections"
57736 +depends on GRKERNSEC
57737 +
57738 +config GRKERNSEC_DMESG
57739 + bool "Dmesg(8) restriction"
57740 + default y if GRKERNSEC_CONFIG_AUTO
57741 + help
57742 + If you say Y here, non-root users will not be able to use dmesg(8)
57743 + to view the contents of the kernel's circular log buffer.
57744 + The kernel's log buffer often contains kernel addresses and other
57745 + identifying information useful to an attacker in fingerprinting a
57746 + system for a targeted exploit.
57747 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57748 + created.
57749 +
57750 +config GRKERNSEC_HARDEN_PTRACE
57751 + bool "Deter ptrace-based process snooping"
57752 + default y if GRKERNSEC_CONFIG_AUTO
57753 + help
57754 + If you say Y here, TTY sniffers and other malicious monitoring
57755 + programs implemented through ptrace will be defeated. If you
57756 + have been using the RBAC system, this option has already been
57757 + enabled for several years for all users, with the ability to make
57758 + fine-grained exceptions.
57759 +
57760 + This option only affects the ability of non-root users to ptrace
57761 + processes that are not a descendent of the ptracing process.
57762 + This means that strace ./binary and gdb ./binary will still work,
57763 + but attaching to arbitrary processes will not. If the sysctl
57764 + option is enabled, a sysctl option with name "harden_ptrace" is
57765 + created.
57766 +
57767 +config GRKERNSEC_PTRACE_READEXEC
57768 + bool "Require read access to ptrace sensitive binaries"
57769 + default y if GRKERNSEC_CONFIG_AUTO
57770 + help
57771 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57772 + binaries. This option is useful in environments that
57773 + remove the read bits (e.g. file mode 4711) from suid binaries to
57774 + prevent infoleaking of their contents. This option adds
57775 + consistency to the use of that file mode, as the binary could normally
57776 + be read out when run without privileges while ptracing.
57777 +
57778 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57779 + is created.
57780 +
57781 +config GRKERNSEC_SETXID
57782 + bool "Enforce consistent multithreaded privileges"
57783 + default y if GRKERNSEC_CONFIG_AUTO
57784 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57785 + help
57786 + If you say Y here, a change from a root uid to a non-root uid
57787 + in a multithreaded application will cause the resulting uids,
57788 + gids, supplementary groups, and capabilities in that thread
57789 + to be propagated to the other threads of the process. In most
57790 + cases this is unnecessary, as glibc will emulate this behavior
57791 + on behalf of the application. Other libcs do not act in the
57792 + same way, allowing the other threads of the process to continue
57793 + running with root privileges. If the sysctl option is enabled,
57794 + a sysctl option with name "consistent_setxid" is created.
57795 +
57796 +config GRKERNSEC_TPE
57797 + bool "Trusted Path Execution (TPE)"
57798 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57799 + help
57800 + If you say Y here, you will be able to choose a gid to add to the
57801 + supplementary groups of users you want to mark as "untrusted."
57802 + These users will not be able to execute any files that are not in
57803 + root-owned directories writable only by root. If the sysctl option
57804 + is enabled, a sysctl option with name "tpe" is created.
57805 +
57806 +config GRKERNSEC_TPE_ALL
57807 + bool "Partially restrict all non-root users"
57808 + depends on GRKERNSEC_TPE
57809 + help
57810 + If you say Y here, all non-root users will be covered under
57811 + a weaker TPE restriction. This is separate from, and in addition to,
57812 + the main TPE options that you have selected elsewhere. Thus, if a
57813 + "trusted" GID is chosen, this restriction applies to even that GID.
57814 + Under this restriction, all non-root users will only be allowed to
57815 + execute files in directories they own that are not group or
57816 + world-writable, or in directories owned by root and writable only by
57817 + root. If the sysctl option is enabled, a sysctl option with name
57818 + "tpe_restrict_all" is created.
57819 +
57820 +config GRKERNSEC_TPE_INVERT
57821 + bool "Invert GID option"
57822 + depends on GRKERNSEC_TPE
57823 + help
57824 + If you say Y here, the group you specify in the TPE configuration will
57825 + decide what group TPE restrictions will be *disabled* for. This
57826 + option is useful if you want TPE restrictions to be applied to most
57827 + users on the system. If the sysctl option is enabled, a sysctl option
57828 + with name "tpe_invert" is created. Unlike other sysctl options, this
57829 + entry will default to on for backward-compatibility.
57830 +
57831 +config GRKERNSEC_TPE_GID
57832 + int
57833 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57834 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57835 +
57836 +config GRKERNSEC_TPE_UNTRUSTED_GID
57837 + int "GID for TPE-untrusted users"
57838 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57839 + default 1005
57840 + help
57841 + Setting this GID determines what group TPE restrictions will be
57842 + *enabled* for. If the sysctl option is enabled, a sysctl option
57843 + with name "tpe_gid" is created.
57844 +
57845 +config GRKERNSEC_TPE_TRUSTED_GID
57846 + int "GID for TPE-trusted users"
57847 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57848 + default 1005
57849 + help
57850 + Setting this GID determines what group TPE restrictions will be
57851 + *disabled* for. If the sysctl option is enabled, a sysctl option
57852 + with name "tpe_gid" is created.
57853 +
57854 +endmenu
57855 +menu "Network Protections"
57856 +depends on GRKERNSEC
57857 +
57858 +config GRKERNSEC_RANDNET
57859 + bool "Larger entropy pools"
57860 + default y if GRKERNSEC_CONFIG_AUTO
57861 + help
57862 + If you say Y here, the entropy pools used for many features of Linux
57863 + and grsecurity will be doubled in size. Since several grsecurity
57864 + features use additional randomness, it is recommended that you say Y
57865 + here. Saying Y here has a similar effect as modifying
57866 + /proc/sys/kernel/random/poolsize.
57867 +
57868 +config GRKERNSEC_BLACKHOLE
57869 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57870 + default y if GRKERNSEC_CONFIG_AUTO
57871 + depends on NET
57872 + help
57873 + If you say Y here, neither TCP resets nor ICMP
57874 + destination-unreachable packets will be sent in response to packets
57875 + sent to ports for which no associated listening process exists.
57876 + This feature supports both IPV4 and IPV6 and exempts the
57877 + loopback interface from blackholing. Enabling this feature
57878 + makes a host more resilient to DoS attacks and reduces network
57879 + visibility against scanners.
57880 +
57881 + The blackhole feature as-implemented is equivalent to the FreeBSD
57882 + blackhole feature, as it prevents RST responses to all packets, not
57883 + just SYNs. Under most application behavior this causes no
57884 + problems, but applications (like haproxy) may not close certain
57885 + connections in a way that cleanly terminates them on the remote
57886 + end, leaving the remote host in LAST_ACK state. Because of this
57887 + side-effect and to prevent intentional LAST_ACK DoSes, this
57888 + feature also adds automatic mitigation against such attacks.
57889 + The mitigation drastically reduces the amount of time a socket
57890 + can spend in LAST_ACK state. If you're using haproxy and not
57891 + all servers it connects to have this option enabled, consider
57892 + disabling this feature on the haproxy host.
57893 +
57894 + If the sysctl option is enabled, two sysctl options with names
57895 + "ip_blackhole" and "lastack_retries" will be created.
57896 + While "ip_blackhole" takes the standard zero/non-zero on/off
57897 + toggle, "lastack_retries" uses the same kinds of values as
57898 + "tcp_retries1" and "tcp_retries2". The default value of 4
57899 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57900 + state.
57901 +
57902 +config GRKERNSEC_NO_SIMULT_CONNECT
57903 + bool "Disable TCP Simultaneous Connect"
57904 + default y if GRKERNSEC_CONFIG_AUTO
57905 + depends on NET
57906 + help
57907 + If you say Y here, a feature by Willy Tarreau will be enabled that
57908 + removes a weakness in Linux's strict implementation of TCP that
57909 + allows two clients to connect to each other without either entering
57910 + a listening state. The weakness allows an attacker to easily prevent
57911 + a client from connecting to a known server provided the source port
57912 + for the connection is guessed correctly.
57913 +
57914 + As the weakness could be used to prevent an antivirus or IPS from
57915 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57916 + it should be eliminated by enabling this option. Though Linux is
57917 + one of few operating systems supporting simultaneous connect, it
57918 + has no legitimate use in practice and is rarely supported by firewalls.
57919 +
57920 +config GRKERNSEC_SOCKET
57921 + bool "Socket restrictions"
57922 + depends on NET
57923 + help
57924 + If you say Y here, you will be able to choose from several options.
57925 + If you assign a GID on your system and add it to the supplementary
57926 + groups of users you want to restrict socket access to, this patch
57927 + will perform up to three things, based on the option(s) you choose.
57928 +
57929 +config GRKERNSEC_SOCKET_ALL
57930 + bool "Deny any sockets to group"
57931 + depends on GRKERNSEC_SOCKET
57932 + help
57933 + If you say Y here, you will be able to choose a GID of whose users will
57934 + be unable to connect to other hosts from your machine or run server
57935 + applications from your machine. If the sysctl option is enabled, a
57936 + sysctl option with name "socket_all" is created.
57937 +
57938 +config GRKERNSEC_SOCKET_ALL_GID
57939 + int "GID to deny all sockets for"
57940 + depends on GRKERNSEC_SOCKET_ALL
57941 + default 1004
57942 + help
57943 + Here you can choose the GID to disable socket access for. Remember to
57944 + add the users you want socket access disabled for to the GID
57945 + specified here. If the sysctl option is enabled, a sysctl option
57946 + with name "socket_all_gid" is created.
57947 +
57948 +config GRKERNSEC_SOCKET_CLIENT
57949 + bool "Deny client sockets to group"
57950 + depends on GRKERNSEC_SOCKET
57951 + help
57952 + If you say Y here, you will be able to choose a GID of whose users will
57953 + be unable to connect to other hosts from your machine, but will be
57954 + able to run servers. If this option is enabled, all users in the group
57955 + you specify will have to use passive mode when initiating ftp transfers
57956 + from the shell on your machine. If the sysctl option is enabled, a
57957 + sysctl option with name "socket_client" is created.
57958 +
57959 +config GRKERNSEC_SOCKET_CLIENT_GID
57960 + int "GID to deny client sockets for"
57961 + depends on GRKERNSEC_SOCKET_CLIENT
57962 + default 1003
57963 + help
57964 + Here you can choose the GID to disable client socket access for.
57965 + Remember to add the users you want client socket access disabled for to
57966 + the GID specified here. If the sysctl option is enabled, a sysctl
57967 + option with name "socket_client_gid" is created.
57968 +
57969 +config GRKERNSEC_SOCKET_SERVER
57970 + bool "Deny server sockets to group"
57971 + depends on GRKERNSEC_SOCKET
57972 + help
57973 + If you say Y here, you will be able to choose a GID of whose users will
57974 + be unable to run server applications from your machine. If the sysctl
57975 + option is enabled, a sysctl option with name "socket_server" is created.
57976 +
57977 +config GRKERNSEC_SOCKET_SERVER_GID
57978 + int "GID to deny server sockets for"
57979 + depends on GRKERNSEC_SOCKET_SERVER
57980 + default 1002
57981 + help
57982 + Here you can choose the GID to disable server socket access for.
57983 + Remember to add the users you want server socket access disabled for to
57984 + the GID specified here. If the sysctl option is enabled, a sysctl
57985 + option with name "socket_server_gid" is created.
57986 +
57987 +endmenu
57988 +menu "Sysctl Support"
57989 +depends on GRKERNSEC && SYSCTL
57990 +
57991 +config GRKERNSEC_SYSCTL
57992 + bool "Sysctl support"
57993 + default y if GRKERNSEC_CONFIG_AUTO
57994 + help
57995 + If you say Y here, you will be able to change the options that
57996 + grsecurity runs with at bootup, without having to recompile your
57997 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57998 + to enable (1) or disable (0) various features. All the sysctl entries
57999 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58000 + All features enabled in the kernel configuration are disabled at boot
58001 + if you do not say Y to the "Turn on features by default" option.
58002 + All options should be set at startup, and the grsec_lock entry should
58003 + be set to a non-zero value after all the options are set.
58004 + *THIS IS EXTREMELY IMPORTANT*
58005 +
58006 +config GRKERNSEC_SYSCTL_DISTRO
58007 + bool "Extra sysctl support for distro makers (READ HELP)"
58008 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58009 + help
58010 + If you say Y here, additional sysctl options will be created
58011 + for features that affect processes running as root. Therefore,
58012 + it is critical when using this option that the grsec_lock entry be
58013 + enabled after boot. Only distros with prebuilt kernel packages
58014 + with this option enabled that can ensure grsec_lock is enabled
58015 + after boot should use this option.
58016 + *Failure to set grsec_lock after boot makes all grsec features
58017 + this option covers useless*
58018 +
58019 + Currently this option creates the following sysctl entries:
58020 + "Disable Privileged I/O": "disable_priv_io"
58021 +
58022 +config GRKERNSEC_SYSCTL_ON
58023 + bool "Turn on features by default"
58024 + default y if GRKERNSEC_CONFIG_AUTO
58025 + depends on GRKERNSEC_SYSCTL
58026 + help
58027 + If you say Y here, instead of having all features enabled in the
58028 + kernel configuration disabled at boot time, the features will be
58029 + enabled at boot time. It is recommended you say Y here unless
58030 + there is some reason you would want all sysctl-tunable features to
58031 + be disabled by default. As mentioned elsewhere, it is important
58032 + to enable the grsec_lock entry once you have finished modifying
58033 + the sysctl entries.
58034 +
58035 +endmenu
58036 +menu "Logging Options"
58037 +depends on GRKERNSEC
58038 +
58039 +config GRKERNSEC_FLOODTIME
58040 + int "Seconds in between log messages (minimum)"
58041 + default 10
58042 + help
58043 + This option allows you to enforce the number of seconds between
58044 + grsecurity log messages. The default should be suitable for most
58045 + people, however, if you choose to change it, choose a value small enough
58046 + to allow informative logs to be produced, but large enough to
58047 + prevent flooding.
58048 +
58049 +config GRKERNSEC_FLOODBURST
58050 + int "Number of messages in a burst (maximum)"
58051 + default 6
58052 + help
58053 + This option allows you to choose the maximum number of messages allowed
58054 + within the flood time interval you chose in a separate option. The
58055 + default should be suitable for most people, however if you find that
58056 + many of your logs are being interpreted as flooding, you may want to
58057 + raise this value.
58058 +
58059 +endmenu
58060 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58061 new file mode 100644
58062 index 0000000..1b9afa9
58063 --- /dev/null
58064 +++ b/grsecurity/Makefile
58065 @@ -0,0 +1,38 @@
58066 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58067 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58068 +# into an RBAC system
58069 +#
58070 +# All code in this directory and various hooks inserted throughout the kernel
58071 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58072 +# under the GPL v2 or higher
58073 +
58074 +KBUILD_CFLAGS += -Werror
58075 +
58076 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58077 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58078 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58079 +
58080 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58081 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58082 + gracl_learn.o grsec_log.o
58083 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58084 +
58085 +ifdef CONFIG_NET
58086 +obj-y += grsec_sock.o
58087 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58088 +endif
58089 +
58090 +ifndef CONFIG_GRKERNSEC
58091 +obj-y += grsec_disabled.o
58092 +endif
58093 +
58094 +ifdef CONFIG_GRKERNSEC_HIDESYM
58095 +extra-y := grsec_hidesym.o
58096 +$(obj)/grsec_hidesym.o:
58097 + @-chmod -f 500 /boot
58098 + @-chmod -f 500 /lib/modules
58099 + @-chmod -f 500 /lib64/modules
58100 + @-chmod -f 500 /lib32/modules
58101 + @-chmod -f 700 .
58102 + @echo ' grsec: protected kernel image paths'
58103 +endif
58104 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58105 new file mode 100644
58106 index 0000000..1248ee0
58107 --- /dev/null
58108 +++ b/grsecurity/gracl.c
58109 @@ -0,0 +1,4073 @@
58110 +#include <linux/kernel.h>
58111 +#include <linux/module.h>
58112 +#include <linux/sched.h>
58113 +#include <linux/mm.h>
58114 +#include <linux/file.h>
58115 +#include <linux/fs.h>
58116 +#include <linux/namei.h>
58117 +#include <linux/mount.h>
58118 +#include <linux/tty.h>
58119 +#include <linux/proc_fs.h>
58120 +#include <linux/lglock.h>
58121 +#include <linux/slab.h>
58122 +#include <linux/vmalloc.h>
58123 +#include <linux/types.h>
58124 +#include <linux/sysctl.h>
58125 +#include <linux/netdevice.h>
58126 +#include <linux/ptrace.h>
58127 +#include <linux/gracl.h>
58128 +#include <linux/gralloc.h>
58129 +#include <linux/security.h>
58130 +#include <linux/grinternal.h>
58131 +#include <linux/pid_namespace.h>
58132 +#include <linux/stop_machine.h>
58133 +#include <linux/fdtable.h>
58134 +#include <linux/percpu.h>
58135 +#include <linux/lglock.h>
58136 +#include <linux/hugetlb.h>
58137 +#include <linux/posix-timers.h>
58138 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58139 +#include <linux/magic.h>
58140 +#include <linux/pagemap.h>
58141 +#include "../fs/btrfs/async-thread.h"
58142 +#include "../fs/btrfs/ctree.h"
58143 +#include "../fs/btrfs/btrfs_inode.h"
58144 +#endif
58145 +#include "../fs/mount.h"
58146 +
58147 +#include <asm/uaccess.h>
58148 +#include <asm/errno.h>
58149 +#include <asm/mman.h>
58150 +
58151 +extern struct lglock vfsmount_lock;
58152 +
58153 +static struct acl_role_db acl_role_set;
58154 +static struct name_db name_set;
58155 +static struct inodev_db inodev_set;
58156 +
58157 +/* for keeping track of userspace pointers used for subjects, so we
58158 + can share references in the kernel as well
58159 +*/
58160 +
58161 +static struct path real_root;
58162 +
58163 +static struct acl_subj_map_db subj_map_set;
58164 +
58165 +static struct acl_role_label *default_role;
58166 +
58167 +static struct acl_role_label *role_list;
58168 +
58169 +static u16 acl_sp_role_value;
58170 +
58171 +extern char *gr_shared_page[4];
58172 +static DEFINE_MUTEX(gr_dev_mutex);
58173 +DEFINE_RWLOCK(gr_inode_lock);
58174 +
58175 +struct gr_arg *gr_usermode;
58176 +
58177 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58178 +
58179 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58180 +extern void gr_clear_learn_entries(void);
58181 +
58182 +unsigned char *gr_system_salt;
58183 +unsigned char *gr_system_sum;
58184 +
58185 +static struct sprole_pw **acl_special_roles = NULL;
58186 +static __u16 num_sprole_pws = 0;
58187 +
58188 +static struct acl_role_label *kernel_role = NULL;
58189 +
58190 +static unsigned int gr_auth_attempts = 0;
58191 +static unsigned long gr_auth_expires = 0UL;
58192 +
58193 +#ifdef CONFIG_NET
58194 +extern struct vfsmount *sock_mnt;
58195 +#endif
58196 +
58197 +extern struct vfsmount *pipe_mnt;
58198 +extern struct vfsmount *shm_mnt;
58199 +
58200 +#ifdef CONFIG_HUGETLBFS
58201 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58202 +#endif
58203 +
58204 +static struct acl_object_label *fakefs_obj_rw;
58205 +static struct acl_object_label *fakefs_obj_rwx;
58206 +
58207 +extern int gr_init_uidset(void);
58208 +extern void gr_free_uidset(void);
58209 +extern void gr_remove_uid(uid_t uid);
58210 +extern int gr_find_uid(uid_t uid);
58211 +
58212 +__inline__ int
58213 +gr_acl_is_enabled(void)
58214 +{
58215 + return (gr_status & GR_READY);
58216 +}
58217 +
58218 +static inline dev_t __get_dev(const struct dentry *dentry)
58219 +{
58220 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58221 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
58222 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
58223 + else
58224 +#endif
58225 + return dentry->d_sb->s_dev;
58226 +}
58227 +
58228 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58229 +{
58230 + return __get_dev(dentry);
58231 +}
58232 +
58233 +static char gr_task_roletype_to_char(struct task_struct *task)
58234 +{
58235 + switch (task->role->roletype &
58236 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58237 + GR_ROLE_SPECIAL)) {
58238 + case GR_ROLE_DEFAULT:
58239 + return 'D';
58240 + case GR_ROLE_USER:
58241 + return 'U';
58242 + case GR_ROLE_GROUP:
58243 + return 'G';
58244 + case GR_ROLE_SPECIAL:
58245 + return 'S';
58246 + }
58247 +
58248 + return 'X';
58249 +}
58250 +
58251 +char gr_roletype_to_char(void)
58252 +{
58253 + return gr_task_roletype_to_char(current);
58254 +}
58255 +
58256 +__inline__ int
58257 +gr_acl_tpe_check(void)
58258 +{
58259 + if (unlikely(!(gr_status & GR_READY)))
58260 + return 0;
58261 + if (current->role->roletype & GR_ROLE_TPE)
58262 + return 1;
58263 + else
58264 + return 0;
58265 +}
58266 +
58267 +int
58268 +gr_handle_rawio(const struct inode *inode)
58269 +{
58270 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58271 + if (inode && S_ISBLK(inode->i_mode) &&
58272 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58273 + !capable(CAP_SYS_RAWIO))
58274 + return 1;
58275 +#endif
58276 + return 0;
58277 +}
58278 +
58279 +static int
58280 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58281 +{
58282 + if (likely(lena != lenb))
58283 + return 0;
58284 +
58285 + return !memcmp(a, b, lena);
58286 +}
58287 +
58288 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58289 +{
58290 + *buflen -= namelen;
58291 + if (*buflen < 0)
58292 + return -ENAMETOOLONG;
58293 + *buffer -= namelen;
58294 + memcpy(*buffer, str, namelen);
58295 + return 0;
58296 +}
58297 +
58298 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58299 +{
58300 + return prepend(buffer, buflen, name->name, name->len);
58301 +}
58302 +
58303 +static int prepend_path(const struct path *path, struct path *root,
58304 + char **buffer, int *buflen)
58305 +{
58306 + struct dentry *dentry = path->dentry;
58307 + struct vfsmount *vfsmnt = path->mnt;
58308 + struct mount *mnt = real_mount(vfsmnt);
58309 + bool slash = false;
58310 + int error = 0;
58311 +
58312 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58313 + struct dentry * parent;
58314 +
58315 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58316 + /* Global root? */
58317 + if (!mnt_has_parent(mnt)) {
58318 + goto out;
58319 + }
58320 + dentry = mnt->mnt_mountpoint;
58321 + mnt = mnt->mnt_parent;
58322 + vfsmnt = &mnt->mnt;
58323 + continue;
58324 + }
58325 + parent = dentry->d_parent;
58326 + prefetch(parent);
58327 + spin_lock(&dentry->d_lock);
58328 + error = prepend_name(buffer, buflen, &dentry->d_name);
58329 + spin_unlock(&dentry->d_lock);
58330 + if (!error)
58331 + error = prepend(buffer, buflen, "/", 1);
58332 + if (error)
58333 + break;
58334 +
58335 + slash = true;
58336 + dentry = parent;
58337 + }
58338 +
58339 +out:
58340 + if (!error && !slash)
58341 + error = prepend(buffer, buflen, "/", 1);
58342 +
58343 + return error;
58344 +}
58345 +
58346 +/* this must be called with vfsmount_lock and rename_lock held */
58347 +
58348 +static char *__our_d_path(const struct path *path, struct path *root,
58349 + char *buf, int buflen)
58350 +{
58351 + char *res = buf + buflen;
58352 + int error;
58353 +
58354 + prepend(&res, &buflen, "\0", 1);
58355 + error = prepend_path(path, root, &res, &buflen);
58356 + if (error)
58357 + return ERR_PTR(error);
58358 +
58359 + return res;
58360 +}
58361 +
58362 +static char *
58363 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58364 +{
58365 + char *retval;
58366 +
58367 + retval = __our_d_path(path, root, buf, buflen);
58368 + if (unlikely(IS_ERR(retval)))
58369 + retval = strcpy(buf, "<path too long>");
58370 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58371 + retval[1] = '\0';
58372 +
58373 + return retval;
58374 +}
58375 +
58376 +static char *
58377 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58378 + char *buf, int buflen)
58379 +{
58380 + struct path path;
58381 + char *res;
58382 +
58383 + path.dentry = (struct dentry *)dentry;
58384 + path.mnt = (struct vfsmount *)vfsmnt;
58385 +
58386 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58387 + by the RBAC system */
58388 + res = gen_full_path(&path, &real_root, buf, buflen);
58389 +
58390 + return res;
58391 +}
58392 +
58393 +static char *
58394 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58395 + char *buf, int buflen)
58396 +{
58397 + char *res;
58398 + struct path path;
58399 + struct path root;
58400 + struct task_struct *reaper = init_pid_ns.child_reaper;
58401 +
58402 + path.dentry = (struct dentry *)dentry;
58403 + path.mnt = (struct vfsmount *)vfsmnt;
58404 +
58405 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58406 + get_fs_root(reaper->fs, &root);
58407 +
58408 + br_read_lock(&vfsmount_lock);
58409 + write_seqlock(&rename_lock);
58410 + res = gen_full_path(&path, &root, buf, buflen);
58411 + write_sequnlock(&rename_lock);
58412 + br_read_unlock(&vfsmount_lock);
58413 +
58414 + path_put(&root);
58415 + return res;
58416 +}
58417 +
58418 +static char *
58419 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58420 +{
58421 + char *ret;
58422 + br_read_lock(&vfsmount_lock);
58423 + write_seqlock(&rename_lock);
58424 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58425 + PAGE_SIZE);
58426 + write_sequnlock(&rename_lock);
58427 + br_read_unlock(&vfsmount_lock);
58428 + return ret;
58429 +}
58430 +
58431 +static char *
58432 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58433 +{
58434 + char *ret;
58435 + char *buf;
58436 + int buflen;
58437 +
58438 + br_read_lock(&vfsmount_lock);
58439 + write_seqlock(&rename_lock);
58440 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58441 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58442 + buflen = (int)(ret - buf);
58443 + if (buflen >= 5)
58444 + prepend(&ret, &buflen, "/proc", 5);
58445 + else
58446 + ret = strcpy(buf, "<path too long>");
58447 + write_sequnlock(&rename_lock);
58448 + br_read_unlock(&vfsmount_lock);
58449 + return ret;
58450 +}
58451 +
58452 +char *
58453 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58454 +{
58455 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58456 + PAGE_SIZE);
58457 +}
58458 +
58459 +char *
58460 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58461 +{
58462 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58463 + PAGE_SIZE);
58464 +}
58465 +
58466 +char *
58467 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58468 +{
58469 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58470 + PAGE_SIZE);
58471 +}
58472 +
58473 +char *
58474 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58475 +{
58476 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58477 + PAGE_SIZE);
58478 +}
58479 +
58480 +char *
58481 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58482 +{
58483 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58484 + PAGE_SIZE);
58485 +}
58486 +
58487 +__inline__ __u32
58488 +to_gr_audit(const __u32 reqmode)
58489 +{
58490 + /* masks off auditable permission flags, then shifts them to create
58491 + auditing flags, and adds the special case of append auditing if
58492 + we're requesting write */
58493 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58494 +}
58495 +
58496 +struct acl_subject_label *
58497 +lookup_subject_map(const struct acl_subject_label *userp)
58498 +{
58499 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58500 + struct subject_map *match;
58501 +
58502 + match = subj_map_set.s_hash[index];
58503 +
58504 + while (match && match->user != userp)
58505 + match = match->next;
58506 +
58507 + if (match != NULL)
58508 + return match->kernel;
58509 + else
58510 + return NULL;
58511 +}
58512 +
58513 +static void
58514 +insert_subj_map_entry(struct subject_map *subjmap)
58515 +{
58516 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58517 + struct subject_map **curr;
58518 +
58519 + subjmap->prev = NULL;
58520 +
58521 + curr = &subj_map_set.s_hash[index];
58522 + if (*curr != NULL)
58523 + (*curr)->prev = subjmap;
58524 +
58525 + subjmap->next = *curr;
58526 + *curr = subjmap;
58527 +
58528 + return;
58529 +}
58530 +
58531 +static struct acl_role_label *
58532 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58533 + const gid_t gid)
58534 +{
58535 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58536 + struct acl_role_label *match;
58537 + struct role_allowed_ip *ipp;
58538 + unsigned int x;
58539 + u32 curr_ip = task->signal->curr_ip;
58540 +
58541 + task->signal->saved_ip = curr_ip;
58542 +
58543 + match = acl_role_set.r_hash[index];
58544 +
58545 + while (match) {
58546 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58547 + for (x = 0; x < match->domain_child_num; x++) {
58548 + if (match->domain_children[x] == uid)
58549 + goto found;
58550 + }
58551 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58552 + break;
58553 + match = match->next;
58554 + }
58555 +found:
58556 + if (match == NULL) {
58557 + try_group:
58558 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58559 + match = acl_role_set.r_hash[index];
58560 +
58561 + while (match) {
58562 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58563 + for (x = 0; x < match->domain_child_num; x++) {
58564 + if (match->domain_children[x] == gid)
58565 + goto found2;
58566 + }
58567 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58568 + break;
58569 + match = match->next;
58570 + }
58571 +found2:
58572 + if (match == NULL)
58573 + match = default_role;
58574 + if (match->allowed_ips == NULL)
58575 + return match;
58576 + else {
58577 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58578 + if (likely
58579 + ((ntohl(curr_ip) & ipp->netmask) ==
58580 + (ntohl(ipp->addr) & ipp->netmask)))
58581 + return match;
58582 + }
58583 + match = default_role;
58584 + }
58585 + } else if (match->allowed_ips == NULL) {
58586 + return match;
58587 + } else {
58588 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58589 + if (likely
58590 + ((ntohl(curr_ip) & ipp->netmask) ==
58591 + (ntohl(ipp->addr) & ipp->netmask)))
58592 + return match;
58593 + }
58594 + goto try_group;
58595 + }
58596 +
58597 + return match;
58598 +}
58599 +
58600 +struct acl_subject_label *
58601 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58602 + const struct acl_role_label *role)
58603 +{
58604 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58605 + struct acl_subject_label *match;
58606 +
58607 + match = role->subj_hash[index];
58608 +
58609 + while (match && (match->inode != ino || match->device != dev ||
58610 + (match->mode & GR_DELETED))) {
58611 + match = match->next;
58612 + }
58613 +
58614 + if (match && !(match->mode & GR_DELETED))
58615 + return match;
58616 + else
58617 + return NULL;
58618 +}
58619 +
58620 +struct acl_subject_label *
58621 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58622 + const struct acl_role_label *role)
58623 +{
58624 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58625 + struct acl_subject_label *match;
58626 +
58627 + match = role->subj_hash[index];
58628 +
58629 + while (match && (match->inode != ino || match->device != dev ||
58630 + !(match->mode & GR_DELETED))) {
58631 + match = match->next;
58632 + }
58633 +
58634 + if (match && (match->mode & GR_DELETED))
58635 + return match;
58636 + else
58637 + return NULL;
58638 +}
58639 +
58640 +static struct acl_object_label *
58641 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58642 + const struct acl_subject_label *subj)
58643 +{
58644 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58645 + struct acl_object_label *match;
58646 +
58647 + match = subj->obj_hash[index];
58648 +
58649 + while (match && (match->inode != ino || match->device != dev ||
58650 + (match->mode & GR_DELETED))) {
58651 + match = match->next;
58652 + }
58653 +
58654 + if (match && !(match->mode & GR_DELETED))
58655 + return match;
58656 + else
58657 + return NULL;
58658 +}
58659 +
58660 +static struct acl_object_label *
58661 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58662 + const struct acl_subject_label *subj)
58663 +{
58664 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58665 + struct acl_object_label *match;
58666 +
58667 + match = subj->obj_hash[index];
58668 +
58669 + while (match && (match->inode != ino || match->device != dev ||
58670 + !(match->mode & GR_DELETED))) {
58671 + match = match->next;
58672 + }
58673 +
58674 + if (match && (match->mode & GR_DELETED))
58675 + return match;
58676 +
58677 + match = subj->obj_hash[index];
58678 +
58679 + while (match && (match->inode != ino || match->device != dev ||
58680 + (match->mode & GR_DELETED))) {
58681 + match = match->next;
58682 + }
58683 +
58684 + if (match && !(match->mode & GR_DELETED))
58685 + return match;
58686 + else
58687 + return NULL;
58688 +}
58689 +
58690 +static struct name_entry *
58691 +lookup_name_entry(const char *name)
58692 +{
58693 + unsigned int len = strlen(name);
58694 + unsigned int key = full_name_hash(name, len);
58695 + unsigned int index = key % name_set.n_size;
58696 + struct name_entry *match;
58697 +
58698 + match = name_set.n_hash[index];
58699 +
58700 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58701 + match = match->next;
58702 +
58703 + return match;
58704 +}
58705 +
58706 +static struct name_entry *
58707 +lookup_name_entry_create(const char *name)
58708 +{
58709 + unsigned int len = strlen(name);
58710 + unsigned int key = full_name_hash(name, len);
58711 + unsigned int index = key % name_set.n_size;
58712 + struct name_entry *match;
58713 +
58714 + match = name_set.n_hash[index];
58715 +
58716 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58717 + !match->deleted))
58718 + match = match->next;
58719 +
58720 + if (match && match->deleted)
58721 + return match;
58722 +
58723 + match = name_set.n_hash[index];
58724 +
58725 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58726 + match->deleted))
58727 + match = match->next;
58728 +
58729 + if (match && !match->deleted)
58730 + return match;
58731 + else
58732 + return NULL;
58733 +}
58734 +
58735 +static struct inodev_entry *
58736 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58737 +{
58738 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58739 + struct inodev_entry *match;
58740 +
58741 + match = inodev_set.i_hash[index];
58742 +
58743 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58744 + match = match->next;
58745 +
58746 + return match;
58747 +}
58748 +
58749 +static void
58750 +insert_inodev_entry(struct inodev_entry *entry)
58751 +{
58752 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58753 + inodev_set.i_size);
58754 + struct inodev_entry **curr;
58755 +
58756 + entry->prev = NULL;
58757 +
58758 + curr = &inodev_set.i_hash[index];
58759 + if (*curr != NULL)
58760 + (*curr)->prev = entry;
58761 +
58762 + entry->next = *curr;
58763 + *curr = entry;
58764 +
58765 + return;
58766 +}
58767 +
58768 +static void
58769 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58770 +{
58771 + unsigned int index =
58772 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58773 + struct acl_role_label **curr;
58774 + struct acl_role_label *tmp, *tmp2;
58775 +
58776 + curr = &acl_role_set.r_hash[index];
58777 +
58778 + /* simple case, slot is empty, just set it to our role */
58779 + if (*curr == NULL) {
58780 + *curr = role;
58781 + } else {
58782 + /* example:
58783 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58784 + 2 -> 3
58785 + */
58786 + /* first check to see if we can already be reached via this slot */
58787 + tmp = *curr;
58788 + while (tmp && tmp != role)
58789 + tmp = tmp->next;
58790 + if (tmp == role) {
58791 + /* we don't need to add ourselves to this slot's chain */
58792 + return;
58793 + }
58794 + /* we need to add ourselves to this chain, two cases */
58795 + if (role->next == NULL) {
58796 + /* simple case, append the current chain to our role */
58797 + role->next = *curr;
58798 + *curr = role;
58799 + } else {
58800 + /* 1 -> 2 -> 3 -> 4
58801 + 2 -> 3 -> 4
58802 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58803 + */
58804 + /* trickier case: walk our role's chain until we find
58805 + the role for the start of the current slot's chain */
58806 + tmp = role;
58807 + tmp2 = *curr;
58808 + while (tmp->next && tmp->next != tmp2)
58809 + tmp = tmp->next;
58810 + if (tmp->next == tmp2) {
58811 + /* from example above, we found 3, so just
58812 + replace this slot's chain with ours */
58813 + *curr = role;
58814 + } else {
58815 + /* we didn't find a subset of our role's chain
58816 + in the current slot's chain, so append their
58817 + chain to ours, and set us as the first role in
58818 + the slot's chain
58819 +
58820 + we could fold this case with the case above,
58821 + but making it explicit for clarity
58822 + */
58823 + tmp->next = tmp2;
58824 + *curr = role;
58825 + }
58826 + }
58827 + }
58828 +
58829 + return;
58830 +}
58831 +
58832 +static void
58833 +insert_acl_role_label(struct acl_role_label *role)
58834 +{
58835 + int i;
58836 +
58837 + if (role_list == NULL) {
58838 + role_list = role;
58839 + role->prev = NULL;
58840 + } else {
58841 + role->prev = role_list;
58842 + role_list = role;
58843 + }
58844 +
58845 + /* used for hash chains */
58846 + role->next = NULL;
58847 +
58848 + if (role->roletype & GR_ROLE_DOMAIN) {
58849 + for (i = 0; i < role->domain_child_num; i++)
58850 + __insert_acl_role_label(role, role->domain_children[i]);
58851 + } else
58852 + __insert_acl_role_label(role, role->uidgid);
58853 +}
58854 +
58855 +static int
58856 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58857 +{
58858 + struct name_entry **curr, *nentry;
58859 + struct inodev_entry *ientry;
58860 + unsigned int len = strlen(name);
58861 + unsigned int key = full_name_hash(name, len);
58862 + unsigned int index = key % name_set.n_size;
58863 +
58864 + curr = &name_set.n_hash[index];
58865 +
58866 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58867 + curr = &((*curr)->next);
58868 +
58869 + if (*curr != NULL)
58870 + return 1;
58871 +
58872 + nentry = acl_alloc(sizeof (struct name_entry));
58873 + if (nentry == NULL)
58874 + return 0;
58875 + ientry = acl_alloc(sizeof (struct inodev_entry));
58876 + if (ientry == NULL)
58877 + return 0;
58878 + ientry->nentry = nentry;
58879 +
58880 + nentry->key = key;
58881 + nentry->name = name;
58882 + nentry->inode = inode;
58883 + nentry->device = device;
58884 + nentry->len = len;
58885 + nentry->deleted = deleted;
58886 +
58887 + nentry->prev = NULL;
58888 + curr = &name_set.n_hash[index];
58889 + if (*curr != NULL)
58890 + (*curr)->prev = nentry;
58891 + nentry->next = *curr;
58892 + *curr = nentry;
58893 +
58894 + /* insert us into the table searchable by inode/dev */
58895 + insert_inodev_entry(ientry);
58896 +
58897 + return 1;
58898 +}
58899 +
58900 +static void
58901 +insert_acl_obj_label(struct acl_object_label *obj,
58902 + struct acl_subject_label *subj)
58903 +{
58904 + unsigned int index =
58905 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58906 + struct acl_object_label **curr;
58907 +
58908 +
58909 + obj->prev = NULL;
58910 +
58911 + curr = &subj->obj_hash[index];
58912 + if (*curr != NULL)
58913 + (*curr)->prev = obj;
58914 +
58915 + obj->next = *curr;
58916 + *curr = obj;
58917 +
58918 + return;
58919 +}
58920 +
58921 +static void
58922 +insert_acl_subj_label(struct acl_subject_label *obj,
58923 + struct acl_role_label *role)
58924 +{
58925 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58926 + struct acl_subject_label **curr;
58927 +
58928 + obj->prev = NULL;
58929 +
58930 + curr = &role->subj_hash[index];
58931 + if (*curr != NULL)
58932 + (*curr)->prev = obj;
58933 +
58934 + obj->next = *curr;
58935 + *curr = obj;
58936 +
58937 + return;
58938 +}
58939 +
58940 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58941 +
58942 +static void *
58943 +create_table(__u32 * len, int elementsize)
58944 +{
58945 + unsigned int table_sizes[] = {
58946 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58947 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58948 + 4194301, 8388593, 16777213, 33554393, 67108859
58949 + };
58950 + void *newtable = NULL;
58951 + unsigned int pwr = 0;
58952 +
58953 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58954 + table_sizes[pwr] <= *len)
58955 + pwr++;
58956 +
58957 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58958 + return newtable;
58959 +
58960 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58961 + newtable =
58962 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58963 + else
58964 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58965 +
58966 + *len = table_sizes[pwr];
58967 +
58968 + return newtable;
58969 +}
58970 +
58971 +static int
58972 +init_variables(const struct gr_arg *arg)
58973 +{
58974 + struct task_struct *reaper = init_pid_ns.child_reaper;
58975 + unsigned int stacksize;
58976 +
58977 + subj_map_set.s_size = arg->role_db.num_subjects;
58978 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58979 + name_set.n_size = arg->role_db.num_objects;
58980 + inodev_set.i_size = arg->role_db.num_objects;
58981 +
58982 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58983 + !name_set.n_size || !inodev_set.i_size)
58984 + return 1;
58985 +
58986 + if (!gr_init_uidset())
58987 + return 1;
58988 +
58989 + /* set up the stack that holds allocation info */
58990 +
58991 + stacksize = arg->role_db.num_pointers + 5;
58992 +
58993 + if (!acl_alloc_stack_init(stacksize))
58994 + return 1;
58995 +
58996 + /* grab reference for the real root dentry and vfsmount */
58997 + get_fs_root(reaper->fs, &real_root);
58998 +
58999 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59000 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59001 +#endif
59002 +
59003 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59004 + if (fakefs_obj_rw == NULL)
59005 + return 1;
59006 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59007 +
59008 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59009 + if (fakefs_obj_rwx == NULL)
59010 + return 1;
59011 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59012 +
59013 + subj_map_set.s_hash =
59014 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59015 + acl_role_set.r_hash =
59016 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59017 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59018 + inodev_set.i_hash =
59019 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59020 +
59021 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59022 + !name_set.n_hash || !inodev_set.i_hash)
59023 + return 1;
59024 +
59025 + memset(subj_map_set.s_hash, 0,
59026 + sizeof(struct subject_map *) * subj_map_set.s_size);
59027 + memset(acl_role_set.r_hash, 0,
59028 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59029 + memset(name_set.n_hash, 0,
59030 + sizeof (struct name_entry *) * name_set.n_size);
59031 + memset(inodev_set.i_hash, 0,
59032 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59033 +
59034 + return 0;
59035 +}
59036 +
59037 +/* free information not needed after startup
59038 + currently contains user->kernel pointer mappings for subjects
59039 +*/
59040 +
59041 +static void
59042 +free_init_variables(void)
59043 +{
59044 + __u32 i;
59045 +
59046 + if (subj_map_set.s_hash) {
59047 + for (i = 0; i < subj_map_set.s_size; i++) {
59048 + if (subj_map_set.s_hash[i]) {
59049 + kfree(subj_map_set.s_hash[i]);
59050 + subj_map_set.s_hash[i] = NULL;
59051 + }
59052 + }
59053 +
59054 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59055 + PAGE_SIZE)
59056 + kfree(subj_map_set.s_hash);
59057 + else
59058 + vfree(subj_map_set.s_hash);
59059 + }
59060 +
59061 + return;
59062 +}
59063 +
59064 +static void
59065 +free_variables(void)
59066 +{
59067 + struct acl_subject_label *s;
59068 + struct acl_role_label *r;
59069 + struct task_struct *task, *task2;
59070 + unsigned int x;
59071 +
59072 + gr_clear_learn_entries();
59073 +
59074 + read_lock(&tasklist_lock);
59075 + do_each_thread(task2, task) {
59076 + task->acl_sp_role = 0;
59077 + task->acl_role_id = 0;
59078 + task->acl = NULL;
59079 + task->role = NULL;
59080 + } while_each_thread(task2, task);
59081 + read_unlock(&tasklist_lock);
59082 +
59083 + /* release the reference to the real root dentry and vfsmount */
59084 + path_put(&real_root);
59085 + memset(&real_root, 0, sizeof(real_root));
59086 +
59087 + /* free all object hash tables */
59088 +
59089 + FOR_EACH_ROLE_START(r)
59090 + if (r->subj_hash == NULL)
59091 + goto next_role;
59092 + FOR_EACH_SUBJECT_START(r, s, x)
59093 + if (s->obj_hash == NULL)
59094 + break;
59095 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59096 + kfree(s->obj_hash);
59097 + else
59098 + vfree(s->obj_hash);
59099 + FOR_EACH_SUBJECT_END(s, x)
59100 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59101 + if (s->obj_hash == NULL)
59102 + break;
59103 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59104 + kfree(s->obj_hash);
59105 + else
59106 + vfree(s->obj_hash);
59107 + FOR_EACH_NESTED_SUBJECT_END(s)
59108 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59109 + kfree(r->subj_hash);
59110 + else
59111 + vfree(r->subj_hash);
59112 + r->subj_hash = NULL;
59113 +next_role:
59114 + FOR_EACH_ROLE_END(r)
59115 +
59116 + acl_free_all();
59117 +
59118 + if (acl_role_set.r_hash) {
59119 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59120 + PAGE_SIZE)
59121 + kfree(acl_role_set.r_hash);
59122 + else
59123 + vfree(acl_role_set.r_hash);
59124 + }
59125 + if (name_set.n_hash) {
59126 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59127 + PAGE_SIZE)
59128 + kfree(name_set.n_hash);
59129 + else
59130 + vfree(name_set.n_hash);
59131 + }
59132 +
59133 + if (inodev_set.i_hash) {
59134 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59135 + PAGE_SIZE)
59136 + kfree(inodev_set.i_hash);
59137 + else
59138 + vfree(inodev_set.i_hash);
59139 + }
59140 +
59141 + gr_free_uidset();
59142 +
59143 + memset(&name_set, 0, sizeof (struct name_db));
59144 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59145 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59146 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59147 +
59148 + default_role = NULL;
59149 + kernel_role = NULL;
59150 + role_list = NULL;
59151 +
59152 + return;
59153 +}
59154 +
59155 +static __u32
59156 +count_user_objs(struct acl_object_label *userp)
59157 +{
59158 + struct acl_object_label o_tmp;
59159 + __u32 num = 0;
59160 +
59161 + while (userp) {
59162 + if (copy_from_user(&o_tmp, userp,
59163 + sizeof (struct acl_object_label)))
59164 + break;
59165 +
59166 + userp = o_tmp.prev;
59167 + num++;
59168 + }
59169 +
59170 + return num;
59171 +}
59172 +
59173 +static struct acl_subject_label *
59174 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59175 +
59176 +static int
59177 +copy_user_glob(struct acl_object_label *obj)
59178 +{
59179 + struct acl_object_label *g_tmp, **guser;
59180 + unsigned int len;
59181 + char *tmp;
59182 +
59183 + if (obj->globbed == NULL)
59184 + return 0;
59185 +
59186 + guser = &obj->globbed;
59187 + while (*guser) {
59188 + g_tmp = (struct acl_object_label *)
59189 + acl_alloc(sizeof (struct acl_object_label));
59190 + if (g_tmp == NULL)
59191 + return -ENOMEM;
59192 +
59193 + if (copy_from_user(g_tmp, *guser,
59194 + sizeof (struct acl_object_label)))
59195 + return -EFAULT;
59196 +
59197 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59198 +
59199 + if (!len || len >= PATH_MAX)
59200 + return -EINVAL;
59201 +
59202 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59203 + return -ENOMEM;
59204 +
59205 + if (copy_from_user(tmp, g_tmp->filename, len))
59206 + return -EFAULT;
59207 + tmp[len-1] = '\0';
59208 + g_tmp->filename = tmp;
59209 +
59210 + *guser = g_tmp;
59211 + guser = &(g_tmp->next);
59212 + }
59213 +
59214 + return 0;
59215 +}
59216 +
59217 +static int
59218 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59219 + struct acl_role_label *role)
59220 +{
59221 + struct acl_object_label *o_tmp;
59222 + unsigned int len;
59223 + int ret;
59224 + char *tmp;
59225 +
59226 + while (userp) {
59227 + if ((o_tmp = (struct acl_object_label *)
59228 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59229 + return -ENOMEM;
59230 +
59231 + if (copy_from_user(o_tmp, userp,
59232 + sizeof (struct acl_object_label)))
59233 + return -EFAULT;
59234 +
59235 + userp = o_tmp->prev;
59236 +
59237 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59238 +
59239 + if (!len || len >= PATH_MAX)
59240 + return -EINVAL;
59241 +
59242 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59243 + return -ENOMEM;
59244 +
59245 + if (copy_from_user(tmp, o_tmp->filename, len))
59246 + return -EFAULT;
59247 + tmp[len-1] = '\0';
59248 + o_tmp->filename = tmp;
59249 +
59250 + insert_acl_obj_label(o_tmp, subj);
59251 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59252 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59253 + return -ENOMEM;
59254 +
59255 + ret = copy_user_glob(o_tmp);
59256 + if (ret)
59257 + return ret;
59258 +
59259 + if (o_tmp->nested) {
59260 + int already_copied;
59261 +
59262 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59263 + if (IS_ERR(o_tmp->nested))
59264 + return PTR_ERR(o_tmp->nested);
59265 +
59266 + /* insert into nested subject list if we haven't copied this one yet
59267 + to prevent duplicate entries */
59268 + if (!already_copied) {
59269 + o_tmp->nested->next = role->hash->first;
59270 + role->hash->first = o_tmp->nested;
59271 + }
59272 + }
59273 + }
59274 +
59275 + return 0;
59276 +}
59277 +
59278 +static __u32
59279 +count_user_subjs(struct acl_subject_label *userp)
59280 +{
59281 + struct acl_subject_label s_tmp;
59282 + __u32 num = 0;
59283 +
59284 + while (userp) {
59285 + if (copy_from_user(&s_tmp, userp,
59286 + sizeof (struct acl_subject_label)))
59287 + break;
59288 +
59289 + userp = s_tmp.prev;
59290 + }
59291 +
59292 + return num;
59293 +}
59294 +
59295 +static int
59296 +copy_user_allowedips(struct acl_role_label *rolep)
59297 +{
59298 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59299 +
59300 + ruserip = rolep->allowed_ips;
59301 +
59302 + while (ruserip) {
59303 + rlast = rtmp;
59304 +
59305 + if ((rtmp = (struct role_allowed_ip *)
59306 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59307 + return -ENOMEM;
59308 +
59309 + if (copy_from_user(rtmp, ruserip,
59310 + sizeof (struct role_allowed_ip)))
59311 + return -EFAULT;
59312 +
59313 + ruserip = rtmp->prev;
59314 +
59315 + if (!rlast) {
59316 + rtmp->prev = NULL;
59317 + rolep->allowed_ips = rtmp;
59318 + } else {
59319 + rlast->next = rtmp;
59320 + rtmp->prev = rlast;
59321 + }
59322 +
59323 + if (!ruserip)
59324 + rtmp->next = NULL;
59325 + }
59326 +
59327 + return 0;
59328 +}
59329 +
59330 +static int
59331 +copy_user_transitions(struct acl_role_label *rolep)
59332 +{
59333 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59334 +
59335 + unsigned int len;
59336 + char *tmp;
59337 +
59338 + rusertp = rolep->transitions;
59339 +
59340 + while (rusertp) {
59341 + rlast = rtmp;
59342 +
59343 + if ((rtmp = (struct role_transition *)
59344 + acl_alloc(sizeof (struct role_transition))) == NULL)
59345 + return -ENOMEM;
59346 +
59347 + if (copy_from_user(rtmp, rusertp,
59348 + sizeof (struct role_transition)))
59349 + return -EFAULT;
59350 +
59351 + rusertp = rtmp->prev;
59352 +
59353 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59354 +
59355 + if (!len || len >= GR_SPROLE_LEN)
59356 + return -EINVAL;
59357 +
59358 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59359 + return -ENOMEM;
59360 +
59361 + if (copy_from_user(tmp, rtmp->rolename, len))
59362 + return -EFAULT;
59363 + tmp[len-1] = '\0';
59364 + rtmp->rolename = tmp;
59365 +
59366 + if (!rlast) {
59367 + rtmp->prev = NULL;
59368 + rolep->transitions = rtmp;
59369 + } else {
59370 + rlast->next = rtmp;
59371 + rtmp->prev = rlast;
59372 + }
59373 +
59374 + if (!rusertp)
59375 + rtmp->next = NULL;
59376 + }
59377 +
59378 + return 0;
59379 +}
59380 +
59381 +static struct acl_subject_label *
59382 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59383 +{
59384 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59385 + unsigned int len;
59386 + char *tmp;
59387 + __u32 num_objs;
59388 + struct acl_ip_label **i_tmp, *i_utmp2;
59389 + struct gr_hash_struct ghash;
59390 + struct subject_map *subjmap;
59391 + unsigned int i_num;
59392 + int err;
59393 +
59394 + if (already_copied != NULL)
59395 + *already_copied = 0;
59396 +
59397 + s_tmp = lookup_subject_map(userp);
59398 +
59399 + /* we've already copied this subject into the kernel, just return
59400 + the reference to it, and don't copy it over again
59401 + */
59402 + if (s_tmp) {
59403 + if (already_copied != NULL)
59404 + *already_copied = 1;
59405 + return(s_tmp);
59406 + }
59407 +
59408 + if ((s_tmp = (struct acl_subject_label *)
59409 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59410 + return ERR_PTR(-ENOMEM);
59411 +
59412 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59413 + if (subjmap == NULL)
59414 + return ERR_PTR(-ENOMEM);
59415 +
59416 + subjmap->user = userp;
59417 + subjmap->kernel = s_tmp;
59418 + insert_subj_map_entry(subjmap);
59419 +
59420 + if (copy_from_user(s_tmp, userp,
59421 + sizeof (struct acl_subject_label)))
59422 + return ERR_PTR(-EFAULT);
59423 +
59424 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59425 +
59426 + if (!len || len >= PATH_MAX)
59427 + return ERR_PTR(-EINVAL);
59428 +
59429 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59430 + return ERR_PTR(-ENOMEM);
59431 +
59432 + if (copy_from_user(tmp, s_tmp->filename, len))
59433 + return ERR_PTR(-EFAULT);
59434 + tmp[len-1] = '\0';
59435 + s_tmp->filename = tmp;
59436 +
59437 + if (!strcmp(s_tmp->filename, "/"))
59438 + role->root_label = s_tmp;
59439 +
59440 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59441 + return ERR_PTR(-EFAULT);
59442 +
59443 + /* copy user and group transition tables */
59444 +
59445 + if (s_tmp->user_trans_num) {
59446 + uid_t *uidlist;
59447 +
59448 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59449 + if (uidlist == NULL)
59450 + return ERR_PTR(-ENOMEM);
59451 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59452 + return ERR_PTR(-EFAULT);
59453 +
59454 + s_tmp->user_transitions = uidlist;
59455 + }
59456 +
59457 + if (s_tmp->group_trans_num) {
59458 + gid_t *gidlist;
59459 +
59460 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59461 + if (gidlist == NULL)
59462 + return ERR_PTR(-ENOMEM);
59463 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59464 + return ERR_PTR(-EFAULT);
59465 +
59466 + s_tmp->group_transitions = gidlist;
59467 + }
59468 +
59469 + /* set up object hash table */
59470 + num_objs = count_user_objs(ghash.first);
59471 +
59472 + s_tmp->obj_hash_size = num_objs;
59473 + s_tmp->obj_hash =
59474 + (struct acl_object_label **)
59475 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59476 +
59477 + if (!s_tmp->obj_hash)
59478 + return ERR_PTR(-ENOMEM);
59479 +
59480 + memset(s_tmp->obj_hash, 0,
59481 + s_tmp->obj_hash_size *
59482 + sizeof (struct acl_object_label *));
59483 +
59484 + /* add in objects */
59485 + err = copy_user_objs(ghash.first, s_tmp, role);
59486 +
59487 + if (err)
59488 + return ERR_PTR(err);
59489 +
59490 + /* set pointer for parent subject */
59491 + if (s_tmp->parent_subject) {
59492 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59493 +
59494 + if (IS_ERR(s_tmp2))
59495 + return s_tmp2;
59496 +
59497 + s_tmp->parent_subject = s_tmp2;
59498 + }
59499 +
59500 + /* add in ip acls */
59501 +
59502 + if (!s_tmp->ip_num) {
59503 + s_tmp->ips = NULL;
59504 + goto insert;
59505 + }
59506 +
59507 + i_tmp =
59508 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59509 + sizeof (struct acl_ip_label *));
59510 +
59511 + if (!i_tmp)
59512 + return ERR_PTR(-ENOMEM);
59513 +
59514 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59515 + *(i_tmp + i_num) =
59516 + (struct acl_ip_label *)
59517 + acl_alloc(sizeof (struct acl_ip_label));
59518 + if (!*(i_tmp + i_num))
59519 + return ERR_PTR(-ENOMEM);
59520 +
59521 + if (copy_from_user
59522 + (&i_utmp2, s_tmp->ips + i_num,
59523 + sizeof (struct acl_ip_label *)))
59524 + return ERR_PTR(-EFAULT);
59525 +
59526 + if (copy_from_user
59527 + (*(i_tmp + i_num), i_utmp2,
59528 + sizeof (struct acl_ip_label)))
59529 + return ERR_PTR(-EFAULT);
59530 +
59531 + if ((*(i_tmp + i_num))->iface == NULL)
59532 + continue;
59533 +
59534 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59535 + if (!len || len >= IFNAMSIZ)
59536 + return ERR_PTR(-EINVAL);
59537 + tmp = acl_alloc(len);
59538 + if (tmp == NULL)
59539 + return ERR_PTR(-ENOMEM);
59540 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59541 + return ERR_PTR(-EFAULT);
59542 + (*(i_tmp + i_num))->iface = tmp;
59543 + }
59544 +
59545 + s_tmp->ips = i_tmp;
59546 +
59547 +insert:
59548 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59549 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59550 + return ERR_PTR(-ENOMEM);
59551 +
59552 + return s_tmp;
59553 +}
59554 +
59555 +static int
59556 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59557 +{
59558 + struct acl_subject_label s_pre;
59559 + struct acl_subject_label * ret;
59560 + int err;
59561 +
59562 + while (userp) {
59563 + if (copy_from_user(&s_pre, userp,
59564 + sizeof (struct acl_subject_label)))
59565 + return -EFAULT;
59566 +
59567 + ret = do_copy_user_subj(userp, role, NULL);
59568 +
59569 + err = PTR_ERR(ret);
59570 + if (IS_ERR(ret))
59571 + return err;
59572 +
59573 + insert_acl_subj_label(ret, role);
59574 +
59575 + userp = s_pre.prev;
59576 + }
59577 +
59578 + return 0;
59579 +}
59580 +
59581 +static int
59582 +copy_user_acl(struct gr_arg *arg)
59583 +{
59584 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59585 + struct acl_subject_label *subj_list;
59586 + struct sprole_pw *sptmp;
59587 + struct gr_hash_struct *ghash;
59588 + uid_t *domainlist;
59589 + unsigned int r_num;
59590 + unsigned int len;
59591 + char *tmp;
59592 + int err = 0;
59593 + __u16 i;
59594 + __u32 num_subjs;
59595 +
59596 + /* we need a default and kernel role */
59597 + if (arg->role_db.num_roles < 2)
59598 + return -EINVAL;
59599 +
59600 + /* copy special role authentication info from userspace */
59601 +
59602 + num_sprole_pws = arg->num_sprole_pws;
59603 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59604 +
59605 + if (!acl_special_roles && num_sprole_pws)
59606 + return -ENOMEM;
59607 +
59608 + for (i = 0; i < num_sprole_pws; i++) {
59609 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59610 + if (!sptmp)
59611 + return -ENOMEM;
59612 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59613 + sizeof (struct sprole_pw)))
59614 + return -EFAULT;
59615 +
59616 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59617 +
59618 + if (!len || len >= GR_SPROLE_LEN)
59619 + return -EINVAL;
59620 +
59621 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59622 + return -ENOMEM;
59623 +
59624 + if (copy_from_user(tmp, sptmp->rolename, len))
59625 + return -EFAULT;
59626 +
59627 + tmp[len-1] = '\0';
59628 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59629 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59630 +#endif
59631 + sptmp->rolename = tmp;
59632 + acl_special_roles[i] = sptmp;
59633 + }
59634 +
59635 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59636 +
59637 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59638 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59639 +
59640 + if (!r_tmp)
59641 + return -ENOMEM;
59642 +
59643 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59644 + sizeof (struct acl_role_label *)))
59645 + return -EFAULT;
59646 +
59647 + if (copy_from_user(r_tmp, r_utmp2,
59648 + sizeof (struct acl_role_label)))
59649 + return -EFAULT;
59650 +
59651 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59652 +
59653 + if (!len || len >= PATH_MAX)
59654 + return -EINVAL;
59655 +
59656 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59657 + return -ENOMEM;
59658 +
59659 + if (copy_from_user(tmp, r_tmp->rolename, len))
59660 + return -EFAULT;
59661 +
59662 + tmp[len-1] = '\0';
59663 + r_tmp->rolename = tmp;
59664 +
59665 + if (!strcmp(r_tmp->rolename, "default")
59666 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59667 + default_role = r_tmp;
59668 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59669 + kernel_role = r_tmp;
59670 + }
59671 +
59672 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59673 + return -ENOMEM;
59674 +
59675 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59676 + return -EFAULT;
59677 +
59678 + r_tmp->hash = ghash;
59679 +
59680 + num_subjs = count_user_subjs(r_tmp->hash->first);
59681 +
59682 + r_tmp->subj_hash_size = num_subjs;
59683 + r_tmp->subj_hash =
59684 + (struct acl_subject_label **)
59685 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59686 +
59687 + if (!r_tmp->subj_hash)
59688 + return -ENOMEM;
59689 +
59690 + err = copy_user_allowedips(r_tmp);
59691 + if (err)
59692 + return err;
59693 +
59694 + /* copy domain info */
59695 + if (r_tmp->domain_children != NULL) {
59696 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59697 + if (domainlist == NULL)
59698 + return -ENOMEM;
59699 +
59700 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59701 + return -EFAULT;
59702 +
59703 + r_tmp->domain_children = domainlist;
59704 + }
59705 +
59706 + err = copy_user_transitions(r_tmp);
59707 + if (err)
59708 + return err;
59709 +
59710 + memset(r_tmp->subj_hash, 0,
59711 + r_tmp->subj_hash_size *
59712 + sizeof (struct acl_subject_label *));
59713 +
59714 + /* acquire the list of subjects, then NULL out
59715 + the list prior to parsing the subjects for this role,
59716 + as during this parsing the list is replaced with a list
59717 + of *nested* subjects for the role
59718 + */
59719 + subj_list = r_tmp->hash->first;
59720 +
59721 + /* set nested subject list to null */
59722 + r_tmp->hash->first = NULL;
59723 +
59724 + err = copy_user_subjs(subj_list, r_tmp);
59725 +
59726 + if (err)
59727 + return err;
59728 +
59729 + insert_acl_role_label(r_tmp);
59730 + }
59731 +
59732 + if (default_role == NULL || kernel_role == NULL)
59733 + return -EINVAL;
59734 +
59735 + return err;
59736 +}
59737 +
59738 +static int
59739 +gracl_init(struct gr_arg *args)
59740 +{
59741 + int error = 0;
59742 +
59743 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59744 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59745 +
59746 + if (init_variables(args)) {
59747 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59748 + error = -ENOMEM;
59749 + free_variables();
59750 + goto out;
59751 + }
59752 +
59753 + error = copy_user_acl(args);
59754 + free_init_variables();
59755 + if (error) {
59756 + free_variables();
59757 + goto out;
59758 + }
59759 +
59760 + if ((error = gr_set_acls(0))) {
59761 + free_variables();
59762 + goto out;
59763 + }
59764 +
59765 + pax_open_kernel();
59766 + gr_status |= GR_READY;
59767 + pax_close_kernel();
59768 +
59769 + out:
59770 + return error;
59771 +}
59772 +
59773 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59774 +
59775 +static int
59776 +glob_match(const char *p, const char *n)
59777 +{
59778 + char c;
59779 +
59780 + while ((c = *p++) != '\0') {
59781 + switch (c) {
59782 + case '?':
59783 + if (*n == '\0')
59784 + return 1;
59785 + else if (*n == '/')
59786 + return 1;
59787 + break;
59788 + case '\\':
59789 + if (*n != c)
59790 + return 1;
59791 + break;
59792 + case '*':
59793 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59794 + if (*n == '/')
59795 + return 1;
59796 + else if (c == '?') {
59797 + if (*n == '\0')
59798 + return 1;
59799 + else
59800 + ++n;
59801 + }
59802 + }
59803 + if (c == '\0') {
59804 + return 0;
59805 + } else {
59806 + const char *endp;
59807 +
59808 + if ((endp = strchr(n, '/')) == NULL)
59809 + endp = n + strlen(n);
59810 +
59811 + if (c == '[') {
59812 + for (--p; n < endp; ++n)
59813 + if (!glob_match(p, n))
59814 + return 0;
59815 + } else if (c == '/') {
59816 + while (*n != '\0' && *n != '/')
59817 + ++n;
59818 + if (*n == '/' && !glob_match(p, n + 1))
59819 + return 0;
59820 + } else {
59821 + for (--p; n < endp; ++n)
59822 + if (*n == c && !glob_match(p, n))
59823 + return 0;
59824 + }
59825 +
59826 + return 1;
59827 + }
59828 + case '[':
59829 + {
59830 + int not;
59831 + char cold;
59832 +
59833 + if (*n == '\0' || *n == '/')
59834 + return 1;
59835 +
59836 + not = (*p == '!' || *p == '^');
59837 + if (not)
59838 + ++p;
59839 +
59840 + c = *p++;
59841 + for (;;) {
59842 + unsigned char fn = (unsigned char)*n;
59843 +
59844 + if (c == '\0')
59845 + return 1;
59846 + else {
59847 + if (c == fn)
59848 + goto matched;
59849 + cold = c;
59850 + c = *p++;
59851 +
59852 + if (c == '-' && *p != ']') {
59853 + unsigned char cend = *p++;
59854 +
59855 + if (cend == '\0')
59856 + return 1;
59857 +
59858 + if (cold <= fn && fn <= cend)
59859 + goto matched;
59860 +
59861 + c = *p++;
59862 + }
59863 + }
59864 +
59865 + if (c == ']')
59866 + break;
59867 + }
59868 + if (!not)
59869 + return 1;
59870 + break;
59871 + matched:
59872 + while (c != ']') {
59873 + if (c == '\0')
59874 + return 1;
59875 +
59876 + c = *p++;
59877 + }
59878 + if (not)
59879 + return 1;
59880 + }
59881 + break;
59882 + default:
59883 + if (c != *n)
59884 + return 1;
59885 + }
59886 +
59887 + ++n;
59888 + }
59889 +
59890 + if (*n == '\0')
59891 + return 0;
59892 +
59893 + if (*n == '/')
59894 + return 0;
59895 +
59896 + return 1;
59897 +}
59898 +
59899 +static struct acl_object_label *
59900 +chk_glob_label(struct acl_object_label *globbed,
59901 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59902 +{
59903 + struct acl_object_label *tmp;
59904 +
59905 + if (*path == NULL)
59906 + *path = gr_to_filename_nolock(dentry, mnt);
59907 +
59908 + tmp = globbed;
59909 +
59910 + while (tmp) {
59911 + if (!glob_match(tmp->filename, *path))
59912 + return tmp;
59913 + tmp = tmp->next;
59914 + }
59915 +
59916 + return NULL;
59917 +}
59918 +
59919 +static struct acl_object_label *
59920 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59921 + const ino_t curr_ino, const dev_t curr_dev,
59922 + const struct acl_subject_label *subj, char **path, const int checkglob)
59923 +{
59924 + struct acl_subject_label *tmpsubj;
59925 + struct acl_object_label *retval;
59926 + struct acl_object_label *retval2;
59927 +
59928 + tmpsubj = (struct acl_subject_label *) subj;
59929 + read_lock(&gr_inode_lock);
59930 + do {
59931 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59932 + if (retval) {
59933 + if (checkglob && retval->globbed) {
59934 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59935 + if (retval2)
59936 + retval = retval2;
59937 + }
59938 + break;
59939 + }
59940 + } while ((tmpsubj = tmpsubj->parent_subject));
59941 + read_unlock(&gr_inode_lock);
59942 +
59943 + return retval;
59944 +}
59945 +
59946 +static __inline__ struct acl_object_label *
59947 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59948 + struct dentry *curr_dentry,
59949 + const struct acl_subject_label *subj, char **path, const int checkglob)
59950 +{
59951 + int newglob = checkglob;
59952 + ino_t inode;
59953 + dev_t device;
59954 +
59955 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59956 + as we don't want a / * rule to match instead of the / object
59957 + don't do this for create lookups that call this function though, since they're looking up
59958 + on the parent and thus need globbing checks on all paths
59959 + */
59960 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59961 + newglob = GR_NO_GLOB;
59962 +
59963 + spin_lock(&curr_dentry->d_lock);
59964 + inode = curr_dentry->d_inode->i_ino;
59965 + device = __get_dev(curr_dentry);
59966 + spin_unlock(&curr_dentry->d_lock);
59967 +
59968 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59969 +}
59970 +
59971 +#ifdef CONFIG_HUGETLBFS
59972 +static inline bool
59973 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59974 +{
59975 + int i;
59976 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59977 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59978 + return true;
59979 + }
59980 +
59981 + return false;
59982 +}
59983 +#endif
59984 +
59985 +static struct acl_object_label *
59986 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59987 + const struct acl_subject_label *subj, char *path, const int checkglob)
59988 +{
59989 + struct dentry *dentry = (struct dentry *) l_dentry;
59990 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59991 + struct mount *real_mnt = real_mount(mnt);
59992 + struct acl_object_label *retval;
59993 + struct dentry *parent;
59994 +
59995 + br_read_lock(&vfsmount_lock);
59996 + write_seqlock(&rename_lock);
59997 +
59998 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59999 +#ifdef CONFIG_NET
60000 + mnt == sock_mnt ||
60001 +#endif
60002 +#ifdef CONFIG_HUGETLBFS
60003 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60004 +#endif
60005 + /* ignore Eric Biederman */
60006 + IS_PRIVATE(l_dentry->d_inode))) {
60007 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60008 + goto out;
60009 + }
60010 +
60011 + for (;;) {
60012 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60013 + break;
60014 +
60015 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60016 + if (!mnt_has_parent(real_mnt))
60017 + break;
60018 +
60019 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60020 + if (retval != NULL)
60021 + goto out;
60022 +
60023 + dentry = real_mnt->mnt_mountpoint;
60024 + real_mnt = real_mnt->mnt_parent;
60025 + mnt = &real_mnt->mnt;
60026 + continue;
60027 + }
60028 +
60029 + parent = dentry->d_parent;
60030 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60031 + if (retval != NULL)
60032 + goto out;
60033 +
60034 + dentry = parent;
60035 + }
60036 +
60037 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60038 +
60039 + /* real_root is pinned so we don't have to hold a reference */
60040 + if (retval == NULL)
60041 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60042 +out:
60043 + write_sequnlock(&rename_lock);
60044 + br_read_unlock(&vfsmount_lock);
60045 +
60046 + BUG_ON(retval == NULL);
60047 +
60048 + return retval;
60049 +}
60050 +
60051 +static __inline__ struct acl_object_label *
60052 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60053 + const struct acl_subject_label *subj)
60054 +{
60055 + char *path = NULL;
60056 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60057 +}
60058 +
60059 +static __inline__ struct acl_object_label *
60060 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60061 + const struct acl_subject_label *subj)
60062 +{
60063 + char *path = NULL;
60064 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60065 +}
60066 +
60067 +static __inline__ struct acl_object_label *
60068 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60069 + const struct acl_subject_label *subj, char *path)
60070 +{
60071 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60072 +}
60073 +
60074 +static struct acl_subject_label *
60075 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60076 + const struct acl_role_label *role)
60077 +{
60078 + struct dentry *dentry = (struct dentry *) l_dentry;
60079 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60080 + struct mount *real_mnt = real_mount(mnt);
60081 + struct acl_subject_label *retval;
60082 + struct dentry *parent;
60083 +
60084 + br_read_lock(&vfsmount_lock);
60085 + write_seqlock(&rename_lock);
60086 +
60087 + for (;;) {
60088 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60089 + break;
60090 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60091 + if (!mnt_has_parent(real_mnt))
60092 + break;
60093 +
60094 + spin_lock(&dentry->d_lock);
60095 + read_lock(&gr_inode_lock);
60096 + retval =
60097 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60098 + __get_dev(dentry), role);
60099 + read_unlock(&gr_inode_lock);
60100 + spin_unlock(&dentry->d_lock);
60101 + if (retval != NULL)
60102 + goto out;
60103 +
60104 + dentry = real_mnt->mnt_mountpoint;
60105 + real_mnt = real_mnt->mnt_parent;
60106 + mnt = &real_mnt->mnt;
60107 + continue;
60108 + }
60109 +
60110 + spin_lock(&dentry->d_lock);
60111 + read_lock(&gr_inode_lock);
60112 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60113 + __get_dev(dentry), role);
60114 + read_unlock(&gr_inode_lock);
60115 + parent = dentry->d_parent;
60116 + spin_unlock(&dentry->d_lock);
60117 +
60118 + if (retval != NULL)
60119 + goto out;
60120 +
60121 + dentry = parent;
60122 + }
60123 +
60124 + spin_lock(&dentry->d_lock);
60125 + read_lock(&gr_inode_lock);
60126 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60127 + __get_dev(dentry), role);
60128 + read_unlock(&gr_inode_lock);
60129 + spin_unlock(&dentry->d_lock);
60130 +
60131 + if (unlikely(retval == NULL)) {
60132 + /* real_root is pinned, we don't need to hold a reference */
60133 + read_lock(&gr_inode_lock);
60134 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60135 + __get_dev(real_root.dentry), role);
60136 + read_unlock(&gr_inode_lock);
60137 + }
60138 +out:
60139 + write_sequnlock(&rename_lock);
60140 + br_read_unlock(&vfsmount_lock);
60141 +
60142 + BUG_ON(retval == NULL);
60143 +
60144 + return retval;
60145 +}
60146 +
60147 +static void
60148 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60149 +{
60150 + struct task_struct *task = current;
60151 + const struct cred *cred = current_cred();
60152 +
60153 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60154 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60155 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60156 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60157 +
60158 + return;
60159 +}
60160 +
60161 +static void
60162 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60163 +{
60164 + struct task_struct *task = current;
60165 + const struct cred *cred = current_cred();
60166 +
60167 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60168 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60169 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60170 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60171 +
60172 + return;
60173 +}
60174 +
60175 +static void
60176 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60177 +{
60178 + struct task_struct *task = current;
60179 + const struct cred *cred = current_cred();
60180 +
60181 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60182 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60183 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60184 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60185 +
60186 + return;
60187 +}
60188 +
60189 +__u32
60190 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60191 + const struct vfsmount * mnt)
60192 +{
60193 + __u32 retval = mode;
60194 + struct acl_subject_label *curracl;
60195 + struct acl_object_label *currobj;
60196 +
60197 + if (unlikely(!(gr_status & GR_READY)))
60198 + return (mode & ~GR_AUDITS);
60199 +
60200 + curracl = current->acl;
60201 +
60202 + currobj = chk_obj_label(dentry, mnt, curracl);
60203 + retval = currobj->mode & mode;
60204 +
60205 + /* if we're opening a specified transfer file for writing
60206 + (e.g. /dev/initctl), then transfer our role to init
60207 + */
60208 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60209 + current->role->roletype & GR_ROLE_PERSIST)) {
60210 + struct task_struct *task = init_pid_ns.child_reaper;
60211 +
60212 + if (task->role != current->role) {
60213 + task->acl_sp_role = 0;
60214 + task->acl_role_id = current->acl_role_id;
60215 + task->role = current->role;
60216 + rcu_read_lock();
60217 + read_lock(&grsec_exec_file_lock);
60218 + gr_apply_subject_to_task(task);
60219 + read_unlock(&grsec_exec_file_lock);
60220 + rcu_read_unlock();
60221 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60222 + }
60223 + }
60224 +
60225 + if (unlikely
60226 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60227 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60228 + __u32 new_mode = mode;
60229 +
60230 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60231 +
60232 + retval = new_mode;
60233 +
60234 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60235 + new_mode |= GR_INHERIT;
60236 +
60237 + if (!(mode & GR_NOLEARN))
60238 + gr_log_learn(dentry, mnt, new_mode);
60239 + }
60240 +
60241 + return retval;
60242 +}
60243 +
60244 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60245 + const struct dentry *parent,
60246 + const struct vfsmount *mnt)
60247 +{
60248 + struct name_entry *match;
60249 + struct acl_object_label *matchpo;
60250 + struct acl_subject_label *curracl;
60251 + char *path;
60252 +
60253 + if (unlikely(!(gr_status & GR_READY)))
60254 + return NULL;
60255 +
60256 + preempt_disable();
60257 + path = gr_to_filename_rbac(new_dentry, mnt);
60258 + match = lookup_name_entry_create(path);
60259 +
60260 + curracl = current->acl;
60261 +
60262 + if (match) {
60263 + read_lock(&gr_inode_lock);
60264 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60265 + read_unlock(&gr_inode_lock);
60266 +
60267 + if (matchpo) {
60268 + preempt_enable();
60269 + return matchpo;
60270 + }
60271 + }
60272 +
60273 + // lookup parent
60274 +
60275 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60276 +
60277 + preempt_enable();
60278 + return matchpo;
60279 +}
60280 +
60281 +__u32
60282 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60283 + const struct vfsmount * mnt, const __u32 mode)
60284 +{
60285 + struct acl_object_label *matchpo;
60286 + __u32 retval;
60287 +
60288 + if (unlikely(!(gr_status & GR_READY)))
60289 + return (mode & ~GR_AUDITS);
60290 +
60291 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60292 +
60293 + retval = matchpo->mode & mode;
60294 +
60295 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60296 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60297 + __u32 new_mode = mode;
60298 +
60299 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60300 +
60301 + gr_log_learn(new_dentry, mnt, new_mode);
60302 + return new_mode;
60303 + }
60304 +
60305 + return retval;
60306 +}
60307 +
60308 +__u32
60309 +gr_check_link(const struct dentry * new_dentry,
60310 + const struct dentry * parent_dentry,
60311 + const struct vfsmount * parent_mnt,
60312 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60313 +{
60314 + struct acl_object_label *obj;
60315 + __u32 oldmode, newmode;
60316 + __u32 needmode;
60317 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60318 + GR_DELETE | GR_INHERIT;
60319 +
60320 + if (unlikely(!(gr_status & GR_READY)))
60321 + return (GR_CREATE | GR_LINK);
60322 +
60323 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60324 + oldmode = obj->mode;
60325 +
60326 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60327 + newmode = obj->mode;
60328 +
60329 + needmode = newmode & checkmodes;
60330 +
60331 + // old name for hardlink must have at least the permissions of the new name
60332 + if ((oldmode & needmode) != needmode)
60333 + goto bad;
60334 +
60335 + // if old name had restrictions/auditing, make sure the new name does as well
60336 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60337 +
60338 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60339 + if (is_privileged_binary(old_dentry))
60340 + needmode |= GR_SETID;
60341 +
60342 + if ((newmode & needmode) != needmode)
60343 + goto bad;
60344 +
60345 + // enforce minimum permissions
60346 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60347 + return newmode;
60348 +bad:
60349 + needmode = oldmode;
60350 + if (is_privileged_binary(old_dentry))
60351 + needmode |= GR_SETID;
60352 +
60353 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60354 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60355 + return (GR_CREATE | GR_LINK);
60356 + } else if (newmode & GR_SUPPRESS)
60357 + return GR_SUPPRESS;
60358 + else
60359 + return 0;
60360 +}
60361 +
60362 +int
60363 +gr_check_hidden_task(const struct task_struct *task)
60364 +{
60365 + if (unlikely(!(gr_status & GR_READY)))
60366 + return 0;
60367 +
60368 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60369 + return 1;
60370 +
60371 + return 0;
60372 +}
60373 +
60374 +int
60375 +gr_check_protected_task(const struct task_struct *task)
60376 +{
60377 + if (unlikely(!(gr_status & GR_READY) || !task))
60378 + return 0;
60379 +
60380 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60381 + task->acl != current->acl)
60382 + return 1;
60383 +
60384 + return 0;
60385 +}
60386 +
60387 +int
60388 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60389 +{
60390 + struct task_struct *p;
60391 + int ret = 0;
60392 +
60393 + if (unlikely(!(gr_status & GR_READY) || !pid))
60394 + return ret;
60395 +
60396 + read_lock(&tasklist_lock);
60397 + do_each_pid_task(pid, type, p) {
60398 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60399 + p->acl != current->acl) {
60400 + ret = 1;
60401 + goto out;
60402 + }
60403 + } while_each_pid_task(pid, type, p);
60404 +out:
60405 + read_unlock(&tasklist_lock);
60406 +
60407 + return ret;
60408 +}
60409 +
60410 +void
60411 +gr_copy_label(struct task_struct *tsk)
60412 +{
60413 + tsk->signal->used_accept = 0;
60414 + tsk->acl_sp_role = 0;
60415 + tsk->acl_role_id = current->acl_role_id;
60416 + tsk->acl = current->acl;
60417 + tsk->role = current->role;
60418 + tsk->signal->curr_ip = current->signal->curr_ip;
60419 + tsk->signal->saved_ip = current->signal->saved_ip;
60420 + if (current->exec_file)
60421 + get_file(current->exec_file);
60422 + tsk->exec_file = current->exec_file;
60423 + tsk->is_writable = current->is_writable;
60424 + if (unlikely(current->signal->used_accept)) {
60425 + current->signal->curr_ip = 0;
60426 + current->signal->saved_ip = 0;
60427 + }
60428 +
60429 + return;
60430 +}
60431 +
60432 +static void
60433 +gr_set_proc_res(struct task_struct *task)
60434 +{
60435 + struct acl_subject_label *proc;
60436 + unsigned short i;
60437 +
60438 + proc = task->acl;
60439 +
60440 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60441 + return;
60442 +
60443 + for (i = 0; i < RLIM_NLIMITS; i++) {
60444 + if (!(proc->resmask & (1U << i)))
60445 + continue;
60446 +
60447 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60448 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60449 +
60450 + if (i == RLIMIT_CPU)
60451 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60452 + }
60453 +
60454 + return;
60455 +}
60456 +
60457 +extern int __gr_process_user_ban(struct user_struct *user);
60458 +
60459 +int
60460 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60461 +{
60462 + unsigned int i;
60463 + __u16 num;
60464 + uid_t *uidlist;
60465 + uid_t curuid;
60466 + int realok = 0;
60467 + int effectiveok = 0;
60468 + int fsok = 0;
60469 + uid_t globalreal, globaleffective, globalfs;
60470 +
60471 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60472 + struct user_struct *user;
60473 +
60474 + if (!uid_valid(real))
60475 + goto skipit;
60476 +
60477 + /* find user based on global namespace */
60478 +
60479 + globalreal = GR_GLOBAL_UID(real);
60480 +
60481 + user = find_user(make_kuid(&init_user_ns, globalreal));
60482 + if (user == NULL)
60483 + goto skipit;
60484 +
60485 + if (__gr_process_user_ban(user)) {
60486 + /* for find_user */
60487 + free_uid(user);
60488 + return 1;
60489 + }
60490 +
60491 + /* for find_user */
60492 + free_uid(user);
60493 +
60494 +skipit:
60495 +#endif
60496 +
60497 + if (unlikely(!(gr_status & GR_READY)))
60498 + return 0;
60499 +
60500 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60501 + gr_log_learn_uid_change(real, effective, fs);
60502 +
60503 + num = current->acl->user_trans_num;
60504 + uidlist = current->acl->user_transitions;
60505 +
60506 + if (uidlist == NULL)
60507 + return 0;
60508 +
60509 + if (!uid_valid(real)) {
60510 + realok = 1;
60511 + globalreal = (uid_t)-1;
60512 + } else {
60513 + globalreal = GR_GLOBAL_UID(real);
60514 + }
60515 + if (!uid_valid(effective)) {
60516 + effectiveok = 1;
60517 + globaleffective = (uid_t)-1;
60518 + } else {
60519 + globaleffective = GR_GLOBAL_UID(effective);
60520 + }
60521 + if (!uid_valid(fs)) {
60522 + fsok = 1;
60523 + globalfs = (uid_t)-1;
60524 + } else {
60525 + globalfs = GR_GLOBAL_UID(fs);
60526 + }
60527 +
60528 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60529 + for (i = 0; i < num; i++) {
60530 + curuid = uidlist[i];
60531 + if (globalreal == curuid)
60532 + realok = 1;
60533 + if (globaleffective == curuid)
60534 + effectiveok = 1;
60535 + if (globalfs == curuid)
60536 + fsok = 1;
60537 + }
60538 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60539 + for (i = 0; i < num; i++) {
60540 + curuid = uidlist[i];
60541 + if (globalreal == curuid)
60542 + break;
60543 + if (globaleffective == curuid)
60544 + break;
60545 + if (globalfs == curuid)
60546 + break;
60547 + }
60548 + /* not in deny list */
60549 + if (i == num) {
60550 + realok = 1;
60551 + effectiveok = 1;
60552 + fsok = 1;
60553 + }
60554 + }
60555 +
60556 + if (realok && effectiveok && fsok)
60557 + return 0;
60558 + else {
60559 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60560 + return 1;
60561 + }
60562 +}
60563 +
60564 +int
60565 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60566 +{
60567 + unsigned int i;
60568 + __u16 num;
60569 + gid_t *gidlist;
60570 + gid_t curgid;
60571 + int realok = 0;
60572 + int effectiveok = 0;
60573 + int fsok = 0;
60574 + gid_t globalreal, globaleffective, globalfs;
60575 +
60576 + if (unlikely(!(gr_status & GR_READY)))
60577 + return 0;
60578 +
60579 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60580 + gr_log_learn_gid_change(real, effective, fs);
60581 +
60582 + num = current->acl->group_trans_num;
60583 + gidlist = current->acl->group_transitions;
60584 +
60585 + if (gidlist == NULL)
60586 + return 0;
60587 +
60588 + if (!gid_valid(real)) {
60589 + realok = 1;
60590 + globalreal = (gid_t)-1;
60591 + } else {
60592 + globalreal = GR_GLOBAL_GID(real);
60593 + }
60594 + if (!gid_valid(effective)) {
60595 + effectiveok = 1;
60596 + globaleffective = (gid_t)-1;
60597 + } else {
60598 + globaleffective = GR_GLOBAL_GID(effective);
60599 + }
60600 + if (!gid_valid(fs)) {
60601 + fsok = 1;
60602 + globalfs = (gid_t)-1;
60603 + } else {
60604 + globalfs = GR_GLOBAL_GID(fs);
60605 + }
60606 +
60607 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60608 + for (i = 0; i < num; i++) {
60609 + curgid = gidlist[i];
60610 + if (globalreal == curgid)
60611 + realok = 1;
60612 + if (globaleffective == curgid)
60613 + effectiveok = 1;
60614 + if (globalfs == curgid)
60615 + fsok = 1;
60616 + }
60617 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60618 + for (i = 0; i < num; i++) {
60619 + curgid = gidlist[i];
60620 + if (globalreal == curgid)
60621 + break;
60622 + if (globaleffective == curgid)
60623 + break;
60624 + if (globalfs == curgid)
60625 + break;
60626 + }
60627 + /* not in deny list */
60628 + if (i == num) {
60629 + realok = 1;
60630 + effectiveok = 1;
60631 + fsok = 1;
60632 + }
60633 + }
60634 +
60635 + if (realok && effectiveok && fsok)
60636 + return 0;
60637 + else {
60638 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60639 + return 1;
60640 + }
60641 +}
60642 +
60643 +extern int gr_acl_is_capable(const int cap);
60644 +
60645 +void
60646 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60647 +{
60648 + struct acl_role_label *role = task->role;
60649 + struct acl_subject_label *subj = NULL;
60650 + struct acl_object_label *obj;
60651 + struct file *filp;
60652 + uid_t uid;
60653 + gid_t gid;
60654 +
60655 + if (unlikely(!(gr_status & GR_READY)))
60656 + return;
60657 +
60658 + uid = GR_GLOBAL_UID(kuid);
60659 + gid = GR_GLOBAL_GID(kgid);
60660 +
60661 + filp = task->exec_file;
60662 +
60663 + /* kernel process, we'll give them the kernel role */
60664 + if (unlikely(!filp)) {
60665 + task->role = kernel_role;
60666 + task->acl = kernel_role->root_label;
60667 + return;
60668 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60669 + role = lookup_acl_role_label(task, uid, gid);
60670 +
60671 + /* don't change the role if we're not a privileged process */
60672 + if (role && task->role != role &&
60673 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60674 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60675 + return;
60676 +
60677 + /* perform subject lookup in possibly new role
60678 + we can use this result below in the case where role == task->role
60679 + */
60680 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60681 +
60682 + /* if we changed uid/gid, but result in the same role
60683 + and are using inheritance, don't lose the inherited subject
60684 + if current subject is other than what normal lookup
60685 + would result in, we arrived via inheritance, don't
60686 + lose subject
60687 + */
60688 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60689 + (subj == task->acl)))
60690 + task->acl = subj;
60691 +
60692 + task->role = role;
60693 +
60694 + task->is_writable = 0;
60695 +
60696 + /* ignore additional mmap checks for processes that are writable
60697 + by the default ACL */
60698 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60699 + if (unlikely(obj->mode & GR_WRITE))
60700 + task->is_writable = 1;
60701 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60702 + if (unlikely(obj->mode & GR_WRITE))
60703 + task->is_writable = 1;
60704 +
60705 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60706 + 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);
60707 +#endif
60708 +
60709 + gr_set_proc_res(task);
60710 +
60711 + return;
60712 +}
60713 +
60714 +int
60715 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60716 + const int unsafe_flags)
60717 +{
60718 + struct task_struct *task = current;
60719 + struct acl_subject_label *newacl;
60720 + struct acl_object_label *obj;
60721 + __u32 retmode;
60722 +
60723 + if (unlikely(!(gr_status & GR_READY)))
60724 + return 0;
60725 +
60726 + newacl = chk_subj_label(dentry, mnt, task->role);
60727 +
60728 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60729 + did an exec
60730 + */
60731 + rcu_read_lock();
60732 + read_lock(&tasklist_lock);
60733 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60734 + (task->parent->acl->mode & GR_POVERRIDE))) {
60735 + read_unlock(&tasklist_lock);
60736 + rcu_read_unlock();
60737 + goto skip_check;
60738 + }
60739 + read_unlock(&tasklist_lock);
60740 + rcu_read_unlock();
60741 +
60742 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60743 + !(task->role->roletype & GR_ROLE_GOD) &&
60744 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60745 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60746 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60747 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60748 + else
60749 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60750 + return -EACCES;
60751 + }
60752 +
60753 +skip_check:
60754 +
60755 + obj = chk_obj_label(dentry, mnt, task->acl);
60756 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60757 +
60758 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60759 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60760 + if (obj->nested)
60761 + task->acl = obj->nested;
60762 + else
60763 + task->acl = newacl;
60764 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60765 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60766 +
60767 + task->is_writable = 0;
60768 +
60769 + /* ignore additional mmap checks for processes that are writable
60770 + by the default ACL */
60771 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60772 + if (unlikely(obj->mode & GR_WRITE))
60773 + task->is_writable = 1;
60774 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60775 + if (unlikely(obj->mode & GR_WRITE))
60776 + task->is_writable = 1;
60777 +
60778 + gr_set_proc_res(task);
60779 +
60780 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60781 + 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);
60782 +#endif
60783 + return 0;
60784 +}
60785 +
60786 +/* always called with valid inodev ptr */
60787 +static void
60788 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60789 +{
60790 + struct acl_object_label *matchpo;
60791 + struct acl_subject_label *matchps;
60792 + struct acl_subject_label *subj;
60793 + struct acl_role_label *role;
60794 + unsigned int x;
60795 +
60796 + FOR_EACH_ROLE_START(role)
60797 + FOR_EACH_SUBJECT_START(role, subj, x)
60798 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60799 + matchpo->mode |= GR_DELETED;
60800 + FOR_EACH_SUBJECT_END(subj,x)
60801 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60802 + /* nested subjects aren't in the role's subj_hash table */
60803 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60804 + matchpo->mode |= GR_DELETED;
60805 + FOR_EACH_NESTED_SUBJECT_END(subj)
60806 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60807 + matchps->mode |= GR_DELETED;
60808 + FOR_EACH_ROLE_END(role)
60809 +
60810 + inodev->nentry->deleted = 1;
60811 +
60812 + return;
60813 +}
60814 +
60815 +void
60816 +gr_handle_delete(const ino_t ino, const dev_t dev)
60817 +{
60818 + struct inodev_entry *inodev;
60819 +
60820 + if (unlikely(!(gr_status & GR_READY)))
60821 + return;
60822 +
60823 + write_lock(&gr_inode_lock);
60824 + inodev = lookup_inodev_entry(ino, dev);
60825 + if (inodev != NULL)
60826 + do_handle_delete(inodev, ino, dev);
60827 + write_unlock(&gr_inode_lock);
60828 +
60829 + return;
60830 +}
60831 +
60832 +static void
60833 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60834 + const ino_t newinode, const dev_t newdevice,
60835 + struct acl_subject_label *subj)
60836 +{
60837 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60838 + struct acl_object_label *match;
60839 +
60840 + match = subj->obj_hash[index];
60841 +
60842 + while (match && (match->inode != oldinode ||
60843 + match->device != olddevice ||
60844 + !(match->mode & GR_DELETED)))
60845 + match = match->next;
60846 +
60847 + if (match && (match->inode == oldinode)
60848 + && (match->device == olddevice)
60849 + && (match->mode & GR_DELETED)) {
60850 + if (match->prev == NULL) {
60851 + subj->obj_hash[index] = match->next;
60852 + if (match->next != NULL)
60853 + match->next->prev = NULL;
60854 + } else {
60855 + match->prev->next = match->next;
60856 + if (match->next != NULL)
60857 + match->next->prev = match->prev;
60858 + }
60859 + match->prev = NULL;
60860 + match->next = NULL;
60861 + match->inode = newinode;
60862 + match->device = newdevice;
60863 + match->mode &= ~GR_DELETED;
60864 +
60865 + insert_acl_obj_label(match, subj);
60866 + }
60867 +
60868 + return;
60869 +}
60870 +
60871 +static void
60872 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60873 + const ino_t newinode, const dev_t newdevice,
60874 + struct acl_role_label *role)
60875 +{
60876 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60877 + struct acl_subject_label *match;
60878 +
60879 + match = role->subj_hash[index];
60880 +
60881 + while (match && (match->inode != oldinode ||
60882 + match->device != olddevice ||
60883 + !(match->mode & GR_DELETED)))
60884 + match = match->next;
60885 +
60886 + if (match && (match->inode == oldinode)
60887 + && (match->device == olddevice)
60888 + && (match->mode & GR_DELETED)) {
60889 + if (match->prev == NULL) {
60890 + role->subj_hash[index] = match->next;
60891 + if (match->next != NULL)
60892 + match->next->prev = NULL;
60893 + } else {
60894 + match->prev->next = match->next;
60895 + if (match->next != NULL)
60896 + match->next->prev = match->prev;
60897 + }
60898 + match->prev = NULL;
60899 + match->next = NULL;
60900 + match->inode = newinode;
60901 + match->device = newdevice;
60902 + match->mode &= ~GR_DELETED;
60903 +
60904 + insert_acl_subj_label(match, role);
60905 + }
60906 +
60907 + return;
60908 +}
60909 +
60910 +static void
60911 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60912 + const ino_t newinode, const dev_t newdevice)
60913 +{
60914 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60915 + struct inodev_entry *match;
60916 +
60917 + match = inodev_set.i_hash[index];
60918 +
60919 + while (match && (match->nentry->inode != oldinode ||
60920 + match->nentry->device != olddevice || !match->nentry->deleted))
60921 + match = match->next;
60922 +
60923 + if (match && (match->nentry->inode == oldinode)
60924 + && (match->nentry->device == olddevice) &&
60925 + match->nentry->deleted) {
60926 + if (match->prev == NULL) {
60927 + inodev_set.i_hash[index] = match->next;
60928 + if (match->next != NULL)
60929 + match->next->prev = NULL;
60930 + } else {
60931 + match->prev->next = match->next;
60932 + if (match->next != NULL)
60933 + match->next->prev = match->prev;
60934 + }
60935 + match->prev = NULL;
60936 + match->next = NULL;
60937 + match->nentry->inode = newinode;
60938 + match->nentry->device = newdevice;
60939 + match->nentry->deleted = 0;
60940 +
60941 + insert_inodev_entry(match);
60942 + }
60943 +
60944 + return;
60945 +}
60946 +
60947 +static void
60948 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60949 +{
60950 + struct acl_subject_label *subj;
60951 + struct acl_role_label *role;
60952 + unsigned int x;
60953 +
60954 + FOR_EACH_ROLE_START(role)
60955 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60956 +
60957 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60958 + if ((subj->inode == ino) && (subj->device == dev)) {
60959 + subj->inode = ino;
60960 + subj->device = dev;
60961 + }
60962 + /* nested subjects aren't in the role's subj_hash table */
60963 + update_acl_obj_label(matchn->inode, matchn->device,
60964 + ino, dev, subj);
60965 + FOR_EACH_NESTED_SUBJECT_END(subj)
60966 + FOR_EACH_SUBJECT_START(role, subj, x)
60967 + update_acl_obj_label(matchn->inode, matchn->device,
60968 + ino, dev, subj);
60969 + FOR_EACH_SUBJECT_END(subj,x)
60970 + FOR_EACH_ROLE_END(role)
60971 +
60972 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60973 +
60974 + return;
60975 +}
60976 +
60977 +static void
60978 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60979 + const struct vfsmount *mnt)
60980 +{
60981 + ino_t ino = dentry->d_inode->i_ino;
60982 + dev_t dev = __get_dev(dentry);
60983 +
60984 + __do_handle_create(matchn, ino, dev);
60985 +
60986 + return;
60987 +}
60988 +
60989 +void
60990 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60991 +{
60992 + struct name_entry *matchn;
60993 +
60994 + if (unlikely(!(gr_status & GR_READY)))
60995 + return;
60996 +
60997 + preempt_disable();
60998 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60999 +
61000 + if (unlikely((unsigned long)matchn)) {
61001 + write_lock(&gr_inode_lock);
61002 + do_handle_create(matchn, dentry, mnt);
61003 + write_unlock(&gr_inode_lock);
61004 + }
61005 + preempt_enable();
61006 +
61007 + return;
61008 +}
61009 +
61010 +void
61011 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61012 +{
61013 + struct name_entry *matchn;
61014 +
61015 + if (unlikely(!(gr_status & GR_READY)))
61016 + return;
61017 +
61018 + preempt_disable();
61019 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61020 +
61021 + if (unlikely((unsigned long)matchn)) {
61022 + write_lock(&gr_inode_lock);
61023 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61024 + write_unlock(&gr_inode_lock);
61025 + }
61026 + preempt_enable();
61027 +
61028 + return;
61029 +}
61030 +
61031 +void
61032 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61033 + struct dentry *old_dentry,
61034 + struct dentry *new_dentry,
61035 + struct vfsmount *mnt, const __u8 replace)
61036 +{
61037 + struct name_entry *matchn;
61038 + struct inodev_entry *inodev;
61039 + struct inode *inode = new_dentry->d_inode;
61040 + ino_t old_ino = old_dentry->d_inode->i_ino;
61041 + dev_t old_dev = __get_dev(old_dentry);
61042 +
61043 + /* vfs_rename swaps the name and parent link for old_dentry and
61044 + new_dentry
61045 + at this point, old_dentry has the new name, parent link, and inode
61046 + for the renamed file
61047 + if a file is being replaced by a rename, new_dentry has the inode
61048 + and name for the replaced file
61049 + */
61050 +
61051 + if (unlikely(!(gr_status & GR_READY)))
61052 + return;
61053 +
61054 + preempt_disable();
61055 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61056 +
61057 + /* we wouldn't have to check d_inode if it weren't for
61058 + NFS silly-renaming
61059 + */
61060 +
61061 + write_lock(&gr_inode_lock);
61062 + if (unlikely(replace && inode)) {
61063 + ino_t new_ino = inode->i_ino;
61064 + dev_t new_dev = __get_dev(new_dentry);
61065 +
61066 + inodev = lookup_inodev_entry(new_ino, new_dev);
61067 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61068 + do_handle_delete(inodev, new_ino, new_dev);
61069 + }
61070 +
61071 + inodev = lookup_inodev_entry(old_ino, old_dev);
61072 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61073 + do_handle_delete(inodev, old_ino, old_dev);
61074 +
61075 + if (unlikely((unsigned long)matchn))
61076 + do_handle_create(matchn, old_dentry, mnt);
61077 +
61078 + write_unlock(&gr_inode_lock);
61079 + preempt_enable();
61080 +
61081 + return;
61082 +}
61083 +
61084 +static int
61085 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61086 + unsigned char **sum)
61087 +{
61088 + struct acl_role_label *r;
61089 + struct role_allowed_ip *ipp;
61090 + struct role_transition *trans;
61091 + unsigned int i;
61092 + int found = 0;
61093 + u32 curr_ip = current->signal->curr_ip;
61094 +
61095 + current->signal->saved_ip = curr_ip;
61096 +
61097 + /* check transition table */
61098 +
61099 + for (trans = current->role->transitions; trans; trans = trans->next) {
61100 + if (!strcmp(rolename, trans->rolename)) {
61101 + found = 1;
61102 + break;
61103 + }
61104 + }
61105 +
61106 + if (!found)
61107 + return 0;
61108 +
61109 + /* handle special roles that do not require authentication
61110 + and check ip */
61111 +
61112 + FOR_EACH_ROLE_START(r)
61113 + if (!strcmp(rolename, r->rolename) &&
61114 + (r->roletype & GR_ROLE_SPECIAL)) {
61115 + found = 0;
61116 + if (r->allowed_ips != NULL) {
61117 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61118 + if ((ntohl(curr_ip) & ipp->netmask) ==
61119 + (ntohl(ipp->addr) & ipp->netmask))
61120 + found = 1;
61121 + }
61122 + } else
61123 + found = 2;
61124 + if (!found)
61125 + return 0;
61126 +
61127 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61128 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61129 + *salt = NULL;
61130 + *sum = NULL;
61131 + return 1;
61132 + }
61133 + }
61134 + FOR_EACH_ROLE_END(r)
61135 +
61136 + for (i = 0; i < num_sprole_pws; i++) {
61137 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61138 + *salt = acl_special_roles[i]->salt;
61139 + *sum = acl_special_roles[i]->sum;
61140 + return 1;
61141 + }
61142 + }
61143 +
61144 + return 0;
61145 +}
61146 +
61147 +static void
61148 +assign_special_role(char *rolename)
61149 +{
61150 + struct acl_object_label *obj;
61151 + struct acl_role_label *r;
61152 + struct acl_role_label *assigned = NULL;
61153 + struct task_struct *tsk;
61154 + struct file *filp;
61155 +
61156 + FOR_EACH_ROLE_START(r)
61157 + if (!strcmp(rolename, r->rolename) &&
61158 + (r->roletype & GR_ROLE_SPECIAL)) {
61159 + assigned = r;
61160 + break;
61161 + }
61162 + FOR_EACH_ROLE_END(r)
61163 +
61164 + if (!assigned)
61165 + return;
61166 +
61167 + read_lock(&tasklist_lock);
61168 + read_lock(&grsec_exec_file_lock);
61169 +
61170 + tsk = current->real_parent;
61171 + if (tsk == NULL)
61172 + goto out_unlock;
61173 +
61174 + filp = tsk->exec_file;
61175 + if (filp == NULL)
61176 + goto out_unlock;
61177 +
61178 + tsk->is_writable = 0;
61179 +
61180 + tsk->acl_sp_role = 1;
61181 + tsk->acl_role_id = ++acl_sp_role_value;
61182 + tsk->role = assigned;
61183 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61184 +
61185 + /* ignore additional mmap checks for processes that are writable
61186 + by the default ACL */
61187 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61188 + if (unlikely(obj->mode & GR_WRITE))
61189 + tsk->is_writable = 1;
61190 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61191 + if (unlikely(obj->mode & GR_WRITE))
61192 + tsk->is_writable = 1;
61193 +
61194 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61195 + 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));
61196 +#endif
61197 +
61198 +out_unlock:
61199 + read_unlock(&grsec_exec_file_lock);
61200 + read_unlock(&tasklist_lock);
61201 + return;
61202 +}
61203 +
61204 +int gr_check_secure_terminal(struct task_struct *task)
61205 +{
61206 + struct task_struct *p, *p2, *p3;
61207 + struct files_struct *files;
61208 + struct fdtable *fdt;
61209 + struct file *our_file = NULL, *file;
61210 + int i;
61211 +
61212 + if (task->signal->tty == NULL)
61213 + return 1;
61214 +
61215 + files = get_files_struct(task);
61216 + if (files != NULL) {
61217 + rcu_read_lock();
61218 + fdt = files_fdtable(files);
61219 + for (i=0; i < fdt->max_fds; i++) {
61220 + file = fcheck_files(files, i);
61221 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61222 + get_file(file);
61223 + our_file = file;
61224 + }
61225 + }
61226 + rcu_read_unlock();
61227 + put_files_struct(files);
61228 + }
61229 +
61230 + if (our_file == NULL)
61231 + return 1;
61232 +
61233 + read_lock(&tasklist_lock);
61234 + do_each_thread(p2, p) {
61235 + files = get_files_struct(p);
61236 + if (files == NULL ||
61237 + (p->signal && p->signal->tty == task->signal->tty)) {
61238 + if (files != NULL)
61239 + put_files_struct(files);
61240 + continue;
61241 + }
61242 + rcu_read_lock();
61243 + fdt = files_fdtable(files);
61244 + for (i=0; i < fdt->max_fds; i++) {
61245 + file = fcheck_files(files, i);
61246 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61247 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61248 + p3 = task;
61249 + while (task_pid_nr(p3) > 0) {
61250 + if (p3 == p)
61251 + break;
61252 + p3 = p3->real_parent;
61253 + }
61254 + if (p3 == p)
61255 + break;
61256 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61257 + gr_handle_alertkill(p);
61258 + rcu_read_unlock();
61259 + put_files_struct(files);
61260 + read_unlock(&tasklist_lock);
61261 + fput(our_file);
61262 + return 0;
61263 + }
61264 + }
61265 + rcu_read_unlock();
61266 + put_files_struct(files);
61267 + } while_each_thread(p2, p);
61268 + read_unlock(&tasklist_lock);
61269 +
61270 + fput(our_file);
61271 + return 1;
61272 +}
61273 +
61274 +static int gr_rbac_disable(void *unused)
61275 +{
61276 + pax_open_kernel();
61277 + gr_status &= ~GR_READY;
61278 + pax_close_kernel();
61279 +
61280 + return 0;
61281 +}
61282 +
61283 +ssize_t
61284 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61285 +{
61286 + struct gr_arg_wrapper uwrap;
61287 + unsigned char *sprole_salt = NULL;
61288 + unsigned char *sprole_sum = NULL;
61289 + int error = sizeof (struct gr_arg_wrapper);
61290 + int error2 = 0;
61291 +
61292 + mutex_lock(&gr_dev_mutex);
61293 +
61294 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61295 + error = -EPERM;
61296 + goto out;
61297 + }
61298 +
61299 + if (count != sizeof (struct gr_arg_wrapper)) {
61300 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61301 + error = -EINVAL;
61302 + goto out;
61303 + }
61304 +
61305 +
61306 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61307 + gr_auth_expires = 0;
61308 + gr_auth_attempts = 0;
61309 + }
61310 +
61311 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61312 + error = -EFAULT;
61313 + goto out;
61314 + }
61315 +
61316 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61317 + error = -EINVAL;
61318 + goto out;
61319 + }
61320 +
61321 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61322 + error = -EFAULT;
61323 + goto out;
61324 + }
61325 +
61326 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61327 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61328 + time_after(gr_auth_expires, get_seconds())) {
61329 + error = -EBUSY;
61330 + goto out;
61331 + }
61332 +
61333 + /* if non-root trying to do anything other than use a special role,
61334 + do not attempt authentication, do not count towards authentication
61335 + locking
61336 + */
61337 +
61338 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61339 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61340 + gr_is_global_nonroot(current_uid())) {
61341 + error = -EPERM;
61342 + goto out;
61343 + }
61344 +
61345 + /* ensure pw and special role name are null terminated */
61346 +
61347 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61348 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61349 +
61350 + /* Okay.
61351 + * We have our enough of the argument structure..(we have yet
61352 + * to copy_from_user the tables themselves) . Copy the tables
61353 + * only if we need them, i.e. for loading operations. */
61354 +
61355 + switch (gr_usermode->mode) {
61356 + case GR_STATUS:
61357 + if (gr_status & GR_READY) {
61358 + error = 1;
61359 + if (!gr_check_secure_terminal(current))
61360 + error = 3;
61361 + } else
61362 + error = 2;
61363 + goto out;
61364 + case GR_SHUTDOWN:
61365 + if ((gr_status & GR_READY)
61366 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61367 + stop_machine(gr_rbac_disable, NULL, NULL);
61368 + free_variables();
61369 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61370 + memset(gr_system_salt, 0, GR_SALT_LEN);
61371 + memset(gr_system_sum, 0, GR_SHA_LEN);
61372 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61373 + } else if (gr_status & GR_READY) {
61374 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61375 + error = -EPERM;
61376 + } else {
61377 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61378 + error = -EAGAIN;
61379 + }
61380 + break;
61381 + case GR_ENABLE:
61382 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61383 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61384 + else {
61385 + if (gr_status & GR_READY)
61386 + error = -EAGAIN;
61387 + else
61388 + error = error2;
61389 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61390 + }
61391 + break;
61392 + case GR_RELOAD:
61393 + if (!(gr_status & GR_READY)) {
61394 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61395 + error = -EAGAIN;
61396 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61397 + stop_machine(gr_rbac_disable, NULL, NULL);
61398 + free_variables();
61399 + error2 = gracl_init(gr_usermode);
61400 + if (!error2)
61401 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61402 + else {
61403 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61404 + error = error2;
61405 + }
61406 + } else {
61407 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61408 + error = -EPERM;
61409 + }
61410 + break;
61411 + case GR_SEGVMOD:
61412 + if (unlikely(!(gr_status & GR_READY))) {
61413 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61414 + error = -EAGAIN;
61415 + break;
61416 + }
61417 +
61418 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61419 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61420 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61421 + struct acl_subject_label *segvacl;
61422 + segvacl =
61423 + lookup_acl_subj_label(gr_usermode->segv_inode,
61424 + gr_usermode->segv_device,
61425 + current->role);
61426 + if (segvacl) {
61427 + segvacl->crashes = 0;
61428 + segvacl->expires = 0;
61429 + }
61430 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61431 + gr_remove_uid(gr_usermode->segv_uid);
61432 + }
61433 + } else {
61434 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61435 + error = -EPERM;
61436 + }
61437 + break;
61438 + case GR_SPROLE:
61439 + case GR_SPROLEPAM:
61440 + if (unlikely(!(gr_status & GR_READY))) {
61441 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61442 + error = -EAGAIN;
61443 + break;
61444 + }
61445 +
61446 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61447 + current->role->expires = 0;
61448 + current->role->auth_attempts = 0;
61449 + }
61450 +
61451 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61452 + time_after(current->role->expires, get_seconds())) {
61453 + error = -EBUSY;
61454 + goto out;
61455 + }
61456 +
61457 + if (lookup_special_role_auth
61458 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61459 + && ((!sprole_salt && !sprole_sum)
61460 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61461 + char *p = "";
61462 + assign_special_role(gr_usermode->sp_role);
61463 + read_lock(&tasklist_lock);
61464 + if (current->real_parent)
61465 + p = current->real_parent->role->rolename;
61466 + read_unlock(&tasklist_lock);
61467 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61468 + p, acl_sp_role_value);
61469 + } else {
61470 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61471 + error = -EPERM;
61472 + if(!(current->role->auth_attempts++))
61473 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61474 +
61475 + goto out;
61476 + }
61477 + break;
61478 + case GR_UNSPROLE:
61479 + if (unlikely(!(gr_status & GR_READY))) {
61480 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61481 + error = -EAGAIN;
61482 + break;
61483 + }
61484 +
61485 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61486 + char *p = "";
61487 + int i = 0;
61488 +
61489 + read_lock(&tasklist_lock);
61490 + if (current->real_parent) {
61491 + p = current->real_parent->role->rolename;
61492 + i = current->real_parent->acl_role_id;
61493 + }
61494 + read_unlock(&tasklist_lock);
61495 +
61496 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61497 + gr_set_acls(1);
61498 + } else {
61499 + error = -EPERM;
61500 + goto out;
61501 + }
61502 + break;
61503 + default:
61504 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61505 + error = -EINVAL;
61506 + break;
61507 + }
61508 +
61509 + if (error != -EPERM)
61510 + goto out;
61511 +
61512 + if(!(gr_auth_attempts++))
61513 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61514 +
61515 + out:
61516 + mutex_unlock(&gr_dev_mutex);
61517 + return error;
61518 +}
61519 +
61520 +/* must be called with
61521 + rcu_read_lock();
61522 + read_lock(&tasklist_lock);
61523 + read_lock(&grsec_exec_file_lock);
61524 +*/
61525 +int gr_apply_subject_to_task(struct task_struct *task)
61526 +{
61527 + struct acl_object_label *obj;
61528 + char *tmpname;
61529 + struct acl_subject_label *tmpsubj;
61530 + struct file *filp;
61531 + struct name_entry *nmatch;
61532 +
61533 + filp = task->exec_file;
61534 + if (filp == NULL)
61535 + return 0;
61536 +
61537 + /* the following is to apply the correct subject
61538 + on binaries running when the RBAC system
61539 + is enabled, when the binaries have been
61540 + replaced or deleted since their execution
61541 + -----
61542 + when the RBAC system starts, the inode/dev
61543 + from exec_file will be one the RBAC system
61544 + is unaware of. It only knows the inode/dev
61545 + of the present file on disk, or the absence
61546 + of it.
61547 + */
61548 + preempt_disable();
61549 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61550 +
61551 + nmatch = lookup_name_entry(tmpname);
61552 + preempt_enable();
61553 + tmpsubj = NULL;
61554 + if (nmatch) {
61555 + if (nmatch->deleted)
61556 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61557 + else
61558 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61559 + if (tmpsubj != NULL)
61560 + task->acl = tmpsubj;
61561 + }
61562 + if (tmpsubj == NULL)
61563 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61564 + task->role);
61565 + if (task->acl) {
61566 + task->is_writable = 0;
61567 + /* ignore additional mmap checks for processes that are writable
61568 + by the default ACL */
61569 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61570 + if (unlikely(obj->mode & GR_WRITE))
61571 + task->is_writable = 1;
61572 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61573 + if (unlikely(obj->mode & GR_WRITE))
61574 + task->is_writable = 1;
61575 +
61576 + gr_set_proc_res(task);
61577 +
61578 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61579 + 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);
61580 +#endif
61581 + } else {
61582 + return 1;
61583 + }
61584 +
61585 + return 0;
61586 +}
61587 +
61588 +int
61589 +gr_set_acls(const int type)
61590 +{
61591 + struct task_struct *task, *task2;
61592 + struct acl_role_label *role = current->role;
61593 + __u16 acl_role_id = current->acl_role_id;
61594 + const struct cred *cred;
61595 + int ret;
61596 +
61597 + rcu_read_lock();
61598 + read_lock(&tasklist_lock);
61599 + read_lock(&grsec_exec_file_lock);
61600 + do_each_thread(task2, task) {
61601 + /* check to see if we're called from the exit handler,
61602 + if so, only replace ACLs that have inherited the admin
61603 + ACL */
61604 +
61605 + if (type && (task->role != role ||
61606 + task->acl_role_id != acl_role_id))
61607 + continue;
61608 +
61609 + task->acl_role_id = 0;
61610 + task->acl_sp_role = 0;
61611 +
61612 + if (task->exec_file) {
61613 + cred = __task_cred(task);
61614 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61615 + ret = gr_apply_subject_to_task(task);
61616 + if (ret) {
61617 + read_unlock(&grsec_exec_file_lock);
61618 + read_unlock(&tasklist_lock);
61619 + rcu_read_unlock();
61620 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61621 + return ret;
61622 + }
61623 + } else {
61624 + // it's a kernel process
61625 + task->role = kernel_role;
61626 + task->acl = kernel_role->root_label;
61627 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61628 + task->acl->mode &= ~GR_PROCFIND;
61629 +#endif
61630 + }
61631 + } while_each_thread(task2, task);
61632 + read_unlock(&grsec_exec_file_lock);
61633 + read_unlock(&tasklist_lock);
61634 + rcu_read_unlock();
61635 +
61636 + return 0;
61637 +}
61638 +
61639 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61640 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61641 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61642 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61643 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61644 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61645 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61646 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61647 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61648 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61649 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61650 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61651 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61652 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61653 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61654 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61655 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61656 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61657 +};
61658 +
61659 +void
61660 +gr_learn_resource(const struct task_struct *task,
61661 + const int res, const unsigned long wanted, const int gt)
61662 +{
61663 + struct acl_subject_label *acl;
61664 + const struct cred *cred;
61665 +
61666 + if (unlikely((gr_status & GR_READY) &&
61667 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61668 + goto skip_reslog;
61669 +
61670 + gr_log_resource(task, res, wanted, gt);
61671 +skip_reslog:
61672 +
61673 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61674 + return;
61675 +
61676 + acl = task->acl;
61677 +
61678 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61679 + !(acl->resmask & (1U << (unsigned short) res))))
61680 + return;
61681 +
61682 + if (wanted >= acl->res[res].rlim_cur) {
61683 + unsigned long res_add;
61684 +
61685 + res_add = wanted + res_learn_bumps[res];
61686 +
61687 + acl->res[res].rlim_cur = res_add;
61688 +
61689 + if (wanted > acl->res[res].rlim_max)
61690 + acl->res[res].rlim_max = res_add;
61691 +
61692 + /* only log the subject filename, since resource logging is supported for
61693 + single-subject learning only */
61694 + rcu_read_lock();
61695 + cred = __task_cred(task);
61696 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61697 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61698 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61699 + "", (unsigned long) res, &task->signal->saved_ip);
61700 + rcu_read_unlock();
61701 + }
61702 +
61703 + return;
61704 +}
61705 +EXPORT_SYMBOL(gr_learn_resource);
61706 +#endif
61707 +
61708 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61709 +void
61710 +pax_set_initial_flags(struct linux_binprm *bprm)
61711 +{
61712 + struct task_struct *task = current;
61713 + struct acl_subject_label *proc;
61714 + unsigned long flags;
61715 +
61716 + if (unlikely(!(gr_status & GR_READY)))
61717 + return;
61718 +
61719 + flags = pax_get_flags(task);
61720 +
61721 + proc = task->acl;
61722 +
61723 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61724 + flags &= ~MF_PAX_PAGEEXEC;
61725 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61726 + flags &= ~MF_PAX_SEGMEXEC;
61727 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61728 + flags &= ~MF_PAX_RANDMMAP;
61729 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61730 + flags &= ~MF_PAX_EMUTRAMP;
61731 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61732 + flags &= ~MF_PAX_MPROTECT;
61733 +
61734 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61735 + flags |= MF_PAX_PAGEEXEC;
61736 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61737 + flags |= MF_PAX_SEGMEXEC;
61738 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61739 + flags |= MF_PAX_RANDMMAP;
61740 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61741 + flags |= MF_PAX_EMUTRAMP;
61742 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61743 + flags |= MF_PAX_MPROTECT;
61744 +
61745 + pax_set_flags(task, flags);
61746 +
61747 + return;
61748 +}
61749 +#endif
61750 +
61751 +int
61752 +gr_handle_proc_ptrace(struct task_struct *task)
61753 +{
61754 + struct file *filp;
61755 + struct task_struct *tmp = task;
61756 + struct task_struct *curtemp = current;
61757 + __u32 retmode;
61758 +
61759 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61760 + if (unlikely(!(gr_status & GR_READY)))
61761 + return 0;
61762 +#endif
61763 +
61764 + read_lock(&tasklist_lock);
61765 + read_lock(&grsec_exec_file_lock);
61766 + filp = task->exec_file;
61767 +
61768 + while (task_pid_nr(tmp) > 0) {
61769 + if (tmp == curtemp)
61770 + break;
61771 + tmp = tmp->real_parent;
61772 + }
61773 +
61774 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61775 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61776 + read_unlock(&grsec_exec_file_lock);
61777 + read_unlock(&tasklist_lock);
61778 + return 1;
61779 + }
61780 +
61781 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61782 + if (!(gr_status & GR_READY)) {
61783 + read_unlock(&grsec_exec_file_lock);
61784 + read_unlock(&tasklist_lock);
61785 + return 0;
61786 + }
61787 +#endif
61788 +
61789 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61790 + read_unlock(&grsec_exec_file_lock);
61791 + read_unlock(&tasklist_lock);
61792 +
61793 + if (retmode & GR_NOPTRACE)
61794 + return 1;
61795 +
61796 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61797 + && (current->acl != task->acl || (current->acl != current->role->root_label
61798 + && task_pid_nr(current) != task_pid_nr(task))))
61799 + return 1;
61800 +
61801 + return 0;
61802 +}
61803 +
61804 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61805 +{
61806 + if (unlikely(!(gr_status & GR_READY)))
61807 + return;
61808 +
61809 + if (!(current->role->roletype & GR_ROLE_GOD))
61810 + return;
61811 +
61812 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61813 + p->role->rolename, gr_task_roletype_to_char(p),
61814 + p->acl->filename);
61815 +}
61816 +
61817 +int
61818 +gr_handle_ptrace(struct task_struct *task, const long request)
61819 +{
61820 + struct task_struct *tmp = task;
61821 + struct task_struct *curtemp = current;
61822 + __u32 retmode;
61823 +
61824 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61825 + if (unlikely(!(gr_status & GR_READY)))
61826 + return 0;
61827 +#endif
61828 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61829 + read_lock(&tasklist_lock);
61830 + while (task_pid_nr(tmp) > 0) {
61831 + if (tmp == curtemp)
61832 + break;
61833 + tmp = tmp->real_parent;
61834 + }
61835 +
61836 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61837 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61838 + read_unlock(&tasklist_lock);
61839 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61840 + return 1;
61841 + }
61842 + read_unlock(&tasklist_lock);
61843 + }
61844 +
61845 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61846 + if (!(gr_status & GR_READY))
61847 + return 0;
61848 +#endif
61849 +
61850 + read_lock(&grsec_exec_file_lock);
61851 + if (unlikely(!task->exec_file)) {
61852 + read_unlock(&grsec_exec_file_lock);
61853 + return 0;
61854 + }
61855 +
61856 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61857 + read_unlock(&grsec_exec_file_lock);
61858 +
61859 + if (retmode & GR_NOPTRACE) {
61860 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61861 + return 1;
61862 + }
61863 +
61864 + if (retmode & GR_PTRACERD) {
61865 + switch (request) {
61866 + case PTRACE_SEIZE:
61867 + case PTRACE_POKETEXT:
61868 + case PTRACE_POKEDATA:
61869 + case PTRACE_POKEUSR:
61870 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61871 + case PTRACE_SETREGS:
61872 + case PTRACE_SETFPREGS:
61873 +#endif
61874 +#ifdef CONFIG_X86
61875 + case PTRACE_SETFPXREGS:
61876 +#endif
61877 +#ifdef CONFIG_ALTIVEC
61878 + case PTRACE_SETVRREGS:
61879 +#endif
61880 + return 1;
61881 + default:
61882 + return 0;
61883 + }
61884 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61885 + !(current->role->roletype & GR_ROLE_GOD) &&
61886 + (current->acl != task->acl)) {
61887 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61888 + return 1;
61889 + }
61890 +
61891 + return 0;
61892 +}
61893 +
61894 +static int is_writable_mmap(const struct file *filp)
61895 +{
61896 + struct task_struct *task = current;
61897 + struct acl_object_label *obj, *obj2;
61898 +
61899 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61900 + !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))) {
61901 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61902 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61903 + task->role->root_label);
61904 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61905 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61906 + return 1;
61907 + }
61908 + }
61909 + return 0;
61910 +}
61911 +
61912 +int
61913 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61914 +{
61915 + __u32 mode;
61916 +
61917 + if (unlikely(!file || !(prot & PROT_EXEC)))
61918 + return 1;
61919 +
61920 + if (is_writable_mmap(file))
61921 + return 0;
61922 +
61923 + mode =
61924 + gr_search_file(file->f_path.dentry,
61925 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61926 + file->f_path.mnt);
61927 +
61928 + if (!gr_tpe_allow(file))
61929 + return 0;
61930 +
61931 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61932 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61933 + return 0;
61934 + } else if (unlikely(!(mode & GR_EXEC))) {
61935 + return 0;
61936 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61937 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61938 + return 1;
61939 + }
61940 +
61941 + return 1;
61942 +}
61943 +
61944 +int
61945 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61946 +{
61947 + __u32 mode;
61948 +
61949 + if (unlikely(!file || !(prot & PROT_EXEC)))
61950 + return 1;
61951 +
61952 + if (is_writable_mmap(file))
61953 + return 0;
61954 +
61955 + mode =
61956 + gr_search_file(file->f_path.dentry,
61957 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61958 + file->f_path.mnt);
61959 +
61960 + if (!gr_tpe_allow(file))
61961 + return 0;
61962 +
61963 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61964 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61965 + return 0;
61966 + } else if (unlikely(!(mode & GR_EXEC))) {
61967 + return 0;
61968 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61969 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61970 + return 1;
61971 + }
61972 +
61973 + return 1;
61974 +}
61975 +
61976 +void
61977 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61978 +{
61979 + unsigned long runtime;
61980 + unsigned long cputime;
61981 + unsigned int wday, cday;
61982 + __u8 whr, chr;
61983 + __u8 wmin, cmin;
61984 + __u8 wsec, csec;
61985 + struct timespec timeval;
61986 +
61987 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61988 + !(task->acl->mode & GR_PROCACCT)))
61989 + return;
61990 +
61991 + do_posix_clock_monotonic_gettime(&timeval);
61992 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61993 + wday = runtime / (3600 * 24);
61994 + runtime -= wday * (3600 * 24);
61995 + whr = runtime / 3600;
61996 + runtime -= whr * 3600;
61997 + wmin = runtime / 60;
61998 + runtime -= wmin * 60;
61999 + wsec = runtime;
62000 +
62001 + cputime = (task->utime + task->stime) / HZ;
62002 + cday = cputime / (3600 * 24);
62003 + cputime -= cday * (3600 * 24);
62004 + chr = cputime / 3600;
62005 + cputime -= chr * 3600;
62006 + cmin = cputime / 60;
62007 + cputime -= cmin * 60;
62008 + csec = cputime;
62009 +
62010 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62011 +
62012 + return;
62013 +}
62014 +
62015 +void gr_set_kernel_label(struct task_struct *task)
62016 +{
62017 + if (gr_status & GR_READY) {
62018 + task->role = kernel_role;
62019 + task->acl = kernel_role->root_label;
62020 + }
62021 + return;
62022 +}
62023 +
62024 +#ifdef CONFIG_TASKSTATS
62025 +int gr_is_taskstats_denied(int pid)
62026 +{
62027 + struct task_struct *task;
62028 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62029 + const struct cred *cred;
62030 +#endif
62031 + int ret = 0;
62032 +
62033 + /* restrict taskstats viewing to un-chrooted root users
62034 + who have the 'view' subject flag if the RBAC system is enabled
62035 + */
62036 +
62037 + rcu_read_lock();
62038 + read_lock(&tasklist_lock);
62039 + task = find_task_by_vpid(pid);
62040 + if (task) {
62041 +#ifdef CONFIG_GRKERNSEC_CHROOT
62042 + if (proc_is_chrooted(task))
62043 + ret = -EACCES;
62044 +#endif
62045 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62046 + cred = __task_cred(task);
62047 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62048 + if (gr_is_global_nonroot(cred->uid))
62049 + ret = -EACCES;
62050 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62051 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62052 + ret = -EACCES;
62053 +#endif
62054 +#endif
62055 + if (gr_status & GR_READY) {
62056 + if (!(task->acl->mode & GR_VIEW))
62057 + ret = -EACCES;
62058 + }
62059 + } else
62060 + ret = -ENOENT;
62061 +
62062 + read_unlock(&tasklist_lock);
62063 + rcu_read_unlock();
62064 +
62065 + return ret;
62066 +}
62067 +#endif
62068 +
62069 +/* AUXV entries are filled via a descendant of search_binary_handler
62070 + after we've already applied the subject for the target
62071 +*/
62072 +int gr_acl_enable_at_secure(void)
62073 +{
62074 + if (unlikely(!(gr_status & GR_READY)))
62075 + return 0;
62076 +
62077 + if (current->acl->mode & GR_ATSECURE)
62078 + return 1;
62079 +
62080 + return 0;
62081 +}
62082 +
62083 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62084 +{
62085 + struct task_struct *task = current;
62086 + struct dentry *dentry = file->f_path.dentry;
62087 + struct vfsmount *mnt = file->f_path.mnt;
62088 + struct acl_object_label *obj, *tmp;
62089 + struct acl_subject_label *subj;
62090 + unsigned int bufsize;
62091 + int is_not_root;
62092 + char *path;
62093 + dev_t dev = __get_dev(dentry);
62094 +
62095 + if (unlikely(!(gr_status & GR_READY)))
62096 + return 1;
62097 +
62098 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62099 + return 1;
62100 +
62101 + /* ignore Eric Biederman */
62102 + if (IS_PRIVATE(dentry->d_inode))
62103 + return 1;
62104 +
62105 + subj = task->acl;
62106 + read_lock(&gr_inode_lock);
62107 + do {
62108 + obj = lookup_acl_obj_label(ino, dev, subj);
62109 + if (obj != NULL) {
62110 + read_unlock(&gr_inode_lock);
62111 + return (obj->mode & GR_FIND) ? 1 : 0;
62112 + }
62113 + } while ((subj = subj->parent_subject));
62114 + read_unlock(&gr_inode_lock);
62115 +
62116 + /* this is purely an optimization since we're looking for an object
62117 + for the directory we're doing a readdir on
62118 + if it's possible for any globbed object to match the entry we're
62119 + filling into the directory, then the object we find here will be
62120 + an anchor point with attached globbed objects
62121 + */
62122 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62123 + if (obj->globbed == NULL)
62124 + return (obj->mode & GR_FIND) ? 1 : 0;
62125 +
62126 + is_not_root = ((obj->filename[0] == '/') &&
62127 + (obj->filename[1] == '\0')) ? 0 : 1;
62128 + bufsize = PAGE_SIZE - namelen - is_not_root;
62129 +
62130 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62131 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62132 + return 1;
62133 +
62134 + preempt_disable();
62135 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62136 + bufsize);
62137 +
62138 + bufsize = strlen(path);
62139 +
62140 + /* if base is "/", don't append an additional slash */
62141 + if (is_not_root)
62142 + *(path + bufsize) = '/';
62143 + memcpy(path + bufsize + is_not_root, name, namelen);
62144 + *(path + bufsize + namelen + is_not_root) = '\0';
62145 +
62146 + tmp = obj->globbed;
62147 + while (tmp) {
62148 + if (!glob_match(tmp->filename, path)) {
62149 + preempt_enable();
62150 + return (tmp->mode & GR_FIND) ? 1 : 0;
62151 + }
62152 + tmp = tmp->next;
62153 + }
62154 + preempt_enable();
62155 + return (obj->mode & GR_FIND) ? 1 : 0;
62156 +}
62157 +
62158 +void gr_put_exec_file(struct task_struct *task)
62159 +{
62160 + struct file *filp;
62161 +
62162 + write_lock(&grsec_exec_file_lock);
62163 + filp = task->exec_file;
62164 + task->exec_file = NULL;
62165 + write_unlock(&grsec_exec_file_lock);
62166 +
62167 + if (filp)
62168 + fput(filp);
62169 +
62170 + return;
62171 +}
62172 +
62173 +
62174 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62175 +EXPORT_SYMBOL(gr_acl_is_enabled);
62176 +#endif
62177 +EXPORT_SYMBOL(gr_set_kernel_label);
62178 +#ifdef CONFIG_SECURITY
62179 +EXPORT_SYMBOL(gr_check_user_change);
62180 +EXPORT_SYMBOL(gr_check_group_change);
62181 +#endif
62182 +
62183 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62184 new file mode 100644
62185 index 0000000..34fefda
62186 --- /dev/null
62187 +++ b/grsecurity/gracl_alloc.c
62188 @@ -0,0 +1,105 @@
62189 +#include <linux/kernel.h>
62190 +#include <linux/mm.h>
62191 +#include <linux/slab.h>
62192 +#include <linux/vmalloc.h>
62193 +#include <linux/gracl.h>
62194 +#include <linux/grsecurity.h>
62195 +
62196 +static unsigned long alloc_stack_next = 1;
62197 +static unsigned long alloc_stack_size = 1;
62198 +static void **alloc_stack;
62199 +
62200 +static __inline__ int
62201 +alloc_pop(void)
62202 +{
62203 + if (alloc_stack_next == 1)
62204 + return 0;
62205 +
62206 + kfree(alloc_stack[alloc_stack_next - 2]);
62207 +
62208 + alloc_stack_next--;
62209 +
62210 + return 1;
62211 +}
62212 +
62213 +static __inline__ int
62214 +alloc_push(void *buf)
62215 +{
62216 + if (alloc_stack_next >= alloc_stack_size)
62217 + return 1;
62218 +
62219 + alloc_stack[alloc_stack_next - 1] = buf;
62220 +
62221 + alloc_stack_next++;
62222 +
62223 + return 0;
62224 +}
62225 +
62226 +void *
62227 +acl_alloc(unsigned long len)
62228 +{
62229 + void *ret = NULL;
62230 +
62231 + if (!len || len > PAGE_SIZE)
62232 + goto out;
62233 +
62234 + ret = kmalloc(len, GFP_KERNEL);
62235 +
62236 + if (ret) {
62237 + if (alloc_push(ret)) {
62238 + kfree(ret);
62239 + ret = NULL;
62240 + }
62241 + }
62242 +
62243 +out:
62244 + return ret;
62245 +}
62246 +
62247 +void *
62248 +acl_alloc_num(unsigned long num, unsigned long len)
62249 +{
62250 + if (!len || (num > (PAGE_SIZE / len)))
62251 + return NULL;
62252 +
62253 + return acl_alloc(num * len);
62254 +}
62255 +
62256 +void
62257 +acl_free_all(void)
62258 +{
62259 + if (gr_acl_is_enabled() || !alloc_stack)
62260 + return;
62261 +
62262 + while (alloc_pop()) ;
62263 +
62264 + if (alloc_stack) {
62265 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62266 + kfree(alloc_stack);
62267 + else
62268 + vfree(alloc_stack);
62269 + }
62270 +
62271 + alloc_stack = NULL;
62272 + alloc_stack_size = 1;
62273 + alloc_stack_next = 1;
62274 +
62275 + return;
62276 +}
62277 +
62278 +int
62279 +acl_alloc_stack_init(unsigned long size)
62280 +{
62281 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62282 + alloc_stack =
62283 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62284 + else
62285 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62286 +
62287 + alloc_stack_size = size;
62288 +
62289 + if (!alloc_stack)
62290 + return 0;
62291 + else
62292 + return 1;
62293 +}
62294 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62295 new file mode 100644
62296 index 0000000..bdd51ea
62297 --- /dev/null
62298 +++ b/grsecurity/gracl_cap.c
62299 @@ -0,0 +1,110 @@
62300 +#include <linux/kernel.h>
62301 +#include <linux/module.h>
62302 +#include <linux/sched.h>
62303 +#include <linux/gracl.h>
62304 +#include <linux/grsecurity.h>
62305 +#include <linux/grinternal.h>
62306 +
62307 +extern const char *captab_log[];
62308 +extern int captab_log_entries;
62309 +
62310 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62311 +{
62312 + struct acl_subject_label *curracl;
62313 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62314 + kernel_cap_t cap_audit = __cap_empty_set;
62315 +
62316 + if (!gr_acl_is_enabled())
62317 + return 1;
62318 +
62319 + curracl = task->acl;
62320 +
62321 + cap_drop = curracl->cap_lower;
62322 + cap_mask = curracl->cap_mask;
62323 + cap_audit = curracl->cap_invert_audit;
62324 +
62325 + while ((curracl = curracl->parent_subject)) {
62326 + /* if the cap isn't specified in the current computed mask but is specified in the
62327 + current level subject, and is lowered in the current level subject, then add
62328 + it to the set of dropped capabilities
62329 + otherwise, add the current level subject's mask to the current computed mask
62330 + */
62331 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62332 + cap_raise(cap_mask, cap);
62333 + if (cap_raised(curracl->cap_lower, cap))
62334 + cap_raise(cap_drop, cap);
62335 + if (cap_raised(curracl->cap_invert_audit, cap))
62336 + cap_raise(cap_audit, cap);
62337 + }
62338 + }
62339 +
62340 + if (!cap_raised(cap_drop, cap)) {
62341 + if (cap_raised(cap_audit, cap))
62342 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62343 + return 1;
62344 + }
62345 +
62346 + curracl = task->acl;
62347 +
62348 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62349 + && cap_raised(cred->cap_effective, cap)) {
62350 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62351 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62352 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62353 + gr_to_filename(task->exec_file->f_path.dentry,
62354 + task->exec_file->f_path.mnt) : curracl->filename,
62355 + curracl->filename, 0UL,
62356 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62357 + return 1;
62358 + }
62359 +
62360 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62361 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62362 +
62363 + return 0;
62364 +}
62365 +
62366 +int
62367 +gr_acl_is_capable(const int cap)
62368 +{
62369 + return gr_task_acl_is_capable(current, current_cred(), cap);
62370 +}
62371 +
62372 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62373 +{
62374 + struct acl_subject_label *curracl;
62375 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62376 +
62377 + if (!gr_acl_is_enabled())
62378 + return 1;
62379 +
62380 + curracl = task->acl;
62381 +
62382 + cap_drop = curracl->cap_lower;
62383 + cap_mask = curracl->cap_mask;
62384 +
62385 + while ((curracl = curracl->parent_subject)) {
62386 + /* if the cap isn't specified in the current computed mask but is specified in the
62387 + current level subject, and is lowered in the current level subject, then add
62388 + it to the set of dropped capabilities
62389 + otherwise, add the current level subject's mask to the current computed mask
62390 + */
62391 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62392 + cap_raise(cap_mask, cap);
62393 + if (cap_raised(curracl->cap_lower, cap))
62394 + cap_raise(cap_drop, cap);
62395 + }
62396 + }
62397 +
62398 + if (!cap_raised(cap_drop, cap))
62399 + return 1;
62400 +
62401 + return 0;
62402 +}
62403 +
62404 +int
62405 +gr_acl_is_capable_nolog(const int cap)
62406 +{
62407 + return gr_task_acl_is_capable_nolog(current, cap);
62408 +}
62409 +
62410 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62411 new file mode 100644
62412 index 0000000..a340c17
62413 --- /dev/null
62414 +++ b/grsecurity/gracl_fs.c
62415 @@ -0,0 +1,431 @@
62416 +#include <linux/kernel.h>
62417 +#include <linux/sched.h>
62418 +#include <linux/types.h>
62419 +#include <linux/fs.h>
62420 +#include <linux/file.h>
62421 +#include <linux/stat.h>
62422 +#include <linux/grsecurity.h>
62423 +#include <linux/grinternal.h>
62424 +#include <linux/gracl.h>
62425 +
62426 +umode_t
62427 +gr_acl_umask(void)
62428 +{
62429 + if (unlikely(!gr_acl_is_enabled()))
62430 + return 0;
62431 +
62432 + return current->role->umask;
62433 +}
62434 +
62435 +__u32
62436 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62437 + const struct vfsmount * mnt)
62438 +{
62439 + __u32 mode;
62440 +
62441 + if (unlikely(!dentry->d_inode))
62442 + return GR_FIND;
62443 +
62444 + mode =
62445 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62446 +
62447 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62448 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62449 + return mode;
62450 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62451 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62452 + return 0;
62453 + } else if (unlikely(!(mode & GR_FIND)))
62454 + return 0;
62455 +
62456 + return GR_FIND;
62457 +}
62458 +
62459 +__u32
62460 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62461 + int acc_mode)
62462 +{
62463 + __u32 reqmode = GR_FIND;
62464 + __u32 mode;
62465 +
62466 + if (unlikely(!dentry->d_inode))
62467 + return reqmode;
62468 +
62469 + if (acc_mode & MAY_APPEND)
62470 + reqmode |= GR_APPEND;
62471 + else if (acc_mode & MAY_WRITE)
62472 + reqmode |= GR_WRITE;
62473 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62474 + reqmode |= GR_READ;
62475 +
62476 + mode =
62477 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62478 + mnt);
62479 +
62480 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62481 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62482 + reqmode & GR_READ ? " reading" : "",
62483 + reqmode & GR_WRITE ? " writing" : reqmode &
62484 + GR_APPEND ? " appending" : "");
62485 + return reqmode;
62486 + } else
62487 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62488 + {
62489 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62490 + reqmode & GR_READ ? " reading" : "",
62491 + reqmode & GR_WRITE ? " writing" : reqmode &
62492 + GR_APPEND ? " appending" : "");
62493 + return 0;
62494 + } else if (unlikely((mode & reqmode) != reqmode))
62495 + return 0;
62496 +
62497 + return reqmode;
62498 +}
62499 +
62500 +__u32
62501 +gr_acl_handle_creat(const struct dentry * dentry,
62502 + const struct dentry * p_dentry,
62503 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62504 + const int imode)
62505 +{
62506 + __u32 reqmode = GR_WRITE | GR_CREATE;
62507 + __u32 mode;
62508 +
62509 + if (acc_mode & MAY_APPEND)
62510 + reqmode |= GR_APPEND;
62511 + // if a directory was required or the directory already exists, then
62512 + // don't count this open as a read
62513 + if ((acc_mode & MAY_READ) &&
62514 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62515 + reqmode |= GR_READ;
62516 + if ((open_flags & O_CREAT) &&
62517 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62518 + reqmode |= GR_SETID;
62519 +
62520 + mode =
62521 + gr_check_create(dentry, p_dentry, p_mnt,
62522 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62523 +
62524 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62525 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62526 + reqmode & GR_READ ? " reading" : "",
62527 + reqmode & GR_WRITE ? " writing" : reqmode &
62528 + GR_APPEND ? " appending" : "");
62529 + return reqmode;
62530 + } else
62531 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62532 + {
62533 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62534 + reqmode & GR_READ ? " reading" : "",
62535 + reqmode & GR_WRITE ? " writing" : reqmode &
62536 + GR_APPEND ? " appending" : "");
62537 + return 0;
62538 + } else if (unlikely((mode & reqmode) != reqmode))
62539 + return 0;
62540 +
62541 + return reqmode;
62542 +}
62543 +
62544 +__u32
62545 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62546 + const int fmode)
62547 +{
62548 + __u32 mode, reqmode = GR_FIND;
62549 +
62550 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62551 + reqmode |= GR_EXEC;
62552 + if (fmode & S_IWOTH)
62553 + reqmode |= GR_WRITE;
62554 + if (fmode & S_IROTH)
62555 + reqmode |= GR_READ;
62556 +
62557 + mode =
62558 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62559 + mnt);
62560 +
62561 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62562 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62563 + reqmode & GR_READ ? " reading" : "",
62564 + reqmode & GR_WRITE ? " writing" : "",
62565 + reqmode & GR_EXEC ? " executing" : "");
62566 + return reqmode;
62567 + } else
62568 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62569 + {
62570 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62571 + reqmode & GR_READ ? " reading" : "",
62572 + reqmode & GR_WRITE ? " writing" : "",
62573 + reqmode & GR_EXEC ? " executing" : "");
62574 + return 0;
62575 + } else if (unlikely((mode & reqmode) != reqmode))
62576 + return 0;
62577 +
62578 + return reqmode;
62579 +}
62580 +
62581 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62582 +{
62583 + __u32 mode;
62584 +
62585 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62586 +
62587 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62588 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62589 + return mode;
62590 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62591 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62592 + return 0;
62593 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62594 + return 0;
62595 +
62596 + return (reqmode);
62597 +}
62598 +
62599 +__u32
62600 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62601 +{
62602 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62603 +}
62604 +
62605 +__u32
62606 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62607 +{
62608 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62609 +}
62610 +
62611 +__u32
62612 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62613 +{
62614 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62615 +}
62616 +
62617 +__u32
62618 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62619 +{
62620 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62621 +}
62622 +
62623 +__u32
62624 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62625 + umode_t *modeptr)
62626 +{
62627 + umode_t mode;
62628 +
62629 + *modeptr &= ~gr_acl_umask();
62630 + mode = *modeptr;
62631 +
62632 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62633 + return 1;
62634 +
62635 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62636 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62637 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62638 + GR_CHMOD_ACL_MSG);
62639 + } else {
62640 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62641 + }
62642 +}
62643 +
62644 +__u32
62645 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62646 +{
62647 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62648 +}
62649 +
62650 +__u32
62651 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62652 +{
62653 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62654 +}
62655 +
62656 +__u32
62657 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62658 +{
62659 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62660 +}
62661 +
62662 +__u32
62663 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62664 +{
62665 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62666 + GR_UNIXCONNECT_ACL_MSG);
62667 +}
62668 +
62669 +/* hardlinks require at minimum create and link permission,
62670 + any additional privilege required is based on the
62671 + privilege of the file being linked to
62672 +*/
62673 +__u32
62674 +gr_acl_handle_link(const struct dentry * new_dentry,
62675 + const struct dentry * parent_dentry,
62676 + const struct vfsmount * parent_mnt,
62677 + const struct dentry * old_dentry,
62678 + const struct vfsmount * old_mnt, const struct filename *to)
62679 +{
62680 + __u32 mode;
62681 + __u32 needmode = GR_CREATE | GR_LINK;
62682 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62683 +
62684 + mode =
62685 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62686 + old_mnt);
62687 +
62688 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62689 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62690 + return mode;
62691 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62692 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62693 + return 0;
62694 + } else if (unlikely((mode & needmode) != needmode))
62695 + return 0;
62696 +
62697 + return 1;
62698 +}
62699 +
62700 +__u32
62701 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62702 + const struct dentry * parent_dentry,
62703 + const struct vfsmount * parent_mnt, const struct filename *from)
62704 +{
62705 + __u32 needmode = GR_WRITE | GR_CREATE;
62706 + __u32 mode;
62707 +
62708 + mode =
62709 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62710 + GR_CREATE | GR_AUDIT_CREATE |
62711 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62712 +
62713 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62714 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62715 + return mode;
62716 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62717 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62718 + return 0;
62719 + } else if (unlikely((mode & needmode) != needmode))
62720 + return 0;
62721 +
62722 + return (GR_WRITE | GR_CREATE);
62723 +}
62724 +
62725 +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)
62726 +{
62727 + __u32 mode;
62728 +
62729 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62730 +
62731 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62732 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62733 + return mode;
62734 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62735 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62736 + return 0;
62737 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62738 + return 0;
62739 +
62740 + return (reqmode);
62741 +}
62742 +
62743 +__u32
62744 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62745 + const struct dentry * parent_dentry,
62746 + const struct vfsmount * parent_mnt,
62747 + const int mode)
62748 +{
62749 + __u32 reqmode = GR_WRITE | GR_CREATE;
62750 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62751 + reqmode |= GR_SETID;
62752 +
62753 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62754 + reqmode, GR_MKNOD_ACL_MSG);
62755 +}
62756 +
62757 +__u32
62758 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62759 + const struct dentry *parent_dentry,
62760 + const struct vfsmount *parent_mnt)
62761 +{
62762 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62763 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62764 +}
62765 +
62766 +#define RENAME_CHECK_SUCCESS(old, new) \
62767 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62768 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62769 +
62770 +int
62771 +gr_acl_handle_rename(struct dentry *new_dentry,
62772 + struct dentry *parent_dentry,
62773 + const struct vfsmount *parent_mnt,
62774 + struct dentry *old_dentry,
62775 + struct inode *old_parent_inode,
62776 + struct vfsmount *old_mnt, const struct filename *newname)
62777 +{
62778 + __u32 comp1, comp2;
62779 + int error = 0;
62780 +
62781 + if (unlikely(!gr_acl_is_enabled()))
62782 + return 0;
62783 +
62784 + if (!new_dentry->d_inode) {
62785 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62786 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62787 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62788 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62789 + GR_DELETE | GR_AUDIT_DELETE |
62790 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62791 + GR_SUPPRESS, old_mnt);
62792 + } else {
62793 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62794 + GR_CREATE | GR_DELETE |
62795 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62796 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62797 + GR_SUPPRESS, parent_mnt);
62798 + comp2 =
62799 + gr_search_file(old_dentry,
62800 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62801 + GR_DELETE | GR_AUDIT_DELETE |
62802 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62803 + }
62804 +
62805 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62806 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62807 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62808 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62809 + && !(comp2 & GR_SUPPRESS)) {
62810 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62811 + error = -EACCES;
62812 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62813 + error = -EACCES;
62814 +
62815 + return error;
62816 +}
62817 +
62818 +void
62819 +gr_acl_handle_exit(void)
62820 +{
62821 + u16 id;
62822 + char *rolename;
62823 +
62824 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62825 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62826 + id = current->acl_role_id;
62827 + rolename = current->role->rolename;
62828 + gr_set_acls(1);
62829 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62830 + }
62831 +
62832 + gr_put_exec_file(current);
62833 + return;
62834 +}
62835 +
62836 +int
62837 +gr_acl_handle_procpidmem(const struct task_struct *task)
62838 +{
62839 + if (unlikely(!gr_acl_is_enabled()))
62840 + return 0;
62841 +
62842 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62843 + return -EACCES;
62844 +
62845 + return 0;
62846 +}
62847 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62848 new file mode 100644
62849 index 0000000..8132048
62850 --- /dev/null
62851 +++ b/grsecurity/gracl_ip.c
62852 @@ -0,0 +1,387 @@
62853 +#include <linux/kernel.h>
62854 +#include <asm/uaccess.h>
62855 +#include <asm/errno.h>
62856 +#include <net/sock.h>
62857 +#include <linux/file.h>
62858 +#include <linux/fs.h>
62859 +#include <linux/net.h>
62860 +#include <linux/in.h>
62861 +#include <linux/skbuff.h>
62862 +#include <linux/ip.h>
62863 +#include <linux/udp.h>
62864 +#include <linux/types.h>
62865 +#include <linux/sched.h>
62866 +#include <linux/netdevice.h>
62867 +#include <linux/inetdevice.h>
62868 +#include <linux/gracl.h>
62869 +#include <linux/grsecurity.h>
62870 +#include <linux/grinternal.h>
62871 +
62872 +#define GR_BIND 0x01
62873 +#define GR_CONNECT 0x02
62874 +#define GR_INVERT 0x04
62875 +#define GR_BINDOVERRIDE 0x08
62876 +#define GR_CONNECTOVERRIDE 0x10
62877 +#define GR_SOCK_FAMILY 0x20
62878 +
62879 +static const char * gr_protocols[IPPROTO_MAX] = {
62880 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62881 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62882 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62883 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62884 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62885 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62886 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62887 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62888 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62889 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62890 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62891 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62892 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62893 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62894 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62895 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62896 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62897 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62898 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62899 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62900 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62901 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62902 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62903 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62904 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62905 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62906 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62907 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62908 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62909 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62910 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62911 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62912 + };
62913 +
62914 +static const char * gr_socktypes[SOCK_MAX] = {
62915 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62916 + "unknown:7", "unknown:8", "unknown:9", "packet"
62917 + };
62918 +
62919 +static const char * gr_sockfamilies[AF_MAX+1] = {
62920 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62921 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62922 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62923 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62924 + };
62925 +
62926 +const char *
62927 +gr_proto_to_name(unsigned char proto)
62928 +{
62929 + return gr_protocols[proto];
62930 +}
62931 +
62932 +const char *
62933 +gr_socktype_to_name(unsigned char type)
62934 +{
62935 + return gr_socktypes[type];
62936 +}
62937 +
62938 +const char *
62939 +gr_sockfamily_to_name(unsigned char family)
62940 +{
62941 + return gr_sockfamilies[family];
62942 +}
62943 +
62944 +int
62945 +gr_search_socket(const int domain, const int type, const int protocol)
62946 +{
62947 + struct acl_subject_label *curr;
62948 + const struct cred *cred = current_cred();
62949 +
62950 + if (unlikely(!gr_acl_is_enabled()))
62951 + goto exit;
62952 +
62953 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62954 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62955 + goto exit; // let the kernel handle it
62956 +
62957 + curr = current->acl;
62958 +
62959 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62960 + /* the family is allowed, if this is PF_INET allow it only if
62961 + the extra sock type/protocol checks pass */
62962 + if (domain == PF_INET)
62963 + goto inet_check;
62964 + goto exit;
62965 + } else {
62966 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62967 + __u32 fakeip = 0;
62968 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62969 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62970 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62971 + gr_to_filename(current->exec_file->f_path.dentry,
62972 + current->exec_file->f_path.mnt) :
62973 + curr->filename, curr->filename,
62974 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62975 + &current->signal->saved_ip);
62976 + goto exit;
62977 + }
62978 + goto exit_fail;
62979 + }
62980 +
62981 +inet_check:
62982 + /* the rest of this checking is for IPv4 only */
62983 + if (!curr->ips)
62984 + goto exit;
62985 +
62986 + if ((curr->ip_type & (1U << type)) &&
62987 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
62988 + goto exit;
62989 +
62990 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62991 + /* we don't place acls on raw sockets , and sometimes
62992 + dgram/ip sockets are opened for ioctl and not
62993 + bind/connect, so we'll fake a bind learn log */
62994 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62995 + __u32 fakeip = 0;
62996 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62997 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62998 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62999 + gr_to_filename(current->exec_file->f_path.dentry,
63000 + current->exec_file->f_path.mnt) :
63001 + curr->filename, curr->filename,
63002 + &fakeip, 0, type,
63003 + protocol, GR_CONNECT, &current->signal->saved_ip);
63004 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63005 + __u32 fakeip = 0;
63006 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63007 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63008 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63009 + gr_to_filename(current->exec_file->f_path.dentry,
63010 + current->exec_file->f_path.mnt) :
63011 + curr->filename, curr->filename,
63012 + &fakeip, 0, type,
63013 + protocol, GR_BIND, &current->signal->saved_ip);
63014 + }
63015 + /* we'll log when they use connect or bind */
63016 + goto exit;
63017 + }
63018 +
63019 +exit_fail:
63020 + if (domain == PF_INET)
63021 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63022 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63023 + else
63024 +#ifndef CONFIG_IPV6
63025 + if (domain != PF_INET6)
63026 +#endif
63027 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63028 + gr_socktype_to_name(type), protocol);
63029 +
63030 + return 0;
63031 +exit:
63032 + return 1;
63033 +}
63034 +
63035 +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)
63036 +{
63037 + if ((ip->mode & mode) &&
63038 + (ip_port >= ip->low) &&
63039 + (ip_port <= ip->high) &&
63040 + ((ntohl(ip_addr) & our_netmask) ==
63041 + (ntohl(our_addr) & our_netmask))
63042 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63043 + && (ip->type & (1U << type))) {
63044 + if (ip->mode & GR_INVERT)
63045 + return 2; // specifically denied
63046 + else
63047 + return 1; // allowed
63048 + }
63049 +
63050 + return 0; // not specifically allowed, may continue parsing
63051 +}
63052 +
63053 +static int
63054 +gr_search_connectbind(const int full_mode, struct sock *sk,
63055 + struct sockaddr_in *addr, const int type)
63056 +{
63057 + char iface[IFNAMSIZ] = {0};
63058 + struct acl_subject_label *curr;
63059 + struct acl_ip_label *ip;
63060 + struct inet_sock *isk;
63061 + struct net_device *dev;
63062 + struct in_device *idev;
63063 + unsigned long i;
63064 + int ret;
63065 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63066 + __u32 ip_addr = 0;
63067 + __u32 our_addr;
63068 + __u32 our_netmask;
63069 + char *p;
63070 + __u16 ip_port = 0;
63071 + const struct cred *cred = current_cred();
63072 +
63073 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63074 + return 0;
63075 +
63076 + curr = current->acl;
63077 + isk = inet_sk(sk);
63078 +
63079 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63080 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63081 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63082 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63083 + struct sockaddr_in saddr;
63084 + int err;
63085 +
63086 + saddr.sin_family = AF_INET;
63087 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63088 + saddr.sin_port = isk->inet_sport;
63089 +
63090 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63091 + if (err)
63092 + return err;
63093 +
63094 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63095 + if (err)
63096 + return err;
63097 + }
63098 +
63099 + if (!curr->ips)
63100 + return 0;
63101 +
63102 + ip_addr = addr->sin_addr.s_addr;
63103 + ip_port = ntohs(addr->sin_port);
63104 +
63105 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63106 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63107 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63108 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63109 + gr_to_filename(current->exec_file->f_path.dentry,
63110 + current->exec_file->f_path.mnt) :
63111 + curr->filename, curr->filename,
63112 + &ip_addr, ip_port, type,
63113 + sk->sk_protocol, mode, &current->signal->saved_ip);
63114 + return 0;
63115 + }
63116 +
63117 + for (i = 0; i < curr->ip_num; i++) {
63118 + ip = *(curr->ips + i);
63119 + if (ip->iface != NULL) {
63120 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63121 + p = strchr(iface, ':');
63122 + if (p != NULL)
63123 + *p = '\0';
63124 + dev = dev_get_by_name(sock_net(sk), iface);
63125 + if (dev == NULL)
63126 + continue;
63127 + idev = in_dev_get(dev);
63128 + if (idev == NULL) {
63129 + dev_put(dev);
63130 + continue;
63131 + }
63132 + rcu_read_lock();
63133 + for_ifa(idev) {
63134 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63135 + our_addr = ifa->ifa_address;
63136 + our_netmask = 0xffffffff;
63137 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63138 + if (ret == 1) {
63139 + rcu_read_unlock();
63140 + in_dev_put(idev);
63141 + dev_put(dev);
63142 + return 0;
63143 + } else if (ret == 2) {
63144 + rcu_read_unlock();
63145 + in_dev_put(idev);
63146 + dev_put(dev);
63147 + goto denied;
63148 + }
63149 + }
63150 + } endfor_ifa(idev);
63151 + rcu_read_unlock();
63152 + in_dev_put(idev);
63153 + dev_put(dev);
63154 + } else {
63155 + our_addr = ip->addr;
63156 + our_netmask = ip->netmask;
63157 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63158 + if (ret == 1)
63159 + return 0;
63160 + else if (ret == 2)
63161 + goto denied;
63162 + }
63163 + }
63164 +
63165 +denied:
63166 + if (mode == GR_BIND)
63167 + 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));
63168 + else if (mode == GR_CONNECT)
63169 + 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));
63170 +
63171 + return -EACCES;
63172 +}
63173 +
63174 +int
63175 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63176 +{
63177 + /* always allow disconnection of dgram sockets with connect */
63178 + if (addr->sin_family == AF_UNSPEC)
63179 + return 0;
63180 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63181 +}
63182 +
63183 +int
63184 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63185 +{
63186 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63187 +}
63188 +
63189 +int gr_search_listen(struct socket *sock)
63190 +{
63191 + struct sock *sk = sock->sk;
63192 + struct sockaddr_in addr;
63193 +
63194 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63195 + addr.sin_port = inet_sk(sk)->inet_sport;
63196 +
63197 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63198 +}
63199 +
63200 +int gr_search_accept(struct socket *sock)
63201 +{
63202 + struct sock *sk = sock->sk;
63203 + struct sockaddr_in addr;
63204 +
63205 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63206 + addr.sin_port = inet_sk(sk)->inet_sport;
63207 +
63208 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63209 +}
63210 +
63211 +int
63212 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63213 +{
63214 + if (addr)
63215 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63216 + else {
63217 + struct sockaddr_in sin;
63218 + const struct inet_sock *inet = inet_sk(sk);
63219 +
63220 + sin.sin_addr.s_addr = inet->inet_daddr;
63221 + sin.sin_port = inet->inet_dport;
63222 +
63223 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63224 + }
63225 +}
63226 +
63227 +int
63228 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63229 +{
63230 + struct sockaddr_in sin;
63231 +
63232 + if (unlikely(skb->len < sizeof (struct udphdr)))
63233 + return 0; // skip this packet
63234 +
63235 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63236 + sin.sin_port = udp_hdr(skb)->source;
63237 +
63238 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63239 +}
63240 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63241 new file mode 100644
63242 index 0000000..25f54ef
63243 --- /dev/null
63244 +++ b/grsecurity/gracl_learn.c
63245 @@ -0,0 +1,207 @@
63246 +#include <linux/kernel.h>
63247 +#include <linux/mm.h>
63248 +#include <linux/sched.h>
63249 +#include <linux/poll.h>
63250 +#include <linux/string.h>
63251 +#include <linux/file.h>
63252 +#include <linux/types.h>
63253 +#include <linux/vmalloc.h>
63254 +#include <linux/grinternal.h>
63255 +
63256 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63257 + size_t count, loff_t *ppos);
63258 +extern int gr_acl_is_enabled(void);
63259 +
63260 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63261 +static int gr_learn_attached;
63262 +
63263 +/* use a 512k buffer */
63264 +#define LEARN_BUFFER_SIZE (512 * 1024)
63265 +
63266 +static DEFINE_SPINLOCK(gr_learn_lock);
63267 +static DEFINE_MUTEX(gr_learn_user_mutex);
63268 +
63269 +/* we need to maintain two buffers, so that the kernel context of grlearn
63270 + uses a semaphore around the userspace copying, and the other kernel contexts
63271 + use a spinlock when copying into the buffer, since they cannot sleep
63272 +*/
63273 +static char *learn_buffer;
63274 +static char *learn_buffer_user;
63275 +static int learn_buffer_len;
63276 +static int learn_buffer_user_len;
63277 +
63278 +static ssize_t
63279 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63280 +{
63281 + DECLARE_WAITQUEUE(wait, current);
63282 + ssize_t retval = 0;
63283 +
63284 + add_wait_queue(&learn_wait, &wait);
63285 + set_current_state(TASK_INTERRUPTIBLE);
63286 + do {
63287 + mutex_lock(&gr_learn_user_mutex);
63288 + spin_lock(&gr_learn_lock);
63289 + if (learn_buffer_len)
63290 + break;
63291 + spin_unlock(&gr_learn_lock);
63292 + mutex_unlock(&gr_learn_user_mutex);
63293 + if (file->f_flags & O_NONBLOCK) {
63294 + retval = -EAGAIN;
63295 + goto out;
63296 + }
63297 + if (signal_pending(current)) {
63298 + retval = -ERESTARTSYS;
63299 + goto out;
63300 + }
63301 +
63302 + schedule();
63303 + } while (1);
63304 +
63305 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63306 + learn_buffer_user_len = learn_buffer_len;
63307 + retval = learn_buffer_len;
63308 + learn_buffer_len = 0;
63309 +
63310 + spin_unlock(&gr_learn_lock);
63311 +
63312 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63313 + retval = -EFAULT;
63314 +
63315 + mutex_unlock(&gr_learn_user_mutex);
63316 +out:
63317 + set_current_state(TASK_RUNNING);
63318 + remove_wait_queue(&learn_wait, &wait);
63319 + return retval;
63320 +}
63321 +
63322 +static unsigned int
63323 +poll_learn(struct file * file, poll_table * wait)
63324 +{
63325 + poll_wait(file, &learn_wait, wait);
63326 +
63327 + if (learn_buffer_len)
63328 + return (POLLIN | POLLRDNORM);
63329 +
63330 + return 0;
63331 +}
63332 +
63333 +void
63334 +gr_clear_learn_entries(void)
63335 +{
63336 + char *tmp;
63337 +
63338 + mutex_lock(&gr_learn_user_mutex);
63339 + spin_lock(&gr_learn_lock);
63340 + tmp = learn_buffer;
63341 + learn_buffer = NULL;
63342 + spin_unlock(&gr_learn_lock);
63343 + if (tmp)
63344 + vfree(tmp);
63345 + if (learn_buffer_user != NULL) {
63346 + vfree(learn_buffer_user);
63347 + learn_buffer_user = NULL;
63348 + }
63349 + learn_buffer_len = 0;
63350 + mutex_unlock(&gr_learn_user_mutex);
63351 +
63352 + return;
63353 +}
63354 +
63355 +void
63356 +gr_add_learn_entry(const char *fmt, ...)
63357 +{
63358 + va_list args;
63359 + unsigned int len;
63360 +
63361 + if (!gr_learn_attached)
63362 + return;
63363 +
63364 + spin_lock(&gr_learn_lock);
63365 +
63366 + /* leave a gap at the end so we know when it's "full" but don't have to
63367 + compute the exact length of the string we're trying to append
63368 + */
63369 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63370 + spin_unlock(&gr_learn_lock);
63371 + wake_up_interruptible(&learn_wait);
63372 + return;
63373 + }
63374 + if (learn_buffer == NULL) {
63375 + spin_unlock(&gr_learn_lock);
63376 + return;
63377 + }
63378 +
63379 + va_start(args, fmt);
63380 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63381 + va_end(args);
63382 +
63383 + learn_buffer_len += len + 1;
63384 +
63385 + spin_unlock(&gr_learn_lock);
63386 + wake_up_interruptible(&learn_wait);
63387 +
63388 + return;
63389 +}
63390 +
63391 +static int
63392 +open_learn(struct inode *inode, struct file *file)
63393 +{
63394 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63395 + return -EBUSY;
63396 + if (file->f_mode & FMODE_READ) {
63397 + int retval = 0;
63398 + mutex_lock(&gr_learn_user_mutex);
63399 + if (learn_buffer == NULL)
63400 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63401 + if (learn_buffer_user == NULL)
63402 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63403 + if (learn_buffer == NULL) {
63404 + retval = -ENOMEM;
63405 + goto out_error;
63406 + }
63407 + if (learn_buffer_user == NULL) {
63408 + retval = -ENOMEM;
63409 + goto out_error;
63410 + }
63411 + learn_buffer_len = 0;
63412 + learn_buffer_user_len = 0;
63413 + gr_learn_attached = 1;
63414 +out_error:
63415 + mutex_unlock(&gr_learn_user_mutex);
63416 + return retval;
63417 + }
63418 + return 0;
63419 +}
63420 +
63421 +static int
63422 +close_learn(struct inode *inode, struct file *file)
63423 +{
63424 + if (file->f_mode & FMODE_READ) {
63425 + char *tmp = NULL;
63426 + mutex_lock(&gr_learn_user_mutex);
63427 + spin_lock(&gr_learn_lock);
63428 + tmp = learn_buffer;
63429 + learn_buffer = NULL;
63430 + spin_unlock(&gr_learn_lock);
63431 + if (tmp)
63432 + vfree(tmp);
63433 + if (learn_buffer_user != NULL) {
63434 + vfree(learn_buffer_user);
63435 + learn_buffer_user = NULL;
63436 + }
63437 + learn_buffer_len = 0;
63438 + learn_buffer_user_len = 0;
63439 + gr_learn_attached = 0;
63440 + mutex_unlock(&gr_learn_user_mutex);
63441 + }
63442 +
63443 + return 0;
63444 +}
63445 +
63446 +const struct file_operations grsec_fops = {
63447 + .read = read_learn,
63448 + .write = write_grsec_handler,
63449 + .open = open_learn,
63450 + .release = close_learn,
63451 + .poll = poll_learn,
63452 +};
63453 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63454 new file mode 100644
63455 index 0000000..39645c9
63456 --- /dev/null
63457 +++ b/grsecurity/gracl_res.c
63458 @@ -0,0 +1,68 @@
63459 +#include <linux/kernel.h>
63460 +#include <linux/sched.h>
63461 +#include <linux/gracl.h>
63462 +#include <linux/grinternal.h>
63463 +
63464 +static const char *restab_log[] = {
63465 + [RLIMIT_CPU] = "RLIMIT_CPU",
63466 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63467 + [RLIMIT_DATA] = "RLIMIT_DATA",
63468 + [RLIMIT_STACK] = "RLIMIT_STACK",
63469 + [RLIMIT_CORE] = "RLIMIT_CORE",
63470 + [RLIMIT_RSS] = "RLIMIT_RSS",
63471 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63472 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63473 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63474 + [RLIMIT_AS] = "RLIMIT_AS",
63475 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63476 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63477 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63478 + [RLIMIT_NICE] = "RLIMIT_NICE",
63479 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63480 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63481 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63482 +};
63483 +
63484 +void
63485 +gr_log_resource(const struct task_struct *task,
63486 + const int res, const unsigned long wanted, const int gt)
63487 +{
63488 + const struct cred *cred;
63489 + unsigned long rlim;
63490 +
63491 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63492 + return;
63493 +
63494 + // not yet supported resource
63495 + if (unlikely(!restab_log[res]))
63496 + return;
63497 +
63498 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63499 + rlim = task_rlimit_max(task, res);
63500 + else
63501 + rlim = task_rlimit(task, res);
63502 +
63503 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63504 + return;
63505 +
63506 + rcu_read_lock();
63507 + cred = __task_cred(task);
63508 +
63509 + if (res == RLIMIT_NPROC &&
63510 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63511 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63512 + goto out_rcu_unlock;
63513 + else if (res == RLIMIT_MEMLOCK &&
63514 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63515 + goto out_rcu_unlock;
63516 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63517 + goto out_rcu_unlock;
63518 + rcu_read_unlock();
63519 +
63520 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63521 +
63522 + return;
63523 +out_rcu_unlock:
63524 + rcu_read_unlock();
63525 + return;
63526 +}
63527 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63528 new file mode 100644
63529 index 0000000..4dcc92a
63530 --- /dev/null
63531 +++ b/grsecurity/gracl_segv.c
63532 @@ -0,0 +1,305 @@
63533 +#include <linux/kernel.h>
63534 +#include <linux/mm.h>
63535 +#include <asm/uaccess.h>
63536 +#include <asm/errno.h>
63537 +#include <asm/mman.h>
63538 +#include <net/sock.h>
63539 +#include <linux/file.h>
63540 +#include <linux/fs.h>
63541 +#include <linux/net.h>
63542 +#include <linux/in.h>
63543 +#include <linux/slab.h>
63544 +#include <linux/types.h>
63545 +#include <linux/sched.h>
63546 +#include <linux/timer.h>
63547 +#include <linux/gracl.h>
63548 +#include <linux/grsecurity.h>
63549 +#include <linux/grinternal.h>
63550 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63551 +#include <linux/magic.h>
63552 +#include <linux/pagemap.h>
63553 +#include "../fs/btrfs/async-thread.h"
63554 +#include "../fs/btrfs/ctree.h"
63555 +#include "../fs/btrfs/btrfs_inode.h"
63556 +#endif
63557 +
63558 +static struct crash_uid *uid_set;
63559 +static unsigned short uid_used;
63560 +static DEFINE_SPINLOCK(gr_uid_lock);
63561 +extern rwlock_t gr_inode_lock;
63562 +extern struct acl_subject_label *
63563 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63564 + struct acl_role_label *role);
63565 +
63566 +static inline dev_t __get_dev(const struct dentry *dentry)
63567 +{
63568 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63569 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63570 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63571 + else
63572 +#endif
63573 + return dentry->d_sb->s_dev;
63574 +}
63575 +
63576 +int
63577 +gr_init_uidset(void)
63578 +{
63579 + uid_set =
63580 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63581 + uid_used = 0;
63582 +
63583 + return uid_set ? 1 : 0;
63584 +}
63585 +
63586 +void
63587 +gr_free_uidset(void)
63588 +{
63589 + if (uid_set)
63590 + kfree(uid_set);
63591 +
63592 + return;
63593 +}
63594 +
63595 +int
63596 +gr_find_uid(const uid_t uid)
63597 +{
63598 + struct crash_uid *tmp = uid_set;
63599 + uid_t buid;
63600 + int low = 0, high = uid_used - 1, mid;
63601 +
63602 + while (high >= low) {
63603 + mid = (low + high) >> 1;
63604 + buid = tmp[mid].uid;
63605 + if (buid == uid)
63606 + return mid;
63607 + if (buid > uid)
63608 + high = mid - 1;
63609 + if (buid < uid)
63610 + low = mid + 1;
63611 + }
63612 +
63613 + return -1;
63614 +}
63615 +
63616 +static __inline__ void
63617 +gr_insertsort(void)
63618 +{
63619 + unsigned short i, j;
63620 + struct crash_uid index;
63621 +
63622 + for (i = 1; i < uid_used; i++) {
63623 + index = uid_set[i];
63624 + j = i;
63625 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63626 + uid_set[j] = uid_set[j - 1];
63627 + j--;
63628 + }
63629 + uid_set[j] = index;
63630 + }
63631 +
63632 + return;
63633 +}
63634 +
63635 +static __inline__ void
63636 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63637 +{
63638 + int loc;
63639 + uid_t uid = GR_GLOBAL_UID(kuid);
63640 +
63641 + if (uid_used == GR_UIDTABLE_MAX)
63642 + return;
63643 +
63644 + loc = gr_find_uid(uid);
63645 +
63646 + if (loc >= 0) {
63647 + uid_set[loc].expires = expires;
63648 + return;
63649 + }
63650 +
63651 + uid_set[uid_used].uid = uid;
63652 + uid_set[uid_used].expires = expires;
63653 + uid_used++;
63654 +
63655 + gr_insertsort();
63656 +
63657 + return;
63658 +}
63659 +
63660 +void
63661 +gr_remove_uid(const unsigned short loc)
63662 +{
63663 + unsigned short i;
63664 +
63665 + for (i = loc + 1; i < uid_used; i++)
63666 + uid_set[i - 1] = uid_set[i];
63667 +
63668 + uid_used--;
63669 +
63670 + return;
63671 +}
63672 +
63673 +int
63674 +gr_check_crash_uid(const kuid_t kuid)
63675 +{
63676 + int loc;
63677 + int ret = 0;
63678 + uid_t uid;
63679 +
63680 + if (unlikely(!gr_acl_is_enabled()))
63681 + return 0;
63682 +
63683 + uid = GR_GLOBAL_UID(kuid);
63684 +
63685 + spin_lock(&gr_uid_lock);
63686 + loc = gr_find_uid(uid);
63687 +
63688 + if (loc < 0)
63689 + goto out_unlock;
63690 +
63691 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63692 + gr_remove_uid(loc);
63693 + else
63694 + ret = 1;
63695 +
63696 +out_unlock:
63697 + spin_unlock(&gr_uid_lock);
63698 + return ret;
63699 +}
63700 +
63701 +static __inline__ int
63702 +proc_is_setxid(const struct cred *cred)
63703 +{
63704 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63705 + !uid_eq(cred->uid, cred->fsuid))
63706 + return 1;
63707 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63708 + !gid_eq(cred->gid, cred->fsgid))
63709 + return 1;
63710 +
63711 + return 0;
63712 +}
63713 +
63714 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63715 +
63716 +void
63717 +gr_handle_crash(struct task_struct *task, const int sig)
63718 +{
63719 + struct acl_subject_label *curr;
63720 + struct task_struct *tsk, *tsk2;
63721 + const struct cred *cred;
63722 + const struct cred *cred2;
63723 +
63724 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63725 + return;
63726 +
63727 + if (unlikely(!gr_acl_is_enabled()))
63728 + return;
63729 +
63730 + curr = task->acl;
63731 +
63732 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63733 + return;
63734 +
63735 + if (time_before_eq(curr->expires, get_seconds())) {
63736 + curr->expires = 0;
63737 + curr->crashes = 0;
63738 + }
63739 +
63740 + curr->crashes++;
63741 +
63742 + if (!curr->expires)
63743 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63744 +
63745 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63746 + time_after(curr->expires, get_seconds())) {
63747 + rcu_read_lock();
63748 + cred = __task_cred(task);
63749 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63750 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63751 + spin_lock(&gr_uid_lock);
63752 + gr_insert_uid(cred->uid, curr->expires);
63753 + spin_unlock(&gr_uid_lock);
63754 + curr->expires = 0;
63755 + curr->crashes = 0;
63756 + read_lock(&tasklist_lock);
63757 + do_each_thread(tsk2, tsk) {
63758 + cred2 = __task_cred(tsk);
63759 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63760 + gr_fake_force_sig(SIGKILL, tsk);
63761 + } while_each_thread(tsk2, tsk);
63762 + read_unlock(&tasklist_lock);
63763 + } else {
63764 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63765 + read_lock(&tasklist_lock);
63766 + read_lock(&grsec_exec_file_lock);
63767 + do_each_thread(tsk2, tsk) {
63768 + if (likely(tsk != task)) {
63769 + // if this thread has the same subject as the one that triggered
63770 + // RES_CRASH and it's the same binary, kill it
63771 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63772 + gr_fake_force_sig(SIGKILL, tsk);
63773 + }
63774 + } while_each_thread(tsk2, tsk);
63775 + read_unlock(&grsec_exec_file_lock);
63776 + read_unlock(&tasklist_lock);
63777 + }
63778 + rcu_read_unlock();
63779 + }
63780 +
63781 + return;
63782 +}
63783 +
63784 +int
63785 +gr_check_crash_exec(const struct file *filp)
63786 +{
63787 + struct acl_subject_label *curr;
63788 +
63789 + if (unlikely(!gr_acl_is_enabled()))
63790 + return 0;
63791 +
63792 + read_lock(&gr_inode_lock);
63793 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63794 + __get_dev(filp->f_path.dentry),
63795 + current->role);
63796 + read_unlock(&gr_inode_lock);
63797 +
63798 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63799 + (!curr->crashes && !curr->expires))
63800 + return 0;
63801 +
63802 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63803 + time_after(curr->expires, get_seconds()))
63804 + return 1;
63805 + else if (time_before_eq(curr->expires, get_seconds())) {
63806 + curr->crashes = 0;
63807 + curr->expires = 0;
63808 + }
63809 +
63810 + return 0;
63811 +}
63812 +
63813 +void
63814 +gr_handle_alertkill(struct task_struct *task)
63815 +{
63816 + struct acl_subject_label *curracl;
63817 + __u32 curr_ip;
63818 + struct task_struct *p, *p2;
63819 +
63820 + if (unlikely(!gr_acl_is_enabled()))
63821 + return;
63822 +
63823 + curracl = task->acl;
63824 + curr_ip = task->signal->curr_ip;
63825 +
63826 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63827 + read_lock(&tasklist_lock);
63828 + do_each_thread(p2, p) {
63829 + if (p->signal->curr_ip == curr_ip)
63830 + gr_fake_force_sig(SIGKILL, p);
63831 + } while_each_thread(p2, p);
63832 + read_unlock(&tasklist_lock);
63833 + } else if (curracl->mode & GR_KILLPROC)
63834 + gr_fake_force_sig(SIGKILL, task);
63835 +
63836 + return;
63837 +}
63838 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63839 new file mode 100644
63840 index 0000000..98011b0
63841 --- /dev/null
63842 +++ b/grsecurity/gracl_shm.c
63843 @@ -0,0 +1,40 @@
63844 +#include <linux/kernel.h>
63845 +#include <linux/mm.h>
63846 +#include <linux/sched.h>
63847 +#include <linux/file.h>
63848 +#include <linux/ipc.h>
63849 +#include <linux/gracl.h>
63850 +#include <linux/grsecurity.h>
63851 +#include <linux/grinternal.h>
63852 +
63853 +int
63854 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63855 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63856 +{
63857 + struct task_struct *task;
63858 +
63859 + if (!gr_acl_is_enabled())
63860 + return 1;
63861 +
63862 + rcu_read_lock();
63863 + read_lock(&tasklist_lock);
63864 +
63865 + task = find_task_by_vpid(shm_cprid);
63866 +
63867 + if (unlikely(!task))
63868 + task = find_task_by_vpid(shm_lapid);
63869 +
63870 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63871 + (task_pid_nr(task) == shm_lapid)) &&
63872 + (task->acl->mode & GR_PROTSHM) &&
63873 + (task->acl != current->acl))) {
63874 + read_unlock(&tasklist_lock);
63875 + rcu_read_unlock();
63876 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63877 + return 0;
63878 + }
63879 + read_unlock(&tasklist_lock);
63880 + rcu_read_unlock();
63881 +
63882 + return 1;
63883 +}
63884 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63885 new file mode 100644
63886 index 0000000..bc0be01
63887 --- /dev/null
63888 +++ b/grsecurity/grsec_chdir.c
63889 @@ -0,0 +1,19 @@
63890 +#include <linux/kernel.h>
63891 +#include <linux/sched.h>
63892 +#include <linux/fs.h>
63893 +#include <linux/file.h>
63894 +#include <linux/grsecurity.h>
63895 +#include <linux/grinternal.h>
63896 +
63897 +void
63898 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63899 +{
63900 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63901 + if ((grsec_enable_chdir && grsec_enable_group &&
63902 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63903 + !grsec_enable_group)) {
63904 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63905 + }
63906 +#endif
63907 + return;
63908 +}
63909 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63910 new file mode 100644
63911 index 0000000..bd6e105
63912 --- /dev/null
63913 +++ b/grsecurity/grsec_chroot.c
63914 @@ -0,0 +1,370 @@
63915 +#include <linux/kernel.h>
63916 +#include <linux/module.h>
63917 +#include <linux/sched.h>
63918 +#include <linux/file.h>
63919 +#include <linux/fs.h>
63920 +#include <linux/mount.h>
63921 +#include <linux/types.h>
63922 +#include "../fs/mount.h"
63923 +#include <linux/grsecurity.h>
63924 +#include <linux/grinternal.h>
63925 +
63926 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63927 +static int gr_init_ran;
63928 +#endif
63929 +
63930 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
63931 +{
63932 +#ifdef CONFIG_GRKERNSEC
63933 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63934 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
63935 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63936 + && gr_init_ran
63937 +#endif
63938 + )
63939 + task->gr_is_chrooted = 1;
63940 + else {
63941 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63942 + if (task_pid_nr(task) == 1 && !gr_init_ran)
63943 + gr_init_ran = 1;
63944 +#endif
63945 + task->gr_is_chrooted = 0;
63946 + }
63947 +
63948 + task->gr_chroot_dentry = path->dentry;
63949 +#endif
63950 + return;
63951 +}
63952 +
63953 +void gr_clear_chroot_entries(struct task_struct *task)
63954 +{
63955 +#ifdef CONFIG_GRKERNSEC
63956 + task->gr_is_chrooted = 0;
63957 + task->gr_chroot_dentry = NULL;
63958 +#endif
63959 + return;
63960 +}
63961 +
63962 +int
63963 +gr_handle_chroot_unix(const pid_t pid)
63964 +{
63965 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63966 + struct task_struct *p;
63967 +
63968 + if (unlikely(!grsec_enable_chroot_unix))
63969 + return 1;
63970 +
63971 + if (likely(!proc_is_chrooted(current)))
63972 + return 1;
63973 +
63974 + rcu_read_lock();
63975 + read_lock(&tasklist_lock);
63976 + p = find_task_by_vpid_unrestricted(pid);
63977 + if (unlikely(p && !have_same_root(current, p))) {
63978 + read_unlock(&tasklist_lock);
63979 + rcu_read_unlock();
63980 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63981 + return 0;
63982 + }
63983 + read_unlock(&tasklist_lock);
63984 + rcu_read_unlock();
63985 +#endif
63986 + return 1;
63987 +}
63988 +
63989 +int
63990 +gr_handle_chroot_nice(void)
63991 +{
63992 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63993 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63994 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63995 + return -EPERM;
63996 + }
63997 +#endif
63998 + return 0;
63999 +}
64000 +
64001 +int
64002 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64003 +{
64004 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64005 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64006 + && proc_is_chrooted(current)) {
64007 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64008 + return -EACCES;
64009 + }
64010 +#endif
64011 + return 0;
64012 +}
64013 +
64014 +int
64015 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64016 +{
64017 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64018 + struct task_struct *p;
64019 + int ret = 0;
64020 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64021 + return ret;
64022 +
64023 + read_lock(&tasklist_lock);
64024 + do_each_pid_task(pid, type, p) {
64025 + if (!have_same_root(current, p)) {
64026 + ret = 1;
64027 + goto out;
64028 + }
64029 + } while_each_pid_task(pid, type, p);
64030 +out:
64031 + read_unlock(&tasklist_lock);
64032 + return ret;
64033 +#endif
64034 + return 0;
64035 +}
64036 +
64037 +int
64038 +gr_pid_is_chrooted(struct task_struct *p)
64039 +{
64040 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64041 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64042 + return 0;
64043 +
64044 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64045 + !have_same_root(current, p)) {
64046 + return 1;
64047 + }
64048 +#endif
64049 + return 0;
64050 +}
64051 +
64052 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64053 +
64054 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64055 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64056 +{
64057 + struct path path, currentroot;
64058 + int ret = 0;
64059 +
64060 + path.dentry = (struct dentry *)u_dentry;
64061 + path.mnt = (struct vfsmount *)u_mnt;
64062 + get_fs_root(current->fs, &currentroot);
64063 + if (path_is_under(&path, &currentroot))
64064 + ret = 1;
64065 + path_put(&currentroot);
64066 +
64067 + return ret;
64068 +}
64069 +#endif
64070 +
64071 +int
64072 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64073 +{
64074 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64075 + if (!grsec_enable_chroot_fchdir)
64076 + return 1;
64077 +
64078 + if (!proc_is_chrooted(current))
64079 + return 1;
64080 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64081 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64082 + return 0;
64083 + }
64084 +#endif
64085 + return 1;
64086 +}
64087 +
64088 +int
64089 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64090 + const time_t shm_createtime)
64091 +{
64092 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64093 + struct task_struct *p;
64094 + time_t starttime;
64095 +
64096 + if (unlikely(!grsec_enable_chroot_shmat))
64097 + return 1;
64098 +
64099 + if (likely(!proc_is_chrooted(current)))
64100 + return 1;
64101 +
64102 + rcu_read_lock();
64103 + read_lock(&tasklist_lock);
64104 +
64105 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64106 + starttime = p->start_time.tv_sec;
64107 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64108 + if (have_same_root(current, p)) {
64109 + goto allow;
64110 + } else {
64111 + read_unlock(&tasklist_lock);
64112 + rcu_read_unlock();
64113 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64114 + return 0;
64115 + }
64116 + }
64117 + /* creator exited, pid reuse, fall through to next check */
64118 + }
64119 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64120 + if (unlikely(!have_same_root(current, p))) {
64121 + read_unlock(&tasklist_lock);
64122 + rcu_read_unlock();
64123 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64124 + return 0;
64125 + }
64126 + }
64127 +
64128 +allow:
64129 + read_unlock(&tasklist_lock);
64130 + rcu_read_unlock();
64131 +#endif
64132 + return 1;
64133 +}
64134 +
64135 +void
64136 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64137 +{
64138 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64139 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64140 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64141 +#endif
64142 + return;
64143 +}
64144 +
64145 +int
64146 +gr_handle_chroot_mknod(const struct dentry *dentry,
64147 + const struct vfsmount *mnt, const int mode)
64148 +{
64149 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64150 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64151 + proc_is_chrooted(current)) {
64152 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64153 + return -EPERM;
64154 + }
64155 +#endif
64156 + return 0;
64157 +}
64158 +
64159 +int
64160 +gr_handle_chroot_mount(const struct dentry *dentry,
64161 + const struct vfsmount *mnt, const char *dev_name)
64162 +{
64163 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64164 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64165 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64166 + return -EPERM;
64167 + }
64168 +#endif
64169 + return 0;
64170 +}
64171 +
64172 +int
64173 +gr_handle_chroot_pivot(void)
64174 +{
64175 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64176 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64177 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64178 + return -EPERM;
64179 + }
64180 +#endif
64181 + return 0;
64182 +}
64183 +
64184 +int
64185 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64186 +{
64187 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64188 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64189 + !gr_is_outside_chroot(dentry, mnt)) {
64190 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64191 + return -EPERM;
64192 + }
64193 +#endif
64194 + return 0;
64195 +}
64196 +
64197 +extern const char *captab_log[];
64198 +extern int captab_log_entries;
64199 +
64200 +int
64201 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64202 +{
64203 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64204 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64205 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64206 + if (cap_raised(chroot_caps, cap)) {
64207 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64208 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64209 + }
64210 + return 0;
64211 + }
64212 + }
64213 +#endif
64214 + return 1;
64215 +}
64216 +
64217 +int
64218 +gr_chroot_is_capable(const int cap)
64219 +{
64220 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64221 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64222 +#endif
64223 + return 1;
64224 +}
64225 +
64226 +int
64227 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64228 +{
64229 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64230 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64231 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64232 + if (cap_raised(chroot_caps, cap)) {
64233 + return 0;
64234 + }
64235 + }
64236 +#endif
64237 + return 1;
64238 +}
64239 +
64240 +int
64241 +gr_chroot_is_capable_nolog(const int cap)
64242 +{
64243 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64244 + return gr_task_chroot_is_capable_nolog(current, cap);
64245 +#endif
64246 + return 1;
64247 +}
64248 +
64249 +int
64250 +gr_handle_chroot_sysctl(const int op)
64251 +{
64252 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64253 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64254 + proc_is_chrooted(current))
64255 + return -EACCES;
64256 +#endif
64257 + return 0;
64258 +}
64259 +
64260 +void
64261 +gr_handle_chroot_chdir(const struct path *path)
64262 +{
64263 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64264 + if (grsec_enable_chroot_chdir)
64265 + set_fs_pwd(current->fs, path);
64266 +#endif
64267 + return;
64268 +}
64269 +
64270 +int
64271 +gr_handle_chroot_chmod(const struct dentry *dentry,
64272 + const struct vfsmount *mnt, const int mode)
64273 +{
64274 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64275 + /* allow chmod +s on directories, but not files */
64276 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64277 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64278 + proc_is_chrooted(current)) {
64279 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64280 + return -EPERM;
64281 + }
64282 +#endif
64283 + return 0;
64284 +}
64285 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64286 new file mode 100644
64287 index 0000000..ce65ceb
64288 --- /dev/null
64289 +++ b/grsecurity/grsec_disabled.c
64290 @@ -0,0 +1,434 @@
64291 +#include <linux/kernel.h>
64292 +#include <linux/module.h>
64293 +#include <linux/sched.h>
64294 +#include <linux/file.h>
64295 +#include <linux/fs.h>
64296 +#include <linux/kdev_t.h>
64297 +#include <linux/net.h>
64298 +#include <linux/in.h>
64299 +#include <linux/ip.h>
64300 +#include <linux/skbuff.h>
64301 +#include <linux/sysctl.h>
64302 +
64303 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64304 +void
64305 +pax_set_initial_flags(struct linux_binprm *bprm)
64306 +{
64307 + return;
64308 +}
64309 +#endif
64310 +
64311 +#ifdef CONFIG_SYSCTL
64312 +__u32
64313 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64314 +{
64315 + return 0;
64316 +}
64317 +#endif
64318 +
64319 +#ifdef CONFIG_TASKSTATS
64320 +int gr_is_taskstats_denied(int pid)
64321 +{
64322 + return 0;
64323 +}
64324 +#endif
64325 +
64326 +int
64327 +gr_acl_is_enabled(void)
64328 +{
64329 + return 0;
64330 +}
64331 +
64332 +void
64333 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64334 +{
64335 + return;
64336 +}
64337 +
64338 +int
64339 +gr_handle_rawio(const struct inode *inode)
64340 +{
64341 + return 0;
64342 +}
64343 +
64344 +void
64345 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64346 +{
64347 + return;
64348 +}
64349 +
64350 +int
64351 +gr_handle_ptrace(struct task_struct *task, const long request)
64352 +{
64353 + return 0;
64354 +}
64355 +
64356 +int
64357 +gr_handle_proc_ptrace(struct task_struct *task)
64358 +{
64359 + return 0;
64360 +}
64361 +
64362 +int
64363 +gr_set_acls(const int type)
64364 +{
64365 + return 0;
64366 +}
64367 +
64368 +int
64369 +gr_check_hidden_task(const struct task_struct *tsk)
64370 +{
64371 + return 0;
64372 +}
64373 +
64374 +int
64375 +gr_check_protected_task(const struct task_struct *task)
64376 +{
64377 + return 0;
64378 +}
64379 +
64380 +int
64381 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64382 +{
64383 + return 0;
64384 +}
64385 +
64386 +void
64387 +gr_copy_label(struct task_struct *tsk)
64388 +{
64389 + return;
64390 +}
64391 +
64392 +void
64393 +gr_set_pax_flags(struct task_struct *task)
64394 +{
64395 + return;
64396 +}
64397 +
64398 +int
64399 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64400 + const int unsafe_share)
64401 +{
64402 + return 0;
64403 +}
64404 +
64405 +void
64406 +gr_handle_delete(const ino_t ino, const dev_t dev)
64407 +{
64408 + return;
64409 +}
64410 +
64411 +void
64412 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64413 +{
64414 + return;
64415 +}
64416 +
64417 +void
64418 +gr_handle_crash(struct task_struct *task, const int sig)
64419 +{
64420 + return;
64421 +}
64422 +
64423 +int
64424 +gr_check_crash_exec(const struct file *filp)
64425 +{
64426 + return 0;
64427 +}
64428 +
64429 +int
64430 +gr_check_crash_uid(const kuid_t uid)
64431 +{
64432 + return 0;
64433 +}
64434 +
64435 +void
64436 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64437 + struct dentry *old_dentry,
64438 + struct dentry *new_dentry,
64439 + struct vfsmount *mnt, const __u8 replace)
64440 +{
64441 + return;
64442 +}
64443 +
64444 +int
64445 +gr_search_socket(const int family, const int type, const int protocol)
64446 +{
64447 + return 1;
64448 +}
64449 +
64450 +int
64451 +gr_search_connectbind(const int mode, const struct socket *sock,
64452 + const struct sockaddr_in *addr)
64453 +{
64454 + return 0;
64455 +}
64456 +
64457 +void
64458 +gr_handle_alertkill(struct task_struct *task)
64459 +{
64460 + return;
64461 +}
64462 +
64463 +__u32
64464 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64465 +{
64466 + return 1;
64467 +}
64468 +
64469 +__u32
64470 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64471 + const struct vfsmount * mnt)
64472 +{
64473 + return 1;
64474 +}
64475 +
64476 +__u32
64477 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64478 + int acc_mode)
64479 +{
64480 + return 1;
64481 +}
64482 +
64483 +__u32
64484 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64485 +{
64486 + return 1;
64487 +}
64488 +
64489 +__u32
64490 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64491 +{
64492 + return 1;
64493 +}
64494 +
64495 +int
64496 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64497 + unsigned int *vm_flags)
64498 +{
64499 + return 1;
64500 +}
64501 +
64502 +__u32
64503 +gr_acl_handle_truncate(const struct dentry * dentry,
64504 + const struct vfsmount * mnt)
64505 +{
64506 + return 1;
64507 +}
64508 +
64509 +__u32
64510 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64511 +{
64512 + return 1;
64513 +}
64514 +
64515 +__u32
64516 +gr_acl_handle_access(const struct dentry * dentry,
64517 + const struct vfsmount * mnt, const int fmode)
64518 +{
64519 + return 1;
64520 +}
64521 +
64522 +__u32
64523 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64524 + umode_t *mode)
64525 +{
64526 + return 1;
64527 +}
64528 +
64529 +__u32
64530 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64531 +{
64532 + return 1;
64533 +}
64534 +
64535 +__u32
64536 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64537 +{
64538 + return 1;
64539 +}
64540 +
64541 +void
64542 +grsecurity_init(void)
64543 +{
64544 + return;
64545 +}
64546 +
64547 +umode_t gr_acl_umask(void)
64548 +{
64549 + return 0;
64550 +}
64551 +
64552 +__u32
64553 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64554 + const struct dentry * parent_dentry,
64555 + const struct vfsmount * parent_mnt,
64556 + const int mode)
64557 +{
64558 + return 1;
64559 +}
64560 +
64561 +__u32
64562 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64563 + const struct dentry * parent_dentry,
64564 + const struct vfsmount * parent_mnt)
64565 +{
64566 + return 1;
64567 +}
64568 +
64569 +__u32
64570 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64571 + const struct dentry * parent_dentry,
64572 + const struct vfsmount * parent_mnt, const struct filename *from)
64573 +{
64574 + return 1;
64575 +}
64576 +
64577 +__u32
64578 +gr_acl_handle_link(const struct dentry * new_dentry,
64579 + const struct dentry * parent_dentry,
64580 + const struct vfsmount * parent_mnt,
64581 + const struct dentry * old_dentry,
64582 + const struct vfsmount * old_mnt, const struct filename *to)
64583 +{
64584 + return 1;
64585 +}
64586 +
64587 +int
64588 +gr_acl_handle_rename(const struct dentry *new_dentry,
64589 + const struct dentry *parent_dentry,
64590 + const struct vfsmount *parent_mnt,
64591 + const struct dentry *old_dentry,
64592 + const struct inode *old_parent_inode,
64593 + const struct vfsmount *old_mnt, const struct filename *newname)
64594 +{
64595 + return 0;
64596 +}
64597 +
64598 +int
64599 +gr_acl_handle_filldir(const struct file *file, const char *name,
64600 + const int namelen, const ino_t ino)
64601 +{
64602 + return 1;
64603 +}
64604 +
64605 +int
64606 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64607 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64608 +{
64609 + return 1;
64610 +}
64611 +
64612 +int
64613 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64614 +{
64615 + return 0;
64616 +}
64617 +
64618 +int
64619 +gr_search_accept(const struct socket *sock)
64620 +{
64621 + return 0;
64622 +}
64623 +
64624 +int
64625 +gr_search_listen(const struct socket *sock)
64626 +{
64627 + return 0;
64628 +}
64629 +
64630 +int
64631 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64632 +{
64633 + return 0;
64634 +}
64635 +
64636 +__u32
64637 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64638 +{
64639 + return 1;
64640 +}
64641 +
64642 +__u32
64643 +gr_acl_handle_creat(const struct dentry * dentry,
64644 + const struct dentry * p_dentry,
64645 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64646 + const int imode)
64647 +{
64648 + return 1;
64649 +}
64650 +
64651 +void
64652 +gr_acl_handle_exit(void)
64653 +{
64654 + return;
64655 +}
64656 +
64657 +int
64658 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64659 +{
64660 + return 1;
64661 +}
64662 +
64663 +void
64664 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64665 +{
64666 + return;
64667 +}
64668 +
64669 +int
64670 +gr_acl_handle_procpidmem(const struct task_struct *task)
64671 +{
64672 + return 0;
64673 +}
64674 +
64675 +int
64676 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64677 +{
64678 + return 0;
64679 +}
64680 +
64681 +int
64682 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64683 +{
64684 + return 0;
64685 +}
64686 +
64687 +void
64688 +gr_set_kernel_label(struct task_struct *task)
64689 +{
64690 + return;
64691 +}
64692 +
64693 +int
64694 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64695 +{
64696 + return 0;
64697 +}
64698 +
64699 +int
64700 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64701 +{
64702 + return 0;
64703 +}
64704 +
64705 +int gr_acl_enable_at_secure(void)
64706 +{
64707 + return 0;
64708 +}
64709 +
64710 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64711 +{
64712 + return dentry->d_sb->s_dev;
64713 +}
64714 +
64715 +void gr_put_exec_file(struct task_struct *task)
64716 +{
64717 + return;
64718 +}
64719 +
64720 +EXPORT_SYMBOL(gr_set_kernel_label);
64721 +#ifdef CONFIG_SECURITY
64722 +EXPORT_SYMBOL(gr_check_user_change);
64723 +EXPORT_SYMBOL(gr_check_group_change);
64724 +#endif
64725 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64726 new file mode 100644
64727 index 0000000..387032b
64728 --- /dev/null
64729 +++ b/grsecurity/grsec_exec.c
64730 @@ -0,0 +1,187 @@
64731 +#include <linux/kernel.h>
64732 +#include <linux/sched.h>
64733 +#include <linux/file.h>
64734 +#include <linux/binfmts.h>
64735 +#include <linux/fs.h>
64736 +#include <linux/types.h>
64737 +#include <linux/grdefs.h>
64738 +#include <linux/grsecurity.h>
64739 +#include <linux/grinternal.h>
64740 +#include <linux/capability.h>
64741 +#include <linux/module.h>
64742 +#include <linux/compat.h>
64743 +
64744 +#include <asm/uaccess.h>
64745 +
64746 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64747 +static char gr_exec_arg_buf[132];
64748 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64749 +#endif
64750 +
64751 +struct user_arg_ptr {
64752 +#ifdef CONFIG_COMPAT
64753 + bool is_compat;
64754 +#endif
64755 + union {
64756 + const char __user *const __user *native;
64757 +#ifdef CONFIG_COMPAT
64758 + const compat_uptr_t __user *compat;
64759 +#endif
64760 + } ptr;
64761 +};
64762 +
64763 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64764 +
64765 +void
64766 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64767 +{
64768 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64769 + char *grarg = gr_exec_arg_buf;
64770 + unsigned int i, x, execlen = 0;
64771 + char c;
64772 +
64773 + if (!((grsec_enable_execlog && grsec_enable_group &&
64774 + in_group_p(grsec_audit_gid))
64775 + || (grsec_enable_execlog && !grsec_enable_group)))
64776 + return;
64777 +
64778 + mutex_lock(&gr_exec_arg_mutex);
64779 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64780 +
64781 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64782 + const char __user *p;
64783 + unsigned int len;
64784 +
64785 + p = get_user_arg_ptr(argv, i);
64786 + if (IS_ERR(p))
64787 + goto log;
64788 +
64789 + len = strnlen_user(p, 128 - execlen);
64790 + if (len > 128 - execlen)
64791 + len = 128 - execlen;
64792 + else if (len > 0)
64793 + len--;
64794 + if (copy_from_user(grarg + execlen, p, len))
64795 + goto log;
64796 +
64797 + /* rewrite unprintable characters */
64798 + for (x = 0; x < len; x++) {
64799 + c = *(grarg + execlen + x);
64800 + if (c < 32 || c > 126)
64801 + *(grarg + execlen + x) = ' ';
64802 + }
64803 +
64804 + execlen += len;
64805 + *(grarg + execlen) = ' ';
64806 + *(grarg + execlen + 1) = '\0';
64807 + execlen++;
64808 + }
64809 +
64810 + log:
64811 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64812 + bprm->file->f_path.mnt, grarg);
64813 + mutex_unlock(&gr_exec_arg_mutex);
64814 +#endif
64815 + return;
64816 +}
64817 +
64818 +#ifdef CONFIG_GRKERNSEC
64819 +extern int gr_acl_is_capable(const int cap);
64820 +extern int gr_acl_is_capable_nolog(const int cap);
64821 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64822 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64823 +extern int gr_chroot_is_capable(const int cap);
64824 +extern int gr_chroot_is_capable_nolog(const int cap);
64825 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64826 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64827 +#endif
64828 +
64829 +const char *captab_log[] = {
64830 + "CAP_CHOWN",
64831 + "CAP_DAC_OVERRIDE",
64832 + "CAP_DAC_READ_SEARCH",
64833 + "CAP_FOWNER",
64834 + "CAP_FSETID",
64835 + "CAP_KILL",
64836 + "CAP_SETGID",
64837 + "CAP_SETUID",
64838 + "CAP_SETPCAP",
64839 + "CAP_LINUX_IMMUTABLE",
64840 + "CAP_NET_BIND_SERVICE",
64841 + "CAP_NET_BROADCAST",
64842 + "CAP_NET_ADMIN",
64843 + "CAP_NET_RAW",
64844 + "CAP_IPC_LOCK",
64845 + "CAP_IPC_OWNER",
64846 + "CAP_SYS_MODULE",
64847 + "CAP_SYS_RAWIO",
64848 + "CAP_SYS_CHROOT",
64849 + "CAP_SYS_PTRACE",
64850 + "CAP_SYS_PACCT",
64851 + "CAP_SYS_ADMIN",
64852 + "CAP_SYS_BOOT",
64853 + "CAP_SYS_NICE",
64854 + "CAP_SYS_RESOURCE",
64855 + "CAP_SYS_TIME",
64856 + "CAP_SYS_TTY_CONFIG",
64857 + "CAP_MKNOD",
64858 + "CAP_LEASE",
64859 + "CAP_AUDIT_WRITE",
64860 + "CAP_AUDIT_CONTROL",
64861 + "CAP_SETFCAP",
64862 + "CAP_MAC_OVERRIDE",
64863 + "CAP_MAC_ADMIN",
64864 + "CAP_SYSLOG",
64865 + "CAP_WAKE_ALARM"
64866 +};
64867 +
64868 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64869 +
64870 +int gr_is_capable(const int cap)
64871 +{
64872 +#ifdef CONFIG_GRKERNSEC
64873 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64874 + return 1;
64875 + return 0;
64876 +#else
64877 + return 1;
64878 +#endif
64879 +}
64880 +
64881 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64882 +{
64883 +#ifdef CONFIG_GRKERNSEC
64884 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64885 + return 1;
64886 + return 0;
64887 +#else
64888 + return 1;
64889 +#endif
64890 +}
64891 +
64892 +int gr_is_capable_nolog(const int cap)
64893 +{
64894 +#ifdef CONFIG_GRKERNSEC
64895 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64896 + return 1;
64897 + return 0;
64898 +#else
64899 + return 1;
64900 +#endif
64901 +}
64902 +
64903 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64904 +{
64905 +#ifdef CONFIG_GRKERNSEC
64906 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64907 + return 1;
64908 + return 0;
64909 +#else
64910 + return 1;
64911 +#endif
64912 +}
64913 +
64914 +EXPORT_SYMBOL(gr_is_capable);
64915 +EXPORT_SYMBOL(gr_is_capable_nolog);
64916 +EXPORT_SYMBOL(gr_task_is_capable);
64917 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64918 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64919 new file mode 100644
64920 index 0000000..06cc6ea
64921 --- /dev/null
64922 +++ b/grsecurity/grsec_fifo.c
64923 @@ -0,0 +1,24 @@
64924 +#include <linux/kernel.h>
64925 +#include <linux/sched.h>
64926 +#include <linux/fs.h>
64927 +#include <linux/file.h>
64928 +#include <linux/grinternal.h>
64929 +
64930 +int
64931 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64932 + const struct dentry *dir, const int flag, const int acc_mode)
64933 +{
64934 +#ifdef CONFIG_GRKERNSEC_FIFO
64935 + const struct cred *cred = current_cred();
64936 +
64937 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64938 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64939 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64940 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64941 + if (!inode_permission(dentry->d_inode, acc_mode))
64942 + 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));
64943 + return -EACCES;
64944 + }
64945 +#endif
64946 + return 0;
64947 +}
64948 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64949 new file mode 100644
64950 index 0000000..8ca18bf
64951 --- /dev/null
64952 +++ b/grsecurity/grsec_fork.c
64953 @@ -0,0 +1,23 @@
64954 +#include <linux/kernel.h>
64955 +#include <linux/sched.h>
64956 +#include <linux/grsecurity.h>
64957 +#include <linux/grinternal.h>
64958 +#include <linux/errno.h>
64959 +
64960 +void
64961 +gr_log_forkfail(const int retval)
64962 +{
64963 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64964 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64965 + switch (retval) {
64966 + case -EAGAIN:
64967 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64968 + break;
64969 + case -ENOMEM:
64970 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64971 + break;
64972 + }
64973 + }
64974 +#endif
64975 + return;
64976 +}
64977 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64978 new file mode 100644
64979 index 0000000..a862e9f
64980 --- /dev/null
64981 +++ b/grsecurity/grsec_init.c
64982 @@ -0,0 +1,283 @@
64983 +#include <linux/kernel.h>
64984 +#include <linux/sched.h>
64985 +#include <linux/mm.h>
64986 +#include <linux/gracl.h>
64987 +#include <linux/slab.h>
64988 +#include <linux/vmalloc.h>
64989 +#include <linux/percpu.h>
64990 +#include <linux/module.h>
64991 +
64992 +int grsec_enable_ptrace_readexec;
64993 +int grsec_enable_setxid;
64994 +int grsec_enable_symlinkown;
64995 +kgid_t grsec_symlinkown_gid;
64996 +int grsec_enable_brute;
64997 +int grsec_enable_link;
64998 +int grsec_enable_dmesg;
64999 +int grsec_enable_harden_ptrace;
65000 +int grsec_enable_fifo;
65001 +int grsec_enable_execlog;
65002 +int grsec_enable_signal;
65003 +int grsec_enable_forkfail;
65004 +int grsec_enable_audit_ptrace;
65005 +int grsec_enable_time;
65006 +int grsec_enable_audit_textrel;
65007 +int grsec_enable_group;
65008 +kgid_t grsec_audit_gid;
65009 +int grsec_enable_chdir;
65010 +int grsec_enable_mount;
65011 +int grsec_enable_rofs;
65012 +int grsec_enable_chroot_findtask;
65013 +int grsec_enable_chroot_mount;
65014 +int grsec_enable_chroot_shmat;
65015 +int grsec_enable_chroot_fchdir;
65016 +int grsec_enable_chroot_double;
65017 +int grsec_enable_chroot_pivot;
65018 +int grsec_enable_chroot_chdir;
65019 +int grsec_enable_chroot_chmod;
65020 +int grsec_enable_chroot_mknod;
65021 +int grsec_enable_chroot_nice;
65022 +int grsec_enable_chroot_execlog;
65023 +int grsec_enable_chroot_caps;
65024 +int grsec_enable_chroot_sysctl;
65025 +int grsec_enable_chroot_unix;
65026 +int grsec_enable_tpe;
65027 +kgid_t grsec_tpe_gid;
65028 +int grsec_enable_blackhole;
65029 +#ifdef CONFIG_IPV6_MODULE
65030 +EXPORT_SYMBOL(grsec_enable_blackhole);
65031 +#endif
65032 +int grsec_lastack_retries;
65033 +int grsec_enable_tpe_all;
65034 +int grsec_enable_tpe_invert;
65035 +int grsec_enable_socket_all;
65036 +kgid_t grsec_socket_all_gid;
65037 +int grsec_enable_socket_client;
65038 +kgid_t grsec_socket_client_gid;
65039 +int grsec_enable_socket_server;
65040 +kgid_t grsec_socket_server_gid;
65041 +int grsec_resource_logging;
65042 +int grsec_disable_privio;
65043 +int grsec_enable_log_rwxmaps;
65044 +int grsec_lock;
65045 +
65046 +DEFINE_SPINLOCK(grsec_alert_lock);
65047 +unsigned long grsec_alert_wtime = 0;
65048 +unsigned long grsec_alert_fyet = 0;
65049 +
65050 +DEFINE_SPINLOCK(grsec_audit_lock);
65051 +
65052 +DEFINE_RWLOCK(grsec_exec_file_lock);
65053 +
65054 +char *gr_shared_page[4];
65055 +
65056 +char *gr_alert_log_fmt;
65057 +char *gr_audit_log_fmt;
65058 +char *gr_alert_log_buf;
65059 +char *gr_audit_log_buf;
65060 +
65061 +extern struct gr_arg *gr_usermode;
65062 +extern unsigned char *gr_system_salt;
65063 +extern unsigned char *gr_system_sum;
65064 +
65065 +void __init
65066 +grsecurity_init(void)
65067 +{
65068 + int j;
65069 + /* create the per-cpu shared pages */
65070 +
65071 +#ifdef CONFIG_X86
65072 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65073 +#endif
65074 +
65075 + for (j = 0; j < 4; j++) {
65076 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65077 + if (gr_shared_page[j] == NULL) {
65078 + panic("Unable to allocate grsecurity shared page");
65079 + return;
65080 + }
65081 + }
65082 +
65083 + /* allocate log buffers */
65084 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65085 + if (!gr_alert_log_fmt) {
65086 + panic("Unable to allocate grsecurity alert log format buffer");
65087 + return;
65088 + }
65089 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65090 + if (!gr_audit_log_fmt) {
65091 + panic("Unable to allocate grsecurity audit log format buffer");
65092 + return;
65093 + }
65094 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65095 + if (!gr_alert_log_buf) {
65096 + panic("Unable to allocate grsecurity alert log buffer");
65097 + return;
65098 + }
65099 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65100 + if (!gr_audit_log_buf) {
65101 + panic("Unable to allocate grsecurity audit log buffer");
65102 + return;
65103 + }
65104 +
65105 + /* allocate memory for authentication structure */
65106 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65107 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65108 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65109 +
65110 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65111 + panic("Unable to allocate grsecurity authentication structure");
65112 + return;
65113 + }
65114 +
65115 +
65116 +#ifdef CONFIG_GRKERNSEC_IO
65117 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65118 + grsec_disable_privio = 1;
65119 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65120 + grsec_disable_privio = 1;
65121 +#else
65122 + grsec_disable_privio = 0;
65123 +#endif
65124 +#endif
65125 +
65126 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65127 + /* for backward compatibility, tpe_invert always defaults to on if
65128 + enabled in the kernel
65129 + */
65130 + grsec_enable_tpe_invert = 1;
65131 +#endif
65132 +
65133 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65134 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65135 + grsec_lock = 1;
65136 +#endif
65137 +
65138 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65139 + grsec_enable_audit_textrel = 1;
65140 +#endif
65141 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65142 + grsec_enable_log_rwxmaps = 1;
65143 +#endif
65144 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65145 + grsec_enable_group = 1;
65146 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65147 +#endif
65148 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65149 + grsec_enable_ptrace_readexec = 1;
65150 +#endif
65151 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65152 + grsec_enable_chdir = 1;
65153 +#endif
65154 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65155 + grsec_enable_harden_ptrace = 1;
65156 +#endif
65157 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65158 + grsec_enable_mount = 1;
65159 +#endif
65160 +#ifdef CONFIG_GRKERNSEC_LINK
65161 + grsec_enable_link = 1;
65162 +#endif
65163 +#ifdef CONFIG_GRKERNSEC_BRUTE
65164 + grsec_enable_brute = 1;
65165 +#endif
65166 +#ifdef CONFIG_GRKERNSEC_DMESG
65167 + grsec_enable_dmesg = 1;
65168 +#endif
65169 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65170 + grsec_enable_blackhole = 1;
65171 + grsec_lastack_retries = 4;
65172 +#endif
65173 +#ifdef CONFIG_GRKERNSEC_FIFO
65174 + grsec_enable_fifo = 1;
65175 +#endif
65176 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65177 + grsec_enable_execlog = 1;
65178 +#endif
65179 +#ifdef CONFIG_GRKERNSEC_SETXID
65180 + grsec_enable_setxid = 1;
65181 +#endif
65182 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65183 + grsec_enable_signal = 1;
65184 +#endif
65185 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65186 + grsec_enable_forkfail = 1;
65187 +#endif
65188 +#ifdef CONFIG_GRKERNSEC_TIME
65189 + grsec_enable_time = 1;
65190 +#endif
65191 +#ifdef CONFIG_GRKERNSEC_RESLOG
65192 + grsec_resource_logging = 1;
65193 +#endif
65194 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65195 + grsec_enable_chroot_findtask = 1;
65196 +#endif
65197 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65198 + grsec_enable_chroot_unix = 1;
65199 +#endif
65200 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65201 + grsec_enable_chroot_mount = 1;
65202 +#endif
65203 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65204 + grsec_enable_chroot_fchdir = 1;
65205 +#endif
65206 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65207 + grsec_enable_chroot_shmat = 1;
65208 +#endif
65209 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65210 + grsec_enable_audit_ptrace = 1;
65211 +#endif
65212 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65213 + grsec_enable_chroot_double = 1;
65214 +#endif
65215 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65216 + grsec_enable_chroot_pivot = 1;
65217 +#endif
65218 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65219 + grsec_enable_chroot_chdir = 1;
65220 +#endif
65221 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65222 + grsec_enable_chroot_chmod = 1;
65223 +#endif
65224 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65225 + grsec_enable_chroot_mknod = 1;
65226 +#endif
65227 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65228 + grsec_enable_chroot_nice = 1;
65229 +#endif
65230 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65231 + grsec_enable_chroot_execlog = 1;
65232 +#endif
65233 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65234 + grsec_enable_chroot_caps = 1;
65235 +#endif
65236 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65237 + grsec_enable_chroot_sysctl = 1;
65238 +#endif
65239 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65240 + grsec_enable_symlinkown = 1;
65241 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65242 +#endif
65243 +#ifdef CONFIG_GRKERNSEC_TPE
65244 + grsec_enable_tpe = 1;
65245 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65246 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65247 + grsec_enable_tpe_all = 1;
65248 +#endif
65249 +#endif
65250 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65251 + grsec_enable_socket_all = 1;
65252 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65253 +#endif
65254 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65255 + grsec_enable_socket_client = 1;
65256 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65257 +#endif
65258 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65259 + grsec_enable_socket_server = 1;
65260 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65261 +#endif
65262 +#endif
65263 +
65264 + return;
65265 +}
65266 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65267 new file mode 100644
65268 index 0000000..5e05e20
65269 --- /dev/null
65270 +++ b/grsecurity/grsec_link.c
65271 @@ -0,0 +1,58 @@
65272 +#include <linux/kernel.h>
65273 +#include <linux/sched.h>
65274 +#include <linux/fs.h>
65275 +#include <linux/file.h>
65276 +#include <linux/grinternal.h>
65277 +
65278 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65279 +{
65280 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65281 + const struct inode *link_inode = link->dentry->d_inode;
65282 +
65283 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65284 + /* ignore root-owned links, e.g. /proc/self */
65285 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65286 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65287 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65288 + return 1;
65289 + }
65290 +#endif
65291 + return 0;
65292 +}
65293 +
65294 +int
65295 +gr_handle_follow_link(const struct inode *parent,
65296 + const struct inode *inode,
65297 + const struct dentry *dentry, const struct vfsmount *mnt)
65298 +{
65299 +#ifdef CONFIG_GRKERNSEC_LINK
65300 + const struct cred *cred = current_cred();
65301 +
65302 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65303 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65304 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65305 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65306 + return -EACCES;
65307 + }
65308 +#endif
65309 + return 0;
65310 +}
65311 +
65312 +int
65313 +gr_handle_hardlink(const struct dentry *dentry,
65314 + const struct vfsmount *mnt,
65315 + struct inode *inode, const int mode, const struct filename *to)
65316 +{
65317 +#ifdef CONFIG_GRKERNSEC_LINK
65318 + const struct cred *cred = current_cred();
65319 +
65320 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65321 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65322 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65323 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65324 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65325 + return -EPERM;
65326 + }
65327 +#endif
65328 + return 0;
65329 +}
65330 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65331 new file mode 100644
65332 index 0000000..7c06085
65333 --- /dev/null
65334 +++ b/grsecurity/grsec_log.c
65335 @@ -0,0 +1,326 @@
65336 +#include <linux/kernel.h>
65337 +#include <linux/sched.h>
65338 +#include <linux/file.h>
65339 +#include <linux/tty.h>
65340 +#include <linux/fs.h>
65341 +#include <linux/grinternal.h>
65342 +
65343 +#ifdef CONFIG_TREE_PREEMPT_RCU
65344 +#define DISABLE_PREEMPT() preempt_disable()
65345 +#define ENABLE_PREEMPT() preempt_enable()
65346 +#else
65347 +#define DISABLE_PREEMPT()
65348 +#define ENABLE_PREEMPT()
65349 +#endif
65350 +
65351 +#define BEGIN_LOCKS(x) \
65352 + DISABLE_PREEMPT(); \
65353 + rcu_read_lock(); \
65354 + read_lock(&tasklist_lock); \
65355 + read_lock(&grsec_exec_file_lock); \
65356 + if (x != GR_DO_AUDIT) \
65357 + spin_lock(&grsec_alert_lock); \
65358 + else \
65359 + spin_lock(&grsec_audit_lock)
65360 +
65361 +#define END_LOCKS(x) \
65362 + if (x != GR_DO_AUDIT) \
65363 + spin_unlock(&grsec_alert_lock); \
65364 + else \
65365 + spin_unlock(&grsec_audit_lock); \
65366 + read_unlock(&grsec_exec_file_lock); \
65367 + read_unlock(&tasklist_lock); \
65368 + rcu_read_unlock(); \
65369 + ENABLE_PREEMPT(); \
65370 + if (x == GR_DONT_AUDIT) \
65371 + gr_handle_alertkill(current)
65372 +
65373 +enum {
65374 + FLOODING,
65375 + NO_FLOODING
65376 +};
65377 +
65378 +extern char *gr_alert_log_fmt;
65379 +extern char *gr_audit_log_fmt;
65380 +extern char *gr_alert_log_buf;
65381 +extern char *gr_audit_log_buf;
65382 +
65383 +static int gr_log_start(int audit)
65384 +{
65385 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65386 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65387 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65388 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65389 + unsigned long curr_secs = get_seconds();
65390 +
65391 + if (audit == GR_DO_AUDIT)
65392 + goto set_fmt;
65393 +
65394 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65395 + grsec_alert_wtime = curr_secs;
65396 + grsec_alert_fyet = 0;
65397 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65398 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65399 + grsec_alert_fyet++;
65400 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65401 + grsec_alert_wtime = curr_secs;
65402 + grsec_alert_fyet++;
65403 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65404 + return FLOODING;
65405 + }
65406 + else return FLOODING;
65407 +
65408 +set_fmt:
65409 +#endif
65410 + memset(buf, 0, PAGE_SIZE);
65411 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65412 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65413 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65414 + } else if (current->signal->curr_ip) {
65415 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65416 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65417 + } else if (gr_acl_is_enabled()) {
65418 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65419 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65420 + } else {
65421 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65422 + strcpy(buf, fmt);
65423 + }
65424 +
65425 + return NO_FLOODING;
65426 +}
65427 +
65428 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65429 + __attribute__ ((format (printf, 2, 0)));
65430 +
65431 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65432 +{
65433 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65434 + unsigned int len = strlen(buf);
65435 +
65436 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65437 +
65438 + return;
65439 +}
65440 +
65441 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65442 + __attribute__ ((format (printf, 2, 3)));
65443 +
65444 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65445 +{
65446 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65447 + unsigned int len = strlen(buf);
65448 + va_list ap;
65449 +
65450 + va_start(ap, msg);
65451 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65452 + va_end(ap);
65453 +
65454 + return;
65455 +}
65456 +
65457 +static void gr_log_end(int audit, int append_default)
65458 +{
65459 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65460 + if (append_default) {
65461 + struct task_struct *task = current;
65462 + struct task_struct *parent = task->real_parent;
65463 + const struct cred *cred = __task_cred(task);
65464 + const struct cred *pcred = __task_cred(parent);
65465 + unsigned int len = strlen(buf);
65466 +
65467 + 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));
65468 + }
65469 +
65470 + printk("%s\n", buf);
65471 +
65472 + return;
65473 +}
65474 +
65475 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65476 +{
65477 + int logtype;
65478 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65479 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65480 + void *voidptr = NULL;
65481 + int num1 = 0, num2 = 0;
65482 + unsigned long ulong1 = 0, ulong2 = 0;
65483 + struct dentry *dentry = NULL;
65484 + struct vfsmount *mnt = NULL;
65485 + struct file *file = NULL;
65486 + struct task_struct *task = NULL;
65487 + const struct cred *cred, *pcred;
65488 + va_list ap;
65489 +
65490 + BEGIN_LOCKS(audit);
65491 + logtype = gr_log_start(audit);
65492 + if (logtype == FLOODING) {
65493 + END_LOCKS(audit);
65494 + return;
65495 + }
65496 + va_start(ap, argtypes);
65497 + switch (argtypes) {
65498 + case GR_TTYSNIFF:
65499 + task = va_arg(ap, struct task_struct *);
65500 + 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));
65501 + break;
65502 + case GR_SYSCTL_HIDDEN:
65503 + str1 = va_arg(ap, char *);
65504 + gr_log_middle_varargs(audit, msg, result, str1);
65505 + break;
65506 + case GR_RBAC:
65507 + dentry = va_arg(ap, struct dentry *);
65508 + mnt = va_arg(ap, struct vfsmount *);
65509 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65510 + break;
65511 + case GR_RBAC_STR:
65512 + dentry = va_arg(ap, struct dentry *);
65513 + mnt = va_arg(ap, struct vfsmount *);
65514 + str1 = va_arg(ap, char *);
65515 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65516 + break;
65517 + case GR_STR_RBAC:
65518 + str1 = va_arg(ap, char *);
65519 + dentry = va_arg(ap, struct dentry *);
65520 + mnt = va_arg(ap, struct vfsmount *);
65521 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65522 + break;
65523 + case GR_RBAC_MODE2:
65524 + dentry = va_arg(ap, struct dentry *);
65525 + mnt = va_arg(ap, struct vfsmount *);
65526 + str1 = va_arg(ap, char *);
65527 + str2 = va_arg(ap, char *);
65528 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65529 + break;
65530 + case GR_RBAC_MODE3:
65531 + dentry = va_arg(ap, struct dentry *);
65532 + mnt = va_arg(ap, struct vfsmount *);
65533 + str1 = va_arg(ap, char *);
65534 + str2 = va_arg(ap, char *);
65535 + str3 = va_arg(ap, char *);
65536 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65537 + break;
65538 + case GR_FILENAME:
65539 + dentry = va_arg(ap, struct dentry *);
65540 + mnt = va_arg(ap, struct vfsmount *);
65541 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65542 + break;
65543 + case GR_STR_FILENAME:
65544 + str1 = va_arg(ap, char *);
65545 + dentry = va_arg(ap, struct dentry *);
65546 + mnt = va_arg(ap, struct vfsmount *);
65547 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65548 + break;
65549 + case GR_FILENAME_STR:
65550 + dentry = va_arg(ap, struct dentry *);
65551 + mnt = va_arg(ap, struct vfsmount *);
65552 + str1 = va_arg(ap, char *);
65553 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65554 + break;
65555 + case GR_FILENAME_TWO_INT:
65556 + dentry = va_arg(ap, struct dentry *);
65557 + mnt = va_arg(ap, struct vfsmount *);
65558 + num1 = va_arg(ap, int);
65559 + num2 = va_arg(ap, int);
65560 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65561 + break;
65562 + case GR_FILENAME_TWO_INT_STR:
65563 + dentry = va_arg(ap, struct dentry *);
65564 + mnt = va_arg(ap, struct vfsmount *);
65565 + num1 = va_arg(ap, int);
65566 + num2 = va_arg(ap, int);
65567 + str1 = va_arg(ap, char *);
65568 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65569 + break;
65570 + case GR_TEXTREL:
65571 + file = va_arg(ap, struct file *);
65572 + ulong1 = va_arg(ap, unsigned long);
65573 + ulong2 = va_arg(ap, unsigned long);
65574 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65575 + break;
65576 + case GR_PTRACE:
65577 + task = va_arg(ap, struct task_struct *);
65578 + 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));
65579 + break;
65580 + case GR_RESOURCE:
65581 + task = va_arg(ap, struct task_struct *);
65582 + cred = __task_cred(task);
65583 + pcred = __task_cred(task->real_parent);
65584 + ulong1 = va_arg(ap, unsigned long);
65585 + str1 = va_arg(ap, char *);
65586 + ulong2 = va_arg(ap, unsigned long);
65587 + 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));
65588 + break;
65589 + case GR_CAP:
65590 + task = va_arg(ap, struct task_struct *);
65591 + cred = __task_cred(task);
65592 + pcred = __task_cred(task->real_parent);
65593 + str1 = va_arg(ap, char *);
65594 + 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));
65595 + break;
65596 + case GR_SIG:
65597 + str1 = va_arg(ap, char *);
65598 + voidptr = va_arg(ap, void *);
65599 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65600 + break;
65601 + case GR_SIG2:
65602 + task = va_arg(ap, struct task_struct *);
65603 + cred = __task_cred(task);
65604 + pcred = __task_cred(task->real_parent);
65605 + num1 = va_arg(ap, int);
65606 + 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));
65607 + break;
65608 + case GR_CRASH1:
65609 + task = va_arg(ap, struct task_struct *);
65610 + cred = __task_cred(task);
65611 + pcred = __task_cred(task->real_parent);
65612 + ulong1 = va_arg(ap, unsigned long);
65613 + 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);
65614 + break;
65615 + case GR_CRASH2:
65616 + task = va_arg(ap, struct task_struct *);
65617 + cred = __task_cred(task);
65618 + pcred = __task_cred(task->real_parent);
65619 + ulong1 = va_arg(ap, unsigned long);
65620 + 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);
65621 + break;
65622 + case GR_RWXMAP:
65623 + file = va_arg(ap, struct file *);
65624 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65625 + break;
65626 + case GR_PSACCT:
65627 + {
65628 + unsigned int wday, cday;
65629 + __u8 whr, chr;
65630 + __u8 wmin, cmin;
65631 + __u8 wsec, csec;
65632 + char cur_tty[64] = { 0 };
65633 + char parent_tty[64] = { 0 };
65634 +
65635 + task = va_arg(ap, struct task_struct *);
65636 + wday = va_arg(ap, unsigned int);
65637 + cday = va_arg(ap, unsigned int);
65638 + whr = va_arg(ap, int);
65639 + chr = va_arg(ap, int);
65640 + wmin = va_arg(ap, int);
65641 + cmin = va_arg(ap, int);
65642 + wsec = va_arg(ap, int);
65643 + csec = va_arg(ap, int);
65644 + ulong1 = va_arg(ap, unsigned long);
65645 + cred = __task_cred(task);
65646 + pcred = __task_cred(task->real_parent);
65647 +
65648 + 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));
65649 + }
65650 + break;
65651 + default:
65652 + gr_log_middle(audit, msg, ap);
65653 + }
65654 + va_end(ap);
65655 + // these don't need DEFAULTSECARGS printed on the end
65656 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65657 + gr_log_end(audit, 0);
65658 + else
65659 + gr_log_end(audit, 1);
65660 + END_LOCKS(audit);
65661 +}
65662 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65663 new file mode 100644
65664 index 0000000..f536303
65665 --- /dev/null
65666 +++ b/grsecurity/grsec_mem.c
65667 @@ -0,0 +1,40 @@
65668 +#include <linux/kernel.h>
65669 +#include <linux/sched.h>
65670 +#include <linux/mm.h>
65671 +#include <linux/mman.h>
65672 +#include <linux/grinternal.h>
65673 +
65674 +void
65675 +gr_handle_ioperm(void)
65676 +{
65677 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65678 + return;
65679 +}
65680 +
65681 +void
65682 +gr_handle_iopl(void)
65683 +{
65684 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65685 + return;
65686 +}
65687 +
65688 +void
65689 +gr_handle_mem_readwrite(u64 from, u64 to)
65690 +{
65691 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65692 + return;
65693 +}
65694 +
65695 +void
65696 +gr_handle_vm86(void)
65697 +{
65698 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65699 + return;
65700 +}
65701 +
65702 +void
65703 +gr_log_badprocpid(const char *entry)
65704 +{
65705 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65706 + return;
65707 +}
65708 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65709 new file mode 100644
65710 index 0000000..2131422
65711 --- /dev/null
65712 +++ b/grsecurity/grsec_mount.c
65713 @@ -0,0 +1,62 @@
65714 +#include <linux/kernel.h>
65715 +#include <linux/sched.h>
65716 +#include <linux/mount.h>
65717 +#include <linux/grsecurity.h>
65718 +#include <linux/grinternal.h>
65719 +
65720 +void
65721 +gr_log_remount(const char *devname, const int retval)
65722 +{
65723 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65724 + if (grsec_enable_mount && (retval >= 0))
65725 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65726 +#endif
65727 + return;
65728 +}
65729 +
65730 +void
65731 +gr_log_unmount(const char *devname, const int retval)
65732 +{
65733 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65734 + if (grsec_enable_mount && (retval >= 0))
65735 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65736 +#endif
65737 + return;
65738 +}
65739 +
65740 +void
65741 +gr_log_mount(const char *from, const char *to, const int retval)
65742 +{
65743 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65744 + if (grsec_enable_mount && (retval >= 0))
65745 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65746 +#endif
65747 + return;
65748 +}
65749 +
65750 +int
65751 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65752 +{
65753 +#ifdef CONFIG_GRKERNSEC_ROFS
65754 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65755 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65756 + return -EPERM;
65757 + } else
65758 + return 0;
65759 +#endif
65760 + return 0;
65761 +}
65762 +
65763 +int
65764 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65765 +{
65766 +#ifdef CONFIG_GRKERNSEC_ROFS
65767 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65768 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65769 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65770 + return -EPERM;
65771 + } else
65772 + return 0;
65773 +#endif
65774 + return 0;
65775 +}
65776 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65777 new file mode 100644
65778 index 0000000..a3b12a0
65779 --- /dev/null
65780 +++ b/grsecurity/grsec_pax.c
65781 @@ -0,0 +1,36 @@
65782 +#include <linux/kernel.h>
65783 +#include <linux/sched.h>
65784 +#include <linux/mm.h>
65785 +#include <linux/file.h>
65786 +#include <linux/grinternal.h>
65787 +#include <linux/grsecurity.h>
65788 +
65789 +void
65790 +gr_log_textrel(struct vm_area_struct * vma)
65791 +{
65792 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65793 + if (grsec_enable_audit_textrel)
65794 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65795 +#endif
65796 + return;
65797 +}
65798 +
65799 +void
65800 +gr_log_rwxmmap(struct file *file)
65801 +{
65802 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65803 + if (grsec_enable_log_rwxmaps)
65804 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65805 +#endif
65806 + return;
65807 +}
65808 +
65809 +void
65810 +gr_log_rwxmprotect(struct file *file)
65811 +{
65812 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65813 + if (grsec_enable_log_rwxmaps)
65814 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65815 +#endif
65816 + return;
65817 +}
65818 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65819 new file mode 100644
65820 index 0000000..f7f29aa
65821 --- /dev/null
65822 +++ b/grsecurity/grsec_ptrace.c
65823 @@ -0,0 +1,30 @@
65824 +#include <linux/kernel.h>
65825 +#include <linux/sched.h>
65826 +#include <linux/grinternal.h>
65827 +#include <linux/security.h>
65828 +
65829 +void
65830 +gr_audit_ptrace(struct task_struct *task)
65831 +{
65832 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65833 + if (grsec_enable_audit_ptrace)
65834 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65835 +#endif
65836 + return;
65837 +}
65838 +
65839 +int
65840 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65841 +{
65842 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65843 + const struct dentry *dentry = file->f_path.dentry;
65844 + const struct vfsmount *mnt = file->f_path.mnt;
65845 +
65846 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65847 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65848 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65849 + return -EACCES;
65850 + }
65851 +#endif
65852 + return 0;
65853 +}
65854 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65855 new file mode 100644
65856 index 0000000..e09715a
65857 --- /dev/null
65858 +++ b/grsecurity/grsec_sig.c
65859 @@ -0,0 +1,222 @@
65860 +#include <linux/kernel.h>
65861 +#include <linux/sched.h>
65862 +#include <linux/delay.h>
65863 +#include <linux/grsecurity.h>
65864 +#include <linux/grinternal.h>
65865 +#include <linux/hardirq.h>
65866 +
65867 +char *signames[] = {
65868 + [SIGSEGV] = "Segmentation fault",
65869 + [SIGILL] = "Illegal instruction",
65870 + [SIGABRT] = "Abort",
65871 + [SIGBUS] = "Invalid alignment/Bus error"
65872 +};
65873 +
65874 +void
65875 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65876 +{
65877 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65878 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65879 + (sig == SIGABRT) || (sig == SIGBUS))) {
65880 + if (task_pid_nr(t) == task_pid_nr(current)) {
65881 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65882 + } else {
65883 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65884 + }
65885 + }
65886 +#endif
65887 + return;
65888 +}
65889 +
65890 +int
65891 +gr_handle_signal(const struct task_struct *p, const int sig)
65892 +{
65893 +#ifdef CONFIG_GRKERNSEC
65894 + /* ignore the 0 signal for protected task checks */
65895 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65896 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65897 + return -EPERM;
65898 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65899 + return -EPERM;
65900 + }
65901 +#endif
65902 + return 0;
65903 +}
65904 +
65905 +#ifdef CONFIG_GRKERNSEC
65906 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65907 +
65908 +int gr_fake_force_sig(int sig, struct task_struct *t)
65909 +{
65910 + unsigned long int flags;
65911 + int ret, blocked, ignored;
65912 + struct k_sigaction *action;
65913 +
65914 + spin_lock_irqsave(&t->sighand->siglock, flags);
65915 + action = &t->sighand->action[sig-1];
65916 + ignored = action->sa.sa_handler == SIG_IGN;
65917 + blocked = sigismember(&t->blocked, sig);
65918 + if (blocked || ignored) {
65919 + action->sa.sa_handler = SIG_DFL;
65920 + if (blocked) {
65921 + sigdelset(&t->blocked, sig);
65922 + recalc_sigpending_and_wake(t);
65923 + }
65924 + }
65925 + if (action->sa.sa_handler == SIG_DFL)
65926 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65927 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65928 +
65929 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65930 +
65931 + return ret;
65932 +}
65933 +#endif
65934 +
65935 +#ifdef CONFIG_GRKERNSEC_BRUTE
65936 +#define GR_USER_BAN_TIME (15 * 60)
65937 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65938 +
65939 +static int __get_dumpable(unsigned long mm_flags)
65940 +{
65941 + int ret;
65942 +
65943 + ret = mm_flags & MMF_DUMPABLE_MASK;
65944 + return (ret >= 2) ? 2 : ret;
65945 +}
65946 +#endif
65947 +
65948 +void gr_handle_brute_attach(unsigned long mm_flags)
65949 +{
65950 +#ifdef CONFIG_GRKERNSEC_BRUTE
65951 + struct task_struct *p = current;
65952 + kuid_t uid = GLOBAL_ROOT_UID;
65953 + int daemon = 0;
65954 +
65955 + if (!grsec_enable_brute)
65956 + return;
65957 +
65958 + rcu_read_lock();
65959 + read_lock(&tasklist_lock);
65960 + read_lock(&grsec_exec_file_lock);
65961 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65962 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65963 + p->real_parent->brute = 1;
65964 + daemon = 1;
65965 + } else {
65966 + const struct cred *cred = __task_cred(p), *cred2;
65967 + struct task_struct *tsk, *tsk2;
65968 +
65969 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65970 + struct user_struct *user;
65971 +
65972 + uid = cred->uid;
65973 +
65974 + /* this is put upon execution past expiration */
65975 + user = find_user(uid);
65976 + if (user == NULL)
65977 + goto unlock;
65978 + user->banned = 1;
65979 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65980 + if (user->ban_expires == ~0UL)
65981 + user->ban_expires--;
65982 +
65983 + do_each_thread(tsk2, tsk) {
65984 + cred2 = __task_cred(tsk);
65985 + if (tsk != p && uid_eq(cred2->uid, uid))
65986 + gr_fake_force_sig(SIGKILL, tsk);
65987 + } while_each_thread(tsk2, tsk);
65988 + }
65989 + }
65990 +unlock:
65991 + read_unlock(&grsec_exec_file_lock);
65992 + read_unlock(&tasklist_lock);
65993 + rcu_read_unlock();
65994 +
65995 + if (gr_is_global_nonroot(uid))
65996 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65997 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65998 + else if (daemon)
65999 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66000 +
66001 +#endif
66002 + return;
66003 +}
66004 +
66005 +void gr_handle_brute_check(void)
66006 +{
66007 +#ifdef CONFIG_GRKERNSEC_BRUTE
66008 + struct task_struct *p = current;
66009 +
66010 + if (unlikely(p->brute)) {
66011 + if (!grsec_enable_brute)
66012 + p->brute = 0;
66013 + else if (time_before(get_seconds(), p->brute_expires))
66014 + msleep(30 * 1000);
66015 + }
66016 +#endif
66017 + return;
66018 +}
66019 +
66020 +void gr_handle_kernel_exploit(void)
66021 +{
66022 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66023 + const struct cred *cred;
66024 + struct task_struct *tsk, *tsk2;
66025 + struct user_struct *user;
66026 + kuid_t uid;
66027 +
66028 + if (in_irq() || in_serving_softirq() || in_nmi())
66029 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66030 +
66031 + uid = current_uid();
66032 +
66033 + if (gr_is_global_root(uid))
66034 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66035 + else {
66036 + /* kill all the processes of this user, hold a reference
66037 + to their creds struct, and prevent them from creating
66038 + another process until system reset
66039 + */
66040 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66041 + GR_GLOBAL_UID(uid));
66042 + /* we intentionally leak this ref */
66043 + user = get_uid(current->cred->user);
66044 + if (user) {
66045 + user->banned = 1;
66046 + user->ban_expires = ~0UL;
66047 + }
66048 +
66049 + read_lock(&tasklist_lock);
66050 + do_each_thread(tsk2, tsk) {
66051 + cred = __task_cred(tsk);
66052 + if (uid_eq(cred->uid, uid))
66053 + gr_fake_force_sig(SIGKILL, tsk);
66054 + } while_each_thread(tsk2, tsk);
66055 + read_unlock(&tasklist_lock);
66056 + }
66057 +#endif
66058 +}
66059 +
66060 +int __gr_process_user_ban(struct user_struct *user)
66061 +{
66062 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66063 + if (unlikely(user->banned)) {
66064 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
66065 + user->banned = 0;
66066 + user->ban_expires = 0;
66067 + free_uid(user);
66068 + } else
66069 + return -EPERM;
66070 + }
66071 +#endif
66072 + return 0;
66073 +}
66074 +
66075 +int gr_process_user_ban(void)
66076 +{
66077 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66078 + return __gr_process_user_ban(current->cred->user);
66079 +#endif
66080 + return 0;
66081 +}
66082 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66083 new file mode 100644
66084 index 0000000..4030d57
66085 --- /dev/null
66086 +++ b/grsecurity/grsec_sock.c
66087 @@ -0,0 +1,244 @@
66088 +#include <linux/kernel.h>
66089 +#include <linux/module.h>
66090 +#include <linux/sched.h>
66091 +#include <linux/file.h>
66092 +#include <linux/net.h>
66093 +#include <linux/in.h>
66094 +#include <linux/ip.h>
66095 +#include <net/sock.h>
66096 +#include <net/inet_sock.h>
66097 +#include <linux/grsecurity.h>
66098 +#include <linux/grinternal.h>
66099 +#include <linux/gracl.h>
66100 +
66101 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66102 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66103 +
66104 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66105 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66106 +
66107 +#ifdef CONFIG_UNIX_MODULE
66108 +EXPORT_SYMBOL(gr_acl_handle_unix);
66109 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66110 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66111 +EXPORT_SYMBOL(gr_handle_create);
66112 +#endif
66113 +
66114 +#ifdef CONFIG_GRKERNSEC
66115 +#define gr_conn_table_size 32749
66116 +struct conn_table_entry {
66117 + struct conn_table_entry *next;
66118 + struct signal_struct *sig;
66119 +};
66120 +
66121 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66122 +DEFINE_SPINLOCK(gr_conn_table_lock);
66123 +
66124 +extern const char * gr_socktype_to_name(unsigned char type);
66125 +extern const char * gr_proto_to_name(unsigned char proto);
66126 +extern const char * gr_sockfamily_to_name(unsigned char family);
66127 +
66128 +static __inline__ int
66129 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66130 +{
66131 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66132 +}
66133 +
66134 +static __inline__ int
66135 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66136 + __u16 sport, __u16 dport)
66137 +{
66138 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66139 + sig->gr_sport == sport && sig->gr_dport == dport))
66140 + return 1;
66141 + else
66142 + return 0;
66143 +}
66144 +
66145 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66146 +{
66147 + struct conn_table_entry **match;
66148 + unsigned int index;
66149 +
66150 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66151 + sig->gr_sport, sig->gr_dport,
66152 + gr_conn_table_size);
66153 +
66154 + newent->sig = sig;
66155 +
66156 + match = &gr_conn_table[index];
66157 + newent->next = *match;
66158 + *match = newent;
66159 +
66160 + return;
66161 +}
66162 +
66163 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66164 +{
66165 + struct conn_table_entry *match, *last = NULL;
66166 + unsigned int index;
66167 +
66168 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66169 + sig->gr_sport, sig->gr_dport,
66170 + gr_conn_table_size);
66171 +
66172 + match = gr_conn_table[index];
66173 + while (match && !conn_match(match->sig,
66174 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66175 + sig->gr_dport)) {
66176 + last = match;
66177 + match = match->next;
66178 + }
66179 +
66180 + if (match) {
66181 + if (last)
66182 + last->next = match->next;
66183 + else
66184 + gr_conn_table[index] = NULL;
66185 + kfree(match);
66186 + }
66187 +
66188 + return;
66189 +}
66190 +
66191 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66192 + __u16 sport, __u16 dport)
66193 +{
66194 + struct conn_table_entry *match;
66195 + unsigned int index;
66196 +
66197 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66198 +
66199 + match = gr_conn_table[index];
66200 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66201 + match = match->next;
66202 +
66203 + if (match)
66204 + return match->sig;
66205 + else
66206 + return NULL;
66207 +}
66208 +
66209 +#endif
66210 +
66211 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66212 +{
66213 +#ifdef CONFIG_GRKERNSEC
66214 + struct signal_struct *sig = task->signal;
66215 + struct conn_table_entry *newent;
66216 +
66217 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66218 + if (newent == NULL)
66219 + return;
66220 + /* no bh lock needed since we are called with bh disabled */
66221 + spin_lock(&gr_conn_table_lock);
66222 + gr_del_task_from_ip_table_nolock(sig);
66223 + sig->gr_saddr = inet->inet_rcv_saddr;
66224 + sig->gr_daddr = inet->inet_daddr;
66225 + sig->gr_sport = inet->inet_sport;
66226 + sig->gr_dport = inet->inet_dport;
66227 + gr_add_to_task_ip_table_nolock(sig, newent);
66228 + spin_unlock(&gr_conn_table_lock);
66229 +#endif
66230 + return;
66231 +}
66232 +
66233 +void gr_del_task_from_ip_table(struct task_struct *task)
66234 +{
66235 +#ifdef CONFIG_GRKERNSEC
66236 + spin_lock_bh(&gr_conn_table_lock);
66237 + gr_del_task_from_ip_table_nolock(task->signal);
66238 + spin_unlock_bh(&gr_conn_table_lock);
66239 +#endif
66240 + return;
66241 +}
66242 +
66243 +void
66244 +gr_attach_curr_ip(const struct sock *sk)
66245 +{
66246 +#ifdef CONFIG_GRKERNSEC
66247 + struct signal_struct *p, *set;
66248 + const struct inet_sock *inet = inet_sk(sk);
66249 +
66250 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66251 + return;
66252 +
66253 + set = current->signal;
66254 +
66255 + spin_lock_bh(&gr_conn_table_lock);
66256 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66257 + inet->inet_dport, inet->inet_sport);
66258 + if (unlikely(p != NULL)) {
66259 + set->curr_ip = p->curr_ip;
66260 + set->used_accept = 1;
66261 + gr_del_task_from_ip_table_nolock(p);
66262 + spin_unlock_bh(&gr_conn_table_lock);
66263 + return;
66264 + }
66265 + spin_unlock_bh(&gr_conn_table_lock);
66266 +
66267 + set->curr_ip = inet->inet_daddr;
66268 + set->used_accept = 1;
66269 +#endif
66270 + return;
66271 +}
66272 +
66273 +int
66274 +gr_handle_sock_all(const int family, const int type, const int protocol)
66275 +{
66276 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66277 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66278 + (family != AF_UNIX)) {
66279 + if (family == AF_INET)
66280 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66281 + else
66282 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66283 + return -EACCES;
66284 + }
66285 +#endif
66286 + return 0;
66287 +}
66288 +
66289 +int
66290 +gr_handle_sock_server(const struct sockaddr *sck)
66291 +{
66292 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66293 + if (grsec_enable_socket_server &&
66294 + in_group_p(grsec_socket_server_gid) &&
66295 + sck && (sck->sa_family != AF_UNIX) &&
66296 + (sck->sa_family != AF_LOCAL)) {
66297 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66298 + return -EACCES;
66299 + }
66300 +#endif
66301 + return 0;
66302 +}
66303 +
66304 +int
66305 +gr_handle_sock_server_other(const struct sock *sck)
66306 +{
66307 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66308 + if (grsec_enable_socket_server &&
66309 + in_group_p(grsec_socket_server_gid) &&
66310 + sck && (sck->sk_family != AF_UNIX) &&
66311 + (sck->sk_family != AF_LOCAL)) {
66312 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66313 + return -EACCES;
66314 + }
66315 +#endif
66316 + return 0;
66317 +}
66318 +
66319 +int
66320 +gr_handle_sock_client(const struct sockaddr *sck)
66321 +{
66322 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66323 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66324 + sck && (sck->sa_family != AF_UNIX) &&
66325 + (sck->sa_family != AF_LOCAL)) {
66326 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66327 + return -EACCES;
66328 + }
66329 +#endif
66330 + return 0;
66331 +}
66332 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66333 new file mode 100644
66334 index 0000000..f55ef0f
66335 --- /dev/null
66336 +++ b/grsecurity/grsec_sysctl.c
66337 @@ -0,0 +1,469 @@
66338 +#include <linux/kernel.h>
66339 +#include <linux/sched.h>
66340 +#include <linux/sysctl.h>
66341 +#include <linux/grsecurity.h>
66342 +#include <linux/grinternal.h>
66343 +
66344 +int
66345 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66346 +{
66347 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66348 + if (dirname == NULL || name == NULL)
66349 + return 0;
66350 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66351 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66352 + return -EACCES;
66353 + }
66354 +#endif
66355 + return 0;
66356 +}
66357 +
66358 +#ifdef CONFIG_GRKERNSEC_ROFS
66359 +static int __maybe_unused one = 1;
66360 +#endif
66361 +
66362 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66363 +struct ctl_table grsecurity_table[] = {
66364 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66365 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66366 +#ifdef CONFIG_GRKERNSEC_IO
66367 + {
66368 + .procname = "disable_priv_io",
66369 + .data = &grsec_disable_privio,
66370 + .maxlen = sizeof(int),
66371 + .mode = 0600,
66372 + .proc_handler = &proc_dointvec,
66373 + },
66374 +#endif
66375 +#endif
66376 +#ifdef CONFIG_GRKERNSEC_LINK
66377 + {
66378 + .procname = "linking_restrictions",
66379 + .data = &grsec_enable_link,
66380 + .maxlen = sizeof(int),
66381 + .mode = 0600,
66382 + .proc_handler = &proc_dointvec,
66383 + },
66384 +#endif
66385 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66386 + {
66387 + .procname = "enforce_symlinksifowner",
66388 + .data = &grsec_enable_symlinkown,
66389 + .maxlen = sizeof(int),
66390 + .mode = 0600,
66391 + .proc_handler = &proc_dointvec,
66392 + },
66393 + {
66394 + .procname = "symlinkown_gid",
66395 + .data = &grsec_symlinkown_gid,
66396 + .maxlen = sizeof(int),
66397 + .mode = 0600,
66398 + .proc_handler = &proc_dointvec,
66399 + },
66400 +#endif
66401 +#ifdef CONFIG_GRKERNSEC_BRUTE
66402 + {
66403 + .procname = "deter_bruteforce",
66404 + .data = &grsec_enable_brute,
66405 + .maxlen = sizeof(int),
66406 + .mode = 0600,
66407 + .proc_handler = &proc_dointvec,
66408 + },
66409 +#endif
66410 +#ifdef CONFIG_GRKERNSEC_FIFO
66411 + {
66412 + .procname = "fifo_restrictions",
66413 + .data = &grsec_enable_fifo,
66414 + .maxlen = sizeof(int),
66415 + .mode = 0600,
66416 + .proc_handler = &proc_dointvec,
66417 + },
66418 +#endif
66419 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66420 + {
66421 + .procname = "ptrace_readexec",
66422 + .data = &grsec_enable_ptrace_readexec,
66423 + .maxlen = sizeof(int),
66424 + .mode = 0600,
66425 + .proc_handler = &proc_dointvec,
66426 + },
66427 +#endif
66428 +#ifdef CONFIG_GRKERNSEC_SETXID
66429 + {
66430 + .procname = "consistent_setxid",
66431 + .data = &grsec_enable_setxid,
66432 + .maxlen = sizeof(int),
66433 + .mode = 0600,
66434 + .proc_handler = &proc_dointvec,
66435 + },
66436 +#endif
66437 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66438 + {
66439 + .procname = "ip_blackhole",
66440 + .data = &grsec_enable_blackhole,
66441 + .maxlen = sizeof(int),
66442 + .mode = 0600,
66443 + .proc_handler = &proc_dointvec,
66444 + },
66445 + {
66446 + .procname = "lastack_retries",
66447 + .data = &grsec_lastack_retries,
66448 + .maxlen = sizeof(int),
66449 + .mode = 0600,
66450 + .proc_handler = &proc_dointvec,
66451 + },
66452 +#endif
66453 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66454 + {
66455 + .procname = "exec_logging",
66456 + .data = &grsec_enable_execlog,
66457 + .maxlen = sizeof(int),
66458 + .mode = 0600,
66459 + .proc_handler = &proc_dointvec,
66460 + },
66461 +#endif
66462 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66463 + {
66464 + .procname = "rwxmap_logging",
66465 + .data = &grsec_enable_log_rwxmaps,
66466 + .maxlen = sizeof(int),
66467 + .mode = 0600,
66468 + .proc_handler = &proc_dointvec,
66469 + },
66470 +#endif
66471 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66472 + {
66473 + .procname = "signal_logging",
66474 + .data = &grsec_enable_signal,
66475 + .maxlen = sizeof(int),
66476 + .mode = 0600,
66477 + .proc_handler = &proc_dointvec,
66478 + },
66479 +#endif
66480 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66481 + {
66482 + .procname = "forkfail_logging",
66483 + .data = &grsec_enable_forkfail,
66484 + .maxlen = sizeof(int),
66485 + .mode = 0600,
66486 + .proc_handler = &proc_dointvec,
66487 + },
66488 +#endif
66489 +#ifdef CONFIG_GRKERNSEC_TIME
66490 + {
66491 + .procname = "timechange_logging",
66492 + .data = &grsec_enable_time,
66493 + .maxlen = sizeof(int),
66494 + .mode = 0600,
66495 + .proc_handler = &proc_dointvec,
66496 + },
66497 +#endif
66498 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66499 + {
66500 + .procname = "chroot_deny_shmat",
66501 + .data = &grsec_enable_chroot_shmat,
66502 + .maxlen = sizeof(int),
66503 + .mode = 0600,
66504 + .proc_handler = &proc_dointvec,
66505 + },
66506 +#endif
66507 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66508 + {
66509 + .procname = "chroot_deny_unix",
66510 + .data = &grsec_enable_chroot_unix,
66511 + .maxlen = sizeof(int),
66512 + .mode = 0600,
66513 + .proc_handler = &proc_dointvec,
66514 + },
66515 +#endif
66516 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66517 + {
66518 + .procname = "chroot_deny_mount",
66519 + .data = &grsec_enable_chroot_mount,
66520 + .maxlen = sizeof(int),
66521 + .mode = 0600,
66522 + .proc_handler = &proc_dointvec,
66523 + },
66524 +#endif
66525 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66526 + {
66527 + .procname = "chroot_deny_fchdir",
66528 + .data = &grsec_enable_chroot_fchdir,
66529 + .maxlen = sizeof(int),
66530 + .mode = 0600,
66531 + .proc_handler = &proc_dointvec,
66532 + },
66533 +#endif
66534 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66535 + {
66536 + .procname = "chroot_deny_chroot",
66537 + .data = &grsec_enable_chroot_double,
66538 + .maxlen = sizeof(int),
66539 + .mode = 0600,
66540 + .proc_handler = &proc_dointvec,
66541 + },
66542 +#endif
66543 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66544 + {
66545 + .procname = "chroot_deny_pivot",
66546 + .data = &grsec_enable_chroot_pivot,
66547 + .maxlen = sizeof(int),
66548 + .mode = 0600,
66549 + .proc_handler = &proc_dointvec,
66550 + },
66551 +#endif
66552 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66553 + {
66554 + .procname = "chroot_enforce_chdir",
66555 + .data = &grsec_enable_chroot_chdir,
66556 + .maxlen = sizeof(int),
66557 + .mode = 0600,
66558 + .proc_handler = &proc_dointvec,
66559 + },
66560 +#endif
66561 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66562 + {
66563 + .procname = "chroot_deny_chmod",
66564 + .data = &grsec_enable_chroot_chmod,
66565 + .maxlen = sizeof(int),
66566 + .mode = 0600,
66567 + .proc_handler = &proc_dointvec,
66568 + },
66569 +#endif
66570 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66571 + {
66572 + .procname = "chroot_deny_mknod",
66573 + .data = &grsec_enable_chroot_mknod,
66574 + .maxlen = sizeof(int),
66575 + .mode = 0600,
66576 + .proc_handler = &proc_dointvec,
66577 + },
66578 +#endif
66579 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66580 + {
66581 + .procname = "chroot_restrict_nice",
66582 + .data = &grsec_enable_chroot_nice,
66583 + .maxlen = sizeof(int),
66584 + .mode = 0600,
66585 + .proc_handler = &proc_dointvec,
66586 + },
66587 +#endif
66588 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66589 + {
66590 + .procname = "chroot_execlog",
66591 + .data = &grsec_enable_chroot_execlog,
66592 + .maxlen = sizeof(int),
66593 + .mode = 0600,
66594 + .proc_handler = &proc_dointvec,
66595 + },
66596 +#endif
66597 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66598 + {
66599 + .procname = "chroot_caps",
66600 + .data = &grsec_enable_chroot_caps,
66601 + .maxlen = sizeof(int),
66602 + .mode = 0600,
66603 + .proc_handler = &proc_dointvec,
66604 + },
66605 +#endif
66606 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66607 + {
66608 + .procname = "chroot_deny_sysctl",
66609 + .data = &grsec_enable_chroot_sysctl,
66610 + .maxlen = sizeof(int),
66611 + .mode = 0600,
66612 + .proc_handler = &proc_dointvec,
66613 + },
66614 +#endif
66615 +#ifdef CONFIG_GRKERNSEC_TPE
66616 + {
66617 + .procname = "tpe",
66618 + .data = &grsec_enable_tpe,
66619 + .maxlen = sizeof(int),
66620 + .mode = 0600,
66621 + .proc_handler = &proc_dointvec,
66622 + },
66623 + {
66624 + .procname = "tpe_gid",
66625 + .data = &grsec_tpe_gid,
66626 + .maxlen = sizeof(int),
66627 + .mode = 0600,
66628 + .proc_handler = &proc_dointvec,
66629 + },
66630 +#endif
66631 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66632 + {
66633 + .procname = "tpe_invert",
66634 + .data = &grsec_enable_tpe_invert,
66635 + .maxlen = sizeof(int),
66636 + .mode = 0600,
66637 + .proc_handler = &proc_dointvec,
66638 + },
66639 +#endif
66640 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66641 + {
66642 + .procname = "tpe_restrict_all",
66643 + .data = &grsec_enable_tpe_all,
66644 + .maxlen = sizeof(int),
66645 + .mode = 0600,
66646 + .proc_handler = &proc_dointvec,
66647 + },
66648 +#endif
66649 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66650 + {
66651 + .procname = "socket_all",
66652 + .data = &grsec_enable_socket_all,
66653 + .maxlen = sizeof(int),
66654 + .mode = 0600,
66655 + .proc_handler = &proc_dointvec,
66656 + },
66657 + {
66658 + .procname = "socket_all_gid",
66659 + .data = &grsec_socket_all_gid,
66660 + .maxlen = sizeof(int),
66661 + .mode = 0600,
66662 + .proc_handler = &proc_dointvec,
66663 + },
66664 +#endif
66665 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66666 + {
66667 + .procname = "socket_client",
66668 + .data = &grsec_enable_socket_client,
66669 + .maxlen = sizeof(int),
66670 + .mode = 0600,
66671 + .proc_handler = &proc_dointvec,
66672 + },
66673 + {
66674 + .procname = "socket_client_gid",
66675 + .data = &grsec_socket_client_gid,
66676 + .maxlen = sizeof(int),
66677 + .mode = 0600,
66678 + .proc_handler = &proc_dointvec,
66679 + },
66680 +#endif
66681 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66682 + {
66683 + .procname = "socket_server",
66684 + .data = &grsec_enable_socket_server,
66685 + .maxlen = sizeof(int),
66686 + .mode = 0600,
66687 + .proc_handler = &proc_dointvec,
66688 + },
66689 + {
66690 + .procname = "socket_server_gid",
66691 + .data = &grsec_socket_server_gid,
66692 + .maxlen = sizeof(int),
66693 + .mode = 0600,
66694 + .proc_handler = &proc_dointvec,
66695 + },
66696 +#endif
66697 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66698 + {
66699 + .procname = "audit_group",
66700 + .data = &grsec_enable_group,
66701 + .maxlen = sizeof(int),
66702 + .mode = 0600,
66703 + .proc_handler = &proc_dointvec,
66704 + },
66705 + {
66706 + .procname = "audit_gid",
66707 + .data = &grsec_audit_gid,
66708 + .maxlen = sizeof(int),
66709 + .mode = 0600,
66710 + .proc_handler = &proc_dointvec,
66711 + },
66712 +#endif
66713 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66714 + {
66715 + .procname = "audit_chdir",
66716 + .data = &grsec_enable_chdir,
66717 + .maxlen = sizeof(int),
66718 + .mode = 0600,
66719 + .proc_handler = &proc_dointvec,
66720 + },
66721 +#endif
66722 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66723 + {
66724 + .procname = "audit_mount",
66725 + .data = &grsec_enable_mount,
66726 + .maxlen = sizeof(int),
66727 + .mode = 0600,
66728 + .proc_handler = &proc_dointvec,
66729 + },
66730 +#endif
66731 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66732 + {
66733 + .procname = "audit_textrel",
66734 + .data = &grsec_enable_audit_textrel,
66735 + .maxlen = sizeof(int),
66736 + .mode = 0600,
66737 + .proc_handler = &proc_dointvec,
66738 + },
66739 +#endif
66740 +#ifdef CONFIG_GRKERNSEC_DMESG
66741 + {
66742 + .procname = "dmesg",
66743 + .data = &grsec_enable_dmesg,
66744 + .maxlen = sizeof(int),
66745 + .mode = 0600,
66746 + .proc_handler = &proc_dointvec,
66747 + },
66748 +#endif
66749 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66750 + {
66751 + .procname = "chroot_findtask",
66752 + .data = &grsec_enable_chroot_findtask,
66753 + .maxlen = sizeof(int),
66754 + .mode = 0600,
66755 + .proc_handler = &proc_dointvec,
66756 + },
66757 +#endif
66758 +#ifdef CONFIG_GRKERNSEC_RESLOG
66759 + {
66760 + .procname = "resource_logging",
66761 + .data = &grsec_resource_logging,
66762 + .maxlen = sizeof(int),
66763 + .mode = 0600,
66764 + .proc_handler = &proc_dointvec,
66765 + },
66766 +#endif
66767 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66768 + {
66769 + .procname = "audit_ptrace",
66770 + .data = &grsec_enable_audit_ptrace,
66771 + .maxlen = sizeof(int),
66772 + .mode = 0600,
66773 + .proc_handler = &proc_dointvec,
66774 + },
66775 +#endif
66776 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66777 + {
66778 + .procname = "harden_ptrace",
66779 + .data = &grsec_enable_harden_ptrace,
66780 + .maxlen = sizeof(int),
66781 + .mode = 0600,
66782 + .proc_handler = &proc_dointvec,
66783 + },
66784 +#endif
66785 + {
66786 + .procname = "grsec_lock",
66787 + .data = &grsec_lock,
66788 + .maxlen = sizeof(int),
66789 + .mode = 0600,
66790 + .proc_handler = &proc_dointvec,
66791 + },
66792 +#endif
66793 +#ifdef CONFIG_GRKERNSEC_ROFS
66794 + {
66795 + .procname = "romount_protect",
66796 + .data = &grsec_enable_rofs,
66797 + .maxlen = sizeof(int),
66798 + .mode = 0600,
66799 + .proc_handler = &proc_dointvec_minmax,
66800 + .extra1 = &one,
66801 + .extra2 = &one,
66802 + },
66803 +#endif
66804 + { }
66805 +};
66806 +#endif
66807 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66808 new file mode 100644
66809 index 0000000..0dc13c3
66810 --- /dev/null
66811 +++ b/grsecurity/grsec_time.c
66812 @@ -0,0 +1,16 @@
66813 +#include <linux/kernel.h>
66814 +#include <linux/sched.h>
66815 +#include <linux/grinternal.h>
66816 +#include <linux/module.h>
66817 +
66818 +void
66819 +gr_log_timechange(void)
66820 +{
66821 +#ifdef CONFIG_GRKERNSEC_TIME
66822 + if (grsec_enable_time)
66823 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66824 +#endif
66825 + return;
66826 +}
66827 +
66828 +EXPORT_SYMBOL(gr_log_timechange);
66829 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66830 new file mode 100644
66831 index 0000000..ee57dcf
66832 --- /dev/null
66833 +++ b/grsecurity/grsec_tpe.c
66834 @@ -0,0 +1,73 @@
66835 +#include <linux/kernel.h>
66836 +#include <linux/sched.h>
66837 +#include <linux/file.h>
66838 +#include <linux/fs.h>
66839 +#include <linux/grinternal.h>
66840 +
66841 +extern int gr_acl_tpe_check(void);
66842 +
66843 +int
66844 +gr_tpe_allow(const struct file *file)
66845 +{
66846 +#ifdef CONFIG_GRKERNSEC
66847 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66848 + const struct cred *cred = current_cred();
66849 + char *msg = NULL;
66850 + char *msg2 = NULL;
66851 +
66852 + // never restrict root
66853 + if (gr_is_global_root(cred->uid))
66854 + return 1;
66855 +
66856 + if (grsec_enable_tpe) {
66857 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66858 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66859 + msg = "not being in trusted group";
66860 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66861 + msg = "being in untrusted group";
66862 +#else
66863 + if (in_group_p(grsec_tpe_gid))
66864 + msg = "being in untrusted group";
66865 +#endif
66866 + }
66867 + if (!msg && gr_acl_tpe_check())
66868 + msg = "being in untrusted role";
66869 +
66870 + // not in any affected group/role
66871 + if (!msg)
66872 + goto next_check;
66873 +
66874 + if (gr_is_global_nonroot(inode->i_uid))
66875 + msg2 = "file in non-root-owned directory";
66876 + else if (inode->i_mode & S_IWOTH)
66877 + msg2 = "file in world-writable directory";
66878 + else if (inode->i_mode & S_IWGRP)
66879 + msg2 = "file in group-writable directory";
66880 +
66881 + if (msg && msg2) {
66882 + char fullmsg[70] = {0};
66883 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66884 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66885 + return 0;
66886 + }
66887 + msg = NULL;
66888 +next_check:
66889 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66890 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66891 + return 1;
66892 +
66893 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66894 + msg = "directory not owned by user";
66895 + else if (inode->i_mode & S_IWOTH)
66896 + msg = "file in world-writable directory";
66897 + else if (inode->i_mode & S_IWGRP)
66898 + msg = "file in group-writable directory";
66899 +
66900 + if (msg) {
66901 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66902 + return 0;
66903 + }
66904 +#endif
66905 +#endif
66906 + return 1;
66907 +}
66908 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66909 new file mode 100644
66910 index 0000000..9f7b1ac
66911 --- /dev/null
66912 +++ b/grsecurity/grsum.c
66913 @@ -0,0 +1,61 @@
66914 +#include <linux/err.h>
66915 +#include <linux/kernel.h>
66916 +#include <linux/sched.h>
66917 +#include <linux/mm.h>
66918 +#include <linux/scatterlist.h>
66919 +#include <linux/crypto.h>
66920 +#include <linux/gracl.h>
66921 +
66922 +
66923 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66924 +#error "crypto and sha256 must be built into the kernel"
66925 +#endif
66926 +
66927 +int
66928 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66929 +{
66930 + char *p;
66931 + struct crypto_hash *tfm;
66932 + struct hash_desc desc;
66933 + struct scatterlist sg;
66934 + unsigned char temp_sum[GR_SHA_LEN];
66935 + volatile int retval = 0;
66936 + volatile int dummy = 0;
66937 + unsigned int i;
66938 +
66939 + sg_init_table(&sg, 1);
66940 +
66941 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66942 + if (IS_ERR(tfm)) {
66943 + /* should never happen, since sha256 should be built in */
66944 + return 1;
66945 + }
66946 +
66947 + desc.tfm = tfm;
66948 + desc.flags = 0;
66949 +
66950 + crypto_hash_init(&desc);
66951 +
66952 + p = salt;
66953 + sg_set_buf(&sg, p, GR_SALT_LEN);
66954 + crypto_hash_update(&desc, &sg, sg.length);
66955 +
66956 + p = entry->pw;
66957 + sg_set_buf(&sg, p, strlen(p));
66958 +
66959 + crypto_hash_update(&desc, &sg, sg.length);
66960 +
66961 + crypto_hash_final(&desc, temp_sum);
66962 +
66963 + memset(entry->pw, 0, GR_PW_LEN);
66964 +
66965 + for (i = 0; i < GR_SHA_LEN; i++)
66966 + if (sum[i] != temp_sum[i])
66967 + retval = 1;
66968 + else
66969 + dummy = 1; // waste a cycle
66970 +
66971 + crypto_free_hash(tfm);
66972 +
66973 + return retval;
66974 +}
66975 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66976 index 77ff547..181834f 100644
66977 --- a/include/asm-generic/4level-fixup.h
66978 +++ b/include/asm-generic/4level-fixup.h
66979 @@ -13,8 +13,10 @@
66980 #define pmd_alloc(mm, pud, address) \
66981 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66982 NULL: pmd_offset(pud, address))
66983 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66984
66985 #define pud_alloc(mm, pgd, address) (pgd)
66986 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66987 #define pud_offset(pgd, start) (pgd)
66988 #define pud_none(pud) 0
66989 #define pud_bad(pud) 0
66990 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66991 index b7babf0..04ad282 100644
66992 --- a/include/asm-generic/atomic-long.h
66993 +++ b/include/asm-generic/atomic-long.h
66994 @@ -22,6 +22,12 @@
66995
66996 typedef atomic64_t atomic_long_t;
66997
66998 +#ifdef CONFIG_PAX_REFCOUNT
66999 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67000 +#else
67001 +typedef atomic64_t atomic_long_unchecked_t;
67002 +#endif
67003 +
67004 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67005
67006 static inline long atomic_long_read(atomic_long_t *l)
67007 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67008 return (long)atomic64_read(v);
67009 }
67010
67011 +#ifdef CONFIG_PAX_REFCOUNT
67012 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67013 +{
67014 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67015 +
67016 + return (long)atomic64_read_unchecked(v);
67017 +}
67018 +#endif
67019 +
67020 static inline void atomic_long_set(atomic_long_t *l, long i)
67021 {
67022 atomic64_t *v = (atomic64_t *)l;
67023 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67024 atomic64_set(v, i);
67025 }
67026
67027 +#ifdef CONFIG_PAX_REFCOUNT
67028 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67029 +{
67030 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67031 +
67032 + atomic64_set_unchecked(v, i);
67033 +}
67034 +#endif
67035 +
67036 static inline void atomic_long_inc(atomic_long_t *l)
67037 {
67038 atomic64_t *v = (atomic64_t *)l;
67039 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67040 atomic64_inc(v);
67041 }
67042
67043 +#ifdef CONFIG_PAX_REFCOUNT
67044 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67045 +{
67046 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67047 +
67048 + atomic64_inc_unchecked(v);
67049 +}
67050 +#endif
67051 +
67052 static inline void atomic_long_dec(atomic_long_t *l)
67053 {
67054 atomic64_t *v = (atomic64_t *)l;
67055 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67056 atomic64_dec(v);
67057 }
67058
67059 +#ifdef CONFIG_PAX_REFCOUNT
67060 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67061 +{
67062 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67063 +
67064 + atomic64_dec_unchecked(v);
67065 +}
67066 +#endif
67067 +
67068 static inline void atomic_long_add(long i, atomic_long_t *l)
67069 {
67070 atomic64_t *v = (atomic64_t *)l;
67071 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67072 atomic64_add(i, v);
67073 }
67074
67075 +#ifdef CONFIG_PAX_REFCOUNT
67076 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67077 +{
67078 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67079 +
67080 + atomic64_add_unchecked(i, v);
67081 +}
67082 +#endif
67083 +
67084 static inline void atomic_long_sub(long i, atomic_long_t *l)
67085 {
67086 atomic64_t *v = (atomic64_t *)l;
67087 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67088 atomic64_sub(i, v);
67089 }
67090
67091 +#ifdef CONFIG_PAX_REFCOUNT
67092 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67093 +{
67094 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67095 +
67096 + atomic64_sub_unchecked(i, v);
67097 +}
67098 +#endif
67099 +
67100 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67101 {
67102 atomic64_t *v = (atomic64_t *)l;
67103 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67104 return (long)atomic64_add_return(i, v);
67105 }
67106
67107 +#ifdef CONFIG_PAX_REFCOUNT
67108 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67109 +{
67110 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67111 +
67112 + return (long)atomic64_add_return_unchecked(i, v);
67113 +}
67114 +#endif
67115 +
67116 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67117 {
67118 atomic64_t *v = (atomic64_t *)l;
67119 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67120 return (long)atomic64_inc_return(v);
67121 }
67122
67123 +#ifdef CONFIG_PAX_REFCOUNT
67124 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67125 +{
67126 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67127 +
67128 + return (long)atomic64_inc_return_unchecked(v);
67129 +}
67130 +#endif
67131 +
67132 static inline long atomic_long_dec_return(atomic_long_t *l)
67133 {
67134 atomic64_t *v = (atomic64_t *)l;
67135 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67136
67137 typedef atomic_t atomic_long_t;
67138
67139 +#ifdef CONFIG_PAX_REFCOUNT
67140 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67141 +#else
67142 +typedef atomic_t atomic_long_unchecked_t;
67143 +#endif
67144 +
67145 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67146 static inline long atomic_long_read(atomic_long_t *l)
67147 {
67148 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67149 return (long)atomic_read(v);
67150 }
67151
67152 +#ifdef CONFIG_PAX_REFCOUNT
67153 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67154 +{
67155 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67156 +
67157 + return (long)atomic_read_unchecked(v);
67158 +}
67159 +#endif
67160 +
67161 static inline void atomic_long_set(atomic_long_t *l, long i)
67162 {
67163 atomic_t *v = (atomic_t *)l;
67164 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67165 atomic_set(v, i);
67166 }
67167
67168 +#ifdef CONFIG_PAX_REFCOUNT
67169 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67170 +{
67171 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67172 +
67173 + atomic_set_unchecked(v, i);
67174 +}
67175 +#endif
67176 +
67177 static inline void atomic_long_inc(atomic_long_t *l)
67178 {
67179 atomic_t *v = (atomic_t *)l;
67180 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67181 atomic_inc(v);
67182 }
67183
67184 +#ifdef CONFIG_PAX_REFCOUNT
67185 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67186 +{
67187 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67188 +
67189 + atomic_inc_unchecked(v);
67190 +}
67191 +#endif
67192 +
67193 static inline void atomic_long_dec(atomic_long_t *l)
67194 {
67195 atomic_t *v = (atomic_t *)l;
67196 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67197 atomic_dec(v);
67198 }
67199
67200 +#ifdef CONFIG_PAX_REFCOUNT
67201 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67202 +{
67203 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67204 +
67205 + atomic_dec_unchecked(v);
67206 +}
67207 +#endif
67208 +
67209 static inline void atomic_long_add(long i, atomic_long_t *l)
67210 {
67211 atomic_t *v = (atomic_t *)l;
67212 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67213 atomic_add(i, v);
67214 }
67215
67216 +#ifdef CONFIG_PAX_REFCOUNT
67217 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67218 +{
67219 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67220 +
67221 + atomic_add_unchecked(i, v);
67222 +}
67223 +#endif
67224 +
67225 static inline void atomic_long_sub(long i, atomic_long_t *l)
67226 {
67227 atomic_t *v = (atomic_t *)l;
67228 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67229 atomic_sub(i, v);
67230 }
67231
67232 +#ifdef CONFIG_PAX_REFCOUNT
67233 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67234 +{
67235 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67236 +
67237 + atomic_sub_unchecked(i, v);
67238 +}
67239 +#endif
67240 +
67241 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67242 {
67243 atomic_t *v = (atomic_t *)l;
67244 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67245 return (long)atomic_add_return(i, v);
67246 }
67247
67248 +#ifdef CONFIG_PAX_REFCOUNT
67249 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67250 +{
67251 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67252 +
67253 + return (long)atomic_add_return_unchecked(i, v);
67254 +}
67255 +
67256 +#endif
67257 +
67258 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67259 {
67260 atomic_t *v = (atomic_t *)l;
67261 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67262 return (long)atomic_inc_return(v);
67263 }
67264
67265 +#ifdef CONFIG_PAX_REFCOUNT
67266 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67267 +{
67268 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67269 +
67270 + return (long)atomic_inc_return_unchecked(v);
67271 +}
67272 +#endif
67273 +
67274 static inline long atomic_long_dec_return(atomic_long_t *l)
67275 {
67276 atomic_t *v = (atomic_t *)l;
67277 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67278
67279 #endif /* BITS_PER_LONG == 64 */
67280
67281 +#ifdef CONFIG_PAX_REFCOUNT
67282 +static inline void pax_refcount_needs_these_functions(void)
67283 +{
67284 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67285 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67286 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67287 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67288 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67289 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67290 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67291 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67292 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67293 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67294 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67295 +#ifdef CONFIG_X86
67296 + atomic_clear_mask_unchecked(0, NULL);
67297 + atomic_set_mask_unchecked(0, NULL);
67298 +#endif
67299 +
67300 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67301 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67302 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67303 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67304 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67305 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67306 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67307 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67308 +}
67309 +#else
67310 +#define atomic_read_unchecked(v) atomic_read(v)
67311 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67312 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67313 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67314 +#define atomic_inc_unchecked(v) atomic_inc(v)
67315 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67316 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67317 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67318 +#define atomic_dec_unchecked(v) atomic_dec(v)
67319 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67320 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67321 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67322 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67323 +
67324 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67325 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67326 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67327 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67328 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67329 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67330 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67331 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67332 +#endif
67333 +
67334 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67335 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67336 index 33bd2de..f31bff97 100644
67337 --- a/include/asm-generic/atomic.h
67338 +++ b/include/asm-generic/atomic.h
67339 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67340 * Atomically clears the bits set in @mask from @v
67341 */
67342 #ifndef atomic_clear_mask
67343 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67344 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67345 {
67346 unsigned long flags;
67347
67348 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67349 index b18ce4f..2ee2843 100644
67350 --- a/include/asm-generic/atomic64.h
67351 +++ b/include/asm-generic/atomic64.h
67352 @@ -16,6 +16,8 @@ typedef struct {
67353 long long counter;
67354 } atomic64_t;
67355
67356 +typedef atomic64_t atomic64_unchecked_t;
67357 +
67358 #define ATOMIC64_INIT(i) { (i) }
67359
67360 extern long long atomic64_read(const atomic64_t *v);
67361 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67362 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67363 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67364
67365 +#define atomic64_read_unchecked(v) atomic64_read(v)
67366 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67367 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67368 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67369 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67370 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67371 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67372 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67373 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67374 +
67375 #endif /* _ASM_GENERIC_ATOMIC64_H */
67376 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67377 index 1bfcfe5..e04c5c9 100644
67378 --- a/include/asm-generic/cache.h
67379 +++ b/include/asm-generic/cache.h
67380 @@ -6,7 +6,7 @@
67381 * cache lines need to provide their own cache.h.
67382 */
67383
67384 -#define L1_CACHE_SHIFT 5
67385 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67386 +#define L1_CACHE_SHIFT 5UL
67387 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67388
67389 #endif /* __ASM_GENERIC_CACHE_H */
67390 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67391 index 0d68a1e..b74a761 100644
67392 --- a/include/asm-generic/emergency-restart.h
67393 +++ b/include/asm-generic/emergency-restart.h
67394 @@ -1,7 +1,7 @@
67395 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67396 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67397
67398 -static inline void machine_emergency_restart(void)
67399 +static inline __noreturn void machine_emergency_restart(void)
67400 {
67401 machine_restart(NULL);
67402 }
67403 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67404 index 90f99c7..00ce236 100644
67405 --- a/include/asm-generic/kmap_types.h
67406 +++ b/include/asm-generic/kmap_types.h
67407 @@ -2,9 +2,9 @@
67408 #define _ASM_GENERIC_KMAP_TYPES_H
67409
67410 #ifdef __WITH_KM_FENCE
67411 -# define KM_TYPE_NR 41
67412 +# define KM_TYPE_NR 42
67413 #else
67414 -# define KM_TYPE_NR 20
67415 +# define KM_TYPE_NR 21
67416 #endif
67417
67418 #endif
67419 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67420 index 9ceb03b..62b0b8f 100644
67421 --- a/include/asm-generic/local.h
67422 +++ b/include/asm-generic/local.h
67423 @@ -23,24 +23,37 @@ typedef struct
67424 atomic_long_t a;
67425 } local_t;
67426
67427 +typedef struct {
67428 + atomic_long_unchecked_t a;
67429 +} local_unchecked_t;
67430 +
67431 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67432
67433 #define local_read(l) atomic_long_read(&(l)->a)
67434 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67435 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67436 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67437 #define local_inc(l) atomic_long_inc(&(l)->a)
67438 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67439 #define local_dec(l) atomic_long_dec(&(l)->a)
67440 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67441 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67442 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67443 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67444 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67445
67446 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67447 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67448 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67449 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67450 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67451 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67452 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67453 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67454 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67455
67456 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67457 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67458 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67459 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67460 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67461 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67462 index 725612b..9cc513a 100644
67463 --- a/include/asm-generic/pgtable-nopmd.h
67464 +++ b/include/asm-generic/pgtable-nopmd.h
67465 @@ -1,14 +1,19 @@
67466 #ifndef _PGTABLE_NOPMD_H
67467 #define _PGTABLE_NOPMD_H
67468
67469 -#ifndef __ASSEMBLY__
67470 -
67471 #include <asm-generic/pgtable-nopud.h>
67472
67473 -struct mm_struct;
67474 -
67475 #define __PAGETABLE_PMD_FOLDED
67476
67477 +#define PMD_SHIFT PUD_SHIFT
67478 +#define PTRS_PER_PMD 1
67479 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67480 +#define PMD_MASK (~(PMD_SIZE-1))
67481 +
67482 +#ifndef __ASSEMBLY__
67483 +
67484 +struct mm_struct;
67485 +
67486 /*
67487 * Having the pmd type consist of a pud gets the size right, and allows
67488 * us to conceptually access the pud entry that this pmd is folded into
67489 @@ -16,11 +21,6 @@ struct mm_struct;
67490 */
67491 typedef struct { pud_t pud; } pmd_t;
67492
67493 -#define PMD_SHIFT PUD_SHIFT
67494 -#define PTRS_PER_PMD 1
67495 -#define PMD_SIZE (1UL << PMD_SHIFT)
67496 -#define PMD_MASK (~(PMD_SIZE-1))
67497 -
67498 /*
67499 * The "pud_xxx()" functions here are trivial for a folded two-level
67500 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67501 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67502 index 810431d..0ec4804f 100644
67503 --- a/include/asm-generic/pgtable-nopud.h
67504 +++ b/include/asm-generic/pgtable-nopud.h
67505 @@ -1,10 +1,15 @@
67506 #ifndef _PGTABLE_NOPUD_H
67507 #define _PGTABLE_NOPUD_H
67508
67509 -#ifndef __ASSEMBLY__
67510 -
67511 #define __PAGETABLE_PUD_FOLDED
67512
67513 +#define PUD_SHIFT PGDIR_SHIFT
67514 +#define PTRS_PER_PUD 1
67515 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67516 +#define PUD_MASK (~(PUD_SIZE-1))
67517 +
67518 +#ifndef __ASSEMBLY__
67519 +
67520 /*
67521 * Having the pud type consist of a pgd gets the size right, and allows
67522 * us to conceptually access the pgd entry that this pud is folded into
67523 @@ -12,11 +17,6 @@
67524 */
67525 typedef struct { pgd_t pgd; } pud_t;
67526
67527 -#define PUD_SHIFT PGDIR_SHIFT
67528 -#define PTRS_PER_PUD 1
67529 -#define PUD_SIZE (1UL << PUD_SHIFT)
67530 -#define PUD_MASK (~(PUD_SIZE-1))
67531 -
67532 /*
67533 * The "pgd_xxx()" functions here are trivial for a folded two-level
67534 * setup: the pud is never bad, and a pud always exists (as it's folded
67535 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67536 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67537
67538 #define pgd_populate(mm, pgd, pud) do { } while (0)
67539 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67540 /*
67541 * (puds are folded into pgds so this doesn't get actually called,
67542 * but the define is needed for a generic inline function.)
67543 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67544 index a59ff51..2594a70 100644
67545 --- a/include/asm-generic/pgtable.h
67546 +++ b/include/asm-generic/pgtable.h
67547 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67548 }
67549 #endif /* CONFIG_NUMA_BALANCING */
67550
67551 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67552 +static inline unsigned long pax_open_kernel(void) { return 0; }
67553 +#endif
67554 +
67555 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67556 +static inline unsigned long pax_close_kernel(void) { return 0; }
67557 +#endif
67558 +
67559 #endif /* CONFIG_MMU */
67560
67561 #endif /* !__ASSEMBLY__ */
67562 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67563 index afa12c7..99d4da0 100644
67564 --- a/include/asm-generic/vmlinux.lds.h
67565 +++ b/include/asm-generic/vmlinux.lds.h
67566 @@ -245,6 +245,7 @@
67567 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67568 VMLINUX_SYMBOL(__start_rodata) = .; \
67569 *(.rodata) *(.rodata.*) \
67570 + *(.data..read_only) \
67571 *(__vermagic) /* Kernel version magic */ \
67572 . = ALIGN(8); \
67573 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67574 @@ -755,17 +756,18 @@
67575 * section in the linker script will go there too. @phdr should have
67576 * a leading colon.
67577 *
67578 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67579 + * Note that this macros defines per_cpu_load as an absolute symbol.
67580 * If there is no need to put the percpu section at a predetermined
67581 * address, use PERCPU_SECTION.
67582 */
67583 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67584 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67585 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67586 + per_cpu_load = .; \
67587 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67588 - LOAD_OFFSET) { \
67589 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67590 PERCPU_INPUT(cacheline) \
67591 } phdr \
67592 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67593 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67594
67595 /**
67596 * PERCPU_SECTION - define output section for percpu area, simple version
67597 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67598 index 418d270..bfd2794 100644
67599 --- a/include/crypto/algapi.h
67600 +++ b/include/crypto/algapi.h
67601 @@ -34,7 +34,7 @@ struct crypto_type {
67602 unsigned int maskclear;
67603 unsigned int maskset;
67604 unsigned int tfmsize;
67605 -};
67606 +} __do_const;
67607
67608 struct crypto_instance {
67609 struct crypto_alg alg;
67610 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67611 index f1ce786..086a7a5 100644
67612 --- a/include/drm/drmP.h
67613 +++ b/include/drm/drmP.h
67614 @@ -72,6 +72,7 @@
67615 #include <linux/workqueue.h>
67616 #include <linux/poll.h>
67617 #include <asm/pgalloc.h>
67618 +#include <asm/local.h>
67619 #include <drm/drm.h>
67620 #include <drm/drm_sarea.h>
67621
67622 @@ -296,10 +297,12 @@ do { \
67623 * \param cmd command.
67624 * \param arg argument.
67625 */
67626 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67627 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67628 + struct drm_file *file_priv);
67629 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67630 struct drm_file *file_priv);
67631
67632 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67633 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67634 unsigned long arg);
67635
67636 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67637 @@ -314,9 +317,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67638 struct drm_ioctl_desc {
67639 unsigned int cmd;
67640 int flags;
67641 - drm_ioctl_t *func;
67642 + drm_ioctl_t func;
67643 unsigned int cmd_drv;
67644 -};
67645 +} __do_const;
67646
67647 /**
67648 * Creates a driver or general drm_ioctl_desc array entry for the given
67649 @@ -1014,7 +1017,7 @@ struct drm_info_list {
67650 int (*show)(struct seq_file*, void*); /** show callback */
67651 u32 driver_features; /**< Required driver features for this entry */
67652 void *data;
67653 -};
67654 +} __do_const;
67655
67656 /**
67657 * debugfs node structure. This structure represents a debugfs file.
67658 @@ -1087,7 +1090,7 @@ struct drm_device {
67659
67660 /** \name Usage Counters */
67661 /*@{ */
67662 - int open_count; /**< Outstanding files open */
67663 + local_t open_count; /**< Outstanding files open */
67664 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67665 atomic_t vma_count; /**< Outstanding vma areas open */
67666 int buf_use; /**< Buffers in use -- cannot alloc */
67667 @@ -1098,7 +1101,7 @@ struct drm_device {
67668 /*@{ */
67669 unsigned long counters;
67670 enum drm_stat_type types[15];
67671 - atomic_t counts[15];
67672 + atomic_unchecked_t counts[15];
67673 /*@} */
67674
67675 struct list_head filelist;
67676 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67677 index f43d556..94d9343 100644
67678 --- a/include/drm/drm_crtc_helper.h
67679 +++ b/include/drm/drm_crtc_helper.h
67680 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67681 struct drm_connector *connector);
67682 /* disable encoder when not in use - more explicit than dpms off */
67683 void (*disable)(struct drm_encoder *encoder);
67684 -};
67685 +} __no_const;
67686
67687 /**
67688 * drm_connector_helper_funcs - helper operations for connectors
67689 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67690 index 72dcbe8..8db58d7 100644
67691 --- a/include/drm/ttm/ttm_memory.h
67692 +++ b/include/drm/ttm/ttm_memory.h
67693 @@ -48,7 +48,7 @@
67694
67695 struct ttm_mem_shrink {
67696 int (*do_shrink) (struct ttm_mem_shrink *);
67697 -};
67698 +} __no_const;
67699
67700 /**
67701 * struct ttm_mem_global - Global memory accounting structure.
67702 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67703 index 4b840e8..155d235 100644
67704 --- a/include/keys/asymmetric-subtype.h
67705 +++ b/include/keys/asymmetric-subtype.h
67706 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67707 /* Verify the signature on a key of this subtype (optional) */
67708 int (*verify_signature)(const struct key *key,
67709 const struct public_key_signature *sig);
67710 -};
67711 +} __do_const;
67712
67713 /**
67714 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67715 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67716 index c1da539..1dcec55 100644
67717 --- a/include/linux/atmdev.h
67718 +++ b/include/linux/atmdev.h
67719 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67720 #endif
67721
67722 struct k_atm_aal_stats {
67723 -#define __HANDLE_ITEM(i) atomic_t i
67724 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67725 __AAL_STAT_ITEMS
67726 #undef __HANDLE_ITEM
67727 };
67728 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67729 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67730 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67731 struct module *owner;
67732 -};
67733 +} __do_const ;
67734
67735 struct atmphy_ops {
67736 int (*start)(struct atm_dev *dev);
67737 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67738 index c3a0914..ec5d48a 100644
67739 --- a/include/linux/binfmts.h
67740 +++ b/include/linux/binfmts.h
67741 @@ -73,8 +73,9 @@ struct linux_binfmt {
67742 int (*load_binary)(struct linux_binprm *);
67743 int (*load_shlib)(struct file *);
67744 int (*core_dump)(struct coredump_params *cprm);
67745 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67746 unsigned long min_coredump; /* minimal dump size */
67747 -};
67748 +} __do_const;
67749
67750 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67751
67752 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67753 index 33f358f..7f2c27f 100644
67754 --- a/include/linux/blkdev.h
67755 +++ b/include/linux/blkdev.h
67756 @@ -1499,7 +1499,7 @@ struct block_device_operations {
67757 /* this callback is with swap_lock and sometimes page table lock held */
67758 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67759 struct module *owner;
67760 -};
67761 +} __do_const;
67762
67763 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67764 unsigned long);
67765 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67766 index 7c2e030..b72475d 100644
67767 --- a/include/linux/blktrace_api.h
67768 +++ b/include/linux/blktrace_api.h
67769 @@ -23,7 +23,7 @@ struct blk_trace {
67770 struct dentry *dir;
67771 struct dentry *dropped_file;
67772 struct dentry *msg_file;
67773 - atomic_t dropped;
67774 + atomic_unchecked_t dropped;
67775 };
67776
67777 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67778 diff --git a/include/linux/cache.h b/include/linux/cache.h
67779 index 4c57065..4307975 100644
67780 --- a/include/linux/cache.h
67781 +++ b/include/linux/cache.h
67782 @@ -16,6 +16,10 @@
67783 #define __read_mostly
67784 #endif
67785
67786 +#ifndef __read_only
67787 +#define __read_only __read_mostly
67788 +#endif
67789 +
67790 #ifndef ____cacheline_aligned
67791 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67792 #endif
67793 diff --git a/include/linux/capability.h b/include/linux/capability.h
67794 index d9a4f7f4..19f77d6 100644
67795 --- a/include/linux/capability.h
67796 +++ b/include/linux/capability.h
67797 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
67798 extern bool nsown_capable(int cap);
67799 extern bool inode_capable(const struct inode *inode, int cap);
67800 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
67801 +extern bool capable_nolog(int cap);
67802 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67803 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67804
67805 /* audit system wants to get cap info from files as well */
67806 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67807
67808 +extern int is_privileged_binary(const struct dentry *dentry);
67809 +
67810 #endif /* !_LINUX_CAPABILITY_H */
67811 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67812 index 8609d57..86e4d79 100644
67813 --- a/include/linux/cdrom.h
67814 +++ b/include/linux/cdrom.h
67815 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67816
67817 /* driver specifications */
67818 const int capability; /* capability flags */
67819 - int n_minors; /* number of active minor devices */
67820 /* handle uniform packets for scsi type devices (scsi,atapi) */
67821 int (*generic_packet) (struct cdrom_device_info *,
67822 struct packet_command *);
67823 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67824 index 42e55de..1cd0e66 100644
67825 --- a/include/linux/cleancache.h
67826 +++ b/include/linux/cleancache.h
67827 @@ -31,7 +31,7 @@ struct cleancache_ops {
67828 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67829 void (*invalidate_inode)(int, struct cleancache_filekey);
67830 void (*invalidate_fs)(int);
67831 -};
67832 +} __no_const;
67833
67834 extern struct cleancache_ops
67835 cleancache_register_ops(struct cleancache_ops *ops);
67836 diff --git a/include/linux/compat.h b/include/linux/compat.h
67837 index 377cd8c..2479845 100644
67838 --- a/include/linux/compat.h
67839 +++ b/include/linux/compat.h
67840 @@ -332,14 +332,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67841 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67842 int version, void __user *uptr);
67843 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67844 - void __user *uptr);
67845 + void __user *uptr) __intentional_overflow(0);
67846 #else
67847 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67848 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67849 compat_ssize_t msgsz, int msgflg);
67850 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67851 compat_ssize_t msgsz, long msgtyp, int msgflg);
67852 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67853 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67854 #endif
67855 long compat_sys_msgctl(int first, int second, void __user *uptr);
67856 long compat_sys_shmctl(int first, int second, void __user *uptr);
67857 @@ -442,7 +442,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67858 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67859 compat_ulong_t addr, compat_ulong_t data);
67860 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67861 - compat_long_t addr, compat_long_t data);
67862 + compat_ulong_t addr, compat_ulong_t data);
67863
67864 /*
67865 * epoll (fs/eventpoll.c) compat bits follow ...
67866 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67867 index 68b162d..660f5f0 100644
67868 --- a/include/linux/compiler-gcc4.h
67869 +++ b/include/linux/compiler-gcc4.h
67870 @@ -39,9 +39,29 @@
67871 # define __compiletime_warning(message) __attribute__((warning(message)))
67872 # define __compiletime_error(message) __attribute__((error(message)))
67873 #endif /* __CHECKER__ */
67874 +
67875 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67876 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67877 +#define __bos0(ptr) __bos((ptr), 0)
67878 +#define __bos1(ptr) __bos((ptr), 1)
67879 #endif /* GCC_VERSION >= 40300 */
67880
67881 #if GCC_VERSION >= 40500
67882 +
67883 +#ifdef CONSTIFY_PLUGIN
67884 +#define __no_const __attribute__((no_const))
67885 +#define __do_const __attribute__((do_const))
67886 +#endif
67887 +
67888 +#ifdef SIZE_OVERFLOW_PLUGIN
67889 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67890 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67891 +#endif
67892 +
67893 +#ifdef LATENT_ENTROPY_PLUGIN
67894 +#define __latent_entropy __attribute__((latent_entropy))
67895 +#endif
67896 +
67897 /*
67898 * Mark a position in code as unreachable. This can be used to
67899 * suppress control flow warnings after asm blocks that transfer
67900 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67901 index 10b8f23..5e0b083 100644
67902 --- a/include/linux/compiler.h
67903 +++ b/include/linux/compiler.h
67904 @@ -5,11 +5,14 @@
67905
67906 #ifdef __CHECKER__
67907 # define __user __attribute__((noderef, address_space(1)))
67908 +# define __force_user __force __user
67909 # define __kernel __attribute__((address_space(0)))
67910 +# define __force_kernel __force __kernel
67911 # define __safe __attribute__((safe))
67912 # define __force __attribute__((force))
67913 # define __nocast __attribute__((nocast))
67914 # define __iomem __attribute__((noderef, address_space(2)))
67915 +# define __force_iomem __force __iomem
67916 # define __must_hold(x) __attribute__((context(x,1,1)))
67917 # define __acquires(x) __attribute__((context(x,0,1)))
67918 # define __releases(x) __attribute__((context(x,1,0)))
67919 @@ -17,20 +20,37 @@
67920 # define __release(x) __context__(x,-1)
67921 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67922 # define __percpu __attribute__((noderef, address_space(3)))
67923 +# define __force_percpu __force __percpu
67924 #ifdef CONFIG_SPARSE_RCU_POINTER
67925 # define __rcu __attribute__((noderef, address_space(4)))
67926 +# define __force_rcu __force __rcu
67927 #else
67928 # define __rcu
67929 +# define __force_rcu
67930 #endif
67931 extern void __chk_user_ptr(const volatile void __user *);
67932 extern void __chk_io_ptr(const volatile void __iomem *);
67933 #else
67934 -# define __user
67935 -# define __kernel
67936 +# ifdef CHECKER_PLUGIN
67937 +//# define __user
67938 +//# define __force_user
67939 +//# define __kernel
67940 +//# define __force_kernel
67941 +# else
67942 +# ifdef STRUCTLEAK_PLUGIN
67943 +# define __user __attribute__((user))
67944 +# else
67945 +# define __user
67946 +# endif
67947 +# define __force_user
67948 +# define __kernel
67949 +# define __force_kernel
67950 +# endif
67951 # define __safe
67952 # define __force
67953 # define __nocast
67954 # define __iomem
67955 +# define __force_iomem
67956 # define __chk_user_ptr(x) (void)0
67957 # define __chk_io_ptr(x) (void)0
67958 # define __builtin_warning(x, y...) (1)
67959 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67960 # define __release(x) (void)0
67961 # define __cond_lock(x,c) (c)
67962 # define __percpu
67963 +# define __force_percpu
67964 # define __rcu
67965 +# define __force_rcu
67966 #endif
67967
67968 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67969 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67970 # define __attribute_const__ /* unimplemented */
67971 #endif
67972
67973 +#ifndef __no_const
67974 +# define __no_const
67975 +#endif
67976 +
67977 +#ifndef __do_const
67978 +# define __do_const
67979 +#endif
67980 +
67981 +#ifndef __size_overflow
67982 +# define __size_overflow(...)
67983 +#endif
67984 +
67985 +#ifndef __intentional_overflow
67986 +# define __intentional_overflow(...)
67987 +#endif
67988 +
67989 +#ifndef __latent_entropy
67990 +# define __latent_entropy
67991 +#endif
67992 +
67993 /*
67994 * Tell gcc if a function is cold. The compiler will assume any path
67995 * directly leading to the call is unlikely.
67996 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67997 #define __cold
67998 #endif
67999
68000 +#ifndef __alloc_size
68001 +#define __alloc_size(...)
68002 +#endif
68003 +
68004 +#ifndef __bos
68005 +#define __bos(ptr, arg)
68006 +#endif
68007 +
68008 +#ifndef __bos0
68009 +#define __bos0(ptr)
68010 +#endif
68011 +
68012 +#ifndef __bos1
68013 +#define __bos1(ptr)
68014 +#endif
68015 +
68016 /* Simple shorthand for a section definition */
68017 #ifndef __section
68018 # define __section(S) __attribute__ ((__section__(#S)))
68019 @@ -349,6 +407,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68020 * use is to mediate communication between process-level code and irq/NMI
68021 * handlers, all running on the same CPU.
68022 */
68023 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68024 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68025 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68026
68027 #endif /* __LINUX_COMPILER_H */
68028 diff --git a/include/linux/completion.h b/include/linux/completion.h
68029 index 33f0280..35c6568 100644
68030 --- a/include/linux/completion.h
68031 +++ b/include/linux/completion.h
68032 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
68033 extern void wait_for_completion(struct completion *);
68034 extern void wait_for_completion_io(struct completion *);
68035 extern int wait_for_completion_interruptible(struct completion *x);
68036 -extern int wait_for_completion_killable(struct completion *x);
68037 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68038 extern unsigned long wait_for_completion_timeout(struct completion *x,
68039 unsigned long timeout);
68040 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
68041 unsigned long timeout);
68042 extern long wait_for_completion_interruptible_timeout(
68043 - struct completion *x, unsigned long timeout);
68044 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68045 extern long wait_for_completion_killable_timeout(
68046 - struct completion *x, unsigned long timeout);
68047 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68048 extern bool try_wait_for_completion(struct completion *x);
68049 extern bool completion_done(struct completion *x);
68050
68051 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68052 index 34025df..d94bbbc 100644
68053 --- a/include/linux/configfs.h
68054 +++ b/include/linux/configfs.h
68055 @@ -125,7 +125,7 @@ struct configfs_attribute {
68056 const char *ca_name;
68057 struct module *ca_owner;
68058 umode_t ca_mode;
68059 -};
68060 +} __do_const;
68061
68062 /*
68063 * Users often need to create attribute structures for their configurable
68064 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68065 index 714e792..e6130d9 100644
68066 --- a/include/linux/cpu.h
68067 +++ b/include/linux/cpu.h
68068 @@ -115,7 +115,7 @@ enum {
68069 /* Need to know about CPUs going up/down? */
68070 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68071 #define cpu_notifier(fn, pri) { \
68072 - static struct notifier_block fn##_nb __cpuinitdata = \
68073 + static struct notifier_block fn##_nb = \
68074 { .notifier_call = fn, .priority = pri }; \
68075 register_cpu_notifier(&fn##_nb); \
68076 }
68077 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68078 index a22944c..4e695fe 100644
68079 --- a/include/linux/cpufreq.h
68080 +++ b/include/linux/cpufreq.h
68081 @@ -252,7 +252,7 @@ struct cpufreq_driver {
68082 int (*suspend) (struct cpufreq_policy *policy);
68083 int (*resume) (struct cpufreq_policy *policy);
68084 struct freq_attr **attr;
68085 -};
68086 +} __do_const;
68087
68088 /* flags */
68089
68090 @@ -311,6 +311,7 @@ struct global_attr {
68091 ssize_t (*store)(struct kobject *a, struct attribute *b,
68092 const char *c, size_t count);
68093 };
68094 +typedef struct global_attr __no_const global_attr_no_const;
68095
68096 #define define_one_global_ro(_name) \
68097 static struct global_attr _name = \
68098 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68099 index 480c14d..552896f 100644
68100 --- a/include/linux/cpuidle.h
68101 +++ b/include/linux/cpuidle.h
68102 @@ -52,7 +52,8 @@ struct cpuidle_state {
68103 int index);
68104
68105 int (*enter_dead) (struct cpuidle_device *dev, int index);
68106 -};
68107 +} __do_const;
68108 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68109
68110 /* Idle State Flags */
68111 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68112 @@ -194,7 +195,7 @@ struct cpuidle_governor {
68113 void (*reflect) (struct cpuidle_device *dev, int index);
68114
68115 struct module *owner;
68116 -};
68117 +} __do_const;
68118
68119 #ifdef CONFIG_CPU_IDLE
68120
68121 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68122 index 0325602..5e9feff 100644
68123 --- a/include/linux/cpumask.h
68124 +++ b/include/linux/cpumask.h
68125 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68126 }
68127
68128 /* Valid inputs for n are -1 and 0. */
68129 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68130 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68131 {
68132 return n+1;
68133 }
68134
68135 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68136 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68137 {
68138 return n+1;
68139 }
68140
68141 -static inline unsigned int cpumask_next_and(int n,
68142 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68143 const struct cpumask *srcp,
68144 const struct cpumask *andp)
68145 {
68146 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68147 *
68148 * Returns >= nr_cpu_ids if no further cpus set.
68149 */
68150 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68151 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68152 {
68153 /* -1 is a legal arg here. */
68154 if (n != -1)
68155 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68156 *
68157 * Returns >= nr_cpu_ids if no further cpus unset.
68158 */
68159 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68160 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68161 {
68162 /* -1 is a legal arg here. */
68163 if (n != -1)
68164 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68165 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68166 }
68167
68168 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68169 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68170 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68171
68172 /**
68173 diff --git a/include/linux/cred.h b/include/linux/cred.h
68174 index 04421e8..6bce4ef 100644
68175 --- a/include/linux/cred.h
68176 +++ b/include/linux/cred.h
68177 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68178 static inline void validate_process_creds(void)
68179 {
68180 }
68181 +static inline void validate_task_creds(struct task_struct *task)
68182 +{
68183 +}
68184 #endif
68185
68186 /**
68187 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68188 index b92eadf..b4ecdc1 100644
68189 --- a/include/linux/crypto.h
68190 +++ b/include/linux/crypto.h
68191 @@ -373,7 +373,7 @@ struct cipher_tfm {
68192 const u8 *key, unsigned int keylen);
68193 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68194 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68195 -};
68196 +} __no_const;
68197
68198 struct hash_tfm {
68199 int (*init)(struct hash_desc *desc);
68200 @@ -394,13 +394,13 @@ struct compress_tfm {
68201 int (*cot_decompress)(struct crypto_tfm *tfm,
68202 const u8 *src, unsigned int slen,
68203 u8 *dst, unsigned int *dlen);
68204 -};
68205 +} __no_const;
68206
68207 struct rng_tfm {
68208 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68209 unsigned int dlen);
68210 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68211 -};
68212 +} __no_const;
68213
68214 #define crt_ablkcipher crt_u.ablkcipher
68215 #define crt_aead crt_u.aead
68216 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68217 index 8acfe31..6ffccd63 100644
68218 --- a/include/linux/ctype.h
68219 +++ b/include/linux/ctype.h
68220 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68221 * Fast implementation of tolower() for internal usage. Do not use in your
68222 * code.
68223 */
68224 -static inline char _tolower(const char c)
68225 +static inline unsigned char _tolower(const unsigned char c)
68226 {
68227 return c | 0x20;
68228 }
68229 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68230 index 7925bf0..d5143d2 100644
68231 --- a/include/linux/decompress/mm.h
68232 +++ b/include/linux/decompress/mm.h
68233 @@ -77,7 +77,7 @@ static void free(void *where)
68234 * warnings when not needed (indeed large_malloc / large_free are not
68235 * needed by inflate */
68236
68237 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68238 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68239 #define free(a) kfree(a)
68240
68241 #define large_malloc(a) vmalloc(a)
68242 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68243 index fe8c447..bdc1f33 100644
68244 --- a/include/linux/devfreq.h
68245 +++ b/include/linux/devfreq.h
68246 @@ -114,7 +114,7 @@ struct devfreq_governor {
68247 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68248 int (*event_handler)(struct devfreq *devfreq,
68249 unsigned int event, void *data);
68250 -};
68251 +} __do_const;
68252
68253 /**
68254 * struct devfreq - Device devfreq structure
68255 diff --git a/include/linux/device.h b/include/linux/device.h
68256 index 9d6464e..8a5cc92 100644
68257 --- a/include/linux/device.h
68258 +++ b/include/linux/device.h
68259 @@ -295,7 +295,7 @@ struct subsys_interface {
68260 struct list_head node;
68261 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68262 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68263 -};
68264 +} __do_const;
68265
68266 int subsys_interface_register(struct subsys_interface *sif);
68267 void subsys_interface_unregister(struct subsys_interface *sif);
68268 @@ -475,7 +475,7 @@ struct device_type {
68269 void (*release)(struct device *dev);
68270
68271 const struct dev_pm_ops *pm;
68272 -};
68273 +} __do_const;
68274
68275 /* interface for exporting device attributes */
68276 struct device_attribute {
68277 @@ -485,11 +485,12 @@ struct device_attribute {
68278 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68279 const char *buf, size_t count);
68280 };
68281 +typedef struct device_attribute __no_const device_attribute_no_const;
68282
68283 struct dev_ext_attribute {
68284 struct device_attribute attr;
68285 void *var;
68286 -};
68287 +} __do_const;
68288
68289 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68290 char *buf);
68291 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68292 index 94af418..b1ca7a2 100644
68293 --- a/include/linux/dma-mapping.h
68294 +++ b/include/linux/dma-mapping.h
68295 @@ -54,7 +54,7 @@ struct dma_map_ops {
68296 u64 (*get_required_mask)(struct device *dev);
68297 #endif
68298 int is_phys;
68299 -};
68300 +} __do_const;
68301
68302 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68303
68304 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68305 index 91ac8da..a841318 100644
68306 --- a/include/linux/dmaengine.h
68307 +++ b/include/linux/dmaengine.h
68308 @@ -1034,9 +1034,9 @@ struct dma_pinned_list {
68309 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68310 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68311
68312 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68313 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68314 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68315 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68316 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68317 struct dma_pinned_list *pinned_list, struct page *page,
68318 unsigned int offset, size_t len);
68319
68320 diff --git a/include/linux/efi.h b/include/linux/efi.h
68321 index 3d7df3d..301f024 100644
68322 --- a/include/linux/efi.h
68323 +++ b/include/linux/efi.h
68324 @@ -740,6 +740,7 @@ struct efivar_operations {
68325 efi_set_variable_t *set_variable;
68326 efi_query_variable_store_t *query_variable_store;
68327 };
68328 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68329
68330 struct efivars {
68331 /*
68332 diff --git a/include/linux/elf.h b/include/linux/elf.h
68333 index 40a3c0e..4c45a38 100644
68334 --- a/include/linux/elf.h
68335 +++ b/include/linux/elf.h
68336 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
68337 #define elf_note elf32_note
68338 #define elf_addr_t Elf32_Off
68339 #define Elf_Half Elf32_Half
68340 +#define elf_dyn Elf32_Dyn
68341
68342 #else
68343
68344 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
68345 #define elf_note elf64_note
68346 #define elf_addr_t Elf64_Off
68347 #define Elf_Half Elf64_Half
68348 +#define elf_dyn Elf64_Dyn
68349
68350 #endif
68351
68352 diff --git a/include/linux/err.h b/include/linux/err.h
68353 index f2edce2..cc2082c 100644
68354 --- a/include/linux/err.h
68355 +++ b/include/linux/err.h
68356 @@ -19,12 +19,12 @@
68357
68358 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68359
68360 -static inline void * __must_check ERR_PTR(long error)
68361 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68362 {
68363 return (void *) error;
68364 }
68365
68366 -static inline long __must_check PTR_ERR(const void *ptr)
68367 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68368 {
68369 return (long) ptr;
68370 }
68371 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68372 index fcb51c8..bdafcf6 100644
68373 --- a/include/linux/extcon.h
68374 +++ b/include/linux/extcon.h
68375 @@ -134,7 +134,7 @@ struct extcon_dev {
68376 /* /sys/class/extcon/.../mutually_exclusive/... */
68377 struct attribute_group attr_g_muex;
68378 struct attribute **attrs_muex;
68379 - struct device_attribute *d_attrs_muex;
68380 + device_attribute_no_const *d_attrs_muex;
68381 };
68382
68383 /**
68384 diff --git a/include/linux/fb.h b/include/linux/fb.h
68385 index 58b9860..58e5516 100644
68386 --- a/include/linux/fb.h
68387 +++ b/include/linux/fb.h
68388 @@ -304,7 +304,7 @@ struct fb_ops {
68389 /* called at KDB enter and leave time to prepare the console */
68390 int (*fb_debug_enter)(struct fb_info *info);
68391 int (*fb_debug_leave)(struct fb_info *info);
68392 -};
68393 +} __do_const;
68394
68395 #ifdef CONFIG_FB_TILEBLITTING
68396 #define FB_TILE_CURSOR_NONE 0
68397 diff --git a/include/linux/filter.h b/include/linux/filter.h
68398 index c45eabc..baa0be5 100644
68399 --- a/include/linux/filter.h
68400 +++ b/include/linux/filter.h
68401 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68402
68403 struct sk_buff;
68404 struct sock;
68405 +struct bpf_jit_work;
68406
68407 struct sk_filter
68408 {
68409 @@ -27,6 +28,9 @@ struct sk_filter
68410 unsigned int len; /* Number of filter blocks */
68411 unsigned int (*bpf_func)(const struct sk_buff *skb,
68412 const struct sock_filter *filter);
68413 +#ifdef CONFIG_BPF_JIT
68414 + struct bpf_jit_work *work;
68415 +#endif
68416 struct rcu_head rcu;
68417 struct sock_filter insns[0];
68418 };
68419 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68420 index 3044254..9767f41 100644
68421 --- a/include/linux/frontswap.h
68422 +++ b/include/linux/frontswap.h
68423 @@ -11,7 +11,7 @@ struct frontswap_ops {
68424 int (*load)(unsigned, pgoff_t, struct page *);
68425 void (*invalidate_page)(unsigned, pgoff_t);
68426 void (*invalidate_area)(unsigned);
68427 -};
68428 +} __no_const;
68429
68430 extern bool frontswap_enabled;
68431 extern struct frontswap_ops
68432 diff --git a/include/linux/fs.h b/include/linux/fs.h
68433 index 2c28271..8d3d74c 100644
68434 --- a/include/linux/fs.h
68435 +++ b/include/linux/fs.h
68436 @@ -1541,7 +1541,8 @@ struct file_operations {
68437 long (*fallocate)(struct file *file, int mode, loff_t offset,
68438 loff_t len);
68439 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68440 -};
68441 +} __do_const;
68442 +typedef struct file_operations __no_const file_operations_no_const;
68443
68444 struct inode_operations {
68445 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68446 @@ -2672,4 +2673,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68447 inode->i_flags |= S_NOSEC;
68448 }
68449
68450 +static inline bool is_sidechannel_device(const struct inode *inode)
68451 +{
68452 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68453 + umode_t mode = inode->i_mode;
68454 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68455 +#else
68456 + return false;
68457 +#endif
68458 +}
68459 +
68460 #endif /* _LINUX_FS_H */
68461 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68462 index 2b93a9a..855d94a 100644
68463 --- a/include/linux/fs_struct.h
68464 +++ b/include/linux/fs_struct.h
68465 @@ -6,7 +6,7 @@
68466 #include <linux/seqlock.h>
68467
68468 struct fs_struct {
68469 - int users;
68470 + atomic_t users;
68471 spinlock_t lock;
68472 seqcount_t seq;
68473 int umask;
68474 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68475 index 5dfa0aa..6acf322 100644
68476 --- a/include/linux/fscache-cache.h
68477 +++ b/include/linux/fscache-cache.h
68478 @@ -112,7 +112,7 @@ struct fscache_operation {
68479 fscache_operation_release_t release;
68480 };
68481
68482 -extern atomic_t fscache_op_debug_id;
68483 +extern atomic_unchecked_t fscache_op_debug_id;
68484 extern void fscache_op_work_func(struct work_struct *work);
68485
68486 extern void fscache_enqueue_operation(struct fscache_operation *);
68487 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68488 INIT_WORK(&op->work, fscache_op_work_func);
68489 atomic_set(&op->usage, 1);
68490 op->state = FSCACHE_OP_ST_INITIALISED;
68491 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68492 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68493 op->processor = processor;
68494 op->release = release;
68495 INIT_LIST_HEAD(&op->pend_link);
68496 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68497 index 7a08623..4c07b0f 100644
68498 --- a/include/linux/fscache.h
68499 +++ b/include/linux/fscache.h
68500 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68501 * - this is mandatory for any object that may have data
68502 */
68503 void (*now_uncached)(void *cookie_netfs_data);
68504 -};
68505 +} __do_const;
68506
68507 /*
68508 * fscache cached network filesystem type
68509 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68510 index a78680a..87bd73e 100644
68511 --- a/include/linux/fsnotify.h
68512 +++ b/include/linux/fsnotify.h
68513 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68514 struct inode *inode = path->dentry->d_inode;
68515 __u32 mask = FS_ACCESS;
68516
68517 + if (is_sidechannel_device(inode))
68518 + return;
68519 +
68520 if (S_ISDIR(inode->i_mode))
68521 mask |= FS_ISDIR;
68522
68523 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68524 struct inode *inode = path->dentry->d_inode;
68525 __u32 mask = FS_MODIFY;
68526
68527 + if (is_sidechannel_device(inode))
68528 + return;
68529 +
68530 if (S_ISDIR(inode->i_mode))
68531 mask |= FS_ISDIR;
68532
68533 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68534 */
68535 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68536 {
68537 - return kstrdup(name, GFP_KERNEL);
68538 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68539 }
68540
68541 /*
68542 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68543 index 13a54d0..c6ce2a7 100644
68544 --- a/include/linux/ftrace_event.h
68545 +++ b/include/linux/ftrace_event.h
68546 @@ -274,7 +274,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68547 extern int trace_add_event_call(struct ftrace_event_call *call);
68548 extern void trace_remove_event_call(struct ftrace_event_call *call);
68549
68550 -#define is_signed_type(type) (((type)(-1)) < (type)0)
68551 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68552
68553 int trace_set_clr_event(const char *system, const char *event, int set);
68554
68555 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68556 index 9f3c275..911b591 100644
68557 --- a/include/linux/genhd.h
68558 +++ b/include/linux/genhd.h
68559 @@ -194,7 +194,7 @@ struct gendisk {
68560 struct kobject *slave_dir;
68561
68562 struct timer_rand_state *random;
68563 - atomic_t sync_io; /* RAID */
68564 + atomic_unchecked_t sync_io; /* RAID */
68565 struct disk_events *ev;
68566 #ifdef CONFIG_BLK_DEV_INTEGRITY
68567 struct blk_integrity *integrity;
68568 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68569 index 023bc34..b02b46a 100644
68570 --- a/include/linux/genl_magic_func.h
68571 +++ b/include/linux/genl_magic_func.h
68572 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68573 },
68574
68575 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68576 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68577 +static struct genl_ops ZZZ_genl_ops[] = {
68578 #include GENL_MAGIC_INCLUDE_FILE
68579 };
68580
68581 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68582 index 0f615eb..5c3832f 100644
68583 --- a/include/linux/gfp.h
68584 +++ b/include/linux/gfp.h
68585 @@ -35,6 +35,13 @@ struct vm_area_struct;
68586 #define ___GFP_NO_KSWAPD 0x400000u
68587 #define ___GFP_OTHER_NODE 0x800000u
68588 #define ___GFP_WRITE 0x1000000u
68589 +
68590 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68591 +#define ___GFP_USERCOPY 0x2000000u
68592 +#else
68593 +#define ___GFP_USERCOPY 0
68594 +#endif
68595 +
68596 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68597
68598 /*
68599 @@ -92,6 +99,7 @@ struct vm_area_struct;
68600 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68601 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68602 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68603 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68604
68605 /*
68606 * This may seem redundant, but it's a way of annotating false positives vs.
68607 @@ -99,7 +107,7 @@ struct vm_area_struct;
68608 */
68609 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68610
68611 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68612 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68613 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68614
68615 /* This equals 0, but use constants in case they ever change */
68616 @@ -153,6 +161,8 @@ struct vm_area_struct;
68617 /* 4GB DMA on some platforms */
68618 #define GFP_DMA32 __GFP_DMA32
68619
68620 +#define GFP_USERCOPY __GFP_USERCOPY
68621 +
68622 /* Convert GFP flags to their corresponding migrate type */
68623 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68624 {
68625 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68626 new file mode 100644
68627 index 0000000..ebe6d72
68628 --- /dev/null
68629 +++ b/include/linux/gracl.h
68630 @@ -0,0 +1,319 @@
68631 +#ifndef GR_ACL_H
68632 +#define GR_ACL_H
68633 +
68634 +#include <linux/grdefs.h>
68635 +#include <linux/resource.h>
68636 +#include <linux/capability.h>
68637 +#include <linux/dcache.h>
68638 +#include <asm/resource.h>
68639 +
68640 +/* Major status information */
68641 +
68642 +#define GR_VERSION "grsecurity 2.9.1"
68643 +#define GRSECURITY_VERSION 0x2901
68644 +
68645 +enum {
68646 + GR_SHUTDOWN = 0,
68647 + GR_ENABLE = 1,
68648 + GR_SPROLE = 2,
68649 + GR_RELOAD = 3,
68650 + GR_SEGVMOD = 4,
68651 + GR_STATUS = 5,
68652 + GR_UNSPROLE = 6,
68653 + GR_PASSSET = 7,
68654 + GR_SPROLEPAM = 8,
68655 +};
68656 +
68657 +/* Password setup definitions
68658 + * kernel/grhash.c */
68659 +enum {
68660 + GR_PW_LEN = 128,
68661 + GR_SALT_LEN = 16,
68662 + GR_SHA_LEN = 32,
68663 +};
68664 +
68665 +enum {
68666 + GR_SPROLE_LEN = 64,
68667 +};
68668 +
68669 +enum {
68670 + GR_NO_GLOB = 0,
68671 + GR_REG_GLOB,
68672 + GR_CREATE_GLOB
68673 +};
68674 +
68675 +#define GR_NLIMITS 32
68676 +
68677 +/* Begin Data Structures */
68678 +
68679 +struct sprole_pw {
68680 + unsigned char *rolename;
68681 + unsigned char salt[GR_SALT_LEN];
68682 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68683 +};
68684 +
68685 +struct name_entry {
68686 + __u32 key;
68687 + ino_t inode;
68688 + dev_t device;
68689 + char *name;
68690 + __u16 len;
68691 + __u8 deleted;
68692 + struct name_entry *prev;
68693 + struct name_entry *next;
68694 +};
68695 +
68696 +struct inodev_entry {
68697 + struct name_entry *nentry;
68698 + struct inodev_entry *prev;
68699 + struct inodev_entry *next;
68700 +};
68701 +
68702 +struct acl_role_db {
68703 + struct acl_role_label **r_hash;
68704 + __u32 r_size;
68705 +};
68706 +
68707 +struct inodev_db {
68708 + struct inodev_entry **i_hash;
68709 + __u32 i_size;
68710 +};
68711 +
68712 +struct name_db {
68713 + struct name_entry **n_hash;
68714 + __u32 n_size;
68715 +};
68716 +
68717 +struct crash_uid {
68718 + uid_t uid;
68719 + unsigned long expires;
68720 +};
68721 +
68722 +struct gr_hash_struct {
68723 + void **table;
68724 + void **nametable;
68725 + void *first;
68726 + __u32 table_size;
68727 + __u32 used_size;
68728 + int type;
68729 +};
68730 +
68731 +/* Userspace Grsecurity ACL data structures */
68732 +
68733 +struct acl_subject_label {
68734 + char *filename;
68735 + ino_t inode;
68736 + dev_t device;
68737 + __u32 mode;
68738 + kernel_cap_t cap_mask;
68739 + kernel_cap_t cap_lower;
68740 + kernel_cap_t cap_invert_audit;
68741 +
68742 + struct rlimit res[GR_NLIMITS];
68743 + __u32 resmask;
68744 +
68745 + __u8 user_trans_type;
68746 + __u8 group_trans_type;
68747 + uid_t *user_transitions;
68748 + gid_t *group_transitions;
68749 + __u16 user_trans_num;
68750 + __u16 group_trans_num;
68751 +
68752 + __u32 sock_families[2];
68753 + __u32 ip_proto[8];
68754 + __u32 ip_type;
68755 + struct acl_ip_label **ips;
68756 + __u32 ip_num;
68757 + __u32 inaddr_any_override;
68758 +
68759 + __u32 crashes;
68760 + unsigned long expires;
68761 +
68762 + struct acl_subject_label *parent_subject;
68763 + struct gr_hash_struct *hash;
68764 + struct acl_subject_label *prev;
68765 + struct acl_subject_label *next;
68766 +
68767 + struct acl_object_label **obj_hash;
68768 + __u32 obj_hash_size;
68769 + __u16 pax_flags;
68770 +};
68771 +
68772 +struct role_allowed_ip {
68773 + __u32 addr;
68774 + __u32 netmask;
68775 +
68776 + struct role_allowed_ip *prev;
68777 + struct role_allowed_ip *next;
68778 +};
68779 +
68780 +struct role_transition {
68781 + char *rolename;
68782 +
68783 + struct role_transition *prev;
68784 + struct role_transition *next;
68785 +};
68786 +
68787 +struct acl_role_label {
68788 + char *rolename;
68789 + uid_t uidgid;
68790 + __u16 roletype;
68791 +
68792 + __u16 auth_attempts;
68793 + unsigned long expires;
68794 +
68795 + struct acl_subject_label *root_label;
68796 + struct gr_hash_struct *hash;
68797 +
68798 + struct acl_role_label *prev;
68799 + struct acl_role_label *next;
68800 +
68801 + struct role_transition *transitions;
68802 + struct role_allowed_ip *allowed_ips;
68803 + uid_t *domain_children;
68804 + __u16 domain_child_num;
68805 +
68806 + umode_t umask;
68807 +
68808 + struct acl_subject_label **subj_hash;
68809 + __u32 subj_hash_size;
68810 +};
68811 +
68812 +struct user_acl_role_db {
68813 + struct acl_role_label **r_table;
68814 + __u32 num_pointers; /* Number of allocations to track */
68815 + __u32 num_roles; /* Number of roles */
68816 + __u32 num_domain_children; /* Number of domain children */
68817 + __u32 num_subjects; /* Number of subjects */
68818 + __u32 num_objects; /* Number of objects */
68819 +};
68820 +
68821 +struct acl_object_label {
68822 + char *filename;
68823 + ino_t inode;
68824 + dev_t device;
68825 + __u32 mode;
68826 +
68827 + struct acl_subject_label *nested;
68828 + struct acl_object_label *globbed;
68829 +
68830 + /* next two structures not used */
68831 +
68832 + struct acl_object_label *prev;
68833 + struct acl_object_label *next;
68834 +};
68835 +
68836 +struct acl_ip_label {
68837 + char *iface;
68838 + __u32 addr;
68839 + __u32 netmask;
68840 + __u16 low, high;
68841 + __u8 mode;
68842 + __u32 type;
68843 + __u32 proto[8];
68844 +
68845 + /* next two structures not used */
68846 +
68847 + struct acl_ip_label *prev;
68848 + struct acl_ip_label *next;
68849 +};
68850 +
68851 +struct gr_arg {
68852 + struct user_acl_role_db role_db;
68853 + unsigned char pw[GR_PW_LEN];
68854 + unsigned char salt[GR_SALT_LEN];
68855 + unsigned char sum[GR_SHA_LEN];
68856 + unsigned char sp_role[GR_SPROLE_LEN];
68857 + struct sprole_pw *sprole_pws;
68858 + dev_t segv_device;
68859 + ino_t segv_inode;
68860 + uid_t segv_uid;
68861 + __u16 num_sprole_pws;
68862 + __u16 mode;
68863 +};
68864 +
68865 +struct gr_arg_wrapper {
68866 + struct gr_arg *arg;
68867 + __u32 version;
68868 + __u32 size;
68869 +};
68870 +
68871 +struct subject_map {
68872 + struct acl_subject_label *user;
68873 + struct acl_subject_label *kernel;
68874 + struct subject_map *prev;
68875 + struct subject_map *next;
68876 +};
68877 +
68878 +struct acl_subj_map_db {
68879 + struct subject_map **s_hash;
68880 + __u32 s_size;
68881 +};
68882 +
68883 +/* End Data Structures Section */
68884 +
68885 +/* Hash functions generated by empirical testing by Brad Spengler
68886 + Makes good use of the low bits of the inode. Generally 0-1 times
68887 + in loop for successful match. 0-3 for unsuccessful match.
68888 + Shift/add algorithm with modulus of table size and an XOR*/
68889 +
68890 +static __inline__ unsigned int
68891 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68892 +{
68893 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68894 +}
68895 +
68896 + static __inline__ unsigned int
68897 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68898 +{
68899 + return ((const unsigned long)userp % sz);
68900 +}
68901 +
68902 +static __inline__ unsigned int
68903 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68904 +{
68905 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68906 +}
68907 +
68908 +static __inline__ unsigned int
68909 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68910 +{
68911 + return full_name_hash((const unsigned char *)name, len) % sz;
68912 +}
68913 +
68914 +#define FOR_EACH_ROLE_START(role) \
68915 + role = role_list; \
68916 + while (role) {
68917 +
68918 +#define FOR_EACH_ROLE_END(role) \
68919 + role = role->prev; \
68920 + }
68921 +
68922 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68923 + subj = NULL; \
68924 + iter = 0; \
68925 + while (iter < role->subj_hash_size) { \
68926 + if (subj == NULL) \
68927 + subj = role->subj_hash[iter]; \
68928 + if (subj == NULL) { \
68929 + iter++; \
68930 + continue; \
68931 + }
68932 +
68933 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68934 + subj = subj->next; \
68935 + if (subj == NULL) \
68936 + iter++; \
68937 + }
68938 +
68939 +
68940 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68941 + subj = role->hash->first; \
68942 + while (subj != NULL) {
68943 +
68944 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68945 + subj = subj->next; \
68946 + }
68947 +
68948 +#endif
68949 +
68950 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68951 new file mode 100644
68952 index 0000000..323ecf2
68953 --- /dev/null
68954 +++ b/include/linux/gralloc.h
68955 @@ -0,0 +1,9 @@
68956 +#ifndef __GRALLOC_H
68957 +#define __GRALLOC_H
68958 +
68959 +void acl_free_all(void);
68960 +int acl_alloc_stack_init(unsigned long size);
68961 +void *acl_alloc(unsigned long len);
68962 +void *acl_alloc_num(unsigned long num, unsigned long len);
68963 +
68964 +#endif
68965 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68966 new file mode 100644
68967 index 0000000..be66033
68968 --- /dev/null
68969 +++ b/include/linux/grdefs.h
68970 @@ -0,0 +1,140 @@
68971 +#ifndef GRDEFS_H
68972 +#define GRDEFS_H
68973 +
68974 +/* Begin grsecurity status declarations */
68975 +
68976 +enum {
68977 + GR_READY = 0x01,
68978 + GR_STATUS_INIT = 0x00 // disabled state
68979 +};
68980 +
68981 +/* Begin ACL declarations */
68982 +
68983 +/* Role flags */
68984 +
68985 +enum {
68986 + GR_ROLE_USER = 0x0001,
68987 + GR_ROLE_GROUP = 0x0002,
68988 + GR_ROLE_DEFAULT = 0x0004,
68989 + GR_ROLE_SPECIAL = 0x0008,
68990 + GR_ROLE_AUTH = 0x0010,
68991 + GR_ROLE_NOPW = 0x0020,
68992 + GR_ROLE_GOD = 0x0040,
68993 + GR_ROLE_LEARN = 0x0080,
68994 + GR_ROLE_TPE = 0x0100,
68995 + GR_ROLE_DOMAIN = 0x0200,
68996 + GR_ROLE_PAM = 0x0400,
68997 + GR_ROLE_PERSIST = 0x0800
68998 +};
68999 +
69000 +/* ACL Subject and Object mode flags */
69001 +enum {
69002 + GR_DELETED = 0x80000000
69003 +};
69004 +
69005 +/* ACL Object-only mode flags */
69006 +enum {
69007 + GR_READ = 0x00000001,
69008 + GR_APPEND = 0x00000002,
69009 + GR_WRITE = 0x00000004,
69010 + GR_EXEC = 0x00000008,
69011 + GR_FIND = 0x00000010,
69012 + GR_INHERIT = 0x00000020,
69013 + GR_SETID = 0x00000040,
69014 + GR_CREATE = 0x00000080,
69015 + GR_DELETE = 0x00000100,
69016 + GR_LINK = 0x00000200,
69017 + GR_AUDIT_READ = 0x00000400,
69018 + GR_AUDIT_APPEND = 0x00000800,
69019 + GR_AUDIT_WRITE = 0x00001000,
69020 + GR_AUDIT_EXEC = 0x00002000,
69021 + GR_AUDIT_FIND = 0x00004000,
69022 + GR_AUDIT_INHERIT= 0x00008000,
69023 + GR_AUDIT_SETID = 0x00010000,
69024 + GR_AUDIT_CREATE = 0x00020000,
69025 + GR_AUDIT_DELETE = 0x00040000,
69026 + GR_AUDIT_LINK = 0x00080000,
69027 + GR_PTRACERD = 0x00100000,
69028 + GR_NOPTRACE = 0x00200000,
69029 + GR_SUPPRESS = 0x00400000,
69030 + GR_NOLEARN = 0x00800000,
69031 + GR_INIT_TRANSFER= 0x01000000
69032 +};
69033 +
69034 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69035 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69036 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69037 +
69038 +/* ACL subject-only mode flags */
69039 +enum {
69040 + GR_KILL = 0x00000001,
69041 + GR_VIEW = 0x00000002,
69042 + GR_PROTECTED = 0x00000004,
69043 + GR_LEARN = 0x00000008,
69044 + GR_OVERRIDE = 0x00000010,
69045 + /* just a placeholder, this mode is only used in userspace */
69046 + GR_DUMMY = 0x00000020,
69047 + GR_PROTSHM = 0x00000040,
69048 + GR_KILLPROC = 0x00000080,
69049 + GR_KILLIPPROC = 0x00000100,
69050 + /* just a placeholder, this mode is only used in userspace */
69051 + GR_NOTROJAN = 0x00000200,
69052 + GR_PROTPROCFD = 0x00000400,
69053 + GR_PROCACCT = 0x00000800,
69054 + GR_RELAXPTRACE = 0x00001000,
69055 + //GR_NESTED = 0x00002000,
69056 + GR_INHERITLEARN = 0x00004000,
69057 + GR_PROCFIND = 0x00008000,
69058 + GR_POVERRIDE = 0x00010000,
69059 + GR_KERNELAUTH = 0x00020000,
69060 + GR_ATSECURE = 0x00040000,
69061 + GR_SHMEXEC = 0x00080000
69062 +};
69063 +
69064 +enum {
69065 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69066 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69067 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69068 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69069 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69070 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69071 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69072 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69073 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69074 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69075 +};
69076 +
69077 +enum {
69078 + GR_ID_USER = 0x01,
69079 + GR_ID_GROUP = 0x02,
69080 +};
69081 +
69082 +enum {
69083 + GR_ID_ALLOW = 0x01,
69084 + GR_ID_DENY = 0x02,
69085 +};
69086 +
69087 +#define GR_CRASH_RES 31
69088 +#define GR_UIDTABLE_MAX 500
69089 +
69090 +/* begin resource learning section */
69091 +enum {
69092 + GR_RLIM_CPU_BUMP = 60,
69093 + GR_RLIM_FSIZE_BUMP = 50000,
69094 + GR_RLIM_DATA_BUMP = 10000,
69095 + GR_RLIM_STACK_BUMP = 1000,
69096 + GR_RLIM_CORE_BUMP = 10000,
69097 + GR_RLIM_RSS_BUMP = 500000,
69098 + GR_RLIM_NPROC_BUMP = 1,
69099 + GR_RLIM_NOFILE_BUMP = 5,
69100 + GR_RLIM_MEMLOCK_BUMP = 50000,
69101 + GR_RLIM_AS_BUMP = 500000,
69102 + GR_RLIM_LOCKS_BUMP = 2,
69103 + GR_RLIM_SIGPENDING_BUMP = 5,
69104 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69105 + GR_RLIM_NICE_BUMP = 1,
69106 + GR_RLIM_RTPRIO_BUMP = 1,
69107 + GR_RLIM_RTTIME_BUMP = 1000000
69108 +};
69109 +
69110 +#endif
69111 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69112 new file mode 100644
69113 index 0000000..5402bce
69114 --- /dev/null
69115 +++ b/include/linux/grinternal.h
69116 @@ -0,0 +1,215 @@
69117 +#ifndef __GRINTERNAL_H
69118 +#define __GRINTERNAL_H
69119 +
69120 +#ifdef CONFIG_GRKERNSEC
69121 +
69122 +#include <linux/fs.h>
69123 +#include <linux/mnt_namespace.h>
69124 +#include <linux/nsproxy.h>
69125 +#include <linux/gracl.h>
69126 +#include <linux/grdefs.h>
69127 +#include <linux/grmsg.h>
69128 +
69129 +void gr_add_learn_entry(const char *fmt, ...)
69130 + __attribute__ ((format (printf, 1, 2)));
69131 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69132 + const struct vfsmount *mnt);
69133 +__u32 gr_check_create(const struct dentry *new_dentry,
69134 + const struct dentry *parent,
69135 + const struct vfsmount *mnt, const __u32 mode);
69136 +int gr_check_protected_task(const struct task_struct *task);
69137 +__u32 to_gr_audit(const __u32 reqmode);
69138 +int gr_set_acls(const int type);
69139 +int gr_apply_subject_to_task(struct task_struct *task);
69140 +int gr_acl_is_enabled(void);
69141 +char gr_roletype_to_char(void);
69142 +
69143 +void gr_handle_alertkill(struct task_struct *task);
69144 +char *gr_to_filename(const struct dentry *dentry,
69145 + const struct vfsmount *mnt);
69146 +char *gr_to_filename1(const struct dentry *dentry,
69147 + const struct vfsmount *mnt);
69148 +char *gr_to_filename2(const struct dentry *dentry,
69149 + const struct vfsmount *mnt);
69150 +char *gr_to_filename3(const struct dentry *dentry,
69151 + const struct vfsmount *mnt);
69152 +
69153 +extern int grsec_enable_ptrace_readexec;
69154 +extern int grsec_enable_harden_ptrace;
69155 +extern int grsec_enable_link;
69156 +extern int grsec_enable_fifo;
69157 +extern int grsec_enable_execve;
69158 +extern int grsec_enable_shm;
69159 +extern int grsec_enable_execlog;
69160 +extern int grsec_enable_signal;
69161 +extern int grsec_enable_audit_ptrace;
69162 +extern int grsec_enable_forkfail;
69163 +extern int grsec_enable_time;
69164 +extern int grsec_enable_rofs;
69165 +extern int grsec_enable_chroot_shmat;
69166 +extern int grsec_enable_chroot_mount;
69167 +extern int grsec_enable_chroot_double;
69168 +extern int grsec_enable_chroot_pivot;
69169 +extern int grsec_enable_chroot_chdir;
69170 +extern int grsec_enable_chroot_chmod;
69171 +extern int grsec_enable_chroot_mknod;
69172 +extern int grsec_enable_chroot_fchdir;
69173 +extern int grsec_enable_chroot_nice;
69174 +extern int grsec_enable_chroot_execlog;
69175 +extern int grsec_enable_chroot_caps;
69176 +extern int grsec_enable_chroot_sysctl;
69177 +extern int grsec_enable_chroot_unix;
69178 +extern int grsec_enable_symlinkown;
69179 +extern kgid_t grsec_symlinkown_gid;
69180 +extern int grsec_enable_tpe;
69181 +extern kgid_t grsec_tpe_gid;
69182 +extern int grsec_enable_tpe_all;
69183 +extern int grsec_enable_tpe_invert;
69184 +extern int grsec_enable_socket_all;
69185 +extern kgid_t grsec_socket_all_gid;
69186 +extern int grsec_enable_socket_client;
69187 +extern kgid_t grsec_socket_client_gid;
69188 +extern int grsec_enable_socket_server;
69189 +extern kgid_t grsec_socket_server_gid;
69190 +extern kgid_t grsec_audit_gid;
69191 +extern int grsec_enable_group;
69192 +extern int grsec_enable_audit_textrel;
69193 +extern int grsec_enable_log_rwxmaps;
69194 +extern int grsec_enable_mount;
69195 +extern int grsec_enable_chdir;
69196 +extern int grsec_resource_logging;
69197 +extern int grsec_enable_blackhole;
69198 +extern int grsec_lastack_retries;
69199 +extern int grsec_enable_brute;
69200 +extern int grsec_lock;
69201 +
69202 +extern spinlock_t grsec_alert_lock;
69203 +extern unsigned long grsec_alert_wtime;
69204 +extern unsigned long grsec_alert_fyet;
69205 +
69206 +extern spinlock_t grsec_audit_lock;
69207 +
69208 +extern rwlock_t grsec_exec_file_lock;
69209 +
69210 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69211 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69212 + (tsk)->exec_file->f_path.mnt) : "/")
69213 +
69214 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69215 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69216 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
69217 +
69218 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69219 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69220 + (tsk)->exec_file->f_path.mnt) : "/")
69221 +
69222 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69223 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69224 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
69225 +
69226 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69227 +
69228 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69229 +
69230 +#define GR_CHROOT_CAPS {{ \
69231 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69232 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69233 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69234 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69235 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69236 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69237 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69238 +
69239 +#define security_learn(normal_msg,args...) \
69240 +({ \
69241 + read_lock(&grsec_exec_file_lock); \
69242 + gr_add_learn_entry(normal_msg "\n", ## args); \
69243 + read_unlock(&grsec_exec_file_lock); \
69244 +})
69245 +
69246 +enum {
69247 + GR_DO_AUDIT,
69248 + GR_DONT_AUDIT,
69249 + /* used for non-audit messages that we shouldn't kill the task on */
69250 + GR_DONT_AUDIT_GOOD
69251 +};
69252 +
69253 +enum {
69254 + GR_TTYSNIFF,
69255 + GR_RBAC,
69256 + GR_RBAC_STR,
69257 + GR_STR_RBAC,
69258 + GR_RBAC_MODE2,
69259 + GR_RBAC_MODE3,
69260 + GR_FILENAME,
69261 + GR_SYSCTL_HIDDEN,
69262 + GR_NOARGS,
69263 + GR_ONE_INT,
69264 + GR_ONE_INT_TWO_STR,
69265 + GR_ONE_STR,
69266 + GR_STR_INT,
69267 + GR_TWO_STR_INT,
69268 + GR_TWO_INT,
69269 + GR_TWO_U64,
69270 + GR_THREE_INT,
69271 + GR_FIVE_INT_TWO_STR,
69272 + GR_TWO_STR,
69273 + GR_THREE_STR,
69274 + GR_FOUR_STR,
69275 + GR_STR_FILENAME,
69276 + GR_FILENAME_STR,
69277 + GR_FILENAME_TWO_INT,
69278 + GR_FILENAME_TWO_INT_STR,
69279 + GR_TEXTREL,
69280 + GR_PTRACE,
69281 + GR_RESOURCE,
69282 + GR_CAP,
69283 + GR_SIG,
69284 + GR_SIG2,
69285 + GR_CRASH1,
69286 + GR_CRASH2,
69287 + GR_PSACCT,
69288 + GR_RWXMAP
69289 +};
69290 +
69291 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69292 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69293 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69294 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69295 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69296 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69297 +#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)
69298 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69299 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69300 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69301 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69302 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69303 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69304 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69305 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69306 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69307 +#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)
69308 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69309 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69310 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69311 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69312 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69313 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69314 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69315 +#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)
69316 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69317 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69318 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69319 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69320 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69321 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69322 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69323 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69324 +#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)
69325 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69326 +
69327 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69328 +
69329 +#endif
69330 +
69331 +#endif
69332 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69333 new file mode 100644
69334 index 0000000..2bd4c8d
69335 --- /dev/null
69336 +++ b/include/linux/grmsg.h
69337 @@ -0,0 +1,111 @@
69338 +#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"
69339 +#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"
69340 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69341 +#define GR_STOPMOD_MSG "denied modification of module state by "
69342 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69343 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69344 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69345 +#define GR_IOPL_MSG "denied use of iopl() by "
69346 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69347 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69348 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69349 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69350 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69351 +#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"
69352 +#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"
69353 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69354 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69355 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69356 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69357 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69358 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69359 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69360 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69361 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69362 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69363 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69364 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69365 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69366 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69367 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69368 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69369 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69370 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69371 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69372 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69373 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69374 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69375 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69376 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69377 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69378 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69379 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69380 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69381 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69382 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69383 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69384 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69385 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69386 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69387 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69388 +#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"
69389 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69390 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69391 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69392 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69393 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69394 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69395 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69396 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69397 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69398 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69399 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69400 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69401 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69402 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69403 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69404 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69405 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69406 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69407 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69408 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69409 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69410 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69411 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69412 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69413 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69414 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69415 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69416 +#define GR_TIME_MSG "time set by "
69417 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69418 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69419 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69420 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69421 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69422 +#define GR_BIND_MSG "denied bind() by "
69423 +#define GR_CONNECT_MSG "denied connect() by "
69424 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69425 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69426 +#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"
69427 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69428 +#define GR_CAP_ACL_MSG "use of %s denied for "
69429 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69430 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69431 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69432 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69433 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69434 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69435 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69436 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69437 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69438 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69439 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69440 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69441 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69442 +#define GR_VM86_MSG "denied use of vm86 by "
69443 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69444 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69445 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69446 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69447 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69448 +#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 "
69449 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69450 new file mode 100644
69451 index 0000000..d7ef0ac
69452 --- /dev/null
69453 +++ b/include/linux/grsecurity.h
69454 @@ -0,0 +1,242 @@
69455 +#ifndef GR_SECURITY_H
69456 +#define GR_SECURITY_H
69457 +#include <linux/fs.h>
69458 +#include <linux/fs_struct.h>
69459 +#include <linux/binfmts.h>
69460 +#include <linux/gracl.h>
69461 +
69462 +/* notify of brain-dead configs */
69463 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69464 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69465 +#endif
69466 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69467 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69468 +#endif
69469 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69470 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69471 +#endif
69472 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69473 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69474 +#endif
69475 +
69476 +void gr_handle_brute_attach(unsigned long mm_flags);
69477 +void gr_handle_brute_check(void);
69478 +void gr_handle_kernel_exploit(void);
69479 +int gr_process_user_ban(void);
69480 +
69481 +char gr_roletype_to_char(void);
69482 +
69483 +int gr_acl_enable_at_secure(void);
69484 +
69485 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69486 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69487 +
69488 +void gr_del_task_from_ip_table(struct task_struct *p);
69489 +
69490 +int gr_pid_is_chrooted(struct task_struct *p);
69491 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69492 +int gr_handle_chroot_nice(void);
69493 +int gr_handle_chroot_sysctl(const int op);
69494 +int gr_handle_chroot_setpriority(struct task_struct *p,
69495 + const int niceval);
69496 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69497 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69498 + const struct vfsmount *mnt);
69499 +void gr_handle_chroot_chdir(const struct path *path);
69500 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69501 + const struct vfsmount *mnt, const int mode);
69502 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69503 + const struct vfsmount *mnt, const int mode);
69504 +int gr_handle_chroot_mount(const struct dentry *dentry,
69505 + const struct vfsmount *mnt,
69506 + const char *dev_name);
69507 +int gr_handle_chroot_pivot(void);
69508 +int gr_handle_chroot_unix(const pid_t pid);
69509 +
69510 +int gr_handle_rawio(const struct inode *inode);
69511 +
69512 +void gr_handle_ioperm(void);
69513 +void gr_handle_iopl(void);
69514 +
69515 +umode_t gr_acl_umask(void);
69516 +
69517 +int gr_tpe_allow(const struct file *file);
69518 +
69519 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
69520 +void gr_clear_chroot_entries(struct task_struct *task);
69521 +
69522 +void gr_log_forkfail(const int retval);
69523 +void gr_log_timechange(void);
69524 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69525 +void gr_log_chdir(const struct dentry *dentry,
69526 + const struct vfsmount *mnt);
69527 +void gr_log_chroot_exec(const struct dentry *dentry,
69528 + const struct vfsmount *mnt);
69529 +void gr_log_remount(const char *devname, const int retval);
69530 +void gr_log_unmount(const char *devname, const int retval);
69531 +void gr_log_mount(const char *from, const char *to, const int retval);
69532 +void gr_log_textrel(struct vm_area_struct *vma);
69533 +void gr_log_rwxmmap(struct file *file);
69534 +void gr_log_rwxmprotect(struct file *file);
69535 +
69536 +int gr_handle_follow_link(const struct inode *parent,
69537 + const struct inode *inode,
69538 + const struct dentry *dentry,
69539 + const struct vfsmount *mnt);
69540 +int gr_handle_fifo(const struct dentry *dentry,
69541 + const struct vfsmount *mnt,
69542 + const struct dentry *dir, const int flag,
69543 + const int acc_mode);
69544 +int gr_handle_hardlink(const struct dentry *dentry,
69545 + const struct vfsmount *mnt,
69546 + struct inode *inode,
69547 + const int mode, const struct filename *to);
69548 +
69549 +int gr_is_capable(const int cap);
69550 +int gr_is_capable_nolog(const int cap);
69551 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69552 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69553 +
69554 +void gr_copy_label(struct task_struct *tsk);
69555 +void gr_handle_crash(struct task_struct *task, const int sig);
69556 +int gr_handle_signal(const struct task_struct *p, const int sig);
69557 +int gr_check_crash_uid(const kuid_t uid);
69558 +int gr_check_protected_task(const struct task_struct *task);
69559 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69560 +int gr_acl_handle_mmap(const struct file *file,
69561 + const unsigned long prot);
69562 +int gr_acl_handle_mprotect(const struct file *file,
69563 + const unsigned long prot);
69564 +int gr_check_hidden_task(const struct task_struct *tsk);
69565 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69566 + const struct vfsmount *mnt);
69567 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69568 + const struct vfsmount *mnt);
69569 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69570 + const struct vfsmount *mnt, const int fmode);
69571 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69572 + const struct vfsmount *mnt, umode_t *mode);
69573 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69574 + const struct vfsmount *mnt);
69575 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69576 + const struct vfsmount *mnt);
69577 +int gr_handle_ptrace(struct task_struct *task, const long request);
69578 +int gr_handle_proc_ptrace(struct task_struct *task);
69579 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69580 + const struct vfsmount *mnt);
69581 +int gr_check_crash_exec(const struct file *filp);
69582 +int gr_acl_is_enabled(void);
69583 +void gr_set_kernel_label(struct task_struct *task);
69584 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69585 + const kgid_t gid);
69586 +int gr_set_proc_label(const struct dentry *dentry,
69587 + const struct vfsmount *mnt,
69588 + const int unsafe_flags);
69589 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69590 + const struct vfsmount *mnt);
69591 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69592 + const struct vfsmount *mnt, int acc_mode);
69593 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69594 + const struct dentry *p_dentry,
69595 + const struct vfsmount *p_mnt,
69596 + int open_flags, int acc_mode, const int imode);
69597 +void gr_handle_create(const struct dentry *dentry,
69598 + const struct vfsmount *mnt);
69599 +void gr_handle_proc_create(const struct dentry *dentry,
69600 + const struct inode *inode);
69601 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69602 + const struct dentry *parent_dentry,
69603 + const struct vfsmount *parent_mnt,
69604 + const int mode);
69605 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69606 + const struct dentry *parent_dentry,
69607 + const struct vfsmount *parent_mnt);
69608 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69609 + const struct vfsmount *mnt);
69610 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69611 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69612 + const struct vfsmount *mnt);
69613 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69614 + const struct dentry *parent_dentry,
69615 + const struct vfsmount *parent_mnt,
69616 + const struct filename *from);
69617 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69618 + const struct dentry *parent_dentry,
69619 + const struct vfsmount *parent_mnt,
69620 + const struct dentry *old_dentry,
69621 + const struct vfsmount *old_mnt, const struct filename *to);
69622 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69623 +int gr_acl_handle_rename(struct dentry *new_dentry,
69624 + struct dentry *parent_dentry,
69625 + const struct vfsmount *parent_mnt,
69626 + struct dentry *old_dentry,
69627 + struct inode *old_parent_inode,
69628 + struct vfsmount *old_mnt, const struct filename *newname);
69629 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69630 + struct dentry *old_dentry,
69631 + struct dentry *new_dentry,
69632 + struct vfsmount *mnt, const __u8 replace);
69633 +__u32 gr_check_link(const struct dentry *new_dentry,
69634 + const struct dentry *parent_dentry,
69635 + const struct vfsmount *parent_mnt,
69636 + const struct dentry *old_dentry,
69637 + const struct vfsmount *old_mnt);
69638 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69639 + const unsigned int namelen, const ino_t ino);
69640 +
69641 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69642 + const struct vfsmount *mnt);
69643 +void gr_acl_handle_exit(void);
69644 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69645 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69646 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69647 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69648 +void gr_audit_ptrace(struct task_struct *task);
69649 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69650 +void gr_put_exec_file(struct task_struct *task);
69651 +
69652 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69653 +
69654 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69655 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69656 + const unsigned long wanted, const int gt);
69657 +#else
69658 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69659 + const unsigned long wanted, const int gt)
69660 +{
69661 +}
69662 +#endif
69663 +
69664 +#ifdef CONFIG_GRKERNSEC_RESLOG
69665 +extern void gr_log_resource(const struct task_struct *task, const int res,
69666 + const unsigned long wanted, const int gt);
69667 +#else
69668 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69669 + const unsigned long wanted, const int gt)
69670 +{
69671 +}
69672 +#endif
69673 +
69674 +#ifdef CONFIG_GRKERNSEC
69675 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69676 +void gr_handle_vm86(void);
69677 +void gr_handle_mem_readwrite(u64 from, u64 to);
69678 +
69679 +void gr_log_badprocpid(const char *entry);
69680 +
69681 +extern int grsec_enable_dmesg;
69682 +extern int grsec_disable_privio;
69683 +
69684 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69685 +extern kgid_t grsec_proc_gid;
69686 +#endif
69687 +
69688 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69689 +extern int grsec_enable_chroot_findtask;
69690 +#endif
69691 +#ifdef CONFIG_GRKERNSEC_SETXID
69692 +extern int grsec_enable_setxid;
69693 +#endif
69694 +#endif
69695 +
69696 +#endif
69697 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69698 new file mode 100644
69699 index 0000000..e7ffaaf
69700 --- /dev/null
69701 +++ b/include/linux/grsock.h
69702 @@ -0,0 +1,19 @@
69703 +#ifndef __GRSOCK_H
69704 +#define __GRSOCK_H
69705 +
69706 +extern void gr_attach_curr_ip(const struct sock *sk);
69707 +extern int gr_handle_sock_all(const int family, const int type,
69708 + const int protocol);
69709 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69710 +extern int gr_handle_sock_server_other(const struct sock *sck);
69711 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69712 +extern int gr_search_connect(struct socket * sock,
69713 + struct sockaddr_in * addr);
69714 +extern int gr_search_bind(struct socket * sock,
69715 + struct sockaddr_in * addr);
69716 +extern int gr_search_listen(struct socket * sock);
69717 +extern int gr_search_accept(struct socket * sock);
69718 +extern int gr_search_socket(const int domain, const int type,
69719 + const int protocol);
69720 +
69721 +#endif
69722 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69723 index 7fb31da..08b5114 100644
69724 --- a/include/linux/highmem.h
69725 +++ b/include/linux/highmem.h
69726 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69727 kunmap_atomic(kaddr);
69728 }
69729
69730 +static inline void sanitize_highpage(struct page *page)
69731 +{
69732 + void *kaddr;
69733 + unsigned long flags;
69734 +
69735 + local_irq_save(flags);
69736 + kaddr = kmap_atomic(page);
69737 + clear_page(kaddr);
69738 + kunmap_atomic(kaddr);
69739 + local_irq_restore(flags);
69740 +}
69741 +
69742 static inline void zero_user_segments(struct page *page,
69743 unsigned start1, unsigned end1,
69744 unsigned start2, unsigned end2)
69745 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69746 index 1c7b89a..7f52502 100644
69747 --- a/include/linux/hwmon-sysfs.h
69748 +++ b/include/linux/hwmon-sysfs.h
69749 @@ -25,7 +25,8 @@
69750 struct sensor_device_attribute{
69751 struct device_attribute dev_attr;
69752 int index;
69753 -};
69754 +} __do_const;
69755 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69756 #define to_sensor_dev_attr(_dev_attr) \
69757 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69758
69759 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69760 struct device_attribute dev_attr;
69761 u8 index;
69762 u8 nr;
69763 -};
69764 +} __do_const;
69765 #define to_sensor_dev_attr_2(_dev_attr) \
69766 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69767
69768 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69769 index d0c4db7..61b3577 100644
69770 --- a/include/linux/i2c.h
69771 +++ b/include/linux/i2c.h
69772 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69773 /* To determine what the adapter supports */
69774 u32 (*functionality) (struct i2c_adapter *);
69775 };
69776 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69777
69778 /*
69779 * i2c_adapter is the structure used to identify a physical i2c bus along
69780 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69781 index d23c3c2..eb63c81 100644
69782 --- a/include/linux/i2o.h
69783 +++ b/include/linux/i2o.h
69784 @@ -565,7 +565,7 @@ struct i2o_controller {
69785 struct i2o_device *exec; /* Executive */
69786 #if BITS_PER_LONG == 64
69787 spinlock_t context_list_lock; /* lock for context_list */
69788 - atomic_t context_list_counter; /* needed for unique contexts */
69789 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69790 struct list_head context_list; /* list of context id's
69791 and pointers */
69792 #endif
69793 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69794 index aff7ad8..3942bbd 100644
69795 --- a/include/linux/if_pppox.h
69796 +++ b/include/linux/if_pppox.h
69797 @@ -76,7 +76,7 @@ struct pppox_proto {
69798 int (*ioctl)(struct socket *sock, unsigned int cmd,
69799 unsigned long arg);
69800 struct module *owner;
69801 -};
69802 +} __do_const;
69803
69804 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69805 extern void unregister_pppox_proto(int proto_num);
69806 diff --git a/include/linux/init.h b/include/linux/init.h
69807 index 8618147..0821126 100644
69808 --- a/include/linux/init.h
69809 +++ b/include/linux/init.h
69810 @@ -39,9 +39,36 @@
69811 * Also note, that this data cannot be "const".
69812 */
69813
69814 +#ifdef MODULE
69815 +#define add_init_latent_entropy
69816 +#define add_devinit_latent_entropy
69817 +#define add_cpuinit_latent_entropy
69818 +#define add_meminit_latent_entropy
69819 +#else
69820 +#define add_init_latent_entropy __latent_entropy
69821 +
69822 +#ifdef CONFIG_HOTPLUG
69823 +#define add_devinit_latent_entropy
69824 +#else
69825 +#define add_devinit_latent_entropy __latent_entropy
69826 +#endif
69827 +
69828 +#ifdef CONFIG_HOTPLUG_CPU
69829 +#define add_cpuinit_latent_entropy
69830 +#else
69831 +#define add_cpuinit_latent_entropy __latent_entropy
69832 +#endif
69833 +
69834 +#ifdef CONFIG_MEMORY_HOTPLUG
69835 +#define add_meminit_latent_entropy
69836 +#else
69837 +#define add_meminit_latent_entropy __latent_entropy
69838 +#endif
69839 +#endif
69840 +
69841 /* These are for everybody (although not all archs will actually
69842 discard it in modules) */
69843 -#define __init __section(.init.text) __cold notrace
69844 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69845 #define __initdata __section(.init.data)
69846 #define __initconst __constsection(.init.rodata)
69847 #define __exitdata __section(.exit.data)
69848 @@ -94,7 +121,7 @@
69849 #define __exit __section(.exit.text) __exitused __cold notrace
69850
69851 /* Used for HOTPLUG_CPU */
69852 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69853 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69854 #define __cpuinitdata __section(.cpuinit.data)
69855 #define __cpuinitconst __constsection(.cpuinit.rodata)
69856 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69857 @@ -102,7 +129,7 @@
69858 #define __cpuexitconst __constsection(.cpuexit.rodata)
69859
69860 /* Used for MEMORY_HOTPLUG */
69861 -#define __meminit __section(.meminit.text) __cold notrace
69862 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69863 #define __meminitdata __section(.meminit.data)
69864 #define __meminitconst __constsection(.meminit.rodata)
69865 #define __memexit __section(.memexit.text) __exitused __cold notrace
69866 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69867 index 5cd0f09..c9f67cc 100644
69868 --- a/include/linux/init_task.h
69869 +++ b/include/linux/init_task.h
69870 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
69871
69872 #define INIT_TASK_COMM "swapper"
69873
69874 +#ifdef CONFIG_X86
69875 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69876 +#else
69877 +#define INIT_TASK_THREAD_INFO
69878 +#endif
69879 +
69880 /*
69881 * INIT_TASK is used to set up the first task table, touch at
69882 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69883 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
69884 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69885 .comm = INIT_TASK_COMM, \
69886 .thread = INIT_THREAD, \
69887 + INIT_TASK_THREAD_INFO \
69888 .fs = &init_fs, \
69889 .files = &init_files, \
69890 .signal = &init_signals, \
69891 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69892 index 5fa5afe..ac55b25 100644
69893 --- a/include/linux/interrupt.h
69894 +++ b/include/linux/interrupt.h
69895 @@ -430,7 +430,7 @@ enum
69896 /* map softirq index to softirq name. update 'softirq_to_name' in
69897 * kernel/softirq.c when adding a new softirq.
69898 */
69899 -extern char *softirq_to_name[NR_SOFTIRQS];
69900 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69901
69902 /* softirq mask and active fields moved to irq_cpustat_t in
69903 * asm/hardirq.h to get better cache usage. KAO
69904 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69905
69906 struct softirq_action
69907 {
69908 - void (*action)(struct softirq_action *);
69909 -};
69910 + void (*action)(void);
69911 +} __no_const;
69912
69913 asmlinkage void do_softirq(void);
69914 asmlinkage void __do_softirq(void);
69915 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69916 +extern void open_softirq(int nr, void (*action)(void));
69917 extern void softirq_init(void);
69918 extern void __raise_softirq_irqoff(unsigned int nr);
69919
69920 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69921 index ba3b8a9..7e14ed8 100644
69922 --- a/include/linux/iommu.h
69923 +++ b/include/linux/iommu.h
69924 @@ -113,7 +113,7 @@ struct iommu_ops {
69925 u32 (*domain_get_windows)(struct iommu_domain *domain);
69926
69927 unsigned long pgsize_bitmap;
69928 -};
69929 +} __do_const;
69930
69931 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69932 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69933 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
69934 index 85ac9b9b..e5759ab 100644
69935 --- a/include/linux/ioport.h
69936 +++ b/include/linux/ioport.h
69937 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
69938 int adjust_resource(struct resource *res, resource_size_t start,
69939 resource_size_t size);
69940 resource_size_t resource_alignment(struct resource *res);
69941 -static inline resource_size_t resource_size(const struct resource *res)
69942 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
69943 {
69944 return res->end - res->start + 1;
69945 }
69946 diff --git a/include/linux/irq.h b/include/linux/irq.h
69947 index bc4e066..50468a9 100644
69948 --- a/include/linux/irq.h
69949 +++ b/include/linux/irq.h
69950 @@ -328,7 +328,8 @@ struct irq_chip {
69951 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69952
69953 unsigned long flags;
69954 -};
69955 +} __do_const;
69956 +typedef struct irq_chip __no_const irq_chip_no_const;
69957
69958 /*
69959 * irq_chip specific flags
69960 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
69961 index 3fd8e42..a73e966 100644
69962 --- a/include/linux/irqchip/arm-gic.h
69963 +++ b/include/linux/irqchip/arm-gic.h
69964 @@ -59,9 +59,11 @@
69965
69966 #ifndef __ASSEMBLY__
69967
69968 +#include <linux/irq.h>
69969 +
69970 struct device_node;
69971
69972 -extern struct irq_chip gic_arch_extn;
69973 +extern irq_chip_no_const gic_arch_extn;
69974
69975 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
69976 u32 offset, struct device_node *);
69977 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69978 index 6883e19..06992b1 100644
69979 --- a/include/linux/kallsyms.h
69980 +++ b/include/linux/kallsyms.h
69981 @@ -15,7 +15,8 @@
69982
69983 struct module;
69984
69985 -#ifdef CONFIG_KALLSYMS
69986 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69987 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69988 /* Lookup the address for a symbol. Returns 0 if not found. */
69989 unsigned long kallsyms_lookup_name(const char *name);
69990
69991 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69992 /* Stupid that this does nothing, but I didn't create this mess. */
69993 #define __print_symbol(fmt, addr)
69994 #endif /*CONFIG_KALLSYMS*/
69995 +#else /* when included by kallsyms.c, vsnprintf.c, or
69996 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69997 +extern void __print_symbol(const char *fmt, unsigned long address);
69998 +extern int sprint_backtrace(char *buffer, unsigned long address);
69999 +extern int sprint_symbol(char *buffer, unsigned long address);
70000 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
70001 +const char *kallsyms_lookup(unsigned long addr,
70002 + unsigned long *symbolsize,
70003 + unsigned long *offset,
70004 + char **modname, char *namebuf);
70005 +#endif
70006
70007 /* This macro allows us to keep printk typechecking */
70008 static __printf(1, 2)
70009 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
70010 index 518a53a..5e28358 100644
70011 --- a/include/linux/key-type.h
70012 +++ b/include/linux/key-type.h
70013 @@ -125,7 +125,7 @@ struct key_type {
70014 /* internal fields */
70015 struct list_head link; /* link in types list */
70016 struct lock_class_key lock_class; /* key->sem lock class */
70017 -};
70018 +} __do_const;
70019
70020 extern struct key_type key_type_keyring;
70021
70022 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
70023 index c6e091b..a940adf 100644
70024 --- a/include/linux/kgdb.h
70025 +++ b/include/linux/kgdb.h
70026 @@ -52,7 +52,7 @@ extern int kgdb_connected;
70027 extern int kgdb_io_module_registered;
70028
70029 extern atomic_t kgdb_setting_breakpoint;
70030 -extern atomic_t kgdb_cpu_doing_single_step;
70031 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70032
70033 extern struct task_struct *kgdb_usethread;
70034 extern struct task_struct *kgdb_contthread;
70035 @@ -254,7 +254,7 @@ struct kgdb_arch {
70036 void (*correct_hw_break)(void);
70037
70038 void (*enable_nmi)(bool on);
70039 -};
70040 +} __do_const;
70041
70042 /**
70043 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
70044 @@ -279,7 +279,7 @@ struct kgdb_io {
70045 void (*pre_exception) (void);
70046 void (*post_exception) (void);
70047 int is_console;
70048 -};
70049 +} __do_const;
70050
70051 extern struct kgdb_arch arch_kgdb_ops;
70052
70053 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70054 index 5398d58..5883a34 100644
70055 --- a/include/linux/kmod.h
70056 +++ b/include/linux/kmod.h
70057 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70058 * usually useless though. */
70059 extern __printf(2, 3)
70060 int __request_module(bool wait, const char *name, ...);
70061 +extern __printf(3, 4)
70062 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70063 #define request_module(mod...) __request_module(true, mod)
70064 #define request_module_nowait(mod...) __request_module(false, mod)
70065 #define try_then_request_module(x, mod...) \
70066 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70067 index 939b112..ed6ed51 100644
70068 --- a/include/linux/kobject.h
70069 +++ b/include/linux/kobject.h
70070 @@ -111,7 +111,7 @@ struct kobj_type {
70071 struct attribute **default_attrs;
70072 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70073 const void *(*namespace)(struct kobject *kobj);
70074 -};
70075 +} __do_const;
70076
70077 struct kobj_uevent_env {
70078 char *envp[UEVENT_NUM_ENVP];
70079 @@ -134,6 +134,7 @@ struct kobj_attribute {
70080 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70081 const char *buf, size_t count);
70082 };
70083 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70084
70085 extern const struct sysfs_ops kobj_sysfs_ops;
70086
70087 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70088 index f66b065..c2c29b4 100644
70089 --- a/include/linux/kobject_ns.h
70090 +++ b/include/linux/kobject_ns.h
70091 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70092 const void *(*netlink_ns)(struct sock *sk);
70093 const void *(*initial_ns)(void);
70094 void (*drop_ns)(void *);
70095 -};
70096 +} __do_const;
70097
70098 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70099 int kobj_ns_type_registered(enum kobj_ns_type type);
70100 diff --git a/include/linux/kref.h b/include/linux/kref.h
70101 index 7419c02..aa2f02d 100644
70102 --- a/include/linux/kref.h
70103 +++ b/include/linux/kref.h
70104 @@ -65,7 +65,7 @@ static inline void kref_get(struct kref *kref)
70105 static inline int kref_sub(struct kref *kref, unsigned int count,
70106 void (*release)(struct kref *kref))
70107 {
70108 - WARN_ON(release == NULL);
70109 + BUG_ON(release == NULL);
70110
70111 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70112 release(kref);
70113 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70114 index c139582..0b5b102 100644
70115 --- a/include/linux/kvm_host.h
70116 +++ b/include/linux/kvm_host.h
70117 @@ -424,7 +424,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
70118 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
70119 void vcpu_put(struct kvm_vcpu *vcpu);
70120
70121 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70122 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70123 struct module *module);
70124 void kvm_exit(void);
70125
70126 @@ -582,7 +582,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70127 struct kvm_guest_debug *dbg);
70128 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70129
70130 -int kvm_arch_init(void *opaque);
70131 +int kvm_arch_init(const void *opaque);
70132 void kvm_arch_exit(void);
70133
70134 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70135 diff --git a/include/linux/libata.h b/include/linux/libata.h
70136 index eae7a05..2cdd875 100644
70137 --- a/include/linux/libata.h
70138 +++ b/include/linux/libata.h
70139 @@ -919,7 +919,7 @@ struct ata_port_operations {
70140 * fields must be pointers.
70141 */
70142 const struct ata_port_operations *inherits;
70143 -};
70144 +} __do_const;
70145
70146 struct ata_port_info {
70147 unsigned long flags;
70148 diff --git a/include/linux/list.h b/include/linux/list.h
70149 index 6a1f8df..eaec1ff 100644
70150 --- a/include/linux/list.h
70151 +++ b/include/linux/list.h
70152 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70153 extern void list_del(struct list_head *entry);
70154 #endif
70155
70156 +extern void __pax_list_add(struct list_head *new,
70157 + struct list_head *prev,
70158 + struct list_head *next);
70159 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70160 +{
70161 + __pax_list_add(new, head, head->next);
70162 +}
70163 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70164 +{
70165 + __pax_list_add(new, head->prev, head);
70166 +}
70167 +extern void pax_list_del(struct list_head *entry);
70168 +
70169 /**
70170 * list_replace - replace old entry by new one
70171 * @old : the element to be replaced
70172 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70173 INIT_LIST_HEAD(entry);
70174 }
70175
70176 +extern void pax_list_del_init(struct list_head *entry);
70177 +
70178 /**
70179 * list_move - delete from one list and add as another's head
70180 * @list: the entry to move
70181 diff --git a/include/linux/math64.h b/include/linux/math64.h
70182 index b8ba855..0148090 100644
70183 --- a/include/linux/math64.h
70184 +++ b/include/linux/math64.h
70185 @@ -14,7 +14,7 @@
70186 * This is commonly provided by 32bit archs to provide an optimized 64bit
70187 * divide.
70188 */
70189 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70190 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70191 {
70192 *remainder = dividend % divisor;
70193 return dividend / divisor;
70194 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70195 #define div64_long(x,y) div_s64((x),(y))
70196
70197 #ifndef div_u64_rem
70198 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70199 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70200 {
70201 *remainder = do_div(dividend, divisor);
70202 return dividend;
70203 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70204 * divide.
70205 */
70206 #ifndef div_u64
70207 -static inline u64 div_u64(u64 dividend, u32 divisor)
70208 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70209 {
70210 u32 remainder;
70211 return div_u64_rem(dividend, divisor, &remainder);
70212 diff --git a/include/linux/mm.h b/include/linux/mm.h
70213 index e2091b8..3c7b38c 100644
70214 --- a/include/linux/mm.h
70215 +++ b/include/linux/mm.h
70216 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
70217 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70218 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70219 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70220 +
70221 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70222 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70223 +#endif
70224 +
70225 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70226
70227 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70228 @@ -202,8 +207,8 @@ struct vm_operations_struct {
70229 /* called by access_process_vm when get_user_pages() fails, typically
70230 * for use by special VMAs that can switch between memory and hardware
70231 */
70232 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70233 - void *buf, int len, int write);
70234 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70235 + void *buf, size_t len, int write);
70236 #ifdef CONFIG_NUMA
70237 /*
70238 * set_policy() op must add a reference to any non-NULL @new mempolicy
70239 @@ -233,6 +238,7 @@ struct vm_operations_struct {
70240 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70241 unsigned long size, pgoff_t pgoff);
70242 };
70243 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70244
70245 struct mmu_gather;
70246 struct inode;
70247 @@ -970,8 +976,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70248 unsigned long *pfn);
70249 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70250 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70251 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70252 - void *buf, int len, int write);
70253 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70254 + void *buf, size_t len, int write);
70255
70256 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70257 loff_t const holebegin, loff_t const holelen)
70258 @@ -1010,9 +1016,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70259 }
70260 #endif
70261
70262 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70263 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70264 - void *buf, int len, int write);
70265 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70266 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70267 + void *buf, size_t len, int write);
70268
70269 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70270 unsigned long start, unsigned long nr_pages,
70271 @@ -1043,34 +1049,6 @@ int set_page_dirty(struct page *page);
70272 int set_page_dirty_lock(struct page *page);
70273 int clear_page_dirty_for_io(struct page *page);
70274
70275 -/* Is the vma a continuation of the stack vma above it? */
70276 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70277 -{
70278 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70279 -}
70280 -
70281 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70282 - unsigned long addr)
70283 -{
70284 - return (vma->vm_flags & VM_GROWSDOWN) &&
70285 - (vma->vm_start == addr) &&
70286 - !vma_growsdown(vma->vm_prev, addr);
70287 -}
70288 -
70289 -/* Is the vma a continuation of the stack vma below it? */
70290 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70291 -{
70292 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70293 -}
70294 -
70295 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70296 - unsigned long addr)
70297 -{
70298 - return (vma->vm_flags & VM_GROWSUP) &&
70299 - (vma->vm_end == addr) &&
70300 - !vma_growsup(vma->vm_next, addr);
70301 -}
70302 -
70303 extern pid_t
70304 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70305
70306 @@ -1173,6 +1151,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70307 }
70308 #endif
70309
70310 +#ifdef CONFIG_MMU
70311 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70312 +#else
70313 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70314 +{
70315 + return __pgprot(0);
70316 +}
70317 +#endif
70318 +
70319 int vma_wants_writenotify(struct vm_area_struct *vma);
70320
70321 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70322 @@ -1191,8 +1178,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70323 {
70324 return 0;
70325 }
70326 +
70327 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70328 + unsigned long address)
70329 +{
70330 + return 0;
70331 +}
70332 #else
70333 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70334 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70335 #endif
70336
70337 #ifdef __PAGETABLE_PMD_FOLDED
70338 @@ -1201,8 +1195,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70339 {
70340 return 0;
70341 }
70342 +
70343 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70344 + unsigned long address)
70345 +{
70346 + return 0;
70347 +}
70348 #else
70349 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70350 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70351 #endif
70352
70353 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70354 @@ -1220,11 +1221,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70355 NULL: pud_offset(pgd, address);
70356 }
70357
70358 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70359 +{
70360 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70361 + NULL: pud_offset(pgd, address);
70362 +}
70363 +
70364 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70365 {
70366 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70367 NULL: pmd_offset(pud, address);
70368 }
70369 +
70370 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70371 +{
70372 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70373 + NULL: pmd_offset(pud, address);
70374 +}
70375 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70376
70377 #if USE_SPLIT_PTLOCKS
70378 @@ -1455,6 +1468,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
70379 unsigned long len, unsigned long prot, unsigned long flags,
70380 unsigned long pgoff, unsigned long *populate);
70381 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70382 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70383
70384 #ifdef CONFIG_MMU
70385 extern int __mm_populate(unsigned long addr, unsigned long len,
70386 @@ -1483,10 +1497,11 @@ struct vm_unmapped_area_info {
70387 unsigned long high_limit;
70388 unsigned long align_mask;
70389 unsigned long align_offset;
70390 + unsigned long threadstack_offset;
70391 };
70392
70393 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
70394 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
70395 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
70396 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
70397
70398 /*
70399 * Search for an unmapped address range.
70400 @@ -1498,7 +1513,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
70401 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
70402 */
70403 static inline unsigned long
70404 -vm_unmapped_area(struct vm_unmapped_area_info *info)
70405 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
70406 {
70407 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
70408 return unmapped_area(info);
70409 @@ -1561,6 +1576,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70410 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70411 struct vm_area_struct **pprev);
70412
70413 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70414 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70415 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70416 +
70417 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70418 NULL if none. Assume start_addr < end_addr. */
70419 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70420 @@ -1589,15 +1608,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70421 return vma;
70422 }
70423
70424 -#ifdef CONFIG_MMU
70425 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70426 -#else
70427 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70428 -{
70429 - return __pgprot(0);
70430 -}
70431 -#endif
70432 -
70433 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70434 unsigned long change_prot_numa(struct vm_area_struct *vma,
70435 unsigned long start, unsigned long end);
70436 @@ -1649,6 +1659,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70437 static inline void vm_stat_account(struct mm_struct *mm,
70438 unsigned long flags, struct file *file, long pages)
70439 {
70440 +
70441 +#ifdef CONFIG_PAX_RANDMMAP
70442 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70443 +#endif
70444 +
70445 mm->total_vm += pages;
70446 }
70447 #endif /* CONFIG_PROC_FS */
70448 @@ -1725,7 +1740,7 @@ extern int unpoison_memory(unsigned long pfn);
70449 extern int sysctl_memory_failure_early_kill;
70450 extern int sysctl_memory_failure_recovery;
70451 extern void shake_page(struct page *p, int access);
70452 -extern atomic_long_t num_poisoned_pages;
70453 +extern atomic_long_unchecked_t num_poisoned_pages;
70454 extern int soft_offline_page(struct page *page, int flags);
70455
70456 extern void dump_page(struct page *page);
70457 @@ -1756,5 +1771,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70458 static inline bool page_is_guard(struct page *page) { return false; }
70459 #endif /* CONFIG_DEBUG_PAGEALLOC */
70460
70461 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70462 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70463 +#else
70464 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70465 +#endif
70466 +
70467 #endif /* __KERNEL__ */
70468 #endif /* _LINUX_MM_H */
70469 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70470 index ace9a5f..81bdb59 100644
70471 --- a/include/linux/mm_types.h
70472 +++ b/include/linux/mm_types.h
70473 @@ -289,6 +289,8 @@ struct vm_area_struct {
70474 #ifdef CONFIG_NUMA
70475 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70476 #endif
70477 +
70478 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70479 };
70480
70481 struct core_thread {
70482 @@ -437,6 +439,24 @@ struct mm_struct {
70483 int first_nid;
70484 #endif
70485 struct uprobes_state uprobes_state;
70486 +
70487 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70488 + unsigned long pax_flags;
70489 +#endif
70490 +
70491 +#ifdef CONFIG_PAX_DLRESOLVE
70492 + unsigned long call_dl_resolve;
70493 +#endif
70494 +
70495 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70496 + unsigned long call_syscall;
70497 +#endif
70498 +
70499 +#ifdef CONFIG_PAX_ASLR
70500 + unsigned long delta_mmap; /* randomized offset */
70501 + unsigned long delta_stack; /* randomized offset */
70502 +#endif
70503 +
70504 };
70505
70506 /* first nid will either be a valid NID or one of these values */
70507 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70508 index c5d5278..f0b68c8 100644
70509 --- a/include/linux/mmiotrace.h
70510 +++ b/include/linux/mmiotrace.h
70511 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70512 /* Called from ioremap.c */
70513 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70514 void __iomem *addr);
70515 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70516 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70517
70518 /* For anyone to insert markers. Remember trailing newline. */
70519 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70520 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70521 {
70522 }
70523
70524 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70525 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70526 {
70527 }
70528
70529 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70530 index c74092e..b663967 100644
70531 --- a/include/linux/mmzone.h
70532 +++ b/include/linux/mmzone.h
70533 @@ -396,7 +396,7 @@ struct zone {
70534 unsigned long flags; /* zone flags, see below */
70535
70536 /* Zone statistics */
70537 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70538 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70539
70540 /*
70541 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70542 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70543 index 779cf7c..e6768240 100644
70544 --- a/include/linux/mod_devicetable.h
70545 +++ b/include/linux/mod_devicetable.h
70546 @@ -12,7 +12,7 @@
70547 typedef unsigned long kernel_ulong_t;
70548 #endif
70549
70550 -#define PCI_ANY_ID (~0)
70551 +#define PCI_ANY_ID ((__u16)~0)
70552
70553 struct pci_device_id {
70554 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70555 @@ -138,7 +138,7 @@ struct usb_device_id {
70556 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70557 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70558
70559 -#define HID_ANY_ID (~0)
70560 +#define HID_ANY_ID (~0U)
70561 #define HID_BUS_ANY 0xffff
70562 #define HID_GROUP_ANY 0x0000
70563
70564 @@ -464,7 +464,7 @@ struct dmi_system_id {
70565 const char *ident;
70566 struct dmi_strmatch matches[4];
70567 void *driver_data;
70568 -};
70569 +} __do_const;
70570 /*
70571 * struct dmi_device_id appears during expansion of
70572 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70573 diff --git a/include/linux/module.h b/include/linux/module.h
70574 index ead1b57..81a3b6c 100644
70575 --- a/include/linux/module.h
70576 +++ b/include/linux/module.h
70577 @@ -17,9 +17,11 @@
70578 #include <linux/moduleparam.h>
70579 #include <linux/tracepoint.h>
70580 #include <linux/export.h>
70581 +#include <linux/fs.h>
70582
70583 #include <linux/percpu.h>
70584 #include <asm/module.h>
70585 +#include <asm/pgtable.h>
70586
70587 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70588 #define MODULE_SIG_STRING "~Module signature appended~\n"
70589 @@ -54,12 +56,13 @@ struct module_attribute {
70590 int (*test)(struct module *);
70591 void (*free)(struct module *);
70592 };
70593 +typedef struct module_attribute __no_const module_attribute_no_const;
70594
70595 struct module_version_attribute {
70596 struct module_attribute mattr;
70597 const char *module_name;
70598 const char *version;
70599 -} __attribute__ ((__aligned__(sizeof(void *))));
70600 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70601
70602 extern ssize_t __modver_version_show(struct module_attribute *,
70603 struct module_kobject *, char *);
70604 @@ -232,7 +235,7 @@ struct module
70605
70606 /* Sysfs stuff. */
70607 struct module_kobject mkobj;
70608 - struct module_attribute *modinfo_attrs;
70609 + module_attribute_no_const *modinfo_attrs;
70610 const char *version;
70611 const char *srcversion;
70612 struct kobject *holders_dir;
70613 @@ -281,19 +284,16 @@ struct module
70614 int (*init)(void);
70615
70616 /* If this is non-NULL, vfree after init() returns */
70617 - void *module_init;
70618 + void *module_init_rx, *module_init_rw;
70619
70620 /* Here is the actual code + data, vfree'd on unload. */
70621 - void *module_core;
70622 + void *module_core_rx, *module_core_rw;
70623
70624 /* Here are the sizes of the init and core sections */
70625 - unsigned int init_size, core_size;
70626 + unsigned int init_size_rw, core_size_rw;
70627
70628 /* The size of the executable code in each section. */
70629 - unsigned int init_text_size, core_text_size;
70630 -
70631 - /* Size of RO sections of the module (text+rodata) */
70632 - unsigned int init_ro_size, core_ro_size;
70633 + unsigned int init_size_rx, core_size_rx;
70634
70635 /* Arch-specific module values */
70636 struct mod_arch_specific arch;
70637 @@ -349,6 +349,10 @@ struct module
70638 #ifdef CONFIG_EVENT_TRACING
70639 struct ftrace_event_call **trace_events;
70640 unsigned int num_trace_events;
70641 + struct file_operations trace_id;
70642 + struct file_operations trace_enable;
70643 + struct file_operations trace_format;
70644 + struct file_operations trace_filter;
70645 #endif
70646 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70647 unsigned int num_ftrace_callsites;
70648 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70649 bool is_module_percpu_address(unsigned long addr);
70650 bool is_module_text_address(unsigned long addr);
70651
70652 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70653 +{
70654 +
70655 +#ifdef CONFIG_PAX_KERNEXEC
70656 + if (ktla_ktva(addr) >= (unsigned long)start &&
70657 + ktla_ktva(addr) < (unsigned long)start + size)
70658 + return 1;
70659 +#endif
70660 +
70661 + return ((void *)addr >= start && (void *)addr < start + size);
70662 +}
70663 +
70664 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
70665 +{
70666 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70667 +}
70668 +
70669 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
70670 +{
70671 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70672 +}
70673 +
70674 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
70675 +{
70676 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70677 +}
70678 +
70679 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
70680 +{
70681 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70682 +}
70683 +
70684 static inline int within_module_core(unsigned long addr, const struct module *mod)
70685 {
70686 - return (unsigned long)mod->module_core <= addr &&
70687 - addr < (unsigned long)mod->module_core + mod->core_size;
70688 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70689 }
70690
70691 static inline int within_module_init(unsigned long addr, const struct module *mod)
70692 {
70693 - return (unsigned long)mod->module_init <= addr &&
70694 - addr < (unsigned long)mod->module_init + mod->init_size;
70695 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70696 }
70697
70698 /* Search for module by name: must hold module_mutex. */
70699 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70700 index 560ca53..ef621ef 100644
70701 --- a/include/linux/moduleloader.h
70702 +++ b/include/linux/moduleloader.h
70703 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70704 sections. Returns NULL on failure. */
70705 void *module_alloc(unsigned long size);
70706
70707 +#ifdef CONFIG_PAX_KERNEXEC
70708 +void *module_alloc_exec(unsigned long size);
70709 +#else
70710 +#define module_alloc_exec(x) module_alloc(x)
70711 +#endif
70712 +
70713 /* Free memory returned from module_alloc. */
70714 void module_free(struct module *mod, void *module_region);
70715
70716 +#ifdef CONFIG_PAX_KERNEXEC
70717 +void module_free_exec(struct module *mod, void *module_region);
70718 +#else
70719 +#define module_free_exec(x, y) module_free((x), (y))
70720 +#endif
70721 +
70722 /*
70723 * Apply the given relocation to the (simplified) ELF. Return -error
70724 * or 0.
70725 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70726 unsigned int relsec,
70727 struct module *me)
70728 {
70729 +#ifdef CONFIG_MODULES
70730 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70731 +#endif
70732 return -ENOEXEC;
70733 }
70734 #endif
70735 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70736 unsigned int relsec,
70737 struct module *me)
70738 {
70739 +#ifdef CONFIG_MODULES
70740 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70741 +#endif
70742 return -ENOEXEC;
70743 }
70744 #endif
70745 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70746 index 137b419..fe663ec 100644
70747 --- a/include/linux/moduleparam.h
70748 +++ b/include/linux/moduleparam.h
70749 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70750 * @len is usually just sizeof(string).
70751 */
70752 #define module_param_string(name, string, len, perm) \
70753 - static const struct kparam_string __param_string_##name \
70754 + static const struct kparam_string __param_string_##name __used \
70755 = { len, string }; \
70756 __module_param_call(MODULE_PARAM_PREFIX, name, \
70757 &param_ops_string, \
70758 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70759 */
70760 #define module_param_array_named(name, array, type, nump, perm) \
70761 param_check_##type(name, &(array)[0]); \
70762 - static const struct kparam_array __param_arr_##name \
70763 + static const struct kparam_array __param_arr_##name __used \
70764 = { .max = ARRAY_SIZE(array), .num = nump, \
70765 .ops = &param_ops_##type, \
70766 .elemsize = sizeof(array[0]), .elem = array }; \
70767 diff --git a/include/linux/namei.h b/include/linux/namei.h
70768 index 5a5ff57..5ae5070 100644
70769 --- a/include/linux/namei.h
70770 +++ b/include/linux/namei.h
70771 @@ -19,7 +19,7 @@ struct nameidata {
70772 unsigned seq;
70773 int last_type;
70774 unsigned depth;
70775 - char *saved_names[MAX_NESTED_LINKS + 1];
70776 + const char *saved_names[MAX_NESTED_LINKS + 1];
70777 };
70778
70779 /*
70780 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70781
70782 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70783
70784 -static inline void nd_set_link(struct nameidata *nd, char *path)
70785 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70786 {
70787 nd->saved_names[nd->depth] = path;
70788 }
70789
70790 -static inline char *nd_get_link(struct nameidata *nd)
70791 +static inline const char *nd_get_link(const struct nameidata *nd)
70792 {
70793 return nd->saved_names[nd->depth];
70794 }
70795 diff --git a/include/linux/net.h b/include/linux/net.h
70796 index aa16731..514b875 100644
70797 --- a/include/linux/net.h
70798 +++ b/include/linux/net.h
70799 @@ -183,7 +183,7 @@ struct net_proto_family {
70800 int (*create)(struct net *net, struct socket *sock,
70801 int protocol, int kern);
70802 struct module *owner;
70803 -};
70804 +} __do_const;
70805
70806 struct iovec;
70807 struct kvec;
70808 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70809 index 6151e90..2e0afb0 100644
70810 --- a/include/linux/netdevice.h
70811 +++ b/include/linux/netdevice.h
70812 @@ -1028,6 +1028,7 @@ struct net_device_ops {
70813 int (*ndo_change_carrier)(struct net_device *dev,
70814 bool new_carrier);
70815 };
70816 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70817
70818 /*
70819 * The DEVICE structure.
70820 @@ -1094,7 +1095,7 @@ struct net_device {
70821 int iflink;
70822
70823 struct net_device_stats stats;
70824 - atomic_long_t rx_dropped; /* dropped packets by core network
70825 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70826 * Do not use this in drivers.
70827 */
70828
70829 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70830 index ee14284..bc65d63 100644
70831 --- a/include/linux/netfilter.h
70832 +++ b/include/linux/netfilter.h
70833 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70834 #endif
70835 /* Use the module struct to lock set/get code in place */
70836 struct module *owner;
70837 -};
70838 +} __do_const;
70839
70840 /* Function to register/unregister hook points. */
70841 int nf_register_hook(struct nf_hook_ops *reg);
70842 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70843 index 7958e84..ed74d7a 100644
70844 --- a/include/linux/netfilter/ipset/ip_set.h
70845 +++ b/include/linux/netfilter/ipset/ip_set.h
70846 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70847 /* Return true if "b" set is the same as "a"
70848 * according to the create set parameters */
70849 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70850 -};
70851 +} __do_const;
70852
70853 /* The core set type structure */
70854 struct ip_set_type {
70855 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70856 index ecbb8e4..8a1c4e1 100644
70857 --- a/include/linux/netfilter/nfnetlink.h
70858 +++ b/include/linux/netfilter/nfnetlink.h
70859 @@ -16,7 +16,7 @@ struct nfnl_callback {
70860 const struct nlattr * const cda[]);
70861 const struct nla_policy *policy; /* netlink attribute policy */
70862 const u_int16_t attr_count; /* number of nlattr's */
70863 -};
70864 +} __do_const;
70865
70866 struct nfnetlink_subsystem {
70867 const char *name;
70868 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70869 new file mode 100644
70870 index 0000000..33f4af8
70871 --- /dev/null
70872 +++ b/include/linux/netfilter/xt_gradm.h
70873 @@ -0,0 +1,9 @@
70874 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70875 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70876 +
70877 +struct xt_gradm_mtinfo {
70878 + __u16 flags;
70879 + __u16 invflags;
70880 +};
70881 +
70882 +#endif
70883 diff --git a/include/linux/nls.h b/include/linux/nls.h
70884 index 5dc635f..35f5e11 100644
70885 --- a/include/linux/nls.h
70886 +++ b/include/linux/nls.h
70887 @@ -31,7 +31,7 @@ struct nls_table {
70888 const unsigned char *charset2upper;
70889 struct module *owner;
70890 struct nls_table *next;
70891 -};
70892 +} __do_const;
70893
70894 /* this value hold the maximum octet of charset */
70895 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70896 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70897 index d65746e..62e72c2 100644
70898 --- a/include/linux/notifier.h
70899 +++ b/include/linux/notifier.h
70900 @@ -51,7 +51,8 @@ struct notifier_block {
70901 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70902 struct notifier_block __rcu *next;
70903 int priority;
70904 -};
70905 +} __do_const;
70906 +typedef struct notifier_block __no_const notifier_block_no_const;
70907
70908 struct atomic_notifier_head {
70909 spinlock_t lock;
70910 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70911 index a4c5624..79d6d88 100644
70912 --- a/include/linux/oprofile.h
70913 +++ b/include/linux/oprofile.h
70914 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70915 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70916 char const * name, ulong * val);
70917
70918 -/** Create a file for read-only access to an atomic_t. */
70919 +/** Create a file for read-only access to an atomic_unchecked_t. */
70920 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70921 - char const * name, atomic_t * val);
70922 + char const * name, atomic_unchecked_t * val);
70923
70924 /** create a directory */
70925 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70926 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70927 index 45fc162..01a4068 100644
70928 --- a/include/linux/pci_hotplug.h
70929 +++ b/include/linux/pci_hotplug.h
70930 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70931 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70932 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70933 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70934 -};
70935 +} __do_const;
70936 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70937
70938 /**
70939 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70940 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70941 index 2f522a3..494e45f 100644
70942 --- a/include/linux/perf_event.h
70943 +++ b/include/linux/perf_event.h
70944 @@ -333,8 +333,8 @@ struct perf_event {
70945
70946 enum perf_event_active_state state;
70947 unsigned int attach_state;
70948 - local64_t count;
70949 - atomic64_t child_count;
70950 + local64_t count; /* PaX: fix it one day */
70951 + atomic64_unchecked_t child_count;
70952
70953 /*
70954 * These are the total time in nanoseconds that the event
70955 @@ -385,8 +385,8 @@ struct perf_event {
70956 * These accumulate total time (in nanoseconds) that children
70957 * events have been enabled and running, respectively.
70958 */
70959 - atomic64_t child_total_time_enabled;
70960 - atomic64_t child_total_time_running;
70961 + atomic64_unchecked_t child_total_time_enabled;
70962 + atomic64_unchecked_t child_total_time_running;
70963
70964 /*
70965 * Protect attach/detach and child_list:
70966 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
70967 entry->ip[entry->nr++] = ip;
70968 }
70969
70970 -extern int sysctl_perf_event_paranoid;
70971 +extern int sysctl_perf_event_legitimately_concerned;
70972 extern int sysctl_perf_event_mlock;
70973 extern int sysctl_perf_event_sample_rate;
70974
70975 @@ -711,19 +711,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
70976 void __user *buffer, size_t *lenp,
70977 loff_t *ppos);
70978
70979 +static inline bool perf_paranoid_any(void)
70980 +{
70981 + return sysctl_perf_event_legitimately_concerned > 2;
70982 +}
70983 +
70984 static inline bool perf_paranoid_tracepoint_raw(void)
70985 {
70986 - return sysctl_perf_event_paranoid > -1;
70987 + return sysctl_perf_event_legitimately_concerned > -1;
70988 }
70989
70990 static inline bool perf_paranoid_cpu(void)
70991 {
70992 - return sysctl_perf_event_paranoid > 0;
70993 + return sysctl_perf_event_legitimately_concerned > 0;
70994 }
70995
70996 static inline bool perf_paranoid_kernel(void)
70997 {
70998 - return sysctl_perf_event_paranoid > 1;
70999 + return sysctl_perf_event_legitimately_concerned > 1;
71000 }
71001
71002 extern void perf_event_init(void);
71003 @@ -811,7 +816,7 @@ static inline void perf_restore_debug_store(void) { }
71004 */
71005 #define perf_cpu_notifier(fn) \
71006 do { \
71007 - static struct notifier_block fn##_nb __cpuinitdata = \
71008 + static struct notifier_block fn##_nb = \
71009 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
71010 unsigned long cpu = smp_processor_id(); \
71011 unsigned long flags; \
71012 @@ -830,7 +835,7 @@ do { \
71013 struct perf_pmu_events_attr {
71014 struct device_attribute attr;
71015 u64 id;
71016 -};
71017 +} __do_const;
71018
71019 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
71020 static struct perf_pmu_events_attr _var = { \
71021 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
71022 index ad1a427..6419649 100644
71023 --- a/include/linux/pipe_fs_i.h
71024 +++ b/include/linux/pipe_fs_i.h
71025 @@ -45,9 +45,9 @@ struct pipe_buffer {
71026 struct pipe_inode_info {
71027 wait_queue_head_t wait;
71028 unsigned int nrbufs, curbuf, buffers;
71029 - unsigned int readers;
71030 - unsigned int writers;
71031 - unsigned int waiting_writers;
71032 + atomic_t readers;
71033 + atomic_t writers;
71034 + atomic_t waiting_writers;
71035 unsigned int r_counter;
71036 unsigned int w_counter;
71037 struct page *tmp_page;
71038 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
71039 index 5f28cae..3d23723 100644
71040 --- a/include/linux/platform_data/usb-ehci-s5p.h
71041 +++ b/include/linux/platform_data/usb-ehci-s5p.h
71042 @@ -14,7 +14,7 @@
71043 struct s5p_ehci_platdata {
71044 int (*phy_init)(struct platform_device *pdev, int type);
71045 int (*phy_exit)(struct platform_device *pdev, int type);
71046 -};
71047 +} __no_const;
71048
71049 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
71050
71051 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
71052 index c256c59..8ea94c7 100644
71053 --- a/include/linux/platform_data/usb-exynos.h
71054 +++ b/include/linux/platform_data/usb-exynos.h
71055 @@ -14,7 +14,7 @@
71056 struct exynos4_ohci_platdata {
71057 int (*phy_init)(struct platform_device *pdev, int type);
71058 int (*phy_exit)(struct platform_device *pdev, int type);
71059 -};
71060 +} __no_const;
71061
71062 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
71063
71064 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
71065 index 7c1d252..c5c773e 100644
71066 --- a/include/linux/pm_domain.h
71067 +++ b/include/linux/pm_domain.h
71068 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
71069
71070 struct gpd_cpu_data {
71071 unsigned int saved_exit_latency;
71072 - struct cpuidle_state *idle_state;
71073 + cpuidle_state_no_const *idle_state;
71074 };
71075
71076 struct generic_pm_domain {
71077 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
71078 index 7d7e09e..8671ef8 100644
71079 --- a/include/linux/pm_runtime.h
71080 +++ b/include/linux/pm_runtime.h
71081 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
71082
71083 static inline void pm_runtime_mark_last_busy(struct device *dev)
71084 {
71085 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
71086 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
71087 }
71088
71089 #else /* !CONFIG_PM_RUNTIME */
71090 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
71091 index 195aafc..49a7bc2 100644
71092 --- a/include/linux/pnp.h
71093 +++ b/include/linux/pnp.h
71094 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
71095 struct pnp_fixup {
71096 char id[7];
71097 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
71098 -};
71099 +} __do_const;
71100
71101 /* config parameters */
71102 #define PNP_CONFIG_NORMAL 0x0001
71103 diff --git a/include/linux/poison.h b/include/linux/poison.h
71104 index 2110a81..13a11bb 100644
71105 --- a/include/linux/poison.h
71106 +++ b/include/linux/poison.h
71107 @@ -19,8 +19,8 @@
71108 * under normal circumstances, used to verify that nobody uses
71109 * non-initialized list entries.
71110 */
71111 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
71112 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
71113 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
71114 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
71115
71116 /********** include/linux/timer.h **********/
71117 /*
71118 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71119 index c0f44c2..1572583 100644
71120 --- a/include/linux/power/smartreflex.h
71121 +++ b/include/linux/power/smartreflex.h
71122 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71123 int (*notify)(struct omap_sr *sr, u32 status);
71124 u8 notify_flags;
71125 u8 class_type;
71126 -};
71127 +} __do_const;
71128
71129 /**
71130 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71131 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71132 index 4ea1d37..80f4b33 100644
71133 --- a/include/linux/ppp-comp.h
71134 +++ b/include/linux/ppp-comp.h
71135 @@ -84,7 +84,7 @@ struct compressor {
71136 struct module *owner;
71137 /* Extra skb space needed by the compressor algorithm */
71138 unsigned int comp_extra;
71139 -};
71140 +} __do_const;
71141
71142 /*
71143 * The return value from decompress routine is the length of the
71144 diff --git a/include/linux/printk.h b/include/linux/printk.h
71145 index 822171f..12b30e8 100644
71146 --- a/include/linux/printk.h
71147 +++ b/include/linux/printk.h
71148 @@ -98,6 +98,8 @@ int no_printk(const char *fmt, ...)
71149 extern asmlinkage __printf(1, 2)
71150 void early_printk(const char *fmt, ...);
71151
71152 +extern int kptr_restrict;
71153 +
71154 #ifdef CONFIG_PRINTK
71155 asmlinkage __printf(5, 0)
71156 int vprintk_emit(int facility, int level,
71157 @@ -132,7 +134,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71158
71159 extern int printk_delay_msec;
71160 extern int dmesg_restrict;
71161 -extern int kptr_restrict;
71162
71163 extern void wake_up_klogd(void);
71164
71165 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71166 index 94dfb2a..88b9d3b 100644
71167 --- a/include/linux/proc_fs.h
71168 +++ b/include/linux/proc_fs.h
71169 @@ -165,6 +165,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
71170 return proc_create_data(name, mode, parent, proc_fops, NULL);
71171 }
71172
71173 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71174 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71175 +{
71176 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71177 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71178 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71179 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71180 +#else
71181 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71182 +#endif
71183 +}
71184 +
71185 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
71186 umode_t mode, struct proc_dir_entry *base,
71187 read_proc_t *read_proc, void * data)
71188 @@ -266,7 +278,7 @@ struct proc_ns_operations {
71189 void (*put)(void *ns);
71190 int (*install)(struct nsproxy *nsproxy, void *ns);
71191 unsigned int (*inum)(void *ns);
71192 -};
71193 +} __do_const;
71194 extern const struct proc_ns_operations netns_operations;
71195 extern const struct proc_ns_operations utsns_operations;
71196 extern const struct proc_ns_operations ipcns_operations;
71197 diff --git a/include/linux/random.h b/include/linux/random.h
71198 index 347ce55..880f97c 100644
71199 --- a/include/linux/random.h
71200 +++ b/include/linux/random.h
71201 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
71202 u32 prandom_u32_state(struct rnd_state *);
71203 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71204
71205 +static inline unsigned long pax_get_random_long(void)
71206 +{
71207 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71208 +}
71209 +
71210 /*
71211 * Handle minimum values for seeds
71212 */
71213 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71214 index 8089e35..3a0d59a 100644
71215 --- a/include/linux/rculist.h
71216 +++ b/include/linux/rculist.h
71217 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71218 struct list_head *prev, struct list_head *next);
71219 #endif
71220
71221 +extern void __pax_list_add_rcu(struct list_head *new,
71222 + struct list_head *prev, struct list_head *next);
71223 +
71224 /**
71225 * list_add_rcu - add a new entry to rcu-protected list
71226 * @new: new entry to be added
71227 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71228 __list_add_rcu(new, head, head->next);
71229 }
71230
71231 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71232 +{
71233 + __pax_list_add_rcu(new, head, head->next);
71234 +}
71235 +
71236 /**
71237 * list_add_tail_rcu - add a new entry to rcu-protected list
71238 * @new: new entry to be added
71239 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71240 __list_add_rcu(new, head->prev, head);
71241 }
71242
71243 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71244 + struct list_head *head)
71245 +{
71246 + __pax_list_add_rcu(new, head->prev, head);
71247 +}
71248 +
71249 /**
71250 * list_del_rcu - deletes entry from list without re-initialization
71251 * @entry: the element to delete from the list.
71252 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71253 entry->prev = LIST_POISON2;
71254 }
71255
71256 +extern void pax_list_del_rcu(struct list_head *entry);
71257 +
71258 /**
71259 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71260 * @n: the element to delete from the hash list.
71261 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71262 index 23b3630..e1bc12b 100644
71263 --- a/include/linux/reboot.h
71264 +++ b/include/linux/reboot.h
71265 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71266 * Architecture-specific implementations of sys_reboot commands.
71267 */
71268
71269 -extern void machine_restart(char *cmd);
71270 -extern void machine_halt(void);
71271 -extern void machine_power_off(void);
71272 +extern void machine_restart(char *cmd) __noreturn;
71273 +extern void machine_halt(void) __noreturn;
71274 +extern void machine_power_off(void) __noreturn;
71275
71276 extern void machine_shutdown(void);
71277 struct pt_regs;
71278 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71279 */
71280
71281 extern void kernel_restart_prepare(char *cmd);
71282 -extern void kernel_restart(char *cmd);
71283 -extern void kernel_halt(void);
71284 -extern void kernel_power_off(void);
71285 +extern void kernel_restart(char *cmd) __noreturn;
71286 +extern void kernel_halt(void) __noreturn;
71287 +extern void kernel_power_off(void) __noreturn;
71288
71289 extern int C_A_D; /* for sysctl */
71290 void ctrl_alt_del(void);
71291 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71292 * Emergency restart, callable from an interrupt handler.
71293 */
71294
71295 -extern void emergency_restart(void);
71296 +extern void emergency_restart(void) __noreturn;
71297 #include <asm/emergency-restart.h>
71298
71299 #endif /* _LINUX_REBOOT_H */
71300 diff --git a/include/linux/regset.h b/include/linux/regset.h
71301 index 8e0c9fe..ac4d221 100644
71302 --- a/include/linux/regset.h
71303 +++ b/include/linux/regset.h
71304 @@ -161,7 +161,8 @@ struct user_regset {
71305 unsigned int align;
71306 unsigned int bias;
71307 unsigned int core_note_type;
71308 -};
71309 +} __do_const;
71310 +typedef struct user_regset __no_const user_regset_no_const;
71311
71312 /**
71313 * struct user_regset_view - available regsets
71314 diff --git a/include/linux/relay.h b/include/linux/relay.h
71315 index 91cacc3..b55ff74 100644
71316 --- a/include/linux/relay.h
71317 +++ b/include/linux/relay.h
71318 @@ -160,7 +160,7 @@ struct rchan_callbacks
71319 * The callback should return 0 if successful, negative if not.
71320 */
71321 int (*remove_buf_file)(struct dentry *dentry);
71322 -};
71323 +} __no_const;
71324
71325 /*
71326 * CONFIG_RELAY kernel API, kernel/relay.c
71327 diff --git a/include/linux/rio.h b/include/linux/rio.h
71328 index a3e7842..d973ca6 100644
71329 --- a/include/linux/rio.h
71330 +++ b/include/linux/rio.h
71331 @@ -339,7 +339,7 @@ struct rio_ops {
71332 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71333 u64 rstart, u32 size, u32 flags);
71334 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71335 -};
71336 +} __no_const;
71337
71338 #define RIO_RESOURCE_MEM 0x00000100
71339 #define RIO_RESOURCE_DOORBELL 0x00000200
71340 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71341 index 6dacb93..6174423 100644
71342 --- a/include/linux/rmap.h
71343 +++ b/include/linux/rmap.h
71344 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71345 void anon_vma_init(void); /* create anon_vma_cachep */
71346 int anon_vma_prepare(struct vm_area_struct *);
71347 void unlink_anon_vmas(struct vm_area_struct *);
71348 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71349 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71350 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71351 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71352
71353 static inline void anon_vma_merge(struct vm_area_struct *vma,
71354 struct vm_area_struct *next)
71355 diff --git a/include/linux/sched.h b/include/linux/sched.h
71356 index be4e742..7f9d593 100644
71357 --- a/include/linux/sched.h
71358 +++ b/include/linux/sched.h
71359 @@ -62,6 +62,7 @@ struct bio_list;
71360 struct fs_struct;
71361 struct perf_event_context;
71362 struct blk_plug;
71363 +struct linux_binprm;
71364
71365 /*
71366 * List of flags we want to share for kernel threads,
71367 @@ -315,7 +316,7 @@ extern char __sched_text_start[], __sched_text_end[];
71368 extern int in_sched_functions(unsigned long addr);
71369
71370 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71371 -extern signed long schedule_timeout(signed long timeout);
71372 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71373 extern signed long schedule_timeout_interruptible(signed long timeout);
71374 extern signed long schedule_timeout_killable(signed long timeout);
71375 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71376 @@ -329,6 +330,18 @@ struct user_namespace;
71377 #include <linux/aio.h>
71378
71379 #ifdef CONFIG_MMU
71380 +
71381 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71382 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71383 +#else
71384 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71385 +{
71386 + return 0;
71387 +}
71388 +#endif
71389 +
71390 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71391 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71392 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71393 extern unsigned long
71394 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71395 @@ -605,6 +618,17 @@ struct signal_struct {
71396 #ifdef CONFIG_TASKSTATS
71397 struct taskstats *stats;
71398 #endif
71399 +
71400 +#ifdef CONFIG_GRKERNSEC
71401 + u32 curr_ip;
71402 + u32 saved_ip;
71403 + u32 gr_saddr;
71404 + u32 gr_daddr;
71405 + u16 gr_sport;
71406 + u16 gr_dport;
71407 + u8 used_accept:1;
71408 +#endif
71409 +
71410 #ifdef CONFIG_AUDIT
71411 unsigned audit_tty;
71412 struct tty_audit_buf *tty_audit_buf;
71413 @@ -683,6 +707,11 @@ struct user_struct {
71414 struct key *session_keyring; /* UID's default session keyring */
71415 #endif
71416
71417 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71418 + unsigned int banned;
71419 + unsigned long ban_expires;
71420 +#endif
71421 +
71422 /* Hash table maintenance information */
71423 struct hlist_node uidhash_node;
71424 kuid_t uid;
71425 @@ -1082,7 +1111,7 @@ struct sched_class {
71426 #ifdef CONFIG_FAIR_GROUP_SCHED
71427 void (*task_move_group) (struct task_struct *p, int on_rq);
71428 #endif
71429 -};
71430 +} __do_const;
71431
71432 struct load_weight {
71433 unsigned long weight, inv_weight;
71434 @@ -1323,8 +1352,8 @@ struct task_struct {
71435 struct list_head thread_group;
71436
71437 struct completion *vfork_done; /* for vfork() */
71438 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71439 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71440 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71441 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71442
71443 cputime_t utime, stime, utimescaled, stimescaled;
71444 cputime_t gtime;
71445 @@ -1349,11 +1378,6 @@ struct task_struct {
71446 struct task_cputime cputime_expires;
71447 struct list_head cpu_timers[3];
71448
71449 -/* process credentials */
71450 - const struct cred __rcu *real_cred; /* objective and real subjective task
71451 - * credentials (COW) */
71452 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71453 - * credentials (COW) */
71454 char comm[TASK_COMM_LEN]; /* executable name excluding path
71455 - access with [gs]et_task_comm (which lock
71456 it with task_lock())
71457 @@ -1370,6 +1394,10 @@ struct task_struct {
71458 #endif
71459 /* CPU-specific state of this task */
71460 struct thread_struct thread;
71461 +/* thread_info moved to task_struct */
71462 +#ifdef CONFIG_X86
71463 + struct thread_info tinfo;
71464 +#endif
71465 /* filesystem information */
71466 struct fs_struct *fs;
71467 /* open file information */
71468 @@ -1443,6 +1471,10 @@ struct task_struct {
71469 gfp_t lockdep_reclaim_gfp;
71470 #endif
71471
71472 +/* process credentials */
71473 + const struct cred __rcu *real_cred; /* objective and real subjective task
71474 + * credentials (COW) */
71475 +
71476 /* journalling filesystem info */
71477 void *journal_info;
71478
71479 @@ -1481,6 +1513,10 @@ struct task_struct {
71480 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71481 struct list_head cg_list;
71482 #endif
71483 +
71484 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71485 + * credentials (COW) */
71486 +
71487 #ifdef CONFIG_FUTEX
71488 struct robust_list_head __user *robust_list;
71489 #ifdef CONFIG_COMPAT
71490 @@ -1577,8 +1613,74 @@ struct task_struct {
71491 #ifdef CONFIG_UPROBES
71492 struct uprobe_task *utask;
71493 #endif
71494 +
71495 +#ifdef CONFIG_GRKERNSEC
71496 + /* grsecurity */
71497 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71498 + u64 exec_id;
71499 +#endif
71500 +#ifdef CONFIG_GRKERNSEC_SETXID
71501 + const struct cred *delayed_cred;
71502 +#endif
71503 + struct dentry *gr_chroot_dentry;
71504 + struct acl_subject_label *acl;
71505 + struct acl_role_label *role;
71506 + struct file *exec_file;
71507 + unsigned long brute_expires;
71508 + u16 acl_role_id;
71509 + /* is this the task that authenticated to the special role */
71510 + u8 acl_sp_role;
71511 + u8 is_writable;
71512 + u8 brute;
71513 + u8 gr_is_chrooted;
71514 +#endif
71515 +
71516 };
71517
71518 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71519 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71520 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71521 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71522 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71523 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71524 +
71525 +#ifdef CONFIG_PAX_SOFTMODE
71526 +extern int pax_softmode;
71527 +#endif
71528 +
71529 +extern int pax_check_flags(unsigned long *);
71530 +
71531 +/* if tsk != current then task_lock must be held on it */
71532 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71533 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71534 +{
71535 + if (likely(tsk->mm))
71536 + return tsk->mm->pax_flags;
71537 + else
71538 + return 0UL;
71539 +}
71540 +
71541 +/* if tsk != current then task_lock must be held on it */
71542 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71543 +{
71544 + if (likely(tsk->mm)) {
71545 + tsk->mm->pax_flags = flags;
71546 + return 0;
71547 + }
71548 + return -EINVAL;
71549 +}
71550 +#endif
71551 +
71552 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71553 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71554 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71555 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71556 +#endif
71557 +
71558 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71559 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71560 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71561 +
71562 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71563 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71564
71565 @@ -1637,7 +1739,7 @@ struct pid_namespace;
71566 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71567 struct pid_namespace *ns);
71568
71569 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71570 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71571 {
71572 return tsk->pid;
71573 }
71574 @@ -2073,7 +2175,9 @@ void yield(void);
71575 extern struct exec_domain default_exec_domain;
71576
71577 union thread_union {
71578 +#ifndef CONFIG_X86
71579 struct thread_info thread_info;
71580 +#endif
71581 unsigned long stack[THREAD_SIZE/sizeof(long)];
71582 };
71583
71584 @@ -2106,6 +2210,7 @@ extern struct pid_namespace init_pid_ns;
71585 */
71586
71587 extern struct task_struct *find_task_by_vpid(pid_t nr);
71588 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71589 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71590 struct pid_namespace *ns);
71591
71592 @@ -2272,7 +2377,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71593 extern void exit_itimers(struct signal_struct *);
71594 extern void flush_itimer_signals(void);
71595
71596 -extern void do_group_exit(int);
71597 +extern __noreturn void do_group_exit(int);
71598
71599 extern int allow_signal(int);
71600 extern int disallow_signal(int);
71601 @@ -2463,9 +2568,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71602
71603 #endif
71604
71605 -static inline int object_is_on_stack(void *obj)
71606 +static inline int object_starts_on_stack(void *obj)
71607 {
71608 - void *stack = task_stack_page(current);
71609 + const void *stack = task_stack_page(current);
71610
71611 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71612 }
71613 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
71614 index bf8086b..962b035 100644
71615 --- a/include/linux/sched/sysctl.h
71616 +++ b/include/linux/sched/sysctl.h
71617 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
71618 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71619
71620 extern int sysctl_max_map_count;
71621 +extern unsigned long sysctl_heap_stack_gap;
71622
71623 extern unsigned int sysctl_sched_latency;
71624 extern unsigned int sysctl_sched_min_granularity;
71625 diff --git a/include/linux/security.h b/include/linux/security.h
71626 index 032c366..2c1c2dc2 100644
71627 --- a/include/linux/security.h
71628 +++ b/include/linux/security.h
71629 @@ -26,6 +26,7 @@
71630 #include <linux/capability.h>
71631 #include <linux/slab.h>
71632 #include <linux/err.h>
71633 +#include <linux/grsecurity.h>
71634
71635 struct linux_binprm;
71636 struct cred;
71637 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71638 index 68a04a3..866e6a1 100644
71639 --- a/include/linux/seq_file.h
71640 +++ b/include/linux/seq_file.h
71641 @@ -26,6 +26,9 @@ struct seq_file {
71642 struct mutex lock;
71643 const struct seq_operations *op;
71644 int poll_event;
71645 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71646 + u64 exec_id;
71647 +#endif
71648 #ifdef CONFIG_USER_NS
71649 struct user_namespace *user_ns;
71650 #endif
71651 @@ -38,6 +41,7 @@ struct seq_operations {
71652 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71653 int (*show) (struct seq_file *m, void *v);
71654 };
71655 +typedef struct seq_operations __no_const seq_operations_no_const;
71656
71657 #define SEQ_SKIP 1
71658
71659 diff --git a/include/linux/shm.h b/include/linux/shm.h
71660 index 429c199..4d42e38 100644
71661 --- a/include/linux/shm.h
71662 +++ b/include/linux/shm.h
71663 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71664
71665 /* The task created the shm object. NULL if the task is dead. */
71666 struct task_struct *shm_creator;
71667 +#ifdef CONFIG_GRKERNSEC
71668 + time_t shm_createtime;
71669 + pid_t shm_lapid;
71670 +#endif
71671 };
71672
71673 /* shm_mode upper byte flags */
71674 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71675 index 1f2803c..4858a3d 100644
71676 --- a/include/linux/skbuff.h
71677 +++ b/include/linux/skbuff.h
71678 @@ -599,7 +599,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71679 extern struct sk_buff *__alloc_skb(unsigned int size,
71680 gfp_t priority, int flags, int node);
71681 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71682 -static inline struct sk_buff *alloc_skb(unsigned int size,
71683 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71684 gfp_t priority)
71685 {
71686 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71687 @@ -709,7 +709,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71688 */
71689 static inline int skb_queue_empty(const struct sk_buff_head *list)
71690 {
71691 - return list->next == (struct sk_buff *)list;
71692 + return list->next == (const struct sk_buff *)list;
71693 }
71694
71695 /**
71696 @@ -722,7 +722,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71697 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71698 const struct sk_buff *skb)
71699 {
71700 - return skb->next == (struct sk_buff *)list;
71701 + return skb->next == (const struct sk_buff *)list;
71702 }
71703
71704 /**
71705 @@ -735,7 +735,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71706 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71707 const struct sk_buff *skb)
71708 {
71709 - return skb->prev == (struct sk_buff *)list;
71710 + return skb->prev == (const struct sk_buff *)list;
71711 }
71712
71713 /**
71714 @@ -1756,7 +1756,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71715 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71716 */
71717 #ifndef NET_SKB_PAD
71718 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71719 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71720 #endif
71721
71722 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71723 @@ -2351,7 +2351,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71724 int noblock, int *err);
71725 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71726 struct poll_table_struct *wait);
71727 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71728 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71729 int offset, struct iovec *to,
71730 int size);
71731 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71732 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
71733 nf_bridge_put(skb->nf_bridge);
71734 skb->nf_bridge = NULL;
71735 #endif
71736 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71737 + skb->nf_trace = 0;
71738 +#endif
71739 }
71740
71741 static inline void nf_reset_trace(struct sk_buff *skb)
71742 diff --git a/include/linux/slab.h b/include/linux/slab.h
71743 index 5d168d7..720bff3 100644
71744 --- a/include/linux/slab.h
71745 +++ b/include/linux/slab.h
71746 @@ -12,13 +12,20 @@
71747 #include <linux/gfp.h>
71748 #include <linux/types.h>
71749 #include <linux/workqueue.h>
71750 -
71751 +#include <linux/err.h>
71752
71753 /*
71754 * Flags to pass to kmem_cache_create().
71755 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71756 */
71757 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71758 +
71759 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71760 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71761 +#else
71762 +#define SLAB_USERCOPY 0x00000000UL
71763 +#endif
71764 +
71765 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71766 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71767 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71768 @@ -89,10 +96,13 @@
71769 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71770 * Both make kfree a no-op.
71771 */
71772 -#define ZERO_SIZE_PTR ((void *)16)
71773 +#define ZERO_SIZE_PTR \
71774 +({ \
71775 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71776 + (void *)(-MAX_ERRNO-1L); \
71777 +})
71778
71779 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71780 - (unsigned long)ZERO_SIZE_PTR)
71781 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71782
71783 /*
71784 * Common fields provided in kmem_cache by all slab allocators
71785 @@ -112,7 +122,7 @@ struct kmem_cache {
71786 unsigned int align; /* Alignment as calculated */
71787 unsigned long flags; /* Active flags on the slab */
71788 const char *name; /* Slab name for sysfs */
71789 - int refcount; /* Use counter */
71790 + atomic_t refcount; /* Use counter */
71791 void (*ctor)(void *); /* Called on object slot creation */
71792 struct list_head list; /* List of all slab caches on the system */
71793 };
71794 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71795 void kfree(const void *);
71796 void kzfree(const void *);
71797 size_t ksize(const void *);
71798 +const char *check_heap_object(const void *ptr, unsigned long n);
71799 +bool is_usercopy_object(const void *ptr);
71800
71801 /*
71802 * Allocator specific definitions. These are mainly used to establish optimized
71803 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71804 * for general use, and so are not documented here. For a full list of
71805 * potential flags, always refer to linux/gfp.h.
71806 */
71807 +
71808 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71809 {
71810 if (size != 0 && n > SIZE_MAX / size)
71811 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71812 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71813 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71814 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71815 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71816 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71817 #define kmalloc_track_caller(size, flags) \
71818 __kmalloc_track_caller(size, flags, _RET_IP_)
71819 #else
71820 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71821 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71822 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71823 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71824 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71825 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71826 #define kmalloc_node_track_caller(size, flags, node) \
71827 __kmalloc_node_track_caller(size, flags, node, \
71828 _RET_IP_)
71829 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71830 index 8bb6e0e..8eb0dbe 100644
71831 --- a/include/linux/slab_def.h
71832 +++ b/include/linux/slab_def.h
71833 @@ -52,7 +52,7 @@ struct kmem_cache {
71834 /* 4) cache creation/removal */
71835 const char *name;
71836 struct list_head list;
71837 - int refcount;
71838 + atomic_t refcount;
71839 int object_size;
71840 int align;
71841
71842 @@ -68,10 +68,10 @@ struct kmem_cache {
71843 unsigned long node_allocs;
71844 unsigned long node_frees;
71845 unsigned long node_overflow;
71846 - atomic_t allochit;
71847 - atomic_t allocmiss;
71848 - atomic_t freehit;
71849 - atomic_t freemiss;
71850 + atomic_unchecked_t allochit;
71851 + atomic_unchecked_t allocmiss;
71852 + atomic_unchecked_t freehit;
71853 + atomic_unchecked_t freemiss;
71854
71855 /*
71856 * If debugging is enabled, then the allocator can add additional
71857 @@ -111,11 +111,16 @@ struct cache_sizes {
71858 #ifdef CONFIG_ZONE_DMA
71859 struct kmem_cache *cs_dmacachep;
71860 #endif
71861 +
71862 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71863 + struct kmem_cache *cs_usercopycachep;
71864 +#endif
71865 +
71866 };
71867 extern struct cache_sizes malloc_sizes[];
71868
71869 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71870 -void *__kmalloc(size_t size, gfp_t flags);
71871 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71872
71873 #ifdef CONFIG_TRACING
71874 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71875 @@ -152,6 +157,13 @@ found:
71876 cachep = malloc_sizes[i].cs_dmacachep;
71877 else
71878 #endif
71879 +
71880 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71881 + if (flags & GFP_USERCOPY)
71882 + cachep = malloc_sizes[i].cs_usercopycachep;
71883 + else
71884 +#endif
71885 +
71886 cachep = malloc_sizes[i].cs_cachep;
71887
71888 ret = kmem_cache_alloc_trace(cachep, flags, size);
71889 @@ -162,7 +174,7 @@ found:
71890 }
71891
71892 #ifdef CONFIG_NUMA
71893 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71894 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71895 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71896
71897 #ifdef CONFIG_TRACING
71898 @@ -205,6 +217,13 @@ found:
71899 cachep = malloc_sizes[i].cs_dmacachep;
71900 else
71901 #endif
71902 +
71903 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71904 + if (flags & GFP_USERCOPY)
71905 + cachep = malloc_sizes[i].cs_usercopycachep;
71906 + else
71907 +#endif
71908 +
71909 cachep = malloc_sizes[i].cs_cachep;
71910
71911 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71912 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71913 index f28e14a..7831211 100644
71914 --- a/include/linux/slob_def.h
71915 +++ b/include/linux/slob_def.h
71916 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71917 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71918 }
71919
71920 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71921 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71922
71923 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71924 {
71925 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71926 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71927 }
71928
71929 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71930 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71931 {
71932 return kmalloc(size, flags);
71933 }
71934 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71935 index 9db4825..ed42fb5 100644
71936 --- a/include/linux/slub_def.h
71937 +++ b/include/linux/slub_def.h
71938 @@ -91,7 +91,7 @@ struct kmem_cache {
71939 struct kmem_cache_order_objects max;
71940 struct kmem_cache_order_objects min;
71941 gfp_t allocflags; /* gfp flags to use on each alloc */
71942 - int refcount; /* Refcount for slab cache destroy */
71943 + atomic_t refcount; /* Refcount for slab cache destroy */
71944 void (*ctor)(void *);
71945 int inuse; /* Offset to metadata */
71946 int align; /* Alignment */
71947 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71948 * Sorry that the following has to be that ugly but some versions of GCC
71949 * have trouble with constant propagation and loops.
71950 */
71951 -static __always_inline int kmalloc_index(size_t size)
71952 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71953 {
71954 if (!size)
71955 return 0;
71956 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71957 }
71958
71959 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71960 -void *__kmalloc(size_t size, gfp_t flags);
71961 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71962
71963 static __always_inline void *
71964 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71965 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71966 }
71967 #endif
71968
71969 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71970 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71971 {
71972 unsigned int order = get_order(size);
71973 return kmalloc_order_trace(size, flags, order);
71974 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71975 }
71976
71977 #ifdef CONFIG_NUMA
71978 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71979 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71980 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71981
71982 #ifdef CONFIG_TRACING
71983 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71984 index e8d702e..0a56eb4 100644
71985 --- a/include/linux/sock_diag.h
71986 +++ b/include/linux/sock_diag.h
71987 @@ -10,7 +10,7 @@ struct sock;
71988 struct sock_diag_handler {
71989 __u8 family;
71990 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71991 -};
71992 +} __do_const;
71993
71994 int sock_diag_register(const struct sock_diag_handler *h);
71995 void sock_diag_unregister(const struct sock_diag_handler *h);
71996 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71997 index 680f9a3..f13aeb0 100644
71998 --- a/include/linux/sonet.h
71999 +++ b/include/linux/sonet.h
72000 @@ -7,7 +7,7 @@
72001 #include <uapi/linux/sonet.h>
72002
72003 struct k_sonet_stats {
72004 -#define __HANDLE_ITEM(i) atomic_t i
72005 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72006 __SONET_ITEMS
72007 #undef __HANDLE_ITEM
72008 };
72009 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
72010 index 07d8e53..dc934c9 100644
72011 --- a/include/linux/sunrpc/addr.h
72012 +++ b/include/linux/sunrpc/addr.h
72013 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
72014 {
72015 switch (sap->sa_family) {
72016 case AF_INET:
72017 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
72018 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
72019 case AF_INET6:
72020 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
72021 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
72022 }
72023 return 0;
72024 }
72025 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
72026 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
72027 const struct sockaddr *src)
72028 {
72029 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
72030 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
72031 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
72032
72033 dsin->sin_family = ssin->sin_family;
72034 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
72035 if (sa->sa_family != AF_INET6)
72036 return 0;
72037
72038 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
72039 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
72040 }
72041
72042 #endif /* _LINUX_SUNRPC_ADDR_H */
72043 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
72044 index 2cf4ffa..470d140 100644
72045 --- a/include/linux/sunrpc/clnt.h
72046 +++ b/include/linux/sunrpc/clnt.h
72047 @@ -96,7 +96,7 @@ struct rpc_procinfo {
72048 unsigned int p_timer; /* Which RTT timer to use */
72049 u32 p_statidx; /* Which procedure to account */
72050 const char * p_name; /* name of procedure */
72051 -};
72052 +} __do_const;
72053
72054 #ifdef __KERNEL__
72055
72056 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
72057 index 1f0216b..6a4fa50 100644
72058 --- a/include/linux/sunrpc/svc.h
72059 +++ b/include/linux/sunrpc/svc.h
72060 @@ -411,7 +411,7 @@ struct svc_procedure {
72061 unsigned int pc_count; /* call count */
72062 unsigned int pc_cachetype; /* cache info (NFS) */
72063 unsigned int pc_xdrressize; /* maximum size of XDR reply */
72064 -};
72065 +} __do_const;
72066
72067 /*
72068 * Function prototypes.
72069 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
72070 index 0b8e3e6..33e0a01 100644
72071 --- a/include/linux/sunrpc/svc_rdma.h
72072 +++ b/include/linux/sunrpc/svc_rdma.h
72073 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
72074 extern unsigned int svcrdma_max_requests;
72075 extern unsigned int svcrdma_max_req_size;
72076
72077 -extern atomic_t rdma_stat_recv;
72078 -extern atomic_t rdma_stat_read;
72079 -extern atomic_t rdma_stat_write;
72080 -extern atomic_t rdma_stat_sq_starve;
72081 -extern atomic_t rdma_stat_rq_starve;
72082 -extern atomic_t rdma_stat_rq_poll;
72083 -extern atomic_t rdma_stat_rq_prod;
72084 -extern atomic_t rdma_stat_sq_poll;
72085 -extern atomic_t rdma_stat_sq_prod;
72086 +extern atomic_unchecked_t rdma_stat_recv;
72087 +extern atomic_unchecked_t rdma_stat_read;
72088 +extern atomic_unchecked_t rdma_stat_write;
72089 +extern atomic_unchecked_t rdma_stat_sq_starve;
72090 +extern atomic_unchecked_t rdma_stat_rq_starve;
72091 +extern atomic_unchecked_t rdma_stat_rq_poll;
72092 +extern atomic_unchecked_t rdma_stat_rq_prod;
72093 +extern atomic_unchecked_t rdma_stat_sq_poll;
72094 +extern atomic_unchecked_t rdma_stat_sq_prod;
72095
72096 #define RPCRDMA_VERSION 1
72097
72098 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
72099 index ff374ab..7fd2ecb 100644
72100 --- a/include/linux/sunrpc/svcauth.h
72101 +++ b/include/linux/sunrpc/svcauth.h
72102 @@ -109,7 +109,7 @@ struct auth_ops {
72103 int (*release)(struct svc_rqst *rq);
72104 void (*domain_release)(struct auth_domain *);
72105 int (*set_client)(struct svc_rqst *rq);
72106 -};
72107 +} __do_const;
72108
72109 #define SVC_GARBAGE 1
72110 #define SVC_SYSERR 2
72111 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
72112 index a5ffd32..0935dea 100644
72113 --- a/include/linux/swiotlb.h
72114 +++ b/include/linux/swiotlb.h
72115 @@ -60,7 +60,8 @@ extern void
72116
72117 extern void
72118 swiotlb_free_coherent(struct device *hwdev, size_t size,
72119 - void *vaddr, dma_addr_t dma_handle);
72120 + void *vaddr, dma_addr_t dma_handle,
72121 + struct dma_attrs *attrs);
72122
72123 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
72124 unsigned long offset, size_t size,
72125 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
72126 index 313a8e0..6b273a9 100644
72127 --- a/include/linux/syscalls.h
72128 +++ b/include/linux/syscalls.h
72129 @@ -418,11 +418,11 @@ asmlinkage long sys_sync(void);
72130 asmlinkage long sys_fsync(unsigned int fd);
72131 asmlinkage long sys_fdatasync(unsigned int fd);
72132 asmlinkage long sys_bdflush(int func, long data);
72133 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
72134 - char __user *type, unsigned long flags,
72135 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
72136 + const char __user *type, unsigned long flags,
72137 void __user *data);
72138 -asmlinkage long sys_umount(char __user *name, int flags);
72139 -asmlinkage long sys_oldumount(char __user *name);
72140 +asmlinkage long sys_umount(const char __user *name, int flags);
72141 +asmlinkage long sys_oldumount(const char __user *name);
72142 asmlinkage long sys_truncate(const char __user *path, long length);
72143 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
72144 asmlinkage long sys_stat(const char __user *filename,
72145 @@ -634,7 +634,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72146 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72147 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72148 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72149 - struct sockaddr __user *, int);
72150 + struct sockaddr __user *, int) __intentional_overflow(0);
72151 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72152 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72153 unsigned int vlen, unsigned flags);
72154 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72155 index 27b3b0b..e093dd9 100644
72156 --- a/include/linux/syscore_ops.h
72157 +++ b/include/linux/syscore_ops.h
72158 @@ -16,7 +16,7 @@ struct syscore_ops {
72159 int (*suspend)(void);
72160 void (*resume)(void);
72161 void (*shutdown)(void);
72162 -};
72163 +} __do_const;
72164
72165 extern void register_syscore_ops(struct syscore_ops *ops);
72166 extern void unregister_syscore_ops(struct syscore_ops *ops);
72167 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72168 index 14a8ff2..af52bad 100644
72169 --- a/include/linux/sysctl.h
72170 +++ b/include/linux/sysctl.h
72171 @@ -34,13 +34,13 @@ struct ctl_table_root;
72172 struct ctl_table_header;
72173 struct ctl_dir;
72174
72175 -typedef struct ctl_table ctl_table;
72176 -
72177 typedef int proc_handler (struct ctl_table *ctl, int write,
72178 void __user *buffer, size_t *lenp, loff_t *ppos);
72179
72180 extern int proc_dostring(struct ctl_table *, int,
72181 void __user *, size_t *, loff_t *);
72182 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72183 + void __user *, size_t *, loff_t *);
72184 extern int proc_dointvec(struct ctl_table *, int,
72185 void __user *, size_t *, loff_t *);
72186 extern int proc_dointvec_minmax(struct ctl_table *, int,
72187 @@ -115,7 +115,9 @@ struct ctl_table
72188 struct ctl_table_poll *poll;
72189 void *extra1;
72190 void *extra2;
72191 -};
72192 +} __do_const;
72193 +typedef struct ctl_table __no_const ctl_table_no_const;
72194 +typedef struct ctl_table ctl_table;
72195
72196 struct ctl_node {
72197 struct rb_node node;
72198 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72199 index e2cee22..3ddb921 100644
72200 --- a/include/linux/sysfs.h
72201 +++ b/include/linux/sysfs.h
72202 @@ -31,7 +31,8 @@ struct attribute {
72203 struct lock_class_key *key;
72204 struct lock_class_key skey;
72205 #endif
72206 -};
72207 +} __do_const;
72208 +typedef struct attribute __no_const attribute_no_const;
72209
72210 /**
72211 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72212 @@ -59,8 +60,8 @@ struct attribute_group {
72213 umode_t (*is_visible)(struct kobject *,
72214 struct attribute *, int);
72215 struct attribute **attrs;
72216 -};
72217 -
72218 +} __do_const;
72219 +typedef struct attribute_group __no_const attribute_group_no_const;
72220
72221
72222 /**
72223 @@ -107,7 +108,8 @@ struct bin_attribute {
72224 char *, loff_t, size_t);
72225 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72226 struct vm_area_struct *vma);
72227 -};
72228 +} __do_const;
72229 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72230
72231 /**
72232 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72233 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72234 index 7faf933..9b85a0c 100644
72235 --- a/include/linux/sysrq.h
72236 +++ b/include/linux/sysrq.h
72237 @@ -16,6 +16,7 @@
72238
72239 #include <linux/errno.h>
72240 #include <linux/types.h>
72241 +#include <linux/compiler.h>
72242
72243 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72244 #define SYSRQ_DEFAULT_ENABLE 1
72245 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72246 char *help_msg;
72247 char *action_msg;
72248 int enable_mask;
72249 -};
72250 +} __do_const;
72251
72252 #ifdef CONFIG_MAGIC_SYSRQ
72253
72254 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72255 index e7e0473..7989295 100644
72256 --- a/include/linux/thread_info.h
72257 +++ b/include/linux/thread_info.h
72258 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72259 #error "no set_restore_sigmask() provided and default one won't work"
72260 #endif
72261
72262 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72263 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72264 +{
72265 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72266 + if (!__builtin_constant_p(n))
72267 +#endif
72268 + __check_object_size(ptr, n, to_user);
72269 +}
72270 +
72271 #endif /* __KERNEL__ */
72272
72273 #endif /* _LINUX_THREAD_INFO_H */
72274 diff --git a/include/linux/tty.h b/include/linux/tty.h
72275 index c75d886..04cb148 100644
72276 --- a/include/linux/tty.h
72277 +++ b/include/linux/tty.h
72278 @@ -194,7 +194,7 @@ struct tty_port {
72279 const struct tty_port_operations *ops; /* Port operations */
72280 spinlock_t lock; /* Lock protecting tty field */
72281 int blocked_open; /* Waiting to open */
72282 - int count; /* Usage count */
72283 + atomic_t count; /* Usage count */
72284 wait_queue_head_t open_wait; /* Open waiters */
72285 wait_queue_head_t close_wait; /* Close waiters */
72286 wait_queue_head_t delta_msr_wait; /* Modem status change */
72287 @@ -515,7 +515,7 @@ extern int tty_port_open(struct tty_port *port,
72288 struct tty_struct *tty, struct file *filp);
72289 static inline int tty_port_users(struct tty_port *port)
72290 {
72291 - return port->count + port->blocked_open;
72292 + return atomic_read(&port->count) + port->blocked_open;
72293 }
72294
72295 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72296 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72297 index 756a609..b302dd6 100644
72298 --- a/include/linux/tty_driver.h
72299 +++ b/include/linux/tty_driver.h
72300 @@ -285,7 +285,7 @@ struct tty_operations {
72301 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72302 #endif
72303 const struct file_operations *proc_fops;
72304 -};
72305 +} __do_const;
72306
72307 struct tty_driver {
72308 int magic; /* magic number for this structure */
72309 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72310 index 455a0d7..bf97ff5 100644
72311 --- a/include/linux/tty_ldisc.h
72312 +++ b/include/linux/tty_ldisc.h
72313 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
72314
72315 struct module *owner;
72316
72317 - int refcount;
72318 + atomic_t refcount;
72319 };
72320
72321 struct tty_ldisc {
72322 diff --git a/include/linux/types.h b/include/linux/types.h
72323 index 4d118ba..c3ee9bf 100644
72324 --- a/include/linux/types.h
72325 +++ b/include/linux/types.h
72326 @@ -176,10 +176,26 @@ typedef struct {
72327 int counter;
72328 } atomic_t;
72329
72330 +#ifdef CONFIG_PAX_REFCOUNT
72331 +typedef struct {
72332 + int counter;
72333 +} atomic_unchecked_t;
72334 +#else
72335 +typedef atomic_t atomic_unchecked_t;
72336 +#endif
72337 +
72338 #ifdef CONFIG_64BIT
72339 typedef struct {
72340 long counter;
72341 } atomic64_t;
72342 +
72343 +#ifdef CONFIG_PAX_REFCOUNT
72344 +typedef struct {
72345 + long counter;
72346 +} atomic64_unchecked_t;
72347 +#else
72348 +typedef atomic64_t atomic64_unchecked_t;
72349 +#endif
72350 #endif
72351
72352 struct list_head {
72353 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72354 index 5ca0951..ab496a5 100644
72355 --- a/include/linux/uaccess.h
72356 +++ b/include/linux/uaccess.h
72357 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72358 long ret; \
72359 mm_segment_t old_fs = get_fs(); \
72360 \
72361 - set_fs(KERNEL_DS); \
72362 pagefault_disable(); \
72363 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72364 - pagefault_enable(); \
72365 + set_fs(KERNEL_DS); \
72366 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72367 set_fs(old_fs); \
72368 + pagefault_enable(); \
72369 ret; \
72370 })
72371
72372 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72373 index 8e522cbc..aa8572d 100644
72374 --- a/include/linux/uidgid.h
72375 +++ b/include/linux/uidgid.h
72376 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72377
72378 #endif /* CONFIG_USER_NS */
72379
72380 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72381 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72382 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72383 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72384 +
72385 #endif /* _LINUX_UIDGID_H */
72386 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72387 index 99c1b4d..562e6f3 100644
72388 --- a/include/linux/unaligned/access_ok.h
72389 +++ b/include/linux/unaligned/access_ok.h
72390 @@ -4,34 +4,34 @@
72391 #include <linux/kernel.h>
72392 #include <asm/byteorder.h>
72393
72394 -static inline u16 get_unaligned_le16(const void *p)
72395 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72396 {
72397 - return le16_to_cpup((__le16 *)p);
72398 + return le16_to_cpup((const __le16 *)p);
72399 }
72400
72401 -static inline u32 get_unaligned_le32(const void *p)
72402 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72403 {
72404 - return le32_to_cpup((__le32 *)p);
72405 + return le32_to_cpup((const __le32 *)p);
72406 }
72407
72408 -static inline u64 get_unaligned_le64(const void *p)
72409 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72410 {
72411 - return le64_to_cpup((__le64 *)p);
72412 + return le64_to_cpup((const __le64 *)p);
72413 }
72414
72415 -static inline u16 get_unaligned_be16(const void *p)
72416 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72417 {
72418 - return be16_to_cpup((__be16 *)p);
72419 + return be16_to_cpup((const __be16 *)p);
72420 }
72421
72422 -static inline u32 get_unaligned_be32(const void *p)
72423 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72424 {
72425 - return be32_to_cpup((__be32 *)p);
72426 + return be32_to_cpup((const __be32 *)p);
72427 }
72428
72429 -static inline u64 get_unaligned_be64(const void *p)
72430 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72431 {
72432 - return be64_to_cpup((__be64 *)p);
72433 + return be64_to_cpup((const __be64 *)p);
72434 }
72435
72436 static inline void put_unaligned_le16(u16 val, void *p)
72437 diff --git a/include/linux/usb.h b/include/linux/usb.h
72438 index 4d22d0f..8d0e8f8 100644
72439 --- a/include/linux/usb.h
72440 +++ b/include/linux/usb.h
72441 @@ -554,7 +554,7 @@ struct usb_device {
72442 int maxchild;
72443
72444 u32 quirks;
72445 - atomic_t urbnum;
72446 + atomic_unchecked_t urbnum;
72447
72448 unsigned long active_duration;
72449
72450 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72451
72452 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72453 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72454 - void *data, __u16 size, int timeout);
72455 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72456 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72457 void *data, int len, int *actual_length, int timeout);
72458 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72459 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72460 index c5d36c6..108f4f9 100644
72461 --- a/include/linux/usb/renesas_usbhs.h
72462 +++ b/include/linux/usb/renesas_usbhs.h
72463 @@ -39,7 +39,7 @@ enum {
72464 */
72465 struct renesas_usbhs_driver_callback {
72466 int (*notify_hotplug)(struct platform_device *pdev);
72467 -};
72468 +} __no_const;
72469
72470 /*
72471 * callback functions for platform
72472 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72473 index 6f8fbcf..8259001 100644
72474 --- a/include/linux/vermagic.h
72475 +++ b/include/linux/vermagic.h
72476 @@ -25,9 +25,35 @@
72477 #define MODULE_ARCH_VERMAGIC ""
72478 #endif
72479
72480 +#ifdef CONFIG_PAX_REFCOUNT
72481 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72482 +#else
72483 +#define MODULE_PAX_REFCOUNT ""
72484 +#endif
72485 +
72486 +#ifdef CONSTIFY_PLUGIN
72487 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72488 +#else
72489 +#define MODULE_CONSTIFY_PLUGIN ""
72490 +#endif
72491 +
72492 +#ifdef STACKLEAK_PLUGIN
72493 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72494 +#else
72495 +#define MODULE_STACKLEAK_PLUGIN ""
72496 +#endif
72497 +
72498 +#ifdef CONFIG_GRKERNSEC
72499 +#define MODULE_GRSEC "GRSEC "
72500 +#else
72501 +#define MODULE_GRSEC ""
72502 +#endif
72503 +
72504 #define VERMAGIC_STRING \
72505 UTS_RELEASE " " \
72506 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72507 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72508 - MODULE_ARCH_VERMAGIC
72509 + MODULE_ARCH_VERMAGIC \
72510 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72511 + MODULE_GRSEC
72512
72513 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72514 index 6071e91..4c73b47 100644
72515 --- a/include/linux/vmalloc.h
72516 +++ b/include/linux/vmalloc.h
72517 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72518 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72519 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72520 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72521 +
72522 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72523 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72524 +#endif
72525 +
72526 /* bits [20..32] reserved for arch specific ioremap internals */
72527
72528 /*
72529 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72530 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72531 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72532 unsigned long start, unsigned long end, gfp_t gfp_mask,
72533 - pgprot_t prot, int node, const void *caller);
72534 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72535 extern void vfree(const void *addr);
72536
72537 extern void *vmap(struct page **pages, unsigned int count,
72538 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72539 extern void free_vm_area(struct vm_struct *area);
72540
72541 /* for /dev/kmem */
72542 -extern long vread(char *buf, char *addr, unsigned long count);
72543 -extern long vwrite(char *buf, char *addr, unsigned long count);
72544 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72545 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72546
72547 /*
72548 * Internals. Dont't use..
72549 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72550 index 5fd71a7..e5ef9a9 100644
72551 --- a/include/linux/vmstat.h
72552 +++ b/include/linux/vmstat.h
72553 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72554 /*
72555 * Zone based page accounting with per cpu differentials.
72556 */
72557 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72558 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72559
72560 static inline void zone_page_state_add(long x, struct zone *zone,
72561 enum zone_stat_item item)
72562 {
72563 - atomic_long_add(x, &zone->vm_stat[item]);
72564 - atomic_long_add(x, &vm_stat[item]);
72565 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72566 + atomic_long_add_unchecked(x, &vm_stat[item]);
72567 }
72568
72569 static inline unsigned long global_page_state(enum zone_stat_item item)
72570 {
72571 - long x = atomic_long_read(&vm_stat[item]);
72572 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72573 #ifdef CONFIG_SMP
72574 if (x < 0)
72575 x = 0;
72576 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72577 static inline unsigned long zone_page_state(struct zone *zone,
72578 enum zone_stat_item item)
72579 {
72580 - long x = atomic_long_read(&zone->vm_stat[item]);
72581 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72582 #ifdef CONFIG_SMP
72583 if (x < 0)
72584 x = 0;
72585 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72586 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72587 enum zone_stat_item item)
72588 {
72589 - long x = atomic_long_read(&zone->vm_stat[item]);
72590 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72591
72592 #ifdef CONFIG_SMP
72593 int cpu;
72594 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72595
72596 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72597 {
72598 - atomic_long_inc(&zone->vm_stat[item]);
72599 - atomic_long_inc(&vm_stat[item]);
72600 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72601 + atomic_long_inc_unchecked(&vm_stat[item]);
72602 }
72603
72604 static inline void __inc_zone_page_state(struct page *page,
72605 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72606
72607 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72608 {
72609 - atomic_long_dec(&zone->vm_stat[item]);
72610 - atomic_long_dec(&vm_stat[item]);
72611 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72612 + atomic_long_dec_unchecked(&vm_stat[item]);
72613 }
72614
72615 static inline void __dec_zone_page_state(struct page *page,
72616 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72617 index fdbafc6..49dfe4f 100644
72618 --- a/include/linux/xattr.h
72619 +++ b/include/linux/xattr.h
72620 @@ -28,7 +28,7 @@ struct xattr_handler {
72621 size_t size, int handler_flags);
72622 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72623 size_t size, int flags, int handler_flags);
72624 -};
72625 +} __do_const;
72626
72627 struct xattr {
72628 char *name;
72629 @@ -37,6 +37,9 @@ struct xattr {
72630 };
72631
72632 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
72633 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
72634 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
72635 +#endif
72636 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
72637 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
72638 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
72639 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72640 index 9c5a6b4..09c9438 100644
72641 --- a/include/linux/zlib.h
72642 +++ b/include/linux/zlib.h
72643 @@ -31,6 +31,7 @@
72644 #define _ZLIB_H
72645
72646 #include <linux/zconf.h>
72647 +#include <linux/compiler.h>
72648
72649 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72650 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72651 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72652
72653 /* basic functions */
72654
72655 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72656 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72657 /*
72658 Returns the number of bytes that needs to be allocated for a per-
72659 stream workspace with the specified parameters. A pointer to this
72660 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72661 index 95d1c91..6798cca 100644
72662 --- a/include/media/v4l2-dev.h
72663 +++ b/include/media/v4l2-dev.h
72664 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72665 int (*mmap) (struct file *, struct vm_area_struct *);
72666 int (*open) (struct file *);
72667 int (*release) (struct file *);
72668 -};
72669 +} __do_const;
72670
72671 /*
72672 * Newer version of video_device, handled by videodev2.c
72673 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72674 index 4118ad1..cb7e25f 100644
72675 --- a/include/media/v4l2-ioctl.h
72676 +++ b/include/media/v4l2-ioctl.h
72677 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72678 bool valid_prio, int cmd, void *arg);
72679 };
72680
72681 -
72682 /* v4l debugging and diagnostics */
72683
72684 /* Debug bitmask flags to be used on V4L2 */
72685 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72686 index adcbb20..62c2559 100644
72687 --- a/include/net/9p/transport.h
72688 +++ b/include/net/9p/transport.h
72689 @@ -57,7 +57,7 @@ struct p9_trans_module {
72690 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72691 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72692 char *, char *, int , int, int, int);
72693 -};
72694 +} __do_const;
72695
72696 void v9fs_register_trans(struct p9_trans_module *m);
72697 void v9fs_unregister_trans(struct p9_trans_module *m);
72698 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72699 index cdd3302..76f8ede 100644
72700 --- a/include/net/bluetooth/l2cap.h
72701 +++ b/include/net/bluetooth/l2cap.h
72702 @@ -551,7 +551,7 @@ struct l2cap_ops {
72703 void (*defer) (struct l2cap_chan *chan);
72704 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72705 unsigned long len, int nb);
72706 -};
72707 +} __do_const;
72708
72709 struct l2cap_conn {
72710 struct hci_conn *hcon;
72711 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72712 index 9e5425b..8136ffc 100644
72713 --- a/include/net/caif/cfctrl.h
72714 +++ b/include/net/caif/cfctrl.h
72715 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72716 void (*radioset_rsp)(void);
72717 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72718 struct cflayer *client_layer);
72719 -};
72720 +} __no_const;
72721
72722 /* Link Setup Parameters for CAIF-Links. */
72723 struct cfctrl_link_param {
72724 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72725 struct cfctrl {
72726 struct cfsrvl serv;
72727 struct cfctrl_rsp res;
72728 - atomic_t req_seq_no;
72729 - atomic_t rsp_seq_no;
72730 + atomic_unchecked_t req_seq_no;
72731 + atomic_unchecked_t rsp_seq_no;
72732 struct list_head list;
72733 /* Protects from simultaneous access to first_req list */
72734 spinlock_t info_list_lock;
72735 diff --git a/include/net/flow.h b/include/net/flow.h
72736 index 628e11b..4c475df 100644
72737 --- a/include/net/flow.h
72738 +++ b/include/net/flow.h
72739 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72740
72741 extern void flow_cache_flush(void);
72742 extern void flow_cache_flush_deferred(void);
72743 -extern atomic_t flow_cache_genid;
72744 +extern atomic_unchecked_t flow_cache_genid;
72745
72746 #endif
72747 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72748 index bdfbe68..4402ebe 100644
72749 --- a/include/net/genetlink.h
72750 +++ b/include/net/genetlink.h
72751 @@ -118,7 +118,7 @@ struct genl_ops {
72752 struct netlink_callback *cb);
72753 int (*done)(struct netlink_callback *cb);
72754 struct list_head ops_list;
72755 -};
72756 +} __do_const;
72757
72758 extern int genl_register_family(struct genl_family *family);
72759 extern int genl_register_family_with_ops(struct genl_family *family,
72760 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72761 index 734d9b5..48a9a4b 100644
72762 --- a/include/net/gro_cells.h
72763 +++ b/include/net/gro_cells.h
72764 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72765 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72766
72767 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72768 - atomic_long_inc(&dev->rx_dropped);
72769 + atomic_long_inc_unchecked(&dev->rx_dropped);
72770 kfree_skb(skb);
72771 return;
72772 }
72773 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72774 index 1832927..ce39aea 100644
72775 --- a/include/net/inet_connection_sock.h
72776 +++ b/include/net/inet_connection_sock.h
72777 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72778 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72779 int (*bind_conflict)(const struct sock *sk,
72780 const struct inet_bind_bucket *tb, bool relax);
72781 -};
72782 +} __do_const;
72783
72784 /** inet_connection_sock - INET connection oriented sock
72785 *
72786 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72787 index 53f464d..ba76aaa 100644
72788 --- a/include/net/inetpeer.h
72789 +++ b/include/net/inetpeer.h
72790 @@ -47,8 +47,8 @@ struct inet_peer {
72791 */
72792 union {
72793 struct {
72794 - atomic_t rid; /* Frag reception counter */
72795 - atomic_t ip_id_count; /* IP ID for the next packet */
72796 + atomic_unchecked_t rid; /* Frag reception counter */
72797 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72798 };
72799 struct rcu_head rcu;
72800 struct inet_peer *gc_next;
72801 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72802 more++;
72803 inet_peer_refcheck(p);
72804 do {
72805 - old = atomic_read(&p->ip_id_count);
72806 + old = atomic_read_unchecked(&p->ip_id_count);
72807 new = old + more;
72808 if (!new)
72809 new = 1;
72810 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72811 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72812 return new;
72813 }
72814
72815 diff --git a/include/net/ip.h b/include/net/ip.h
72816 index a68f838..74518ab 100644
72817 --- a/include/net/ip.h
72818 +++ b/include/net/ip.h
72819 @@ -202,7 +202,7 @@ extern struct local_ports {
72820 } sysctl_local_ports;
72821 extern void inet_get_local_port_range(int *low, int *high);
72822
72823 -extern unsigned long *sysctl_local_reserved_ports;
72824 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72825 static inline int inet_is_reserved_local_port(int port)
72826 {
72827 return test_bit(port, sysctl_local_reserved_ports);
72828 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72829 index e49db91..76a81de 100644
72830 --- a/include/net/ip_fib.h
72831 +++ b/include/net/ip_fib.h
72832 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72833
72834 #define FIB_RES_SADDR(net, res) \
72835 ((FIB_RES_NH(res).nh_saddr_genid == \
72836 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72837 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72838 FIB_RES_NH(res).nh_saddr : \
72839 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72840 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72841 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72842 index fce8e6b..3ca4916 100644
72843 --- a/include/net/ip_vs.h
72844 +++ b/include/net/ip_vs.h
72845 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72846 struct ip_vs_conn *control; /* Master control connection */
72847 atomic_t n_control; /* Number of controlled ones */
72848 struct ip_vs_dest *dest; /* real server */
72849 - atomic_t in_pkts; /* incoming packet counter */
72850 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72851
72852 /* packet transmitter for different forwarding methods. If it
72853 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72854 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72855 __be16 port; /* port number of the server */
72856 union nf_inet_addr addr; /* IP address of the server */
72857 volatile unsigned int flags; /* dest status flags */
72858 - atomic_t conn_flags; /* flags to copy to conn */
72859 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72860 atomic_t weight; /* server weight */
72861
72862 atomic_t refcnt; /* reference counter */
72863 @@ -981,11 +981,11 @@ struct netns_ipvs {
72864 /* ip_vs_lblc */
72865 int sysctl_lblc_expiration;
72866 struct ctl_table_header *lblc_ctl_header;
72867 - struct ctl_table *lblc_ctl_table;
72868 + ctl_table_no_const *lblc_ctl_table;
72869 /* ip_vs_lblcr */
72870 int sysctl_lblcr_expiration;
72871 struct ctl_table_header *lblcr_ctl_header;
72872 - struct ctl_table *lblcr_ctl_table;
72873 + ctl_table_no_const *lblcr_ctl_table;
72874 /* ip_vs_est */
72875 struct list_head est_list; /* estimator list */
72876 spinlock_t est_lock;
72877 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72878 index 80ffde3..968b0f4 100644
72879 --- a/include/net/irda/ircomm_tty.h
72880 +++ b/include/net/irda/ircomm_tty.h
72881 @@ -35,6 +35,7 @@
72882 #include <linux/termios.h>
72883 #include <linux/timer.h>
72884 #include <linux/tty.h> /* struct tty_struct */
72885 +#include <asm/local.h>
72886
72887 #include <net/irda/irias_object.h>
72888 #include <net/irda/ircomm_core.h>
72889 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72890 index 714cc9a..ea05f3e 100644
72891 --- a/include/net/iucv/af_iucv.h
72892 +++ b/include/net/iucv/af_iucv.h
72893 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
72894 struct iucv_sock_list {
72895 struct hlist_head head;
72896 rwlock_t lock;
72897 - atomic_t autobind_name;
72898 + atomic_unchecked_t autobind_name;
72899 };
72900
72901 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72902 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72903 index df83f69..9b640b8 100644
72904 --- a/include/net/llc_c_ac.h
72905 +++ b/include/net/llc_c_ac.h
72906 @@ -87,7 +87,7 @@
72907 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72908 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72909
72910 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72911 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72912
72913 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72914 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72915 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72916 index 6ca3113..f8026dd 100644
72917 --- a/include/net/llc_c_ev.h
72918 +++ b/include/net/llc_c_ev.h
72919 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72920 return (struct llc_conn_state_ev *)skb->cb;
72921 }
72922
72923 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72924 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72925 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72926 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72927
72928 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72929 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72930 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72931 index 0e79cfb..f46db31 100644
72932 --- a/include/net/llc_c_st.h
72933 +++ b/include/net/llc_c_st.h
72934 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72935 u8 next_state;
72936 llc_conn_ev_qfyr_t *ev_qualifiers;
72937 llc_conn_action_t *ev_actions;
72938 -};
72939 +} __do_const;
72940
72941 struct llc_conn_state {
72942 u8 current_state;
72943 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72944 index 37a3bbd..55a4241 100644
72945 --- a/include/net/llc_s_ac.h
72946 +++ b/include/net/llc_s_ac.h
72947 @@ -23,7 +23,7 @@
72948 #define SAP_ACT_TEST_IND 9
72949
72950 /* All action functions must look like this */
72951 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72952 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72953
72954 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72955 struct sk_buff *skb);
72956 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72957 index 567c681..cd73ac0 100644
72958 --- a/include/net/llc_s_st.h
72959 +++ b/include/net/llc_s_st.h
72960 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72961 llc_sap_ev_t ev;
72962 u8 next_state;
72963 llc_sap_action_t *ev_actions;
72964 -};
72965 +} __do_const;
72966
72967 struct llc_sap_state {
72968 u8 curr_state;
72969 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72970 index f7eba13..91ed983 100644
72971 --- a/include/net/mac80211.h
72972 +++ b/include/net/mac80211.h
72973 @@ -4119,7 +4119,7 @@ struct rate_control_ops {
72974 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72975 struct dentry *dir);
72976 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72977 -};
72978 +} __do_const;
72979
72980 static inline int rate_supported(struct ieee80211_sta *sta,
72981 enum ieee80211_band band,
72982 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72983 index 7e748ad..5c6229b 100644
72984 --- a/include/net/neighbour.h
72985 +++ b/include/net/neighbour.h
72986 @@ -123,7 +123,7 @@ struct neigh_ops {
72987 void (*error_report)(struct neighbour *, struct sk_buff *);
72988 int (*output)(struct neighbour *, struct sk_buff *);
72989 int (*connected_output)(struct neighbour *, struct sk_buff *);
72990 -};
72991 +} __do_const;
72992
72993 struct pneigh_entry {
72994 struct pneigh_entry *next;
72995 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72996 index de644bc..dfbcc4c 100644
72997 --- a/include/net/net_namespace.h
72998 +++ b/include/net/net_namespace.h
72999 @@ -115,7 +115,7 @@ struct net {
73000 #endif
73001 struct netns_ipvs *ipvs;
73002 struct sock *diag_nlsk;
73003 - atomic_t rt_genid;
73004 + atomic_unchecked_t rt_genid;
73005 };
73006
73007 /*
73008 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
73009 #define __net_init __init
73010 #define __net_exit __exit_refok
73011 #define __net_initdata __initdata
73012 +#ifdef CONSTIFY_PLUGIN
73013 #define __net_initconst __initconst
73014 +#else
73015 +#define __net_initconst __initdata
73016 +#endif
73017 #endif
73018
73019 struct pernet_operations {
73020 @@ -282,7 +286,7 @@ struct pernet_operations {
73021 void (*exit_batch)(struct list_head *net_exit_list);
73022 int *id;
73023 size_t size;
73024 -};
73025 +} __do_const;
73026
73027 /*
73028 * Use these carefully. If you implement a network device and it
73029 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
73030
73031 static inline int rt_genid(struct net *net)
73032 {
73033 - return atomic_read(&net->rt_genid);
73034 + return atomic_read_unchecked(&net->rt_genid);
73035 }
73036
73037 static inline void rt_genid_bump(struct net *net)
73038 {
73039 - atomic_inc(&net->rt_genid);
73040 + atomic_inc_unchecked(&net->rt_genid);
73041 }
73042
73043 #endif /* __NET_NET_NAMESPACE_H */
73044 diff --git a/include/net/netdma.h b/include/net/netdma.h
73045 index 8ba8ce2..99b7fff 100644
73046 --- a/include/net/netdma.h
73047 +++ b/include/net/netdma.h
73048 @@ -24,7 +24,7 @@
73049 #include <linux/dmaengine.h>
73050 #include <linux/skbuff.h>
73051
73052 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73053 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73054 struct sk_buff *skb, int offset, struct iovec *to,
73055 size_t len, struct dma_pinned_list *pinned_list);
73056
73057 diff --git a/include/net/netlink.h b/include/net/netlink.h
73058 index 9690b0f..87aded7 100644
73059 --- a/include/net/netlink.h
73060 +++ b/include/net/netlink.h
73061 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
73062 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
73063 {
73064 if (mark)
73065 - skb_trim(skb, (unsigned char *) mark - skb->data);
73066 + skb_trim(skb, (const unsigned char *) mark - skb->data);
73067 }
73068
73069 /**
73070 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
73071 index c9c0c53..53f24c3 100644
73072 --- a/include/net/netns/conntrack.h
73073 +++ b/include/net/netns/conntrack.h
73074 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
73075 struct nf_proto_net {
73076 #ifdef CONFIG_SYSCTL
73077 struct ctl_table_header *ctl_table_header;
73078 - struct ctl_table *ctl_table;
73079 + ctl_table_no_const *ctl_table;
73080 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
73081 struct ctl_table_header *ctl_compat_header;
73082 - struct ctl_table *ctl_compat_table;
73083 + ctl_table_no_const *ctl_compat_table;
73084 #endif
73085 #endif
73086 unsigned int users;
73087 @@ -58,7 +58,7 @@ struct nf_ip_net {
73088 struct nf_icmp_net icmpv6;
73089 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
73090 struct ctl_table_header *ctl_table_header;
73091 - struct ctl_table *ctl_table;
73092 + ctl_table_no_const *ctl_table;
73093 #endif
73094 };
73095
73096 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
73097 index 2ba9de8..47bd6c7 100644
73098 --- a/include/net/netns/ipv4.h
73099 +++ b/include/net/netns/ipv4.h
73100 @@ -67,7 +67,7 @@ struct netns_ipv4 {
73101 kgid_t sysctl_ping_group_range[2];
73102 long sysctl_tcp_mem[3];
73103
73104 - atomic_t dev_addr_genid;
73105 + atomic_unchecked_t dev_addr_genid;
73106
73107 #ifdef CONFIG_IP_MROUTE
73108 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73109 diff --git a/include/net/protocol.h b/include/net/protocol.h
73110 index 047c047..b9dad15 100644
73111 --- a/include/net/protocol.h
73112 +++ b/include/net/protocol.h
73113 @@ -44,7 +44,7 @@ struct net_protocol {
73114 void (*err_handler)(struct sk_buff *skb, u32 info);
73115 unsigned int no_policy:1,
73116 netns_ok:1;
73117 -};
73118 +} __do_const;
73119
73120 #if IS_ENABLED(CONFIG_IPV6)
73121 struct inet6_protocol {
73122 @@ -57,7 +57,7 @@ struct inet6_protocol {
73123 u8 type, u8 code, int offset,
73124 __be32 info);
73125 unsigned int flags; /* INET6_PROTO_xxx */
73126 -};
73127 +} __do_const;
73128
73129 #define INET6_PROTO_NOPOLICY 0x1
73130 #define INET6_PROTO_FINAL 0x2
73131 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73132 index 5a15fab..d799ea7 100644
73133 --- a/include/net/rtnetlink.h
73134 +++ b/include/net/rtnetlink.h
73135 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73136 const struct net_device *dev);
73137 unsigned int (*get_num_tx_queues)(void);
73138 unsigned int (*get_num_rx_queues)(void);
73139 -};
73140 +} __do_const;
73141
73142 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73143 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73144 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73145 index df85a0c..19ac300 100644
73146 --- a/include/net/sctp/sctp.h
73147 +++ b/include/net/sctp/sctp.h
73148 @@ -330,9 +330,9 @@ do { \
73149
73150 #else /* SCTP_DEBUG */
73151
73152 -#define SCTP_DEBUG_PRINTK(whatever...)
73153 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73154 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73155 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73156 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73157 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73158 #define SCTP_ENABLE_DEBUG
73159 #define SCTP_DISABLE_DEBUG
73160 #define SCTP_ASSERT(expr, str, func)
73161 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73162 index 2a82d13..62a31c2 100644
73163 --- a/include/net/sctp/sm.h
73164 +++ b/include/net/sctp/sm.h
73165 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73166 typedef struct {
73167 sctp_state_fn_t *fn;
73168 const char *name;
73169 -} sctp_sm_table_entry_t;
73170 +} __do_const sctp_sm_table_entry_t;
73171
73172 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73173 * currently in use.
73174 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73175 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73176
73177 /* Extern declarations for major data structures. */
73178 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73179 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73180
73181
73182 /* Get the size of a DATA chunk payload. */
73183 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73184 index 0e0f9d2..cd05ebb 100644
73185 --- a/include/net/sctp/structs.h
73186 +++ b/include/net/sctp/structs.h
73187 @@ -517,7 +517,7 @@ struct sctp_pf {
73188 struct sctp_association *asoc);
73189 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73190 struct sctp_af *af;
73191 -};
73192 +} __do_const;
73193
73194
73195 /* Structure to track chunk fragments that have been acked, but peer
73196 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
73197 index c2e542b..6ca975b 100644
73198 --- a/include/net/secure_seq.h
73199 +++ b/include/net/secure_seq.h
73200 @@ -3,6 +3,7 @@
73201
73202 #include <linux/types.h>
73203
73204 +extern void net_secret_init(void);
73205 extern __u32 secure_ip_id(__be32 daddr);
73206 extern __u32 secure_ipv6_id(const __be32 daddr[4]);
73207 extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
73208 diff --git a/include/net/sock.h b/include/net/sock.h
73209 index 0be480a..586232f 100644
73210 --- a/include/net/sock.h
73211 +++ b/include/net/sock.h
73212 @@ -325,7 +325,7 @@ struct sock {
73213 #ifdef CONFIG_RPS
73214 __u32 sk_rxhash;
73215 #endif
73216 - atomic_t sk_drops;
73217 + atomic_unchecked_t sk_drops;
73218 int sk_rcvbuf;
73219
73220 struct sk_filter __rcu *sk_filter;
73221 @@ -1796,7 +1796,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73222 }
73223
73224 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73225 - char __user *from, char *to,
73226 + char __user *from, unsigned char *to,
73227 int copy, int offset)
73228 {
73229 if (skb->ip_summed == CHECKSUM_NONE) {
73230 @@ -2055,7 +2055,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73231 }
73232 }
73233
73234 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73235 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73236
73237 /**
73238 * sk_page_frag - return an appropriate page_frag
73239 diff --git a/include/net/tcp.h b/include/net/tcp.h
73240 index a345480..3c65cf4 100644
73241 --- a/include/net/tcp.h
73242 +++ b/include/net/tcp.h
73243 @@ -529,7 +529,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73244 extern void tcp_xmit_retransmit_queue(struct sock *);
73245 extern void tcp_simple_retransmit(struct sock *);
73246 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73247 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73248 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73249
73250 extern void tcp_send_probe0(struct sock *);
73251 extern void tcp_send_partial(struct sock *);
73252 @@ -700,8 +700,8 @@ struct tcp_skb_cb {
73253 struct inet6_skb_parm h6;
73254 #endif
73255 } header; /* For incoming frames */
73256 - __u32 seq; /* Starting sequence number */
73257 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73258 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73259 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73260 __u32 when; /* used to compute rtt's */
73261 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73262
73263 @@ -715,7 +715,7 @@ struct tcp_skb_cb {
73264
73265 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73266 /* 1 byte hole */
73267 - __u32 ack_seq; /* Sequence number ACK'd */
73268 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73269 };
73270
73271 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73272 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73273 index 24c8886..e6fb816 100644
73274 --- a/include/net/xfrm.h
73275 +++ b/include/net/xfrm.h
73276 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73277 struct net_device *dev,
73278 const struct flowi *fl);
73279 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73280 -};
73281 +} __do_const;
73282
73283 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73284 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73285 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73286 struct sk_buff *skb);
73287 int (*transport_finish)(struct sk_buff *skb,
73288 int async);
73289 -};
73290 +} __do_const;
73291
73292 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73293 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73294 @@ -423,7 +423,7 @@ struct xfrm_mode {
73295 struct module *owner;
73296 unsigned int encap;
73297 int flags;
73298 -};
73299 +} __do_const;
73300
73301 /* Flags for xfrm_mode. */
73302 enum {
73303 @@ -520,7 +520,7 @@ struct xfrm_policy {
73304 struct timer_list timer;
73305
73306 struct flow_cache_object flo;
73307 - atomic_t genid;
73308 + atomic_unchecked_t genid;
73309 u32 priority;
73310 u32 index;
73311 struct xfrm_mark mark;
73312 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73313 index 1a046b1..ee0bef0 100644
73314 --- a/include/rdma/iw_cm.h
73315 +++ b/include/rdma/iw_cm.h
73316 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73317 int backlog);
73318
73319 int (*destroy_listen)(struct iw_cm_id *cm_id);
73320 -};
73321 +} __no_const;
73322
73323 /**
73324 * iw_create_cm_id - Create an IW CM identifier.
73325 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73326 index e1379b4..67eafbe 100644
73327 --- a/include/scsi/libfc.h
73328 +++ b/include/scsi/libfc.h
73329 @@ -762,6 +762,7 @@ struct libfc_function_template {
73330 */
73331 void (*disc_stop_final) (struct fc_lport *);
73332 };
73333 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73334
73335 /**
73336 * struct fc_disc - Discovery context
73337 @@ -866,7 +867,7 @@ struct fc_lport {
73338 struct fc_vport *vport;
73339
73340 /* Operational Information */
73341 - struct libfc_function_template tt;
73342 + libfc_function_template_no_const tt;
73343 u8 link_up;
73344 u8 qfull;
73345 enum fc_lport_state state;
73346 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73347 index a7f9cba..b1f44d0 100644
73348 --- a/include/scsi/scsi_device.h
73349 +++ b/include/scsi/scsi_device.h
73350 @@ -171,9 +171,9 @@ struct scsi_device {
73351 unsigned int max_device_blocked; /* what device_blocked counts down from */
73352 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73353
73354 - atomic_t iorequest_cnt;
73355 - atomic_t iodone_cnt;
73356 - atomic_t ioerr_cnt;
73357 + atomic_unchecked_t iorequest_cnt;
73358 + atomic_unchecked_t iodone_cnt;
73359 + atomic_unchecked_t ioerr_cnt;
73360
73361 struct device sdev_gendev,
73362 sdev_dev;
73363 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73364 index b797e8f..8e2c3aa 100644
73365 --- a/include/scsi/scsi_transport_fc.h
73366 +++ b/include/scsi/scsi_transport_fc.h
73367 @@ -751,7 +751,8 @@ struct fc_function_template {
73368 unsigned long show_host_system_hostname:1;
73369
73370 unsigned long disable_target_scan:1;
73371 -};
73372 +} __do_const;
73373 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73374
73375
73376 /**
73377 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
73378 index ff6c741..393815f 100644
73379 --- a/include/sound/compress_driver.h
73380 +++ b/include/sound/compress_driver.h
73381 @@ -130,7 +130,7 @@ struct snd_compr_ops {
73382 struct snd_compr_caps *caps);
73383 int (*get_codec_caps) (struct snd_compr_stream *stream,
73384 struct snd_compr_codec_caps *codec);
73385 -};
73386 +} __no_const;
73387
73388 /**
73389 * struct snd_compr: Compressed device
73390 diff --git a/include/sound/soc.h b/include/sound/soc.h
73391 index a6a059c..2243336 100644
73392 --- a/include/sound/soc.h
73393 +++ b/include/sound/soc.h
73394 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73395 /* probe ordering - for components with runtime dependencies */
73396 int probe_order;
73397 int remove_order;
73398 -};
73399 +} __do_const;
73400
73401 /* SoC platform interface */
73402 struct snd_soc_platform_driver {
73403 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73404 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73405 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73406 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73407 -};
73408 +} __do_const;
73409
73410 struct snd_soc_platform {
73411 const char *name;
73412 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73413 index f8640f3..b72d113 100644
73414 --- a/include/target/target_core_base.h
73415 +++ b/include/target/target_core_base.h
73416 @@ -658,7 +658,7 @@ struct se_device {
73417 spinlock_t stats_lock;
73418 /* Active commands on this virtual SE device */
73419 atomic_t simple_cmds;
73420 - atomic_t dev_ordered_id;
73421 + atomic_unchecked_t dev_ordered_id;
73422 atomic_t dev_ordered_sync;
73423 atomic_t dev_qf_count;
73424 int export_count;
73425 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73426 new file mode 100644
73427 index 0000000..fb634b7
73428 --- /dev/null
73429 +++ b/include/trace/events/fs.h
73430 @@ -0,0 +1,53 @@
73431 +#undef TRACE_SYSTEM
73432 +#define TRACE_SYSTEM fs
73433 +
73434 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73435 +#define _TRACE_FS_H
73436 +
73437 +#include <linux/fs.h>
73438 +#include <linux/tracepoint.h>
73439 +
73440 +TRACE_EVENT(do_sys_open,
73441 +
73442 + TP_PROTO(const char *filename, int flags, int mode),
73443 +
73444 + TP_ARGS(filename, flags, mode),
73445 +
73446 + TP_STRUCT__entry(
73447 + __string( filename, filename )
73448 + __field( int, flags )
73449 + __field( int, mode )
73450 + ),
73451 +
73452 + TP_fast_assign(
73453 + __assign_str(filename, filename);
73454 + __entry->flags = flags;
73455 + __entry->mode = mode;
73456 + ),
73457 +
73458 + TP_printk("\"%s\" %x %o",
73459 + __get_str(filename), __entry->flags, __entry->mode)
73460 +);
73461 +
73462 +TRACE_EVENT(open_exec,
73463 +
73464 + TP_PROTO(const char *filename),
73465 +
73466 + TP_ARGS(filename),
73467 +
73468 + TP_STRUCT__entry(
73469 + __string( filename, filename )
73470 + ),
73471 +
73472 + TP_fast_assign(
73473 + __assign_str(filename, filename);
73474 + ),
73475 +
73476 + TP_printk("\"%s\"",
73477 + __get_str(filename))
73478 +);
73479 +
73480 +#endif /* _TRACE_FS_H */
73481 +
73482 +/* This part must be outside protection */
73483 +#include <trace/define_trace.h>
73484 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73485 index 1c09820..7f5ec79 100644
73486 --- a/include/trace/events/irq.h
73487 +++ b/include/trace/events/irq.h
73488 @@ -36,7 +36,7 @@ struct softirq_action;
73489 */
73490 TRACE_EVENT(irq_handler_entry,
73491
73492 - TP_PROTO(int irq, struct irqaction *action),
73493 + TP_PROTO(int irq, const struct irqaction *action),
73494
73495 TP_ARGS(irq, action),
73496
73497 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73498 */
73499 TRACE_EVENT(irq_handler_exit,
73500
73501 - TP_PROTO(int irq, struct irqaction *action, int ret),
73502 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73503
73504 TP_ARGS(irq, action, ret),
73505
73506 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73507 index 7caf44c..23c6f27 100644
73508 --- a/include/uapi/linux/a.out.h
73509 +++ b/include/uapi/linux/a.out.h
73510 @@ -39,6 +39,14 @@ enum machine_type {
73511 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73512 };
73513
73514 +/* Constants for the N_FLAGS field */
73515 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73516 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73517 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73518 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73519 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73520 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73521 +
73522 #if !defined (N_MAGIC)
73523 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73524 #endif
73525 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73526 index d876736..ccce5c0 100644
73527 --- a/include/uapi/linux/byteorder/little_endian.h
73528 +++ b/include/uapi/linux/byteorder/little_endian.h
73529 @@ -42,51 +42,51 @@
73530
73531 static inline __le64 __cpu_to_le64p(const __u64 *p)
73532 {
73533 - return (__force __le64)*p;
73534 + return (__force const __le64)*p;
73535 }
73536 -static inline __u64 __le64_to_cpup(const __le64 *p)
73537 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73538 {
73539 - return (__force __u64)*p;
73540 + return (__force const __u64)*p;
73541 }
73542 static inline __le32 __cpu_to_le32p(const __u32 *p)
73543 {
73544 - return (__force __le32)*p;
73545 + return (__force const __le32)*p;
73546 }
73547 static inline __u32 __le32_to_cpup(const __le32 *p)
73548 {
73549 - return (__force __u32)*p;
73550 + return (__force const __u32)*p;
73551 }
73552 static inline __le16 __cpu_to_le16p(const __u16 *p)
73553 {
73554 - return (__force __le16)*p;
73555 + return (__force const __le16)*p;
73556 }
73557 static inline __u16 __le16_to_cpup(const __le16 *p)
73558 {
73559 - return (__force __u16)*p;
73560 + return (__force const __u16)*p;
73561 }
73562 static inline __be64 __cpu_to_be64p(const __u64 *p)
73563 {
73564 - return (__force __be64)__swab64p(p);
73565 + return (__force const __be64)__swab64p(p);
73566 }
73567 static inline __u64 __be64_to_cpup(const __be64 *p)
73568 {
73569 - return __swab64p((__u64 *)p);
73570 + return __swab64p((const __u64 *)p);
73571 }
73572 static inline __be32 __cpu_to_be32p(const __u32 *p)
73573 {
73574 - return (__force __be32)__swab32p(p);
73575 + return (__force const __be32)__swab32p(p);
73576 }
73577 -static inline __u32 __be32_to_cpup(const __be32 *p)
73578 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73579 {
73580 - return __swab32p((__u32 *)p);
73581 + return __swab32p((const __u32 *)p);
73582 }
73583 static inline __be16 __cpu_to_be16p(const __u16 *p)
73584 {
73585 - return (__force __be16)__swab16p(p);
73586 + return (__force const __be16)__swab16p(p);
73587 }
73588 static inline __u16 __be16_to_cpup(const __be16 *p)
73589 {
73590 - return __swab16p((__u16 *)p);
73591 + return __swab16p((const __u16 *)p);
73592 }
73593 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73594 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73595 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73596 index 8072d35..e77aeb8 100644
73597 --- a/include/uapi/linux/elf.h
73598 +++ b/include/uapi/linux/elf.h
73599 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73600 #define PT_GNU_EH_FRAME 0x6474e550
73601
73602 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73603 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73604 +
73605 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73606 +
73607 +/* Constants for the e_flags field */
73608 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73609 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73610 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73611 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73612 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73613 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73614
73615 /*
73616 * Extended Numbering
73617 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73618 #define DT_DEBUG 21
73619 #define DT_TEXTREL 22
73620 #define DT_JMPREL 23
73621 +#define DT_FLAGS 30
73622 + #define DF_TEXTREL 0x00000004
73623 #define DT_ENCODING 32
73624 #define OLD_DT_LOOS 0x60000000
73625 #define DT_LOOS 0x6000000d
73626 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73627 #define PF_W 0x2
73628 #define PF_X 0x1
73629
73630 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73631 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73632 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73633 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73634 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73635 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73636 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73637 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73638 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73639 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73640 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73641 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73642 +
73643 typedef struct elf32_phdr{
73644 Elf32_Word p_type;
73645 Elf32_Off p_offset;
73646 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73647 #define EI_OSABI 7
73648 #define EI_PAD 8
73649
73650 +#define EI_PAX 14
73651 +
73652 #define ELFMAG0 0x7f /* EI_MAG */
73653 #define ELFMAG1 'E'
73654 #define ELFMAG2 'L'
73655 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73656 index aa169c4..6a2771d 100644
73657 --- a/include/uapi/linux/personality.h
73658 +++ b/include/uapi/linux/personality.h
73659 @@ -30,6 +30,7 @@ enum {
73660 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73661 ADDR_NO_RANDOMIZE | \
73662 ADDR_COMPAT_LAYOUT | \
73663 + ADDR_LIMIT_3GB | \
73664 MMAP_PAGE_ZERO)
73665
73666 /*
73667 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73668 index 7530e74..e714828 100644
73669 --- a/include/uapi/linux/screen_info.h
73670 +++ b/include/uapi/linux/screen_info.h
73671 @@ -43,7 +43,8 @@ struct screen_info {
73672 __u16 pages; /* 0x32 */
73673 __u16 vesa_attributes; /* 0x34 */
73674 __u32 capabilities; /* 0x36 */
73675 - __u8 _reserved[6]; /* 0x3a */
73676 + __u16 vesapm_size; /* 0x3a */
73677 + __u8 _reserved[4]; /* 0x3c */
73678 } __attribute__((packed));
73679
73680 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73681 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73682 index 0e011eb..82681b1 100644
73683 --- a/include/uapi/linux/swab.h
73684 +++ b/include/uapi/linux/swab.h
73685 @@ -43,7 +43,7 @@
73686 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73687 */
73688
73689 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73690 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73691 {
73692 #ifdef __HAVE_BUILTIN_BSWAP16__
73693 return __builtin_bswap16(val);
73694 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73695 #endif
73696 }
73697
73698 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73699 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73700 {
73701 #ifdef __HAVE_BUILTIN_BSWAP32__
73702 return __builtin_bswap32(val);
73703 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73704 #endif
73705 }
73706
73707 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73708 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73709 {
73710 #ifdef __HAVE_BUILTIN_BSWAP64__
73711 return __builtin_bswap64(val);
73712 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73713 index 6d67213..8dab561 100644
73714 --- a/include/uapi/linux/sysctl.h
73715 +++ b/include/uapi/linux/sysctl.h
73716 @@ -155,7 +155,11 @@ enum
73717 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73718 };
73719
73720 -
73721 +#ifdef CONFIG_PAX_SOFTMODE
73722 +enum {
73723 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73724 +};
73725 +#endif
73726
73727 /* CTL_VM names: */
73728 enum
73729 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73730 index e4629b9..6958086 100644
73731 --- a/include/uapi/linux/xattr.h
73732 +++ b/include/uapi/linux/xattr.h
73733 @@ -63,5 +63,9 @@
73734 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73735 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73736
73737 +/* User namespace */
73738 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73739 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73740 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73741
73742 #endif /* _UAPI_LINUX_XATTR_H */
73743 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73744 index f9466fa..f4e2b81 100644
73745 --- a/include/video/udlfb.h
73746 +++ b/include/video/udlfb.h
73747 @@ -53,10 +53,10 @@ struct dlfb_data {
73748 u32 pseudo_palette[256];
73749 int blank_mode; /*one of FB_BLANK_ */
73750 /* blit-only rendering path metrics, exposed through sysfs */
73751 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73752 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73753 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73754 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73755 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73756 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73757 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73758 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73759 };
73760
73761 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73762 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73763 index 1a91850..28573f8 100644
73764 --- a/include/video/uvesafb.h
73765 +++ b/include/video/uvesafb.h
73766 @@ -122,6 +122,7 @@ struct uvesafb_par {
73767 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73768 u8 pmi_setpal; /* PMI for palette changes */
73769 u16 *pmi_base; /* protected mode interface location */
73770 + u8 *pmi_code; /* protected mode code location */
73771 void *pmi_start;
73772 void *pmi_pal;
73773 u8 *vbe_state_orig; /*
73774 diff --git a/init/Kconfig b/init/Kconfig
73775 index 5341d72..153f24f 100644
73776 --- a/init/Kconfig
73777 +++ b/init/Kconfig
73778 @@ -984,6 +984,7 @@ endif # CGROUPS
73779
73780 config CHECKPOINT_RESTORE
73781 bool "Checkpoint/restore support" if EXPERT
73782 + depends on !GRKERNSEC
73783 default n
73784 help
73785 Enables additional kernel features in a sake of checkpoint/restore.
73786 @@ -1471,7 +1472,7 @@ config SLUB_DEBUG
73787
73788 config COMPAT_BRK
73789 bool "Disable heap randomization"
73790 - default y
73791 + default n
73792 help
73793 Randomizing heap placement makes heap exploits harder, but it
73794 also breaks ancient binaries (including anything libc5 based).
73795 @@ -1734,7 +1735,7 @@ config INIT_ALL_POSSIBLE
73796 config STOP_MACHINE
73797 bool
73798 default y
73799 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73800 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73801 help
73802 Need stop_machine() primitive.
73803
73804 diff --git a/init/Makefile b/init/Makefile
73805 index 7bc47ee..6da2dc7 100644
73806 --- a/init/Makefile
73807 +++ b/init/Makefile
73808 @@ -2,6 +2,9 @@
73809 # Makefile for the linux kernel.
73810 #
73811
73812 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73813 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73814 +
73815 obj-y := main.o version.o mounts.o
73816 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73817 obj-y += noinitramfs.o
73818 diff --git a/init/do_mounts.c b/init/do_mounts.c
73819 index a2b49f2..03a0e17c 100644
73820 --- a/init/do_mounts.c
73821 +++ b/init/do_mounts.c
73822 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73823 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73824 {
73825 struct super_block *s;
73826 - int err = sys_mount(name, "/root", fs, flags, data);
73827 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73828 if (err)
73829 return err;
73830
73831 - sys_chdir("/root");
73832 + sys_chdir((const char __force_user *)"/root");
73833 s = current->fs->pwd.dentry->d_sb;
73834 ROOT_DEV = s->s_dev;
73835 printk(KERN_INFO
73836 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73837 va_start(args, fmt);
73838 vsprintf(buf, fmt, args);
73839 va_end(args);
73840 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73841 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73842 if (fd >= 0) {
73843 sys_ioctl(fd, FDEJECT, 0);
73844 sys_close(fd);
73845 }
73846 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73847 - fd = sys_open("/dev/console", O_RDWR, 0);
73848 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73849 if (fd >= 0) {
73850 sys_ioctl(fd, TCGETS, (long)&termios);
73851 termios.c_lflag &= ~ICANON;
73852 sys_ioctl(fd, TCSETSF, (long)&termios);
73853 - sys_read(fd, &c, 1);
73854 + sys_read(fd, (char __user *)&c, 1);
73855 termios.c_lflag |= ICANON;
73856 sys_ioctl(fd, TCSETSF, (long)&termios);
73857 sys_close(fd);
73858 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73859 mount_root();
73860 out:
73861 devtmpfs_mount("dev");
73862 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73863 - sys_chroot(".");
73864 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73865 + sys_chroot((const char __force_user *)".");
73866 }
73867 diff --git a/init/do_mounts.h b/init/do_mounts.h
73868 index f5b978a..69dbfe8 100644
73869 --- a/init/do_mounts.h
73870 +++ b/init/do_mounts.h
73871 @@ -15,15 +15,15 @@ extern int root_mountflags;
73872
73873 static inline int create_dev(char *name, dev_t dev)
73874 {
73875 - sys_unlink(name);
73876 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73877 + sys_unlink((char __force_user *)name);
73878 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73879 }
73880
73881 #if BITS_PER_LONG == 32
73882 static inline u32 bstat(char *name)
73883 {
73884 struct stat64 stat;
73885 - if (sys_stat64(name, &stat) != 0)
73886 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73887 return 0;
73888 if (!S_ISBLK(stat.st_mode))
73889 return 0;
73890 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73891 static inline u32 bstat(char *name)
73892 {
73893 struct stat stat;
73894 - if (sys_newstat(name, &stat) != 0)
73895 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73896 return 0;
73897 if (!S_ISBLK(stat.st_mode))
73898 return 0;
73899 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73900 index a32ec1c..60a6659 100644
73901 --- a/init/do_mounts_initrd.c
73902 +++ b/init/do_mounts_initrd.c
73903 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
73904 {
73905 sys_unshare(CLONE_FS | CLONE_FILES);
73906 /* stdin/stdout/stderr for /linuxrc */
73907 - sys_open("/dev/console", O_RDWR, 0);
73908 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
73909 sys_dup(0);
73910 sys_dup(0);
73911 /* move initrd over / and chdir/chroot in initrd root */
73912 - sys_chdir("/root");
73913 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73914 - sys_chroot(".");
73915 + sys_chdir((const char __force_user *)"/root");
73916 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73917 + sys_chroot((const char __force_user *)".");
73918 sys_setsid();
73919 return 0;
73920 }
73921 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73922 create_dev("/dev/root.old", Root_RAM0);
73923 /* mount initrd on rootfs' /root */
73924 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73925 - sys_mkdir("/old", 0700);
73926 - sys_chdir("/old");
73927 + sys_mkdir((const char __force_user *)"/old", 0700);
73928 + sys_chdir((const char __force_user *)"/old");
73929
73930 /* try loading default modules from initrd */
73931 load_default_modules();
73932 @@ -76,31 +76,31 @@ static void __init handle_initrd(void)
73933 current->flags &= ~PF_FREEZER_SKIP;
73934
73935 /* move initrd to rootfs' /old */
73936 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73937 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73938 /* switch root and cwd back to / of rootfs */
73939 - sys_chroot("..");
73940 + sys_chroot((const char __force_user *)"..");
73941
73942 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73943 - sys_chdir("/old");
73944 + sys_chdir((const char __force_user *)"/old");
73945 return;
73946 }
73947
73948 - sys_chdir("/");
73949 + sys_chdir((const char __force_user *)"/");
73950 ROOT_DEV = new_decode_dev(real_root_dev);
73951 mount_root();
73952
73953 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73954 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73955 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73956 if (!error)
73957 printk("okay\n");
73958 else {
73959 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73960 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73961 if (error == -ENOENT)
73962 printk("/initrd does not exist. Ignored.\n");
73963 else
73964 printk("failed\n");
73965 printk(KERN_NOTICE "Unmounting old root\n");
73966 - sys_umount("/old", MNT_DETACH);
73967 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73968 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73969 if (fd < 0) {
73970 error = fd;
73971 @@ -123,11 +123,11 @@ int __init initrd_load(void)
73972 * mounted in the normal path.
73973 */
73974 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73975 - sys_unlink("/initrd.image");
73976 + sys_unlink((const char __force_user *)"/initrd.image");
73977 handle_initrd();
73978 return 1;
73979 }
73980 }
73981 - sys_unlink("/initrd.image");
73982 + sys_unlink((const char __force_user *)"/initrd.image");
73983 return 0;
73984 }
73985 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73986 index 8cb6db5..d729f50 100644
73987 --- a/init/do_mounts_md.c
73988 +++ b/init/do_mounts_md.c
73989 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73990 partitioned ? "_d" : "", minor,
73991 md_setup_args[ent].device_names);
73992
73993 - fd = sys_open(name, 0, 0);
73994 + fd = sys_open((char __force_user *)name, 0, 0);
73995 if (fd < 0) {
73996 printk(KERN_ERR "md: open failed - cannot start "
73997 "array %s\n", name);
73998 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73999 * array without it
74000 */
74001 sys_close(fd);
74002 - fd = sys_open(name, 0, 0);
74003 + fd = sys_open((char __force_user *)name, 0, 0);
74004 sys_ioctl(fd, BLKRRPART, 0);
74005 }
74006 sys_close(fd);
74007 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
74008
74009 wait_for_device_probe();
74010
74011 - fd = sys_open("/dev/md0", 0, 0);
74012 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
74013 if (fd >= 0) {
74014 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
74015 sys_close(fd);
74016 diff --git a/init/init_task.c b/init/init_task.c
74017 index ba0a7f36..2bcf1d5 100644
74018 --- a/init/init_task.c
74019 +++ b/init/init_task.c
74020 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
74021 * Initial thread structure. Alignment of this is handled by a special
74022 * linker map entry.
74023 */
74024 +#ifdef CONFIG_X86
74025 +union thread_union init_thread_union __init_task_data;
74026 +#else
74027 union thread_union init_thread_union __init_task_data =
74028 { INIT_THREAD_INFO(init_task) };
74029 +#endif
74030 diff --git a/init/initramfs.c b/init/initramfs.c
74031 index a67ef9d..2d17ed9 100644
74032 --- a/init/initramfs.c
74033 +++ b/init/initramfs.c
74034 @@ -84,7 +84,7 @@ static void __init free_hash(void)
74035 }
74036 }
74037
74038 -static long __init do_utime(char *filename, time_t mtime)
74039 +static long __init do_utime(char __force_user *filename, time_t mtime)
74040 {
74041 struct timespec t[2];
74042
74043 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
74044 struct dir_entry *de, *tmp;
74045 list_for_each_entry_safe(de, tmp, &dir_list, list) {
74046 list_del(&de->list);
74047 - do_utime(de->name, de->mtime);
74048 + do_utime((char __force_user *)de->name, de->mtime);
74049 kfree(de->name);
74050 kfree(de);
74051 }
74052 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
74053 if (nlink >= 2) {
74054 char *old = find_link(major, minor, ino, mode, collected);
74055 if (old)
74056 - return (sys_link(old, collected) < 0) ? -1 : 1;
74057 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
74058 }
74059 return 0;
74060 }
74061 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
74062 {
74063 struct stat st;
74064
74065 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
74066 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
74067 if (S_ISDIR(st.st_mode))
74068 - sys_rmdir(path);
74069 + sys_rmdir((char __force_user *)path);
74070 else
74071 - sys_unlink(path);
74072 + sys_unlink((char __force_user *)path);
74073 }
74074 }
74075
74076 @@ -315,7 +315,7 @@ static int __init do_name(void)
74077 int openflags = O_WRONLY|O_CREAT;
74078 if (ml != 1)
74079 openflags |= O_TRUNC;
74080 - wfd = sys_open(collected, openflags, mode);
74081 + wfd = sys_open((char __force_user *)collected, openflags, mode);
74082
74083 if (wfd >= 0) {
74084 sys_fchown(wfd, uid, gid);
74085 @@ -327,17 +327,17 @@ static int __init do_name(void)
74086 }
74087 }
74088 } else if (S_ISDIR(mode)) {
74089 - sys_mkdir(collected, mode);
74090 - sys_chown(collected, uid, gid);
74091 - sys_chmod(collected, mode);
74092 + sys_mkdir((char __force_user *)collected, mode);
74093 + sys_chown((char __force_user *)collected, uid, gid);
74094 + sys_chmod((char __force_user *)collected, mode);
74095 dir_add(collected, mtime);
74096 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
74097 S_ISFIFO(mode) || S_ISSOCK(mode)) {
74098 if (maybe_link() == 0) {
74099 - sys_mknod(collected, mode, rdev);
74100 - sys_chown(collected, uid, gid);
74101 - sys_chmod(collected, mode);
74102 - do_utime(collected, mtime);
74103 + sys_mknod((char __force_user *)collected, mode, rdev);
74104 + sys_chown((char __force_user *)collected, uid, gid);
74105 + sys_chmod((char __force_user *)collected, mode);
74106 + do_utime((char __force_user *)collected, mtime);
74107 }
74108 }
74109 return 0;
74110 @@ -346,15 +346,15 @@ static int __init do_name(void)
74111 static int __init do_copy(void)
74112 {
74113 if (count >= body_len) {
74114 - sys_write(wfd, victim, body_len);
74115 + sys_write(wfd, (char __force_user *)victim, body_len);
74116 sys_close(wfd);
74117 - do_utime(vcollected, mtime);
74118 + do_utime((char __force_user *)vcollected, mtime);
74119 kfree(vcollected);
74120 eat(body_len);
74121 state = SkipIt;
74122 return 0;
74123 } else {
74124 - sys_write(wfd, victim, count);
74125 + sys_write(wfd, (char __force_user *)victim, count);
74126 body_len -= count;
74127 eat(count);
74128 return 1;
74129 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
74130 {
74131 collected[N_ALIGN(name_len) + body_len] = '\0';
74132 clean_path(collected, 0);
74133 - sys_symlink(collected + N_ALIGN(name_len), collected);
74134 - sys_lchown(collected, uid, gid);
74135 - do_utime(collected, mtime);
74136 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
74137 + sys_lchown((char __force_user *)collected, uid, gid);
74138 + do_utime((char __force_user *)collected, mtime);
74139 state = SkipIt;
74140 next_state = Reset;
74141 return 0;
74142 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
74143 {
74144 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
74145 if (err)
74146 - panic(err); /* Failed to decompress INTERNAL initramfs */
74147 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
74148 if (initrd_start) {
74149 #ifdef CONFIG_BLK_DEV_RAM
74150 int fd;
74151 diff --git a/init/main.c b/init/main.c
74152 index 63534a1..85feae2 100644
74153 --- a/init/main.c
74154 +++ b/init/main.c
74155 @@ -98,6 +98,8 @@ static inline void mark_rodata_ro(void) { }
74156 extern void tc_init(void);
74157 #endif
74158
74159 +extern void grsecurity_init(void);
74160 +
74161 /*
74162 * Debug helper: via this flag we know that we are in 'early bootup code'
74163 * where only the boot processor is running with IRQ disabled. This means
74164 @@ -151,6 +153,64 @@ static int __init set_reset_devices(char *str)
74165
74166 __setup("reset_devices", set_reset_devices);
74167
74168 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74169 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74170 +static int __init setup_grsec_proc_gid(char *str)
74171 +{
74172 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74173 + return 1;
74174 +}
74175 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74176 +#endif
74177 +
74178 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74179 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
74180 +EXPORT_SYMBOL(pax_user_shadow_base);
74181 +extern char pax_enter_kernel_user[];
74182 +extern char pax_exit_kernel_user[];
74183 +extern pgdval_t clone_pgd_mask;
74184 +#endif
74185 +
74186 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74187 +static int __init setup_pax_nouderef(char *str)
74188 +{
74189 +#ifdef CONFIG_X86_32
74190 + unsigned int cpu;
74191 + struct desc_struct *gdt;
74192 +
74193 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74194 + gdt = get_cpu_gdt_table(cpu);
74195 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74196 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74197 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74198 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74199 + }
74200 + loadsegment(ds, __KERNEL_DS);
74201 + loadsegment(es, __KERNEL_DS);
74202 + loadsegment(ss, __KERNEL_DS);
74203 +#else
74204 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74205 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74206 + clone_pgd_mask = ~(pgdval_t)0UL;
74207 + pax_user_shadow_base = 0UL;
74208 +#endif
74209 +
74210 + return 0;
74211 +}
74212 +early_param("pax_nouderef", setup_pax_nouderef);
74213 +#endif
74214 +
74215 +#ifdef CONFIG_PAX_SOFTMODE
74216 +int pax_softmode;
74217 +
74218 +static int __init setup_pax_softmode(char *str)
74219 +{
74220 + get_option(&str, &pax_softmode);
74221 + return 1;
74222 +}
74223 +__setup("pax_softmode=", setup_pax_softmode);
74224 +#endif
74225 +
74226 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74227 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74228 static const char *panic_later, *panic_param;
74229 @@ -683,6 +743,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
74230 {
74231 int count = preempt_count();
74232 int ret;
74233 + const char *msg1 = "", *msg2 = "";
74234
74235 if (initcall_debug)
74236 ret = do_one_initcall_debug(fn);
74237 @@ -695,15 +756,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
74238 sprintf(msgbuf, "error code %d ", ret);
74239
74240 if (preempt_count() != count) {
74241 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
74242 + msg1 = " preemption imbalance";
74243 preempt_count() = count;
74244 }
74245 if (irqs_disabled()) {
74246 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74247 + msg2 = " disabled interrupts";
74248 local_irq_enable();
74249 }
74250 - if (msgbuf[0]) {
74251 - printk("initcall %pF returned with %s\n", fn, msgbuf);
74252 + if (msgbuf[0] || *msg1 || *msg2) {
74253 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
74254 }
74255
74256 return ret;
74257 @@ -757,8 +818,14 @@ static void __init do_initcall_level(int level)
74258 level, level,
74259 &repair_env_string);
74260
74261 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74262 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74263 do_one_initcall(*fn);
74264 +
74265 +#ifdef LATENT_ENTROPY_PLUGIN
74266 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74267 +#endif
74268 +
74269 + }
74270 }
74271
74272 static void __init do_initcalls(void)
74273 @@ -792,8 +859,14 @@ static void __init do_pre_smp_initcalls(void)
74274 {
74275 initcall_t *fn;
74276
74277 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74278 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74279 do_one_initcall(*fn);
74280 +
74281 +#ifdef LATENT_ENTROPY_PLUGIN
74282 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74283 +#endif
74284 +
74285 + }
74286 }
74287
74288 /*
74289 @@ -811,8 +884,8 @@ static int run_init_process(const char *init_filename)
74290 {
74291 argv_init[0] = init_filename;
74292 return do_execve(init_filename,
74293 - (const char __user *const __user *)argv_init,
74294 - (const char __user *const __user *)envp_init);
74295 + (const char __user *const __force_user *)argv_init,
74296 + (const char __user *const __force_user *)envp_init);
74297 }
74298
74299 static noinline void __init kernel_init_freeable(void);
74300 @@ -890,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
74301 do_basic_setup();
74302
74303 /* Open the /dev/console on the rootfs, this should never fail */
74304 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74305 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74306 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74307
74308 (void) sys_dup(0);
74309 @@ -903,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
74310 if (!ramdisk_execute_command)
74311 ramdisk_execute_command = "/init";
74312
74313 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74314 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74315 ramdisk_execute_command = NULL;
74316 prepare_namespace();
74317 }
74318
74319 + grsecurity_init();
74320 +
74321 /*
74322 * Ok, we have completed the initial bootup, and
74323 * we're essentially up and running. Get rid of the
74324 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74325 index 130dfec..cc88451 100644
74326 --- a/ipc/ipc_sysctl.c
74327 +++ b/ipc/ipc_sysctl.c
74328 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74329 static int proc_ipc_dointvec(ctl_table *table, int write,
74330 void __user *buffer, size_t *lenp, loff_t *ppos)
74331 {
74332 - struct ctl_table ipc_table;
74333 + ctl_table_no_const ipc_table;
74334
74335 memcpy(&ipc_table, table, sizeof(ipc_table));
74336 ipc_table.data = get_ipc(table);
74337 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74338 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74339 void __user *buffer, size_t *lenp, loff_t *ppos)
74340 {
74341 - struct ctl_table ipc_table;
74342 + ctl_table_no_const ipc_table;
74343
74344 memcpy(&ipc_table, table, sizeof(ipc_table));
74345 ipc_table.data = get_ipc(table);
74346 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74347 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74348 void __user *buffer, size_t *lenp, loff_t *ppos)
74349 {
74350 - struct ctl_table ipc_table;
74351 + ctl_table_no_const ipc_table;
74352 size_t lenp_bef = *lenp;
74353 int rc;
74354
74355 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74356 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74357 void __user *buffer, size_t *lenp, loff_t *ppos)
74358 {
74359 - struct ctl_table ipc_table;
74360 + ctl_table_no_const ipc_table;
74361 memcpy(&ipc_table, table, sizeof(ipc_table));
74362 ipc_table.data = get_ipc(table);
74363
74364 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74365 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74366 void __user *buffer, size_t *lenp, loff_t *ppos)
74367 {
74368 - struct ctl_table ipc_table;
74369 + ctl_table_no_const ipc_table;
74370 size_t lenp_bef = *lenp;
74371 int oldval;
74372 int rc;
74373 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74374 index 383d638..943fdbb 100644
74375 --- a/ipc/mq_sysctl.c
74376 +++ b/ipc/mq_sysctl.c
74377 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74378 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74379 void __user *buffer, size_t *lenp, loff_t *ppos)
74380 {
74381 - struct ctl_table mq_table;
74382 + ctl_table_no_const mq_table;
74383 memcpy(&mq_table, table, sizeof(mq_table));
74384 mq_table.data = get_mq(table);
74385
74386 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74387 index e4e47f6..a85e0ad 100644
74388 --- a/ipc/mqueue.c
74389 +++ b/ipc/mqueue.c
74390 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74391 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74392 info->attr.mq_msgsize);
74393
74394 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74395 spin_lock(&mq_lock);
74396 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74397 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74398 diff --git a/ipc/msg.c b/ipc/msg.c
74399 index fede1d0..9778e0f8 100644
74400 --- a/ipc/msg.c
74401 +++ b/ipc/msg.c
74402 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74403 return security_msg_queue_associate(msq, msgflg);
74404 }
74405
74406 +static struct ipc_ops msg_ops = {
74407 + .getnew = newque,
74408 + .associate = msg_security,
74409 + .more_checks = NULL
74410 +};
74411 +
74412 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74413 {
74414 struct ipc_namespace *ns;
74415 - struct ipc_ops msg_ops;
74416 struct ipc_params msg_params;
74417
74418 ns = current->nsproxy->ipc_ns;
74419
74420 - msg_ops.getnew = newque;
74421 - msg_ops.associate = msg_security;
74422 - msg_ops.more_checks = NULL;
74423 -
74424 msg_params.key = key;
74425 msg_params.flg = msgflg;
74426
74427 diff --git a/ipc/sem.c b/ipc/sem.c
74428 index 58d31f1..cce7a55 100644
74429 --- a/ipc/sem.c
74430 +++ b/ipc/sem.c
74431 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74432 return 0;
74433 }
74434
74435 +static struct ipc_ops sem_ops = {
74436 + .getnew = newary,
74437 + .associate = sem_security,
74438 + .more_checks = sem_more_checks
74439 +};
74440 +
74441 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74442 {
74443 struct ipc_namespace *ns;
74444 - struct ipc_ops sem_ops;
74445 struct ipc_params sem_params;
74446
74447 ns = current->nsproxy->ipc_ns;
74448 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74449 if (nsems < 0 || nsems > ns->sc_semmsl)
74450 return -EINVAL;
74451
74452 - sem_ops.getnew = newary;
74453 - sem_ops.associate = sem_security;
74454 - sem_ops.more_checks = sem_more_checks;
74455 -
74456 sem_params.key = key;
74457 sem_params.flg = semflg;
74458 sem_params.u.nsems = nsems;
74459 diff --git a/ipc/shm.c b/ipc/shm.c
74460 index 7e199fa..180a1ca 100644
74461 --- a/ipc/shm.c
74462 +++ b/ipc/shm.c
74463 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74464 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74465 #endif
74466
74467 +#ifdef CONFIG_GRKERNSEC
74468 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74469 + const time_t shm_createtime, const kuid_t cuid,
74470 + const int shmid);
74471 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74472 + const time_t shm_createtime);
74473 +#endif
74474 +
74475 void shm_init_ns(struct ipc_namespace *ns)
74476 {
74477 ns->shm_ctlmax = SHMMAX;
74478 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74479 shp->shm_lprid = 0;
74480 shp->shm_atim = shp->shm_dtim = 0;
74481 shp->shm_ctim = get_seconds();
74482 +#ifdef CONFIG_GRKERNSEC
74483 + {
74484 + struct timespec timeval;
74485 + do_posix_clock_monotonic_gettime(&timeval);
74486 +
74487 + shp->shm_createtime = timeval.tv_sec;
74488 + }
74489 +#endif
74490 shp->shm_segsz = size;
74491 shp->shm_nattch = 0;
74492 shp->shm_file = file;
74493 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74494 return 0;
74495 }
74496
74497 +static struct ipc_ops shm_ops = {
74498 + .getnew = newseg,
74499 + .associate = shm_security,
74500 + .more_checks = shm_more_checks
74501 +};
74502 +
74503 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74504 {
74505 struct ipc_namespace *ns;
74506 - struct ipc_ops shm_ops;
74507 struct ipc_params shm_params;
74508
74509 ns = current->nsproxy->ipc_ns;
74510
74511 - shm_ops.getnew = newseg;
74512 - shm_ops.associate = shm_security;
74513 - shm_ops.more_checks = shm_more_checks;
74514 -
74515 shm_params.key = key;
74516 shm_params.flg = shmflg;
74517 shm_params.u.size = size;
74518 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74519 f_mode = FMODE_READ | FMODE_WRITE;
74520 }
74521 if (shmflg & SHM_EXEC) {
74522 +
74523 +#ifdef CONFIG_PAX_MPROTECT
74524 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74525 + goto out;
74526 +#endif
74527 +
74528 prot |= PROT_EXEC;
74529 acc_mode |= S_IXUGO;
74530 }
74531 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74532 if (err)
74533 goto out_unlock;
74534
74535 +#ifdef CONFIG_GRKERNSEC
74536 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74537 + shp->shm_perm.cuid, shmid) ||
74538 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74539 + err = -EACCES;
74540 + goto out_unlock;
74541 + }
74542 +#endif
74543 +
74544 path = shp->shm_file->f_path;
74545 path_get(&path);
74546 shp->shm_nattch++;
74547 +#ifdef CONFIG_GRKERNSEC
74548 + shp->shm_lapid = current->pid;
74549 +#endif
74550 size = i_size_read(path.dentry->d_inode);
74551 shm_unlock(shp);
74552
74553 diff --git a/kernel/acct.c b/kernel/acct.c
74554 index b9bd7f0..1762b4a 100644
74555 --- a/kernel/acct.c
74556 +++ b/kernel/acct.c
74557 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74558 */
74559 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74560 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74561 - file->f_op->write(file, (char *)&ac,
74562 + file->f_op->write(file, (char __force_user *)&ac,
74563 sizeof(acct_t), &file->f_pos);
74564 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74565 set_fs(fs);
74566 diff --git a/kernel/audit.c b/kernel/audit.c
74567 index 8a667f10..7375e3f 100644
74568 --- a/kernel/audit.c
74569 +++ b/kernel/audit.c
74570 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74571 3) suppressed due to audit_rate_limit
74572 4) suppressed due to audit_backlog_limit
74573 */
74574 -static atomic_t audit_lost = ATOMIC_INIT(0);
74575 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74576
74577 /* The netlink socket. */
74578 static struct sock *audit_sock;
74579 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74580 unsigned long now;
74581 int print;
74582
74583 - atomic_inc(&audit_lost);
74584 + atomic_inc_unchecked(&audit_lost);
74585
74586 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74587
74588 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74589 printk(KERN_WARNING
74590 "audit: audit_lost=%d audit_rate_limit=%d "
74591 "audit_backlog_limit=%d\n",
74592 - atomic_read(&audit_lost),
74593 + atomic_read_unchecked(&audit_lost),
74594 audit_rate_limit,
74595 audit_backlog_limit);
74596 audit_panic(message);
74597 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74598 status_set.pid = audit_pid;
74599 status_set.rate_limit = audit_rate_limit;
74600 status_set.backlog_limit = audit_backlog_limit;
74601 - status_set.lost = atomic_read(&audit_lost);
74602 + status_set.lost = atomic_read_unchecked(&audit_lost);
74603 status_set.backlog = skb_queue_len(&audit_skb_queue);
74604 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74605 &status_set, sizeof(status_set));
74606 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74607 index c4b72b0..8654c4e 100644
74608 --- a/kernel/auditsc.c
74609 +++ b/kernel/auditsc.c
74610 @@ -2295,7 +2295,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74611 }
74612
74613 /* global counter which is incremented every time something logs in */
74614 -static atomic_t session_id = ATOMIC_INIT(0);
74615 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74616
74617 /**
74618 * audit_set_loginuid - set current task's audit_context loginuid
74619 @@ -2319,7 +2319,7 @@ int audit_set_loginuid(kuid_t loginuid)
74620 return -EPERM;
74621 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74622
74623 - sessionid = atomic_inc_return(&session_id);
74624 + sessionid = atomic_inc_return_unchecked(&session_id);
74625 if (context && context->in_syscall) {
74626 struct audit_buffer *ab;
74627
74628 diff --git a/kernel/capability.c b/kernel/capability.c
74629 index f6c2ce5..982c0f9 100644
74630 --- a/kernel/capability.c
74631 +++ b/kernel/capability.c
74632 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74633 * before modification is attempted and the application
74634 * fails.
74635 */
74636 + if (tocopy > ARRAY_SIZE(kdata))
74637 + return -EFAULT;
74638 +
74639 if (copy_to_user(dataptr, kdata, tocopy
74640 * sizeof(struct __user_cap_data_struct))) {
74641 return -EFAULT;
74642 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74643 int ret;
74644
74645 rcu_read_lock();
74646 - ret = security_capable(__task_cred(t), ns, cap);
74647 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74648 + gr_task_is_capable(t, __task_cred(t), cap);
74649 rcu_read_unlock();
74650
74651 - return (ret == 0);
74652 + return ret;
74653 }
74654
74655 /**
74656 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74657 int ret;
74658
74659 rcu_read_lock();
74660 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74661 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74662 rcu_read_unlock();
74663
74664 - return (ret == 0);
74665 + return ret;
74666 }
74667
74668 /**
74669 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74670 BUG();
74671 }
74672
74673 - if (security_capable(current_cred(), ns, cap) == 0) {
74674 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74675 current->flags |= PF_SUPERPRIV;
74676 return true;
74677 }
74678 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74679 }
74680 EXPORT_SYMBOL(ns_capable);
74681
74682 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74683 +{
74684 + if (unlikely(!cap_valid(cap))) {
74685 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74686 + BUG();
74687 + }
74688 +
74689 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74690 + current->flags |= PF_SUPERPRIV;
74691 + return true;
74692 + }
74693 + return false;
74694 +}
74695 +EXPORT_SYMBOL(ns_capable_nolog);
74696 +
74697 /**
74698 * file_ns_capable - Determine if the file's opener had a capability in effect
74699 * @file: The file we want to check
74700 @@ -432,6 +451,12 @@ bool capable(int cap)
74701 }
74702 EXPORT_SYMBOL(capable);
74703
74704 +bool capable_nolog(int cap)
74705 +{
74706 + return ns_capable_nolog(&init_user_ns, cap);
74707 +}
74708 +EXPORT_SYMBOL(capable_nolog);
74709 +
74710 /**
74711 * nsown_capable - Check superior capability to one's own user_ns
74712 * @cap: The capability in question
74713 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74714
74715 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74716 }
74717 +
74718 +bool inode_capable_nolog(const struct inode *inode, int cap)
74719 +{
74720 + struct user_namespace *ns = current_user_ns();
74721 +
74722 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74723 +}
74724 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74725 index a48de6a..df24bfe 100644
74726 --- a/kernel/cgroup.c
74727 +++ b/kernel/cgroup.c
74728 @@ -5567,7 +5567,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74729 struct css_set *cg = link->cg;
74730 struct task_struct *task;
74731 int count = 0;
74732 - seq_printf(seq, "css_set %p\n", cg);
74733 + seq_printf(seq, "css_set %pK\n", cg);
74734 list_for_each_entry(task, &cg->tasks, cg_list) {
74735 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74736 seq_puts(seq, " ...\n");
74737 diff --git a/kernel/compat.c b/kernel/compat.c
74738 index 19971d8..02fe2df 100644
74739 --- a/kernel/compat.c
74740 +++ b/kernel/compat.c
74741 @@ -13,6 +13,7 @@
74742
74743 #include <linux/linkage.h>
74744 #include <linux/compat.h>
74745 +#include <linux/module.h>
74746 #include <linux/errno.h>
74747 #include <linux/time.h>
74748 #include <linux/signal.h>
74749 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74750 mm_segment_t oldfs;
74751 long ret;
74752
74753 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74754 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74755 oldfs = get_fs();
74756 set_fs(KERNEL_DS);
74757 ret = hrtimer_nanosleep_restart(restart);
74758 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74759 oldfs = get_fs();
74760 set_fs(KERNEL_DS);
74761 ret = hrtimer_nanosleep(&tu,
74762 - rmtp ? (struct timespec __user *)&rmt : NULL,
74763 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74764 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74765 set_fs(oldfs);
74766
74767 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74768 mm_segment_t old_fs = get_fs();
74769
74770 set_fs(KERNEL_DS);
74771 - ret = sys_sigpending((old_sigset_t __user *) &s);
74772 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74773 set_fs(old_fs);
74774 if (ret == 0)
74775 ret = put_user(s, set);
74776 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74777 mm_segment_t old_fs = get_fs();
74778
74779 set_fs(KERNEL_DS);
74780 - ret = sys_old_getrlimit(resource, &r);
74781 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74782 set_fs(old_fs);
74783
74784 if (!ret) {
74785 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74786 mm_segment_t old_fs = get_fs();
74787
74788 set_fs(KERNEL_DS);
74789 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74790 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74791 set_fs(old_fs);
74792
74793 if (ret)
74794 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74795 set_fs (KERNEL_DS);
74796 ret = sys_wait4(pid,
74797 (stat_addr ?
74798 - (unsigned int __user *) &status : NULL),
74799 - options, (struct rusage __user *) &r);
74800 + (unsigned int __force_user *) &status : NULL),
74801 + options, (struct rusage __force_user *) &r);
74802 set_fs (old_fs);
74803
74804 if (ret > 0) {
74805 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74806 memset(&info, 0, sizeof(info));
74807
74808 set_fs(KERNEL_DS);
74809 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74810 - uru ? (struct rusage __user *)&ru : NULL);
74811 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74812 + uru ? (struct rusage __force_user *)&ru : NULL);
74813 set_fs(old_fs);
74814
74815 if ((ret < 0) || (info.si_signo == 0))
74816 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74817 oldfs = get_fs();
74818 set_fs(KERNEL_DS);
74819 err = sys_timer_settime(timer_id, flags,
74820 - (struct itimerspec __user *) &newts,
74821 - (struct itimerspec __user *) &oldts);
74822 + (struct itimerspec __force_user *) &newts,
74823 + (struct itimerspec __force_user *) &oldts);
74824 set_fs(oldfs);
74825 if (!err && old && put_compat_itimerspec(old, &oldts))
74826 return -EFAULT;
74827 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74828 oldfs = get_fs();
74829 set_fs(KERNEL_DS);
74830 err = sys_timer_gettime(timer_id,
74831 - (struct itimerspec __user *) &ts);
74832 + (struct itimerspec __force_user *) &ts);
74833 set_fs(oldfs);
74834 if (!err && put_compat_itimerspec(setting, &ts))
74835 return -EFAULT;
74836 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74837 oldfs = get_fs();
74838 set_fs(KERNEL_DS);
74839 err = sys_clock_settime(which_clock,
74840 - (struct timespec __user *) &ts);
74841 + (struct timespec __force_user *) &ts);
74842 set_fs(oldfs);
74843 return err;
74844 }
74845 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74846 oldfs = get_fs();
74847 set_fs(KERNEL_DS);
74848 err = sys_clock_gettime(which_clock,
74849 - (struct timespec __user *) &ts);
74850 + (struct timespec __force_user *) &ts);
74851 set_fs(oldfs);
74852 if (!err && put_compat_timespec(&ts, tp))
74853 return -EFAULT;
74854 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74855
74856 oldfs = get_fs();
74857 set_fs(KERNEL_DS);
74858 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74859 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74860 set_fs(oldfs);
74861
74862 err = compat_put_timex(utp, &txc);
74863 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74864 oldfs = get_fs();
74865 set_fs(KERNEL_DS);
74866 err = sys_clock_getres(which_clock,
74867 - (struct timespec __user *) &ts);
74868 + (struct timespec __force_user *) &ts);
74869 set_fs(oldfs);
74870 if (!err && tp && put_compat_timespec(&ts, tp))
74871 return -EFAULT;
74872 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74873 long err;
74874 mm_segment_t oldfs;
74875 struct timespec tu;
74876 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74877 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74878
74879 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74880 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74881 oldfs = get_fs();
74882 set_fs(KERNEL_DS);
74883 err = clock_nanosleep_restart(restart);
74884 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74885 oldfs = get_fs();
74886 set_fs(KERNEL_DS);
74887 err = sys_clock_nanosleep(which_clock, flags,
74888 - (struct timespec __user *) &in,
74889 - (struct timespec __user *) &out);
74890 + (struct timespec __force_user *) &in,
74891 + (struct timespec __force_user *) &out);
74892 set_fs(oldfs);
74893
74894 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74895 diff --git a/kernel/configs.c b/kernel/configs.c
74896 index 42e8fa0..9e7406b 100644
74897 --- a/kernel/configs.c
74898 +++ b/kernel/configs.c
74899 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74900 struct proc_dir_entry *entry;
74901
74902 /* create the current config file */
74903 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74904 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74905 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74906 + &ikconfig_file_ops);
74907 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74908 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74909 + &ikconfig_file_ops);
74910 +#endif
74911 +#else
74912 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74913 &ikconfig_file_ops);
74914 +#endif
74915 +
74916 if (!entry)
74917 return -ENOMEM;
74918
74919 diff --git a/kernel/cred.c b/kernel/cred.c
74920 index e0573a4..3874e41 100644
74921 --- a/kernel/cred.c
74922 +++ b/kernel/cred.c
74923 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74924 validate_creds(cred);
74925 alter_cred_subscribers(cred, -1);
74926 put_cred(cred);
74927 +
74928 +#ifdef CONFIG_GRKERNSEC_SETXID
74929 + cred = (struct cred *) tsk->delayed_cred;
74930 + if (cred != NULL) {
74931 + tsk->delayed_cred = NULL;
74932 + validate_creds(cred);
74933 + alter_cred_subscribers(cred, -1);
74934 + put_cred(cred);
74935 + }
74936 +#endif
74937 }
74938
74939 /**
74940 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74941 * Always returns 0 thus allowing this function to be tail-called at the end
74942 * of, say, sys_setgid().
74943 */
74944 -int commit_creds(struct cred *new)
74945 +static int __commit_creds(struct cred *new)
74946 {
74947 struct task_struct *task = current;
74948 const struct cred *old = task->real_cred;
74949 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74950
74951 get_cred(new); /* we will require a ref for the subj creds too */
74952
74953 + gr_set_role_label(task, new->uid, new->gid);
74954 +
74955 /* dumpability changes */
74956 if (!uid_eq(old->euid, new->euid) ||
74957 !gid_eq(old->egid, new->egid) ||
74958 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74959 put_cred(old);
74960 return 0;
74961 }
74962 +#ifdef CONFIG_GRKERNSEC_SETXID
74963 +extern int set_user(struct cred *new);
74964 +
74965 +void gr_delayed_cred_worker(void)
74966 +{
74967 + const struct cred *new = current->delayed_cred;
74968 + struct cred *ncred;
74969 +
74970 + current->delayed_cred = NULL;
74971 +
74972 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74973 + // from doing get_cred on it when queueing this
74974 + put_cred(new);
74975 + return;
74976 + } else if (new == NULL)
74977 + return;
74978 +
74979 + ncred = prepare_creds();
74980 + if (!ncred)
74981 + goto die;
74982 + // uids
74983 + ncred->uid = new->uid;
74984 + ncred->euid = new->euid;
74985 + ncred->suid = new->suid;
74986 + ncred->fsuid = new->fsuid;
74987 + // gids
74988 + ncred->gid = new->gid;
74989 + ncred->egid = new->egid;
74990 + ncred->sgid = new->sgid;
74991 + ncred->fsgid = new->fsgid;
74992 + // groups
74993 + if (set_groups(ncred, new->group_info) < 0) {
74994 + abort_creds(ncred);
74995 + goto die;
74996 + }
74997 + // caps
74998 + ncred->securebits = new->securebits;
74999 + ncred->cap_inheritable = new->cap_inheritable;
75000 + ncred->cap_permitted = new->cap_permitted;
75001 + ncred->cap_effective = new->cap_effective;
75002 + ncred->cap_bset = new->cap_bset;
75003 +
75004 + if (set_user(ncred)) {
75005 + abort_creds(ncred);
75006 + goto die;
75007 + }
75008 +
75009 + // from doing get_cred on it when queueing this
75010 + put_cred(new);
75011 +
75012 + __commit_creds(ncred);
75013 + return;
75014 +die:
75015 + // from doing get_cred on it when queueing this
75016 + put_cred(new);
75017 + do_group_exit(SIGKILL);
75018 +}
75019 +#endif
75020 +
75021 +int commit_creds(struct cred *new)
75022 +{
75023 +#ifdef CONFIG_GRKERNSEC_SETXID
75024 + int ret;
75025 + int schedule_it = 0;
75026 + struct task_struct *t;
75027 +
75028 + /* we won't get called with tasklist_lock held for writing
75029 + and interrupts disabled as the cred struct in that case is
75030 + init_cred
75031 + */
75032 + if (grsec_enable_setxid && !current_is_single_threaded() &&
75033 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
75034 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
75035 + schedule_it = 1;
75036 + }
75037 + ret = __commit_creds(new);
75038 + if (schedule_it) {
75039 + rcu_read_lock();
75040 + read_lock(&tasklist_lock);
75041 + for (t = next_thread(current); t != current;
75042 + t = next_thread(t)) {
75043 + if (t->delayed_cred == NULL) {
75044 + t->delayed_cred = get_cred(new);
75045 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
75046 + set_tsk_need_resched(t);
75047 + }
75048 + }
75049 + read_unlock(&tasklist_lock);
75050 + rcu_read_unlock();
75051 + }
75052 + return ret;
75053 +#else
75054 + return __commit_creds(new);
75055 +#endif
75056 +}
75057 +
75058 EXPORT_SYMBOL(commit_creds);
75059
75060 /**
75061 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
75062 index c26278f..e323fb8 100644
75063 --- a/kernel/debug/debug_core.c
75064 +++ b/kernel/debug/debug_core.c
75065 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
75066 */
75067 static atomic_t masters_in_kgdb;
75068 static atomic_t slaves_in_kgdb;
75069 -static atomic_t kgdb_break_tasklet_var;
75070 +static atomic_unchecked_t kgdb_break_tasklet_var;
75071 atomic_t kgdb_setting_breakpoint;
75072
75073 struct task_struct *kgdb_usethread;
75074 @@ -133,7 +133,7 @@ int kgdb_single_step;
75075 static pid_t kgdb_sstep_pid;
75076
75077 /* to keep track of the CPU which is doing the single stepping*/
75078 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75079 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75080
75081 /*
75082 * If you are debugging a problem where roundup (the collection of
75083 @@ -541,7 +541,7 @@ return_normal:
75084 * kernel will only try for the value of sstep_tries before
75085 * giving up and continuing on.
75086 */
75087 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
75088 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
75089 (kgdb_info[cpu].task &&
75090 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
75091 atomic_set(&kgdb_active, -1);
75092 @@ -635,8 +635,8 @@ cpu_master_loop:
75093 }
75094
75095 kgdb_restore:
75096 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
75097 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
75098 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
75099 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
75100 if (kgdb_info[sstep_cpu].task)
75101 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
75102 else
75103 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
75104 static void kgdb_tasklet_bpt(unsigned long ing)
75105 {
75106 kgdb_breakpoint();
75107 - atomic_set(&kgdb_break_tasklet_var, 0);
75108 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
75109 }
75110
75111 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
75112
75113 void kgdb_schedule_breakpoint(void)
75114 {
75115 - if (atomic_read(&kgdb_break_tasklet_var) ||
75116 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
75117 atomic_read(&kgdb_active) != -1 ||
75118 atomic_read(&kgdb_setting_breakpoint))
75119 return;
75120 - atomic_inc(&kgdb_break_tasklet_var);
75121 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
75122 tasklet_schedule(&kgdb_tasklet_breakpoint);
75123 }
75124 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
75125 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
75126 index 00eb8f7..d7e3244 100644
75127 --- a/kernel/debug/kdb/kdb_main.c
75128 +++ b/kernel/debug/kdb/kdb_main.c
75129 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
75130 continue;
75131
75132 kdb_printf("%-20s%8u 0x%p ", mod->name,
75133 - mod->core_size, (void *)mod);
75134 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
75135 #ifdef CONFIG_MODULE_UNLOAD
75136 kdb_printf("%4ld ", module_refcount(mod));
75137 #endif
75138 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
75139 kdb_printf(" (Loading)");
75140 else
75141 kdb_printf(" (Live)");
75142 - kdb_printf(" 0x%p", mod->module_core);
75143 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
75144
75145 #ifdef CONFIG_MODULE_UNLOAD
75146 {
75147 diff --git a/kernel/events/core.c b/kernel/events/core.c
75148 index f8ddcfb..77c06ec 100644
75149 --- a/kernel/events/core.c
75150 +++ b/kernel/events/core.c
75151 @@ -154,8 +154,15 @@ static struct srcu_struct pmus_srcu;
75152 * 0 - disallow raw tracepoint access for unpriv
75153 * 1 - disallow cpu events for unpriv
75154 * 2 - disallow kernel profiling for unpriv
75155 + * 3 - disallow all unpriv perf event use
75156 */
75157 -int sysctl_perf_event_paranoid __read_mostly = 1;
75158 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75159 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
75160 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
75161 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
75162 +#else
75163 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
75164 +#endif
75165
75166 /* Minimum for 512 kiB + 1 user control page */
75167 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
75168 @@ -182,7 +189,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
75169 return 0;
75170 }
75171
75172 -static atomic64_t perf_event_id;
75173 +static atomic64_unchecked_t perf_event_id;
75174
75175 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
75176 enum event_type_t event_type);
75177 @@ -2674,7 +2681,7 @@ static void __perf_event_read(void *info)
75178
75179 static inline u64 perf_event_count(struct perf_event *event)
75180 {
75181 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75182 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75183 }
75184
75185 static u64 perf_event_read(struct perf_event *event)
75186 @@ -3020,9 +3027,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75187 mutex_lock(&event->child_mutex);
75188 total += perf_event_read(event);
75189 *enabled += event->total_time_enabled +
75190 - atomic64_read(&event->child_total_time_enabled);
75191 + atomic64_read_unchecked(&event->child_total_time_enabled);
75192 *running += event->total_time_running +
75193 - atomic64_read(&event->child_total_time_running);
75194 + atomic64_read_unchecked(&event->child_total_time_running);
75195
75196 list_for_each_entry(child, &event->child_list, child_list) {
75197 total += perf_event_read(child);
75198 @@ -3408,10 +3415,10 @@ void perf_event_update_userpage(struct perf_event *event)
75199 userpg->offset -= local64_read(&event->hw.prev_count);
75200
75201 userpg->time_enabled = enabled +
75202 - atomic64_read(&event->child_total_time_enabled);
75203 + atomic64_read_unchecked(&event->child_total_time_enabled);
75204
75205 userpg->time_running = running +
75206 - atomic64_read(&event->child_total_time_running);
75207 + atomic64_read_unchecked(&event->child_total_time_running);
75208
75209 arch_perf_update_userpage(userpg, now);
75210
75211 @@ -3961,7 +3968,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
75212
75213 /* Data. */
75214 sp = perf_user_stack_pointer(regs);
75215 - rem = __output_copy_user(handle, (void *) sp, dump_size);
75216 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
75217 dyn_size = dump_size - rem;
75218
75219 perf_output_skip(handle, rem);
75220 @@ -4049,11 +4056,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75221 values[n++] = perf_event_count(event);
75222 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75223 values[n++] = enabled +
75224 - atomic64_read(&event->child_total_time_enabled);
75225 + atomic64_read_unchecked(&event->child_total_time_enabled);
75226 }
75227 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75228 values[n++] = running +
75229 - atomic64_read(&event->child_total_time_running);
75230 + atomic64_read_unchecked(&event->child_total_time_running);
75231 }
75232 if (read_format & PERF_FORMAT_ID)
75233 values[n++] = primary_event_id(event);
75234 @@ -4801,12 +4808,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75235 * need to add enough zero bytes after the string to handle
75236 * the 64bit alignment we do later.
75237 */
75238 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75239 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75240 if (!buf) {
75241 name = strncpy(tmp, "//enomem", sizeof(tmp));
75242 goto got_name;
75243 }
75244 - name = d_path(&file->f_path, buf, PATH_MAX);
75245 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75246 if (IS_ERR(name)) {
75247 name = strncpy(tmp, "//toolong", sizeof(tmp));
75248 goto got_name;
75249 @@ -6242,7 +6249,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75250 event->parent = parent_event;
75251
75252 event->ns = get_pid_ns(task_active_pid_ns(current));
75253 - event->id = atomic64_inc_return(&perf_event_id);
75254 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75255
75256 event->state = PERF_EVENT_STATE_INACTIVE;
75257
75258 @@ -6552,6 +6559,11 @@ SYSCALL_DEFINE5(perf_event_open,
75259 if (flags & ~PERF_FLAG_ALL)
75260 return -EINVAL;
75261
75262 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75263 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
75264 + return -EACCES;
75265 +#endif
75266 +
75267 err = perf_copy_attr(attr_uptr, &attr);
75268 if (err)
75269 return err;
75270 @@ -6884,10 +6896,10 @@ static void sync_child_event(struct perf_event *child_event,
75271 /*
75272 * Add back the child's count to the parent's count:
75273 */
75274 - atomic64_add(child_val, &parent_event->child_count);
75275 - atomic64_add(child_event->total_time_enabled,
75276 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75277 + atomic64_add_unchecked(child_event->total_time_enabled,
75278 &parent_event->child_total_time_enabled);
75279 - atomic64_add(child_event->total_time_running,
75280 + atomic64_add_unchecked(child_event->total_time_running,
75281 &parent_event->child_total_time_running);
75282
75283 /*
75284 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
75285 index ca65997..cc8cee4 100644
75286 --- a/kernel/events/internal.h
75287 +++ b/kernel/events/internal.h
75288 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
75289 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
75290 }
75291
75292 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
75293 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
75294 static inline unsigned int \
75295 func_name(struct perf_output_handle *handle, \
75296 - const void *buf, unsigned int len) \
75297 + const void user *buf, unsigned int len) \
75298 { \
75299 unsigned long size, written; \
75300 \
75301 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
75302 return n;
75303 }
75304
75305 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
75306 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
75307
75308 #define MEMCPY_SKIP(dst, src, n) (n)
75309
75310 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
75311 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
75312
75313 #ifndef arch_perf_out_copy_user
75314 #define arch_perf_out_copy_user __copy_from_user_inatomic
75315 #endif
75316
75317 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
75318 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
75319
75320 /* Callchain handling */
75321 extern struct perf_callchain_entry *
75322 diff --git a/kernel/exit.c b/kernel/exit.c
75323 index 60bc027..ca6d727 100644
75324 --- a/kernel/exit.c
75325 +++ b/kernel/exit.c
75326 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
75327 struct task_struct *leader;
75328 int zap_leader;
75329 repeat:
75330 +#ifdef CONFIG_NET
75331 + gr_del_task_from_ip_table(p);
75332 +#endif
75333 +
75334 /* don't need to get the RCU readlock here - the process is dead and
75335 * can't be modifying its own credentials. But shut RCU-lockdep up */
75336 rcu_read_lock();
75337 @@ -340,7 +344,7 @@ int allow_signal(int sig)
75338 * know it'll be handled, so that they don't get converted to
75339 * SIGKILL or just silently dropped.
75340 */
75341 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75342 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75343 recalc_sigpending();
75344 spin_unlock_irq(&current->sighand->siglock);
75345 return 0;
75346 @@ -710,6 +714,8 @@ void do_exit(long code)
75347 struct task_struct *tsk = current;
75348 int group_dead;
75349
75350 + set_fs(USER_DS);
75351 +
75352 profile_task_exit(tsk);
75353
75354 WARN_ON(blk_needs_flush_plug(tsk));
75355 @@ -726,7 +732,6 @@ void do_exit(long code)
75356 * mm_release()->clear_child_tid() from writing to a user-controlled
75357 * kernel address.
75358 */
75359 - set_fs(USER_DS);
75360
75361 ptrace_event(PTRACE_EVENT_EXIT, code);
75362
75363 @@ -785,6 +790,9 @@ void do_exit(long code)
75364 tsk->exit_code = code;
75365 taskstats_exit(tsk, group_dead);
75366
75367 + gr_acl_handle_psacct(tsk, code);
75368 + gr_acl_handle_exit();
75369 +
75370 exit_mm(tsk);
75371
75372 if (group_dead)
75373 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75374 * Take down every thread in the group. This is called by fatal signals
75375 * as well as by sys_exit_group (below).
75376 */
75377 -void
75378 +__noreturn void
75379 do_group_exit(int exit_code)
75380 {
75381 struct signal_struct *sig = current->signal;
75382 diff --git a/kernel/fork.c b/kernel/fork.c
75383 index 1766d32..c0e44e2 100644
75384 --- a/kernel/fork.c
75385 +++ b/kernel/fork.c
75386 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75387 *stackend = STACK_END_MAGIC; /* for overflow detection */
75388
75389 #ifdef CONFIG_CC_STACKPROTECTOR
75390 - tsk->stack_canary = get_random_int();
75391 + tsk->stack_canary = pax_get_random_long();
75392 #endif
75393
75394 /*
75395 @@ -344,13 +344,81 @@ free_tsk:
75396 }
75397
75398 #ifdef CONFIG_MMU
75399 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75400 +{
75401 + struct vm_area_struct *tmp;
75402 + unsigned long charge;
75403 + struct mempolicy *pol;
75404 + struct file *file;
75405 +
75406 + charge = 0;
75407 + if (mpnt->vm_flags & VM_ACCOUNT) {
75408 + unsigned long len = vma_pages(mpnt);
75409 +
75410 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75411 + goto fail_nomem;
75412 + charge = len;
75413 + }
75414 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75415 + if (!tmp)
75416 + goto fail_nomem;
75417 + *tmp = *mpnt;
75418 + tmp->vm_mm = mm;
75419 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75420 + pol = mpol_dup(vma_policy(mpnt));
75421 + if (IS_ERR(pol))
75422 + goto fail_nomem_policy;
75423 + vma_set_policy(tmp, pol);
75424 + if (anon_vma_fork(tmp, mpnt))
75425 + goto fail_nomem_anon_vma_fork;
75426 + tmp->vm_flags &= ~VM_LOCKED;
75427 + tmp->vm_next = tmp->vm_prev = NULL;
75428 + tmp->vm_mirror = NULL;
75429 + file = tmp->vm_file;
75430 + if (file) {
75431 + struct inode *inode = file_inode(file);
75432 + struct address_space *mapping = file->f_mapping;
75433 +
75434 + get_file(file);
75435 + if (tmp->vm_flags & VM_DENYWRITE)
75436 + atomic_dec(&inode->i_writecount);
75437 + mutex_lock(&mapping->i_mmap_mutex);
75438 + if (tmp->vm_flags & VM_SHARED)
75439 + mapping->i_mmap_writable++;
75440 + flush_dcache_mmap_lock(mapping);
75441 + /* insert tmp into the share list, just after mpnt */
75442 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75443 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75444 + else
75445 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75446 + flush_dcache_mmap_unlock(mapping);
75447 + mutex_unlock(&mapping->i_mmap_mutex);
75448 + }
75449 +
75450 + /*
75451 + * Clear hugetlb-related page reserves for children. This only
75452 + * affects MAP_PRIVATE mappings. Faults generated by the child
75453 + * are not guaranteed to succeed, even if read-only
75454 + */
75455 + if (is_vm_hugetlb_page(tmp))
75456 + reset_vma_resv_huge_pages(tmp);
75457 +
75458 + return tmp;
75459 +
75460 +fail_nomem_anon_vma_fork:
75461 + mpol_put(pol);
75462 +fail_nomem_policy:
75463 + kmem_cache_free(vm_area_cachep, tmp);
75464 +fail_nomem:
75465 + vm_unacct_memory(charge);
75466 + return NULL;
75467 +}
75468 +
75469 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75470 {
75471 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75472 struct rb_node **rb_link, *rb_parent;
75473 int retval;
75474 - unsigned long charge;
75475 - struct mempolicy *pol;
75476
75477 uprobe_start_dup_mmap();
75478 down_write(&oldmm->mmap_sem);
75479 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75480 mm->locked_vm = 0;
75481 mm->mmap = NULL;
75482 mm->mmap_cache = NULL;
75483 - mm->free_area_cache = oldmm->mmap_base;
75484 - mm->cached_hole_size = ~0UL;
75485 + mm->free_area_cache = oldmm->free_area_cache;
75486 + mm->cached_hole_size = oldmm->cached_hole_size;
75487 mm->map_count = 0;
75488 cpumask_clear(mm_cpumask(mm));
75489 mm->mm_rb = RB_ROOT;
75490 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75491
75492 prev = NULL;
75493 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75494 - struct file *file;
75495 -
75496 if (mpnt->vm_flags & VM_DONTCOPY) {
75497 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75498 -vma_pages(mpnt));
75499 continue;
75500 }
75501 - charge = 0;
75502 - if (mpnt->vm_flags & VM_ACCOUNT) {
75503 - unsigned long len = vma_pages(mpnt);
75504 -
75505 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75506 - goto fail_nomem;
75507 - charge = len;
75508 - }
75509 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75510 - if (!tmp)
75511 - goto fail_nomem;
75512 - *tmp = *mpnt;
75513 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75514 - pol = mpol_dup(vma_policy(mpnt));
75515 - retval = PTR_ERR(pol);
75516 - if (IS_ERR(pol))
75517 - goto fail_nomem_policy;
75518 - vma_set_policy(tmp, pol);
75519 - tmp->vm_mm = mm;
75520 - if (anon_vma_fork(tmp, mpnt))
75521 - goto fail_nomem_anon_vma_fork;
75522 - tmp->vm_flags &= ~VM_LOCKED;
75523 - tmp->vm_next = tmp->vm_prev = NULL;
75524 - file = tmp->vm_file;
75525 - if (file) {
75526 - struct inode *inode = file_inode(file);
75527 - struct address_space *mapping = file->f_mapping;
75528 -
75529 - get_file(file);
75530 - if (tmp->vm_flags & VM_DENYWRITE)
75531 - atomic_dec(&inode->i_writecount);
75532 - mutex_lock(&mapping->i_mmap_mutex);
75533 - if (tmp->vm_flags & VM_SHARED)
75534 - mapping->i_mmap_writable++;
75535 - flush_dcache_mmap_lock(mapping);
75536 - /* insert tmp into the share list, just after mpnt */
75537 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75538 - vma_nonlinear_insert(tmp,
75539 - &mapping->i_mmap_nonlinear);
75540 - else
75541 - vma_interval_tree_insert_after(tmp, mpnt,
75542 - &mapping->i_mmap);
75543 - flush_dcache_mmap_unlock(mapping);
75544 - mutex_unlock(&mapping->i_mmap_mutex);
75545 + tmp = dup_vma(mm, oldmm, mpnt);
75546 + if (!tmp) {
75547 + retval = -ENOMEM;
75548 + goto out;
75549 }
75550
75551 /*
75552 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75553 if (retval)
75554 goto out;
75555 }
75556 +
75557 +#ifdef CONFIG_PAX_SEGMEXEC
75558 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75559 + struct vm_area_struct *mpnt_m;
75560 +
75561 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75562 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75563 +
75564 + if (!mpnt->vm_mirror)
75565 + continue;
75566 +
75567 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75568 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75569 + mpnt->vm_mirror = mpnt_m;
75570 + } else {
75571 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75572 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75573 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75574 + mpnt->vm_mirror->vm_mirror = mpnt;
75575 + }
75576 + }
75577 + BUG_ON(mpnt_m);
75578 + }
75579 +#endif
75580 +
75581 /* a new mm has just been created */
75582 arch_dup_mmap(oldmm, mm);
75583 retval = 0;
75584 @@ -472,14 +523,6 @@ out:
75585 up_write(&oldmm->mmap_sem);
75586 uprobe_end_dup_mmap();
75587 return retval;
75588 -fail_nomem_anon_vma_fork:
75589 - mpol_put(pol);
75590 -fail_nomem_policy:
75591 - kmem_cache_free(vm_area_cachep, tmp);
75592 -fail_nomem:
75593 - retval = -ENOMEM;
75594 - vm_unacct_memory(charge);
75595 - goto out;
75596 }
75597
75598 static inline int mm_alloc_pgd(struct mm_struct *mm)
75599 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75600 return ERR_PTR(err);
75601
75602 mm = get_task_mm(task);
75603 - if (mm && mm != current->mm &&
75604 - !ptrace_may_access(task, mode)) {
75605 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75606 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75607 mmput(mm);
75608 mm = ERR_PTR(-EACCES);
75609 }
75610 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75611 spin_unlock(&fs->lock);
75612 return -EAGAIN;
75613 }
75614 - fs->users++;
75615 + atomic_inc(&fs->users);
75616 spin_unlock(&fs->lock);
75617 return 0;
75618 }
75619 tsk->fs = copy_fs_struct(fs);
75620 if (!tsk->fs)
75621 return -ENOMEM;
75622 + /* Carry through gr_chroot_dentry and is_chrooted instead
75623 + of recomputing it here. Already copied when the task struct
75624 + is duplicated. This allows pivot_root to not be treated as
75625 + a chroot
75626 + */
75627 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75628 +
75629 return 0;
75630 }
75631
75632 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75633 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75634 #endif
75635 retval = -EAGAIN;
75636 +
75637 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75638 +
75639 if (atomic_read(&p->real_cred->user->processes) >=
75640 task_rlimit(p, RLIMIT_NPROC)) {
75641 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75642 @@ -1441,6 +1494,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75643 goto bad_fork_free_pid;
75644 }
75645
75646 + /* synchronizes with gr_set_acls()
75647 + we need to call this past the point of no return for fork()
75648 + */
75649 + gr_copy_label(p);
75650 +
75651 if (clone_flags & CLONE_THREAD) {
75652 current->signal->nr_threads++;
75653 atomic_inc(&current->signal->live);
75654 @@ -1524,6 +1582,8 @@ bad_fork_cleanup_count:
75655 bad_fork_free:
75656 free_task(p);
75657 fork_out:
75658 + gr_log_forkfail(retval);
75659 +
75660 return ERR_PTR(retval);
75661 }
75662
75663 @@ -1574,6 +1634,23 @@ long do_fork(unsigned long clone_flags,
75664 return -EINVAL;
75665 }
75666
75667 +#ifdef CONFIG_GRKERNSEC
75668 + if (clone_flags & CLONE_NEWUSER) {
75669 + /*
75670 + * This doesn't really inspire confidence:
75671 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75672 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75673 + * Increases kernel attack surface in areas developers
75674 + * previously cared little about ("low importance due
75675 + * to requiring "root" capability")
75676 + * To be removed when this code receives *proper* review
75677 + */
75678 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75679 + !capable(CAP_SETGID))
75680 + return -EPERM;
75681 + }
75682 +#endif
75683 +
75684 /*
75685 * Determine whether and which event to report to ptracer. When
75686 * called from kernel_thread or CLONE_UNTRACED is explicitly
75687 @@ -1608,6 +1685,8 @@ long do_fork(unsigned long clone_flags,
75688 if (clone_flags & CLONE_PARENT_SETTID)
75689 put_user(nr, parent_tidptr);
75690
75691 + gr_handle_brute_check();
75692 +
75693 if (clone_flags & CLONE_VFORK) {
75694 p->vfork_done = &vfork;
75695 init_completion(&vfork);
75696 @@ -1761,7 +1840,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75697 return 0;
75698
75699 /* don't need lock here; in the worst case we'll do useless copy */
75700 - if (fs->users == 1)
75701 + if (atomic_read(&fs->users) == 1)
75702 return 0;
75703
75704 *new_fsp = copy_fs_struct(fs);
75705 @@ -1873,7 +1952,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75706 fs = current->fs;
75707 spin_lock(&fs->lock);
75708 current->fs = new_fs;
75709 - if (--fs->users)
75710 + gr_set_chroot_entries(current, &current->fs->root);
75711 + if (atomic_dec_return(&fs->users))
75712 new_fs = NULL;
75713 else
75714 new_fs = fs;
75715 diff --git a/kernel/futex.c b/kernel/futex.c
75716 index b26dcfc..39e266a 100644
75717 --- a/kernel/futex.c
75718 +++ b/kernel/futex.c
75719 @@ -54,6 +54,7 @@
75720 #include <linux/mount.h>
75721 #include <linux/pagemap.h>
75722 #include <linux/syscalls.h>
75723 +#include <linux/ptrace.h>
75724 #include <linux/signal.h>
75725 #include <linux/export.h>
75726 #include <linux/magic.h>
75727 @@ -241,6 +242,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75728 struct page *page, *page_head;
75729 int err, ro = 0;
75730
75731 +#ifdef CONFIG_PAX_SEGMEXEC
75732 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75733 + return -EFAULT;
75734 +#endif
75735 +
75736 /*
75737 * The futex address must be "naturally" aligned.
75738 */
75739 @@ -2732,6 +2738,7 @@ static int __init futex_init(void)
75740 {
75741 u32 curval;
75742 int i;
75743 + mm_segment_t oldfs;
75744
75745 /*
75746 * This will fail and we want it. Some arch implementations do
75747 @@ -2743,8 +2750,11 @@ static int __init futex_init(void)
75748 * implementation, the non-functional ones will return
75749 * -ENOSYS.
75750 */
75751 + oldfs = get_fs();
75752 + set_fs(USER_DS);
75753 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75754 futex_cmpxchg_enabled = 1;
75755 + set_fs(oldfs);
75756
75757 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75758 plist_head_init(&futex_queues[i].chain);
75759 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75760 index f9f44fd..29885e4 100644
75761 --- a/kernel/futex_compat.c
75762 +++ b/kernel/futex_compat.c
75763 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75764 return 0;
75765 }
75766
75767 -static void __user *futex_uaddr(struct robust_list __user *entry,
75768 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75769 compat_long_t futex_offset)
75770 {
75771 compat_uptr_t base = ptr_to_compat(entry);
75772 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75773 index 9b22d03..6295b62 100644
75774 --- a/kernel/gcov/base.c
75775 +++ b/kernel/gcov/base.c
75776 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75777 }
75778
75779 #ifdef CONFIG_MODULES
75780 -static inline int within(void *addr, void *start, unsigned long size)
75781 -{
75782 - return ((addr >= start) && (addr < start + size));
75783 -}
75784 -
75785 /* Update list and generate events when modules are unloaded. */
75786 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75787 void *data)
75788 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75789 prev = NULL;
75790 /* Remove entries located in module from linked list. */
75791 for (info = gcov_info_head; info; info = info->next) {
75792 - if (within(info, mod->module_core, mod->core_size)) {
75793 + if (within_module_core_rw((unsigned long)info, mod)) {
75794 if (prev)
75795 prev->next = info->next;
75796 else
75797 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75798 index 7ef5556..8247f11 100644
75799 --- a/kernel/hrtimer.c
75800 +++ b/kernel/hrtimer.c
75801 @@ -1416,7 +1416,7 @@ void hrtimer_peek_ahead_timers(void)
75802 local_irq_restore(flags);
75803 }
75804
75805 -static void run_hrtimer_softirq(struct softirq_action *h)
75806 +static void run_hrtimer_softirq(void)
75807 {
75808 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75809
75810 @@ -1758,7 +1758,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75811 return NOTIFY_OK;
75812 }
75813
75814 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75815 +static struct notifier_block hrtimers_nb = {
75816 .notifier_call = hrtimer_cpu_notify,
75817 };
75818
75819 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
75820 index 55fcce6..0e4cf34 100644
75821 --- a/kernel/irq_work.c
75822 +++ b/kernel/irq_work.c
75823 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
75824 return NOTIFY_OK;
75825 }
75826
75827 -static struct notifier_block cpu_notify;
75828 +static struct notifier_block cpu_notify = {
75829 + .notifier_call = irq_work_cpu_notify,
75830 + .priority = 0,
75831 +};
75832
75833 static __init int irq_work_init_cpu_notifier(void)
75834 {
75835 - cpu_notify.notifier_call = irq_work_cpu_notify;
75836 - cpu_notify.priority = 0;
75837 register_cpu_notifier(&cpu_notify);
75838 return 0;
75839 }
75840 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75841 index 60f48fa..7f3a770 100644
75842 --- a/kernel/jump_label.c
75843 +++ b/kernel/jump_label.c
75844 @@ -13,6 +13,7 @@
75845 #include <linux/sort.h>
75846 #include <linux/err.h>
75847 #include <linux/static_key.h>
75848 +#include <linux/mm.h>
75849
75850 #ifdef HAVE_JUMP_LABEL
75851
75852 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75853
75854 size = (((unsigned long)stop - (unsigned long)start)
75855 / sizeof(struct jump_entry));
75856 + pax_open_kernel();
75857 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75858 + pax_close_kernel();
75859 }
75860
75861 static void jump_label_update(struct static_key *key, int enable);
75862 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75863 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75864 struct jump_entry *iter;
75865
75866 + pax_open_kernel();
75867 for (iter = iter_start; iter < iter_stop; iter++) {
75868 if (within_module_init(iter->code, mod))
75869 iter->code = 0;
75870 }
75871 + pax_close_kernel();
75872 }
75873
75874 static int
75875 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75876 index 2169fee..706ccca 100644
75877 --- a/kernel/kallsyms.c
75878 +++ b/kernel/kallsyms.c
75879 @@ -11,6 +11,9 @@
75880 * Changed the compression method from stem compression to "table lookup"
75881 * compression (see scripts/kallsyms.c for a more complete description)
75882 */
75883 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75884 +#define __INCLUDED_BY_HIDESYM 1
75885 +#endif
75886 #include <linux/kallsyms.h>
75887 #include <linux/module.h>
75888 #include <linux/init.h>
75889 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75890
75891 static inline int is_kernel_inittext(unsigned long addr)
75892 {
75893 + if (system_state != SYSTEM_BOOTING)
75894 + return 0;
75895 +
75896 if (addr >= (unsigned long)_sinittext
75897 && addr <= (unsigned long)_einittext)
75898 return 1;
75899 return 0;
75900 }
75901
75902 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75903 +#ifdef CONFIG_MODULES
75904 +static inline int is_module_text(unsigned long addr)
75905 +{
75906 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75907 + return 1;
75908 +
75909 + addr = ktla_ktva(addr);
75910 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75911 +}
75912 +#else
75913 +static inline int is_module_text(unsigned long addr)
75914 +{
75915 + return 0;
75916 +}
75917 +#endif
75918 +#endif
75919 +
75920 static inline int is_kernel_text(unsigned long addr)
75921 {
75922 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75923 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75924
75925 static inline int is_kernel(unsigned long addr)
75926 {
75927 +
75928 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75929 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75930 + return 1;
75931 +
75932 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75933 +#else
75934 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75935 +#endif
75936 +
75937 return 1;
75938 return in_gate_area_no_mm(addr);
75939 }
75940
75941 static int is_ksym_addr(unsigned long addr)
75942 {
75943 +
75944 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75945 + if (is_module_text(addr))
75946 + return 0;
75947 +#endif
75948 +
75949 if (all_var)
75950 return is_kernel(addr);
75951
75952 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75953
75954 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75955 {
75956 - iter->name[0] = '\0';
75957 iter->nameoff = get_symbol_offset(new_pos);
75958 iter->pos = new_pos;
75959 }
75960 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75961 {
75962 struct kallsym_iter *iter = m->private;
75963
75964 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75965 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75966 + return 0;
75967 +#endif
75968 +
75969 /* Some debugging symbols have no name. Ignore them. */
75970 if (!iter->name[0])
75971 return 0;
75972 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75973 */
75974 type = iter->exported ? toupper(iter->type) :
75975 tolower(iter->type);
75976 +
75977 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75978 type, iter->name, iter->module_name);
75979 } else
75980 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75981 struct kallsym_iter *iter;
75982 int ret;
75983
75984 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75985 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75986 if (!iter)
75987 return -ENOMEM;
75988 reset_iter(iter, 0);
75989 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75990 index e30ac0f..3528cac 100644
75991 --- a/kernel/kcmp.c
75992 +++ b/kernel/kcmp.c
75993 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75994 struct task_struct *task1, *task2;
75995 int ret;
75996
75997 +#ifdef CONFIG_GRKERNSEC
75998 + return -ENOSYS;
75999 +#endif
76000 +
76001 rcu_read_lock();
76002
76003 /*
76004 diff --git a/kernel/kexec.c b/kernel/kexec.c
76005 index ffd4e11..c3ff6bf 100644
76006 --- a/kernel/kexec.c
76007 +++ b/kernel/kexec.c
76008 @@ -1048,7 +1048,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
76009 unsigned long flags)
76010 {
76011 struct compat_kexec_segment in;
76012 - struct kexec_segment out, __user *ksegments;
76013 + struct kexec_segment out;
76014 + struct kexec_segment __user *ksegments;
76015 unsigned long i, result;
76016
76017 /* Don't allow clients that don't understand the native
76018 diff --git a/kernel/kmod.c b/kernel/kmod.c
76019 index 8985c87..f539dbe 100644
76020 --- a/kernel/kmod.c
76021 +++ b/kernel/kmod.c
76022 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
76023 kfree(info->argv);
76024 }
76025
76026 -static int call_modprobe(char *module_name, int wait)
76027 +static int call_modprobe(char *module_name, char *module_param, int wait)
76028 {
76029 static char *envp[] = {
76030 "HOME=/",
76031 @@ -84,7 +84,7 @@ static int call_modprobe(char *module_name, int wait)
76032 NULL
76033 };
76034
76035 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
76036 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
76037 if (!argv)
76038 goto out;
76039
76040 @@ -96,7 +96,8 @@ static int call_modprobe(char *module_name, int wait)
76041 argv[1] = "-q";
76042 argv[2] = "--";
76043 argv[3] = module_name; /* check free_modprobe_argv() */
76044 - argv[4] = NULL;
76045 + argv[4] = module_param;
76046 + argv[5] = NULL;
76047
76048 return call_usermodehelper_fns(modprobe_path, argv, envp,
76049 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
76050 @@ -121,9 +122,8 @@ out:
76051 * If module auto-loading support is disabled then this function
76052 * becomes a no-operation.
76053 */
76054 -int __request_module(bool wait, const char *fmt, ...)
76055 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
76056 {
76057 - va_list args;
76058 char module_name[MODULE_NAME_LEN];
76059 unsigned int max_modprobes;
76060 int ret;
76061 @@ -139,9 +139,7 @@ int __request_module(bool wait, const char *fmt, ...)
76062 */
76063 WARN_ON_ONCE(wait && current_is_async());
76064
76065 - va_start(args, fmt);
76066 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
76067 - va_end(args);
76068 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
76069 if (ret >= MODULE_NAME_LEN)
76070 return -ENAMETOOLONG;
76071
76072 @@ -149,6 +147,20 @@ int __request_module(bool wait, const char *fmt, ...)
76073 if (ret)
76074 return ret;
76075
76076 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76077 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76078 + /* hack to workaround consolekit/udisks stupidity */
76079 + read_lock(&tasklist_lock);
76080 + if (!strcmp(current->comm, "mount") &&
76081 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
76082 + read_unlock(&tasklist_lock);
76083 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
76084 + return -EPERM;
76085 + }
76086 + read_unlock(&tasklist_lock);
76087 + }
76088 +#endif
76089 +
76090 /* If modprobe needs a service that is in a module, we get a recursive
76091 * loop. Limit the number of running kmod threads to max_threads/2 or
76092 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
76093 @@ -177,11 +189,52 @@ int __request_module(bool wait, const char *fmt, ...)
76094
76095 trace_module_request(module_name, wait, _RET_IP_);
76096
76097 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76098 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76099
76100 atomic_dec(&kmod_concurrent);
76101 return ret;
76102 }
76103 +
76104 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
76105 +{
76106 + va_list args;
76107 + int ret;
76108 +
76109 + va_start(args, fmt);
76110 + ret = ____request_module(wait, module_param, fmt, args);
76111 + va_end(args);
76112 +
76113 + return ret;
76114 +}
76115 +
76116 +int __request_module(bool wait, const char *fmt, ...)
76117 +{
76118 + va_list args;
76119 + int ret;
76120 +
76121 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76122 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76123 + char module_param[MODULE_NAME_LEN];
76124 +
76125 + memset(module_param, 0, sizeof(module_param));
76126 +
76127 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
76128 +
76129 + va_start(args, fmt);
76130 + ret = ____request_module(wait, module_param, fmt, args);
76131 + va_end(args);
76132 +
76133 + return ret;
76134 + }
76135 +#endif
76136 +
76137 + va_start(args, fmt);
76138 + ret = ____request_module(wait, NULL, fmt, args);
76139 + va_end(args);
76140 +
76141 + return ret;
76142 +}
76143 +
76144 EXPORT_SYMBOL(__request_module);
76145 #endif /* CONFIG_MODULES */
76146
76147 @@ -292,7 +345,7 @@ static int wait_for_helper(void *data)
76148 *
76149 * Thus the __user pointer cast is valid here.
76150 */
76151 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
76152 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
76153
76154 /*
76155 * If ret is 0, either ____call_usermodehelper failed and the
76156 @@ -649,7 +702,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
76157 static int proc_cap_handler(struct ctl_table *table, int write,
76158 void __user *buffer, size_t *lenp, loff_t *ppos)
76159 {
76160 - struct ctl_table t;
76161 + ctl_table_no_const t;
76162 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
76163 kernel_cap_t new_cap;
76164 int err, i;
76165 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
76166 index 3fed7f0..a3f95ed 100644
76167 --- a/kernel/kprobes.c
76168 +++ b/kernel/kprobes.c
76169 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
76170 * kernel image and loaded module images reside. This is required
76171 * so x86_64 can correctly handle the %rip-relative fixups.
76172 */
76173 - kip->insns = module_alloc(PAGE_SIZE);
76174 + kip->insns = module_alloc_exec(PAGE_SIZE);
76175 if (!kip->insns) {
76176 kfree(kip);
76177 return NULL;
76178 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
76179 */
76180 if (!list_is_singular(&kip->list)) {
76181 list_del(&kip->list);
76182 - module_free(NULL, kip->insns);
76183 + module_free_exec(NULL, kip->insns);
76184 kfree(kip);
76185 }
76186 return 1;
76187 @@ -2073,7 +2073,7 @@ static int __init init_kprobes(void)
76188 {
76189 int i, err = 0;
76190 unsigned long offset = 0, size = 0;
76191 - char *modname, namebuf[128];
76192 + char *modname, namebuf[KSYM_NAME_LEN];
76193 const char *symbol_name;
76194 void *addr;
76195 struct kprobe_blackpoint *kb;
76196 @@ -2158,11 +2158,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
76197 kprobe_type = "k";
76198
76199 if (sym)
76200 - seq_printf(pi, "%p %s %s+0x%x %s ",
76201 + seq_printf(pi, "%pK %s %s+0x%x %s ",
76202 p->addr, kprobe_type, sym, offset,
76203 (modname ? modname : " "));
76204 else
76205 - seq_printf(pi, "%p %s %p ",
76206 + seq_printf(pi, "%pK %s %pK ",
76207 p->addr, kprobe_type, p->addr);
76208
76209 if (!pp)
76210 @@ -2199,7 +2199,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
76211 const char *sym = NULL;
76212 unsigned int i = *(loff_t *) v;
76213 unsigned long offset = 0;
76214 - char *modname, namebuf[128];
76215 + char *modname, namebuf[KSYM_NAME_LEN];
76216
76217 head = &kprobe_table[i];
76218 preempt_disable();
76219 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
76220 index 6ada93c..dce7d5d 100644
76221 --- a/kernel/ksysfs.c
76222 +++ b/kernel/ksysfs.c
76223 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
76224 {
76225 if (count+1 > UEVENT_HELPER_PATH_LEN)
76226 return -ENOENT;
76227 + if (!capable(CAP_SYS_ADMIN))
76228 + return -EPERM;
76229 memcpy(uevent_helper, buf, count);
76230 uevent_helper[count] = '\0';
76231 if (count && uevent_helper[count-1] == '\n')
76232 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
76233 return count;
76234 }
76235
76236 -static struct bin_attribute notes_attr = {
76237 +static bin_attribute_no_const notes_attr __read_only = {
76238 .attr = {
76239 .name = "notes",
76240 .mode = S_IRUGO,
76241 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
76242 index 8a0efac..56f1e2d 100644
76243 --- a/kernel/lockdep.c
76244 +++ b/kernel/lockdep.c
76245 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
76246 end = (unsigned long) &_end,
76247 addr = (unsigned long) obj;
76248
76249 +#ifdef CONFIG_PAX_KERNEXEC
76250 + start = ktla_ktva(start);
76251 +#endif
76252 +
76253 /*
76254 * static variable?
76255 */
76256 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
76257 if (!static_obj(lock->key)) {
76258 debug_locks_off();
76259 printk("INFO: trying to register non-static key.\n");
76260 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76261 printk("the code is fine but needs lockdep annotation.\n");
76262 printk("turning off the locking correctness validator.\n");
76263 dump_stack();
76264 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76265 if (!class)
76266 return 0;
76267 }
76268 - atomic_inc((atomic_t *)&class->ops);
76269 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76270 if (very_verbose(class)) {
76271 printk("\nacquire class [%p] %s", class->key, class->name);
76272 if (class->name_version > 1)
76273 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76274 index b2c71c5..7b88d63 100644
76275 --- a/kernel/lockdep_proc.c
76276 +++ b/kernel/lockdep_proc.c
76277 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76278 return 0;
76279 }
76280
76281 - seq_printf(m, "%p", class->key);
76282 + seq_printf(m, "%pK", class->key);
76283 #ifdef CONFIG_DEBUG_LOCKDEP
76284 seq_printf(m, " OPS:%8ld", class->ops);
76285 #endif
76286 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76287
76288 list_for_each_entry(entry, &class->locks_after, entry) {
76289 if (entry->distance == 1) {
76290 - seq_printf(m, " -> [%p] ", entry->class->key);
76291 + seq_printf(m, " -> [%pK] ", entry->class->key);
76292 print_name(m, entry->class);
76293 seq_puts(m, "\n");
76294 }
76295 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76296 if (!class->key)
76297 continue;
76298
76299 - seq_printf(m, "[%p] ", class->key);
76300 + seq_printf(m, "[%pK] ", class->key);
76301 print_name(m, class);
76302 seq_puts(m, "\n");
76303 }
76304 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76305 if (!i)
76306 seq_line(m, '-', 40-namelen, namelen);
76307
76308 - snprintf(ip, sizeof(ip), "[<%p>]",
76309 + snprintf(ip, sizeof(ip), "[<%pK>]",
76310 (void *)class->contention_point[i]);
76311 seq_printf(m, "%40s %14lu %29s %pS\n",
76312 name, stats->contention_point[i],
76313 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76314 if (!i)
76315 seq_line(m, '-', 40-namelen, namelen);
76316
76317 - snprintf(ip, sizeof(ip), "[<%p>]",
76318 + snprintf(ip, sizeof(ip), "[<%pK>]",
76319 (void *)class->contending_point[i]);
76320 seq_printf(m, "%40s %14lu %29s %pS\n",
76321 name, stats->contending_point[i],
76322 diff --git a/kernel/module.c b/kernel/module.c
76323 index 97f202c..109575f 100644
76324 --- a/kernel/module.c
76325 +++ b/kernel/module.c
76326 @@ -61,6 +61,7 @@
76327 #include <linux/pfn.h>
76328 #include <linux/bsearch.h>
76329 #include <linux/fips.h>
76330 +#include <linux/grsecurity.h>
76331 #include <uapi/linux/module.h>
76332 #include "module-internal.h"
76333
76334 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76335
76336 /* Bounds of module allocation, for speeding __module_address.
76337 * Protected by module_mutex. */
76338 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76339 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76340 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76341
76342 int register_module_notifier(struct notifier_block * nb)
76343 {
76344 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76345 return true;
76346
76347 list_for_each_entry_rcu(mod, &modules, list) {
76348 - struct symsearch arr[] = {
76349 + struct symsearch modarr[] = {
76350 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76351 NOT_GPL_ONLY, false },
76352 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76353 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76354 if (mod->state == MODULE_STATE_UNFORMED)
76355 continue;
76356
76357 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76358 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76359 return true;
76360 }
76361 return false;
76362 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76363 static int percpu_modalloc(struct module *mod,
76364 unsigned long size, unsigned long align)
76365 {
76366 - if (align > PAGE_SIZE) {
76367 + if (align-1 >= PAGE_SIZE) {
76368 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76369 mod->name, align, PAGE_SIZE);
76370 align = PAGE_SIZE;
76371 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
76372 static ssize_t show_coresize(struct module_attribute *mattr,
76373 struct module_kobject *mk, char *buffer)
76374 {
76375 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76376 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76377 }
76378
76379 static struct module_attribute modinfo_coresize =
76380 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
76381 static ssize_t show_initsize(struct module_attribute *mattr,
76382 struct module_kobject *mk, char *buffer)
76383 {
76384 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76385 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76386 }
76387
76388 static struct module_attribute modinfo_initsize =
76389 @@ -1312,7 +1314,7 @@ resolve_symbol_wait(struct module *mod,
76390 */
76391 #ifdef CONFIG_SYSFS
76392
76393 -#ifdef CONFIG_KALLSYMS
76394 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76395 static inline bool sect_empty(const Elf_Shdr *sect)
76396 {
76397 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76398 @@ -1452,7 +1454,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76399 {
76400 unsigned int notes, loaded, i;
76401 struct module_notes_attrs *notes_attrs;
76402 - struct bin_attribute *nattr;
76403 + bin_attribute_no_const *nattr;
76404
76405 /* failed to create section attributes, so can't create notes */
76406 if (!mod->sect_attrs)
76407 @@ -1564,7 +1566,7 @@ static void del_usage_links(struct module *mod)
76408 static int module_add_modinfo_attrs(struct module *mod)
76409 {
76410 struct module_attribute *attr;
76411 - struct module_attribute *temp_attr;
76412 + module_attribute_no_const *temp_attr;
76413 int error = 0;
76414 int i;
76415
76416 @@ -1778,21 +1780,21 @@ static void set_section_ro_nx(void *base,
76417
76418 static void unset_module_core_ro_nx(struct module *mod)
76419 {
76420 - set_page_attributes(mod->module_core + mod->core_text_size,
76421 - mod->module_core + mod->core_size,
76422 + set_page_attributes(mod->module_core_rw,
76423 + mod->module_core_rw + mod->core_size_rw,
76424 set_memory_x);
76425 - set_page_attributes(mod->module_core,
76426 - mod->module_core + mod->core_ro_size,
76427 + set_page_attributes(mod->module_core_rx,
76428 + mod->module_core_rx + mod->core_size_rx,
76429 set_memory_rw);
76430 }
76431
76432 static void unset_module_init_ro_nx(struct module *mod)
76433 {
76434 - set_page_attributes(mod->module_init + mod->init_text_size,
76435 - mod->module_init + mod->init_size,
76436 + set_page_attributes(mod->module_init_rw,
76437 + mod->module_init_rw + mod->init_size_rw,
76438 set_memory_x);
76439 - set_page_attributes(mod->module_init,
76440 - mod->module_init + mod->init_ro_size,
76441 + set_page_attributes(mod->module_init_rx,
76442 + mod->module_init_rx + mod->init_size_rx,
76443 set_memory_rw);
76444 }
76445
76446 @@ -1805,14 +1807,14 @@ void set_all_modules_text_rw(void)
76447 list_for_each_entry_rcu(mod, &modules, list) {
76448 if (mod->state == MODULE_STATE_UNFORMED)
76449 continue;
76450 - if ((mod->module_core) && (mod->core_text_size)) {
76451 - set_page_attributes(mod->module_core,
76452 - mod->module_core + mod->core_text_size,
76453 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76454 + set_page_attributes(mod->module_core_rx,
76455 + mod->module_core_rx + mod->core_size_rx,
76456 set_memory_rw);
76457 }
76458 - if ((mod->module_init) && (mod->init_text_size)) {
76459 - set_page_attributes(mod->module_init,
76460 - mod->module_init + mod->init_text_size,
76461 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76462 + set_page_attributes(mod->module_init_rx,
76463 + mod->module_init_rx + mod->init_size_rx,
76464 set_memory_rw);
76465 }
76466 }
76467 @@ -1828,14 +1830,14 @@ void set_all_modules_text_ro(void)
76468 list_for_each_entry_rcu(mod, &modules, list) {
76469 if (mod->state == MODULE_STATE_UNFORMED)
76470 continue;
76471 - if ((mod->module_core) && (mod->core_text_size)) {
76472 - set_page_attributes(mod->module_core,
76473 - mod->module_core + mod->core_text_size,
76474 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76475 + set_page_attributes(mod->module_core_rx,
76476 + mod->module_core_rx + mod->core_size_rx,
76477 set_memory_ro);
76478 }
76479 - if ((mod->module_init) && (mod->init_text_size)) {
76480 - set_page_attributes(mod->module_init,
76481 - mod->module_init + mod->init_text_size,
76482 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76483 + set_page_attributes(mod->module_init_rx,
76484 + mod->module_init_rx + mod->init_size_rx,
76485 set_memory_ro);
76486 }
76487 }
76488 @@ -1886,16 +1888,19 @@ static void free_module(struct module *mod)
76489
76490 /* This may be NULL, but that's OK */
76491 unset_module_init_ro_nx(mod);
76492 - module_free(mod, mod->module_init);
76493 + module_free(mod, mod->module_init_rw);
76494 + module_free_exec(mod, mod->module_init_rx);
76495 kfree(mod->args);
76496 percpu_modfree(mod);
76497
76498 /* Free lock-classes: */
76499 - lockdep_free_key_range(mod->module_core, mod->core_size);
76500 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76501 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76502
76503 /* Finally, free the core (containing the module structure) */
76504 unset_module_core_ro_nx(mod);
76505 - module_free(mod, mod->module_core);
76506 + module_free_exec(mod, mod->module_core_rx);
76507 + module_free(mod, mod->module_core_rw);
76508
76509 #ifdef CONFIG_MPU
76510 update_protections(current->mm);
76511 @@ -1965,9 +1970,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76512 int ret = 0;
76513 const struct kernel_symbol *ksym;
76514
76515 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76516 + int is_fs_load = 0;
76517 + int register_filesystem_found = 0;
76518 + char *p;
76519 +
76520 + p = strstr(mod->args, "grsec_modharden_fs");
76521 + if (p) {
76522 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76523 + /* copy \0 as well */
76524 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76525 + is_fs_load = 1;
76526 + }
76527 +#endif
76528 +
76529 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76530 const char *name = info->strtab + sym[i].st_name;
76531
76532 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76533 + /* it's a real shame this will never get ripped and copied
76534 + upstream! ;(
76535 + */
76536 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76537 + register_filesystem_found = 1;
76538 +#endif
76539 +
76540 switch (sym[i].st_shndx) {
76541 case SHN_COMMON:
76542 /* We compiled with -fno-common. These are not
76543 @@ -1988,7 +2015,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76544 ksym = resolve_symbol_wait(mod, info, name);
76545 /* Ok if resolved. */
76546 if (ksym && !IS_ERR(ksym)) {
76547 + pax_open_kernel();
76548 sym[i].st_value = ksym->value;
76549 + pax_close_kernel();
76550 break;
76551 }
76552
76553 @@ -2007,11 +2036,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76554 secbase = (unsigned long)mod_percpu(mod);
76555 else
76556 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76557 + pax_open_kernel();
76558 sym[i].st_value += secbase;
76559 + pax_close_kernel();
76560 break;
76561 }
76562 }
76563
76564 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76565 + if (is_fs_load && !register_filesystem_found) {
76566 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76567 + ret = -EPERM;
76568 + }
76569 +#endif
76570 +
76571 return ret;
76572 }
76573
76574 @@ -2095,22 +2133,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76575 || s->sh_entsize != ~0UL
76576 || strstarts(sname, ".init"))
76577 continue;
76578 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76579 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76580 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76581 + else
76582 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76583 pr_debug("\t%s\n", sname);
76584 }
76585 - switch (m) {
76586 - case 0: /* executable */
76587 - mod->core_size = debug_align(mod->core_size);
76588 - mod->core_text_size = mod->core_size;
76589 - break;
76590 - case 1: /* RO: text and ro-data */
76591 - mod->core_size = debug_align(mod->core_size);
76592 - mod->core_ro_size = mod->core_size;
76593 - break;
76594 - case 3: /* whole core */
76595 - mod->core_size = debug_align(mod->core_size);
76596 - break;
76597 - }
76598 }
76599
76600 pr_debug("Init section allocation order:\n");
76601 @@ -2124,23 +2152,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76602 || s->sh_entsize != ~0UL
76603 || !strstarts(sname, ".init"))
76604 continue;
76605 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76606 - | INIT_OFFSET_MASK);
76607 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76608 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76609 + else
76610 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76611 + s->sh_entsize |= INIT_OFFSET_MASK;
76612 pr_debug("\t%s\n", sname);
76613 }
76614 - switch (m) {
76615 - case 0: /* executable */
76616 - mod->init_size = debug_align(mod->init_size);
76617 - mod->init_text_size = mod->init_size;
76618 - break;
76619 - case 1: /* RO: text and ro-data */
76620 - mod->init_size = debug_align(mod->init_size);
76621 - mod->init_ro_size = mod->init_size;
76622 - break;
76623 - case 3: /* whole init */
76624 - mod->init_size = debug_align(mod->init_size);
76625 - break;
76626 - }
76627 }
76628 }
76629
76630 @@ -2313,7 +2331,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76631
76632 /* Put symbol section at end of init part of module. */
76633 symsect->sh_flags |= SHF_ALLOC;
76634 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76635 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76636 info->index.sym) | INIT_OFFSET_MASK;
76637 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76638
76639 @@ -2330,13 +2348,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76640 }
76641
76642 /* Append room for core symbols at end of core part. */
76643 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76644 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76645 - mod->core_size += strtab_size;
76646 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76647 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76648 + mod->core_size_rx += strtab_size;
76649
76650 /* Put string table section at end of init part of module. */
76651 strsect->sh_flags |= SHF_ALLOC;
76652 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76653 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76654 info->index.str) | INIT_OFFSET_MASK;
76655 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76656 }
76657 @@ -2354,12 +2372,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76658 /* Make sure we get permanent strtab: don't use info->strtab. */
76659 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76660
76661 + pax_open_kernel();
76662 +
76663 /* Set types up while we still have access to sections. */
76664 for (i = 0; i < mod->num_symtab; i++)
76665 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76666
76667 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76668 - mod->core_strtab = s = mod->module_core + info->stroffs;
76669 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76670 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76671 src = mod->symtab;
76672 for (ndst = i = 0; i < mod->num_symtab; i++) {
76673 if (i == 0 ||
76674 @@ -2371,6 +2391,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76675 }
76676 }
76677 mod->core_num_syms = ndst;
76678 +
76679 + pax_close_kernel();
76680 }
76681 #else
76682 static inline void layout_symtab(struct module *mod, struct load_info *info)
76683 @@ -2404,17 +2426,33 @@ void * __weak module_alloc(unsigned long size)
76684 return vmalloc_exec(size);
76685 }
76686
76687 -static void *module_alloc_update_bounds(unsigned long size)
76688 +static void *module_alloc_update_bounds_rw(unsigned long size)
76689 {
76690 void *ret = module_alloc(size);
76691
76692 if (ret) {
76693 mutex_lock(&module_mutex);
76694 /* Update module bounds. */
76695 - if ((unsigned long)ret < module_addr_min)
76696 - module_addr_min = (unsigned long)ret;
76697 - if ((unsigned long)ret + size > module_addr_max)
76698 - module_addr_max = (unsigned long)ret + size;
76699 + if ((unsigned long)ret < module_addr_min_rw)
76700 + module_addr_min_rw = (unsigned long)ret;
76701 + if ((unsigned long)ret + size > module_addr_max_rw)
76702 + module_addr_max_rw = (unsigned long)ret + size;
76703 + mutex_unlock(&module_mutex);
76704 + }
76705 + return ret;
76706 +}
76707 +
76708 +static void *module_alloc_update_bounds_rx(unsigned long size)
76709 +{
76710 + void *ret = module_alloc_exec(size);
76711 +
76712 + if (ret) {
76713 + mutex_lock(&module_mutex);
76714 + /* Update module bounds. */
76715 + if ((unsigned long)ret < module_addr_min_rx)
76716 + module_addr_min_rx = (unsigned long)ret;
76717 + if ((unsigned long)ret + size > module_addr_max_rx)
76718 + module_addr_max_rx = (unsigned long)ret + size;
76719 mutex_unlock(&module_mutex);
76720 }
76721 return ret;
76722 @@ -2690,8 +2728,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76723 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76724 {
76725 const char *modmagic = get_modinfo(info, "vermagic");
76726 + const char *license = get_modinfo(info, "license");
76727 int err;
76728
76729 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76730 + if (!license || !license_is_gpl_compatible(license))
76731 + return -ENOEXEC;
76732 +#endif
76733 +
76734 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76735 modmagic = NULL;
76736
76737 @@ -2717,7 +2761,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76738 }
76739
76740 /* Set up license info based on the info section */
76741 - set_license(mod, get_modinfo(info, "license"));
76742 + set_license(mod, license);
76743
76744 return 0;
76745 }
76746 @@ -2811,7 +2855,7 @@ static int move_module(struct module *mod, struct load_info *info)
76747 void *ptr;
76748
76749 /* Do the allocs. */
76750 - ptr = module_alloc_update_bounds(mod->core_size);
76751 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76752 /*
76753 * The pointer to this block is stored in the module structure
76754 * which is inside the block. Just mark it as not being a
76755 @@ -2821,11 +2865,11 @@ static int move_module(struct module *mod, struct load_info *info)
76756 if (!ptr)
76757 return -ENOMEM;
76758
76759 - memset(ptr, 0, mod->core_size);
76760 - mod->module_core = ptr;
76761 + memset(ptr, 0, mod->core_size_rw);
76762 + mod->module_core_rw = ptr;
76763
76764 - if (mod->init_size) {
76765 - ptr = module_alloc_update_bounds(mod->init_size);
76766 + if (mod->init_size_rw) {
76767 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76768 /*
76769 * The pointer to this block is stored in the module structure
76770 * which is inside the block. This block doesn't need to be
76771 @@ -2834,13 +2878,45 @@ static int move_module(struct module *mod, struct load_info *info)
76772 */
76773 kmemleak_ignore(ptr);
76774 if (!ptr) {
76775 - module_free(mod, mod->module_core);
76776 + module_free(mod, mod->module_core_rw);
76777 return -ENOMEM;
76778 }
76779 - memset(ptr, 0, mod->init_size);
76780 - mod->module_init = ptr;
76781 + memset(ptr, 0, mod->init_size_rw);
76782 + mod->module_init_rw = ptr;
76783 } else
76784 - mod->module_init = NULL;
76785 + mod->module_init_rw = NULL;
76786 +
76787 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76788 + kmemleak_not_leak(ptr);
76789 + if (!ptr) {
76790 + if (mod->module_init_rw)
76791 + module_free(mod, mod->module_init_rw);
76792 + module_free(mod, mod->module_core_rw);
76793 + return -ENOMEM;
76794 + }
76795 +
76796 + pax_open_kernel();
76797 + memset(ptr, 0, mod->core_size_rx);
76798 + pax_close_kernel();
76799 + mod->module_core_rx = ptr;
76800 +
76801 + if (mod->init_size_rx) {
76802 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76803 + kmemleak_ignore(ptr);
76804 + if (!ptr && mod->init_size_rx) {
76805 + module_free_exec(mod, mod->module_core_rx);
76806 + if (mod->module_init_rw)
76807 + module_free(mod, mod->module_init_rw);
76808 + module_free(mod, mod->module_core_rw);
76809 + return -ENOMEM;
76810 + }
76811 +
76812 + pax_open_kernel();
76813 + memset(ptr, 0, mod->init_size_rx);
76814 + pax_close_kernel();
76815 + mod->module_init_rx = ptr;
76816 + } else
76817 + mod->module_init_rx = NULL;
76818
76819 /* Transfer each section which specifies SHF_ALLOC */
76820 pr_debug("final section addresses:\n");
76821 @@ -2851,16 +2927,45 @@ static int move_module(struct module *mod, struct load_info *info)
76822 if (!(shdr->sh_flags & SHF_ALLOC))
76823 continue;
76824
76825 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76826 - dest = mod->module_init
76827 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76828 - else
76829 - dest = mod->module_core + shdr->sh_entsize;
76830 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76831 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76832 + dest = mod->module_init_rw
76833 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76834 + else
76835 + dest = mod->module_init_rx
76836 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76837 + } else {
76838 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76839 + dest = mod->module_core_rw + shdr->sh_entsize;
76840 + else
76841 + dest = mod->module_core_rx + shdr->sh_entsize;
76842 + }
76843 +
76844 + if (shdr->sh_type != SHT_NOBITS) {
76845 +
76846 +#ifdef CONFIG_PAX_KERNEXEC
76847 +#ifdef CONFIG_X86_64
76848 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76849 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76850 +#endif
76851 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76852 + pax_open_kernel();
76853 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76854 + pax_close_kernel();
76855 + } else
76856 +#endif
76857
76858 - if (shdr->sh_type != SHT_NOBITS)
76859 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76860 + }
76861 /* Update sh_addr to point to copy in image. */
76862 - shdr->sh_addr = (unsigned long)dest;
76863 +
76864 +#ifdef CONFIG_PAX_KERNEXEC
76865 + if (shdr->sh_flags & SHF_EXECINSTR)
76866 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76867 + else
76868 +#endif
76869 +
76870 + shdr->sh_addr = (unsigned long)dest;
76871 pr_debug("\t0x%lx %s\n",
76872 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76873 }
76874 @@ -2917,12 +3022,12 @@ static void flush_module_icache(const struct module *mod)
76875 * Do it before processing of module parameters, so the module
76876 * can provide parameter accessor functions of its own.
76877 */
76878 - if (mod->module_init)
76879 - flush_icache_range((unsigned long)mod->module_init,
76880 - (unsigned long)mod->module_init
76881 - + mod->init_size);
76882 - flush_icache_range((unsigned long)mod->module_core,
76883 - (unsigned long)mod->module_core + mod->core_size);
76884 + if (mod->module_init_rx)
76885 + flush_icache_range((unsigned long)mod->module_init_rx,
76886 + (unsigned long)mod->module_init_rx
76887 + + mod->init_size_rx);
76888 + flush_icache_range((unsigned long)mod->module_core_rx,
76889 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76890
76891 set_fs(old_fs);
76892 }
76893 @@ -2992,8 +3097,10 @@ out:
76894 static void module_deallocate(struct module *mod, struct load_info *info)
76895 {
76896 percpu_modfree(mod);
76897 - module_free(mod, mod->module_init);
76898 - module_free(mod, mod->module_core);
76899 + module_free_exec(mod, mod->module_init_rx);
76900 + module_free_exec(mod, mod->module_core_rx);
76901 + module_free(mod, mod->module_init_rw);
76902 + module_free(mod, mod->module_core_rw);
76903 }
76904
76905 int __weak module_finalize(const Elf_Ehdr *hdr,
76906 @@ -3006,7 +3113,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76907 static int post_relocation(struct module *mod, const struct load_info *info)
76908 {
76909 /* Sort exception table now relocations are done. */
76910 + pax_open_kernel();
76911 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76912 + pax_close_kernel();
76913
76914 /* Copy relocated percpu area over. */
76915 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76916 @@ -3060,16 +3169,16 @@ static int do_init_module(struct module *mod)
76917 MODULE_STATE_COMING, mod);
76918
76919 /* Set RO and NX regions for core */
76920 - set_section_ro_nx(mod->module_core,
76921 - mod->core_text_size,
76922 - mod->core_ro_size,
76923 - mod->core_size);
76924 + set_section_ro_nx(mod->module_core_rx,
76925 + mod->core_size_rx,
76926 + mod->core_size_rx,
76927 + mod->core_size_rx);
76928
76929 /* Set RO and NX regions for init */
76930 - set_section_ro_nx(mod->module_init,
76931 - mod->init_text_size,
76932 - mod->init_ro_size,
76933 - mod->init_size);
76934 + set_section_ro_nx(mod->module_init_rx,
76935 + mod->init_size_rx,
76936 + mod->init_size_rx,
76937 + mod->init_size_rx);
76938
76939 do_mod_ctors(mod);
76940 /* Start the module */
76941 @@ -3131,11 +3240,12 @@ static int do_init_module(struct module *mod)
76942 mod->strtab = mod->core_strtab;
76943 #endif
76944 unset_module_init_ro_nx(mod);
76945 - module_free(mod, mod->module_init);
76946 - mod->module_init = NULL;
76947 - mod->init_size = 0;
76948 - mod->init_ro_size = 0;
76949 - mod->init_text_size = 0;
76950 + module_free(mod, mod->module_init_rw);
76951 + module_free_exec(mod, mod->module_init_rx);
76952 + mod->module_init_rw = NULL;
76953 + mod->module_init_rx = NULL;
76954 + mod->init_size_rw = 0;
76955 + mod->init_size_rx = 0;
76956 mutex_unlock(&module_mutex);
76957 wake_up_all(&module_wq);
76958
76959 @@ -3262,9 +3372,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
76960 if (err)
76961 goto free_unload;
76962
76963 + /* Now copy in args */
76964 + mod->args = strndup_user(uargs, ~0UL >> 1);
76965 + if (IS_ERR(mod->args)) {
76966 + err = PTR_ERR(mod->args);
76967 + goto free_unload;
76968 + }
76969 +
76970 /* Set up MODINFO_ATTR fields */
76971 setup_modinfo(mod, info);
76972
76973 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76974 + {
76975 + char *p, *p2;
76976 +
76977 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76978 + 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);
76979 + err = -EPERM;
76980 + goto free_modinfo;
76981 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76982 + p += sizeof("grsec_modharden_normal") - 1;
76983 + p2 = strstr(p, "_");
76984 + if (p2) {
76985 + *p2 = '\0';
76986 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76987 + *p2 = '_';
76988 + }
76989 + err = -EPERM;
76990 + goto free_modinfo;
76991 + }
76992 + }
76993 +#endif
76994 +
76995 /* Fix up syms, so that st_value is a pointer to location. */
76996 err = simplify_symbols(mod, info);
76997 if (err < 0)
76998 @@ -3280,13 +3419,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
76999
77000 flush_module_icache(mod);
77001
77002 - /* Now copy in args */
77003 - mod->args = strndup_user(uargs, ~0UL >> 1);
77004 - if (IS_ERR(mod->args)) {
77005 - err = PTR_ERR(mod->args);
77006 - goto free_arch_cleanup;
77007 - }
77008 -
77009 dynamic_debug_setup(info->debug, info->num_debug);
77010
77011 /* Finally it's fully formed, ready to start executing. */
77012 @@ -3321,11 +3453,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
77013 ddebug_cleanup:
77014 dynamic_debug_remove(info->debug);
77015 synchronize_sched();
77016 - kfree(mod->args);
77017 - free_arch_cleanup:
77018 module_arch_cleanup(mod);
77019 free_modinfo:
77020 free_modinfo(mod);
77021 + kfree(mod->args);
77022 free_unload:
77023 module_unload_free(mod);
77024 unlink_mod:
77025 @@ -3408,10 +3539,16 @@ static const char *get_ksymbol(struct module *mod,
77026 unsigned long nextval;
77027
77028 /* At worse, next value is at end of module */
77029 - if (within_module_init(addr, mod))
77030 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
77031 + if (within_module_init_rx(addr, mod))
77032 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
77033 + else if (within_module_init_rw(addr, mod))
77034 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
77035 + else if (within_module_core_rx(addr, mod))
77036 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
77037 + else if (within_module_core_rw(addr, mod))
77038 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
77039 else
77040 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
77041 + return NULL;
77042
77043 /* Scan for closest preceding symbol, and next symbol. (ELF
77044 starts real symbols at 1). */
77045 @@ -3664,7 +3801,7 @@ static int m_show(struct seq_file *m, void *p)
77046 return 0;
77047
77048 seq_printf(m, "%s %u",
77049 - mod->name, mod->init_size + mod->core_size);
77050 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
77051 print_unload_info(m, mod);
77052
77053 /* Informative for users. */
77054 @@ -3673,7 +3810,7 @@ static int m_show(struct seq_file *m, void *p)
77055 mod->state == MODULE_STATE_COMING ? "Loading":
77056 "Live");
77057 /* Used by oprofile and other similar tools. */
77058 - seq_printf(m, " 0x%pK", mod->module_core);
77059 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
77060
77061 /* Taints info */
77062 if (mod->taints)
77063 @@ -3709,7 +3846,17 @@ static const struct file_operations proc_modules_operations = {
77064
77065 static int __init proc_modules_init(void)
77066 {
77067 +#ifndef CONFIG_GRKERNSEC_HIDESYM
77068 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77069 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77070 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77071 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
77072 +#else
77073 proc_create("modules", 0, NULL, &proc_modules_operations);
77074 +#endif
77075 +#else
77076 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77077 +#endif
77078 return 0;
77079 }
77080 module_init(proc_modules_init);
77081 @@ -3770,14 +3917,14 @@ struct module *__module_address(unsigned long addr)
77082 {
77083 struct module *mod;
77084
77085 - if (addr < module_addr_min || addr > module_addr_max)
77086 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
77087 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
77088 return NULL;
77089
77090 list_for_each_entry_rcu(mod, &modules, list) {
77091 if (mod->state == MODULE_STATE_UNFORMED)
77092 continue;
77093 - if (within_module_core(addr, mod)
77094 - || within_module_init(addr, mod))
77095 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
77096 return mod;
77097 }
77098 return NULL;
77099 @@ -3812,11 +3959,20 @@ bool is_module_text_address(unsigned long addr)
77100 */
77101 struct module *__module_text_address(unsigned long addr)
77102 {
77103 - struct module *mod = __module_address(addr);
77104 + struct module *mod;
77105 +
77106 +#ifdef CONFIG_X86_32
77107 + addr = ktla_ktva(addr);
77108 +#endif
77109 +
77110 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
77111 + return NULL;
77112 +
77113 + mod = __module_address(addr);
77114 +
77115 if (mod) {
77116 /* Make sure it's within the text section. */
77117 - if (!within(addr, mod->module_init, mod->init_text_size)
77118 - && !within(addr, mod->module_core, mod->core_text_size))
77119 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
77120 mod = NULL;
77121 }
77122 return mod;
77123 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
77124 index 7e3443f..b2a1e6b 100644
77125 --- a/kernel/mutex-debug.c
77126 +++ b/kernel/mutex-debug.c
77127 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
77128 }
77129
77130 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77131 - struct thread_info *ti)
77132 + struct task_struct *task)
77133 {
77134 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
77135
77136 /* Mark the current thread as blocked on the lock: */
77137 - ti->task->blocked_on = waiter;
77138 + task->blocked_on = waiter;
77139 }
77140
77141 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77142 - struct thread_info *ti)
77143 + struct task_struct *task)
77144 {
77145 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
77146 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
77147 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
77148 - ti->task->blocked_on = NULL;
77149 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
77150 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
77151 + task->blocked_on = NULL;
77152
77153 list_del_init(&waiter->list);
77154 waiter->task = NULL;
77155 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
77156 index 0799fd3..d06ae3b 100644
77157 --- a/kernel/mutex-debug.h
77158 +++ b/kernel/mutex-debug.h
77159 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
77160 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
77161 extern void debug_mutex_add_waiter(struct mutex *lock,
77162 struct mutex_waiter *waiter,
77163 - struct thread_info *ti);
77164 + struct task_struct *task);
77165 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77166 - struct thread_info *ti);
77167 + struct task_struct *task);
77168 extern void debug_mutex_unlock(struct mutex *lock);
77169 extern void debug_mutex_init(struct mutex *lock, const char *name,
77170 struct lock_class_key *key);
77171 diff --git a/kernel/mutex.c b/kernel/mutex.c
77172 index 52f2301..73f7528 100644
77173 --- a/kernel/mutex.c
77174 +++ b/kernel/mutex.c
77175 @@ -199,7 +199,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77176 spin_lock_mutex(&lock->wait_lock, flags);
77177
77178 debug_mutex_lock_common(lock, &waiter);
77179 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
77180 + debug_mutex_add_waiter(lock, &waiter, task);
77181
77182 /* add waiting tasks to the end of the waitqueue (FIFO): */
77183 list_add_tail(&waiter.list, &lock->wait_list);
77184 @@ -228,8 +228,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77185 * TASK_UNINTERRUPTIBLE case.)
77186 */
77187 if (unlikely(signal_pending_state(state, task))) {
77188 - mutex_remove_waiter(lock, &waiter,
77189 - task_thread_info(task));
77190 + mutex_remove_waiter(lock, &waiter, task);
77191 mutex_release(&lock->dep_map, 1, ip);
77192 spin_unlock_mutex(&lock->wait_lock, flags);
77193
77194 @@ -248,7 +247,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77195 done:
77196 lock_acquired(&lock->dep_map, ip);
77197 /* got the lock - rejoice! */
77198 - mutex_remove_waiter(lock, &waiter, current_thread_info());
77199 + mutex_remove_waiter(lock, &waiter, task);
77200 mutex_set_owner(lock);
77201
77202 /* set it to 0 if there are no waiters left: */
77203 diff --git a/kernel/notifier.c b/kernel/notifier.c
77204 index 2d5cc4c..d9ea600 100644
77205 --- a/kernel/notifier.c
77206 +++ b/kernel/notifier.c
77207 @@ -5,6 +5,7 @@
77208 #include <linux/rcupdate.h>
77209 #include <linux/vmalloc.h>
77210 #include <linux/reboot.h>
77211 +#include <linux/mm.h>
77212
77213 /*
77214 * Notifier list for kernel code which wants to be called
77215 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
77216 while ((*nl) != NULL) {
77217 if (n->priority > (*nl)->priority)
77218 break;
77219 - nl = &((*nl)->next);
77220 + nl = (struct notifier_block **)&((*nl)->next);
77221 }
77222 - n->next = *nl;
77223 + pax_open_kernel();
77224 + *(const void **)&n->next = *nl;
77225 rcu_assign_pointer(*nl, n);
77226 + pax_close_kernel();
77227 return 0;
77228 }
77229
77230 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
77231 return 0;
77232 if (n->priority > (*nl)->priority)
77233 break;
77234 - nl = &((*nl)->next);
77235 + nl = (struct notifier_block **)&((*nl)->next);
77236 }
77237 - n->next = *nl;
77238 + pax_open_kernel();
77239 + *(const void **)&n->next = *nl;
77240 rcu_assign_pointer(*nl, n);
77241 + pax_close_kernel();
77242 return 0;
77243 }
77244
77245 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
77246 {
77247 while ((*nl) != NULL) {
77248 if ((*nl) == n) {
77249 + pax_open_kernel();
77250 rcu_assign_pointer(*nl, n->next);
77251 + pax_close_kernel();
77252 return 0;
77253 }
77254 - nl = &((*nl)->next);
77255 + nl = (struct notifier_block **)&((*nl)->next);
77256 }
77257 return -ENOENT;
77258 }
77259 diff --git a/kernel/panic.c b/kernel/panic.c
77260 index 7c57cc9..28f1b3f 100644
77261 --- a/kernel/panic.c
77262 +++ b/kernel/panic.c
77263 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77264 const char *board;
77265
77266 printk(KERN_WARNING "------------[ cut here ]------------\n");
77267 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77268 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77269 board = dmi_get_system_info(DMI_PRODUCT_NAME);
77270 if (board)
77271 printk(KERN_WARNING "Hardware name: %s\n", board);
77272 @@ -459,7 +459,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77273 */
77274 void __stack_chk_fail(void)
77275 {
77276 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77277 + dump_stack();
77278 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77279 __builtin_return_address(0));
77280 }
77281 EXPORT_SYMBOL(__stack_chk_fail);
77282 diff --git a/kernel/pid.c b/kernel/pid.c
77283 index 047dc62..418d74b 100644
77284 --- a/kernel/pid.c
77285 +++ b/kernel/pid.c
77286 @@ -33,6 +33,7 @@
77287 #include <linux/rculist.h>
77288 #include <linux/bootmem.h>
77289 #include <linux/hash.h>
77290 +#include <linux/security.h>
77291 #include <linux/pid_namespace.h>
77292 #include <linux/init_task.h>
77293 #include <linux/syscalls.h>
77294 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77295
77296 int pid_max = PID_MAX_DEFAULT;
77297
77298 -#define RESERVED_PIDS 300
77299 +#define RESERVED_PIDS 500
77300
77301 int pid_max_min = RESERVED_PIDS + 1;
77302 int pid_max_max = PID_MAX_LIMIT;
77303 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
77304 */
77305 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77306 {
77307 + struct task_struct *task;
77308 +
77309 rcu_lockdep_assert(rcu_read_lock_held(),
77310 "find_task_by_pid_ns() needs rcu_read_lock()"
77311 " protection");
77312 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77313 +
77314 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77315 +
77316 + if (gr_pid_is_chrooted(task))
77317 + return NULL;
77318 +
77319 + return task;
77320 }
77321
77322 struct task_struct *find_task_by_vpid(pid_t vnr)
77323 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77324 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77325 }
77326
77327 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77328 +{
77329 + rcu_lockdep_assert(rcu_read_lock_held(),
77330 + "find_task_by_pid_ns() needs rcu_read_lock()"
77331 + " protection");
77332 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77333 +}
77334 +
77335 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77336 {
77337 struct pid *pid;
77338 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77339 index bea15bd..789f3d0 100644
77340 --- a/kernel/pid_namespace.c
77341 +++ b/kernel/pid_namespace.c
77342 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77343 void __user *buffer, size_t *lenp, loff_t *ppos)
77344 {
77345 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77346 - struct ctl_table tmp = *table;
77347 + ctl_table_no_const tmp = *table;
77348
77349 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77350 return -EPERM;
77351 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77352 index 8fd709c..542bf4b 100644
77353 --- a/kernel/posix-cpu-timers.c
77354 +++ b/kernel/posix-cpu-timers.c
77355 @@ -1592,14 +1592,14 @@ struct k_clock clock_posix_cpu = {
77356
77357 static __init int init_posix_cpu_timers(void)
77358 {
77359 - struct k_clock process = {
77360 + static struct k_clock process = {
77361 .clock_getres = process_cpu_clock_getres,
77362 .clock_get = process_cpu_clock_get,
77363 .timer_create = process_cpu_timer_create,
77364 .nsleep = process_cpu_nsleep,
77365 .nsleep_restart = process_cpu_nsleep_restart,
77366 };
77367 - struct k_clock thread = {
77368 + static struct k_clock thread = {
77369 .clock_getres = thread_cpu_clock_getres,
77370 .clock_get = thread_cpu_clock_get,
77371 .timer_create = thread_cpu_timer_create,
77372 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77373 index 6edbb2c..334f085 100644
77374 --- a/kernel/posix-timers.c
77375 +++ b/kernel/posix-timers.c
77376 @@ -43,6 +43,7 @@
77377 #include <linux/idr.h>
77378 #include <linux/posix-clock.h>
77379 #include <linux/posix-timers.h>
77380 +#include <linux/grsecurity.h>
77381 #include <linux/syscalls.h>
77382 #include <linux/wait.h>
77383 #include <linux/workqueue.h>
77384 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77385 * which we beg off on and pass to do_sys_settimeofday().
77386 */
77387
77388 -static struct k_clock posix_clocks[MAX_CLOCKS];
77389 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77390
77391 /*
77392 * These ones are defined below.
77393 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77394 */
77395 static __init int init_posix_timers(void)
77396 {
77397 - struct k_clock clock_realtime = {
77398 + static struct k_clock clock_realtime = {
77399 .clock_getres = hrtimer_get_res,
77400 .clock_get = posix_clock_realtime_get,
77401 .clock_set = posix_clock_realtime_set,
77402 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
77403 .timer_get = common_timer_get,
77404 .timer_del = common_timer_del,
77405 };
77406 - struct k_clock clock_monotonic = {
77407 + static struct k_clock clock_monotonic = {
77408 .clock_getres = hrtimer_get_res,
77409 .clock_get = posix_ktime_get_ts,
77410 .nsleep = common_nsleep,
77411 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77412 .timer_get = common_timer_get,
77413 .timer_del = common_timer_del,
77414 };
77415 - struct k_clock clock_monotonic_raw = {
77416 + static struct k_clock clock_monotonic_raw = {
77417 .clock_getres = hrtimer_get_res,
77418 .clock_get = posix_get_monotonic_raw,
77419 };
77420 - struct k_clock clock_realtime_coarse = {
77421 + static struct k_clock clock_realtime_coarse = {
77422 .clock_getres = posix_get_coarse_res,
77423 .clock_get = posix_get_realtime_coarse,
77424 };
77425 - struct k_clock clock_monotonic_coarse = {
77426 + static struct k_clock clock_monotonic_coarse = {
77427 .clock_getres = posix_get_coarse_res,
77428 .clock_get = posix_get_monotonic_coarse,
77429 };
77430 - struct k_clock clock_boottime = {
77431 + static struct k_clock clock_boottime = {
77432 .clock_getres = hrtimer_get_res,
77433 .clock_get = posix_get_boottime,
77434 .nsleep = common_nsleep,
77435 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77436 return;
77437 }
77438
77439 - posix_clocks[clock_id] = *new_clock;
77440 + posix_clocks[clock_id] = new_clock;
77441 }
77442 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77443
77444 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77445 return (id & CLOCKFD_MASK) == CLOCKFD ?
77446 &clock_posix_dynamic : &clock_posix_cpu;
77447
77448 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77449 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77450 return NULL;
77451 - return &posix_clocks[id];
77452 + return posix_clocks[id];
77453 }
77454
77455 static int common_timer_create(struct k_itimer *new_timer)
77456 @@ -964,6 +965,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77457 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77458 return -EFAULT;
77459
77460 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77461 + have their clock_set fptr set to a nosettime dummy function
77462 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77463 + call common_clock_set, which calls do_sys_settimeofday, which
77464 + we hook
77465 + */
77466 +
77467 return kc->clock_set(which_clock, &new_tp);
77468 }
77469
77470 diff --git a/kernel/power/process.c b/kernel/power/process.c
77471 index 98088e0..aaf95c0 100644
77472 --- a/kernel/power/process.c
77473 +++ b/kernel/power/process.c
77474 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77475 u64 elapsed_csecs64;
77476 unsigned int elapsed_csecs;
77477 bool wakeup = false;
77478 + bool timedout = false;
77479
77480 do_gettimeofday(&start);
77481
77482 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77483
77484 while (true) {
77485 todo = 0;
77486 + if (time_after(jiffies, end_time))
77487 + timedout = true;
77488 read_lock(&tasklist_lock);
77489 do_each_thread(g, p) {
77490 if (p == current || !freeze_task(p))
77491 continue;
77492
77493 - if (!freezer_should_skip(p))
77494 + if (!freezer_should_skip(p)) {
77495 todo++;
77496 + if (timedout) {
77497 + printk(KERN_ERR "Task refusing to freeze:\n");
77498 + sched_show_task(p);
77499 + }
77500 + }
77501 } while_each_thread(g, p);
77502 read_unlock(&tasklist_lock);
77503
77504 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77505 todo += wq_busy;
77506 }
77507
77508 - if (!todo || time_after(jiffies, end_time))
77509 + if (!todo || timedout)
77510 break;
77511
77512 if (pm_wakeup_pending()) {
77513 diff --git a/kernel/printk.c b/kernel/printk.c
77514 index 0e4eba6a..d58ebf0 100644
77515 --- a/kernel/printk.c
77516 +++ b/kernel/printk.c
77517 @@ -395,6 +395,11 @@ static int check_syslog_permissions(int type, bool from_file)
77518 if (from_file && type != SYSLOG_ACTION_OPEN)
77519 return 0;
77520
77521 +#ifdef CONFIG_GRKERNSEC_DMESG
77522 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77523 + return -EPERM;
77524 +#endif
77525 +
77526 if (syslog_action_restricted(type)) {
77527 if (capable(CAP_SYSLOG))
77528 return 0;
77529 diff --git a/kernel/profile.c b/kernel/profile.c
77530 index dc3384e..0de5b49 100644
77531 --- a/kernel/profile.c
77532 +++ b/kernel/profile.c
77533 @@ -37,7 +37,7 @@ struct profile_hit {
77534 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
77535 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
77536
77537 -static atomic_t *prof_buffer;
77538 +static atomic_unchecked_t *prof_buffer;
77539 static unsigned long prof_len, prof_shift;
77540
77541 int prof_on __read_mostly;
77542 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
77543 hits[i].pc = 0;
77544 continue;
77545 }
77546 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77547 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77548 hits[i].hits = hits[i].pc = 0;
77549 }
77550 }
77551 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77552 * Add the current hit(s) and flush the write-queue out
77553 * to the global buffer:
77554 */
77555 - atomic_add(nr_hits, &prof_buffer[pc]);
77556 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77557 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77558 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77559 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77560 hits[i].pc = hits[i].hits = 0;
77561 }
77562 out:
77563 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77564 {
77565 unsigned long pc;
77566 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77567 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77568 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77569 }
77570 #endif /* !CONFIG_SMP */
77571
77572 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77573 return -EFAULT;
77574 buf++; p++; count--; read++;
77575 }
77576 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77577 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77578 if (copy_to_user(buf, (void *)pnt, count))
77579 return -EFAULT;
77580 read += count;
77581 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77582 }
77583 #endif
77584 profile_discard_flip_buffers();
77585 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77586 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77587 return count;
77588 }
77589
77590 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77591 index acbd284..00bb0c9 100644
77592 --- a/kernel/ptrace.c
77593 +++ b/kernel/ptrace.c
77594 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77595 if (seize)
77596 flags |= PT_SEIZED;
77597 rcu_read_lock();
77598 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77599 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77600 flags |= PT_PTRACE_CAP;
77601 rcu_read_unlock();
77602 task->ptrace = flags;
77603 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77604 break;
77605 return -EIO;
77606 }
77607 - if (copy_to_user(dst, buf, retval))
77608 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77609 return -EFAULT;
77610 copied += retval;
77611 src += retval;
77612 @@ -726,7 +726,7 @@ int ptrace_request(struct task_struct *child, long request,
77613 bool seized = child->ptrace & PT_SEIZED;
77614 int ret = -EIO;
77615 siginfo_t siginfo, *si;
77616 - void __user *datavp = (void __user *) data;
77617 + void __user *datavp = (__force void __user *) data;
77618 unsigned long __user *datalp = datavp;
77619 unsigned long flags;
77620
77621 @@ -928,14 +928,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77622 goto out;
77623 }
77624
77625 + if (gr_handle_ptrace(child, request)) {
77626 + ret = -EPERM;
77627 + goto out_put_task_struct;
77628 + }
77629 +
77630 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77631 ret = ptrace_attach(child, request, addr, data);
77632 /*
77633 * Some architectures need to do book-keeping after
77634 * a ptrace attach.
77635 */
77636 - if (!ret)
77637 + if (!ret) {
77638 arch_ptrace_attach(child);
77639 + gr_audit_ptrace(child);
77640 + }
77641 goto out_put_task_struct;
77642 }
77643
77644 @@ -963,7 +970,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77645 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77646 if (copied != sizeof(tmp))
77647 return -EIO;
77648 - return put_user(tmp, (unsigned long __user *)data);
77649 + return put_user(tmp, (__force unsigned long __user *)data);
77650 }
77651
77652 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77653 @@ -1057,7 +1064,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77654 }
77655
77656 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77657 - compat_long_t addr, compat_long_t data)
77658 + compat_ulong_t addr, compat_ulong_t data)
77659 {
77660 struct task_struct *child;
77661 long ret;
77662 @@ -1073,14 +1080,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77663 goto out;
77664 }
77665
77666 + if (gr_handle_ptrace(child, request)) {
77667 + ret = -EPERM;
77668 + goto out_put_task_struct;
77669 + }
77670 +
77671 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77672 ret = ptrace_attach(child, request, addr, data);
77673 /*
77674 * Some architectures need to do book-keeping after
77675 * a ptrace attach.
77676 */
77677 - if (!ret)
77678 + if (!ret) {
77679 arch_ptrace_attach(child);
77680 + gr_audit_ptrace(child);
77681 + }
77682 goto out_put_task_struct;
77683 }
77684
77685 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
77686 index 48ab703..07561d4 100644
77687 --- a/kernel/rcupdate.c
77688 +++ b/kernel/rcupdate.c
77689 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
77690 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77691 */
77692 if (till_stall_check < 3) {
77693 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77694 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77695 till_stall_check = 3;
77696 } else if (till_stall_check > 300) {
77697 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77698 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77699 till_stall_check = 300;
77700 }
77701 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77702 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77703 index a0714a5..2ab5e34 100644
77704 --- a/kernel/rcutiny.c
77705 +++ b/kernel/rcutiny.c
77706 @@ -46,7 +46,7 @@
77707 struct rcu_ctrlblk;
77708 static void invoke_rcu_callbacks(void);
77709 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77710 -static void rcu_process_callbacks(struct softirq_action *unused);
77711 +static void rcu_process_callbacks(void);
77712 static void __call_rcu(struct rcu_head *head,
77713 void (*func)(struct rcu_head *rcu),
77714 struct rcu_ctrlblk *rcp);
77715 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77716 rcu_is_callbacks_kthread()));
77717 }
77718
77719 -static void rcu_process_callbacks(struct softirq_action *unused)
77720 +static void rcu_process_callbacks(void)
77721 {
77722 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77723 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77724 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77725 index 8a23300..4255818 100644
77726 --- a/kernel/rcutiny_plugin.h
77727 +++ b/kernel/rcutiny_plugin.h
77728 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
77729 have_rcu_kthread_work = morework;
77730 local_irq_restore(flags);
77731 if (work)
77732 - rcu_process_callbacks(NULL);
77733 + rcu_process_callbacks();
77734 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77735 }
77736
77737 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77738 index e1f3a8c..42c94a2 100644
77739 --- a/kernel/rcutorture.c
77740 +++ b/kernel/rcutorture.c
77741 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77742 { 0 };
77743 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77744 { 0 };
77745 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77746 -static atomic_t n_rcu_torture_alloc;
77747 -static atomic_t n_rcu_torture_alloc_fail;
77748 -static atomic_t n_rcu_torture_free;
77749 -static atomic_t n_rcu_torture_mberror;
77750 -static atomic_t n_rcu_torture_error;
77751 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77752 +static atomic_unchecked_t n_rcu_torture_alloc;
77753 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77754 +static atomic_unchecked_t n_rcu_torture_free;
77755 +static atomic_unchecked_t n_rcu_torture_mberror;
77756 +static atomic_unchecked_t n_rcu_torture_error;
77757 static long n_rcu_torture_barrier_error;
77758 static long n_rcu_torture_boost_ktrerror;
77759 static long n_rcu_torture_boost_rterror;
77760 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
77761
77762 spin_lock_bh(&rcu_torture_lock);
77763 if (list_empty(&rcu_torture_freelist)) {
77764 - atomic_inc(&n_rcu_torture_alloc_fail);
77765 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77766 spin_unlock_bh(&rcu_torture_lock);
77767 return NULL;
77768 }
77769 - atomic_inc(&n_rcu_torture_alloc);
77770 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77771 p = rcu_torture_freelist.next;
77772 list_del_init(p);
77773 spin_unlock_bh(&rcu_torture_lock);
77774 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
77775 static void
77776 rcu_torture_free(struct rcu_torture *p)
77777 {
77778 - atomic_inc(&n_rcu_torture_free);
77779 + atomic_inc_unchecked(&n_rcu_torture_free);
77780 spin_lock_bh(&rcu_torture_lock);
77781 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77782 spin_unlock_bh(&rcu_torture_lock);
77783 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
77784 i = rp->rtort_pipe_count;
77785 if (i > RCU_TORTURE_PIPE_LEN)
77786 i = RCU_TORTURE_PIPE_LEN;
77787 - atomic_inc(&rcu_torture_wcount[i]);
77788 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77789 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77790 rp->rtort_mbtest = 0;
77791 rcu_torture_free(rp);
77792 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77793 i = rp->rtort_pipe_count;
77794 if (i > RCU_TORTURE_PIPE_LEN)
77795 i = RCU_TORTURE_PIPE_LEN;
77796 - atomic_inc(&rcu_torture_wcount[i]);
77797 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77798 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77799 rp->rtort_mbtest = 0;
77800 list_del(&rp->rtort_free);
77801 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
77802 i = old_rp->rtort_pipe_count;
77803 if (i > RCU_TORTURE_PIPE_LEN)
77804 i = RCU_TORTURE_PIPE_LEN;
77805 - atomic_inc(&rcu_torture_wcount[i]);
77806 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77807 old_rp->rtort_pipe_count++;
77808 cur_ops->deferred_free(old_rp);
77809 }
77810 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
77811 return;
77812 }
77813 if (p->rtort_mbtest == 0)
77814 - atomic_inc(&n_rcu_torture_mberror);
77815 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77816 spin_lock(&rand_lock);
77817 cur_ops->read_delay(&rand);
77818 n_rcu_torture_timers++;
77819 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
77820 continue;
77821 }
77822 if (p->rtort_mbtest == 0)
77823 - atomic_inc(&n_rcu_torture_mberror);
77824 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77825 cur_ops->read_delay(&rand);
77826 preempt_disable();
77827 pipe_count = p->rtort_pipe_count;
77828 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
77829 rcu_torture_current,
77830 rcu_torture_current_version,
77831 list_empty(&rcu_torture_freelist),
77832 - atomic_read(&n_rcu_torture_alloc),
77833 - atomic_read(&n_rcu_torture_alloc_fail),
77834 - atomic_read(&n_rcu_torture_free));
77835 + atomic_read_unchecked(&n_rcu_torture_alloc),
77836 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77837 + atomic_read_unchecked(&n_rcu_torture_free));
77838 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77839 - atomic_read(&n_rcu_torture_mberror),
77840 + atomic_read_unchecked(&n_rcu_torture_mberror),
77841 n_rcu_torture_boost_ktrerror,
77842 n_rcu_torture_boost_rterror);
77843 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77844 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
77845 n_barrier_attempts,
77846 n_rcu_torture_barrier_error);
77847 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77848 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77849 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77850 n_rcu_torture_barrier_error != 0 ||
77851 n_rcu_torture_boost_ktrerror != 0 ||
77852 n_rcu_torture_boost_rterror != 0 ||
77853 n_rcu_torture_boost_failure != 0 ||
77854 i > 1) {
77855 cnt += sprintf(&page[cnt], "!!! ");
77856 - atomic_inc(&n_rcu_torture_error);
77857 + atomic_inc_unchecked(&n_rcu_torture_error);
77858 WARN_ON_ONCE(1);
77859 }
77860 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77861 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
77862 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77863 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77864 cnt += sprintf(&page[cnt], " %d",
77865 - atomic_read(&rcu_torture_wcount[i]));
77866 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77867 }
77868 cnt += sprintf(&page[cnt], "\n");
77869 if (cur_ops->stats)
77870 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
77871
77872 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77873
77874 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77875 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77876 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77877 else if (n_online_successes != n_online_attempts ||
77878 n_offline_successes != n_offline_attempts)
77879 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
77880
77881 rcu_torture_current = NULL;
77882 rcu_torture_current_version = 0;
77883 - atomic_set(&n_rcu_torture_alloc, 0);
77884 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77885 - atomic_set(&n_rcu_torture_free, 0);
77886 - atomic_set(&n_rcu_torture_mberror, 0);
77887 - atomic_set(&n_rcu_torture_error, 0);
77888 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77889 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77890 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77891 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77892 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77893 n_rcu_torture_barrier_error = 0;
77894 n_rcu_torture_boost_ktrerror = 0;
77895 n_rcu_torture_boost_rterror = 0;
77896 n_rcu_torture_boost_failure = 0;
77897 n_rcu_torture_boosts = 0;
77898 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77899 - atomic_set(&rcu_torture_wcount[i], 0);
77900 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77901 for_each_possible_cpu(cpu) {
77902 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77903 per_cpu(rcu_torture_count, cpu)[i] = 0;
77904 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77905 index 5b8ad82..59e1f64 100644
77906 --- a/kernel/rcutree.c
77907 +++ b/kernel/rcutree.c
77908 @@ -353,9 +353,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77909 rcu_prepare_for_idle(smp_processor_id());
77910 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77911 smp_mb__before_atomic_inc(); /* See above. */
77912 - atomic_inc(&rdtp->dynticks);
77913 + atomic_inc_unchecked(&rdtp->dynticks);
77914 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77915 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77916 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77917
77918 /*
77919 * It is illegal to enter an extended quiescent state while
77920 @@ -491,10 +491,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77921 int user)
77922 {
77923 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77924 - atomic_inc(&rdtp->dynticks);
77925 + atomic_inc_unchecked(&rdtp->dynticks);
77926 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77927 smp_mb__after_atomic_inc(); /* See above. */
77928 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77929 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77930 rcu_cleanup_after_idle(smp_processor_id());
77931 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77932 if (!user && !is_idle_task(current)) {
77933 @@ -633,14 +633,14 @@ void rcu_nmi_enter(void)
77934 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77935
77936 if (rdtp->dynticks_nmi_nesting == 0 &&
77937 - (atomic_read(&rdtp->dynticks) & 0x1))
77938 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77939 return;
77940 rdtp->dynticks_nmi_nesting++;
77941 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77942 - atomic_inc(&rdtp->dynticks);
77943 + atomic_inc_unchecked(&rdtp->dynticks);
77944 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77945 smp_mb__after_atomic_inc(); /* See above. */
77946 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77947 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77948 }
77949
77950 /**
77951 @@ -659,9 +659,9 @@ void rcu_nmi_exit(void)
77952 return;
77953 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77954 smp_mb__before_atomic_inc(); /* See above. */
77955 - atomic_inc(&rdtp->dynticks);
77956 + atomic_inc_unchecked(&rdtp->dynticks);
77957 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77958 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77959 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77960 }
77961
77962 /**
77963 @@ -675,7 +675,7 @@ int rcu_is_cpu_idle(void)
77964 int ret;
77965
77966 preempt_disable();
77967 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77968 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77969 preempt_enable();
77970 return ret;
77971 }
77972 @@ -743,7 +743,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
77973 */
77974 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77975 {
77976 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77977 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77978 return (rdp->dynticks_snap & 0x1) == 0;
77979 }
77980
77981 @@ -758,7 +758,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77982 unsigned int curr;
77983 unsigned int snap;
77984
77985 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77986 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77987 snap = (unsigned int)rdp->dynticks_snap;
77988
77989 /*
77990 @@ -1698,7 +1698,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77991 rsp->qlen += rdp->qlen;
77992 rdp->n_cbs_orphaned += rdp->qlen;
77993 rdp->qlen_lazy = 0;
77994 - ACCESS_ONCE(rdp->qlen) = 0;
77995 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77996 }
77997
77998 /*
77999 @@ -1944,7 +1944,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
78000 }
78001 smp_mb(); /* List handling before counting for rcu_barrier(). */
78002 rdp->qlen_lazy -= count_lazy;
78003 - ACCESS_ONCE(rdp->qlen) -= count;
78004 + ACCESS_ONCE_RW(rdp->qlen) -= count;
78005 rdp->n_cbs_invoked += count;
78006
78007 /* Reinstate batch limit if we have worked down the excess. */
78008 @@ -2137,7 +2137,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
78009 /*
78010 * Do RCU core processing for the current CPU.
78011 */
78012 -static void rcu_process_callbacks(struct softirq_action *unused)
78013 +static void rcu_process_callbacks(void)
78014 {
78015 struct rcu_state *rsp;
78016
78017 @@ -2260,7 +2260,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
78018 local_irq_restore(flags);
78019 return;
78020 }
78021 - ACCESS_ONCE(rdp->qlen)++;
78022 + ACCESS_ONCE_RW(rdp->qlen)++;
78023 if (lazy)
78024 rdp->qlen_lazy++;
78025 else
78026 @@ -2469,11 +2469,11 @@ void synchronize_sched_expedited(void)
78027 * counter wrap on a 32-bit system. Quite a few more CPUs would of
78028 * course be required on a 64-bit system.
78029 */
78030 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
78031 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
78032 (ulong)atomic_long_read(&rsp->expedited_done) +
78033 ULONG_MAX / 8)) {
78034 synchronize_sched();
78035 - atomic_long_inc(&rsp->expedited_wrap);
78036 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
78037 return;
78038 }
78039
78040 @@ -2481,7 +2481,7 @@ void synchronize_sched_expedited(void)
78041 * Take a ticket. Note that atomic_inc_return() implies a
78042 * full memory barrier.
78043 */
78044 - snap = atomic_long_inc_return(&rsp->expedited_start);
78045 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
78046 firstsnap = snap;
78047 get_online_cpus();
78048 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
78049 @@ -2494,14 +2494,14 @@ void synchronize_sched_expedited(void)
78050 synchronize_sched_expedited_cpu_stop,
78051 NULL) == -EAGAIN) {
78052 put_online_cpus();
78053 - atomic_long_inc(&rsp->expedited_tryfail);
78054 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
78055
78056 /* Check to see if someone else did our work for us. */
78057 s = atomic_long_read(&rsp->expedited_done);
78058 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78059 /* ensure test happens before caller kfree */
78060 smp_mb__before_atomic_inc(); /* ^^^ */
78061 - atomic_long_inc(&rsp->expedited_workdone1);
78062 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
78063 return;
78064 }
78065
78066 @@ -2510,7 +2510,7 @@ void synchronize_sched_expedited(void)
78067 udelay(trycount * num_online_cpus());
78068 } else {
78069 wait_rcu_gp(call_rcu_sched);
78070 - atomic_long_inc(&rsp->expedited_normal);
78071 + atomic_long_inc_unchecked(&rsp->expedited_normal);
78072 return;
78073 }
78074
78075 @@ -2519,7 +2519,7 @@ void synchronize_sched_expedited(void)
78076 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78077 /* ensure test happens before caller kfree */
78078 smp_mb__before_atomic_inc(); /* ^^^ */
78079 - atomic_long_inc(&rsp->expedited_workdone2);
78080 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
78081 return;
78082 }
78083
78084 @@ -2531,10 +2531,10 @@ void synchronize_sched_expedited(void)
78085 * period works for us.
78086 */
78087 get_online_cpus();
78088 - snap = atomic_long_read(&rsp->expedited_start);
78089 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
78090 smp_mb(); /* ensure read is before try_stop_cpus(). */
78091 }
78092 - atomic_long_inc(&rsp->expedited_stoppedcpus);
78093 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
78094
78095 /*
78096 * Everyone up to our most recent fetch is covered by our grace
78097 @@ -2543,16 +2543,16 @@ void synchronize_sched_expedited(void)
78098 * than we did already did their update.
78099 */
78100 do {
78101 - atomic_long_inc(&rsp->expedited_done_tries);
78102 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
78103 s = atomic_long_read(&rsp->expedited_done);
78104 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
78105 /* ensure test happens before caller kfree */
78106 smp_mb__before_atomic_inc(); /* ^^^ */
78107 - atomic_long_inc(&rsp->expedited_done_lost);
78108 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
78109 break;
78110 }
78111 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
78112 - atomic_long_inc(&rsp->expedited_done_exit);
78113 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
78114
78115 put_online_cpus();
78116 }
78117 @@ -2726,7 +2726,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78118 * ACCESS_ONCE() to prevent the compiler from speculating
78119 * the increment to precede the early-exit check.
78120 */
78121 - ACCESS_ONCE(rsp->n_barrier_done)++;
78122 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78123 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
78124 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
78125 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
78126 @@ -2776,7 +2776,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78127
78128 /* Increment ->n_barrier_done to prevent duplicate work. */
78129 smp_mb(); /* Keep increment after above mechanism. */
78130 - ACCESS_ONCE(rsp->n_barrier_done)++;
78131 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78132 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
78133 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
78134 smp_mb(); /* Keep increment before caller's subsequent code. */
78135 @@ -2821,10 +2821,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
78136 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
78137 init_callback_list(rdp);
78138 rdp->qlen_lazy = 0;
78139 - ACCESS_ONCE(rdp->qlen) = 0;
78140 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78141 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
78142 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
78143 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
78144 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
78145 rdp->cpu = cpu;
78146 rdp->rsp = rsp;
78147 rcu_boot_init_nocb_percpu_data(rdp);
78148 @@ -2857,8 +2857,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
78149 rdp->blimit = blimit;
78150 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
78151 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
78152 - atomic_set(&rdp->dynticks->dynticks,
78153 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
78154 + atomic_set_unchecked(&rdp->dynticks->dynticks,
78155 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
78156 rcu_prepare_for_idle_init(cpu);
78157 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
78158
78159 @@ -2964,7 +2964,7 @@ static int __init rcu_spawn_gp_kthread(void)
78160 struct task_struct *t;
78161
78162 for_each_rcu_flavor(rsp) {
78163 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
78164 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
78165 BUG_ON(IS_ERR(t));
78166 rnp = rcu_get_root(rsp);
78167 raw_spin_lock_irqsave(&rnp->lock, flags);
78168 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
78169 index c896b50..c357252 100644
78170 --- a/kernel/rcutree.h
78171 +++ b/kernel/rcutree.h
78172 @@ -86,7 +86,7 @@ struct rcu_dynticks {
78173 long long dynticks_nesting; /* Track irq/process nesting level. */
78174 /* Process level is worth LLONG_MAX/2. */
78175 int dynticks_nmi_nesting; /* Track NMI nesting level. */
78176 - atomic_t dynticks; /* Even value for idle, else odd. */
78177 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
78178 #ifdef CONFIG_RCU_FAST_NO_HZ
78179 int dyntick_drain; /* Prepare-for-idle state variable. */
78180 unsigned long dyntick_holdoff;
78181 @@ -416,17 +416,17 @@ struct rcu_state {
78182 /* _rcu_barrier(). */
78183 /* End of fields guarded by barrier_mutex. */
78184
78185 - atomic_long_t expedited_start; /* Starting ticket. */
78186 - atomic_long_t expedited_done; /* Done ticket. */
78187 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
78188 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
78189 - atomic_long_t expedited_workdone1; /* # done by others #1. */
78190 - atomic_long_t expedited_workdone2; /* # done by others #2. */
78191 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
78192 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
78193 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
78194 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
78195 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
78196 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
78197 + atomic_long_t expedited_done; /* Done ticket. */
78198 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
78199 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
78200 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
78201 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
78202 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
78203 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
78204 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
78205 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
78206 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
78207
78208 unsigned long jiffies_force_qs; /* Time at which to invoke */
78209 /* force_quiescent_state(). */
78210 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
78211 index c1cc7e1..f62e436 100644
78212 --- a/kernel/rcutree_plugin.h
78213 +++ b/kernel/rcutree_plugin.h
78214 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
78215
78216 /* Clean up and exit. */
78217 smp_mb(); /* ensure expedited GP seen before counter increment. */
78218 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
78219 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
78220 unlock_mb_ret:
78221 mutex_unlock(&sync_rcu_preempt_exp_mutex);
78222 mb_ret:
78223 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
78224 free_cpumask_var(cm);
78225 }
78226
78227 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
78228 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
78229 .store = &rcu_cpu_kthread_task,
78230 .thread_should_run = rcu_cpu_kthread_should_run,
78231 .thread_fn = rcu_cpu_kthread,
78232 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
78233 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
78234 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
78235 cpu, ticks_value, ticks_title,
78236 - atomic_read(&rdtp->dynticks) & 0xfff,
78237 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
78238 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
78239 fast_no_hz);
78240 }
78241 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
78242
78243 /* Enqueue the callback on the nocb list and update counts. */
78244 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78245 - ACCESS_ONCE(*old_rhpp) = rhp;
78246 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78247 atomic_long_add(rhcount, &rdp->nocb_q_count);
78248 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78249
78250 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
78251 * Extract queued callbacks, update counts, and wait
78252 * for a grace period to elapse.
78253 */
78254 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78255 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78256 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78257 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78258 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78259 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78260 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78261 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78262 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78263 wait_rcu_gp(rdp->rsp->call_remote);
78264
78265 /* Each pass through the following loop invokes a callback. */
78266 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
78267 list = next;
78268 }
78269 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78270 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78271 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78272 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78273 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78274 rdp->n_nocbs_invoked += c;
78275 }
78276 return 0;
78277 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78278 rdp = per_cpu_ptr(rsp->rda, cpu);
78279 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
78280 BUG_ON(IS_ERR(t));
78281 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78282 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78283 }
78284 }
78285
78286 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78287 index 93f8e8f..cf812ae 100644
78288 --- a/kernel/rcutree_trace.c
78289 +++ b/kernel/rcutree_trace.c
78290 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78291 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78292 rdp->passed_quiesce, rdp->qs_pending);
78293 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78294 - atomic_read(&rdp->dynticks->dynticks),
78295 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78296 rdp->dynticks->dynticks_nesting,
78297 rdp->dynticks->dynticks_nmi_nesting,
78298 rdp->dynticks_fqs);
78299 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78300 struct rcu_state *rsp = (struct rcu_state *)m->private;
78301
78302 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",
78303 - atomic_long_read(&rsp->expedited_start),
78304 + atomic_long_read_unchecked(&rsp->expedited_start),
78305 atomic_long_read(&rsp->expedited_done),
78306 - atomic_long_read(&rsp->expedited_wrap),
78307 - atomic_long_read(&rsp->expedited_tryfail),
78308 - atomic_long_read(&rsp->expedited_workdone1),
78309 - atomic_long_read(&rsp->expedited_workdone2),
78310 - atomic_long_read(&rsp->expedited_normal),
78311 - atomic_long_read(&rsp->expedited_stoppedcpus),
78312 - atomic_long_read(&rsp->expedited_done_tries),
78313 - atomic_long_read(&rsp->expedited_done_lost),
78314 - atomic_long_read(&rsp->expedited_done_exit));
78315 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78316 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78317 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78318 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78319 + atomic_long_read_unchecked(&rsp->expedited_normal),
78320 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78321 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78322 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78323 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78324 return 0;
78325 }
78326
78327 diff --git a/kernel/resource.c b/kernel/resource.c
78328 index 73f35d4..4684fc4 100644
78329 --- a/kernel/resource.c
78330 +++ b/kernel/resource.c
78331 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78332
78333 static int __init ioresources_init(void)
78334 {
78335 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78336 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78337 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78338 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78339 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78340 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78341 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78342 +#endif
78343 +#else
78344 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78345 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78346 +#endif
78347 return 0;
78348 }
78349 __initcall(ioresources_init);
78350 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78351 index 7890b10..8b68605f 100644
78352 --- a/kernel/rtmutex-tester.c
78353 +++ b/kernel/rtmutex-tester.c
78354 @@ -21,7 +21,7 @@
78355 #define MAX_RT_TEST_MUTEXES 8
78356
78357 static spinlock_t rttest_lock;
78358 -static atomic_t rttest_event;
78359 +static atomic_unchecked_t rttest_event;
78360
78361 struct test_thread_data {
78362 int opcode;
78363 @@ -62,7 +62,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78364
78365 case RTTEST_LOCKCONT:
78366 td->mutexes[td->opdata] = 1;
78367 - td->event = atomic_add_return(1, &rttest_event);
78368 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78369 return 0;
78370
78371 case RTTEST_RESET:
78372 @@ -75,7 +75,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78373 return 0;
78374
78375 case RTTEST_RESETEVENT:
78376 - atomic_set(&rttest_event, 0);
78377 + atomic_set_unchecked(&rttest_event, 0);
78378 return 0;
78379
78380 default:
78381 @@ -92,9 +92,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78382 return ret;
78383
78384 td->mutexes[id] = 1;
78385 - td->event = atomic_add_return(1, &rttest_event);
78386 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78387 rt_mutex_lock(&mutexes[id]);
78388 - td->event = atomic_add_return(1, &rttest_event);
78389 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78390 td->mutexes[id] = 4;
78391 return 0;
78392
78393 @@ -105,9 +105,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78394 return ret;
78395
78396 td->mutexes[id] = 1;
78397 - td->event = atomic_add_return(1, &rttest_event);
78398 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78399 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78400 - td->event = atomic_add_return(1, &rttest_event);
78401 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78402 td->mutexes[id] = ret ? 0 : 4;
78403 return ret ? -EINTR : 0;
78404
78405 @@ -116,9 +116,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78406 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78407 return ret;
78408
78409 - td->event = atomic_add_return(1, &rttest_event);
78410 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78411 rt_mutex_unlock(&mutexes[id]);
78412 - td->event = atomic_add_return(1, &rttest_event);
78413 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78414 td->mutexes[id] = 0;
78415 return 0;
78416
78417 @@ -165,7 +165,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78418 break;
78419
78420 td->mutexes[dat] = 2;
78421 - td->event = atomic_add_return(1, &rttest_event);
78422 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78423 break;
78424
78425 default:
78426 @@ -185,7 +185,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78427 return;
78428
78429 td->mutexes[dat] = 3;
78430 - td->event = atomic_add_return(1, &rttest_event);
78431 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78432 break;
78433
78434 case RTTEST_LOCKNOWAIT:
78435 @@ -197,7 +197,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78436 return;
78437
78438 td->mutexes[dat] = 1;
78439 - td->event = atomic_add_return(1, &rttest_event);
78440 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78441 return;
78442
78443 default:
78444 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78445 index 64de5f8..7735e12 100644
78446 --- a/kernel/sched/auto_group.c
78447 +++ b/kernel/sched/auto_group.c
78448 @@ -11,7 +11,7 @@
78449
78450 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78451 static struct autogroup autogroup_default;
78452 -static atomic_t autogroup_seq_nr;
78453 +static atomic_unchecked_t autogroup_seq_nr;
78454
78455 void __init autogroup_init(struct task_struct *init_task)
78456 {
78457 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
78458
78459 kref_init(&ag->kref);
78460 init_rwsem(&ag->lock);
78461 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78462 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78463 ag->tg = tg;
78464 #ifdef CONFIG_RT_GROUP_SCHED
78465 /*
78466 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78467 index 67d0465..4cf9361 100644
78468 --- a/kernel/sched/core.c
78469 +++ b/kernel/sched/core.c
78470 @@ -3406,7 +3406,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78471 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78472 * positive (at least 1, or number of jiffies left till timeout) if completed.
78473 */
78474 -long __sched
78475 +long __sched __intentional_overflow(-1)
78476 wait_for_completion_interruptible_timeout(struct completion *x,
78477 unsigned long timeout)
78478 {
78479 @@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78480 *
78481 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78482 */
78483 -int __sched wait_for_completion_killable(struct completion *x)
78484 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78485 {
78486 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78487 if (t == -ERESTARTSYS)
78488 @@ -3444,7 +3444,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78489 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78490 * positive (at least 1, or number of jiffies left till timeout) if completed.
78491 */
78492 -long __sched
78493 +long __sched __intentional_overflow(-1)
78494 wait_for_completion_killable_timeout(struct completion *x,
78495 unsigned long timeout)
78496 {
78497 @@ -3670,6 +3670,8 @@ int can_nice(const struct task_struct *p, const int nice)
78498 /* convert nice value [19,-20] to rlimit style value [1,40] */
78499 int nice_rlim = 20 - nice;
78500
78501 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78502 +
78503 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78504 capable(CAP_SYS_NICE));
78505 }
78506 @@ -3703,7 +3705,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78507 if (nice > 19)
78508 nice = 19;
78509
78510 - if (increment < 0 && !can_nice(current, nice))
78511 + if (increment < 0 && (!can_nice(current, nice) ||
78512 + gr_handle_chroot_nice()))
78513 return -EPERM;
78514
78515 retval = security_task_setnice(current, nice);
78516 @@ -3857,6 +3860,7 @@ recheck:
78517 unsigned long rlim_rtprio =
78518 task_rlimit(p, RLIMIT_RTPRIO);
78519
78520 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78521 /* can't set/change the rt policy */
78522 if (policy != p->policy && !rlim_rtprio)
78523 return -EPERM;
78524 @@ -4954,7 +4958,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78525
78526 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78527
78528 -static struct ctl_table sd_ctl_dir[] = {
78529 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78530 {
78531 .procname = "sched_domain",
78532 .mode = 0555,
78533 @@ -4971,17 +4975,17 @@ static struct ctl_table sd_ctl_root[] = {
78534 {}
78535 };
78536
78537 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78538 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78539 {
78540 - struct ctl_table *entry =
78541 + ctl_table_no_const *entry =
78542 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78543
78544 return entry;
78545 }
78546
78547 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78548 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78549 {
78550 - struct ctl_table *entry;
78551 + ctl_table_no_const *entry;
78552
78553 /*
78554 * In the intermediate directories, both the child directory and
78555 @@ -4989,22 +4993,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78556 * will always be set. In the lowest directory the names are
78557 * static strings and all have proc handlers.
78558 */
78559 - for (entry = *tablep; entry->mode; entry++) {
78560 - if (entry->child)
78561 - sd_free_ctl_entry(&entry->child);
78562 + for (entry = tablep; entry->mode; entry++) {
78563 + if (entry->child) {
78564 + sd_free_ctl_entry(entry->child);
78565 + pax_open_kernel();
78566 + entry->child = NULL;
78567 + pax_close_kernel();
78568 + }
78569 if (entry->proc_handler == NULL)
78570 kfree(entry->procname);
78571 }
78572
78573 - kfree(*tablep);
78574 - *tablep = NULL;
78575 + kfree(tablep);
78576 }
78577
78578 static int min_load_idx = 0;
78579 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78580
78581 static void
78582 -set_table_entry(struct ctl_table *entry,
78583 +set_table_entry(ctl_table_no_const *entry,
78584 const char *procname, void *data, int maxlen,
78585 umode_t mode, proc_handler *proc_handler,
78586 bool load_idx)
78587 @@ -5024,7 +5031,7 @@ set_table_entry(struct ctl_table *entry,
78588 static struct ctl_table *
78589 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78590 {
78591 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78592 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78593
78594 if (table == NULL)
78595 return NULL;
78596 @@ -5059,9 +5066,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78597 return table;
78598 }
78599
78600 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78601 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78602 {
78603 - struct ctl_table *entry, *table;
78604 + ctl_table_no_const *entry, *table;
78605 struct sched_domain *sd;
78606 int domain_num = 0, i;
78607 char buf[32];
78608 @@ -5088,11 +5095,13 @@ static struct ctl_table_header *sd_sysctl_header;
78609 static void register_sched_domain_sysctl(void)
78610 {
78611 int i, cpu_num = num_possible_cpus();
78612 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78613 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78614 char buf[32];
78615
78616 WARN_ON(sd_ctl_dir[0].child);
78617 + pax_open_kernel();
78618 sd_ctl_dir[0].child = entry;
78619 + pax_close_kernel();
78620
78621 if (entry == NULL)
78622 return;
78623 @@ -5115,8 +5124,12 @@ static void unregister_sched_domain_sysctl(void)
78624 if (sd_sysctl_header)
78625 unregister_sysctl_table(sd_sysctl_header);
78626 sd_sysctl_header = NULL;
78627 - if (sd_ctl_dir[0].child)
78628 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78629 + if (sd_ctl_dir[0].child) {
78630 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78631 + pax_open_kernel();
78632 + sd_ctl_dir[0].child = NULL;
78633 + pax_close_kernel();
78634 + }
78635 }
78636 #else
78637 static void register_sched_domain_sysctl(void)
78638 @@ -5215,7 +5228,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78639 * happens before everything else. This has to be lower priority than
78640 * the notifier in the perf_event subsystem, though.
78641 */
78642 -static struct notifier_block __cpuinitdata migration_notifier = {
78643 +static struct notifier_block migration_notifier = {
78644 .notifier_call = migration_call,
78645 .priority = CPU_PRI_MIGRATION,
78646 };
78647 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78648 index 7a33e59..2f7730c 100644
78649 --- a/kernel/sched/fair.c
78650 +++ b/kernel/sched/fair.c
78651 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78652
78653 static void reset_ptenuma_scan(struct task_struct *p)
78654 {
78655 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78656 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78657 p->mm->numa_scan_offset = 0;
78658 }
78659
78660 @@ -5654,7 +5654,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78661 * run_rebalance_domains is triggered when needed from the scheduler tick.
78662 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78663 */
78664 -static void run_rebalance_domains(struct softirq_action *h)
78665 +static void run_rebalance_domains(void)
78666 {
78667 int this_cpu = smp_processor_id();
78668 struct rq *this_rq = cpu_rq(this_cpu);
78669 diff --git a/kernel/signal.c b/kernel/signal.c
78670 index 598dc06..471310a 100644
78671 --- a/kernel/signal.c
78672 +++ b/kernel/signal.c
78673 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78674
78675 int print_fatal_signals __read_mostly;
78676
78677 -static void __user *sig_handler(struct task_struct *t, int sig)
78678 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78679 {
78680 return t->sighand->action[sig - 1].sa.sa_handler;
78681 }
78682
78683 -static int sig_handler_ignored(void __user *handler, int sig)
78684 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78685 {
78686 /* Is it explicitly or implicitly ignored? */
78687 return handler == SIG_IGN ||
78688 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78689
78690 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78691 {
78692 - void __user *handler;
78693 + __sighandler_t handler;
78694
78695 handler = sig_handler(t, sig);
78696
78697 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78698 atomic_inc(&user->sigpending);
78699 rcu_read_unlock();
78700
78701 + if (!override_rlimit)
78702 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78703 +
78704 if (override_rlimit ||
78705 atomic_read(&user->sigpending) <=
78706 task_rlimit(t, RLIMIT_SIGPENDING)) {
78707 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78708
78709 int unhandled_signal(struct task_struct *tsk, int sig)
78710 {
78711 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78712 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78713 if (is_global_init(tsk))
78714 return 1;
78715 if (handler != SIG_IGN && handler != SIG_DFL)
78716 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78717 }
78718 }
78719
78720 + /* allow glibc communication via tgkill to other threads in our
78721 + thread group */
78722 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78723 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78724 + && gr_handle_signal(t, sig))
78725 + return -EPERM;
78726 +
78727 return security_task_kill(t, info, sig, 0);
78728 }
78729
78730 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78731 return send_signal(sig, info, p, 1);
78732 }
78733
78734 -static int
78735 +int
78736 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78737 {
78738 return send_signal(sig, info, t, 0);
78739 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78740 unsigned long int flags;
78741 int ret, blocked, ignored;
78742 struct k_sigaction *action;
78743 + int is_unhandled = 0;
78744
78745 spin_lock_irqsave(&t->sighand->siglock, flags);
78746 action = &t->sighand->action[sig-1];
78747 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78748 }
78749 if (action->sa.sa_handler == SIG_DFL)
78750 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78751 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78752 + is_unhandled = 1;
78753 ret = specific_send_sig_info(sig, info, t);
78754 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78755
78756 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78757 + normal operation */
78758 + if (is_unhandled) {
78759 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78760 + gr_handle_crash(t, sig);
78761 + }
78762 +
78763 return ret;
78764 }
78765
78766 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78767 ret = check_kill_permission(sig, info, p);
78768 rcu_read_unlock();
78769
78770 - if (!ret && sig)
78771 + if (!ret && sig) {
78772 ret = do_send_sig_info(sig, info, p, true);
78773 + if (!ret)
78774 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78775 + }
78776
78777 return ret;
78778 }
78779 @@ -2923,7 +2946,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78780 int error = -ESRCH;
78781
78782 rcu_read_lock();
78783 - p = find_task_by_vpid(pid);
78784 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78785 + /* allow glibc communication via tgkill to other threads in our
78786 + thread group */
78787 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78788 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78789 + p = find_task_by_vpid_unrestricted(pid);
78790 + else
78791 +#endif
78792 + p = find_task_by_vpid(pid);
78793 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78794 error = check_kill_permission(sig, info, p);
78795 /*
78796 @@ -3237,8 +3268,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78797 }
78798 seg = get_fs();
78799 set_fs(KERNEL_DS);
78800 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78801 - (stack_t __force __user *) &uoss,
78802 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78803 + (stack_t __force_user *) &uoss,
78804 compat_user_stack_pointer());
78805 set_fs(seg);
78806 if (ret >= 0 && uoss_ptr) {
78807 diff --git a/kernel/smp.c b/kernel/smp.c
78808 index 8e451f3..8322029 100644
78809 --- a/kernel/smp.c
78810 +++ b/kernel/smp.c
78811 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78812 return NOTIFY_OK;
78813 }
78814
78815 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78816 +static struct notifier_block hotplug_cfd_notifier = {
78817 .notifier_call = hotplug_cfd,
78818 };
78819
78820 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78821 index 02fc5c9..e54c335 100644
78822 --- a/kernel/smpboot.c
78823 +++ b/kernel/smpboot.c
78824 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78825 }
78826 smpboot_unpark_thread(plug_thread, cpu);
78827 }
78828 - list_add(&plug_thread->list, &hotplug_threads);
78829 + pax_list_add(&plug_thread->list, &hotplug_threads);
78830 out:
78831 mutex_unlock(&smpboot_threads_lock);
78832 return ret;
78833 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78834 {
78835 get_online_cpus();
78836 mutex_lock(&smpboot_threads_lock);
78837 - list_del(&plug_thread->list);
78838 + pax_list_del(&plug_thread->list);
78839 smpboot_destroy_threads(plug_thread);
78840 mutex_unlock(&smpboot_threads_lock);
78841 put_online_cpus();
78842 diff --git a/kernel/softirq.c b/kernel/softirq.c
78843 index d93dcb1..1cd8a71 100644
78844 --- a/kernel/softirq.c
78845 +++ b/kernel/softirq.c
78846 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78847 EXPORT_SYMBOL(irq_stat);
78848 #endif
78849
78850 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78851 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78852
78853 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78854
78855 -char *softirq_to_name[NR_SOFTIRQS] = {
78856 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78857 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78858 "TASKLET", "SCHED", "HRTIMER", "RCU"
78859 };
78860 @@ -250,7 +250,7 @@ restart:
78861 kstat_incr_softirqs_this_cpu(vec_nr);
78862
78863 trace_softirq_entry(vec_nr);
78864 - h->action(h);
78865 + h->action();
78866 trace_softirq_exit(vec_nr);
78867 if (unlikely(prev_count != preempt_count())) {
78868 printk(KERN_ERR "huh, entered softirq %u %s %p"
78869 @@ -396,7 +396,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78870 or_softirq_pending(1UL << nr);
78871 }
78872
78873 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78874 +void __init open_softirq(int nr, void (*action)(void))
78875 {
78876 softirq_vec[nr].action = action;
78877 }
78878 @@ -452,7 +452,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78879
78880 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78881
78882 -static void tasklet_action(struct softirq_action *a)
78883 +static void tasklet_action(void)
78884 {
78885 struct tasklet_struct *list;
78886
78887 @@ -487,7 +487,7 @@ static void tasklet_action(struct softirq_action *a)
78888 }
78889 }
78890
78891 -static void tasklet_hi_action(struct softirq_action *a)
78892 +static void tasklet_hi_action(void)
78893 {
78894 struct tasklet_struct *list;
78895
78896 @@ -723,7 +723,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78897 return NOTIFY_OK;
78898 }
78899
78900 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78901 +static struct notifier_block remote_softirq_cpu_notifier = {
78902 .notifier_call = remote_softirq_cpu_notify,
78903 };
78904
78905 @@ -840,11 +840,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78906 return NOTIFY_OK;
78907 }
78908
78909 -static struct notifier_block __cpuinitdata cpu_nfb = {
78910 +static struct notifier_block cpu_nfb = {
78911 .notifier_call = cpu_callback
78912 };
78913
78914 -static struct smp_hotplug_thread softirq_threads = {
78915 +static struct smp_hotplug_thread softirq_threads __read_only = {
78916 .store = &ksoftirqd,
78917 .thread_should_run = ksoftirqd_should_run,
78918 .thread_fn = run_ksoftirqd,
78919 diff --git a/kernel/srcu.c b/kernel/srcu.c
78920 index 01d5ccb..cdcbee6 100644
78921 --- a/kernel/srcu.c
78922 +++ b/kernel/srcu.c
78923 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78924
78925 idx = ACCESS_ONCE(sp->completed) & 0x1;
78926 preempt_disable();
78927 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78928 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78929 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78930 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78931 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78932 preempt_enable();
78933 return idx;
78934 }
78935 diff --git a/kernel/sys.c b/kernel/sys.c
78936 index e5f0aca..8d58b1f 100644
78937 --- a/kernel/sys.c
78938 +++ b/kernel/sys.c
78939 @@ -158,6 +158,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78940 error = -EACCES;
78941 goto out;
78942 }
78943 +
78944 + if (gr_handle_chroot_setpriority(p, niceval)) {
78945 + error = -EACCES;
78946 + goto out;
78947 + }
78948 +
78949 no_nice = security_task_setnice(p, niceval);
78950 if (no_nice) {
78951 error = no_nice;
78952 @@ -621,6 +627,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78953 goto error;
78954 }
78955
78956 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78957 + goto error;
78958 +
78959 if (rgid != (gid_t) -1 ||
78960 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78961 new->sgid = new->egid;
78962 @@ -656,6 +665,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78963 old = current_cred();
78964
78965 retval = -EPERM;
78966 +
78967 + if (gr_check_group_change(kgid, kgid, kgid))
78968 + goto error;
78969 +
78970 if (nsown_capable(CAP_SETGID))
78971 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78972 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78973 @@ -673,7 +686,7 @@ error:
78974 /*
78975 * change the user struct in a credentials set to match the new UID
78976 */
78977 -static int set_user(struct cred *new)
78978 +int set_user(struct cred *new)
78979 {
78980 struct user_struct *new_user;
78981
78982 @@ -753,6 +766,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78983 goto error;
78984 }
78985
78986 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78987 + goto error;
78988 +
78989 if (!uid_eq(new->uid, old->uid)) {
78990 retval = set_user(new);
78991 if (retval < 0)
78992 @@ -803,6 +819,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78993 old = current_cred();
78994
78995 retval = -EPERM;
78996 +
78997 + if (gr_check_crash_uid(kuid))
78998 + goto error;
78999 + if (gr_check_user_change(kuid, kuid, kuid))
79000 + goto error;
79001 +
79002 if (nsown_capable(CAP_SETUID)) {
79003 new->suid = new->uid = kuid;
79004 if (!uid_eq(kuid, old->uid)) {
79005 @@ -872,6 +894,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
79006 goto error;
79007 }
79008
79009 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
79010 + goto error;
79011 +
79012 if (ruid != (uid_t) -1) {
79013 new->uid = kruid;
79014 if (!uid_eq(kruid, old->uid)) {
79015 @@ -954,6 +979,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
79016 goto error;
79017 }
79018
79019 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
79020 + goto error;
79021 +
79022 if (rgid != (gid_t) -1)
79023 new->gid = krgid;
79024 if (egid != (gid_t) -1)
79025 @@ -1015,12 +1043,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
79026 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
79027 nsown_capable(CAP_SETUID)) {
79028 if (!uid_eq(kuid, old->fsuid)) {
79029 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
79030 + goto error;
79031 +
79032 new->fsuid = kuid;
79033 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
79034 goto change_okay;
79035 }
79036 }
79037
79038 +error:
79039 abort_creds(new);
79040 return old_fsuid;
79041
79042 @@ -1053,12 +1085,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
79043 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
79044 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
79045 nsown_capable(CAP_SETGID)) {
79046 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
79047 + goto error;
79048 +
79049 if (!gid_eq(kgid, old->fsgid)) {
79050 new->fsgid = kgid;
79051 goto change_okay;
79052 }
79053 }
79054
79055 +error:
79056 abort_creds(new);
79057 return old_fsgid;
79058
79059 @@ -1366,19 +1402,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
79060 return -EFAULT;
79061
79062 down_read(&uts_sem);
79063 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
79064 + error = __copy_to_user(name->sysname, &utsname()->sysname,
79065 __OLD_UTS_LEN);
79066 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
79067 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
79068 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
79069 __OLD_UTS_LEN);
79070 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
79071 - error |= __copy_to_user(&name->release, &utsname()->release,
79072 + error |= __copy_to_user(name->release, &utsname()->release,
79073 __OLD_UTS_LEN);
79074 error |= __put_user(0, name->release + __OLD_UTS_LEN);
79075 - error |= __copy_to_user(&name->version, &utsname()->version,
79076 + error |= __copy_to_user(name->version, &utsname()->version,
79077 __OLD_UTS_LEN);
79078 error |= __put_user(0, name->version + __OLD_UTS_LEN);
79079 - error |= __copy_to_user(&name->machine, &utsname()->machine,
79080 + error |= __copy_to_user(name->machine, &utsname()->machine,
79081 __OLD_UTS_LEN);
79082 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
79083 up_read(&uts_sem);
79084 @@ -1580,6 +1616,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
79085 */
79086 new_rlim->rlim_cur = 1;
79087 }
79088 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
79089 + is changed to a lower value. Since tasks can be created by the same
79090 + user in between this limit change and an execve by this task, force
79091 + a recheck only for this task by setting PF_NPROC_EXCEEDED
79092 + */
79093 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
79094 + tsk->flags |= PF_NPROC_EXCEEDED;
79095 }
79096 if (!retval) {
79097 if (old_rlim)
79098 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
79099 index afc1dc6..f6cf355 100644
79100 --- a/kernel/sysctl.c
79101 +++ b/kernel/sysctl.c
79102 @@ -93,7 +93,6 @@
79103
79104
79105 #if defined(CONFIG_SYSCTL)
79106 -
79107 /* External variables not in a header file. */
79108 extern int sysctl_overcommit_memory;
79109 extern int sysctl_overcommit_ratio;
79110 @@ -120,18 +119,18 @@ extern int blk_iopoll_enabled;
79111
79112 /* Constants used for minimum and maximum */
79113 #ifdef CONFIG_LOCKUP_DETECTOR
79114 -static int sixty = 60;
79115 -static int neg_one = -1;
79116 +static int sixty __read_only = 60;
79117 #endif
79118
79119 -static int zero;
79120 -static int __maybe_unused one = 1;
79121 -static int __maybe_unused two = 2;
79122 -static int __maybe_unused three = 3;
79123 -static unsigned long one_ul = 1;
79124 -static int one_hundred = 100;
79125 +static int neg_one __read_only = -1;
79126 +static int zero __read_only = 0;
79127 +static int __maybe_unused one __read_only = 1;
79128 +static int __maybe_unused two __read_only = 2;
79129 +static int __maybe_unused three __read_only = 3;
79130 +static unsigned long one_ul __read_only = 1;
79131 +static int one_hundred __read_only = 100;
79132 #ifdef CONFIG_PRINTK
79133 -static int ten_thousand = 10000;
79134 +static int ten_thousand __read_only = 10000;
79135 #endif
79136
79137 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
79138 @@ -178,10 +177,8 @@ static int proc_taint(struct ctl_table *table, int write,
79139 void __user *buffer, size_t *lenp, loff_t *ppos);
79140 #endif
79141
79142 -#ifdef CONFIG_PRINTK
79143 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79144 void __user *buffer, size_t *lenp, loff_t *ppos);
79145 -#endif
79146
79147 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
79148 void __user *buffer, size_t *lenp, loff_t *ppos);
79149 @@ -212,6 +209,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
79150
79151 #endif
79152
79153 +extern struct ctl_table grsecurity_table[];
79154 +
79155 static struct ctl_table kern_table[];
79156 static struct ctl_table vm_table[];
79157 static struct ctl_table fs_table[];
79158 @@ -226,6 +225,20 @@ extern struct ctl_table epoll_table[];
79159 int sysctl_legacy_va_layout;
79160 #endif
79161
79162 +#ifdef CONFIG_PAX_SOFTMODE
79163 +static ctl_table pax_table[] = {
79164 + {
79165 + .procname = "softmode",
79166 + .data = &pax_softmode,
79167 + .maxlen = sizeof(unsigned int),
79168 + .mode = 0600,
79169 + .proc_handler = &proc_dointvec,
79170 + },
79171 +
79172 + { }
79173 +};
79174 +#endif
79175 +
79176 /* The default sysctl tables: */
79177
79178 static struct ctl_table sysctl_base_table[] = {
79179 @@ -274,6 +287,22 @@ static int max_extfrag_threshold = 1000;
79180 #endif
79181
79182 static struct ctl_table kern_table[] = {
79183 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
79184 + {
79185 + .procname = "grsecurity",
79186 + .mode = 0500,
79187 + .child = grsecurity_table,
79188 + },
79189 +#endif
79190 +
79191 +#ifdef CONFIG_PAX_SOFTMODE
79192 + {
79193 + .procname = "pax",
79194 + .mode = 0500,
79195 + .child = pax_table,
79196 + },
79197 +#endif
79198 +
79199 {
79200 .procname = "sched_child_runs_first",
79201 .data = &sysctl_sched_child_runs_first,
79202 @@ -608,7 +637,7 @@ static struct ctl_table kern_table[] = {
79203 .data = &modprobe_path,
79204 .maxlen = KMOD_PATH_LEN,
79205 .mode = 0644,
79206 - .proc_handler = proc_dostring,
79207 + .proc_handler = proc_dostring_modpriv,
79208 },
79209 {
79210 .procname = "modules_disabled",
79211 @@ -775,16 +804,20 @@ static struct ctl_table kern_table[] = {
79212 .extra1 = &zero,
79213 .extra2 = &one,
79214 },
79215 +#endif
79216 {
79217 .procname = "kptr_restrict",
79218 .data = &kptr_restrict,
79219 .maxlen = sizeof(int),
79220 .mode = 0644,
79221 .proc_handler = proc_dointvec_minmax_sysadmin,
79222 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79223 + .extra1 = &two,
79224 +#else
79225 .extra1 = &zero,
79226 +#endif
79227 .extra2 = &two,
79228 },
79229 -#endif
79230 {
79231 .procname = "ngroups_max",
79232 .data = &ngroups_max,
79233 @@ -1026,10 +1059,17 @@ static struct ctl_table kern_table[] = {
79234 */
79235 {
79236 .procname = "perf_event_paranoid",
79237 - .data = &sysctl_perf_event_paranoid,
79238 - .maxlen = sizeof(sysctl_perf_event_paranoid),
79239 + .data = &sysctl_perf_event_legitimately_concerned,
79240 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
79241 .mode = 0644,
79242 - .proc_handler = proc_dointvec,
79243 + /* go ahead, be a hero */
79244 + .proc_handler = proc_dointvec_minmax_sysadmin,
79245 + .extra1 = &neg_one,
79246 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
79247 + .extra2 = &three,
79248 +#else
79249 + .extra2 = &two,
79250 +#endif
79251 },
79252 {
79253 .procname = "perf_event_mlock_kb",
79254 @@ -1283,6 +1323,13 @@ static struct ctl_table vm_table[] = {
79255 .proc_handler = proc_dointvec_minmax,
79256 .extra1 = &zero,
79257 },
79258 + {
79259 + .procname = "heap_stack_gap",
79260 + .data = &sysctl_heap_stack_gap,
79261 + .maxlen = sizeof(sysctl_heap_stack_gap),
79262 + .mode = 0644,
79263 + .proc_handler = proc_doulongvec_minmax,
79264 + },
79265 #else
79266 {
79267 .procname = "nr_trim_pages",
79268 @@ -1733,6 +1780,16 @@ int proc_dostring(struct ctl_table *table, int write,
79269 buffer, lenp, ppos);
79270 }
79271
79272 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79273 + void __user *buffer, size_t *lenp, loff_t *ppos)
79274 +{
79275 + if (write && !capable(CAP_SYS_MODULE))
79276 + return -EPERM;
79277 +
79278 + return _proc_do_string(table->data, table->maxlen, write,
79279 + buffer, lenp, ppos);
79280 +}
79281 +
79282 static size_t proc_skip_spaces(char **buf)
79283 {
79284 size_t ret;
79285 @@ -1838,6 +1895,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79286 len = strlen(tmp);
79287 if (len > *size)
79288 len = *size;
79289 + if (len > sizeof(tmp))
79290 + len = sizeof(tmp);
79291 if (copy_to_user(*buf, tmp, len))
79292 return -EFAULT;
79293 *size -= len;
79294 @@ -2002,7 +2061,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79295 static int proc_taint(struct ctl_table *table, int write,
79296 void __user *buffer, size_t *lenp, loff_t *ppos)
79297 {
79298 - struct ctl_table t;
79299 + ctl_table_no_const t;
79300 unsigned long tmptaint = get_taint();
79301 int err;
79302
79303 @@ -2030,7 +2089,6 @@ static int proc_taint(struct ctl_table *table, int write,
79304 return err;
79305 }
79306
79307 -#ifdef CONFIG_PRINTK
79308 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79309 void __user *buffer, size_t *lenp, loff_t *ppos)
79310 {
79311 @@ -2039,7 +2097,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79312
79313 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79314 }
79315 -#endif
79316
79317 struct do_proc_dointvec_minmax_conv_param {
79318 int *min;
79319 @@ -2186,8 +2243,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79320 *i = val;
79321 } else {
79322 val = convdiv * (*i) / convmul;
79323 - if (!first)
79324 + if (!first) {
79325 err = proc_put_char(&buffer, &left, '\t');
79326 + if (err)
79327 + break;
79328 + }
79329 err = proc_put_long(&buffer, &left, val, false);
79330 if (err)
79331 break;
79332 @@ -2579,6 +2639,12 @@ int proc_dostring(struct ctl_table *table, int write,
79333 return -ENOSYS;
79334 }
79335
79336 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79337 + void __user *buffer, size_t *lenp, loff_t *ppos)
79338 +{
79339 + return -ENOSYS;
79340 +}
79341 +
79342 int proc_dointvec(struct ctl_table *table, int write,
79343 void __user *buffer, size_t *lenp, loff_t *ppos)
79344 {
79345 @@ -2635,5 +2701,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79346 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79347 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79348 EXPORT_SYMBOL(proc_dostring);
79349 +EXPORT_SYMBOL(proc_dostring_modpriv);
79350 EXPORT_SYMBOL(proc_doulongvec_minmax);
79351 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79352 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79353 index 145bb4d..b2aa969 100644
79354 --- a/kernel/taskstats.c
79355 +++ b/kernel/taskstats.c
79356 @@ -28,9 +28,12 @@
79357 #include <linux/fs.h>
79358 #include <linux/file.h>
79359 #include <linux/pid_namespace.h>
79360 +#include <linux/grsecurity.h>
79361 #include <net/genetlink.h>
79362 #include <linux/atomic.h>
79363
79364 +extern int gr_is_taskstats_denied(int pid);
79365 +
79366 /*
79367 * Maximum length of a cpumask that can be specified in
79368 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79369 @@ -570,6 +573,9 @@ err:
79370
79371 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79372 {
79373 + if (gr_is_taskstats_denied(current->pid))
79374 + return -EACCES;
79375 +
79376 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79377 return cmd_attr_register_cpumask(info);
79378 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79379 diff --git a/kernel/time.c b/kernel/time.c
79380 index f8342a4..288f13b 100644
79381 --- a/kernel/time.c
79382 +++ b/kernel/time.c
79383 @@ -171,6 +171,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79384 return error;
79385
79386 if (tz) {
79387 + /* we log in do_settimeofday called below, so don't log twice
79388 + */
79389 + if (!tv)
79390 + gr_log_timechange();
79391 +
79392 sys_tz = *tz;
79393 update_vsyscall_tz();
79394 if (firsttime) {
79395 @@ -501,7 +506,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79396 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79397 * value to a scaled second value.
79398 */
79399 -unsigned long
79400 +unsigned long __intentional_overflow(-1)
79401 timespec_to_jiffies(const struct timespec *value)
79402 {
79403 unsigned long sec = value->tv_sec;
79404 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79405 index f11d83b..d016d91 100644
79406 --- a/kernel/time/alarmtimer.c
79407 +++ b/kernel/time/alarmtimer.c
79408 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79409 struct platform_device *pdev;
79410 int error = 0;
79411 int i;
79412 - struct k_clock alarm_clock = {
79413 + static struct k_clock alarm_clock = {
79414 .clock_getres = alarm_clock_getres,
79415 .clock_get = alarm_clock_get,
79416 .timer_create = alarm_timer_create,
79417 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79418 index 90ad470..1814e9a 100644
79419 --- a/kernel/time/tick-broadcast.c
79420 +++ b/kernel/time/tick-broadcast.c
79421 @@ -138,7 +138,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79422 * then clear the broadcast bit.
79423 */
79424 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79425 - int cpu = smp_processor_id();
79426 + cpu = smp_processor_id();
79427 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79428 tick_broadcast_clear_oneshot(cpu);
79429 } else {
79430 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79431 index 183df62..59b1442 100644
79432 --- a/kernel/time/timekeeping.c
79433 +++ b/kernel/time/timekeeping.c
79434 @@ -15,6 +15,7 @@
79435 #include <linux/init.h>
79436 #include <linux/mm.h>
79437 #include <linux/sched.h>
79438 +#include <linux/grsecurity.h>
79439 #include <linux/syscore_ops.h>
79440 #include <linux/clocksource.h>
79441 #include <linux/jiffies.h>
79442 @@ -448,6 +449,8 @@ int do_settimeofday(const struct timespec *tv)
79443 if (!timespec_valid_strict(tv))
79444 return -EINVAL;
79445
79446 + gr_log_timechange();
79447 +
79448 write_seqlock_irqsave(&tk->lock, flags);
79449
79450 timekeeping_forward_now(tk);
79451 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79452 index af5a7e9..715611a 100644
79453 --- a/kernel/time/timer_list.c
79454 +++ b/kernel/time/timer_list.c
79455 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79456
79457 static void print_name_offset(struct seq_file *m, void *sym)
79458 {
79459 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79460 + SEQ_printf(m, "<%p>", NULL);
79461 +#else
79462 char symname[KSYM_NAME_LEN];
79463
79464 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79465 SEQ_printf(m, "<%pK>", sym);
79466 else
79467 SEQ_printf(m, "%s", symname);
79468 +#endif
79469 }
79470
79471 static void
79472 @@ -112,7 +116,11 @@ next_one:
79473 static void
79474 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79475 {
79476 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79477 + SEQ_printf(m, " .base: %p\n", NULL);
79478 +#else
79479 SEQ_printf(m, " .base: %pK\n", base);
79480 +#endif
79481 SEQ_printf(m, " .index: %d\n",
79482 base->index);
79483 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79484 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79485 {
79486 struct proc_dir_entry *pe;
79487
79488 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79489 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79490 +#else
79491 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79492 +#endif
79493 if (!pe)
79494 return -ENOMEM;
79495 return 0;
79496 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79497 index 0b537f2..40d6c20 100644
79498 --- a/kernel/time/timer_stats.c
79499 +++ b/kernel/time/timer_stats.c
79500 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79501 static unsigned long nr_entries;
79502 static struct entry entries[MAX_ENTRIES];
79503
79504 -static atomic_t overflow_count;
79505 +static atomic_unchecked_t overflow_count;
79506
79507 /*
79508 * The entries are in a hash-table, for fast lookup:
79509 @@ -140,7 +140,7 @@ static void reset_entries(void)
79510 nr_entries = 0;
79511 memset(entries, 0, sizeof(entries));
79512 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79513 - atomic_set(&overflow_count, 0);
79514 + atomic_set_unchecked(&overflow_count, 0);
79515 }
79516
79517 static struct entry *alloc_entry(void)
79518 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79519 if (likely(entry))
79520 entry->count++;
79521 else
79522 - atomic_inc(&overflow_count);
79523 + atomic_inc_unchecked(&overflow_count);
79524
79525 out_unlock:
79526 raw_spin_unlock_irqrestore(lock, flags);
79527 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79528
79529 static void print_name_offset(struct seq_file *m, unsigned long addr)
79530 {
79531 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79532 + seq_printf(m, "<%p>", NULL);
79533 +#else
79534 char symname[KSYM_NAME_LEN];
79535
79536 if (lookup_symbol_name(addr, symname) < 0)
79537 - seq_printf(m, "<%p>", (void *)addr);
79538 + seq_printf(m, "<%pK>", (void *)addr);
79539 else
79540 seq_printf(m, "%s", symname);
79541 +#endif
79542 }
79543
79544 static int tstats_show(struct seq_file *m, void *v)
79545 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79546
79547 seq_puts(m, "Timer Stats Version: v0.2\n");
79548 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79549 - if (atomic_read(&overflow_count))
79550 + if (atomic_read_unchecked(&overflow_count))
79551 seq_printf(m, "Overflow: %d entries\n",
79552 - atomic_read(&overflow_count));
79553 + atomic_read_unchecked(&overflow_count));
79554
79555 for (i = 0; i < nr_entries; i++) {
79556 entry = entries + i;
79557 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79558 {
79559 struct proc_dir_entry *pe;
79560
79561 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79562 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79563 +#else
79564 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79565 +#endif
79566 if (!pe)
79567 return -ENOMEM;
79568 return 0;
79569 diff --git a/kernel/timer.c b/kernel/timer.c
79570 index 1b399c8..90e1849 100644
79571 --- a/kernel/timer.c
79572 +++ b/kernel/timer.c
79573 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79574 /*
79575 * This function runs timers and the timer-tq in bottom half context.
79576 */
79577 -static void run_timer_softirq(struct softirq_action *h)
79578 +static void run_timer_softirq(void)
79579 {
79580 struct tvec_base *base = __this_cpu_read(tvec_bases);
79581
79582 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79583 *
79584 * In all cases the return value is guaranteed to be non-negative.
79585 */
79586 -signed long __sched schedule_timeout(signed long timeout)
79587 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79588 {
79589 struct timer_list timer;
79590 unsigned long expire;
79591 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79592 return NOTIFY_OK;
79593 }
79594
79595 -static struct notifier_block __cpuinitdata timers_nb = {
79596 +static struct notifier_block timers_nb = {
79597 .notifier_call = timer_cpu_notify,
79598 };
79599
79600 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79601 index 5a0f781..1497f95 100644
79602 --- a/kernel/trace/blktrace.c
79603 +++ b/kernel/trace/blktrace.c
79604 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79605 struct blk_trace *bt = filp->private_data;
79606 char buf[16];
79607
79608 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79609 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79610
79611 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79612 }
79613 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79614 return 1;
79615
79616 bt = buf->chan->private_data;
79617 - atomic_inc(&bt->dropped);
79618 + atomic_inc_unchecked(&bt->dropped);
79619 return 0;
79620 }
79621
79622 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79623
79624 bt->dir = dir;
79625 bt->dev = dev;
79626 - atomic_set(&bt->dropped, 0);
79627 + atomic_set_unchecked(&bt->dropped, 0);
79628
79629 ret = -EIO;
79630 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79631 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79632 index 0a0e2a6..943495e 100644
79633 --- a/kernel/trace/ftrace.c
79634 +++ b/kernel/trace/ftrace.c
79635 @@ -1909,12 +1909,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79636 if (unlikely(ftrace_disabled))
79637 return 0;
79638
79639 + ret = ftrace_arch_code_modify_prepare();
79640 + FTRACE_WARN_ON(ret);
79641 + if (ret)
79642 + return 0;
79643 +
79644 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79645 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79646 if (ret) {
79647 ftrace_bug(ret, ip);
79648 - return 0;
79649 }
79650 - return 1;
79651 + return ret ? 0 : 1;
79652 }
79653
79654 /*
79655 @@ -2986,7 +2991,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79656
79657 int
79658 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79659 - void *data)
79660 + void *data)
79661 {
79662 struct ftrace_func_probe *entry;
79663 struct ftrace_page *pg;
79664 @@ -3854,8 +3859,10 @@ static int ftrace_process_locs(struct module *mod,
79665 if (!count)
79666 return 0;
79667
79668 + pax_open_kernel();
79669 sort(start, count, sizeof(*start),
79670 ftrace_cmp_ips, ftrace_swap_ips);
79671 + pax_close_kernel();
79672
79673 start_pg = ftrace_allocate_pages(count);
79674 if (!start_pg)
79675 @@ -4574,8 +4581,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79676 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79677
79678 static int ftrace_graph_active;
79679 -static struct notifier_block ftrace_suspend_notifier;
79680 -
79681 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79682 {
79683 return 0;
79684 @@ -4719,6 +4724,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79685 return NOTIFY_DONE;
79686 }
79687
79688 +static struct notifier_block ftrace_suspend_notifier = {
79689 + .notifier_call = ftrace_suspend_notifier_call
79690 +};
79691 +
79692 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79693 trace_func_graph_ent_t entryfunc)
79694 {
79695 @@ -4732,7 +4741,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79696 goto out;
79697 }
79698
79699 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79700 register_pm_notifier(&ftrace_suspend_notifier);
79701
79702 ftrace_graph_active++;
79703 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79704 index 6989df2..c2265cf 100644
79705 --- a/kernel/trace/ring_buffer.c
79706 +++ b/kernel/trace/ring_buffer.c
79707 @@ -349,9 +349,9 @@ struct buffer_data_page {
79708 */
79709 struct buffer_page {
79710 struct list_head list; /* list of buffer pages */
79711 - local_t write; /* index for next write */
79712 + local_unchecked_t write; /* index for next write */
79713 unsigned read; /* index for next read */
79714 - local_t entries; /* entries on this page */
79715 + local_unchecked_t entries; /* entries on this page */
79716 unsigned long real_end; /* real end of data */
79717 struct buffer_data_page *page; /* Actual data page */
79718 };
79719 @@ -464,8 +464,8 @@ struct ring_buffer_per_cpu {
79720 unsigned long last_overrun;
79721 local_t entries_bytes;
79722 local_t entries;
79723 - local_t overrun;
79724 - local_t commit_overrun;
79725 + local_unchecked_t overrun;
79726 + local_unchecked_t commit_overrun;
79727 local_t dropped_events;
79728 local_t committing;
79729 local_t commits;
79730 @@ -864,8 +864,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79731 *
79732 * We add a counter to the write field to denote this.
79733 */
79734 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79735 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79736 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79737 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79738
79739 /*
79740 * Just make sure we have seen our old_write and synchronize
79741 @@ -893,8 +893,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79742 * cmpxchg to only update if an interrupt did not already
79743 * do it for us. If the cmpxchg fails, we don't care.
79744 */
79745 - (void)local_cmpxchg(&next_page->write, old_write, val);
79746 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79747 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79748 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79749
79750 /*
79751 * No need to worry about races with clearing out the commit.
79752 @@ -1253,12 +1253,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79753
79754 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79755 {
79756 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79757 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79758 }
79759
79760 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79761 {
79762 - return local_read(&bpage->write) & RB_WRITE_MASK;
79763 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79764 }
79765
79766 static int
79767 @@ -1353,7 +1353,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79768 * bytes consumed in ring buffer from here.
79769 * Increment overrun to account for the lost events.
79770 */
79771 - local_add(page_entries, &cpu_buffer->overrun);
79772 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79773 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79774 }
79775
79776 @@ -1909,7 +1909,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79777 * it is our responsibility to update
79778 * the counters.
79779 */
79780 - local_add(entries, &cpu_buffer->overrun);
79781 + local_add_unchecked(entries, &cpu_buffer->overrun);
79782 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79783
79784 /*
79785 @@ -2059,7 +2059,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79786 if (tail == BUF_PAGE_SIZE)
79787 tail_page->real_end = 0;
79788
79789 - local_sub(length, &tail_page->write);
79790 + local_sub_unchecked(length, &tail_page->write);
79791 return;
79792 }
79793
79794 @@ -2094,7 +2094,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79795 rb_event_set_padding(event);
79796
79797 /* Set the write back to the previous setting */
79798 - local_sub(length, &tail_page->write);
79799 + local_sub_unchecked(length, &tail_page->write);
79800 return;
79801 }
79802
79803 @@ -2106,7 +2106,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79804
79805 /* Set write to end of buffer */
79806 length = (tail + length) - BUF_PAGE_SIZE;
79807 - local_sub(length, &tail_page->write);
79808 + local_sub_unchecked(length, &tail_page->write);
79809 }
79810
79811 /*
79812 @@ -2132,7 +2132,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79813 * about it.
79814 */
79815 if (unlikely(next_page == commit_page)) {
79816 - local_inc(&cpu_buffer->commit_overrun);
79817 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79818 goto out_reset;
79819 }
79820
79821 @@ -2188,7 +2188,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79822 cpu_buffer->tail_page) &&
79823 (cpu_buffer->commit_page ==
79824 cpu_buffer->reader_page))) {
79825 - local_inc(&cpu_buffer->commit_overrun);
79826 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79827 goto out_reset;
79828 }
79829 }
79830 @@ -2236,7 +2236,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79831 length += RB_LEN_TIME_EXTEND;
79832
79833 tail_page = cpu_buffer->tail_page;
79834 - write = local_add_return(length, &tail_page->write);
79835 + write = local_add_return_unchecked(length, &tail_page->write);
79836
79837 /* set write to only the index of the write */
79838 write &= RB_WRITE_MASK;
79839 @@ -2253,7 +2253,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79840 kmemcheck_annotate_bitfield(event, bitfield);
79841 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79842
79843 - local_inc(&tail_page->entries);
79844 + local_inc_unchecked(&tail_page->entries);
79845
79846 /*
79847 * If this is the first commit on the page, then update
79848 @@ -2286,7 +2286,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79849
79850 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79851 unsigned long write_mask =
79852 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79853 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79854 unsigned long event_length = rb_event_length(event);
79855 /*
79856 * This is on the tail page. It is possible that
79857 @@ -2296,7 +2296,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79858 */
79859 old_index += write_mask;
79860 new_index += write_mask;
79861 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79862 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79863 if (index == old_index) {
79864 /* update counters */
79865 local_sub(event_length, &cpu_buffer->entries_bytes);
79866 @@ -2670,7 +2670,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79867
79868 /* Do the likely case first */
79869 if (likely(bpage->page == (void *)addr)) {
79870 - local_dec(&bpage->entries);
79871 + local_dec_unchecked(&bpage->entries);
79872 return;
79873 }
79874
79875 @@ -2682,7 +2682,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79876 start = bpage;
79877 do {
79878 if (bpage->page == (void *)addr) {
79879 - local_dec(&bpage->entries);
79880 + local_dec_unchecked(&bpage->entries);
79881 return;
79882 }
79883 rb_inc_page(cpu_buffer, &bpage);
79884 @@ -2964,7 +2964,7 @@ static inline unsigned long
79885 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79886 {
79887 return local_read(&cpu_buffer->entries) -
79888 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79889 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79890 }
79891
79892 /**
79893 @@ -3053,7 +3053,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79894 return 0;
79895
79896 cpu_buffer = buffer->buffers[cpu];
79897 - ret = local_read(&cpu_buffer->overrun);
79898 + ret = local_read_unchecked(&cpu_buffer->overrun);
79899
79900 return ret;
79901 }
79902 @@ -3076,7 +3076,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79903 return 0;
79904
79905 cpu_buffer = buffer->buffers[cpu];
79906 - ret = local_read(&cpu_buffer->commit_overrun);
79907 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79908
79909 return ret;
79910 }
79911 @@ -3161,7 +3161,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79912 /* if you care about this being correct, lock the buffer */
79913 for_each_buffer_cpu(buffer, cpu) {
79914 cpu_buffer = buffer->buffers[cpu];
79915 - overruns += local_read(&cpu_buffer->overrun);
79916 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79917 }
79918
79919 return overruns;
79920 @@ -3337,8 +3337,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79921 /*
79922 * Reset the reader page to size zero.
79923 */
79924 - local_set(&cpu_buffer->reader_page->write, 0);
79925 - local_set(&cpu_buffer->reader_page->entries, 0);
79926 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79927 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79928 local_set(&cpu_buffer->reader_page->page->commit, 0);
79929 cpu_buffer->reader_page->real_end = 0;
79930
79931 @@ -3372,7 +3372,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79932 * want to compare with the last_overrun.
79933 */
79934 smp_mb();
79935 - overwrite = local_read(&(cpu_buffer->overrun));
79936 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79937
79938 /*
79939 * Here's the tricky part.
79940 @@ -3942,8 +3942,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79941
79942 cpu_buffer->head_page
79943 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79944 - local_set(&cpu_buffer->head_page->write, 0);
79945 - local_set(&cpu_buffer->head_page->entries, 0);
79946 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79947 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79948 local_set(&cpu_buffer->head_page->page->commit, 0);
79949
79950 cpu_buffer->head_page->read = 0;
79951 @@ -3953,14 +3953,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79952
79953 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79954 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79955 - local_set(&cpu_buffer->reader_page->write, 0);
79956 - local_set(&cpu_buffer->reader_page->entries, 0);
79957 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79958 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79959 local_set(&cpu_buffer->reader_page->page->commit, 0);
79960 cpu_buffer->reader_page->read = 0;
79961
79962 local_set(&cpu_buffer->entries_bytes, 0);
79963 - local_set(&cpu_buffer->overrun, 0);
79964 - local_set(&cpu_buffer->commit_overrun, 0);
79965 + local_set_unchecked(&cpu_buffer->overrun, 0);
79966 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79967 local_set(&cpu_buffer->dropped_events, 0);
79968 local_set(&cpu_buffer->entries, 0);
79969 local_set(&cpu_buffer->committing, 0);
79970 @@ -4364,8 +4364,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79971 rb_init_page(bpage);
79972 bpage = reader->page;
79973 reader->page = *data_page;
79974 - local_set(&reader->write, 0);
79975 - local_set(&reader->entries, 0);
79976 + local_set_unchecked(&reader->write, 0);
79977 + local_set_unchecked(&reader->entries, 0);
79978 reader->read = 0;
79979 *data_page = bpage;
79980
79981 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79982 index 3f28192..a29e8b0 100644
79983 --- a/kernel/trace/trace.c
79984 +++ b/kernel/trace/trace.c
79985 @@ -2893,7 +2893,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
79986 return 0;
79987 }
79988
79989 -int set_tracer_flag(unsigned int mask, int enabled)
79990 +int set_tracer_flag(unsigned long mask, int enabled)
79991 {
79992 /* do nothing if flag is already set */
79993 if (!!(trace_flags & mask) == !!enabled)
79994 @@ -4637,10 +4637,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79995 };
79996 #endif
79997
79998 -static struct dentry *d_tracer;
79999 -
80000 struct dentry *tracing_init_dentry(void)
80001 {
80002 + static struct dentry *d_tracer;
80003 static int once;
80004
80005 if (d_tracer)
80006 @@ -4660,10 +4659,9 @@ struct dentry *tracing_init_dentry(void)
80007 return d_tracer;
80008 }
80009
80010 -static struct dentry *d_percpu;
80011 -
80012 static struct dentry *tracing_dentry_percpu(void)
80013 {
80014 + static struct dentry *d_percpu;
80015 static int once;
80016 struct dentry *d_tracer;
80017
80018 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
80019 index 2081971..09f861e 100644
80020 --- a/kernel/trace/trace.h
80021 +++ b/kernel/trace/trace.h
80022 @@ -948,7 +948,7 @@ extern const char *__stop___trace_bprintk_fmt[];
80023 void trace_printk_init_buffers(void);
80024 void trace_printk_start_comm(void);
80025 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
80026 -int set_tracer_flag(unsigned int mask, int enabled);
80027 +int set_tracer_flag(unsigned long mask, int enabled);
80028
80029 #undef FTRACE_ENTRY
80030 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
80031 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
80032 index 57e9b28..eebe41c 100644
80033 --- a/kernel/trace/trace_events.c
80034 +++ b/kernel/trace/trace_events.c
80035 @@ -1329,10 +1329,6 @@ static LIST_HEAD(ftrace_module_file_list);
80036 struct ftrace_module_file_ops {
80037 struct list_head list;
80038 struct module *mod;
80039 - struct file_operations id;
80040 - struct file_operations enable;
80041 - struct file_operations format;
80042 - struct file_operations filter;
80043 };
80044
80045 static struct ftrace_module_file_ops *
80046 @@ -1353,17 +1349,12 @@ trace_create_file_ops(struct module *mod)
80047
80048 file_ops->mod = mod;
80049
80050 - file_ops->id = ftrace_event_id_fops;
80051 - file_ops->id.owner = mod;
80052 -
80053 - file_ops->enable = ftrace_enable_fops;
80054 - file_ops->enable.owner = mod;
80055 -
80056 - file_ops->filter = ftrace_event_filter_fops;
80057 - file_ops->filter.owner = mod;
80058 -
80059 - file_ops->format = ftrace_event_format_fops;
80060 - file_ops->format.owner = mod;
80061 + pax_open_kernel();
80062 + mod->trace_id.owner = mod;
80063 + mod->trace_enable.owner = mod;
80064 + mod->trace_filter.owner = mod;
80065 + mod->trace_format.owner = mod;
80066 + pax_close_kernel();
80067
80068 list_add(&file_ops->list, &ftrace_module_file_list);
80069
80070 @@ -1387,8 +1378,8 @@ static void trace_module_add_events(struct module *mod)
80071
80072 for_each_event(call, start, end) {
80073 __trace_add_event_call(*call, mod,
80074 - &file_ops->id, &file_ops->enable,
80075 - &file_ops->filter, &file_ops->format);
80076 + &mod->trace_id, &mod->trace_enable,
80077 + &mod->trace_filter, &mod->trace_format);
80078 }
80079 }
80080
80081 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
80082 index fd3c8aa..5f324a6 100644
80083 --- a/kernel/trace/trace_mmiotrace.c
80084 +++ b/kernel/trace/trace_mmiotrace.c
80085 @@ -24,7 +24,7 @@ struct header_iter {
80086 static struct trace_array *mmio_trace_array;
80087 static bool overrun_detected;
80088 static unsigned long prev_overruns;
80089 -static atomic_t dropped_count;
80090 +static atomic_unchecked_t dropped_count;
80091
80092 static void mmio_reset_data(struct trace_array *tr)
80093 {
80094 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
80095
80096 static unsigned long count_overruns(struct trace_iterator *iter)
80097 {
80098 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
80099 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
80100 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
80101
80102 if (over > prev_overruns)
80103 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
80104 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
80105 sizeof(*entry), 0, pc);
80106 if (!event) {
80107 - atomic_inc(&dropped_count);
80108 + atomic_inc_unchecked(&dropped_count);
80109 return;
80110 }
80111 entry = ring_buffer_event_data(event);
80112 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
80113 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
80114 sizeof(*entry), 0, pc);
80115 if (!event) {
80116 - atomic_inc(&dropped_count);
80117 + atomic_inc_unchecked(&dropped_count);
80118 return;
80119 }
80120 entry = ring_buffer_event_data(event);
80121 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
80122 index 697e88d..1a79993 100644
80123 --- a/kernel/trace/trace_output.c
80124 +++ b/kernel/trace/trace_output.c
80125 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
80126
80127 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
80128 if (!IS_ERR(p)) {
80129 - p = mangle_path(s->buffer + s->len, p, "\n");
80130 + p = mangle_path(s->buffer + s->len, p, "\n\\");
80131 if (p) {
80132 s->len = p - s->buffer;
80133 return 1;
80134 @@ -851,14 +851,16 @@ int register_ftrace_event(struct trace_event *event)
80135 goto out;
80136 }
80137
80138 + pax_open_kernel();
80139 if (event->funcs->trace == NULL)
80140 - event->funcs->trace = trace_nop_print;
80141 + *(void **)&event->funcs->trace = trace_nop_print;
80142 if (event->funcs->raw == NULL)
80143 - event->funcs->raw = trace_nop_print;
80144 + *(void **)&event->funcs->raw = trace_nop_print;
80145 if (event->funcs->hex == NULL)
80146 - event->funcs->hex = trace_nop_print;
80147 + *(void **)&event->funcs->hex = trace_nop_print;
80148 if (event->funcs->binary == NULL)
80149 - event->funcs->binary = trace_nop_print;
80150 + *(void **)&event->funcs->binary = trace_nop_print;
80151 + pax_close_kernel();
80152
80153 key = event->type & (EVENT_HASHSIZE - 1);
80154
80155 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
80156 index b20428c..4845a10 100644
80157 --- a/kernel/trace/trace_stack.c
80158 +++ b/kernel/trace/trace_stack.c
80159 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
80160 return;
80161
80162 /* we do not handle interrupt stacks yet */
80163 - if (!object_is_on_stack(stack))
80164 + if (!object_starts_on_stack(stack))
80165 return;
80166
80167 local_irq_save(flags);
80168 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
80169 index e134d8f..a018cdd 100644
80170 --- a/kernel/user_namespace.c
80171 +++ b/kernel/user_namespace.c
80172 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80173 if (atomic_read(&current->mm->mm_users) > 1)
80174 return -EINVAL;
80175
80176 - if (current->fs->users != 1)
80177 + if (atomic_read(&current->fs->users) != 1)
80178 return -EINVAL;
80179
80180 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80181 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80182 index 4f69f9a..7c6f8f8 100644
80183 --- a/kernel/utsname_sysctl.c
80184 +++ b/kernel/utsname_sysctl.c
80185 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80186 static int proc_do_uts_string(ctl_table *table, int write,
80187 void __user *buffer, size_t *lenp, loff_t *ppos)
80188 {
80189 - struct ctl_table uts_table;
80190 + ctl_table_no_const uts_table;
80191 int r;
80192 memcpy(&uts_table, table, sizeof(uts_table));
80193 uts_table.data = get_uts(table, write);
80194 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80195 index 4a94467..80a6f9c 100644
80196 --- a/kernel/watchdog.c
80197 +++ b/kernel/watchdog.c
80198 @@ -526,7 +526,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80199 }
80200 #endif /* CONFIG_SYSCTL */
80201
80202 -static struct smp_hotplug_thread watchdog_threads = {
80203 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80204 .store = &softlockup_watchdog,
80205 .thread_should_run = watchdog_should_run,
80206 .thread_fn = watchdog,
80207 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80208 index 28be08c..47bab92 100644
80209 --- a/lib/Kconfig.debug
80210 +++ b/lib/Kconfig.debug
80211 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
80212
80213 config DEBUG_LOCK_ALLOC
80214 bool "Lock debugging: detect incorrect freeing of live locks"
80215 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80216 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80217 select DEBUG_SPINLOCK
80218 select DEBUG_MUTEXES
80219 select LOCKDEP
80220 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
80221
80222 config PROVE_LOCKING
80223 bool "Lock debugging: prove locking correctness"
80224 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80225 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80226 select LOCKDEP
80227 select DEBUG_SPINLOCK
80228 select DEBUG_MUTEXES
80229 @@ -614,7 +614,7 @@ config LOCKDEP
80230
80231 config LOCK_STAT
80232 bool "Lock usage statistics"
80233 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80234 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80235 select LOCKDEP
80236 select DEBUG_SPINLOCK
80237 select DEBUG_MUTEXES
80238 @@ -1282,6 +1282,7 @@ config LATENCYTOP
80239 depends on DEBUG_KERNEL
80240 depends on STACKTRACE_SUPPORT
80241 depends on PROC_FS
80242 + depends on !GRKERNSEC_HIDESYM
80243 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80244 select KALLSYMS
80245 select KALLSYMS_ALL
80246 @@ -1310,7 +1311,7 @@ config INTERVAL_TREE_TEST
80247
80248 config PROVIDE_OHCI1394_DMA_INIT
80249 bool "Remote debugging over FireWire early on boot"
80250 - depends on PCI && X86
80251 + depends on PCI && X86 && !GRKERNSEC
80252 help
80253 If you want to debug problems which hang or crash the kernel early
80254 on boot and the crashing machine has a FireWire port, you can use
80255 @@ -1339,7 +1340,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80256
80257 config FIREWIRE_OHCI_REMOTE_DMA
80258 bool "Remote debugging over FireWire with firewire-ohci"
80259 - depends on FIREWIRE_OHCI
80260 + depends on FIREWIRE_OHCI && !GRKERNSEC
80261 help
80262 This option lets you use the FireWire bus for remote debugging
80263 with help of the firewire-ohci driver. It enables unfiltered
80264 diff --git a/lib/Makefile b/lib/Makefile
80265 index 6e2cc56..9b13738 100644
80266 --- a/lib/Makefile
80267 +++ b/lib/Makefile
80268 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80269
80270 obj-$(CONFIG_BTREE) += btree.o
80271 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80272 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80273 +obj-y += list_debug.o
80274 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80275
80276 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80277 diff --git a/lib/bitmap.c b/lib/bitmap.c
80278 index 06f7e4f..f3cf2b0 100644
80279 --- a/lib/bitmap.c
80280 +++ b/lib/bitmap.c
80281 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80282 {
80283 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80284 u32 chunk;
80285 - const char __user __force *ubuf = (const char __user __force *)buf;
80286 + const char __user *ubuf = (const char __force_user *)buf;
80287
80288 bitmap_zero(maskp, nmaskbits);
80289
80290 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80291 {
80292 if (!access_ok(VERIFY_READ, ubuf, ulen))
80293 return -EFAULT;
80294 - return __bitmap_parse((const char __force *)ubuf,
80295 + return __bitmap_parse((const char __force_kernel *)ubuf,
80296 ulen, 1, maskp, nmaskbits);
80297
80298 }
80299 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80300 {
80301 unsigned a, b;
80302 int c, old_c, totaldigits;
80303 - const char __user __force *ubuf = (const char __user __force *)buf;
80304 + const char __user *ubuf = (const char __force_user *)buf;
80305 int exp_digit, in_range;
80306
80307 totaldigits = c = 0;
80308 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80309 {
80310 if (!access_ok(VERIFY_READ, ubuf, ulen))
80311 return -EFAULT;
80312 - return __bitmap_parselist((const char __force *)ubuf,
80313 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80314 ulen, 1, maskp, nmaskbits);
80315 }
80316 EXPORT_SYMBOL(bitmap_parselist_user);
80317 diff --git a/lib/bug.c b/lib/bug.c
80318 index 1686034..a9c00c8 100644
80319 --- a/lib/bug.c
80320 +++ b/lib/bug.c
80321 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80322 return BUG_TRAP_TYPE_NONE;
80323
80324 bug = find_bug(bugaddr);
80325 + if (!bug)
80326 + return BUG_TRAP_TYPE_NONE;
80327
80328 file = NULL;
80329 line = 0;
80330 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80331 index 37061ed..da83f48 100644
80332 --- a/lib/debugobjects.c
80333 +++ b/lib/debugobjects.c
80334 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80335 if (limit > 4)
80336 return;
80337
80338 - is_on_stack = object_is_on_stack(addr);
80339 + is_on_stack = object_starts_on_stack(addr);
80340 if (is_on_stack == onstack)
80341 return;
80342
80343 diff --git a/lib/devres.c b/lib/devres.c
80344 index 8235331..5881053 100644
80345 --- a/lib/devres.c
80346 +++ b/lib/devres.c
80347 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80348 void devm_iounmap(struct device *dev, void __iomem *addr)
80349 {
80350 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80351 - (void *)addr));
80352 + (void __force *)addr));
80353 iounmap(addr);
80354 }
80355 EXPORT_SYMBOL(devm_iounmap);
80356 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80357 {
80358 ioport_unmap(addr);
80359 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80360 - devm_ioport_map_match, (void *)addr));
80361 + devm_ioport_map_match, (void __force *)addr));
80362 }
80363 EXPORT_SYMBOL(devm_ioport_unmap);
80364 #endif /* CONFIG_HAS_IOPORT */
80365 diff --git a/lib/div64.c b/lib/div64.c
80366 index a163b6c..9618fa5 100644
80367 --- a/lib/div64.c
80368 +++ b/lib/div64.c
80369 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80370 EXPORT_SYMBOL(__div64_32);
80371
80372 #ifndef div_s64_rem
80373 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80374 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80375 {
80376 u64 quotient;
80377
80378 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80379 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80380 */
80381 #ifndef div64_u64
80382 -u64 div64_u64(u64 dividend, u64 divisor)
80383 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80384 {
80385 u32 high = divisor >> 32;
80386 u64 quot;
80387 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80388 index d87a17a..ac0d79a 100644
80389 --- a/lib/dma-debug.c
80390 +++ b/lib/dma-debug.c
80391 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80392
80393 void dma_debug_add_bus(struct bus_type *bus)
80394 {
80395 - struct notifier_block *nb;
80396 + notifier_block_no_const *nb;
80397
80398 if (global_disable)
80399 return;
80400 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
80401
80402 static void check_for_stack(struct device *dev, void *addr)
80403 {
80404 - if (object_is_on_stack(addr))
80405 + if (object_starts_on_stack(addr))
80406 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80407 "stack [addr=%p]\n", addr);
80408 }
80409 diff --git a/lib/inflate.c b/lib/inflate.c
80410 index 013a761..c28f3fc 100644
80411 --- a/lib/inflate.c
80412 +++ b/lib/inflate.c
80413 @@ -269,7 +269,7 @@ static void free(void *where)
80414 malloc_ptr = free_mem_ptr;
80415 }
80416 #else
80417 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80418 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80419 #define free(a) kfree(a)
80420 #endif
80421
80422 diff --git a/lib/ioremap.c b/lib/ioremap.c
80423 index 0c9216c..863bd89 100644
80424 --- a/lib/ioremap.c
80425 +++ b/lib/ioremap.c
80426 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80427 unsigned long next;
80428
80429 phys_addr -= addr;
80430 - pmd = pmd_alloc(&init_mm, pud, addr);
80431 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80432 if (!pmd)
80433 return -ENOMEM;
80434 do {
80435 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80436 unsigned long next;
80437
80438 phys_addr -= addr;
80439 - pud = pud_alloc(&init_mm, pgd, addr);
80440 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80441 if (!pud)
80442 return -ENOMEM;
80443 do {
80444 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80445 index bd2bea9..6b3c95e 100644
80446 --- a/lib/is_single_threaded.c
80447 +++ b/lib/is_single_threaded.c
80448 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80449 struct task_struct *p, *t;
80450 bool ret;
80451
80452 + if (!mm)
80453 + return true;
80454 +
80455 if (atomic_read(&task->signal->live) != 1)
80456 return false;
80457
80458 diff --git a/lib/kobject.c b/lib/kobject.c
80459 index a654866..d8bb115 100644
80460 --- a/lib/kobject.c
80461 +++ b/lib/kobject.c
80462 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
80463 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
80464 if (!kset)
80465 return NULL;
80466 - retval = kobject_set_name(&kset->kobj, name);
80467 + retval = kobject_set_name(&kset->kobj, "%s", name);
80468 if (retval) {
80469 kfree(kset);
80470 return NULL;
80471 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80472
80473
80474 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80475 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80476 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80477
80478 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80479 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80480 {
80481 enum kobj_ns_type type = ops->type;
80482 int error;
80483 diff --git a/lib/list_debug.c b/lib/list_debug.c
80484 index c24c2f7..06e070b 100644
80485 --- a/lib/list_debug.c
80486 +++ b/lib/list_debug.c
80487 @@ -11,7 +11,9 @@
80488 #include <linux/bug.h>
80489 #include <linux/kernel.h>
80490 #include <linux/rculist.h>
80491 +#include <linux/mm.h>
80492
80493 +#ifdef CONFIG_DEBUG_LIST
80494 /*
80495 * Insert a new entry between two known consecutive entries.
80496 *
80497 @@ -19,21 +21,32 @@
80498 * the prev/next entries already!
80499 */
80500
80501 -void __list_add(struct list_head *new,
80502 - struct list_head *prev,
80503 - struct list_head *next)
80504 +static bool __list_add_debug(struct list_head *new,
80505 + struct list_head *prev,
80506 + struct list_head *next)
80507 {
80508 - WARN(next->prev != prev,
80509 + if (WARN(next->prev != prev,
80510 "list_add corruption. next->prev should be "
80511 "prev (%p), but was %p. (next=%p).\n",
80512 - prev, next->prev, next);
80513 - WARN(prev->next != next,
80514 + prev, next->prev, next) ||
80515 + WARN(prev->next != next,
80516 "list_add corruption. prev->next should be "
80517 "next (%p), but was %p. (prev=%p).\n",
80518 - next, prev->next, prev);
80519 - WARN(new == prev || new == next,
80520 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80521 - new, prev, next);
80522 + next, prev->next, prev) ||
80523 + WARN(new == prev || new == next,
80524 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80525 + new, prev, next))
80526 + return false;
80527 + return true;
80528 +}
80529 +
80530 +void __list_add(struct list_head *new,
80531 + struct list_head *prev,
80532 + struct list_head *next)
80533 +{
80534 + if (!__list_add_debug(new, prev, next))
80535 + return;
80536 +
80537 next->prev = new;
80538 new->next = next;
80539 new->prev = prev;
80540 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80541 }
80542 EXPORT_SYMBOL(__list_add);
80543
80544 -void __list_del_entry(struct list_head *entry)
80545 +static bool __list_del_entry_debug(struct list_head *entry)
80546 {
80547 struct list_head *prev, *next;
80548
80549 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80550 WARN(next->prev != entry,
80551 "list_del corruption. next->prev should be %p, "
80552 "but was %p\n", entry, next->prev))
80553 + return false;
80554 + return true;
80555 +}
80556 +
80557 +void __list_del_entry(struct list_head *entry)
80558 +{
80559 + if (!__list_del_entry_debug(entry))
80560 return;
80561
80562 - __list_del(prev, next);
80563 + __list_del(entry->prev, entry->next);
80564 }
80565 EXPORT_SYMBOL(__list_del_entry);
80566
80567 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80568 void __list_add_rcu(struct list_head *new,
80569 struct list_head *prev, struct list_head *next)
80570 {
80571 - WARN(next->prev != prev,
80572 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80573 - prev, next->prev, next);
80574 - WARN(prev->next != next,
80575 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80576 - next, prev->next, prev);
80577 + if (!__list_add_debug(new, prev, next))
80578 + return;
80579 +
80580 new->next = next;
80581 new->prev = prev;
80582 rcu_assign_pointer(list_next_rcu(prev), new);
80583 next->prev = new;
80584 }
80585 EXPORT_SYMBOL(__list_add_rcu);
80586 +#endif
80587 +
80588 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80589 +{
80590 +#ifdef CONFIG_DEBUG_LIST
80591 + if (!__list_add_debug(new, prev, next))
80592 + return;
80593 +#endif
80594 +
80595 + pax_open_kernel();
80596 + next->prev = new;
80597 + new->next = next;
80598 + new->prev = prev;
80599 + prev->next = new;
80600 + pax_close_kernel();
80601 +}
80602 +EXPORT_SYMBOL(__pax_list_add);
80603 +
80604 +void pax_list_del(struct list_head *entry)
80605 +{
80606 +#ifdef CONFIG_DEBUG_LIST
80607 + if (!__list_del_entry_debug(entry))
80608 + return;
80609 +#endif
80610 +
80611 + pax_open_kernel();
80612 + __list_del(entry->prev, entry->next);
80613 + entry->next = LIST_POISON1;
80614 + entry->prev = LIST_POISON2;
80615 + pax_close_kernel();
80616 +}
80617 +EXPORT_SYMBOL(pax_list_del);
80618 +
80619 +void pax_list_del_init(struct list_head *entry)
80620 +{
80621 + pax_open_kernel();
80622 + __list_del(entry->prev, entry->next);
80623 + INIT_LIST_HEAD(entry);
80624 + pax_close_kernel();
80625 +}
80626 +EXPORT_SYMBOL(pax_list_del_init);
80627 +
80628 +void __pax_list_add_rcu(struct list_head *new,
80629 + struct list_head *prev, struct list_head *next)
80630 +{
80631 +#ifdef CONFIG_DEBUG_LIST
80632 + if (!__list_add_debug(new, prev, next))
80633 + return;
80634 +#endif
80635 +
80636 + pax_open_kernel();
80637 + new->next = next;
80638 + new->prev = prev;
80639 + rcu_assign_pointer(list_next_rcu(prev), new);
80640 + next->prev = new;
80641 + pax_close_kernel();
80642 +}
80643 +EXPORT_SYMBOL(__pax_list_add_rcu);
80644 +
80645 +void pax_list_del_rcu(struct list_head *entry)
80646 +{
80647 +#ifdef CONFIG_DEBUG_LIST
80648 + if (!__list_del_entry_debug(entry))
80649 + return;
80650 +#endif
80651 +
80652 + pax_open_kernel();
80653 + __list_del(entry->prev, entry->next);
80654 + entry->next = LIST_POISON1;
80655 + entry->prev = LIST_POISON2;
80656 + pax_close_kernel();
80657 +}
80658 +EXPORT_SYMBOL(pax_list_del_rcu);
80659 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80660 index e796429..6e38f9f 100644
80661 --- a/lib/radix-tree.c
80662 +++ b/lib/radix-tree.c
80663 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80664 int nr;
80665 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80666 };
80667 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80668 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80669
80670 static inline void *ptr_to_indirect(void *ptr)
80671 {
80672 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80673 index bb2b201..46abaf9 100644
80674 --- a/lib/strncpy_from_user.c
80675 +++ b/lib/strncpy_from_user.c
80676 @@ -21,7 +21,7 @@
80677 */
80678 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80679 {
80680 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80681 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80682 long res = 0;
80683
80684 /*
80685 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80686 index a28df52..3d55877 100644
80687 --- a/lib/strnlen_user.c
80688 +++ b/lib/strnlen_user.c
80689 @@ -26,7 +26,7 @@
80690 */
80691 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80692 {
80693 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80694 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80695 long align, res = 0;
80696 unsigned long c;
80697
80698 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80699 index d23762e..e21eab2 100644
80700 --- a/lib/swiotlb.c
80701 +++ b/lib/swiotlb.c
80702 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80703
80704 void
80705 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80706 - dma_addr_t dev_addr)
80707 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80708 {
80709 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80710
80711 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80712 index 0d62fd7..b7bc911 100644
80713 --- a/lib/vsprintf.c
80714 +++ b/lib/vsprintf.c
80715 @@ -16,6 +16,9 @@
80716 * - scnprintf and vscnprintf
80717 */
80718
80719 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80720 +#define __INCLUDED_BY_HIDESYM 1
80721 +#endif
80722 #include <stdarg.h>
80723 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80724 #include <linux/types.h>
80725 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80726 return number(buf, end, *(const netdev_features_t *)addr, spec);
80727 }
80728
80729 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80730 +int kptr_restrict __read_mostly = 2;
80731 +#else
80732 int kptr_restrict __read_mostly;
80733 +#endif
80734
80735 /*
80736 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80737 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80738 * - 'S' For symbolic direct pointers with offset
80739 * - 's' For symbolic direct pointers without offset
80740 * - 'B' For backtraced symbolic direct pointers with offset
80741 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80742 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80743 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80744 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80745 * - 'M' For a 6-byte MAC address, it prints the address in the
80746 @@ -1044,12 +1053,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80747
80748 if (!ptr && *fmt != 'K') {
80749 /*
80750 - * Print (null) with the same width as a pointer so it makes
80751 + * Print (nil) with the same width as a pointer so it makes
80752 * tabular output look nice.
80753 */
80754 if (spec.field_width == -1)
80755 spec.field_width = default_width;
80756 - return string(buf, end, "(null)", spec);
80757 + return string(buf, end, "(nil)", spec);
80758 }
80759
80760 switch (*fmt) {
80761 @@ -1059,6 +1068,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80762 /* Fallthrough */
80763 case 'S':
80764 case 's':
80765 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80766 + break;
80767 +#else
80768 + return symbol_string(buf, end, ptr, spec, *fmt);
80769 +#endif
80770 + case 'A':
80771 case 'B':
80772 return symbol_string(buf, end, ptr, spec, *fmt);
80773 case 'R':
80774 @@ -1099,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80775 va_end(va);
80776 return buf;
80777 }
80778 + case 'P':
80779 + break;
80780 case 'K':
80781 /*
80782 * %pK cannot be used in IRQ context because its test
80783 @@ -1128,6 +1145,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80784 return number(buf, end,
80785 (unsigned long long) *((phys_addr_t *)ptr), spec);
80786 }
80787 +
80788 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80789 + /* 'P' = approved pointers to copy to userland,
80790 + as in the /proc/kallsyms case, as we make it display nothing
80791 + for non-root users, and the real contents for root users
80792 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80793 + above
80794 + */
80795 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80796 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80797 + dump_stack();
80798 + ptr = NULL;
80799 + }
80800 +#endif
80801 +
80802 spec.flags |= SMALL;
80803 if (spec.field_width == -1) {
80804 spec.field_width = default_width;
80805 @@ -1849,11 +1881,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80806 typeof(type) value; \
80807 if (sizeof(type) == 8) { \
80808 args = PTR_ALIGN(args, sizeof(u32)); \
80809 - *(u32 *)&value = *(u32 *)args; \
80810 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80811 + *(u32 *)&value = *(const u32 *)args; \
80812 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80813 } else { \
80814 args = PTR_ALIGN(args, sizeof(type)); \
80815 - value = *(typeof(type) *)args; \
80816 + value = *(const typeof(type) *)args; \
80817 } \
80818 args += sizeof(type); \
80819 value; \
80820 @@ -1916,7 +1948,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80821 case FORMAT_TYPE_STR: {
80822 const char *str_arg = args;
80823 args += strlen(str_arg) + 1;
80824 - str = string(str, end, (char *)str_arg, spec);
80825 + str = string(str, end, str_arg, spec);
80826 break;
80827 }
80828
80829 diff --git a/localversion-grsec b/localversion-grsec
80830 new file mode 100644
80831 index 0000000..7cd6065
80832 --- /dev/null
80833 +++ b/localversion-grsec
80834 @@ -0,0 +1 @@
80835 +-grsec
80836 diff --git a/mm/Kconfig b/mm/Kconfig
80837 index 3bea74f..e821c99 100644
80838 --- a/mm/Kconfig
80839 +++ b/mm/Kconfig
80840 @@ -311,10 +311,10 @@ config KSM
80841 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80842
80843 config DEFAULT_MMAP_MIN_ADDR
80844 - int "Low address space to protect from user allocation"
80845 + int "Low address space to protect from user allocation"
80846 depends on MMU
80847 - default 4096
80848 - help
80849 + default 65536
80850 + help
80851 This is the portion of low virtual memory which should be protected
80852 from userspace allocation. Keeping a user from writing to low pages
80853 can help reduce the impact of kernel NULL pointer bugs.
80854 @@ -345,7 +345,7 @@ config MEMORY_FAILURE
80855
80856 config HWPOISON_INJECT
80857 tristate "HWPoison pages injector"
80858 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80859 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80860 select PROC_PAGE_MONITOR
80861
80862 config NOMMU_INITIAL_TRIM_EXCESS
80863 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
80864 index 41733c5..d80d7a9 100644
80865 --- a/mm/backing-dev.c
80866 +++ b/mm/backing-dev.c
80867 @@ -716,7 +716,6 @@ EXPORT_SYMBOL(bdi_destroy);
80868 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
80869 unsigned int cap)
80870 {
80871 - char tmp[32];
80872 int err;
80873
80874 bdi->name = name;
80875 @@ -725,8 +724,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
80876 if (err)
80877 return err;
80878
80879 - sprintf(tmp, "%.28s%s", name, "-%d");
80880 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
80881 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return(&bdi_seq));
80882 if (err) {
80883 bdi_destroy(bdi);
80884 return err;
80885 diff --git a/mm/filemap.c b/mm/filemap.c
80886 index e1979fd..dda5120 100644
80887 --- a/mm/filemap.c
80888 +++ b/mm/filemap.c
80889 @@ -1748,7 +1748,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80890 struct address_space *mapping = file->f_mapping;
80891
80892 if (!mapping->a_ops->readpage)
80893 - return -ENOEXEC;
80894 + return -ENODEV;
80895 file_accessed(file);
80896 vma->vm_ops = &generic_file_vm_ops;
80897 return 0;
80898 @@ -2088,6 +2088,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80899 *pos = i_size_read(inode);
80900
80901 if (limit != RLIM_INFINITY) {
80902 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80903 if (*pos >= limit) {
80904 send_sig(SIGXFSZ, current, 0);
80905 return -EFBIG;
80906 diff --git a/mm/fremap.c b/mm/fremap.c
80907 index 87da359..3f41cb1 100644
80908 --- a/mm/fremap.c
80909 +++ b/mm/fremap.c
80910 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80911 retry:
80912 vma = find_vma(mm, start);
80913
80914 +#ifdef CONFIG_PAX_SEGMEXEC
80915 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80916 + goto out;
80917 +#endif
80918 +
80919 /*
80920 * Make sure the vma is shared, that it supports prefaulting,
80921 * and that the remapped range is valid and fully within
80922 diff --git a/mm/highmem.c b/mm/highmem.c
80923 index b32b70c..e512eb0 100644
80924 --- a/mm/highmem.c
80925 +++ b/mm/highmem.c
80926 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80927 * So no dangers, even with speculative execution.
80928 */
80929 page = pte_page(pkmap_page_table[i]);
80930 + pax_open_kernel();
80931 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80932 -
80933 + pax_close_kernel();
80934 set_page_address(page, NULL);
80935 need_flush = 1;
80936 }
80937 @@ -198,9 +199,11 @@ start:
80938 }
80939 }
80940 vaddr = PKMAP_ADDR(last_pkmap_nr);
80941 +
80942 + pax_open_kernel();
80943 set_pte_at(&init_mm, vaddr,
80944 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80945 -
80946 + pax_close_kernel();
80947 pkmap_count[last_pkmap_nr] = 1;
80948 set_page_address(page, (void *)vaddr);
80949
80950 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80951 index ce4cb19..93899ef 100644
80952 --- a/mm/hugetlb.c
80953 +++ b/mm/hugetlb.c
80954 @@ -2005,15 +2005,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80955 struct hstate *h = &default_hstate;
80956 unsigned long tmp;
80957 int ret;
80958 + ctl_table_no_const hugetlb_table;
80959
80960 tmp = h->max_huge_pages;
80961
80962 if (write && h->order >= MAX_ORDER)
80963 return -EINVAL;
80964
80965 - table->data = &tmp;
80966 - table->maxlen = sizeof(unsigned long);
80967 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80968 + hugetlb_table = *table;
80969 + hugetlb_table.data = &tmp;
80970 + hugetlb_table.maxlen = sizeof(unsigned long);
80971 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80972 if (ret)
80973 goto out;
80974
80975 @@ -2070,15 +2072,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80976 struct hstate *h = &default_hstate;
80977 unsigned long tmp;
80978 int ret;
80979 + ctl_table_no_const hugetlb_table;
80980
80981 tmp = h->nr_overcommit_huge_pages;
80982
80983 if (write && h->order >= MAX_ORDER)
80984 return -EINVAL;
80985
80986 - table->data = &tmp;
80987 - table->maxlen = sizeof(unsigned long);
80988 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80989 + hugetlb_table = *table;
80990 + hugetlb_table.data = &tmp;
80991 + hugetlb_table.maxlen = sizeof(unsigned long);
80992 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80993 if (ret)
80994 goto out;
80995
80996 @@ -2512,6 +2516,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80997 return 1;
80998 }
80999
81000 +#ifdef CONFIG_PAX_SEGMEXEC
81001 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
81002 +{
81003 + struct mm_struct *mm = vma->vm_mm;
81004 + struct vm_area_struct *vma_m;
81005 + unsigned long address_m;
81006 + pte_t *ptep_m;
81007 +
81008 + vma_m = pax_find_mirror_vma(vma);
81009 + if (!vma_m)
81010 + return;
81011 +
81012 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81013 + address_m = address + SEGMEXEC_TASK_SIZE;
81014 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
81015 + get_page(page_m);
81016 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
81017 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
81018 +}
81019 +#endif
81020 +
81021 /*
81022 * Hugetlb_cow() should be called with page lock of the original hugepage held.
81023 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
81024 @@ -2630,6 +2655,11 @@ retry_avoidcopy:
81025 make_huge_pte(vma, new_page, 1));
81026 page_remove_rmap(old_page);
81027 hugepage_add_new_anon_rmap(new_page, vma, address);
81028 +
81029 +#ifdef CONFIG_PAX_SEGMEXEC
81030 + pax_mirror_huge_pte(vma, address, new_page);
81031 +#endif
81032 +
81033 /* Make the old page be freed below */
81034 new_page = old_page;
81035 }
81036 @@ -2788,6 +2818,10 @@ retry:
81037 && (vma->vm_flags & VM_SHARED)));
81038 set_huge_pte_at(mm, address, ptep, new_pte);
81039
81040 +#ifdef CONFIG_PAX_SEGMEXEC
81041 + pax_mirror_huge_pte(vma, address, page);
81042 +#endif
81043 +
81044 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
81045 /* Optimization, do the COW without a second fault */
81046 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
81047 @@ -2817,6 +2851,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81048 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
81049 struct hstate *h = hstate_vma(vma);
81050
81051 +#ifdef CONFIG_PAX_SEGMEXEC
81052 + struct vm_area_struct *vma_m;
81053 +#endif
81054 +
81055 address &= huge_page_mask(h);
81056
81057 ptep = huge_pte_offset(mm, address);
81058 @@ -2830,6 +2868,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81059 VM_FAULT_SET_HINDEX(hstate_index(h));
81060 }
81061
81062 +#ifdef CONFIG_PAX_SEGMEXEC
81063 + vma_m = pax_find_mirror_vma(vma);
81064 + if (vma_m) {
81065 + unsigned long address_m;
81066 +
81067 + if (vma->vm_start > vma_m->vm_start) {
81068 + address_m = address;
81069 + address -= SEGMEXEC_TASK_SIZE;
81070 + vma = vma_m;
81071 + h = hstate_vma(vma);
81072 + } else
81073 + address_m = address + SEGMEXEC_TASK_SIZE;
81074 +
81075 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
81076 + return VM_FAULT_OOM;
81077 + address_m &= HPAGE_MASK;
81078 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
81079 + }
81080 +#endif
81081 +
81082 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
81083 if (!ptep)
81084 return VM_FAULT_OOM;
81085 diff --git a/mm/internal.h b/mm/internal.h
81086 index 8562de0..7fdfe92 100644
81087 --- a/mm/internal.h
81088 +++ b/mm/internal.h
81089 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
81090 * in mm/page_alloc.c
81091 */
81092 extern void __free_pages_bootmem(struct page *page, unsigned int order);
81093 +extern void free_compound_page(struct page *page);
81094 extern void prep_compound_page(struct page *page, unsigned long order);
81095 #ifdef CONFIG_MEMORY_FAILURE
81096 extern bool is_free_buddy_page(struct page *page);
81097 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
81098 index c8d7f31..2dbeffd 100644
81099 --- a/mm/kmemleak.c
81100 +++ b/mm/kmemleak.c
81101 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
81102
81103 for (i = 0; i < object->trace_len; i++) {
81104 void *ptr = (void *)object->trace[i];
81105 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
81106 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
81107 }
81108 }
81109
81110 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
81111 return -ENOMEM;
81112 }
81113
81114 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
81115 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
81116 &kmemleak_fops);
81117 if (!dentry)
81118 pr_warning("Failed to create the debugfs kmemleak file\n");
81119 diff --git a/mm/maccess.c b/mm/maccess.c
81120 index d53adf9..03a24bf 100644
81121 --- a/mm/maccess.c
81122 +++ b/mm/maccess.c
81123 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
81124 set_fs(KERNEL_DS);
81125 pagefault_disable();
81126 ret = __copy_from_user_inatomic(dst,
81127 - (__force const void __user *)src, size);
81128 + (const void __force_user *)src, size);
81129 pagefault_enable();
81130 set_fs(old_fs);
81131
81132 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
81133
81134 set_fs(KERNEL_DS);
81135 pagefault_disable();
81136 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81137 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81138 pagefault_enable();
81139 set_fs(old_fs);
81140
81141 diff --git a/mm/madvise.c b/mm/madvise.c
81142 index c58c94b..86ec14e 100644
81143 --- a/mm/madvise.c
81144 +++ b/mm/madvise.c
81145 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81146 pgoff_t pgoff;
81147 unsigned long new_flags = vma->vm_flags;
81148
81149 +#ifdef CONFIG_PAX_SEGMEXEC
81150 + struct vm_area_struct *vma_m;
81151 +#endif
81152 +
81153 switch (behavior) {
81154 case MADV_NORMAL:
81155 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81156 @@ -126,6 +130,13 @@ success:
81157 /*
81158 * vm_flags is protected by the mmap_sem held in write mode.
81159 */
81160 +
81161 +#ifdef CONFIG_PAX_SEGMEXEC
81162 + vma_m = pax_find_mirror_vma(vma);
81163 + if (vma_m)
81164 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81165 +#endif
81166 +
81167 vma->vm_flags = new_flags;
81168
81169 out:
81170 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81171 struct vm_area_struct ** prev,
81172 unsigned long start, unsigned long end)
81173 {
81174 +
81175 +#ifdef CONFIG_PAX_SEGMEXEC
81176 + struct vm_area_struct *vma_m;
81177 +#endif
81178 +
81179 *prev = vma;
81180 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81181 return -EINVAL;
81182 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81183 zap_page_range(vma, start, end - start, &details);
81184 } else
81185 zap_page_range(vma, start, end - start, NULL);
81186 +
81187 +#ifdef CONFIG_PAX_SEGMEXEC
81188 + vma_m = pax_find_mirror_vma(vma);
81189 + if (vma_m) {
81190 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81191 + struct zap_details details = {
81192 + .nonlinear_vma = vma_m,
81193 + .last_index = ULONG_MAX,
81194 + };
81195 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81196 + } else
81197 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81198 + }
81199 +#endif
81200 +
81201 return 0;
81202 }
81203
81204 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81205 if (end < start)
81206 goto out;
81207
81208 +#ifdef CONFIG_PAX_SEGMEXEC
81209 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81210 + if (end > SEGMEXEC_TASK_SIZE)
81211 + goto out;
81212 + } else
81213 +#endif
81214 +
81215 + if (end > TASK_SIZE)
81216 + goto out;
81217 +
81218 error = 0;
81219 if (end == start)
81220 goto out;
81221 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81222 index df0694c..bc95539 100644
81223 --- a/mm/memory-failure.c
81224 +++ b/mm/memory-failure.c
81225 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81226
81227 int sysctl_memory_failure_recovery __read_mostly = 1;
81228
81229 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
81230 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
81231
81232 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81233
81234 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81235 pfn, t->comm, t->pid);
81236 si.si_signo = SIGBUS;
81237 si.si_errno = 0;
81238 - si.si_addr = (void *)addr;
81239 + si.si_addr = (void __user *)addr;
81240 #ifdef __ARCH_SI_TRAPNO
81241 si.si_trapno = trapno;
81242 #endif
81243 @@ -760,7 +760,7 @@ static struct page_state {
81244 unsigned long res;
81245 char *msg;
81246 int (*action)(struct page *p, unsigned long pfn);
81247 -} error_states[] = {
81248 +} __do_const error_states[] = {
81249 { reserved, reserved, "reserved kernel", me_kernel },
81250 /*
81251 * free pages are specially detected outside this table:
81252 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81253 nr_pages = 1 << compound_order(hpage);
81254 else /* normal page or thp */
81255 nr_pages = 1;
81256 - atomic_long_add(nr_pages, &num_poisoned_pages);
81257 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
81258
81259 /*
81260 * We need/can do nothing about count=0 pages.
81261 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81262 if (!PageHWPoison(hpage)
81263 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81264 || (p != hpage && TestSetPageHWPoison(hpage))) {
81265 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81266 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81267 return 0;
81268 }
81269 set_page_hwpoison_huge_page(hpage);
81270 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81271 }
81272 if (hwpoison_filter(p)) {
81273 if (TestClearPageHWPoison(p))
81274 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81275 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81276 unlock_page(hpage);
81277 put_page(hpage);
81278 return 0;
81279 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
81280 return 0;
81281 }
81282 if (TestClearPageHWPoison(p))
81283 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81284 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81285 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81286 return 0;
81287 }
81288 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
81289 */
81290 if (TestClearPageHWPoison(page)) {
81291 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81292 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81293 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81294 freeit = 1;
81295 if (PageHuge(page))
81296 clear_page_hwpoison_huge_page(page);
81297 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81298 } else {
81299 set_page_hwpoison_huge_page(hpage);
81300 dequeue_hwpoisoned_huge_page(hpage);
81301 - atomic_long_add(1 << compound_trans_order(hpage),
81302 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81303 &num_poisoned_pages);
81304 }
81305 /* keep elevated page count for bad page */
81306 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
81307 if (PageHuge(page)) {
81308 set_page_hwpoison_huge_page(hpage);
81309 dequeue_hwpoisoned_huge_page(hpage);
81310 - atomic_long_add(1 << compound_trans_order(hpage),
81311 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81312 &num_poisoned_pages);
81313 } else {
81314 SetPageHWPoison(page);
81315 - atomic_long_inc(&num_poisoned_pages);
81316 + atomic_long_inc_unchecked(&num_poisoned_pages);
81317 }
81318 }
81319 /* keep elevated page count for bad page */
81320 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
81321 put_page(page);
81322 pr_info("soft_offline: %#lx: invalidated\n", pfn);
81323 SetPageHWPoison(page);
81324 - atomic_long_inc(&num_poisoned_pages);
81325 + atomic_long_inc_unchecked(&num_poisoned_pages);
81326 return 0;
81327 }
81328
81329 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
81330 ret = -EIO;
81331 } else {
81332 SetPageHWPoison(page);
81333 - atomic_long_inc(&num_poisoned_pages);
81334 + atomic_long_inc_unchecked(&num_poisoned_pages);
81335 }
81336 } else {
81337 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
81338 diff --git a/mm/memory.c b/mm/memory.c
81339 index ba94dec..08ffe0d 100644
81340 --- a/mm/memory.c
81341 +++ b/mm/memory.c
81342 @@ -438,6 +438,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81343 free_pte_range(tlb, pmd, addr);
81344 } while (pmd++, addr = next, addr != end);
81345
81346 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81347 start &= PUD_MASK;
81348 if (start < floor)
81349 return;
81350 @@ -452,6 +453,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81351 pmd = pmd_offset(pud, start);
81352 pud_clear(pud);
81353 pmd_free_tlb(tlb, pmd, start);
81354 +#endif
81355 +
81356 }
81357
81358 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81359 @@ -471,6 +474,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81360 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81361 } while (pud++, addr = next, addr != end);
81362
81363 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81364 start &= PGDIR_MASK;
81365 if (start < floor)
81366 return;
81367 @@ -485,6 +489,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81368 pud = pud_offset(pgd, start);
81369 pgd_clear(pgd);
81370 pud_free_tlb(tlb, pud, start);
81371 +#endif
81372 +
81373 }
81374
81375 /*
81376 @@ -1644,12 +1650,6 @@ no_page_table:
81377 return page;
81378 }
81379
81380 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81381 -{
81382 - return stack_guard_page_start(vma, addr) ||
81383 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81384 -}
81385 -
81386 /**
81387 * __get_user_pages() - pin user pages in memory
81388 * @tsk: task_struct of target task
81389 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81390
81391 i = 0;
81392
81393 - do {
81394 + while (nr_pages) {
81395 struct vm_area_struct *vma;
81396
81397 - vma = find_extend_vma(mm, start);
81398 + vma = find_vma(mm, start);
81399 if (!vma && in_gate_area(mm, start)) {
81400 unsigned long pg = start & PAGE_MASK;
81401 pgd_t *pgd;
81402 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81403 goto next_page;
81404 }
81405
81406 - if (!vma ||
81407 + if (!vma || start < vma->vm_start ||
81408 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81409 !(vm_flags & vma->vm_flags))
81410 return i ? : -EFAULT;
81411 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81412 int ret;
81413 unsigned int fault_flags = 0;
81414
81415 - /* For mlock, just skip the stack guard page. */
81416 - if (foll_flags & FOLL_MLOCK) {
81417 - if (stack_guard_page(vma, start))
81418 - goto next_page;
81419 - }
81420 if (foll_flags & FOLL_WRITE)
81421 fault_flags |= FAULT_FLAG_WRITE;
81422 if (nonblocking)
81423 @@ -1901,7 +1896,7 @@ next_page:
81424 start += page_increm * PAGE_SIZE;
81425 nr_pages -= page_increm;
81426 } while (nr_pages && start < vma->vm_end);
81427 - } while (nr_pages);
81428 + }
81429 return i;
81430 }
81431 EXPORT_SYMBOL(__get_user_pages);
81432 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81433 page_add_file_rmap(page);
81434 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81435
81436 +#ifdef CONFIG_PAX_SEGMEXEC
81437 + pax_mirror_file_pte(vma, addr, page, ptl);
81438 +#endif
81439 +
81440 retval = 0;
81441 pte_unmap_unlock(pte, ptl);
81442 return retval;
81443 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81444 if (!page_count(page))
81445 return -EINVAL;
81446 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81447 +
81448 +#ifdef CONFIG_PAX_SEGMEXEC
81449 + struct vm_area_struct *vma_m;
81450 +#endif
81451 +
81452 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81453 BUG_ON(vma->vm_flags & VM_PFNMAP);
81454 vma->vm_flags |= VM_MIXEDMAP;
81455 +
81456 +#ifdef CONFIG_PAX_SEGMEXEC
81457 + vma_m = pax_find_mirror_vma(vma);
81458 + if (vma_m)
81459 + vma_m->vm_flags |= VM_MIXEDMAP;
81460 +#endif
81461 +
81462 }
81463 return insert_page(vma, addr, page, vma->vm_page_prot);
81464 }
81465 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81466 unsigned long pfn)
81467 {
81468 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81469 + BUG_ON(vma->vm_mirror);
81470
81471 if (addr < vma->vm_start || addr >= vma->vm_end)
81472 return -EFAULT;
81473 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81474
81475 BUG_ON(pud_huge(*pud));
81476
81477 - pmd = pmd_alloc(mm, pud, addr);
81478 + pmd = (mm == &init_mm) ?
81479 + pmd_alloc_kernel(mm, pud, addr) :
81480 + pmd_alloc(mm, pud, addr);
81481 if (!pmd)
81482 return -ENOMEM;
81483 do {
81484 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81485 unsigned long next;
81486 int err;
81487
81488 - pud = pud_alloc(mm, pgd, addr);
81489 + pud = (mm == &init_mm) ?
81490 + pud_alloc_kernel(mm, pgd, addr) :
81491 + pud_alloc(mm, pgd, addr);
81492 if (!pud)
81493 return -ENOMEM;
81494 do {
81495 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81496 copy_user_highpage(dst, src, va, vma);
81497 }
81498
81499 +#ifdef CONFIG_PAX_SEGMEXEC
81500 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81501 +{
81502 + struct mm_struct *mm = vma->vm_mm;
81503 + spinlock_t *ptl;
81504 + pte_t *pte, entry;
81505 +
81506 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81507 + entry = *pte;
81508 + if (!pte_present(entry)) {
81509 + if (!pte_none(entry)) {
81510 + BUG_ON(pte_file(entry));
81511 + free_swap_and_cache(pte_to_swp_entry(entry));
81512 + pte_clear_not_present_full(mm, address, pte, 0);
81513 + }
81514 + } else {
81515 + struct page *page;
81516 +
81517 + flush_cache_page(vma, address, pte_pfn(entry));
81518 + entry = ptep_clear_flush(vma, address, pte);
81519 + BUG_ON(pte_dirty(entry));
81520 + page = vm_normal_page(vma, address, entry);
81521 + if (page) {
81522 + update_hiwater_rss(mm);
81523 + if (PageAnon(page))
81524 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81525 + else
81526 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81527 + page_remove_rmap(page);
81528 + page_cache_release(page);
81529 + }
81530 + }
81531 + pte_unmap_unlock(pte, ptl);
81532 +}
81533 +
81534 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81535 + *
81536 + * the ptl of the lower mapped page is held on entry and is not released on exit
81537 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81538 + */
81539 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81540 +{
81541 + struct mm_struct *mm = vma->vm_mm;
81542 + unsigned long address_m;
81543 + spinlock_t *ptl_m;
81544 + struct vm_area_struct *vma_m;
81545 + pmd_t *pmd_m;
81546 + pte_t *pte_m, entry_m;
81547 +
81548 + BUG_ON(!page_m || !PageAnon(page_m));
81549 +
81550 + vma_m = pax_find_mirror_vma(vma);
81551 + if (!vma_m)
81552 + return;
81553 +
81554 + BUG_ON(!PageLocked(page_m));
81555 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81556 + address_m = address + SEGMEXEC_TASK_SIZE;
81557 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81558 + pte_m = pte_offset_map(pmd_m, address_m);
81559 + ptl_m = pte_lockptr(mm, pmd_m);
81560 + if (ptl != ptl_m) {
81561 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81562 + if (!pte_none(*pte_m))
81563 + goto out;
81564 + }
81565 +
81566 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81567 + page_cache_get(page_m);
81568 + page_add_anon_rmap(page_m, vma_m, address_m);
81569 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81570 + set_pte_at(mm, address_m, pte_m, entry_m);
81571 + update_mmu_cache(vma_m, address_m, pte_m);
81572 +out:
81573 + if (ptl != ptl_m)
81574 + spin_unlock(ptl_m);
81575 + pte_unmap(pte_m);
81576 + unlock_page(page_m);
81577 +}
81578 +
81579 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81580 +{
81581 + struct mm_struct *mm = vma->vm_mm;
81582 + unsigned long address_m;
81583 + spinlock_t *ptl_m;
81584 + struct vm_area_struct *vma_m;
81585 + pmd_t *pmd_m;
81586 + pte_t *pte_m, entry_m;
81587 +
81588 + BUG_ON(!page_m || PageAnon(page_m));
81589 +
81590 + vma_m = pax_find_mirror_vma(vma);
81591 + if (!vma_m)
81592 + return;
81593 +
81594 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81595 + address_m = address + SEGMEXEC_TASK_SIZE;
81596 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81597 + pte_m = pte_offset_map(pmd_m, address_m);
81598 + ptl_m = pte_lockptr(mm, pmd_m);
81599 + if (ptl != ptl_m) {
81600 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81601 + if (!pte_none(*pte_m))
81602 + goto out;
81603 + }
81604 +
81605 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81606 + page_cache_get(page_m);
81607 + page_add_file_rmap(page_m);
81608 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81609 + set_pte_at(mm, address_m, pte_m, entry_m);
81610 + update_mmu_cache(vma_m, address_m, pte_m);
81611 +out:
81612 + if (ptl != ptl_m)
81613 + spin_unlock(ptl_m);
81614 + pte_unmap(pte_m);
81615 +}
81616 +
81617 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81618 +{
81619 + struct mm_struct *mm = vma->vm_mm;
81620 + unsigned long address_m;
81621 + spinlock_t *ptl_m;
81622 + struct vm_area_struct *vma_m;
81623 + pmd_t *pmd_m;
81624 + pte_t *pte_m, entry_m;
81625 +
81626 + vma_m = pax_find_mirror_vma(vma);
81627 + if (!vma_m)
81628 + return;
81629 +
81630 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81631 + address_m = address + SEGMEXEC_TASK_SIZE;
81632 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81633 + pte_m = pte_offset_map(pmd_m, address_m);
81634 + ptl_m = pte_lockptr(mm, pmd_m);
81635 + if (ptl != ptl_m) {
81636 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81637 + if (!pte_none(*pte_m))
81638 + goto out;
81639 + }
81640 +
81641 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81642 + set_pte_at(mm, address_m, pte_m, entry_m);
81643 +out:
81644 + if (ptl != ptl_m)
81645 + spin_unlock(ptl_m);
81646 + pte_unmap(pte_m);
81647 +}
81648 +
81649 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81650 +{
81651 + struct page *page_m;
81652 + pte_t entry;
81653 +
81654 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81655 + goto out;
81656 +
81657 + entry = *pte;
81658 + page_m = vm_normal_page(vma, address, entry);
81659 + if (!page_m)
81660 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81661 + else if (PageAnon(page_m)) {
81662 + if (pax_find_mirror_vma(vma)) {
81663 + pte_unmap_unlock(pte, ptl);
81664 + lock_page(page_m);
81665 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81666 + if (pte_same(entry, *pte))
81667 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81668 + else
81669 + unlock_page(page_m);
81670 + }
81671 + } else
81672 + pax_mirror_file_pte(vma, address, page_m, ptl);
81673 +
81674 +out:
81675 + pte_unmap_unlock(pte, ptl);
81676 +}
81677 +#endif
81678 +
81679 /*
81680 * This routine handles present pages, when users try to write
81681 * to a shared page. It is done by copying the page to a new address
81682 @@ -2808,6 +3004,12 @@ gotten:
81683 */
81684 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81685 if (likely(pte_same(*page_table, orig_pte))) {
81686 +
81687 +#ifdef CONFIG_PAX_SEGMEXEC
81688 + if (pax_find_mirror_vma(vma))
81689 + BUG_ON(!trylock_page(new_page));
81690 +#endif
81691 +
81692 if (old_page) {
81693 if (!PageAnon(old_page)) {
81694 dec_mm_counter_fast(mm, MM_FILEPAGES);
81695 @@ -2859,6 +3061,10 @@ gotten:
81696 page_remove_rmap(old_page);
81697 }
81698
81699 +#ifdef CONFIG_PAX_SEGMEXEC
81700 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81701 +#endif
81702 +
81703 /* Free the old page.. */
81704 new_page = old_page;
81705 ret |= VM_FAULT_WRITE;
81706 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81707 swap_free(entry);
81708 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81709 try_to_free_swap(page);
81710 +
81711 +#ifdef CONFIG_PAX_SEGMEXEC
81712 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81713 +#endif
81714 +
81715 unlock_page(page);
81716 if (page != swapcache) {
81717 /*
81718 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81719
81720 /* No need to invalidate - it was non-present before */
81721 update_mmu_cache(vma, address, page_table);
81722 +
81723 +#ifdef CONFIG_PAX_SEGMEXEC
81724 + pax_mirror_anon_pte(vma, address, page, ptl);
81725 +#endif
81726 +
81727 unlock:
81728 pte_unmap_unlock(page_table, ptl);
81729 out:
81730 @@ -3176,40 +3392,6 @@ out_release:
81731 }
81732
81733 /*
81734 - * This is like a special single-page "expand_{down|up}wards()",
81735 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81736 - * doesn't hit another vma.
81737 - */
81738 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81739 -{
81740 - address &= PAGE_MASK;
81741 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81742 - struct vm_area_struct *prev = vma->vm_prev;
81743 -
81744 - /*
81745 - * Is there a mapping abutting this one below?
81746 - *
81747 - * That's only ok if it's the same stack mapping
81748 - * that has gotten split..
81749 - */
81750 - if (prev && prev->vm_end == address)
81751 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81752 -
81753 - expand_downwards(vma, address - PAGE_SIZE);
81754 - }
81755 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81756 - struct vm_area_struct *next = vma->vm_next;
81757 -
81758 - /* As VM_GROWSDOWN but s/below/above/ */
81759 - if (next && next->vm_start == address + PAGE_SIZE)
81760 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81761 -
81762 - expand_upwards(vma, address + PAGE_SIZE);
81763 - }
81764 - return 0;
81765 -}
81766 -
81767 -/*
81768 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81769 * but allow concurrent faults), and pte mapped but not yet locked.
81770 * We return with mmap_sem still held, but pte unmapped and unlocked.
81771 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81772 unsigned long address, pte_t *page_table, pmd_t *pmd,
81773 unsigned int flags)
81774 {
81775 - struct page *page;
81776 + struct page *page = NULL;
81777 spinlock_t *ptl;
81778 pte_t entry;
81779
81780 - pte_unmap(page_table);
81781 -
81782 - /* Check if we need to add a guard page to the stack */
81783 - if (check_stack_guard_page(vma, address) < 0)
81784 - return VM_FAULT_SIGBUS;
81785 -
81786 - /* Use the zero-page for reads */
81787 if (!(flags & FAULT_FLAG_WRITE)) {
81788 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81789 vma->vm_page_prot));
81790 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81791 + ptl = pte_lockptr(mm, pmd);
81792 + spin_lock(ptl);
81793 if (!pte_none(*page_table))
81794 goto unlock;
81795 goto setpte;
81796 }
81797
81798 /* Allocate our own private page. */
81799 + pte_unmap(page_table);
81800 +
81801 if (unlikely(anon_vma_prepare(vma)))
81802 goto oom;
81803 page = alloc_zeroed_user_highpage_movable(vma, address);
81804 @@ -3257,6 +3435,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81805 if (!pte_none(*page_table))
81806 goto release;
81807
81808 +#ifdef CONFIG_PAX_SEGMEXEC
81809 + if (pax_find_mirror_vma(vma))
81810 + BUG_ON(!trylock_page(page));
81811 +#endif
81812 +
81813 inc_mm_counter_fast(mm, MM_ANONPAGES);
81814 page_add_new_anon_rmap(page, vma, address);
81815 setpte:
81816 @@ -3264,6 +3447,12 @@ setpte:
81817
81818 /* No need to invalidate - it was non-present before */
81819 update_mmu_cache(vma, address, page_table);
81820 +
81821 +#ifdef CONFIG_PAX_SEGMEXEC
81822 + if (page)
81823 + pax_mirror_anon_pte(vma, address, page, ptl);
81824 +#endif
81825 +
81826 unlock:
81827 pte_unmap_unlock(page_table, ptl);
81828 return 0;
81829 @@ -3407,6 +3596,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81830 */
81831 /* Only go through if we didn't race with anybody else... */
81832 if (likely(pte_same(*page_table, orig_pte))) {
81833 +
81834 +#ifdef CONFIG_PAX_SEGMEXEC
81835 + if (anon && pax_find_mirror_vma(vma))
81836 + BUG_ON(!trylock_page(page));
81837 +#endif
81838 +
81839 flush_icache_page(vma, page);
81840 entry = mk_pte(page, vma->vm_page_prot);
81841 if (flags & FAULT_FLAG_WRITE)
81842 @@ -3426,6 +3621,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81843
81844 /* no need to invalidate: a not-present page won't be cached */
81845 update_mmu_cache(vma, address, page_table);
81846 +
81847 +#ifdef CONFIG_PAX_SEGMEXEC
81848 + if (anon)
81849 + pax_mirror_anon_pte(vma, address, page, ptl);
81850 + else
81851 + pax_mirror_file_pte(vma, address, page, ptl);
81852 +#endif
81853 +
81854 } else {
81855 if (cow_page)
81856 mem_cgroup_uncharge_page(cow_page);
81857 @@ -3747,6 +3950,12 @@ int handle_pte_fault(struct mm_struct *mm,
81858 if (flags & FAULT_FLAG_WRITE)
81859 flush_tlb_fix_spurious_fault(vma, address);
81860 }
81861 +
81862 +#ifdef CONFIG_PAX_SEGMEXEC
81863 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81864 + return 0;
81865 +#endif
81866 +
81867 unlock:
81868 pte_unmap_unlock(pte, ptl);
81869 return 0;
81870 @@ -3763,6 +3972,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81871 pmd_t *pmd;
81872 pte_t *pte;
81873
81874 +#ifdef CONFIG_PAX_SEGMEXEC
81875 + struct vm_area_struct *vma_m;
81876 +#endif
81877 +
81878 __set_current_state(TASK_RUNNING);
81879
81880 count_vm_event(PGFAULT);
81881 @@ -3774,6 +3987,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81882 if (unlikely(is_vm_hugetlb_page(vma)))
81883 return hugetlb_fault(mm, vma, address, flags);
81884
81885 +#ifdef CONFIG_PAX_SEGMEXEC
81886 + vma_m = pax_find_mirror_vma(vma);
81887 + if (vma_m) {
81888 + unsigned long address_m;
81889 + pgd_t *pgd_m;
81890 + pud_t *pud_m;
81891 + pmd_t *pmd_m;
81892 +
81893 + if (vma->vm_start > vma_m->vm_start) {
81894 + address_m = address;
81895 + address -= SEGMEXEC_TASK_SIZE;
81896 + vma = vma_m;
81897 + } else
81898 + address_m = address + SEGMEXEC_TASK_SIZE;
81899 +
81900 + pgd_m = pgd_offset(mm, address_m);
81901 + pud_m = pud_alloc(mm, pgd_m, address_m);
81902 + if (!pud_m)
81903 + return VM_FAULT_OOM;
81904 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81905 + if (!pmd_m)
81906 + return VM_FAULT_OOM;
81907 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81908 + return VM_FAULT_OOM;
81909 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81910 + }
81911 +#endif
81912 +
81913 retry:
81914 pgd = pgd_offset(mm, address);
81915 pud = pud_alloc(mm, pgd, address);
81916 @@ -3872,6 +4113,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81917 spin_unlock(&mm->page_table_lock);
81918 return 0;
81919 }
81920 +
81921 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81922 +{
81923 + pud_t *new = pud_alloc_one(mm, address);
81924 + if (!new)
81925 + return -ENOMEM;
81926 +
81927 + smp_wmb(); /* See comment in __pte_alloc */
81928 +
81929 + spin_lock(&mm->page_table_lock);
81930 + if (pgd_present(*pgd)) /* Another has populated it */
81931 + pud_free(mm, new);
81932 + else
81933 + pgd_populate_kernel(mm, pgd, new);
81934 + spin_unlock(&mm->page_table_lock);
81935 + return 0;
81936 +}
81937 #endif /* __PAGETABLE_PUD_FOLDED */
81938
81939 #ifndef __PAGETABLE_PMD_FOLDED
81940 @@ -3902,6 +4160,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81941 spin_unlock(&mm->page_table_lock);
81942 return 0;
81943 }
81944 +
81945 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81946 +{
81947 + pmd_t *new = pmd_alloc_one(mm, address);
81948 + if (!new)
81949 + return -ENOMEM;
81950 +
81951 + smp_wmb(); /* See comment in __pte_alloc */
81952 +
81953 + spin_lock(&mm->page_table_lock);
81954 +#ifndef __ARCH_HAS_4LEVEL_HACK
81955 + if (pud_present(*pud)) /* Another has populated it */
81956 + pmd_free(mm, new);
81957 + else
81958 + pud_populate_kernel(mm, pud, new);
81959 +#else
81960 + if (pgd_present(*pud)) /* Another has populated it */
81961 + pmd_free(mm, new);
81962 + else
81963 + pgd_populate_kernel(mm, pud, new);
81964 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81965 + spin_unlock(&mm->page_table_lock);
81966 + return 0;
81967 +}
81968 #endif /* __PAGETABLE_PMD_FOLDED */
81969
81970 #if !defined(__HAVE_ARCH_GATE_AREA)
81971 @@ -3915,7 +4197,7 @@ static int __init gate_vma_init(void)
81972 gate_vma.vm_start = FIXADDR_USER_START;
81973 gate_vma.vm_end = FIXADDR_USER_END;
81974 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81975 - gate_vma.vm_page_prot = __P101;
81976 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81977
81978 return 0;
81979 }
81980 @@ -4049,8 +4331,8 @@ out:
81981 return ret;
81982 }
81983
81984 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81985 - void *buf, int len, int write)
81986 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81987 + void *buf, size_t len, int write)
81988 {
81989 resource_size_t phys_addr;
81990 unsigned long prot = 0;
81991 @@ -4075,8 +4357,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81992 * Access another process' address space as given in mm. If non-NULL, use the
81993 * given task for page fault accounting.
81994 */
81995 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81996 - unsigned long addr, void *buf, int len, int write)
81997 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81998 + unsigned long addr, void *buf, size_t len, int write)
81999 {
82000 struct vm_area_struct *vma;
82001 void *old_buf = buf;
82002 @@ -4084,7 +4366,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82003 down_read(&mm->mmap_sem);
82004 /* ignore errors, just check how much was successfully transferred */
82005 while (len) {
82006 - int bytes, ret, offset;
82007 + ssize_t bytes, ret, offset;
82008 void *maddr;
82009 struct page *page = NULL;
82010
82011 @@ -4143,8 +4425,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82012 *
82013 * The caller must hold a reference on @mm.
82014 */
82015 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82016 - void *buf, int len, int write)
82017 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
82018 + void *buf, size_t len, int write)
82019 {
82020 return __access_remote_vm(NULL, mm, addr, buf, len, write);
82021 }
82022 @@ -4154,11 +4436,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82023 * Source/target buffer must be kernel space,
82024 * Do not walk the page table directly, use get_user_pages
82025 */
82026 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
82027 - void *buf, int len, int write)
82028 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
82029 + void *buf, size_t len, int write)
82030 {
82031 struct mm_struct *mm;
82032 - int ret;
82033 + ssize_t ret;
82034
82035 mm = get_task_mm(tsk);
82036 if (!mm)
82037 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
82038 index 7431001..0f8344e 100644
82039 --- a/mm/mempolicy.c
82040 +++ b/mm/mempolicy.c
82041 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82042 unsigned long vmstart;
82043 unsigned long vmend;
82044
82045 +#ifdef CONFIG_PAX_SEGMEXEC
82046 + struct vm_area_struct *vma_m;
82047 +#endif
82048 +
82049 vma = find_vma(mm, start);
82050 if (!vma || vma->vm_start > start)
82051 return -EFAULT;
82052 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82053 if (err)
82054 goto out;
82055 }
82056 +
82057 err = vma_replace_policy(vma, new_pol);
82058 if (err)
82059 goto out;
82060 +
82061 +#ifdef CONFIG_PAX_SEGMEXEC
82062 + vma_m = pax_find_mirror_vma(vma);
82063 + if (vma_m) {
82064 + err = vma_replace_policy(vma_m, new_pol);
82065 + if (err)
82066 + goto out;
82067 + }
82068 +#endif
82069 +
82070 }
82071
82072 out:
82073 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
82074
82075 if (end < start)
82076 return -EINVAL;
82077 +
82078 +#ifdef CONFIG_PAX_SEGMEXEC
82079 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82080 + if (end > SEGMEXEC_TASK_SIZE)
82081 + return -EINVAL;
82082 + } else
82083 +#endif
82084 +
82085 + if (end > TASK_SIZE)
82086 + return -EINVAL;
82087 +
82088 if (end == start)
82089 return 0;
82090
82091 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82092 */
82093 tcred = __task_cred(task);
82094 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82095 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82096 - !capable(CAP_SYS_NICE)) {
82097 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82098 rcu_read_unlock();
82099 err = -EPERM;
82100 goto out_put;
82101 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82102 goto out;
82103 }
82104
82105 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82106 + if (mm != current->mm &&
82107 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
82108 + mmput(mm);
82109 + err = -EPERM;
82110 + goto out;
82111 + }
82112 +#endif
82113 +
82114 err = do_migrate_pages(mm, old, new,
82115 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
82116
82117 diff --git a/mm/migrate.c b/mm/migrate.c
82118 index c04d9af..0b41805 100644
82119 --- a/mm/migrate.c
82120 +++ b/mm/migrate.c
82121 @@ -1395,8 +1395,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
82122 */
82123 tcred = __task_cred(task);
82124 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82125 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82126 - !capable(CAP_SYS_NICE)) {
82127 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82128 rcu_read_unlock();
82129 err = -EPERM;
82130 goto out;
82131 diff --git a/mm/mlock.c b/mm/mlock.c
82132 index 79b7cf7..9944291 100644
82133 --- a/mm/mlock.c
82134 +++ b/mm/mlock.c
82135 @@ -13,6 +13,7 @@
82136 #include <linux/pagemap.h>
82137 #include <linux/mempolicy.h>
82138 #include <linux/syscalls.h>
82139 +#include <linux/security.h>
82140 #include <linux/sched.h>
82141 #include <linux/export.h>
82142 #include <linux/rmap.h>
82143 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82144 {
82145 unsigned long nstart, end, tmp;
82146 struct vm_area_struct * vma, * prev;
82147 - int error;
82148 + int error = 0;
82149
82150 VM_BUG_ON(start & ~PAGE_MASK);
82151 VM_BUG_ON(len != PAGE_ALIGN(len));
82152 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82153 return -EINVAL;
82154 if (end == start)
82155 return 0;
82156 + if (end > TASK_SIZE)
82157 + return -EINVAL;
82158 +
82159 vma = find_vma(current->mm, start);
82160 if (!vma || vma->vm_start > start)
82161 return -ENOMEM;
82162 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82163 for (nstart = start ; ; ) {
82164 vm_flags_t newflags;
82165
82166 +#ifdef CONFIG_PAX_SEGMEXEC
82167 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82168 + break;
82169 +#endif
82170 +
82171 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82172
82173 newflags = vma->vm_flags & ~VM_LOCKED;
82174 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82175 lock_limit >>= PAGE_SHIFT;
82176
82177 /* check against resource limits */
82178 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82179 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82180 error = do_mlock(start, len, 1);
82181 up_write(&current->mm->mmap_sem);
82182 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
82183 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82184 vm_flags_t newflags;
82185
82186 +#ifdef CONFIG_PAX_SEGMEXEC
82187 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82188 + break;
82189 +#endif
82190 +
82191 newflags = vma->vm_flags & ~VM_LOCKED;
82192 if (flags & MCL_CURRENT)
82193 newflags |= VM_LOCKED;
82194 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82195 lock_limit >>= PAGE_SHIFT;
82196
82197 ret = -ENOMEM;
82198 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82199 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82200 capable(CAP_IPC_LOCK))
82201 ret = do_mlockall(flags);
82202 diff --git a/mm/mmap.c b/mm/mmap.c
82203 index 0dceed8..bfcaf45 100644
82204 --- a/mm/mmap.c
82205 +++ b/mm/mmap.c
82206 @@ -33,6 +33,7 @@
82207 #include <linux/uprobes.h>
82208 #include <linux/rbtree_augmented.h>
82209 #include <linux/sched/sysctl.h>
82210 +#include <linux/random.h>
82211
82212 #include <asm/uaccess.h>
82213 #include <asm/cacheflush.h>
82214 @@ -49,6 +50,16 @@
82215 #define arch_rebalance_pgtables(addr, len) (addr)
82216 #endif
82217
82218 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82219 +{
82220 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82221 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82222 + up_read(&mm->mmap_sem);
82223 + BUG();
82224 + }
82225 +#endif
82226 +}
82227 +
82228 static void unmap_region(struct mm_struct *mm,
82229 struct vm_area_struct *vma, struct vm_area_struct *prev,
82230 unsigned long start, unsigned long end);
82231 @@ -68,22 +79,32 @@ static void unmap_region(struct mm_struct *mm,
82232 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82233 *
82234 */
82235 -pgprot_t protection_map[16] = {
82236 +pgprot_t protection_map[16] __read_only = {
82237 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82238 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82239 };
82240
82241 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82242 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82243 {
82244 - return __pgprot(pgprot_val(protection_map[vm_flags &
82245 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82246 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82247 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82248 +
82249 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82250 + if (!(__supported_pte_mask & _PAGE_NX) &&
82251 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82252 + (vm_flags & (VM_READ | VM_WRITE)))
82253 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82254 +#endif
82255 +
82256 + return prot;
82257 }
82258 EXPORT_SYMBOL(vm_get_page_prot);
82259
82260 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
82261 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82262 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82263 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82264 /*
82265 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82266 * other variables. It can be updated by several CPUs frequently.
82267 @@ -239,6 +260,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82268 struct vm_area_struct *next = vma->vm_next;
82269
82270 might_sleep();
82271 + BUG_ON(vma->vm_mirror);
82272 if (vma->vm_ops && vma->vm_ops->close)
82273 vma->vm_ops->close(vma);
82274 if (vma->vm_file)
82275 @@ -283,6 +305,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82276 * not page aligned -Ram Gupta
82277 */
82278 rlim = rlimit(RLIMIT_DATA);
82279 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82280 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82281 (mm->end_data - mm->start_data) > rlim)
82282 goto out;
82283 @@ -897,6 +920,12 @@ static int
82284 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82285 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82286 {
82287 +
82288 +#ifdef CONFIG_PAX_SEGMEXEC
82289 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82290 + return 0;
82291 +#endif
82292 +
82293 if (is_mergeable_vma(vma, file, vm_flags) &&
82294 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82295 if (vma->vm_pgoff == vm_pgoff)
82296 @@ -916,6 +945,12 @@ static int
82297 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82298 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82299 {
82300 +
82301 +#ifdef CONFIG_PAX_SEGMEXEC
82302 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82303 + return 0;
82304 +#endif
82305 +
82306 if (is_mergeable_vma(vma, file, vm_flags) &&
82307 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82308 pgoff_t vm_pglen;
82309 @@ -958,13 +993,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82310 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82311 struct vm_area_struct *prev, unsigned long addr,
82312 unsigned long end, unsigned long vm_flags,
82313 - struct anon_vma *anon_vma, struct file *file,
82314 + struct anon_vma *anon_vma, struct file *file,
82315 pgoff_t pgoff, struct mempolicy *policy)
82316 {
82317 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82318 struct vm_area_struct *area, *next;
82319 int err;
82320
82321 +#ifdef CONFIG_PAX_SEGMEXEC
82322 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82323 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82324 +
82325 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82326 +#endif
82327 +
82328 /*
82329 * We later require that vma->vm_flags == vm_flags,
82330 * so this tests vma->vm_flags & VM_SPECIAL, too.
82331 @@ -980,6 +1022,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82332 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82333 next = next->vm_next;
82334
82335 +#ifdef CONFIG_PAX_SEGMEXEC
82336 + if (prev)
82337 + prev_m = pax_find_mirror_vma(prev);
82338 + if (area)
82339 + area_m = pax_find_mirror_vma(area);
82340 + if (next)
82341 + next_m = pax_find_mirror_vma(next);
82342 +#endif
82343 +
82344 /*
82345 * Can it merge with the predecessor?
82346 */
82347 @@ -999,9 +1050,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82348 /* cases 1, 6 */
82349 err = vma_adjust(prev, prev->vm_start,
82350 next->vm_end, prev->vm_pgoff, NULL);
82351 - } else /* cases 2, 5, 7 */
82352 +
82353 +#ifdef CONFIG_PAX_SEGMEXEC
82354 + if (!err && prev_m)
82355 + err = vma_adjust(prev_m, prev_m->vm_start,
82356 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82357 +#endif
82358 +
82359 + } else { /* cases 2, 5, 7 */
82360 err = vma_adjust(prev, prev->vm_start,
82361 end, prev->vm_pgoff, NULL);
82362 +
82363 +#ifdef CONFIG_PAX_SEGMEXEC
82364 + if (!err && prev_m)
82365 + err = vma_adjust(prev_m, prev_m->vm_start,
82366 + end_m, prev_m->vm_pgoff, NULL);
82367 +#endif
82368 +
82369 + }
82370 if (err)
82371 return NULL;
82372 khugepaged_enter_vma_merge(prev);
82373 @@ -1015,12 +1081,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82374 mpol_equal(policy, vma_policy(next)) &&
82375 can_vma_merge_before(next, vm_flags,
82376 anon_vma, file, pgoff+pglen)) {
82377 - if (prev && addr < prev->vm_end) /* case 4 */
82378 + if (prev && addr < prev->vm_end) { /* case 4 */
82379 err = vma_adjust(prev, prev->vm_start,
82380 addr, prev->vm_pgoff, NULL);
82381 - else /* cases 3, 8 */
82382 +
82383 +#ifdef CONFIG_PAX_SEGMEXEC
82384 + if (!err && prev_m)
82385 + err = vma_adjust(prev_m, prev_m->vm_start,
82386 + addr_m, prev_m->vm_pgoff, NULL);
82387 +#endif
82388 +
82389 + } else { /* cases 3, 8 */
82390 err = vma_adjust(area, addr, next->vm_end,
82391 next->vm_pgoff - pglen, NULL);
82392 +
82393 +#ifdef CONFIG_PAX_SEGMEXEC
82394 + if (!err && area_m)
82395 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82396 + next_m->vm_pgoff - pglen, NULL);
82397 +#endif
82398 +
82399 + }
82400 if (err)
82401 return NULL;
82402 khugepaged_enter_vma_merge(area);
82403 @@ -1129,8 +1210,10 @@ none:
82404 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82405 struct file *file, long pages)
82406 {
82407 - const unsigned long stack_flags
82408 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82409 +
82410 +#ifdef CONFIG_PAX_RANDMMAP
82411 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82412 +#endif
82413
82414 mm->total_vm += pages;
82415
82416 @@ -1138,7 +1221,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82417 mm->shared_vm += pages;
82418 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82419 mm->exec_vm += pages;
82420 - } else if (flags & stack_flags)
82421 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82422 mm->stack_vm += pages;
82423 }
82424 #endif /* CONFIG_PROC_FS */
82425 @@ -1177,7 +1260,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82426 * (the exception is when the underlying filesystem is noexec
82427 * mounted, in which case we dont add PROT_EXEC.)
82428 */
82429 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82430 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82431 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82432 prot |= PROT_EXEC;
82433
82434 @@ -1203,7 +1286,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82435 /* Obtain the address to map to. we verify (or select) it and ensure
82436 * that it represents a valid section of the address space.
82437 */
82438 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82439 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82440 if (addr & ~PAGE_MASK)
82441 return addr;
82442
82443 @@ -1214,6 +1297,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82444 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82445 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82446
82447 +#ifdef CONFIG_PAX_MPROTECT
82448 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82449 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82450 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82451 + gr_log_rwxmmap(file);
82452 +
82453 +#ifdef CONFIG_PAX_EMUPLT
82454 + vm_flags &= ~VM_EXEC;
82455 +#else
82456 + return -EPERM;
82457 +#endif
82458 +
82459 + }
82460 +
82461 + if (!(vm_flags & VM_EXEC))
82462 + vm_flags &= ~VM_MAYEXEC;
82463 +#else
82464 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82465 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82466 +#endif
82467 + else
82468 + vm_flags &= ~VM_MAYWRITE;
82469 + }
82470 +#endif
82471 +
82472 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82473 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82474 + vm_flags &= ~VM_PAGEEXEC;
82475 +#endif
82476 +
82477 if (flags & MAP_LOCKED)
82478 if (!can_do_mlock())
82479 return -EPERM;
82480 @@ -1225,6 +1338,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82481 locked += mm->locked_vm;
82482 lock_limit = rlimit(RLIMIT_MEMLOCK);
82483 lock_limit >>= PAGE_SHIFT;
82484 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82485 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82486 return -EAGAIN;
82487 }
82488 @@ -1305,6 +1419,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82489 vm_flags |= VM_NORESERVE;
82490 }
82491
82492 + if (!gr_acl_handle_mmap(file, prot))
82493 + return -EACCES;
82494 +
82495 addr = mmap_region(file, addr, len, vm_flags, pgoff);
82496 if (!IS_ERR_VALUE(addr) &&
82497 ((vm_flags & VM_LOCKED) ||
82498 @@ -1396,7 +1513,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82499 vm_flags_t vm_flags = vma->vm_flags;
82500
82501 /* If it was private or non-writable, the write bit is already clear */
82502 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82503 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82504 return 0;
82505
82506 /* The backer wishes to know when pages are first written to? */
82507 @@ -1444,16 +1561,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82508 unsigned long charged = 0;
82509 struct inode *inode = file ? file_inode(file) : NULL;
82510
82511 +#ifdef CONFIG_PAX_SEGMEXEC
82512 + struct vm_area_struct *vma_m = NULL;
82513 +#endif
82514 +
82515 + /*
82516 + * mm->mmap_sem is required to protect against another thread
82517 + * changing the mappings in case we sleep.
82518 + */
82519 + verify_mm_writelocked(mm);
82520 +
82521 /* Clear old maps */
82522 error = -ENOMEM;
82523 -munmap_back:
82524 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82525 if (do_munmap(mm, addr, len))
82526 return -ENOMEM;
82527 - goto munmap_back;
82528 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82529 }
82530
82531 /* Check against address space limit. */
82532 +
82533 +#ifdef CONFIG_PAX_RANDMMAP
82534 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82535 +#endif
82536 +
82537 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82538 return -ENOMEM;
82539
82540 @@ -1485,6 +1616,16 @@ munmap_back:
82541 goto unacct_error;
82542 }
82543
82544 +#ifdef CONFIG_PAX_SEGMEXEC
82545 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82546 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82547 + if (!vma_m) {
82548 + error = -ENOMEM;
82549 + goto free_vma;
82550 + }
82551 + }
82552 +#endif
82553 +
82554 vma->vm_mm = mm;
82555 vma->vm_start = addr;
82556 vma->vm_end = addr + len;
82557 @@ -1509,6 +1650,13 @@ munmap_back:
82558 if (error)
82559 goto unmap_and_free_vma;
82560
82561 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82562 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82563 + vma->vm_flags |= VM_PAGEEXEC;
82564 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82565 + }
82566 +#endif
82567 +
82568 /* Can addr have changed??
82569 *
82570 * Answer: Yes, several device drivers can do it in their
82571 @@ -1547,6 +1695,11 @@ munmap_back:
82572 vma_link(mm, vma, prev, rb_link, rb_parent);
82573 file = vma->vm_file;
82574
82575 +#ifdef CONFIG_PAX_SEGMEXEC
82576 + if (vma_m)
82577 + BUG_ON(pax_mirror_vma(vma_m, vma));
82578 +#endif
82579 +
82580 /* Once vma denies write, undo our temporary denial count */
82581 if (correct_wcount)
82582 atomic_inc(&inode->i_writecount);
82583 @@ -1554,6 +1707,7 @@ out:
82584 perf_event_mmap(vma);
82585
82586 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82587 + track_exec_limit(mm, addr, addr + len, vm_flags);
82588 if (vm_flags & VM_LOCKED) {
82589 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
82590 vma == get_gate_vma(current->mm)))
82591 @@ -1577,6 +1731,12 @@ unmap_and_free_vma:
82592 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82593 charged = 0;
82594 free_vma:
82595 +
82596 +#ifdef CONFIG_PAX_SEGMEXEC
82597 + if (vma_m)
82598 + kmem_cache_free(vm_area_cachep, vma_m);
82599 +#endif
82600 +
82601 kmem_cache_free(vm_area_cachep, vma);
82602 unacct_error:
82603 if (charged)
82604 @@ -1584,7 +1744,63 @@ unacct_error:
82605 return error;
82606 }
82607
82608 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82609 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82610 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82611 +{
82612 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82613 + return (random32() & 0xFF) << PAGE_SHIFT;
82614 +
82615 + return 0;
82616 +}
82617 +#endif
82618 +
82619 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82620 +{
82621 + if (!vma) {
82622 +#ifdef CONFIG_STACK_GROWSUP
82623 + if (addr > sysctl_heap_stack_gap)
82624 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82625 + else
82626 + vma = find_vma(current->mm, 0);
82627 + if (vma && (vma->vm_flags & VM_GROWSUP))
82628 + return false;
82629 +#endif
82630 + return true;
82631 + }
82632 +
82633 + if (addr + len > vma->vm_start)
82634 + return false;
82635 +
82636 + if (vma->vm_flags & VM_GROWSDOWN)
82637 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82638 +#ifdef CONFIG_STACK_GROWSUP
82639 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82640 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82641 +#endif
82642 + else if (offset)
82643 + return offset <= vma->vm_start - addr - len;
82644 +
82645 + return true;
82646 +}
82647 +
82648 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82649 +{
82650 + if (vma->vm_start < len)
82651 + return -ENOMEM;
82652 +
82653 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82654 + if (offset <= vma->vm_start - len)
82655 + return vma->vm_start - len - offset;
82656 + else
82657 + return -ENOMEM;
82658 + }
82659 +
82660 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82661 + return vma->vm_start - len - sysctl_heap_stack_gap;
82662 + return -ENOMEM;
82663 +}
82664 +
82665 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
82666 {
82667 /*
82668 * We implement the search by looking for an rbtree node that
82669 @@ -1632,11 +1848,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82670 }
82671 }
82672
82673 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
82674 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
82675 check_current:
82676 /* Check if current node has a suitable gap */
82677 if (gap_start > high_limit)
82678 return -ENOMEM;
82679 +
82680 + if (gap_end - gap_start > info->threadstack_offset)
82681 + gap_start += info->threadstack_offset;
82682 + else
82683 + gap_start = gap_end;
82684 +
82685 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
82686 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82687 + gap_start += sysctl_heap_stack_gap;
82688 + else
82689 + gap_start = gap_end;
82690 + }
82691 + if (vma->vm_flags & VM_GROWSDOWN) {
82692 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82693 + gap_end -= sysctl_heap_stack_gap;
82694 + else
82695 + gap_end = gap_start;
82696 + }
82697 if (gap_end >= low_limit && gap_end - gap_start >= length)
82698 goto found;
82699
82700 @@ -1686,7 +1920,7 @@ found:
82701 return gap_start;
82702 }
82703
82704 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
82705 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
82706 {
82707 struct mm_struct *mm = current->mm;
82708 struct vm_area_struct *vma;
82709 @@ -1740,6 +1974,24 @@ check_current:
82710 gap_end = vma->vm_start;
82711 if (gap_end < low_limit)
82712 return -ENOMEM;
82713 +
82714 + if (gap_end - gap_start > info->threadstack_offset)
82715 + gap_end -= info->threadstack_offset;
82716 + else
82717 + gap_end = gap_start;
82718 +
82719 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
82720 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82721 + gap_start += sysctl_heap_stack_gap;
82722 + else
82723 + gap_start = gap_end;
82724 + }
82725 + if (vma->vm_flags & VM_GROWSDOWN) {
82726 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82727 + gap_end -= sysctl_heap_stack_gap;
82728 + else
82729 + gap_end = gap_start;
82730 + }
82731 if (gap_start <= high_limit && gap_end - gap_start >= length)
82732 goto found;
82733
82734 @@ -1803,6 +2055,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82735 struct mm_struct *mm = current->mm;
82736 struct vm_area_struct *vma;
82737 struct vm_unmapped_area_info info;
82738 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82739
82740 if (len > TASK_SIZE)
82741 return -ENOMEM;
82742 @@ -1810,29 +2063,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82743 if (flags & MAP_FIXED)
82744 return addr;
82745
82746 +#ifdef CONFIG_PAX_RANDMMAP
82747 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82748 +#endif
82749 +
82750 if (addr) {
82751 addr = PAGE_ALIGN(addr);
82752 vma = find_vma(mm, addr);
82753 - if (TASK_SIZE - len >= addr &&
82754 - (!vma || addr + len <= vma->vm_start))
82755 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82756 return addr;
82757 }
82758
82759 info.flags = 0;
82760 info.length = len;
82761 info.low_limit = TASK_UNMAPPED_BASE;
82762 +
82763 +#ifdef CONFIG_PAX_RANDMMAP
82764 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82765 + info.low_limit += mm->delta_mmap;
82766 +#endif
82767 +
82768 info.high_limit = TASK_SIZE;
82769 info.align_mask = 0;
82770 + info.threadstack_offset = offset;
82771 return vm_unmapped_area(&info);
82772 }
82773 #endif
82774
82775 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82776 {
82777 +
82778 +#ifdef CONFIG_PAX_SEGMEXEC
82779 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82780 + return;
82781 +#endif
82782 +
82783 /*
82784 * Is this a new hole at the lowest possible address?
82785 */
82786 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82787 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82788 mm->free_area_cache = addr;
82789 }
82790
82791 @@ -1850,6 +2119,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82792 struct mm_struct *mm = current->mm;
82793 unsigned long addr = addr0;
82794 struct vm_unmapped_area_info info;
82795 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82796
82797 /* requested length too big for entire address space */
82798 if (len > TASK_SIZE)
82799 @@ -1858,12 +2128,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82800 if (flags & MAP_FIXED)
82801 return addr;
82802
82803 +#ifdef CONFIG_PAX_RANDMMAP
82804 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82805 +#endif
82806 +
82807 /* requesting a specific address */
82808 if (addr) {
82809 addr = PAGE_ALIGN(addr);
82810 vma = find_vma(mm, addr);
82811 - if (TASK_SIZE - len >= addr &&
82812 - (!vma || addr + len <= vma->vm_start))
82813 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82814 return addr;
82815 }
82816
82817 @@ -1872,6 +2145,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82818 info.low_limit = PAGE_SIZE;
82819 info.high_limit = mm->mmap_base;
82820 info.align_mask = 0;
82821 + info.threadstack_offset = offset;
82822 addr = vm_unmapped_area(&info);
82823
82824 /*
82825 @@ -1884,6 +2158,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82826 VM_BUG_ON(addr != -ENOMEM);
82827 info.flags = 0;
82828 info.low_limit = TASK_UNMAPPED_BASE;
82829 +
82830 +#ifdef CONFIG_PAX_RANDMMAP
82831 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82832 + info.low_limit += mm->delta_mmap;
82833 +#endif
82834 +
82835 info.high_limit = TASK_SIZE;
82836 addr = vm_unmapped_area(&info);
82837 }
82838 @@ -1894,6 +2174,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82839
82840 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82841 {
82842 +
82843 +#ifdef CONFIG_PAX_SEGMEXEC
82844 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82845 + return;
82846 +#endif
82847 +
82848 /*
82849 * Is this a new hole at the highest possible address?
82850 */
82851 @@ -1901,8 +2187,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82852 mm->free_area_cache = addr;
82853
82854 /* dont allow allocations above current base */
82855 - if (mm->free_area_cache > mm->mmap_base)
82856 + if (mm->free_area_cache > mm->mmap_base) {
82857 mm->free_area_cache = mm->mmap_base;
82858 + mm->cached_hole_size = ~0UL;
82859 + }
82860 }
82861
82862 unsigned long
82863 @@ -2001,6 +2289,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82864 return vma;
82865 }
82866
82867 +#ifdef CONFIG_PAX_SEGMEXEC
82868 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82869 +{
82870 + struct vm_area_struct *vma_m;
82871 +
82872 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82873 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82874 + BUG_ON(vma->vm_mirror);
82875 + return NULL;
82876 + }
82877 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82878 + vma_m = vma->vm_mirror;
82879 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82880 + BUG_ON(vma->vm_file != vma_m->vm_file);
82881 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82882 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82883 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82884 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82885 + return vma_m;
82886 +}
82887 +#endif
82888 +
82889 /*
82890 * Verify that the stack growth is acceptable and
82891 * update accounting. This is shared with both the
82892 @@ -2017,6 +2327,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82893 return -ENOMEM;
82894
82895 /* Stack limit test */
82896 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82897 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82898 return -ENOMEM;
82899
82900 @@ -2027,6 +2338,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82901 locked = mm->locked_vm + grow;
82902 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82903 limit >>= PAGE_SHIFT;
82904 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82905 if (locked > limit && !capable(CAP_IPC_LOCK))
82906 return -ENOMEM;
82907 }
82908 @@ -2056,37 +2368,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82909 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82910 * vma is the last one with address > vma->vm_end. Have to extend vma.
82911 */
82912 +#ifndef CONFIG_IA64
82913 +static
82914 +#endif
82915 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82916 {
82917 int error;
82918 + bool locknext;
82919
82920 if (!(vma->vm_flags & VM_GROWSUP))
82921 return -EFAULT;
82922
82923 + /* Also guard against wrapping around to address 0. */
82924 + if (address < PAGE_ALIGN(address+1))
82925 + address = PAGE_ALIGN(address+1);
82926 + else
82927 + return -ENOMEM;
82928 +
82929 /*
82930 * We must make sure the anon_vma is allocated
82931 * so that the anon_vma locking is not a noop.
82932 */
82933 if (unlikely(anon_vma_prepare(vma)))
82934 return -ENOMEM;
82935 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82936 + if (locknext && anon_vma_prepare(vma->vm_next))
82937 + return -ENOMEM;
82938 vma_lock_anon_vma(vma);
82939 + if (locknext)
82940 + vma_lock_anon_vma(vma->vm_next);
82941
82942 /*
82943 * vma->vm_start/vm_end cannot change under us because the caller
82944 * is required to hold the mmap_sem in read mode. We need the
82945 - * anon_vma lock to serialize against concurrent expand_stacks.
82946 - * Also guard against wrapping around to address 0.
82947 + * anon_vma locks to serialize against concurrent expand_stacks
82948 + * and expand_upwards.
82949 */
82950 - if (address < PAGE_ALIGN(address+4))
82951 - address = PAGE_ALIGN(address+4);
82952 - else {
82953 - vma_unlock_anon_vma(vma);
82954 - return -ENOMEM;
82955 - }
82956 error = 0;
82957
82958 /* Somebody else might have raced and expanded it already */
82959 - if (address > vma->vm_end) {
82960 + 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)
82961 + error = -ENOMEM;
82962 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82963 unsigned long size, grow;
82964
82965 size = address - vma->vm_start;
82966 @@ -2121,6 +2444,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82967 }
82968 }
82969 }
82970 + if (locknext)
82971 + vma_unlock_anon_vma(vma->vm_next);
82972 vma_unlock_anon_vma(vma);
82973 khugepaged_enter_vma_merge(vma);
82974 validate_mm(vma->vm_mm);
82975 @@ -2135,6 +2460,8 @@ int expand_downwards(struct vm_area_struct *vma,
82976 unsigned long address)
82977 {
82978 int error;
82979 + bool lockprev = false;
82980 + struct vm_area_struct *prev;
82981
82982 /*
82983 * We must make sure the anon_vma is allocated
82984 @@ -2148,6 +2475,15 @@ int expand_downwards(struct vm_area_struct *vma,
82985 if (error)
82986 return error;
82987
82988 + prev = vma->vm_prev;
82989 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82990 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82991 +#endif
82992 + if (lockprev && anon_vma_prepare(prev))
82993 + return -ENOMEM;
82994 + if (lockprev)
82995 + vma_lock_anon_vma(prev);
82996 +
82997 vma_lock_anon_vma(vma);
82998
82999 /*
83000 @@ -2157,9 +2493,17 @@ int expand_downwards(struct vm_area_struct *vma,
83001 */
83002
83003 /* Somebody else might have raced and expanded it already */
83004 - if (address < vma->vm_start) {
83005 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
83006 + error = -ENOMEM;
83007 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
83008 unsigned long size, grow;
83009
83010 +#ifdef CONFIG_PAX_SEGMEXEC
83011 + struct vm_area_struct *vma_m;
83012 +
83013 + vma_m = pax_find_mirror_vma(vma);
83014 +#endif
83015 +
83016 size = vma->vm_end - address;
83017 grow = (vma->vm_start - address) >> PAGE_SHIFT;
83018
83019 @@ -2184,13 +2528,27 @@ int expand_downwards(struct vm_area_struct *vma,
83020 vma->vm_pgoff -= grow;
83021 anon_vma_interval_tree_post_update_vma(vma);
83022 vma_gap_update(vma);
83023 +
83024 +#ifdef CONFIG_PAX_SEGMEXEC
83025 + if (vma_m) {
83026 + anon_vma_interval_tree_pre_update_vma(vma_m);
83027 + vma_m->vm_start -= grow << PAGE_SHIFT;
83028 + vma_m->vm_pgoff -= grow;
83029 + anon_vma_interval_tree_post_update_vma(vma_m);
83030 + vma_gap_update(vma_m);
83031 + }
83032 +#endif
83033 +
83034 spin_unlock(&vma->vm_mm->page_table_lock);
83035
83036 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
83037 perf_event_mmap(vma);
83038 }
83039 }
83040 }
83041 vma_unlock_anon_vma(vma);
83042 + if (lockprev)
83043 + vma_unlock_anon_vma(prev);
83044 khugepaged_enter_vma_merge(vma);
83045 validate_mm(vma->vm_mm);
83046 return error;
83047 @@ -2288,6 +2646,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
83048 do {
83049 long nrpages = vma_pages(vma);
83050
83051 +#ifdef CONFIG_PAX_SEGMEXEC
83052 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
83053 + vma = remove_vma(vma);
83054 + continue;
83055 + }
83056 +#endif
83057 +
83058 if (vma->vm_flags & VM_ACCOUNT)
83059 nr_accounted += nrpages;
83060 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
83061 @@ -2333,6 +2698,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
83062 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
83063 vma->vm_prev = NULL;
83064 do {
83065 +
83066 +#ifdef CONFIG_PAX_SEGMEXEC
83067 + if (vma->vm_mirror) {
83068 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
83069 + vma->vm_mirror->vm_mirror = NULL;
83070 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
83071 + vma->vm_mirror = NULL;
83072 + }
83073 +#endif
83074 +
83075 vma_rb_erase(vma, &mm->mm_rb);
83076 mm->map_count--;
83077 tail_vma = vma;
83078 @@ -2364,14 +2739,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83079 struct vm_area_struct *new;
83080 int err = -ENOMEM;
83081
83082 +#ifdef CONFIG_PAX_SEGMEXEC
83083 + struct vm_area_struct *vma_m, *new_m = NULL;
83084 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
83085 +#endif
83086 +
83087 if (is_vm_hugetlb_page(vma) && (addr &
83088 ~(huge_page_mask(hstate_vma(vma)))))
83089 return -EINVAL;
83090
83091 +#ifdef CONFIG_PAX_SEGMEXEC
83092 + vma_m = pax_find_mirror_vma(vma);
83093 +#endif
83094 +
83095 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83096 if (!new)
83097 goto out_err;
83098
83099 +#ifdef CONFIG_PAX_SEGMEXEC
83100 + if (vma_m) {
83101 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83102 + if (!new_m) {
83103 + kmem_cache_free(vm_area_cachep, new);
83104 + goto out_err;
83105 + }
83106 + }
83107 +#endif
83108 +
83109 /* most fields are the same, copy all, and then fixup */
83110 *new = *vma;
83111
83112 @@ -2384,6 +2778,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83113 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
83114 }
83115
83116 +#ifdef CONFIG_PAX_SEGMEXEC
83117 + if (vma_m) {
83118 + *new_m = *vma_m;
83119 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
83120 + new_m->vm_mirror = new;
83121 + new->vm_mirror = new_m;
83122 +
83123 + if (new_below)
83124 + new_m->vm_end = addr_m;
83125 + else {
83126 + new_m->vm_start = addr_m;
83127 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
83128 + }
83129 + }
83130 +#endif
83131 +
83132 pol = mpol_dup(vma_policy(vma));
83133 if (IS_ERR(pol)) {
83134 err = PTR_ERR(pol);
83135 @@ -2406,6 +2816,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83136 else
83137 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
83138
83139 +#ifdef CONFIG_PAX_SEGMEXEC
83140 + if (!err && vma_m) {
83141 + if (anon_vma_clone(new_m, vma_m))
83142 + goto out_free_mpol;
83143 +
83144 + mpol_get(pol);
83145 + vma_set_policy(new_m, pol);
83146 +
83147 + if (new_m->vm_file)
83148 + get_file(new_m->vm_file);
83149 +
83150 + if (new_m->vm_ops && new_m->vm_ops->open)
83151 + new_m->vm_ops->open(new_m);
83152 +
83153 + if (new_below)
83154 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
83155 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
83156 + else
83157 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
83158 +
83159 + if (err) {
83160 + if (new_m->vm_ops && new_m->vm_ops->close)
83161 + new_m->vm_ops->close(new_m);
83162 + if (new_m->vm_file)
83163 + fput(new_m->vm_file);
83164 + mpol_put(pol);
83165 + }
83166 + }
83167 +#endif
83168 +
83169 /* Success. */
83170 if (!err)
83171 return 0;
83172 @@ -2415,10 +2855,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83173 new->vm_ops->close(new);
83174 if (new->vm_file)
83175 fput(new->vm_file);
83176 - unlink_anon_vmas(new);
83177 out_free_mpol:
83178 mpol_put(pol);
83179 out_free_vma:
83180 +
83181 +#ifdef CONFIG_PAX_SEGMEXEC
83182 + if (new_m) {
83183 + unlink_anon_vmas(new_m);
83184 + kmem_cache_free(vm_area_cachep, new_m);
83185 + }
83186 +#endif
83187 +
83188 + unlink_anon_vmas(new);
83189 kmem_cache_free(vm_area_cachep, new);
83190 out_err:
83191 return err;
83192 @@ -2431,6 +2879,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83193 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83194 unsigned long addr, int new_below)
83195 {
83196 +
83197 +#ifdef CONFIG_PAX_SEGMEXEC
83198 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83199 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
83200 + if (mm->map_count >= sysctl_max_map_count-1)
83201 + return -ENOMEM;
83202 + } else
83203 +#endif
83204 +
83205 if (mm->map_count >= sysctl_max_map_count)
83206 return -ENOMEM;
83207
83208 @@ -2442,11 +2899,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83209 * work. This now handles partial unmappings.
83210 * Jeremy Fitzhardinge <jeremy@goop.org>
83211 */
83212 +#ifdef CONFIG_PAX_SEGMEXEC
83213 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83214 {
83215 + int ret = __do_munmap(mm, start, len);
83216 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
83217 + return ret;
83218 +
83219 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
83220 +}
83221 +
83222 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83223 +#else
83224 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83225 +#endif
83226 +{
83227 unsigned long end;
83228 struct vm_area_struct *vma, *prev, *last;
83229
83230 + /*
83231 + * mm->mmap_sem is required to protect against another thread
83232 + * changing the mappings in case we sleep.
83233 + */
83234 + verify_mm_writelocked(mm);
83235 +
83236 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83237 return -EINVAL;
83238
83239 @@ -2521,6 +2997,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83240 /* Fix up all other VM information */
83241 remove_vma_list(mm, vma);
83242
83243 + track_exec_limit(mm, start, end, 0UL);
83244 +
83245 return 0;
83246 }
83247
83248 @@ -2529,6 +3007,13 @@ int vm_munmap(unsigned long start, size_t len)
83249 int ret;
83250 struct mm_struct *mm = current->mm;
83251
83252 +
83253 +#ifdef CONFIG_PAX_SEGMEXEC
83254 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83255 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83256 + return -EINVAL;
83257 +#endif
83258 +
83259 down_write(&mm->mmap_sem);
83260 ret = do_munmap(mm, start, len);
83261 up_write(&mm->mmap_sem);
83262 @@ -2542,16 +3027,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83263 return vm_munmap(addr, len);
83264 }
83265
83266 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83267 -{
83268 -#ifdef CONFIG_DEBUG_VM
83269 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83270 - WARN_ON(1);
83271 - up_read(&mm->mmap_sem);
83272 - }
83273 -#endif
83274 -}
83275 -
83276 /*
83277 * this is really a simplified "do_mmap". it only handles
83278 * anonymous maps. eventually we may be able to do some
83279 @@ -2565,6 +3040,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83280 struct rb_node ** rb_link, * rb_parent;
83281 pgoff_t pgoff = addr >> PAGE_SHIFT;
83282 int error;
83283 + unsigned long charged;
83284
83285 len = PAGE_ALIGN(len);
83286 if (!len)
83287 @@ -2572,16 +3048,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83288
83289 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83290
83291 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83292 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83293 + flags &= ~VM_EXEC;
83294 +
83295 +#ifdef CONFIG_PAX_MPROTECT
83296 + if (mm->pax_flags & MF_PAX_MPROTECT)
83297 + flags &= ~VM_MAYEXEC;
83298 +#endif
83299 +
83300 + }
83301 +#endif
83302 +
83303 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83304 if (error & ~PAGE_MASK)
83305 return error;
83306
83307 + charged = len >> PAGE_SHIFT;
83308 +
83309 /*
83310 * mlock MCL_FUTURE?
83311 */
83312 if (mm->def_flags & VM_LOCKED) {
83313 unsigned long locked, lock_limit;
83314 - locked = len >> PAGE_SHIFT;
83315 + locked = charged;
83316 locked += mm->locked_vm;
83317 lock_limit = rlimit(RLIMIT_MEMLOCK);
83318 lock_limit >>= PAGE_SHIFT;
83319 @@ -2598,21 +3088,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83320 /*
83321 * Clear old maps. this also does some error checking for us
83322 */
83323 - munmap_back:
83324 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83325 if (do_munmap(mm, addr, len))
83326 return -ENOMEM;
83327 - goto munmap_back;
83328 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83329 }
83330
83331 /* Check against address space limits *after* clearing old maps... */
83332 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83333 + if (!may_expand_vm(mm, charged))
83334 return -ENOMEM;
83335
83336 if (mm->map_count > sysctl_max_map_count)
83337 return -ENOMEM;
83338
83339 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83340 + if (security_vm_enough_memory_mm(mm, charged))
83341 return -ENOMEM;
83342
83343 /* Can we just expand an old private anonymous mapping? */
83344 @@ -2626,7 +3115,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83345 */
83346 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83347 if (!vma) {
83348 - vm_unacct_memory(len >> PAGE_SHIFT);
83349 + vm_unacct_memory(charged);
83350 return -ENOMEM;
83351 }
83352
83353 @@ -2640,9 +3129,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83354 vma_link(mm, vma, prev, rb_link, rb_parent);
83355 out:
83356 perf_event_mmap(vma);
83357 - mm->total_vm += len >> PAGE_SHIFT;
83358 + mm->total_vm += charged;
83359 if (flags & VM_LOCKED)
83360 - mm->locked_vm += (len >> PAGE_SHIFT);
83361 + mm->locked_vm += charged;
83362 + track_exec_limit(mm, addr, addr + len, flags);
83363 return addr;
83364 }
83365
83366 @@ -2704,6 +3194,7 @@ void exit_mmap(struct mm_struct *mm)
83367 while (vma) {
83368 if (vma->vm_flags & VM_ACCOUNT)
83369 nr_accounted += vma_pages(vma);
83370 + vma->vm_mirror = NULL;
83371 vma = remove_vma(vma);
83372 }
83373 vm_unacct_memory(nr_accounted);
83374 @@ -2720,6 +3211,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83375 struct vm_area_struct *prev;
83376 struct rb_node **rb_link, *rb_parent;
83377
83378 +#ifdef CONFIG_PAX_SEGMEXEC
83379 + struct vm_area_struct *vma_m = NULL;
83380 +#endif
83381 +
83382 + if (security_mmap_addr(vma->vm_start))
83383 + return -EPERM;
83384 +
83385 /*
83386 * The vm_pgoff of a purely anonymous vma should be irrelevant
83387 * until its first write fault, when page's anon_vma and index
83388 @@ -2743,7 +3241,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83389 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83390 return -ENOMEM;
83391
83392 +#ifdef CONFIG_PAX_SEGMEXEC
83393 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83394 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83395 + if (!vma_m)
83396 + return -ENOMEM;
83397 + }
83398 +#endif
83399 +
83400 vma_link(mm, vma, prev, rb_link, rb_parent);
83401 +
83402 +#ifdef CONFIG_PAX_SEGMEXEC
83403 + if (vma_m)
83404 + BUG_ON(pax_mirror_vma(vma_m, vma));
83405 +#endif
83406 +
83407 return 0;
83408 }
83409
83410 @@ -2763,6 +3275,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83411 struct mempolicy *pol;
83412 bool faulted_in_anon_vma = true;
83413
83414 + BUG_ON(vma->vm_mirror);
83415 +
83416 /*
83417 * If anonymous vma has not yet been faulted, update new pgoff
83418 * to match new location, to increase its chance of merging.
83419 @@ -2829,6 +3343,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83420 return NULL;
83421 }
83422
83423 +#ifdef CONFIG_PAX_SEGMEXEC
83424 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83425 +{
83426 + struct vm_area_struct *prev_m;
83427 + struct rb_node **rb_link_m, *rb_parent_m;
83428 + struct mempolicy *pol_m;
83429 +
83430 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83431 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83432 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83433 + *vma_m = *vma;
83434 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83435 + if (anon_vma_clone(vma_m, vma))
83436 + return -ENOMEM;
83437 + pol_m = vma_policy(vma_m);
83438 + mpol_get(pol_m);
83439 + vma_set_policy(vma_m, pol_m);
83440 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83441 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83442 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83443 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83444 + if (vma_m->vm_file)
83445 + get_file(vma_m->vm_file);
83446 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83447 + vma_m->vm_ops->open(vma_m);
83448 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83449 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83450 + vma_m->vm_mirror = vma;
83451 + vma->vm_mirror = vma_m;
83452 + return 0;
83453 +}
83454 +#endif
83455 +
83456 /*
83457 * Return true if the calling process may expand its vm space by the passed
83458 * number of pages
83459 @@ -2840,6 +3387,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83460
83461 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83462
83463 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83464 if (cur + npages > lim)
83465 return 0;
83466 return 1;
83467 @@ -2910,6 +3458,22 @@ int install_special_mapping(struct mm_struct *mm,
83468 vma->vm_start = addr;
83469 vma->vm_end = addr + len;
83470
83471 +#ifdef CONFIG_PAX_MPROTECT
83472 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83473 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83474 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83475 + return -EPERM;
83476 + if (!(vm_flags & VM_EXEC))
83477 + vm_flags &= ~VM_MAYEXEC;
83478 +#else
83479 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83480 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83481 +#endif
83482 + else
83483 + vm_flags &= ~VM_MAYWRITE;
83484 + }
83485 +#endif
83486 +
83487 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83488 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83489
83490 diff --git a/mm/mprotect.c b/mm/mprotect.c
83491 index 94722a4..07d9926 100644
83492 --- a/mm/mprotect.c
83493 +++ b/mm/mprotect.c
83494 @@ -23,10 +23,18 @@
83495 #include <linux/mmu_notifier.h>
83496 #include <linux/migrate.h>
83497 #include <linux/perf_event.h>
83498 +#include <linux/sched/sysctl.h>
83499 +
83500 +#ifdef CONFIG_PAX_MPROTECT
83501 +#include <linux/elf.h>
83502 +#include <linux/binfmts.h>
83503 +#endif
83504 +
83505 #include <asm/uaccess.h>
83506 #include <asm/pgtable.h>
83507 #include <asm/cacheflush.h>
83508 #include <asm/tlbflush.h>
83509 +#include <asm/mmu_context.h>
83510
83511 #ifndef pgprot_modify
83512 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83513 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83514 return pages;
83515 }
83516
83517 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83518 +/* called while holding the mmap semaphor for writing except stack expansion */
83519 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83520 +{
83521 + unsigned long oldlimit, newlimit = 0UL;
83522 +
83523 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83524 + return;
83525 +
83526 + spin_lock(&mm->page_table_lock);
83527 + oldlimit = mm->context.user_cs_limit;
83528 + if ((prot & VM_EXEC) && oldlimit < end)
83529 + /* USER_CS limit moved up */
83530 + newlimit = end;
83531 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83532 + /* USER_CS limit moved down */
83533 + newlimit = start;
83534 +
83535 + if (newlimit) {
83536 + mm->context.user_cs_limit = newlimit;
83537 +
83538 +#ifdef CONFIG_SMP
83539 + wmb();
83540 + cpus_clear(mm->context.cpu_user_cs_mask);
83541 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83542 +#endif
83543 +
83544 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83545 + }
83546 + spin_unlock(&mm->page_table_lock);
83547 + if (newlimit == end) {
83548 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83549 +
83550 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83551 + if (is_vm_hugetlb_page(vma))
83552 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83553 + else
83554 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83555 + }
83556 +}
83557 +#endif
83558 +
83559 int
83560 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83561 unsigned long start, unsigned long end, unsigned long newflags)
83562 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83563 int error;
83564 int dirty_accountable = 0;
83565
83566 +#ifdef CONFIG_PAX_SEGMEXEC
83567 + struct vm_area_struct *vma_m = NULL;
83568 + unsigned long start_m, end_m;
83569 +
83570 + start_m = start + SEGMEXEC_TASK_SIZE;
83571 + end_m = end + SEGMEXEC_TASK_SIZE;
83572 +#endif
83573 +
83574 if (newflags == oldflags) {
83575 *pprev = vma;
83576 return 0;
83577 }
83578
83579 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83580 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83581 +
83582 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83583 + return -ENOMEM;
83584 +
83585 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83586 + return -ENOMEM;
83587 + }
83588 +
83589 /*
83590 * If we make a private mapping writable we increase our commit;
83591 * but (without finer accounting) cannot reduce our commit if we
83592 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83593 }
83594 }
83595
83596 +#ifdef CONFIG_PAX_SEGMEXEC
83597 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83598 + if (start != vma->vm_start) {
83599 + error = split_vma(mm, vma, start, 1);
83600 + if (error)
83601 + goto fail;
83602 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83603 + *pprev = (*pprev)->vm_next;
83604 + }
83605 +
83606 + if (end != vma->vm_end) {
83607 + error = split_vma(mm, vma, end, 0);
83608 + if (error)
83609 + goto fail;
83610 + }
83611 +
83612 + if (pax_find_mirror_vma(vma)) {
83613 + error = __do_munmap(mm, start_m, end_m - start_m);
83614 + if (error)
83615 + goto fail;
83616 + } else {
83617 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83618 + if (!vma_m) {
83619 + error = -ENOMEM;
83620 + goto fail;
83621 + }
83622 + vma->vm_flags = newflags;
83623 + error = pax_mirror_vma(vma_m, vma);
83624 + if (error) {
83625 + vma->vm_flags = oldflags;
83626 + goto fail;
83627 + }
83628 + }
83629 + }
83630 +#endif
83631 +
83632 /*
83633 * First try to merge with previous and/or next vma.
83634 */
83635 @@ -296,9 +400,21 @@ success:
83636 * vm_flags and vm_page_prot are protected by the mmap_sem
83637 * held in write mode.
83638 */
83639 +
83640 +#ifdef CONFIG_PAX_SEGMEXEC
83641 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83642 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83643 +#endif
83644 +
83645 vma->vm_flags = newflags;
83646 +
83647 +#ifdef CONFIG_PAX_MPROTECT
83648 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83649 + mm->binfmt->handle_mprotect(vma, newflags);
83650 +#endif
83651 +
83652 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83653 - vm_get_page_prot(newflags));
83654 + vm_get_page_prot(vma->vm_flags));
83655
83656 if (vma_wants_writenotify(vma)) {
83657 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83658 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83659 end = start + len;
83660 if (end <= start)
83661 return -ENOMEM;
83662 +
83663 +#ifdef CONFIG_PAX_SEGMEXEC
83664 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83665 + if (end > SEGMEXEC_TASK_SIZE)
83666 + return -EINVAL;
83667 + } else
83668 +#endif
83669 +
83670 + if (end > TASK_SIZE)
83671 + return -EINVAL;
83672 +
83673 if (!arch_validate_prot(prot))
83674 return -EINVAL;
83675
83676 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83677 /*
83678 * Does the application expect PROT_READ to imply PROT_EXEC:
83679 */
83680 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83681 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83682 prot |= PROT_EXEC;
83683
83684 vm_flags = calc_vm_prot_bits(prot);
83685 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83686 if (start > vma->vm_start)
83687 prev = vma;
83688
83689 +#ifdef CONFIG_PAX_MPROTECT
83690 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83691 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83692 +#endif
83693 +
83694 for (nstart = start ; ; ) {
83695 unsigned long newflags;
83696
83697 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83698
83699 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83700 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83701 + if (prot & (PROT_WRITE | PROT_EXEC))
83702 + gr_log_rwxmprotect(vma->vm_file);
83703 +
83704 + error = -EACCES;
83705 + goto out;
83706 + }
83707 +
83708 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83709 error = -EACCES;
83710 goto out;
83711 }
83712 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83713 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83714 if (error)
83715 goto out;
83716 +
83717 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83718 +
83719 nstart = tmp;
83720
83721 if (nstart < prev->vm_end)
83722 diff --git a/mm/mremap.c b/mm/mremap.c
83723 index 463a257..c0c7a92 100644
83724 --- a/mm/mremap.c
83725 +++ b/mm/mremap.c
83726 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83727 continue;
83728 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83729 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83730 +
83731 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83732 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83733 + pte = pte_exprotect(pte);
83734 +#endif
83735 +
83736 set_pte_at(mm, new_addr, new_pte, pte);
83737 }
83738
83739 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83740 if (is_vm_hugetlb_page(vma))
83741 goto Einval;
83742
83743 +#ifdef CONFIG_PAX_SEGMEXEC
83744 + if (pax_find_mirror_vma(vma))
83745 + goto Einval;
83746 +#endif
83747 +
83748 /* We can't remap across vm area boundaries */
83749 if (old_len > vma->vm_end - addr)
83750 goto Efault;
83751 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
83752 unsigned long ret = -EINVAL;
83753 unsigned long charged = 0;
83754 unsigned long map_flags;
83755 + unsigned long pax_task_size = TASK_SIZE;
83756
83757 if (new_addr & ~PAGE_MASK)
83758 goto out;
83759
83760 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83761 +#ifdef CONFIG_PAX_SEGMEXEC
83762 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83763 + pax_task_size = SEGMEXEC_TASK_SIZE;
83764 +#endif
83765 +
83766 + pax_task_size -= PAGE_SIZE;
83767 +
83768 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83769 goto out;
83770
83771 /* Check if the location we're moving into overlaps the
83772 * old location at all, and fail if it does.
83773 */
83774 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83775 - goto out;
83776 -
83777 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83778 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83779 goto out;
83780
83781 ret = do_munmap(mm, new_addr, new_len);
83782 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83783 unsigned long ret = -EINVAL;
83784 unsigned long charged = 0;
83785 bool locked = false;
83786 + unsigned long pax_task_size = TASK_SIZE;
83787
83788 down_write(&current->mm->mmap_sem);
83789
83790 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83791 if (!new_len)
83792 goto out;
83793
83794 +#ifdef CONFIG_PAX_SEGMEXEC
83795 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83796 + pax_task_size = SEGMEXEC_TASK_SIZE;
83797 +#endif
83798 +
83799 + pax_task_size -= PAGE_SIZE;
83800 +
83801 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83802 + old_len > pax_task_size || addr > pax_task_size-old_len)
83803 + goto out;
83804 +
83805 if (flags & MREMAP_FIXED) {
83806 if (flags & MREMAP_MAYMOVE)
83807 ret = mremap_to(addr, old_len, new_addr, new_len,
83808 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83809 new_addr = addr;
83810 }
83811 ret = addr;
83812 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83813 goto out;
83814 }
83815 }
83816 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83817 goto out;
83818 }
83819
83820 + map_flags = vma->vm_flags;
83821 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
83822 + if (!(ret & ~PAGE_MASK)) {
83823 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83824 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83825 + }
83826 }
83827 out:
83828 if (ret & ~PAGE_MASK)
83829 diff --git a/mm/nommu.c b/mm/nommu.c
83830 index e001768..9b52b30 100644
83831 --- a/mm/nommu.c
83832 +++ b/mm/nommu.c
83833 @@ -63,7 +63,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83834 int sysctl_overcommit_ratio = 50; /* default is 50% */
83835 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83836 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83837 -int heap_stack_gap = 0;
83838
83839 atomic_long_t mmap_pages_allocated;
83840
83841 @@ -841,15 +840,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83842 EXPORT_SYMBOL(find_vma);
83843
83844 /*
83845 - * find a VMA
83846 - * - we don't extend stack VMAs under NOMMU conditions
83847 - */
83848 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83849 -{
83850 - return find_vma(mm, addr);
83851 -}
83852 -
83853 -/*
83854 * expand a stack to a given address
83855 * - not supported under NOMMU conditions
83856 */
83857 @@ -1560,6 +1550,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83858
83859 /* most fields are the same, copy all, and then fixup */
83860 *new = *vma;
83861 + INIT_LIST_HEAD(&new->anon_vma_chain);
83862 *region = *vma->vm_region;
83863 new->vm_region = region;
83864
83865 @@ -1992,8 +1983,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83866 }
83867 EXPORT_SYMBOL(generic_file_remap_pages);
83868
83869 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83870 - unsigned long addr, void *buf, int len, int write)
83871 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83872 + unsigned long addr, void *buf, size_t len, int write)
83873 {
83874 struct vm_area_struct *vma;
83875
83876 @@ -2034,8 +2025,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83877 *
83878 * The caller must hold a reference on @mm.
83879 */
83880 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83881 - void *buf, int len, int write)
83882 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83883 + void *buf, size_t len, int write)
83884 {
83885 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83886 }
83887 @@ -2044,7 +2035,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83888 * Access another process' address space.
83889 * - source/target buffer must be kernel space
83890 */
83891 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83892 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83893 {
83894 struct mm_struct *mm;
83895
83896 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83897 index efe6814..64b4701 100644
83898 --- a/mm/page-writeback.c
83899 +++ b/mm/page-writeback.c
83900 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83901 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83902 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83903 */
83904 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83905 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83906 unsigned long thresh,
83907 unsigned long bg_thresh,
83908 unsigned long dirty,
83909 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83910 }
83911 }
83912
83913 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83914 +static struct notifier_block ratelimit_nb = {
83915 .notifier_call = ratelimit_handler,
83916 .next = NULL,
83917 };
83918 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83919 index 0d4fef2..8870335 100644
83920 --- a/mm/page_alloc.c
83921 +++ b/mm/page_alloc.c
83922 @@ -59,6 +59,7 @@
83923 #include <linux/migrate.h>
83924 #include <linux/page-debug-flags.h>
83925 #include <linux/sched/rt.h>
83926 +#include <linux/random.h>
83927
83928 #include <asm/tlbflush.h>
83929 #include <asm/div64.h>
83930 @@ -344,7 +345,7 @@ out:
83931 * This usage means that zero-order pages may not be compound.
83932 */
83933
83934 -static void free_compound_page(struct page *page)
83935 +void free_compound_page(struct page *page)
83936 {
83937 __free_pages_ok(page, compound_order(page));
83938 }
83939 @@ -701,6 +702,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83940 int i;
83941 int bad = 0;
83942
83943 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83944 + unsigned long index = 1UL << order;
83945 +#endif
83946 +
83947 trace_mm_page_free(page, order);
83948 kmemcheck_free_shadow(page, order);
83949
83950 @@ -716,6 +721,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83951 debug_check_no_obj_freed(page_address(page),
83952 PAGE_SIZE << order);
83953 }
83954 +
83955 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83956 + for (; index; --index)
83957 + sanitize_highpage(page + index - 1);
83958 +#endif
83959 +
83960 arch_free_page(page, order);
83961 kernel_map_pages(page, 1 << order, 0);
83962
83963 @@ -738,6 +749,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83964 local_irq_restore(flags);
83965 }
83966
83967 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83968 +bool __meminitdata extra_latent_entropy;
83969 +
83970 +static int __init setup_pax_extra_latent_entropy(char *str)
83971 +{
83972 + extra_latent_entropy = true;
83973 + return 0;
83974 +}
83975 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83976 +
83977 +volatile u64 latent_entropy;
83978 +#endif
83979 +
83980 /*
83981 * Read access to zone->managed_pages is safe because it's unsigned long,
83982 * but we still need to serialize writers. Currently all callers of
83983 @@ -760,6 +784,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83984 set_page_count(p, 0);
83985 }
83986
83987 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83988 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83989 + u64 hash = 0;
83990 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83991 + const u64 *data = lowmem_page_address(page);
83992 +
83993 + for (index = 0; index < end; index++)
83994 + hash ^= hash + data[index];
83995 + latent_entropy ^= hash;
83996 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83997 + }
83998 +#endif
83999 +
84000 page_zone(page)->managed_pages += 1 << order;
84001 set_page_refcounted(page);
84002 __free_pages(page, order);
84003 @@ -869,8 +906,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
84004 arch_alloc_page(page, order);
84005 kernel_map_pages(page, 1 << order, 1);
84006
84007 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
84008 if (gfp_flags & __GFP_ZERO)
84009 prep_zero_page(page, order, gfp_flags);
84010 +#endif
84011
84012 if (order && (gfp_flags & __GFP_COMP))
84013 prep_compound_page(page, order);
84014 diff --git a/mm/page_io.c b/mm/page_io.c
84015 index 6182870..4bba6a2 100644
84016 --- a/mm/page_io.c
84017 +++ b/mm/page_io.c
84018 @@ -205,7 +205,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
84019 struct file *swap_file = sis->swap_file;
84020 struct address_space *mapping = swap_file->f_mapping;
84021 struct iovec iov = {
84022 - .iov_base = kmap(page),
84023 + .iov_base = (void __force_user *)kmap(page),
84024 .iov_len = PAGE_SIZE,
84025 };
84026
84027 diff --git a/mm/percpu.c b/mm/percpu.c
84028 index 8c8e08f..73a5cda 100644
84029 --- a/mm/percpu.c
84030 +++ b/mm/percpu.c
84031 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
84032 static unsigned int pcpu_high_unit_cpu __read_mostly;
84033
84034 /* the address of the first chunk which starts with the kernel static area */
84035 -void *pcpu_base_addr __read_mostly;
84036 +void *pcpu_base_addr __read_only;
84037 EXPORT_SYMBOL_GPL(pcpu_base_addr);
84038
84039 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
84040 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
84041 index fd26d04..0cea1b0 100644
84042 --- a/mm/process_vm_access.c
84043 +++ b/mm/process_vm_access.c
84044 @@ -13,6 +13,7 @@
84045 #include <linux/uio.h>
84046 #include <linux/sched.h>
84047 #include <linux/highmem.h>
84048 +#include <linux/security.h>
84049 #include <linux/ptrace.h>
84050 #include <linux/slab.h>
84051 #include <linux/syscalls.h>
84052 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84053 size_t iov_l_curr_offset = 0;
84054 ssize_t iov_len;
84055
84056 + return -ENOSYS; // PaX: until properly audited
84057 +
84058 /*
84059 * Work out how many pages of struct pages we're going to need
84060 * when eventually calling get_user_pages
84061 */
84062 for (i = 0; i < riovcnt; i++) {
84063 iov_len = rvec[i].iov_len;
84064 - if (iov_len > 0) {
84065 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
84066 - + iov_len)
84067 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
84068 - / PAGE_SIZE + 1;
84069 - nr_pages = max(nr_pages, nr_pages_iov);
84070 - }
84071 + if (iov_len <= 0)
84072 + continue;
84073 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
84074 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
84075 + nr_pages = max(nr_pages, nr_pages_iov);
84076 }
84077
84078 if (nr_pages == 0)
84079 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84080 goto free_proc_pages;
84081 }
84082
84083 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
84084 + rc = -EPERM;
84085 + goto put_task_struct;
84086 + }
84087 +
84088 mm = mm_access(task, PTRACE_MODE_ATTACH);
84089 if (!mm || IS_ERR(mm)) {
84090 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
84091 diff --git a/mm/rmap.c b/mm/rmap.c
84092 index 807c96b..0e05279 100644
84093 --- a/mm/rmap.c
84094 +++ b/mm/rmap.c
84095 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84096 struct anon_vma *anon_vma = vma->anon_vma;
84097 struct anon_vma_chain *avc;
84098
84099 +#ifdef CONFIG_PAX_SEGMEXEC
84100 + struct anon_vma_chain *avc_m = NULL;
84101 +#endif
84102 +
84103 might_sleep();
84104 if (unlikely(!anon_vma)) {
84105 struct mm_struct *mm = vma->vm_mm;
84106 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84107 if (!avc)
84108 goto out_enomem;
84109
84110 +#ifdef CONFIG_PAX_SEGMEXEC
84111 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
84112 + if (!avc_m)
84113 + goto out_enomem_free_avc;
84114 +#endif
84115 +
84116 anon_vma = find_mergeable_anon_vma(vma);
84117 allocated = NULL;
84118 if (!anon_vma) {
84119 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84120 /* page_table_lock to protect against threads */
84121 spin_lock(&mm->page_table_lock);
84122 if (likely(!vma->anon_vma)) {
84123 +
84124 +#ifdef CONFIG_PAX_SEGMEXEC
84125 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
84126 +
84127 + if (vma_m) {
84128 + BUG_ON(vma_m->anon_vma);
84129 + vma_m->anon_vma = anon_vma;
84130 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
84131 + avc_m = NULL;
84132 + }
84133 +#endif
84134 +
84135 vma->anon_vma = anon_vma;
84136 anon_vma_chain_link(vma, avc, anon_vma);
84137 allocated = NULL;
84138 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84139
84140 if (unlikely(allocated))
84141 put_anon_vma(allocated);
84142 +
84143 +#ifdef CONFIG_PAX_SEGMEXEC
84144 + if (unlikely(avc_m))
84145 + anon_vma_chain_free(avc_m);
84146 +#endif
84147 +
84148 if (unlikely(avc))
84149 anon_vma_chain_free(avc);
84150 }
84151 return 0;
84152
84153 out_enomem_free_avc:
84154 +
84155 +#ifdef CONFIG_PAX_SEGMEXEC
84156 + if (avc_m)
84157 + anon_vma_chain_free(avc_m);
84158 +#endif
84159 +
84160 anon_vma_chain_free(avc);
84161 out_enomem:
84162 return -ENOMEM;
84163 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
84164 * Attach the anon_vmas from src to dst.
84165 * Returns 0 on success, -ENOMEM on failure.
84166 */
84167 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84168 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
84169 {
84170 struct anon_vma_chain *avc, *pavc;
84171 struct anon_vma *root = NULL;
84172 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84173 * the corresponding VMA in the parent process is attached to.
84174 * Returns 0 on success, non-zero on failure.
84175 */
84176 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
84177 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
84178 {
84179 struct anon_vma_chain *avc;
84180 struct anon_vma *anon_vma;
84181 diff --git a/mm/shmem.c b/mm/shmem.c
84182 index 1c44af7..cefe9a6 100644
84183 --- a/mm/shmem.c
84184 +++ b/mm/shmem.c
84185 @@ -31,7 +31,7 @@
84186 #include <linux/export.h>
84187 #include <linux/swap.h>
84188
84189 -static struct vfsmount *shm_mnt;
84190 +struct vfsmount *shm_mnt;
84191
84192 #ifdef CONFIG_SHMEM
84193 /*
84194 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
84195 #define BOGO_DIRENT_SIZE 20
84196
84197 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
84198 -#define SHORT_SYMLINK_LEN 128
84199 +#define SHORT_SYMLINK_LEN 64
84200
84201 /*
84202 * shmem_fallocate and shmem_writepage communicate via inode->i_private
84203 @@ -2201,6 +2201,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
84204 static int shmem_xattr_validate(const char *name)
84205 {
84206 struct { const char *prefix; size_t len; } arr[] = {
84207 +
84208 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84209 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
84210 +#endif
84211 +
84212 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
84213 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
84214 };
84215 @@ -2256,6 +2261,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
84216 if (err)
84217 return err;
84218
84219 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84220 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
84221 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
84222 + return -EOPNOTSUPP;
84223 + if (size > 8)
84224 + return -EINVAL;
84225 + }
84226 +#endif
84227 +
84228 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84229 }
84230
84231 @@ -2568,8 +2582,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84232 int err = -ENOMEM;
84233
84234 /* Round up to L1_CACHE_BYTES to resist false sharing */
84235 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84236 - L1_CACHE_BYTES), GFP_KERNEL);
84237 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84238 if (!sbinfo)
84239 return -ENOMEM;
84240
84241 diff --git a/mm/slab.c b/mm/slab.c
84242 index 856e4a1..fafb820 100644
84243 --- a/mm/slab.c
84244 +++ b/mm/slab.c
84245 @@ -306,7 +306,7 @@ struct kmem_list3 {
84246 * Need this for bootstrapping a per node allocator.
84247 */
84248 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
84249 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
84250 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
84251 #define CACHE_CACHE 0
84252 #define SIZE_AC MAX_NUMNODES
84253 #define SIZE_L3 (2 * MAX_NUMNODES)
84254 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
84255 if ((x)->max_freeable < i) \
84256 (x)->max_freeable = i; \
84257 } while (0)
84258 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84259 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84260 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84261 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84262 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84263 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84264 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84265 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84266 #else
84267 #define STATS_INC_ACTIVE(x) do { } while (0)
84268 #define STATS_DEC_ACTIVE(x) do { } while (0)
84269 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84270 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84271 */
84272 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84273 - const struct slab *slab, void *obj)
84274 + const struct slab *slab, const void *obj)
84275 {
84276 u32 offset = (obj - slab->s_mem);
84277 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84278 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
84279 struct cache_names {
84280 char *name;
84281 char *name_dma;
84282 + char *name_usercopy;
84283 };
84284
84285 static struct cache_names __initdata cache_names[] = {
84286 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
84287 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
84288 #include <linux/kmalloc_sizes.h>
84289 - {NULL,}
84290 + {NULL}
84291 #undef CACHE
84292 };
84293
84294 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
84295 if (unlikely(gfpflags & GFP_DMA))
84296 return csizep->cs_dmacachep;
84297 #endif
84298 +
84299 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84300 + if (unlikely(gfpflags & GFP_USERCOPY))
84301 + return csizep->cs_usercopycachep;
84302 +#endif
84303 +
84304 return csizep->cs_cachep;
84305 }
84306
84307 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84308 return notifier_from_errno(err);
84309 }
84310
84311 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84312 +static struct notifier_block cpucache_notifier = {
84313 &cpuup_callback, NULL, 0
84314 };
84315
84316 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
84317 */
84318
84319 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
84320 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
84321 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84322
84323 if (INDEX_AC != INDEX_L3)
84324 sizes[INDEX_L3].cs_cachep =
84325 create_kmalloc_cache(names[INDEX_L3].name,
84326 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
84327 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84328
84329 slab_early_init = 0;
84330
84331 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
84332 */
84333 if (!sizes->cs_cachep)
84334 sizes->cs_cachep = create_kmalloc_cache(names->name,
84335 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
84336 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84337
84338 #ifdef CONFIG_ZONE_DMA
84339 sizes->cs_dmacachep = create_kmalloc_cache(
84340 names->name_dma, sizes->cs_size,
84341 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84342 #endif
84343 +
84344 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84345 + sizes->cs_usercopycachep = create_kmalloc_cache(
84346 + names->name_usercopy, sizes->cs_size,
84347 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84348 +#endif
84349 +
84350 sizes++;
84351 names++;
84352 }
84353 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84354
84355 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84356 return;
84357 + VM_BUG_ON(!virt_addr_valid(objp));
84358 local_irq_save(flags);
84359 kfree_debugcheck(objp);
84360 c = virt_to_cache(objp);
84361 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84362 }
84363 /* cpu stats */
84364 {
84365 - unsigned long allochit = atomic_read(&cachep->allochit);
84366 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84367 - unsigned long freehit = atomic_read(&cachep->freehit);
84368 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84369 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84370 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84371 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84372 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84373
84374 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84375 allochit, allocmiss, freehit, freemiss);
84376 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84377 static int __init slab_proc_init(void)
84378 {
84379 #ifdef CONFIG_DEBUG_SLAB_LEAK
84380 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84381 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84382 #endif
84383 return 0;
84384 }
84385 module_init(slab_proc_init);
84386 #endif
84387
84388 +bool is_usercopy_object(const void *ptr)
84389 +{
84390 + struct page *page;
84391 + struct kmem_cache *cachep;
84392 +
84393 + if (ZERO_OR_NULL_PTR(ptr))
84394 + return false;
84395 +
84396 + if (!slab_is_available())
84397 + return false;
84398 +
84399 + if (!virt_addr_valid(ptr))
84400 + return false;
84401 +
84402 + page = virt_to_head_page(ptr);
84403 +
84404 + if (!PageSlab(page))
84405 + return false;
84406 +
84407 + cachep = page->slab_cache;
84408 + return cachep->flags & SLAB_USERCOPY;
84409 +}
84410 +
84411 +#ifdef CONFIG_PAX_USERCOPY
84412 +const char *check_heap_object(const void *ptr, unsigned long n)
84413 +{
84414 + struct page *page;
84415 + struct kmem_cache *cachep;
84416 + struct slab *slabp;
84417 + unsigned int objnr;
84418 + unsigned long offset;
84419 +
84420 + if (ZERO_OR_NULL_PTR(ptr))
84421 + return "<null>";
84422 +
84423 + if (!virt_addr_valid(ptr))
84424 + return NULL;
84425 +
84426 + page = virt_to_head_page(ptr);
84427 +
84428 + if (!PageSlab(page))
84429 + return NULL;
84430 +
84431 + cachep = page->slab_cache;
84432 + if (!(cachep->flags & SLAB_USERCOPY))
84433 + return cachep->name;
84434 +
84435 + slabp = page->slab_page;
84436 + objnr = obj_to_index(cachep, slabp, ptr);
84437 + BUG_ON(objnr >= cachep->num);
84438 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84439 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84440 + return NULL;
84441 +
84442 + return cachep->name;
84443 +}
84444 +#endif
84445 +
84446 /**
84447 * ksize - get the actual amount of memory allocated for a given object
84448 * @objp: Pointer to the object
84449 diff --git a/mm/slab.h b/mm/slab.h
84450 index 34a98d6..73633d1 100644
84451 --- a/mm/slab.h
84452 +++ b/mm/slab.h
84453 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84454
84455 /* Legal flag mask for kmem_cache_create(), for various configurations */
84456 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84457 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84458 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84459
84460 #if defined(CONFIG_DEBUG_SLAB)
84461 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84462 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84463 return s;
84464
84465 page = virt_to_head_page(x);
84466 +
84467 + BUG_ON(!PageSlab(page));
84468 +
84469 cachep = page->slab_cache;
84470 if (slab_equal_or_root(cachep, s))
84471 return cachep;
84472 diff --git a/mm/slab_common.c b/mm/slab_common.c
84473 index 3f3cd97..93b0236 100644
84474 --- a/mm/slab_common.c
84475 +++ b/mm/slab_common.c
84476 @@ -22,7 +22,7 @@
84477
84478 #include "slab.h"
84479
84480 -enum slab_state slab_state;
84481 +enum slab_state slab_state __read_only;
84482 LIST_HEAD(slab_caches);
84483 DEFINE_MUTEX(slab_mutex);
84484 struct kmem_cache *kmem_cache;
84485 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84486
84487 err = __kmem_cache_create(s, flags);
84488 if (!err) {
84489 - s->refcount = 1;
84490 + atomic_set(&s->refcount, 1);
84491 list_add(&s->list, &slab_caches);
84492 memcg_cache_list_add(memcg, s);
84493 } else {
84494 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84495
84496 get_online_cpus();
84497 mutex_lock(&slab_mutex);
84498 - s->refcount--;
84499 - if (!s->refcount) {
84500 + if (atomic_dec_and_test(&s->refcount)) {
84501 list_del(&s->list);
84502
84503 if (!__kmem_cache_shutdown(s)) {
84504 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84505 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84506 name, size, err);
84507
84508 - s->refcount = -1; /* Exempt from merging for now */
84509 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84510 }
84511
84512 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84513 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84514
84515 create_boot_cache(s, name, size, flags);
84516 list_add(&s->list, &slab_caches);
84517 - s->refcount = 1;
84518 + atomic_set(&s->refcount, 1);
84519 return s;
84520 }
84521
84522 diff --git a/mm/slob.c b/mm/slob.c
84523 index eeed4a0..6ee34ec 100644
84524 --- a/mm/slob.c
84525 +++ b/mm/slob.c
84526 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84527 /*
84528 * Return the size of a slob block.
84529 */
84530 -static slobidx_t slob_units(slob_t *s)
84531 +static slobidx_t slob_units(const slob_t *s)
84532 {
84533 if (s->units > 0)
84534 return s->units;
84535 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84536 /*
84537 * Return the next free slob block pointer after this one.
84538 */
84539 -static slob_t *slob_next(slob_t *s)
84540 +static slob_t *slob_next(const slob_t *s)
84541 {
84542 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84543 slobidx_t next;
84544 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84545 /*
84546 * Returns true if s is the last free block in its page.
84547 */
84548 -static int slob_last(slob_t *s)
84549 +static int slob_last(const slob_t *s)
84550 {
84551 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84552 }
84553
84554 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84555 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84556 {
84557 - void *page;
84558 + struct page *page;
84559
84560 #ifdef CONFIG_NUMA
84561 if (node != NUMA_NO_NODE)
84562 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84563 if (!page)
84564 return NULL;
84565
84566 - return page_address(page);
84567 + __SetPageSlab(page);
84568 + return page;
84569 }
84570
84571 -static void slob_free_pages(void *b, int order)
84572 +static void slob_free_pages(struct page *sp, int order)
84573 {
84574 if (current->reclaim_state)
84575 current->reclaim_state->reclaimed_slab += 1 << order;
84576 - free_pages((unsigned long)b, order);
84577 + __ClearPageSlab(sp);
84578 + reset_page_mapcount(sp);
84579 + sp->private = 0;
84580 + __free_pages(sp, order);
84581 }
84582
84583 /*
84584 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84585
84586 /* Not enough space: must allocate a new page */
84587 if (!b) {
84588 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84589 - if (!b)
84590 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84591 + if (!sp)
84592 return NULL;
84593 - sp = virt_to_page(b);
84594 - __SetPageSlab(sp);
84595 + b = page_address(sp);
84596
84597 spin_lock_irqsave(&slob_lock, flags);
84598 sp->units = SLOB_UNITS(PAGE_SIZE);
84599 sp->freelist = b;
84600 + sp->private = 0;
84601 INIT_LIST_HEAD(&sp->list);
84602 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84603 set_slob_page_free(sp, slob_list);
84604 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84605 if (slob_page_free(sp))
84606 clear_slob_page_free(sp);
84607 spin_unlock_irqrestore(&slob_lock, flags);
84608 - __ClearPageSlab(sp);
84609 - page_mapcount_reset(sp);
84610 - slob_free_pages(b, 0);
84611 + slob_free_pages(sp, 0);
84612 return;
84613 }
84614
84615 @@ -424,11 +426,10 @@ out:
84616 */
84617
84618 static __always_inline void *
84619 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84620 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84621 {
84622 - unsigned int *m;
84623 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84624 - void *ret;
84625 + slob_t *m;
84626 + void *ret = NULL;
84627
84628 gfp &= gfp_allowed_mask;
84629
84630 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84631
84632 if (!m)
84633 return NULL;
84634 - *m = size;
84635 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84636 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84637 + m[0].units = size;
84638 + m[1].units = align;
84639 ret = (void *)m + align;
84640
84641 trace_kmalloc_node(caller, ret,
84642 size, size + align, gfp, node);
84643 } else {
84644 unsigned int order = get_order(size);
84645 + struct page *page;
84646
84647 if (likely(order))
84648 gfp |= __GFP_COMP;
84649 - ret = slob_new_pages(gfp, order, node);
84650 + page = slob_new_pages(gfp, order, node);
84651 + if (page) {
84652 + ret = page_address(page);
84653 + page->private = size;
84654 + }
84655
84656 trace_kmalloc_node(caller, ret,
84657 size, PAGE_SIZE << order, gfp, node);
84658 }
84659
84660 - kmemleak_alloc(ret, size, 1, gfp);
84661 + return ret;
84662 +}
84663 +
84664 +static __always_inline void *
84665 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84666 +{
84667 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84668 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84669 +
84670 + if (!ZERO_OR_NULL_PTR(ret))
84671 + kmemleak_alloc(ret, size, 1, gfp);
84672 return ret;
84673 }
84674
84675 @@ -493,34 +512,112 @@ void kfree(const void *block)
84676 return;
84677 kmemleak_free(block);
84678
84679 + VM_BUG_ON(!virt_addr_valid(block));
84680 sp = virt_to_page(block);
84681 - if (PageSlab(sp)) {
84682 + VM_BUG_ON(!PageSlab(sp));
84683 + if (!sp->private) {
84684 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84685 - unsigned int *m = (unsigned int *)(block - align);
84686 - slob_free(m, *m + align);
84687 - } else
84688 + slob_t *m = (slob_t *)(block - align);
84689 + slob_free(m, m[0].units + align);
84690 + } else {
84691 + __ClearPageSlab(sp);
84692 + reset_page_mapcount(sp);
84693 + sp->private = 0;
84694 __free_pages(sp, compound_order(sp));
84695 + }
84696 }
84697 EXPORT_SYMBOL(kfree);
84698
84699 +bool is_usercopy_object(const void *ptr)
84700 +{
84701 + if (!slab_is_available())
84702 + return false;
84703 +
84704 + // PAX: TODO
84705 +
84706 + return false;
84707 +}
84708 +
84709 +#ifdef CONFIG_PAX_USERCOPY
84710 +const char *check_heap_object(const void *ptr, unsigned long n)
84711 +{
84712 + struct page *page;
84713 + const slob_t *free;
84714 + const void *base;
84715 + unsigned long flags;
84716 +
84717 + if (ZERO_OR_NULL_PTR(ptr))
84718 + return "<null>";
84719 +
84720 + if (!virt_addr_valid(ptr))
84721 + return NULL;
84722 +
84723 + page = virt_to_head_page(ptr);
84724 + if (!PageSlab(page))
84725 + return NULL;
84726 +
84727 + if (page->private) {
84728 + base = page;
84729 + if (base <= ptr && n <= page->private - (ptr - base))
84730 + return NULL;
84731 + return "<slob>";
84732 + }
84733 +
84734 + /* some tricky double walking to find the chunk */
84735 + spin_lock_irqsave(&slob_lock, flags);
84736 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84737 + free = page->freelist;
84738 +
84739 + while (!slob_last(free) && (void *)free <= ptr) {
84740 + base = free + slob_units(free);
84741 + free = slob_next(free);
84742 + }
84743 +
84744 + while (base < (void *)free) {
84745 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84746 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84747 + int offset;
84748 +
84749 + if (ptr < base + align)
84750 + break;
84751 +
84752 + offset = ptr - base - align;
84753 + if (offset >= m) {
84754 + base += size;
84755 + continue;
84756 + }
84757 +
84758 + if (n > m - offset)
84759 + break;
84760 +
84761 + spin_unlock_irqrestore(&slob_lock, flags);
84762 + return NULL;
84763 + }
84764 +
84765 + spin_unlock_irqrestore(&slob_lock, flags);
84766 + return "<slob>";
84767 +}
84768 +#endif
84769 +
84770 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84771 size_t ksize(const void *block)
84772 {
84773 struct page *sp;
84774 int align;
84775 - unsigned int *m;
84776 + slob_t *m;
84777
84778 BUG_ON(!block);
84779 if (unlikely(block == ZERO_SIZE_PTR))
84780 return 0;
84781
84782 sp = virt_to_page(block);
84783 - if (unlikely(!PageSlab(sp)))
84784 - return PAGE_SIZE << compound_order(sp);
84785 + VM_BUG_ON(!PageSlab(sp));
84786 + if (sp->private)
84787 + return sp->private;
84788
84789 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84790 - m = (unsigned int *)(block - align);
84791 - return SLOB_UNITS(*m) * SLOB_UNIT;
84792 + m = (slob_t *)(block - align);
84793 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84794 }
84795 EXPORT_SYMBOL(ksize);
84796
84797 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84798
84799 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84800 {
84801 - void *b;
84802 + void *b = NULL;
84803
84804 flags &= gfp_allowed_mask;
84805
84806 lockdep_trace_alloc(flags);
84807
84808 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84809 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84810 +#else
84811 if (c->size < PAGE_SIZE) {
84812 b = slob_alloc(c->size, flags, c->align, node);
84813 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84814 SLOB_UNITS(c->size) * SLOB_UNIT,
84815 flags, node);
84816 } else {
84817 - b = slob_new_pages(flags, get_order(c->size), node);
84818 + struct page *sp;
84819 +
84820 + sp = slob_new_pages(flags, get_order(c->size), node);
84821 + if (sp) {
84822 + b = page_address(sp);
84823 + sp->private = c->size;
84824 + }
84825 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84826 PAGE_SIZE << get_order(c->size),
84827 flags, node);
84828 }
84829 +#endif
84830
84831 if (c->ctor)
84832 c->ctor(b);
84833 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84834
84835 static void __kmem_cache_free(void *b, int size)
84836 {
84837 - if (size < PAGE_SIZE)
84838 + struct page *sp;
84839 +
84840 + sp = virt_to_page(b);
84841 + BUG_ON(!PageSlab(sp));
84842 + if (!sp->private)
84843 slob_free(b, size);
84844 else
84845 - slob_free_pages(b, get_order(size));
84846 + slob_free_pages(sp, get_order(size));
84847 }
84848
84849 static void kmem_rcu_free(struct rcu_head *head)
84850 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84851
84852 void kmem_cache_free(struct kmem_cache *c, void *b)
84853 {
84854 + int size = c->size;
84855 +
84856 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84857 + if (size + c->align < PAGE_SIZE) {
84858 + size += c->align;
84859 + b -= c->align;
84860 + }
84861 +#endif
84862 +
84863 kmemleak_free_recursive(b, c->flags);
84864 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84865 struct slob_rcu *slob_rcu;
84866 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84867 - slob_rcu->size = c->size;
84868 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84869 + slob_rcu->size = size;
84870 call_rcu(&slob_rcu->head, kmem_rcu_free);
84871 } else {
84872 - __kmem_cache_free(b, c->size);
84873 + __kmem_cache_free(b, size);
84874 }
84875
84876 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84877 + trace_kfree(_RET_IP_, b);
84878 +#else
84879 trace_kmem_cache_free(_RET_IP_, b);
84880 +#endif
84881 +
84882 }
84883 EXPORT_SYMBOL(kmem_cache_free);
84884
84885 diff --git a/mm/slub.c b/mm/slub.c
84886 index 4aec537..8043df1 100644
84887 --- a/mm/slub.c
84888 +++ b/mm/slub.c
84889 @@ -197,7 +197,7 @@ struct track {
84890
84891 enum track_item { TRACK_ALLOC, TRACK_FREE };
84892
84893 -#ifdef CONFIG_SYSFS
84894 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84895 static int sysfs_slab_add(struct kmem_cache *);
84896 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84897 static void sysfs_slab_remove(struct kmem_cache *);
84898 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84899 if (!t->addr)
84900 return;
84901
84902 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84903 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84904 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84905 #ifdef CONFIG_STACKTRACE
84906 {
84907 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84908 * Merge control. If this is set then no merging of slab caches will occur.
84909 * (Could be removed. This was introduced to pacify the merge skeptics.)
84910 */
84911 -static int slub_nomerge;
84912 +static int slub_nomerge = 1;
84913
84914 /*
84915 * Calculate the order of allocation given an slab object size.
84916 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84917 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84918 #endif
84919
84920 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84921 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84922 +#endif
84923 +
84924 static int __init setup_slub_min_order(char *str)
84925 {
84926 get_option(&str, &slub_min_order);
84927 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84928 return kmalloc_dma_caches[index];
84929
84930 #endif
84931 +
84932 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84933 + if (flags & SLAB_USERCOPY)
84934 + return kmalloc_usercopy_caches[index];
84935 +
84936 +#endif
84937 +
84938 return kmalloc_caches[index];
84939 }
84940
84941 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84942 EXPORT_SYMBOL(__kmalloc_node);
84943 #endif
84944
84945 +bool is_usercopy_object(const void *ptr)
84946 +{
84947 + struct page *page;
84948 + struct kmem_cache *s;
84949 +
84950 + if (ZERO_OR_NULL_PTR(ptr))
84951 + return false;
84952 +
84953 + if (!slab_is_available())
84954 + return false;
84955 +
84956 + if (!virt_addr_valid(ptr))
84957 + return false;
84958 +
84959 + page = virt_to_head_page(ptr);
84960 +
84961 + if (!PageSlab(page))
84962 + return false;
84963 +
84964 + s = page->slab_cache;
84965 + return s->flags & SLAB_USERCOPY;
84966 +}
84967 +
84968 +#ifdef CONFIG_PAX_USERCOPY
84969 +const char *check_heap_object(const void *ptr, unsigned long n)
84970 +{
84971 + struct page *page;
84972 + struct kmem_cache *s;
84973 + unsigned long offset;
84974 +
84975 + if (ZERO_OR_NULL_PTR(ptr))
84976 + return "<null>";
84977 +
84978 + if (!virt_addr_valid(ptr))
84979 + return NULL;
84980 +
84981 + page = virt_to_head_page(ptr);
84982 +
84983 + if (!PageSlab(page))
84984 + return NULL;
84985 +
84986 + s = page->slab_cache;
84987 + if (!(s->flags & SLAB_USERCOPY))
84988 + return s->name;
84989 +
84990 + offset = (ptr - page_address(page)) % s->size;
84991 + if (offset <= s->object_size && n <= s->object_size - offset)
84992 + return NULL;
84993 +
84994 + return s->name;
84995 +}
84996 +#endif
84997 +
84998 size_t ksize(const void *object)
84999 {
85000 struct page *page;
85001 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
85002 if (unlikely(ZERO_OR_NULL_PTR(x)))
85003 return;
85004
85005 + VM_BUG_ON(!virt_addr_valid(x));
85006 page = virt_to_head_page(x);
85007 if (unlikely(!PageSlab(page))) {
85008 BUG_ON(!PageCompound(page));
85009 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
85010
85011 /* Caches that are not of the two-to-the-power-of size */
85012 if (KMALLOC_MIN_SIZE <= 32) {
85013 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
85014 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
85015 caches++;
85016 }
85017
85018 if (KMALLOC_MIN_SIZE <= 64) {
85019 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
85020 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
85021 caches++;
85022 }
85023
85024 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
85025 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
85026 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
85027 caches++;
85028 }
85029
85030 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
85031 }
85032 }
85033 #endif
85034 +
85035 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85036 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
85037 + struct kmem_cache *s = kmalloc_caches[i];
85038 +
85039 + if (s && s->size) {
85040 + char *name = kasprintf(GFP_NOWAIT,
85041 + "usercopy-kmalloc-%d", s->object_size);
85042 +
85043 + BUG_ON(!name);
85044 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
85045 + s->object_size, SLAB_USERCOPY);
85046 + }
85047 + }
85048 +#endif
85049 +
85050 printk(KERN_INFO
85051 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
85052 " CPUs=%d, Nodes=%d\n",
85053 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
85054 /*
85055 * We may have set a slab to be unmergeable during bootstrap.
85056 */
85057 - if (s->refcount < 0)
85058 + if (atomic_read(&s->refcount) < 0)
85059 return 1;
85060
85061 return 0;
85062 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85063
85064 s = find_mergeable(memcg, size, align, flags, name, ctor);
85065 if (s) {
85066 - s->refcount++;
85067 + atomic_inc(&s->refcount);
85068 /*
85069 * Adjust the object sizes so that we clear
85070 * the complete object on kzalloc.
85071 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85072 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
85073
85074 if (sysfs_slab_alias(s, name)) {
85075 - s->refcount--;
85076 + atomic_dec(&s->refcount);
85077 s = NULL;
85078 }
85079 }
85080 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
85081 return NOTIFY_OK;
85082 }
85083
85084 -static struct notifier_block __cpuinitdata slab_notifier = {
85085 +static struct notifier_block slab_notifier = {
85086 .notifier_call = slab_cpuup_callback
85087 };
85088
85089 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
85090 }
85091 #endif
85092
85093 -#ifdef CONFIG_SYSFS
85094 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85095 static int count_inuse(struct page *page)
85096 {
85097 return page->inuse;
85098 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
85099 validate_slab_cache(kmalloc_caches[9]);
85100 }
85101 #else
85102 -#ifdef CONFIG_SYSFS
85103 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85104 static void resiliency_test(void) {};
85105 #endif
85106 #endif
85107
85108 -#ifdef CONFIG_SYSFS
85109 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85110 enum slab_stat_type {
85111 SL_ALL, /* All slabs */
85112 SL_PARTIAL, /* Only partially allocated slabs */
85113 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
85114
85115 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
85116 {
85117 - return sprintf(buf, "%d\n", s->refcount - 1);
85118 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
85119 }
85120 SLAB_ATTR_RO(aliases);
85121
85122 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
85123 return name;
85124 }
85125
85126 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85127 static int sysfs_slab_add(struct kmem_cache *s)
85128 {
85129 int err;
85130 @@ -5289,7 +5371,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
85131 }
85132
85133 s->kobj.kset = slab_kset;
85134 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
85135 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
85136 if (err) {
85137 kobject_put(&s->kobj);
85138 return err;
85139 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
85140 kobject_del(&s->kobj);
85141 kobject_put(&s->kobj);
85142 }
85143 +#endif
85144
85145 /*
85146 * Need to buffer aliases during bootup until sysfs becomes
85147 @@ -5336,6 +5419,7 @@ struct saved_alias {
85148
85149 static struct saved_alias *alias_list;
85150
85151 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85152 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85153 {
85154 struct saved_alias *al;
85155 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85156 alias_list = al;
85157 return 0;
85158 }
85159 +#endif
85160
85161 static int __init slab_sysfs_init(void)
85162 {
85163 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
85164 index 1b7e22a..3fcd4f3 100644
85165 --- a/mm/sparse-vmemmap.c
85166 +++ b/mm/sparse-vmemmap.c
85167 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
85168 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85169 if (!p)
85170 return NULL;
85171 - pud_populate(&init_mm, pud, p);
85172 + pud_populate_kernel(&init_mm, pud, p);
85173 }
85174 return pud;
85175 }
85176 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
85177 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85178 if (!p)
85179 return NULL;
85180 - pgd_populate(&init_mm, pgd, p);
85181 + pgd_populate_kernel(&init_mm, pgd, p);
85182 }
85183 return pgd;
85184 }
85185 diff --git a/mm/sparse.c b/mm/sparse.c
85186 index 7ca6dc8..6472aa1 100644
85187 --- a/mm/sparse.c
85188 +++ b/mm/sparse.c
85189 @@ -783,7 +783,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
85190
85191 for (i = 0; i < PAGES_PER_SECTION; i++) {
85192 if (PageHWPoison(&memmap[i])) {
85193 - atomic_long_sub(1, &num_poisoned_pages);
85194 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
85195 ClearPageHWPoison(&memmap[i]);
85196 }
85197 }
85198 diff --git a/mm/swap.c b/mm/swap.c
85199 index 8a529a0..154ef26 100644
85200 --- a/mm/swap.c
85201 +++ b/mm/swap.c
85202 @@ -30,6 +30,7 @@
85203 #include <linux/backing-dev.h>
85204 #include <linux/memcontrol.h>
85205 #include <linux/gfp.h>
85206 +#include <linux/hugetlb.h>
85207
85208 #include "internal.h"
85209
85210 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
85211
85212 __page_cache_release(page);
85213 dtor = get_compound_page_dtor(page);
85214 + if (!PageHuge(page))
85215 + BUG_ON(dtor != free_compound_page);
85216 (*dtor)(page);
85217 }
85218
85219 diff --git a/mm/swapfile.c b/mm/swapfile.c
85220 index a1f7772..9e982ac 100644
85221 --- a/mm/swapfile.c
85222 +++ b/mm/swapfile.c
85223 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
85224
85225 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
85226 /* Activity counter to indicate that a swapon or swapoff has occurred */
85227 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
85228 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
85229
85230 static inline unsigned char swap_count(unsigned char ent)
85231 {
85232 @@ -1683,7 +1683,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
85233 }
85234 filp_close(swap_file, NULL);
85235 err = 0;
85236 - atomic_inc(&proc_poll_event);
85237 + atomic_inc_unchecked(&proc_poll_event);
85238 wake_up_interruptible(&proc_poll_wait);
85239
85240 out_dput:
85241 @@ -1700,8 +1700,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85242
85243 poll_wait(file, &proc_poll_wait, wait);
85244
85245 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85246 - seq->poll_event = atomic_read(&proc_poll_event);
85247 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85248 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85249 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85250 }
85251
85252 @@ -1799,7 +1799,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85253 return ret;
85254
85255 seq = file->private_data;
85256 - seq->poll_event = atomic_read(&proc_poll_event);
85257 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85258 return 0;
85259 }
85260
85261 @@ -2142,7 +2142,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85262 (frontswap_map) ? "FS" : "");
85263
85264 mutex_unlock(&swapon_mutex);
85265 - atomic_inc(&proc_poll_event);
85266 + atomic_inc_unchecked(&proc_poll_event);
85267 wake_up_interruptible(&proc_poll_wait);
85268
85269 if (S_ISREG(inode->i_mode))
85270 diff --git a/mm/util.c b/mm/util.c
85271 index ab1424d..7c5bd5a 100644
85272 --- a/mm/util.c
85273 +++ b/mm/util.c
85274 @@ -294,6 +294,12 @@ done:
85275 void arch_pick_mmap_layout(struct mm_struct *mm)
85276 {
85277 mm->mmap_base = TASK_UNMAPPED_BASE;
85278 +
85279 +#ifdef CONFIG_PAX_RANDMMAP
85280 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85281 + mm->mmap_base += mm->delta_mmap;
85282 +#endif
85283 +
85284 mm->get_unmapped_area = arch_get_unmapped_area;
85285 mm->unmap_area = arch_unmap_area;
85286 }
85287 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85288 index 0f751f2..2bc3bd1 100644
85289 --- a/mm/vmalloc.c
85290 +++ b/mm/vmalloc.c
85291 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85292
85293 pte = pte_offset_kernel(pmd, addr);
85294 do {
85295 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85296 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85297 +
85298 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85299 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85300 + BUG_ON(!pte_exec(*pte));
85301 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85302 + continue;
85303 + }
85304 +#endif
85305 +
85306 + {
85307 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85308 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85309 + }
85310 } while (pte++, addr += PAGE_SIZE, addr != end);
85311 }
85312
85313 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85314 pte = pte_alloc_kernel(pmd, addr);
85315 if (!pte)
85316 return -ENOMEM;
85317 +
85318 + pax_open_kernel();
85319 do {
85320 struct page *page = pages[*nr];
85321
85322 - if (WARN_ON(!pte_none(*pte)))
85323 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85324 + if (pgprot_val(prot) & _PAGE_NX)
85325 +#endif
85326 +
85327 + if (!pte_none(*pte)) {
85328 + pax_close_kernel();
85329 + WARN_ON(1);
85330 return -EBUSY;
85331 - if (WARN_ON(!page))
85332 + }
85333 + if (!page) {
85334 + pax_close_kernel();
85335 + WARN_ON(1);
85336 return -ENOMEM;
85337 + }
85338 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85339 (*nr)++;
85340 } while (pte++, addr += PAGE_SIZE, addr != end);
85341 + pax_close_kernel();
85342 return 0;
85343 }
85344
85345 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85346 pmd_t *pmd;
85347 unsigned long next;
85348
85349 - pmd = pmd_alloc(&init_mm, pud, addr);
85350 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85351 if (!pmd)
85352 return -ENOMEM;
85353 do {
85354 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85355 pud_t *pud;
85356 unsigned long next;
85357
85358 - pud = pud_alloc(&init_mm, pgd, addr);
85359 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85360 if (!pud)
85361 return -ENOMEM;
85362 do {
85363 @@ -196,6 +220,12 @@ int is_vmalloc_or_module_addr(const void *x)
85364 if (addr >= MODULES_VADDR && addr < MODULES_END)
85365 return 1;
85366 #endif
85367 +
85368 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85369 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85370 + return 1;
85371 +#endif
85372 +
85373 return is_vmalloc_addr(x);
85374 }
85375
85376 @@ -216,8 +246,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85377
85378 if (!pgd_none(*pgd)) {
85379 pud_t *pud = pud_offset(pgd, addr);
85380 +#ifdef CONFIG_X86
85381 + if (!pud_large(*pud))
85382 +#endif
85383 if (!pud_none(*pud)) {
85384 pmd_t *pmd = pmd_offset(pud, addr);
85385 +#ifdef CONFIG_X86
85386 + if (!pmd_large(*pmd))
85387 +#endif
85388 if (!pmd_none(*pmd)) {
85389 pte_t *ptep, pte;
85390
85391 @@ -329,7 +365,7 @@ static void purge_vmap_area_lazy(void);
85392 * Allocate a region of KVA of the specified size and alignment, within the
85393 * vstart and vend.
85394 */
85395 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85396 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85397 unsigned long align,
85398 unsigned long vstart, unsigned long vend,
85399 int node, gfp_t gfp_mask)
85400 @@ -1328,6 +1364,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85401 struct vm_struct *area;
85402
85403 BUG_ON(in_interrupt());
85404 +
85405 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85406 + if (flags & VM_KERNEXEC) {
85407 + if (start != VMALLOC_START || end != VMALLOC_END)
85408 + return NULL;
85409 + start = (unsigned long)MODULES_EXEC_VADDR;
85410 + end = (unsigned long)MODULES_EXEC_END;
85411 + }
85412 +#endif
85413 +
85414 if (flags & VM_IOREMAP) {
85415 int bit = fls(size);
85416
85417 @@ -1569,6 +1615,11 @@ void *vmap(struct page **pages, unsigned int count,
85418 if (count > totalram_pages)
85419 return NULL;
85420
85421 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85422 + if (!(pgprot_val(prot) & _PAGE_NX))
85423 + flags |= VM_KERNEXEC;
85424 +#endif
85425 +
85426 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85427 __builtin_return_address(0));
85428 if (!area)
85429 @@ -1670,6 +1721,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85430 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85431 goto fail;
85432
85433 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85434 + if (!(pgprot_val(prot) & _PAGE_NX))
85435 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85436 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85437 + else
85438 +#endif
85439 +
85440 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85441 start, end, node, gfp_mask, caller);
85442 if (!area)
85443 @@ -1845,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
85444 * For tight control over page level allocator and protection flags
85445 * use __vmalloc() instead.
85446 */
85447 -
85448 void *vmalloc_exec(unsigned long size)
85449 {
85450 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85451 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85452 NUMA_NO_NODE, __builtin_return_address(0));
85453 }
85454
85455 @@ -2139,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85456 unsigned long uaddr = vma->vm_start;
85457 unsigned long usize = vma->vm_end - vma->vm_start;
85458
85459 + BUG_ON(vma->vm_mirror);
85460 +
85461 if ((PAGE_SIZE-1) & (unsigned long)addr)
85462 return -EINVAL;
85463
85464 @@ -2578,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
85465 v->addr, v->addr + v->size, v->size);
85466
85467 if (v->caller)
85468 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85469 + seq_printf(m, " %pK", v->caller);
85470 +#else
85471 seq_printf(m, " %pS", v->caller);
85472 +#endif
85473
85474 if (v->nr_pages)
85475 seq_printf(m, " pages=%d", v->nr_pages);
85476 diff --git a/mm/vmstat.c b/mm/vmstat.c
85477 index e1d8ed1..253fa3c 100644
85478 --- a/mm/vmstat.c
85479 +++ b/mm/vmstat.c
85480 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85481 *
85482 * vm_stat contains the global counters
85483 */
85484 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85485 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85486 EXPORT_SYMBOL(vm_stat);
85487
85488 #ifdef CONFIG_SMP
85489 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85490 v = p->vm_stat_diff[i];
85491 p->vm_stat_diff[i] = 0;
85492 local_irq_restore(flags);
85493 - atomic_long_add(v, &zone->vm_stat[i]);
85494 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85495 global_diff[i] += v;
85496 #ifdef CONFIG_NUMA
85497 /* 3 seconds idle till flush */
85498 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85499
85500 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85501 if (global_diff[i])
85502 - atomic_long_add(global_diff[i], &vm_stat[i]);
85503 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85504 }
85505
85506 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85507 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85508 if (pset->vm_stat_diff[i]) {
85509 int v = pset->vm_stat_diff[i];
85510 pset->vm_stat_diff[i] = 0;
85511 - atomic_long_add(v, &zone->vm_stat[i]);
85512 - atomic_long_add(v, &vm_stat[i]);
85513 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85514 + atomic_long_add_unchecked(v, &vm_stat[i]);
85515 }
85516 }
85517 #endif
85518 @@ -1224,7 +1224,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85519 return NOTIFY_OK;
85520 }
85521
85522 -static struct notifier_block __cpuinitdata vmstat_notifier =
85523 +static struct notifier_block vmstat_notifier =
85524 { &vmstat_cpuup_callback, NULL, 0 };
85525 #endif
85526
85527 @@ -1239,10 +1239,20 @@ static int __init setup_vmstat(void)
85528 start_cpu_timer(cpu);
85529 #endif
85530 #ifdef CONFIG_PROC_FS
85531 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85532 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85533 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85534 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85535 + {
85536 + mode_t gr_mode = S_IRUGO;
85537 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85538 + gr_mode = S_IRUSR;
85539 +#endif
85540 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85541 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85542 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85543 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85544 +#else
85545 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85546 +#endif
85547 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85548 + }
85549 #endif
85550 return 0;
85551 }
85552 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85553 index 85addcd..c429a13 100644
85554 --- a/net/8021q/vlan.c
85555 +++ b/net/8021q/vlan.c
85556 @@ -114,6 +114,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85557 if (vlan_id)
85558 vlan_vid_del(real_dev, vlan_id);
85559
85560 + /* Take it out of our own structures, but be sure to interlock with
85561 + * HW accelerating devices or SW vlan input packet processing if
85562 + * VLAN is not 0 (leave it there for 802.1p).
85563 + */
85564 + if (vlan_id)
85565 + vlan_vid_del(real_dev, vlan_id);
85566 +
85567 /* Get rid of the vlan's reference to real_dev */
85568 dev_put(real_dev);
85569 }
85570 @@ -496,7 +503,7 @@ out:
85571 return NOTIFY_DONE;
85572 }
85573
85574 -static struct notifier_block vlan_notifier_block __read_mostly = {
85575 +static struct notifier_block vlan_notifier_block = {
85576 .notifier_call = vlan_device_event,
85577 };
85578
85579 @@ -571,8 +578,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85580 err = -EPERM;
85581 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85582 break;
85583 - if ((args.u.name_type >= 0) &&
85584 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85585 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85586 struct vlan_net *vn;
85587
85588 vn = net_generic(net, vlan_net_id);
85589 diff --git a/net/9p/mod.c b/net/9p/mod.c
85590 index 6ab36ae..6f1841b 100644
85591 --- a/net/9p/mod.c
85592 +++ b/net/9p/mod.c
85593 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85594 void v9fs_register_trans(struct p9_trans_module *m)
85595 {
85596 spin_lock(&v9fs_trans_lock);
85597 - list_add_tail(&m->list, &v9fs_trans_list);
85598 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85599 spin_unlock(&v9fs_trans_lock);
85600 }
85601 EXPORT_SYMBOL(v9fs_register_trans);
85602 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85603 void v9fs_unregister_trans(struct p9_trans_module *m)
85604 {
85605 spin_lock(&v9fs_trans_lock);
85606 - list_del_init(&m->list);
85607 + pax_list_del_init((struct list_head *)&m->list);
85608 spin_unlock(&v9fs_trans_lock);
85609 }
85610 EXPORT_SYMBOL(v9fs_unregister_trans);
85611 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85612 index 02efb25..41541a9 100644
85613 --- a/net/9p/trans_fd.c
85614 +++ b/net/9p/trans_fd.c
85615 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85616 oldfs = get_fs();
85617 set_fs(get_ds());
85618 /* The cast to a user pointer is valid due to the set_fs() */
85619 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85620 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85621 set_fs(oldfs);
85622
85623 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85624 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85625 index 876fbe8..8bbea9f 100644
85626 --- a/net/atm/atm_misc.c
85627 +++ b/net/atm/atm_misc.c
85628 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85629 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85630 return 1;
85631 atm_return(vcc, truesize);
85632 - atomic_inc(&vcc->stats->rx_drop);
85633 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85634 return 0;
85635 }
85636 EXPORT_SYMBOL(atm_charge);
85637 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85638 }
85639 }
85640 atm_return(vcc, guess);
85641 - atomic_inc(&vcc->stats->rx_drop);
85642 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85643 return NULL;
85644 }
85645 EXPORT_SYMBOL(atm_alloc_charge);
85646 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85647
85648 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85649 {
85650 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85651 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85652 __SONET_ITEMS
85653 #undef __HANDLE_ITEM
85654 }
85655 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85656
85657 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85658 {
85659 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85660 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85661 __SONET_ITEMS
85662 #undef __HANDLE_ITEM
85663 }
85664 diff --git a/net/atm/lec.h b/net/atm/lec.h
85665 index a86aff9..3a0d6f6 100644
85666 --- a/net/atm/lec.h
85667 +++ b/net/atm/lec.h
85668 @@ -48,7 +48,7 @@ struct lane2_ops {
85669 const u8 *tlvs, u32 sizeoftlvs);
85670 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85671 const u8 *tlvs, u32 sizeoftlvs);
85672 -};
85673 +} __no_const;
85674
85675 /*
85676 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85677 diff --git a/net/atm/proc.c b/net/atm/proc.c
85678 index 6ac35ff..ac0e136 100644
85679 --- a/net/atm/proc.c
85680 +++ b/net/atm/proc.c
85681 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85682 const struct k_atm_aal_stats *stats)
85683 {
85684 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85685 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85686 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85687 - atomic_read(&stats->rx_drop));
85688 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85689 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85690 + atomic_read_unchecked(&stats->rx_drop));
85691 }
85692
85693 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85694 diff --git a/net/atm/resources.c b/net/atm/resources.c
85695 index 0447d5d..3cf4728 100644
85696 --- a/net/atm/resources.c
85697 +++ b/net/atm/resources.c
85698 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85699 static void copy_aal_stats(struct k_atm_aal_stats *from,
85700 struct atm_aal_stats *to)
85701 {
85702 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85703 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85704 __AAL_STAT_ITEMS
85705 #undef __HANDLE_ITEM
85706 }
85707 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85708 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85709 struct atm_aal_stats *to)
85710 {
85711 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85712 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85713 __AAL_STAT_ITEMS
85714 #undef __HANDLE_ITEM
85715 }
85716 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85717 index d5744b7..506bae3 100644
85718 --- a/net/ax25/sysctl_net_ax25.c
85719 +++ b/net/ax25/sysctl_net_ax25.c
85720 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85721 {
85722 char path[sizeof("net/ax25/") + IFNAMSIZ];
85723 int k;
85724 - struct ctl_table *table;
85725 + ctl_table_no_const *table;
85726
85727 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85728 if (!table)
85729 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85730 index a5bb0a7..e1d8b97 100644
85731 --- a/net/batman-adv/bat_iv_ogm.c
85732 +++ b/net/batman-adv/bat_iv_ogm.c
85733 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85734
85735 /* randomize initial seqno to avoid collision */
85736 get_random_bytes(&random_seqno, sizeof(random_seqno));
85737 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85738 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85739
85740 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85741 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85742 @@ -611,9 +611,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85743 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85744
85745 /* change sequence number to network order */
85746 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85747 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85748 batadv_ogm_packet->seqno = htonl(seqno);
85749 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85750 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85751
85752 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85753 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85754 @@ -1013,7 +1013,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85755 return;
85756
85757 /* could be changed by schedule_own_packet() */
85758 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85759 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85760
85761 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85762 has_directlink_flag = 1;
85763 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85764 index 368219e..53f56f9 100644
85765 --- a/net/batman-adv/hard-interface.c
85766 +++ b/net/batman-adv/hard-interface.c
85767 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85768 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85769 dev_add_pack(&hard_iface->batman_adv_ptype);
85770
85771 - atomic_set(&hard_iface->frag_seqno, 1);
85772 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85773 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85774 hard_iface->net_dev->name);
85775
85776 @@ -514,7 +514,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85777 /* This can't be called via a bat_priv callback because
85778 * we have no bat_priv yet.
85779 */
85780 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85781 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85782 hard_iface->bat_iv.ogm_buff = NULL;
85783
85784 return hard_iface;
85785 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85786 index 2711e87..4ca48fa 100644
85787 --- a/net/batman-adv/soft-interface.c
85788 +++ b/net/batman-adv/soft-interface.c
85789 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85790 primary_if->net_dev->dev_addr, ETH_ALEN);
85791
85792 /* set broadcast sequence number */
85793 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85794 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85795 bcast_packet->seqno = htonl(seqno);
85796
85797 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85798 @@ -527,7 +527,7 @@ struct net_device *batadv_softif_create(const char *name)
85799 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85800
85801 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85802 - atomic_set(&bat_priv->bcast_seqno, 1);
85803 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85804 atomic_set(&bat_priv->tt.vn, 0);
85805 atomic_set(&bat_priv->tt.local_changes, 0);
85806 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85807 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85808 index 4cd87a0..348e705 100644
85809 --- a/net/batman-adv/types.h
85810 +++ b/net/batman-adv/types.h
85811 @@ -51,7 +51,7 @@
85812 struct batadv_hard_iface_bat_iv {
85813 unsigned char *ogm_buff;
85814 int ogm_buff_len;
85815 - atomic_t ogm_seqno;
85816 + atomic_unchecked_t ogm_seqno;
85817 };
85818
85819 /**
85820 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
85821 int16_t if_num;
85822 char if_status;
85823 struct net_device *net_dev;
85824 - atomic_t frag_seqno;
85825 + atomic_unchecked_t frag_seqno;
85826 struct kobject *hardif_obj;
85827 atomic_t refcount;
85828 struct packet_type batman_adv_ptype;
85829 @@ -495,7 +495,7 @@ struct batadv_priv {
85830 #ifdef CONFIG_BATMAN_ADV_DEBUG
85831 atomic_t log_level;
85832 #endif
85833 - atomic_t bcast_seqno;
85834 + atomic_unchecked_t bcast_seqno;
85835 atomic_t bcast_queue_left;
85836 atomic_t batman_queue_left;
85837 char num_ifaces;
85838 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85839 index 50e079f..49ce2d2 100644
85840 --- a/net/batman-adv/unicast.c
85841 +++ b/net/batman-adv/unicast.c
85842 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85843 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85844 frag2->flags = large_tail;
85845
85846 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85847 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85848 frag1->seqno = htons(seqno - 1);
85849 frag2->seqno = htons(seqno);
85850
85851 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
85852 index b88605f..958e3e2 100644
85853 --- a/net/bluetooth/hci_core.c
85854 +++ b/net/bluetooth/hci_core.c
85855 @@ -1793,16 +1793,16 @@ int hci_register_dev(struct hci_dev *hdev)
85856 list_add(&hdev->list, &hci_dev_list);
85857 write_unlock(&hci_dev_list_lock);
85858
85859 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
85860 - WQ_MEM_RECLAIM, 1);
85861 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
85862 + WQ_MEM_RECLAIM, 1, hdev->name);
85863 if (!hdev->workqueue) {
85864 error = -ENOMEM;
85865 goto err;
85866 }
85867
85868 - hdev->req_workqueue = alloc_workqueue(hdev->name,
85869 + hdev->req_workqueue = alloc_workqueue("%s",
85870 WQ_HIGHPRI | WQ_UNBOUND |
85871 - WQ_MEM_RECLAIM, 1);
85872 + WQ_MEM_RECLAIM, 1, hdev->name);
85873 if (!hdev->req_workqueue) {
85874 destroy_workqueue(hdev->workqueue);
85875 error = -ENOMEM;
85876 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85877 index 6a93614..1415549 100644
85878 --- a/net/bluetooth/hci_sock.c
85879 +++ b/net/bluetooth/hci_sock.c
85880 @@ -929,7 +929,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85881 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85882 }
85883
85884 - len = min_t(unsigned int, len, sizeof(uf));
85885 + len = min((size_t)len, sizeof(uf));
85886 if (copy_from_user(&uf, optval, len)) {
85887 err = -EFAULT;
85888 break;
85889 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85890 index c5f9cd6..dfc8ec1 100644
85891 --- a/net/bluetooth/l2cap_core.c
85892 +++ b/net/bluetooth/l2cap_core.c
85893 @@ -2743,6 +2743,9 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, u8 code,
85894 BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %u",
85895 conn, code, ident, dlen);
85896
85897 + if (conn->mtu < L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE)
85898 + return NULL;
85899 +
85900 len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen;
85901 count = min_t(unsigned int, conn->mtu, len);
85902
85903 @@ -3395,8 +3398,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85904 break;
85905
85906 case L2CAP_CONF_RFC:
85907 - if (olen == sizeof(rfc))
85908 - memcpy(&rfc, (void *)val, olen);
85909 + if (olen != sizeof(rfc))
85910 + break;
85911 +
85912 + memcpy(&rfc, (void *)val, olen);
85913
85914 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85915 rfc.mode != chan->mode)
85916 @@ -4221,7 +4226,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn,
85917 struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data;
85918 u16 type, result;
85919
85920 - if (cmd_len != sizeof(*rsp))
85921 + if (cmd_len < sizeof(*rsp))
85922 return -EPROTO;
85923
85924 type = __le16_to_cpu(rsp->type);
85925 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85926 index 1bcfb84..dad9f98 100644
85927 --- a/net/bluetooth/l2cap_sock.c
85928 +++ b/net/bluetooth/l2cap_sock.c
85929 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85930 struct sock *sk = sock->sk;
85931 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85932 struct l2cap_options opts;
85933 - int len, err = 0;
85934 + int err = 0;
85935 + size_t len = optlen;
85936 u32 opt;
85937
85938 BT_DBG("sk %p", sk);
85939 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85940 opts.max_tx = chan->max_tx;
85941 opts.txwin_size = chan->tx_win;
85942
85943 - len = min_t(unsigned int, sizeof(opts), optlen);
85944 + len = min(sizeof(opts), len);
85945 if (copy_from_user((char *) &opts, optval, len)) {
85946 err = -EFAULT;
85947 break;
85948 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85949 struct bt_security sec;
85950 struct bt_power pwr;
85951 struct l2cap_conn *conn;
85952 - int len, err = 0;
85953 + int err = 0;
85954 + size_t len = optlen;
85955 u32 opt;
85956
85957 BT_DBG("sk %p", sk);
85958 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85959
85960 sec.level = BT_SECURITY_LOW;
85961
85962 - len = min_t(unsigned int, sizeof(sec), optlen);
85963 + len = min(sizeof(sec), len);
85964 if (copy_from_user((char *) &sec, optval, len)) {
85965 err = -EFAULT;
85966 break;
85967 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85968
85969 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85970
85971 - len = min_t(unsigned int, sizeof(pwr), optlen);
85972 + len = min(sizeof(pwr), len);
85973 if (copy_from_user((char *) &pwr, optval, len)) {
85974 err = -EFAULT;
85975 break;
85976 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85977 index 7c9224b..381009e 100644
85978 --- a/net/bluetooth/rfcomm/sock.c
85979 +++ b/net/bluetooth/rfcomm/sock.c
85980 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85981 struct sock *sk = sock->sk;
85982 struct bt_security sec;
85983 int err = 0;
85984 - size_t len;
85985 + size_t len = optlen;
85986 u32 opt;
85987
85988 BT_DBG("sk %p", sk);
85989 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85990
85991 sec.level = BT_SECURITY_LOW;
85992
85993 - len = min_t(unsigned int, sizeof(sec), optlen);
85994 + len = min(sizeof(sec), len);
85995 if (copy_from_user((char *) &sec, optval, len)) {
85996 err = -EFAULT;
85997 break;
85998 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85999 index b6e44ad..5b0d514 100644
86000 --- a/net/bluetooth/rfcomm/tty.c
86001 +++ b/net/bluetooth/rfcomm/tty.c
86002 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
86003 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
86004
86005 spin_lock_irqsave(&dev->port.lock, flags);
86006 - if (dev->port.count > 0) {
86007 + if (atomic_read(&dev->port.count) > 0) {
86008 spin_unlock_irqrestore(&dev->port.lock, flags);
86009 return;
86010 }
86011 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
86012 return -ENODEV;
86013
86014 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
86015 - dev->channel, dev->port.count);
86016 + dev->channel, atomic_read(&dev->port.count));
86017
86018 spin_lock_irqsave(&dev->port.lock, flags);
86019 - if (++dev->port.count > 1) {
86020 + if (atomic_inc_return(&dev->port.count) > 1) {
86021 spin_unlock_irqrestore(&dev->port.lock, flags);
86022 return 0;
86023 }
86024 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
86025 return;
86026
86027 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
86028 - dev->port.count);
86029 + atomic_read(&dev->port.count));
86030
86031 spin_lock_irqsave(&dev->port.lock, flags);
86032 - if (!--dev->port.count) {
86033 + if (!atomic_dec_return(&dev->port.count)) {
86034 spin_unlock_irqrestore(&dev->port.lock, flags);
86035 if (dev->tty_dev->parent)
86036 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
86037 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
86038 index 8d493c9..3849e49 100644
86039 --- a/net/bridge/netfilter/ebtables.c
86040 +++ b/net/bridge/netfilter/ebtables.c
86041 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86042 tmp.valid_hooks = t->table->valid_hooks;
86043 }
86044 mutex_unlock(&ebt_mutex);
86045 - if (copy_to_user(user, &tmp, *len) != 0){
86046 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
86047 BUGPRINT("c2u Didn't work\n");
86048 ret = -EFAULT;
86049 break;
86050 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86051 goto out;
86052 tmp.valid_hooks = t->valid_hooks;
86053
86054 - if (copy_to_user(user, &tmp, *len) != 0) {
86055 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86056 ret = -EFAULT;
86057 break;
86058 }
86059 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86060 tmp.entries_size = t->table->entries_size;
86061 tmp.valid_hooks = t->table->valid_hooks;
86062
86063 - if (copy_to_user(user, &tmp, *len) != 0) {
86064 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86065 ret = -EFAULT;
86066 break;
86067 }
86068 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
86069 index a376ec1..1fbd6be 100644
86070 --- a/net/caif/cfctrl.c
86071 +++ b/net/caif/cfctrl.c
86072 @@ -10,6 +10,7 @@
86073 #include <linux/spinlock.h>
86074 #include <linux/slab.h>
86075 #include <linux/pkt_sched.h>
86076 +#include <linux/sched.h>
86077 #include <net/caif/caif_layer.h>
86078 #include <net/caif/cfpkt.h>
86079 #include <net/caif/cfctrl.h>
86080 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
86081 memset(&dev_info, 0, sizeof(dev_info));
86082 dev_info.id = 0xff;
86083 cfsrvl_init(&this->serv, 0, &dev_info, false);
86084 - atomic_set(&this->req_seq_no, 1);
86085 - atomic_set(&this->rsp_seq_no, 1);
86086 + atomic_set_unchecked(&this->req_seq_no, 1);
86087 + atomic_set_unchecked(&this->rsp_seq_no, 1);
86088 this->serv.layer.receive = cfctrl_recv;
86089 sprintf(this->serv.layer.name, "ctrl");
86090 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
86091 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
86092 struct cfctrl_request_info *req)
86093 {
86094 spin_lock_bh(&ctrl->info_list_lock);
86095 - atomic_inc(&ctrl->req_seq_no);
86096 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
86097 + atomic_inc_unchecked(&ctrl->req_seq_no);
86098 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
86099 list_add_tail(&req->list, &ctrl->list);
86100 spin_unlock_bh(&ctrl->info_list_lock);
86101 }
86102 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
86103 if (p != first)
86104 pr_warn("Requests are not received in order\n");
86105
86106 - atomic_set(&ctrl->rsp_seq_no,
86107 + atomic_set_unchecked(&ctrl->rsp_seq_no,
86108 p->sequence_no);
86109 list_del(&p->list);
86110 goto out;
86111 diff --git a/net/can/af_can.c b/net/can/af_can.c
86112 index c48e522..1223690 100644
86113 --- a/net/can/af_can.c
86114 +++ b/net/can/af_can.c
86115 @@ -870,7 +870,7 @@ static const struct net_proto_family can_family_ops = {
86116 };
86117
86118 /* notifier block for netdevice event */
86119 -static struct notifier_block can_netdev_notifier __read_mostly = {
86120 +static struct notifier_block can_netdev_notifier = {
86121 .notifier_call = can_notifier,
86122 };
86123
86124 diff --git a/net/can/gw.c b/net/can/gw.c
86125 index 117814a..ad4fb73 100644
86126 --- a/net/can/gw.c
86127 +++ b/net/can/gw.c
86128 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
86129 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
86130
86131 static HLIST_HEAD(cgw_list);
86132 -static struct notifier_block notifier;
86133
86134 static struct kmem_cache *cgw_cache __read_mostly;
86135
86136 @@ -928,6 +927,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
86137 return err;
86138 }
86139
86140 +static struct notifier_block notifier = {
86141 + .notifier_call = cgw_notifier
86142 +};
86143 +
86144 static __init int cgw_module_init(void)
86145 {
86146 /* sanitize given module parameter */
86147 @@ -943,7 +946,6 @@ static __init int cgw_module_init(void)
86148 return -ENOMEM;
86149
86150 /* set notifier */
86151 - notifier.notifier_call = cgw_notifier;
86152 register_netdevice_notifier(&notifier);
86153
86154 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
86155 diff --git a/net/compat.c b/net/compat.c
86156 index f0a1ba6..0541331 100644
86157 --- a/net/compat.c
86158 +++ b/net/compat.c
86159 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
86160 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
86161 __get_user(kmsg->msg_flags, &umsg->msg_flags))
86162 return -EFAULT;
86163 - kmsg->msg_name = compat_ptr(tmp1);
86164 - kmsg->msg_iov = compat_ptr(tmp2);
86165 - kmsg->msg_control = compat_ptr(tmp3);
86166 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
86167 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
86168 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
86169 return 0;
86170 }
86171
86172 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86173
86174 if (kern_msg->msg_namelen) {
86175 if (mode == VERIFY_READ) {
86176 - int err = move_addr_to_kernel(kern_msg->msg_name,
86177 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
86178 kern_msg->msg_namelen,
86179 kern_address);
86180 if (err < 0)
86181 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86182 kern_msg->msg_name = NULL;
86183
86184 tot_len = iov_from_user_compat_to_kern(kern_iov,
86185 - (struct compat_iovec __user *)kern_msg->msg_iov,
86186 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
86187 kern_msg->msg_iovlen);
86188 if (tot_len >= 0)
86189 kern_msg->msg_iov = kern_iov;
86190 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86191
86192 #define CMSG_COMPAT_FIRSTHDR(msg) \
86193 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
86194 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
86195 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
86196 (struct compat_cmsghdr __user *)NULL)
86197
86198 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
86199 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
86200 (ucmlen) <= (unsigned long) \
86201 ((mhdr)->msg_controllen - \
86202 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
86203 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
86204
86205 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
86206 struct compat_cmsghdr __user *cmsg, int cmsg_len)
86207 {
86208 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
86209 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
86210 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
86211 msg->msg_controllen)
86212 return NULL;
86213 return (struct compat_cmsghdr __user *)ptr;
86214 @@ -219,7 +219,7 @@ Efault:
86215
86216 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
86217 {
86218 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86219 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86220 struct compat_cmsghdr cmhdr;
86221 struct compat_timeval ctv;
86222 struct compat_timespec cts[3];
86223 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
86224
86225 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
86226 {
86227 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86228 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86229 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
86230 int fdnum = scm->fp->count;
86231 struct file **fp = scm->fp->fp;
86232 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
86233 return -EFAULT;
86234 old_fs = get_fs();
86235 set_fs(KERNEL_DS);
86236 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
86237 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
86238 set_fs(old_fs);
86239
86240 return err;
86241 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
86242 len = sizeof(ktime);
86243 old_fs = get_fs();
86244 set_fs(KERNEL_DS);
86245 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
86246 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
86247 set_fs(old_fs);
86248
86249 if (!err) {
86250 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86251 case MCAST_JOIN_GROUP:
86252 case MCAST_LEAVE_GROUP:
86253 {
86254 - struct compat_group_req __user *gr32 = (void *)optval;
86255 + struct compat_group_req __user *gr32 = (void __user *)optval;
86256 struct group_req __user *kgr =
86257 compat_alloc_user_space(sizeof(struct group_req));
86258 u32 interface;
86259 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86260 case MCAST_BLOCK_SOURCE:
86261 case MCAST_UNBLOCK_SOURCE:
86262 {
86263 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86264 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86265 struct group_source_req __user *kgsr = compat_alloc_user_space(
86266 sizeof(struct group_source_req));
86267 u32 interface;
86268 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86269 }
86270 case MCAST_MSFILTER:
86271 {
86272 - struct compat_group_filter __user *gf32 = (void *)optval;
86273 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86274 struct group_filter __user *kgf;
86275 u32 interface, fmode, numsrc;
86276
86277 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86278 char __user *optval, int __user *optlen,
86279 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86280 {
86281 - struct compat_group_filter __user *gf32 = (void *)optval;
86282 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86283 struct group_filter __user *kgf;
86284 int __user *koptlen;
86285 u32 interface, fmode, numsrc;
86286 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86287
86288 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86289 return -EINVAL;
86290 - if (copy_from_user(a, args, nas[call]))
86291 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86292 return -EFAULT;
86293 a0 = a[0];
86294 a1 = a[1];
86295 diff --git a/net/core/datagram.c b/net/core/datagram.c
86296 index 368f9c3..f82d4a3 100644
86297 --- a/net/core/datagram.c
86298 +++ b/net/core/datagram.c
86299 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86300 }
86301
86302 kfree_skb(skb);
86303 - atomic_inc(&sk->sk_drops);
86304 + atomic_inc_unchecked(&sk->sk_drops);
86305 sk_mem_reclaim_partial(sk);
86306
86307 return err;
86308 diff --git a/net/core/dev.c b/net/core/dev.c
86309 index c9eb9e6..922c789 100644
86310 --- a/net/core/dev.c
86311 +++ b/net/core/dev.c
86312 @@ -1617,7 +1617,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86313 {
86314 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86315 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86316 - atomic_long_inc(&dev->rx_dropped);
86317 + atomic_long_inc_unchecked(&dev->rx_dropped);
86318 kfree_skb(skb);
86319 return NET_RX_DROP;
86320 }
86321 @@ -1626,7 +1626,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86322 skb_orphan(skb);
86323
86324 if (unlikely(!is_skb_forwardable(dev, skb))) {
86325 - atomic_long_inc(&dev->rx_dropped);
86326 + atomic_long_inc_unchecked(&dev->rx_dropped);
86327 kfree_skb(skb);
86328 return NET_RX_DROP;
86329 }
86330 @@ -2351,7 +2351,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86331
86332 struct dev_gso_cb {
86333 void (*destructor)(struct sk_buff *skb);
86334 -};
86335 +} __no_const;
86336
86337 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86338
86339 @@ -3099,7 +3099,7 @@ enqueue:
86340
86341 local_irq_restore(flags);
86342
86343 - atomic_long_inc(&skb->dev->rx_dropped);
86344 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86345 kfree_skb(skb);
86346 return NET_RX_DROP;
86347 }
86348 @@ -3171,7 +3171,7 @@ int netif_rx_ni(struct sk_buff *skb)
86349 }
86350 EXPORT_SYMBOL(netif_rx_ni);
86351
86352 -static void net_tx_action(struct softirq_action *h)
86353 +static void net_tx_action(void)
86354 {
86355 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86356
86357 @@ -3496,7 +3496,7 @@ ncls:
86358 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86359 } else {
86360 drop:
86361 - atomic_long_inc(&skb->dev->rx_dropped);
86362 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86363 kfree_skb(skb);
86364 /* Jamal, now you will not able to escape explaining
86365 * me how you were going to use this. :-)
86366 @@ -4101,7 +4101,7 @@ void netif_napi_del(struct napi_struct *napi)
86367 }
86368 EXPORT_SYMBOL(netif_napi_del);
86369
86370 -static void net_rx_action(struct softirq_action *h)
86371 +static void net_rx_action(void)
86372 {
86373 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86374 unsigned long time_limit = jiffies + 2;
86375 @@ -5528,7 +5528,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86376 } else {
86377 netdev_stats_to_stats64(storage, &dev->stats);
86378 }
86379 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86380 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86381 return storage;
86382 }
86383 EXPORT_SYMBOL(dev_get_stats);
86384 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
86385 index 6cc0481..59cfb00 100644
86386 --- a/net/core/dev_ioctl.c
86387 +++ b/net/core/dev_ioctl.c
86388 @@ -376,9 +376,13 @@ void dev_load(struct net *net, const char *name)
86389 if (no_module && capable(CAP_NET_ADMIN))
86390 no_module = request_module("netdev-%s", name);
86391 if (no_module && capable(CAP_SYS_MODULE)) {
86392 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86393 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86394 +#else
86395 if (!request_module("%s", name))
86396 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86397 name);
86398 +#endif
86399 }
86400 }
86401 EXPORT_SYMBOL(dev_load);
86402 diff --git a/net/core/flow.c b/net/core/flow.c
86403 index 2bfd081..53c6058 100644
86404 --- a/net/core/flow.c
86405 +++ b/net/core/flow.c
86406 @@ -61,7 +61,7 @@ struct flow_cache {
86407 struct timer_list rnd_timer;
86408 };
86409
86410 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86411 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86412 EXPORT_SYMBOL(flow_cache_genid);
86413 static struct flow_cache flow_cache_global;
86414 static struct kmem_cache *flow_cachep __read_mostly;
86415 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86416
86417 static int flow_entry_valid(struct flow_cache_entry *fle)
86418 {
86419 - if (atomic_read(&flow_cache_genid) != fle->genid)
86420 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86421 return 0;
86422 if (fle->object && !fle->object->ops->check(fle->object))
86423 return 0;
86424 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86425 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86426 fcp->hash_count++;
86427 }
86428 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86429 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86430 flo = fle->object;
86431 if (!flo)
86432 goto ret_object;
86433 @@ -279,7 +279,7 @@ nocache:
86434 }
86435 flo = resolver(net, key, family, dir, flo, ctx);
86436 if (fle) {
86437 - fle->genid = atomic_read(&flow_cache_genid);
86438 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86439 if (!IS_ERR(flo))
86440 fle->object = flo;
86441 else
86442 diff --git a/net/core/iovec.c b/net/core/iovec.c
86443 index 7e7aeb0..2a998cb 100644
86444 --- a/net/core/iovec.c
86445 +++ b/net/core/iovec.c
86446 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86447 if (m->msg_namelen) {
86448 if (mode == VERIFY_READ) {
86449 void __user *namep;
86450 - namep = (void __user __force *) m->msg_name;
86451 + namep = (void __force_user *) m->msg_name;
86452 err = move_addr_to_kernel(namep, m->msg_namelen,
86453 address);
86454 if (err < 0)
86455 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86456 }
86457
86458 size = m->msg_iovlen * sizeof(struct iovec);
86459 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86460 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86461 return -EFAULT;
86462
86463 m->msg_iov = iov;
86464 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86465 index 3863b8f..85c99a6 100644
86466 --- a/net/core/neighbour.c
86467 +++ b/net/core/neighbour.c
86468 @@ -2778,7 +2778,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86469 size_t *lenp, loff_t *ppos)
86470 {
86471 int size, ret;
86472 - ctl_table tmp = *ctl;
86473 + ctl_table_no_const tmp = *ctl;
86474
86475 tmp.extra1 = &zero;
86476 tmp.extra2 = &unres_qlen_max;
86477 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
86478 index 3174f19..5810985 100644
86479 --- a/net/core/net-procfs.c
86480 +++ b/net/core/net-procfs.c
86481 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86482 else
86483 seq_printf(seq, "%04x", ntohs(pt->type));
86484
86485 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86486 + seq_printf(seq, " %-8s %pF\n",
86487 + pt->dev ? pt->dev->name : "", NULL);
86488 +#else
86489 seq_printf(seq, " %-8s %pF\n",
86490 pt->dev ? pt->dev->name : "", pt->func);
86491 +#endif
86492 }
86493
86494 return 0;
86495 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86496 index 7427ab5..389f411 100644
86497 --- a/net/core/net-sysfs.c
86498 +++ b/net/core/net-sysfs.c
86499 @@ -1321,7 +1321,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86500 }
86501 EXPORT_SYMBOL(netdev_class_remove_file);
86502
86503 -int netdev_kobject_init(void)
86504 +int __init netdev_kobject_init(void)
86505 {
86506 kobj_ns_type_register(&net_ns_type_operations);
86507 return class_register(&net_class);
86508 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86509 index 80e271d..2980cc2 100644
86510 --- a/net/core/net_namespace.c
86511 +++ b/net/core/net_namespace.c
86512 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86513 int error;
86514 LIST_HEAD(net_exit_list);
86515
86516 - list_add_tail(&ops->list, list);
86517 + pax_list_add_tail((struct list_head *)&ops->list, list);
86518 if (ops->init || (ops->id && ops->size)) {
86519 for_each_net(net) {
86520 error = ops_init(ops, net);
86521 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86522
86523 out_undo:
86524 /* If I have an error cleanup all namespaces I initialized */
86525 - list_del(&ops->list);
86526 + pax_list_del((struct list_head *)&ops->list);
86527 ops_exit_list(ops, &net_exit_list);
86528 ops_free_list(ops, &net_exit_list);
86529 return error;
86530 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86531 struct net *net;
86532 LIST_HEAD(net_exit_list);
86533
86534 - list_del(&ops->list);
86535 + pax_list_del((struct list_head *)&ops->list);
86536 for_each_net(net)
86537 list_add_tail(&net->exit_list, &net_exit_list);
86538 ops_exit_list(ops, &net_exit_list);
86539 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86540 mutex_lock(&net_mutex);
86541 error = register_pernet_operations(&pernet_list, ops);
86542 if (!error && (first_device == &pernet_list))
86543 - first_device = &ops->list;
86544 + first_device = (struct list_head *)&ops->list;
86545 mutex_unlock(&net_mutex);
86546 return error;
86547 }
86548 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86549 index 23854b5..ff4fda4 100644
86550 --- a/net/core/rtnetlink.c
86551 +++ b/net/core/rtnetlink.c
86552 @@ -58,7 +58,7 @@ struct rtnl_link {
86553 rtnl_doit_func doit;
86554 rtnl_dumpit_func dumpit;
86555 rtnl_calcit_func calcit;
86556 -};
86557 +} __no_const;
86558
86559 static DEFINE_MUTEX(rtnl_mutex);
86560
86561 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86562 if (rtnl_link_ops_get(ops->kind))
86563 return -EEXIST;
86564
86565 - if (!ops->dellink)
86566 - ops->dellink = unregister_netdevice_queue;
86567 + if (!ops->dellink) {
86568 + pax_open_kernel();
86569 + *(void **)&ops->dellink = unregister_netdevice_queue;
86570 + pax_close_kernel();
86571 + }
86572
86573 - list_add_tail(&ops->list, &link_ops);
86574 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86575 return 0;
86576 }
86577 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86578 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86579 for_each_net(net) {
86580 __rtnl_kill_links(net, ops);
86581 }
86582 - list_del(&ops->list);
86583 + pax_list_del((struct list_head *)&ops->list);
86584 }
86585 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86586
86587 diff --git a/net/core/scm.c b/net/core/scm.c
86588 index 2dc6cda..2159524 100644
86589 --- a/net/core/scm.c
86590 +++ b/net/core/scm.c
86591 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86592 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86593 {
86594 struct cmsghdr __user *cm
86595 - = (__force struct cmsghdr __user *)msg->msg_control;
86596 + = (struct cmsghdr __force_user *)msg->msg_control;
86597 struct cmsghdr cmhdr;
86598 int cmlen = CMSG_LEN(len);
86599 int err;
86600 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86601 err = -EFAULT;
86602 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86603 goto out;
86604 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86605 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86606 goto out;
86607 cmlen = CMSG_SPACE(len);
86608 if (msg->msg_controllen < cmlen)
86609 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86610 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86611 {
86612 struct cmsghdr __user *cm
86613 - = (__force struct cmsghdr __user*)msg->msg_control;
86614 + = (struct cmsghdr __force_user *)msg->msg_control;
86615
86616 int fdmax = 0;
86617 int fdnum = scm->fp->count;
86618 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86619 if (fdnum < fdmax)
86620 fdmax = fdnum;
86621
86622 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86623 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86624 i++, cmfptr++)
86625 {
86626 struct socket *sock;
86627 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
86628 index e61a8bb..6a2f13c 100644
86629 --- a/net/core/secure_seq.c
86630 +++ b/net/core/secure_seq.c
86631 @@ -12,12 +12,10 @@
86632
86633 static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
86634
86635 -static int __init net_secret_init(void)
86636 +void net_secret_init(void)
86637 {
86638 get_random_bytes(net_secret, sizeof(net_secret));
86639 - return 0;
86640 }
86641 -late_initcall(net_secret_init);
86642
86643 #ifdef CONFIG_INET
86644 static u32 seq_scale(u32 seq)
86645 diff --git a/net/core/sock.c b/net/core/sock.c
86646 index 684c37d..b541900 100644
86647 --- a/net/core/sock.c
86648 +++ b/net/core/sock.c
86649 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86650 struct sk_buff_head *list = &sk->sk_receive_queue;
86651
86652 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86653 - atomic_inc(&sk->sk_drops);
86654 + atomic_inc_unchecked(&sk->sk_drops);
86655 trace_sock_rcvqueue_full(sk, skb);
86656 return -ENOMEM;
86657 }
86658 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86659 return err;
86660
86661 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86662 - atomic_inc(&sk->sk_drops);
86663 + atomic_inc_unchecked(&sk->sk_drops);
86664 return -ENOBUFS;
86665 }
86666
86667 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86668 skb_dst_force(skb);
86669
86670 spin_lock_irqsave(&list->lock, flags);
86671 - skb->dropcount = atomic_read(&sk->sk_drops);
86672 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86673 __skb_queue_tail(list, skb);
86674 spin_unlock_irqrestore(&list->lock, flags);
86675
86676 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86677 skb->dev = NULL;
86678
86679 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86680 - atomic_inc(&sk->sk_drops);
86681 + atomic_inc_unchecked(&sk->sk_drops);
86682 goto discard_and_relse;
86683 }
86684 if (nested)
86685 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86686 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86687 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86688 bh_unlock_sock(sk);
86689 - atomic_inc(&sk->sk_drops);
86690 + atomic_inc_unchecked(&sk->sk_drops);
86691 goto discard_and_relse;
86692 }
86693
86694 @@ -942,12 +942,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86695 struct timeval tm;
86696 } v;
86697
86698 - int lv = sizeof(int);
86699 - int len;
86700 + unsigned int lv = sizeof(int);
86701 + unsigned int len;
86702
86703 if (get_user(len, optlen))
86704 return -EFAULT;
86705 - if (len < 0)
86706 + if (len > INT_MAX)
86707 return -EINVAL;
86708
86709 memset(&v, 0, sizeof(v));
86710 @@ -1099,11 +1099,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86711
86712 case SO_PEERNAME:
86713 {
86714 - char address[128];
86715 + char address[_K_SS_MAXSIZE];
86716
86717 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86718 return -ENOTCONN;
86719 - if (lv < len)
86720 + if (lv < len || sizeof address < len)
86721 return -EINVAL;
86722 if (copy_to_user(optval, address, len))
86723 return -EFAULT;
86724 @@ -1166,7 +1166,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86725
86726 if (len > lv)
86727 len = lv;
86728 - if (copy_to_user(optval, &v, len))
86729 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86730 return -EFAULT;
86731 lenout:
86732 if (put_user(len, optlen))
86733 @@ -2284,7 +2284,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86734 */
86735 smp_wmb();
86736 atomic_set(&sk->sk_refcnt, 1);
86737 - atomic_set(&sk->sk_drops, 0);
86738 + atomic_set_unchecked(&sk->sk_drops, 0);
86739 }
86740 EXPORT_SYMBOL(sock_init_data);
86741
86742 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86743 index a29e90c..922399c 100644
86744 --- a/net/core/sock_diag.c
86745 +++ b/net/core/sock_diag.c
86746 @@ -9,26 +9,33 @@
86747 #include <linux/inet_diag.h>
86748 #include <linux/sock_diag.h>
86749
86750 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86751 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86752 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86753 static DEFINE_MUTEX(sock_diag_table_mutex);
86754
86755 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86756 {
86757 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86758 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86759 cookie[1] != INET_DIAG_NOCOOKIE) &&
86760 ((u32)(unsigned long)sk != cookie[0] ||
86761 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86762 return -ESTALE;
86763 else
86764 +#endif
86765 return 0;
86766 }
86767 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86768
86769 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86770 {
86771 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86772 + cookie[0] = 0;
86773 + cookie[1] = 0;
86774 +#else
86775 cookie[0] = (u32)(unsigned long)sk;
86776 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86777 +#endif
86778 }
86779 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86780
86781 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86782 mutex_lock(&sock_diag_table_mutex);
86783 if (sock_diag_handlers[hndl->family])
86784 err = -EBUSY;
86785 - else
86786 + else {
86787 + pax_open_kernel();
86788 sock_diag_handlers[hndl->family] = hndl;
86789 + pax_close_kernel();
86790 + }
86791 mutex_unlock(&sock_diag_table_mutex);
86792
86793 return err;
86794 @@ -92,7 +102,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86795
86796 mutex_lock(&sock_diag_table_mutex);
86797 BUG_ON(sock_diag_handlers[family] != hnld);
86798 + pax_open_kernel();
86799 sock_diag_handlers[family] = NULL;
86800 + pax_close_kernel();
86801 mutex_unlock(&sock_diag_table_mutex);
86802 }
86803 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86804 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86805 index cfdb46a..cef55e1 100644
86806 --- a/net/core/sysctl_net_core.c
86807 +++ b/net/core/sysctl_net_core.c
86808 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86809 {
86810 unsigned int orig_size, size;
86811 int ret, i;
86812 - ctl_table tmp = {
86813 + ctl_table_no_const tmp = {
86814 .data = &size,
86815 .maxlen = sizeof(size),
86816 .mode = table->mode
86817 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
86818
86819 static __net_init int sysctl_core_net_init(struct net *net)
86820 {
86821 - struct ctl_table *tbl;
86822 + ctl_table_no_const *tbl = NULL;
86823
86824 net->core.sysctl_somaxconn = SOMAXCONN;
86825
86826 - tbl = netns_core_table;
86827 if (!net_eq(net, &init_net)) {
86828 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86829 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86830 if (tbl == NULL)
86831 goto err_dup;
86832
86833 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86834 if (net->user_ns != &init_user_ns) {
86835 tbl[0].procname = NULL;
86836 }
86837 - }
86838 -
86839 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86840 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86841 + } else
86842 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86843 if (net->core.sysctl_hdr == NULL)
86844 goto err_reg;
86845
86846 return 0;
86847
86848 err_reg:
86849 - if (tbl != netns_core_table)
86850 - kfree(tbl);
86851 + kfree(tbl);
86852 err_dup:
86853 return -ENOMEM;
86854 }
86855 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86856 kfree(tbl);
86857 }
86858
86859 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86860 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86861 .init = sysctl_core_net_init,
86862 .exit = sysctl_core_net_exit,
86863 };
86864 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86865 index c21f200..bc4565b 100644
86866 --- a/net/decnet/af_decnet.c
86867 +++ b/net/decnet/af_decnet.c
86868 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
86869 .sysctl_rmem = sysctl_decnet_rmem,
86870 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86871 .obj_size = sizeof(struct dn_sock),
86872 + .slab_flags = SLAB_USERCOPY,
86873 };
86874
86875 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86876 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86877 index a55eecc..dd8428c 100644
86878 --- a/net/decnet/sysctl_net_decnet.c
86879 +++ b/net/decnet/sysctl_net_decnet.c
86880 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86881
86882 if (len > *lenp) len = *lenp;
86883
86884 - if (copy_to_user(buffer, addr, len))
86885 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86886 return -EFAULT;
86887
86888 *lenp = len;
86889 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86890
86891 if (len > *lenp) len = *lenp;
86892
86893 - if (copy_to_user(buffer, devname, len))
86894 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86895 return -EFAULT;
86896
86897 *lenp = len;
86898 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86899 index c929d9c..df10cde 100644
86900 --- a/net/ipv4/af_inet.c
86901 +++ b/net/ipv4/af_inet.c
86902 @@ -115,6 +115,7 @@
86903 #include <net/inet_common.h>
86904 #include <net/xfrm.h>
86905 #include <net/net_namespace.h>
86906 +#include <net/secure_seq.h>
86907 #ifdef CONFIG_IP_MROUTE
86908 #include <linux/mroute.h>
86909 #endif
86910 @@ -263,8 +264,10 @@ void build_ehash_secret(void)
86911 get_random_bytes(&rnd, sizeof(rnd));
86912 } while (rnd == 0);
86913
86914 - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
86915 + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
86916 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
86917 + net_secret_init();
86918 + }
86919 }
86920 EXPORT_SYMBOL(build_ehash_secret);
86921
86922 @@ -1699,13 +1702,9 @@ static int __init inet_init(void)
86923
86924 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
86925
86926 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86927 - if (!sysctl_local_reserved_ports)
86928 - goto out;
86929 -
86930 rc = proto_register(&tcp_prot, 1);
86931 if (rc)
86932 - goto out_free_reserved_ports;
86933 + goto out;
86934
86935 rc = proto_register(&udp_prot, 1);
86936 if (rc)
86937 @@ -1814,8 +1813,6 @@ out_unregister_udp_proto:
86938 proto_unregister(&udp_prot);
86939 out_unregister_tcp_proto:
86940 proto_unregister(&tcp_prot);
86941 -out_free_reserved_ports:
86942 - kfree(sysctl_local_reserved_ports);
86943 goto out;
86944 }
86945
86946 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86947 index 2e7f194..0fa4d6d 100644
86948 --- a/net/ipv4/ah4.c
86949 +++ b/net/ipv4/ah4.c
86950 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86951 return;
86952
86953 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86954 - atomic_inc(&flow_cache_genid);
86955 + atomic_inc_unchecked(&flow_cache_genid);
86956 rt_genid_bump(net);
86957
86958 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86959 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86960 index c6287cd..e9bc96a 100644
86961 --- a/net/ipv4/devinet.c
86962 +++ b/net/ipv4/devinet.c
86963 @@ -1992,7 +1992,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86964 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86965 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86966
86967 -static struct devinet_sysctl_table {
86968 +static const struct devinet_sysctl_table {
86969 struct ctl_table_header *sysctl_header;
86970 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86971 } devinet_sysctl = {
86972 @@ -2110,7 +2110,7 @@ static __net_init int devinet_init_net(struct net *net)
86973 int err;
86974 struct ipv4_devconf *all, *dflt;
86975 #ifdef CONFIG_SYSCTL
86976 - struct ctl_table *tbl = ctl_forward_entry;
86977 + ctl_table_no_const *tbl = NULL;
86978 struct ctl_table_header *forw_hdr;
86979 #endif
86980
86981 @@ -2128,7 +2128,7 @@ static __net_init int devinet_init_net(struct net *net)
86982 goto err_alloc_dflt;
86983
86984 #ifdef CONFIG_SYSCTL
86985 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86986 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86987 if (tbl == NULL)
86988 goto err_alloc_ctl;
86989
86990 @@ -2148,7 +2148,10 @@ static __net_init int devinet_init_net(struct net *net)
86991 goto err_reg_dflt;
86992
86993 err = -ENOMEM;
86994 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86995 + if (!net_eq(net, &init_net))
86996 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86997 + else
86998 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86999 if (forw_hdr == NULL)
87000 goto err_reg_ctl;
87001 net->ipv4.forw_hdr = forw_hdr;
87002 @@ -2164,8 +2167,7 @@ err_reg_ctl:
87003 err_reg_dflt:
87004 __devinet_sysctl_unregister(all);
87005 err_reg_all:
87006 - if (tbl != ctl_forward_entry)
87007 - kfree(tbl);
87008 + kfree(tbl);
87009 err_alloc_ctl:
87010 #endif
87011 if (dflt != &ipv4_devconf_dflt)
87012 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
87013 index 4cfe34d..a6ba66e 100644
87014 --- a/net/ipv4/esp4.c
87015 +++ b/net/ipv4/esp4.c
87016 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
87017 return;
87018
87019 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87020 - atomic_inc(&flow_cache_genid);
87021 + atomic_inc_unchecked(&flow_cache_genid);
87022 rt_genid_bump(net);
87023
87024 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
87025 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
87026 index eb4bb12..ee4ec7d 100644
87027 --- a/net/ipv4/fib_frontend.c
87028 +++ b/net/ipv4/fib_frontend.c
87029 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
87030 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87031 fib_sync_up(dev);
87032 #endif
87033 - atomic_inc(&net->ipv4.dev_addr_genid);
87034 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87035 rt_cache_flush(dev_net(dev));
87036 break;
87037 case NETDEV_DOWN:
87038 fib_del_ifaddr(ifa, NULL);
87039 - atomic_inc(&net->ipv4.dev_addr_genid);
87040 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87041 if (ifa->ifa_dev->ifa_list == NULL) {
87042 /* Last address was deleted from this interface.
87043 * Disable IP.
87044 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
87045 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87046 fib_sync_up(dev);
87047 #endif
87048 - atomic_inc(&net->ipv4.dev_addr_genid);
87049 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87050 rt_cache_flush(net);
87051 break;
87052 case NETDEV_DOWN:
87053 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
87054 index 8f6cb7a..34507f9 100644
87055 --- a/net/ipv4/fib_semantics.c
87056 +++ b/net/ipv4/fib_semantics.c
87057 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
87058 nh->nh_saddr = inet_select_addr(nh->nh_dev,
87059 nh->nh_gw,
87060 nh->nh_parent->fib_scope);
87061 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
87062 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
87063
87064 return nh->nh_saddr;
87065 }
87066 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
87067 index 786d97a..1889c0d 100644
87068 --- a/net/ipv4/inet_connection_sock.c
87069 +++ b/net/ipv4/inet_connection_sock.c
87070 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
87071 .range = { 32768, 61000 },
87072 };
87073
87074 -unsigned long *sysctl_local_reserved_ports;
87075 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
87076 EXPORT_SYMBOL(sysctl_local_reserved_ports);
87077
87078 void inet_get_local_port_range(int *low, int *high)
87079 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
87080 index 6af375a..c493c74 100644
87081 --- a/net/ipv4/inet_hashtables.c
87082 +++ b/net/ipv4/inet_hashtables.c
87083 @@ -18,12 +18,15 @@
87084 #include <linux/sched.h>
87085 #include <linux/slab.h>
87086 #include <linux/wait.h>
87087 +#include <linux/security.h>
87088
87089 #include <net/inet_connection_sock.h>
87090 #include <net/inet_hashtables.h>
87091 #include <net/secure_seq.h>
87092 #include <net/ip.h>
87093
87094 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
87095 +
87096 /*
87097 * Allocate and initialize a new local port bind bucket.
87098 * The bindhash mutex for snum's hash chain must be held here.
87099 @@ -554,6 +557,8 @@ ok:
87100 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
87101 spin_unlock(&head->lock);
87102
87103 + gr_update_task_in_ip_table(current, inet_sk(sk));
87104 +
87105 if (tw) {
87106 inet_twsk_deschedule(tw, death_row);
87107 while (twrefcnt) {
87108 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
87109 index 000e3d2..5472da3 100644
87110 --- a/net/ipv4/inetpeer.c
87111 +++ b/net/ipv4/inetpeer.c
87112 @@ -503,8 +503,8 @@ relookup:
87113 if (p) {
87114 p->daddr = *daddr;
87115 atomic_set(&p->refcnt, 1);
87116 - atomic_set(&p->rid, 0);
87117 - atomic_set(&p->ip_id_count,
87118 + atomic_set_unchecked(&p->rid, 0);
87119 + atomic_set_unchecked(&p->ip_id_count,
87120 (daddr->family == AF_INET) ?
87121 secure_ip_id(daddr->addr.a4) :
87122 secure_ipv6_id(daddr->addr.a6));
87123 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
87124 index 52c273e..579060b 100644
87125 --- a/net/ipv4/ip_fragment.c
87126 +++ b/net/ipv4/ip_fragment.c
87127 @@ -311,7 +311,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
87128 return 0;
87129
87130 start = qp->rid;
87131 - end = atomic_inc_return(&peer->rid);
87132 + end = atomic_inc_return_unchecked(&peer->rid);
87133 qp->rid = end;
87134
87135 rc = qp->q.fragments && (end - start) > max;
87136 @@ -788,12 +788,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
87137
87138 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87139 {
87140 - struct ctl_table *table;
87141 + ctl_table_no_const *table = NULL;
87142 struct ctl_table_header *hdr;
87143
87144 - table = ip4_frags_ns_ctl_table;
87145 if (!net_eq(net, &init_net)) {
87146 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87147 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87148 if (table == NULL)
87149 goto err_alloc;
87150
87151 @@ -804,9 +803,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87152 /* Don't export sysctls to unprivileged users */
87153 if (net->user_ns != &init_user_ns)
87154 table[0].procname = NULL;
87155 - }
87156 + hdr = register_net_sysctl(net, "net/ipv4", table);
87157 + } else
87158 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
87159
87160 - hdr = register_net_sysctl(net, "net/ipv4", table);
87161 if (hdr == NULL)
87162 goto err_reg;
87163
87164 @@ -814,8 +814,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87165 return 0;
87166
87167 err_reg:
87168 - if (!net_eq(net, &init_net))
87169 - kfree(table);
87170 + kfree(table);
87171 err_alloc:
87172 return -ENOMEM;
87173 }
87174 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
87175 index c7e8c04..56cb4c1 100644
87176 --- a/net/ipv4/ip_gre.c
87177 +++ b/net/ipv4/ip_gre.c
87178 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
87179 module_param(log_ecn_error, bool, 0644);
87180 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87181
87182 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
87183 +static struct rtnl_link_ops ipgre_link_ops;
87184 static int ipgre_tunnel_init(struct net_device *dev);
87185 static void ipgre_tunnel_setup(struct net_device *dev);
87186 static int ipgre_tunnel_bind_dev(struct net_device *dev);
87187 @@ -1823,7 +1823,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
87188 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
87189 };
87190
87191 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87192 +static struct rtnl_link_ops ipgre_link_ops = {
87193 .kind = "gre",
87194 .maxtype = IFLA_GRE_MAX,
87195 .policy = ipgre_policy,
87196 @@ -1836,7 +1836,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87197 .fill_info = ipgre_fill_info,
87198 };
87199
87200 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
87201 +static struct rtnl_link_ops ipgre_tap_ops = {
87202 .kind = "gretap",
87203 .maxtype = IFLA_GRE_MAX,
87204 .policy = ipgre_policy,
87205 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
87206 index d9c4f11..02b82dbc 100644
87207 --- a/net/ipv4/ip_sockglue.c
87208 +++ b/net/ipv4/ip_sockglue.c
87209 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87210 len = min_t(unsigned int, len, opt->optlen);
87211 if (put_user(len, optlen))
87212 return -EFAULT;
87213 - if (copy_to_user(optval, opt->__data, len))
87214 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
87215 + copy_to_user(optval, opt->__data, len))
87216 return -EFAULT;
87217 return 0;
87218 }
87219 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87220 if (sk->sk_type != SOCK_STREAM)
87221 return -ENOPROTOOPT;
87222
87223 - msg.msg_control = optval;
87224 + msg.msg_control = (void __force_kernel *)optval;
87225 msg.msg_controllen = len;
87226 msg.msg_flags = flags;
87227
87228 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
87229 index c3a4233..7df5626 100644
87230 --- a/net/ipv4/ip_vti.c
87231 +++ b/net/ipv4/ip_vti.c
87232 @@ -47,7 +47,7 @@
87233 #define HASH_SIZE 16
87234 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
87235
87236 -static struct rtnl_link_ops vti_link_ops __read_mostly;
87237 +static struct rtnl_link_ops vti_link_ops;
87238
87239 static int vti_net_id __read_mostly;
87240 struct vti_net {
87241 @@ -399,8 +399,7 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
87242 tunnel->err_count = 0;
87243 }
87244
87245 - IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
87246 - IPSKB_REROUTED);
87247 + memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
87248 skb_dst_drop(skb);
87249 skb_dst_set(skb, &rt->dst);
87250 nf_reset(skb);
87251 @@ -886,7 +885,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
87252 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
87253 };
87254
87255 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
87256 +static struct rtnl_link_ops vti_link_ops = {
87257 .kind = "vti",
87258 .maxtype = IFLA_VTI_MAX,
87259 .policy = vti_policy,
87260 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87261 index f01d1b1..8fe03ad 100644
87262 --- a/net/ipv4/ipcomp.c
87263 +++ b/net/ipv4/ipcomp.c
87264 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87265 return;
87266
87267 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87268 - atomic_inc(&flow_cache_genid);
87269 + atomic_inc_unchecked(&flow_cache_genid);
87270 rt_genid_bump(net);
87271
87272 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87273 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87274 index bf6c5cf..ab2e9c6 100644
87275 --- a/net/ipv4/ipconfig.c
87276 +++ b/net/ipv4/ipconfig.c
87277 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87278
87279 mm_segment_t oldfs = get_fs();
87280 set_fs(get_ds());
87281 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87282 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87283 set_fs(oldfs);
87284 return res;
87285 }
87286 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87287
87288 mm_segment_t oldfs = get_fs();
87289 set_fs(get_ds());
87290 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87291 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87292 set_fs(oldfs);
87293 return res;
87294 }
87295 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87296
87297 mm_segment_t oldfs = get_fs();
87298 set_fs(get_ds());
87299 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87300 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87301 set_fs(oldfs);
87302 return res;
87303 }
87304 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87305 index 7533846..d2361d1 100644
87306 --- a/net/ipv4/ipip.c
87307 +++ b/net/ipv4/ipip.c
87308 @@ -138,7 +138,7 @@ struct ipip_net {
87309 static int ipip_tunnel_init(struct net_device *dev);
87310 static void ipip_tunnel_setup(struct net_device *dev);
87311 static void ipip_dev_free(struct net_device *dev);
87312 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87313 +static struct rtnl_link_ops ipip_link_ops;
87314
87315 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
87316 struct rtnl_link_stats64 *tot)
87317 @@ -974,7 +974,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87318 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87319 };
87320
87321 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87322 +static struct rtnl_link_ops ipip_link_ops = {
87323 .kind = "ipip",
87324 .maxtype = IFLA_IPTUN_MAX,
87325 .policy = ipip_policy,
87326 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87327 index 7dc6a97..229c61b 100644
87328 --- a/net/ipv4/netfilter/arp_tables.c
87329 +++ b/net/ipv4/netfilter/arp_tables.c
87330 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
87331 #endif
87332
87333 static int get_info(struct net *net, void __user *user,
87334 - const int *len, int compat)
87335 + int len, int compat)
87336 {
87337 char name[XT_TABLE_MAXNAMELEN];
87338 struct xt_table *t;
87339 int ret;
87340
87341 - if (*len != sizeof(struct arpt_getinfo)) {
87342 - duprintf("length %u != %Zu\n", *len,
87343 + if (len != sizeof(struct arpt_getinfo)) {
87344 + duprintf("length %u != %Zu\n", len,
87345 sizeof(struct arpt_getinfo));
87346 return -EINVAL;
87347 }
87348 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
87349 info.size = private->size;
87350 strcpy(info.name, name);
87351
87352 - if (copy_to_user(user, &info, *len) != 0)
87353 + if (copy_to_user(user, &info, len) != 0)
87354 ret = -EFAULT;
87355 else
87356 ret = 0;
87357 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87358
87359 switch (cmd) {
87360 case ARPT_SO_GET_INFO:
87361 - ret = get_info(sock_net(sk), user, len, 1);
87362 + ret = get_info(sock_net(sk), user, *len, 1);
87363 break;
87364 case ARPT_SO_GET_ENTRIES:
87365 ret = compat_get_entries(sock_net(sk), user, len);
87366 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87367
87368 switch (cmd) {
87369 case ARPT_SO_GET_INFO:
87370 - ret = get_info(sock_net(sk), user, len, 0);
87371 + ret = get_info(sock_net(sk), user, *len, 0);
87372 break;
87373
87374 case ARPT_SO_GET_ENTRIES:
87375 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87376 index 3efcf87..5247916 100644
87377 --- a/net/ipv4/netfilter/ip_tables.c
87378 +++ b/net/ipv4/netfilter/ip_tables.c
87379 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87380 #endif
87381
87382 static int get_info(struct net *net, void __user *user,
87383 - const int *len, int compat)
87384 + int len, int compat)
87385 {
87386 char name[XT_TABLE_MAXNAMELEN];
87387 struct xt_table *t;
87388 int ret;
87389
87390 - if (*len != sizeof(struct ipt_getinfo)) {
87391 - duprintf("length %u != %zu\n", *len,
87392 + if (len != sizeof(struct ipt_getinfo)) {
87393 + duprintf("length %u != %zu\n", len,
87394 sizeof(struct ipt_getinfo));
87395 return -EINVAL;
87396 }
87397 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87398 info.size = private->size;
87399 strcpy(info.name, name);
87400
87401 - if (copy_to_user(user, &info, *len) != 0)
87402 + if (copy_to_user(user, &info, len) != 0)
87403 ret = -EFAULT;
87404 else
87405 ret = 0;
87406 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87407
87408 switch (cmd) {
87409 case IPT_SO_GET_INFO:
87410 - ret = get_info(sock_net(sk), user, len, 1);
87411 + ret = get_info(sock_net(sk), user, *len, 1);
87412 break;
87413 case IPT_SO_GET_ENTRIES:
87414 ret = compat_get_entries(sock_net(sk), user, len);
87415 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87416
87417 switch (cmd) {
87418 case IPT_SO_GET_INFO:
87419 - ret = get_info(sock_net(sk), user, len, 0);
87420 + ret = get_info(sock_net(sk), user, *len, 0);
87421 break;
87422
87423 case IPT_SO_GET_ENTRIES:
87424 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87425 index 2e91006..f084394 100644
87426 --- a/net/ipv4/ping.c
87427 +++ b/net/ipv4/ping.c
87428 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87429 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87430 0, sock_i_ino(sp),
87431 atomic_read(&sp->sk_refcnt), sp,
87432 - atomic_read(&sp->sk_drops), len);
87433 + atomic_read_unchecked(&sp->sk_drops), len);
87434 }
87435
87436 static int ping_seq_show(struct seq_file *seq, void *v)
87437 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87438 index dd44e0a..06dcca4 100644
87439 --- a/net/ipv4/raw.c
87440 +++ b/net/ipv4/raw.c
87441 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87442 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87443 {
87444 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87445 - atomic_inc(&sk->sk_drops);
87446 + atomic_inc_unchecked(&sk->sk_drops);
87447 kfree_skb(skb);
87448 return NET_RX_DROP;
87449 }
87450 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
87451
87452 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87453 {
87454 + struct icmp_filter filter;
87455 +
87456 if (optlen > sizeof(struct icmp_filter))
87457 optlen = sizeof(struct icmp_filter);
87458 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87459 + if (copy_from_user(&filter, optval, optlen))
87460 return -EFAULT;
87461 + raw_sk(sk)->filter = filter;
87462 return 0;
87463 }
87464
87465 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87466 {
87467 int len, ret = -EFAULT;
87468 + struct icmp_filter filter;
87469
87470 if (get_user(len, optlen))
87471 goto out;
87472 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87473 if (len > sizeof(struct icmp_filter))
87474 len = sizeof(struct icmp_filter);
87475 ret = -EFAULT;
87476 - if (put_user(len, optlen) ||
87477 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87478 + filter = raw_sk(sk)->filter;
87479 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87480 goto out;
87481 ret = 0;
87482 out: return ret;
87483 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87484 0, 0L, 0,
87485 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87486 0, sock_i_ino(sp),
87487 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87488 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87489 }
87490
87491 static int raw_seq_show(struct seq_file *seq, void *v)
87492 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87493 index cfede9a..22248f9 100644
87494 --- a/net/ipv4/route.c
87495 +++ b/net/ipv4/route.c
87496 @@ -2558,34 +2558,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87497 .maxlen = sizeof(int),
87498 .mode = 0200,
87499 .proc_handler = ipv4_sysctl_rtcache_flush,
87500 + .extra1 = &init_net,
87501 },
87502 { },
87503 };
87504
87505 static __net_init int sysctl_route_net_init(struct net *net)
87506 {
87507 - struct ctl_table *tbl;
87508 + ctl_table_no_const *tbl = NULL;
87509
87510 - tbl = ipv4_route_flush_table;
87511 if (!net_eq(net, &init_net)) {
87512 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87513 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87514 if (tbl == NULL)
87515 goto err_dup;
87516
87517 /* Don't export sysctls to unprivileged users */
87518 if (net->user_ns != &init_user_ns)
87519 tbl[0].procname = NULL;
87520 - }
87521 - tbl[0].extra1 = net;
87522 + tbl[0].extra1 = net;
87523 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87524 + } else
87525 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87526
87527 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87528 if (net->ipv4.route_hdr == NULL)
87529 goto err_reg;
87530 return 0;
87531
87532 err_reg:
87533 - if (tbl != ipv4_route_flush_table)
87534 - kfree(tbl);
87535 + kfree(tbl);
87536 err_dup:
87537 return -ENOMEM;
87538 }
87539 @@ -2608,7 +2608,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87540
87541 static __net_init int rt_genid_init(struct net *net)
87542 {
87543 - atomic_set(&net->rt_genid, 0);
87544 + atomic_set_unchecked(&net->rt_genid, 0);
87545 get_random_bytes(&net->ipv4.dev_addr_genid,
87546 sizeof(net->ipv4.dev_addr_genid));
87547 return 0;
87548 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87549 index 960fd29..d55bf64 100644
87550 --- a/net/ipv4/sysctl_net_ipv4.c
87551 +++ b/net/ipv4/sysctl_net_ipv4.c
87552 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87553 {
87554 int ret;
87555 int range[2];
87556 - ctl_table tmp = {
87557 + ctl_table_no_const tmp = {
87558 .data = &range,
87559 .maxlen = sizeof(range),
87560 .mode = table->mode,
87561 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87562 int ret;
87563 gid_t urange[2];
87564 kgid_t low, high;
87565 - ctl_table tmp = {
87566 + ctl_table_no_const tmp = {
87567 .data = &urange,
87568 .maxlen = sizeof(urange),
87569 .mode = table->mode,
87570 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87571 void __user *buffer, size_t *lenp, loff_t *ppos)
87572 {
87573 char val[TCP_CA_NAME_MAX];
87574 - ctl_table tbl = {
87575 + ctl_table_no_const tbl = {
87576 .data = val,
87577 .maxlen = TCP_CA_NAME_MAX,
87578 };
87579 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87580 void __user *buffer, size_t *lenp,
87581 loff_t *ppos)
87582 {
87583 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87584 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87585 int ret;
87586
87587 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87588 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87589 void __user *buffer, size_t *lenp,
87590 loff_t *ppos)
87591 {
87592 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87593 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87594 int ret;
87595
87596 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87597 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87598 struct mem_cgroup *memcg;
87599 #endif
87600
87601 - ctl_table tmp = {
87602 + ctl_table_no_const tmp = {
87603 .data = &vec,
87604 .maxlen = sizeof(vec),
87605 .mode = ctl->mode,
87606 };
87607
87608 if (!write) {
87609 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87610 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87611 + ctl_table_no_const tcp_mem = *ctl;
87612 +
87613 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87614 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87615 }
87616
87617 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87618 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87619 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87620 size_t *lenp, loff_t *ppos)
87621 {
87622 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87623 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87624 struct tcp_fastopen_context *ctxt;
87625 int ret;
87626 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87627 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
87628 },
87629 {
87630 .procname = "ip_local_reserved_ports",
87631 - .data = NULL, /* initialized in sysctl_ipv4_init */
87632 + .data = sysctl_local_reserved_ports,
87633 .maxlen = 65536,
87634 .mode = 0644,
87635 .proc_handler = proc_do_large_bitmap,
87636 @@ -856,11 +858,10 @@ static struct ctl_table ipv4_net_table[] = {
87637
87638 static __net_init int ipv4_sysctl_init_net(struct net *net)
87639 {
87640 - struct ctl_table *table;
87641 + ctl_table_no_const *table = NULL;
87642
87643 - table = ipv4_net_table;
87644 if (!net_eq(net, &init_net)) {
87645 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87646 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87647 if (table == NULL)
87648 goto err_alloc;
87649
87650 @@ -895,15 +896,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87651
87652 tcp_init_mem(net);
87653
87654 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87655 + if (!net_eq(net, &init_net))
87656 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87657 + else
87658 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87659 if (net->ipv4.ipv4_hdr == NULL)
87660 goto err_reg;
87661
87662 return 0;
87663
87664 err_reg:
87665 - if (!net_eq(net, &init_net))
87666 - kfree(table);
87667 + kfree(table);
87668 err_alloc:
87669 return -ENOMEM;
87670 }
87671 @@ -925,16 +928,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87672 static __init int sysctl_ipv4_init(void)
87673 {
87674 struct ctl_table_header *hdr;
87675 - struct ctl_table *i;
87676 -
87677 - for (i = ipv4_table; i->procname; i++) {
87678 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87679 - i->data = sysctl_local_reserved_ports;
87680 - break;
87681 - }
87682 - }
87683 - if (!i->procname)
87684 - return -EINVAL;
87685
87686 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87687 if (hdr == NULL)
87688 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87689 index 59163c8..8277c51 100644
87690 --- a/net/ipv4/tcp_input.c
87691 +++ b/net/ipv4/tcp_input.c
87692 @@ -4727,7 +4727,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87693 * simplifies code)
87694 */
87695 static void
87696 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87697 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87698 struct sk_buff *head, struct sk_buff *tail,
87699 u32 start, u32 end)
87700 {
87701 @@ -5841,6 +5841,7 @@ discard:
87702 tcp_paws_reject(&tp->rx_opt, 0))
87703 goto discard_and_undo;
87704
87705 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87706 if (th->syn) {
87707 /* We see SYN without ACK. It is attempt of
87708 * simultaneous connect with crossed SYNs.
87709 @@ -5891,6 +5892,7 @@ discard:
87710 goto discard;
87711 #endif
87712 }
87713 +#endif
87714 /* "fifth, if neither of the SYN or RST bits is set then
87715 * drop the segment and return."
87716 */
87717 @@ -5935,7 +5937,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87718 goto discard;
87719
87720 if (th->syn) {
87721 - if (th->fin)
87722 + if (th->fin || th->urg || th->psh)
87723 goto discard;
87724 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87725 return 1;
87726 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87727 index d09203c..fd5cc91 100644
87728 --- a/net/ipv4/tcp_ipv4.c
87729 +++ b/net/ipv4/tcp_ipv4.c
87730 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87731 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87732
87733
87734 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87735 +extern int grsec_enable_blackhole;
87736 +#endif
87737 +
87738 #ifdef CONFIG_TCP_MD5SIG
87739 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87740 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87741 @@ -1897,6 +1901,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87742 return 0;
87743
87744 reset:
87745 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87746 + if (!grsec_enable_blackhole)
87747 +#endif
87748 tcp_v4_send_reset(rsk, skb);
87749 discard:
87750 kfree_skb(skb);
87751 @@ -1996,12 +2003,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87752 TCP_SKB_CB(skb)->sacked = 0;
87753
87754 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87755 - if (!sk)
87756 + if (!sk) {
87757 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87758 + ret = 1;
87759 +#endif
87760 goto no_tcp_socket;
87761 -
87762 + }
87763 process:
87764 - if (sk->sk_state == TCP_TIME_WAIT)
87765 + if (sk->sk_state == TCP_TIME_WAIT) {
87766 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87767 + ret = 2;
87768 +#endif
87769 goto do_time_wait;
87770 + }
87771
87772 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87773 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87774 @@ -2052,6 +2066,10 @@ no_tcp_socket:
87775 bad_packet:
87776 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87777 } else {
87778 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87779 + if (!grsec_enable_blackhole || (ret == 1 &&
87780 + (skb->dev->flags & IFF_LOOPBACK)))
87781 +#endif
87782 tcp_v4_send_reset(NULL, skb);
87783 }
87784
87785 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87786 index 2f672e7..b8895e9 100644
87787 --- a/net/ipv4/tcp_minisocks.c
87788 +++ b/net/ipv4/tcp_minisocks.c
87789 @@ -27,6 +27,10 @@
87790 #include <net/inet_common.h>
87791 #include <net/xfrm.h>
87792
87793 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87794 +extern int grsec_enable_blackhole;
87795 +#endif
87796 +
87797 int sysctl_tcp_syncookies __read_mostly = 1;
87798 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87799
87800 @@ -749,7 +753,10 @@ embryonic_reset:
87801 * avoid becoming vulnerable to outside attack aiming at
87802 * resetting legit local connections.
87803 */
87804 - req->rsk_ops->send_reset(sk, skb);
87805 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87806 + if (!grsec_enable_blackhole)
87807 +#endif
87808 + req->rsk_ops->send_reset(sk, skb);
87809 } else if (fastopen) { /* received a valid RST pkt */
87810 reqsk_fastopen_remove(sk, req, true);
87811 tcp_reset(sk);
87812 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87813 index d4943f6..e7a74a5 100644
87814 --- a/net/ipv4/tcp_probe.c
87815 +++ b/net/ipv4/tcp_probe.c
87816 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87817 if (cnt + width >= len)
87818 break;
87819
87820 - if (copy_to_user(buf + cnt, tbuf, width))
87821 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87822 return -EFAULT;
87823 cnt += width;
87824 }
87825 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87826 index b78aac3..e18230b 100644
87827 --- a/net/ipv4/tcp_timer.c
87828 +++ b/net/ipv4/tcp_timer.c
87829 @@ -22,6 +22,10 @@
87830 #include <linux/gfp.h>
87831 #include <net/tcp.h>
87832
87833 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87834 +extern int grsec_lastack_retries;
87835 +#endif
87836 +
87837 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87838 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87839 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87840 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87841 }
87842 }
87843
87844 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87845 + if ((sk->sk_state == TCP_LAST_ACK) &&
87846 + (grsec_lastack_retries > 0) &&
87847 + (grsec_lastack_retries < retry_until))
87848 + retry_until = grsec_lastack_retries;
87849 +#endif
87850 +
87851 if (retransmits_timed_out(sk, retry_until,
87852 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87853 /* Has it gone just too far? */
87854 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87855 index 0a073a2..ddf6279 100644
87856 --- a/net/ipv4/udp.c
87857 +++ b/net/ipv4/udp.c
87858 @@ -87,6 +87,7 @@
87859 #include <linux/types.h>
87860 #include <linux/fcntl.h>
87861 #include <linux/module.h>
87862 +#include <linux/security.h>
87863 #include <linux/socket.h>
87864 #include <linux/sockios.h>
87865 #include <linux/igmp.h>
87866 @@ -111,6 +112,10 @@
87867 #include <trace/events/skb.h>
87868 #include "udp_impl.h"
87869
87870 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87871 +extern int grsec_enable_blackhole;
87872 +#endif
87873 +
87874 struct udp_table udp_table __read_mostly;
87875 EXPORT_SYMBOL(udp_table);
87876
87877 @@ -594,6 +599,9 @@ found:
87878 return s;
87879 }
87880
87881 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87882 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87883 +
87884 /*
87885 * This routine is called by the ICMP module when it gets some
87886 * sort of error condition. If err < 0 then the socket should
87887 @@ -889,9 +897,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87888 dport = usin->sin_port;
87889 if (dport == 0)
87890 return -EINVAL;
87891 +
87892 + err = gr_search_udp_sendmsg(sk, usin);
87893 + if (err)
87894 + return err;
87895 } else {
87896 if (sk->sk_state != TCP_ESTABLISHED)
87897 return -EDESTADDRREQ;
87898 +
87899 + err = gr_search_udp_sendmsg(sk, NULL);
87900 + if (err)
87901 + return err;
87902 +
87903 daddr = inet->inet_daddr;
87904 dport = inet->inet_dport;
87905 /* Open fast path for connected socket.
87906 @@ -1133,7 +1150,7 @@ static unsigned int first_packet_length(struct sock *sk)
87907 udp_lib_checksum_complete(skb)) {
87908 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87909 IS_UDPLITE(sk));
87910 - atomic_inc(&sk->sk_drops);
87911 + atomic_inc_unchecked(&sk->sk_drops);
87912 __skb_unlink(skb, rcvq);
87913 __skb_queue_tail(&list_kill, skb);
87914 }
87915 @@ -1219,6 +1236,10 @@ try_again:
87916 if (!skb)
87917 goto out;
87918
87919 + err = gr_search_udp_recvmsg(sk, skb);
87920 + if (err)
87921 + goto out_free;
87922 +
87923 ulen = skb->len - sizeof(struct udphdr);
87924 copied = len;
87925 if (copied > ulen)
87926 @@ -1252,7 +1273,7 @@ try_again:
87927 if (unlikely(err)) {
87928 trace_kfree_skb(skb, udp_recvmsg);
87929 if (!peeked) {
87930 - atomic_inc(&sk->sk_drops);
87931 + atomic_inc_unchecked(&sk->sk_drops);
87932 UDP_INC_STATS_USER(sock_net(sk),
87933 UDP_MIB_INERRORS, is_udplite);
87934 }
87935 @@ -1535,7 +1556,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87936
87937 drop:
87938 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87939 - atomic_inc(&sk->sk_drops);
87940 + atomic_inc_unchecked(&sk->sk_drops);
87941 kfree_skb(skb);
87942 return -1;
87943 }
87944 @@ -1554,7 +1575,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87945 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87946
87947 if (!skb1) {
87948 - atomic_inc(&sk->sk_drops);
87949 + atomic_inc_unchecked(&sk->sk_drops);
87950 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87951 IS_UDPLITE(sk));
87952 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87953 @@ -1723,6 +1744,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87954 goto csum_error;
87955
87956 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87957 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87958 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87959 +#endif
87960 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87961
87962 /*
87963 @@ -2152,7 +2176,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87964 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87965 0, sock_i_ino(sp),
87966 atomic_read(&sp->sk_refcnt), sp,
87967 - atomic_read(&sp->sk_drops), len);
87968 + atomic_read_unchecked(&sp->sk_drops), len);
87969 }
87970
87971 int udp4_seq_show(struct seq_file *seq, void *v)
87972 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
87973 index 9a459be..086b866 100644
87974 --- a/net/ipv4/xfrm4_policy.c
87975 +++ b/net/ipv4/xfrm4_policy.c
87976 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
87977
87978 static int __net_init xfrm4_net_init(struct net *net)
87979 {
87980 - struct ctl_table *table;
87981 + ctl_table_no_const *table = NULL;
87982 struct ctl_table_header *hdr;
87983
87984 - table = xfrm4_policy_table;
87985 if (!net_eq(net, &init_net)) {
87986 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
87987 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
87988 if (!table)
87989 goto err_alloc;
87990
87991 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
87992 - }
87993 -
87994 - hdr = register_net_sysctl(net, "net/ipv4", table);
87995 + hdr = register_net_sysctl(net, "net/ipv4", table);
87996 + } else
87997 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
87998 if (!hdr)
87999 goto err_reg;
88000
88001 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
88002 return 0;
88003
88004 err_reg:
88005 - if (!net_eq(net, &init_net))
88006 - kfree(table);
88007 + kfree(table);
88008 err_alloc:
88009 return -ENOMEM;
88010 }
88011 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
88012 index 50a4c7c..50a27e6 100644
88013 --- a/net/ipv6/addrconf.c
88014 +++ b/net/ipv6/addrconf.c
88015 @@ -2274,7 +2274,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
88016 p.iph.ihl = 5;
88017 p.iph.protocol = IPPROTO_IPV6;
88018 p.iph.ttl = 64;
88019 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
88020 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
88021
88022 if (ops->ndo_do_ioctl) {
88023 mm_segment_t oldfs = get_fs();
88024 @@ -4412,7 +4412,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
88025 int *valp = ctl->data;
88026 int val = *valp;
88027 loff_t pos = *ppos;
88028 - ctl_table lctl;
88029 + ctl_table_no_const lctl;
88030 int ret;
88031
88032 /*
88033 @@ -4494,7 +4494,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
88034 int *valp = ctl->data;
88035 int val = *valp;
88036 loff_t pos = *ppos;
88037 - ctl_table lctl;
88038 + ctl_table_no_const lctl;
88039 int ret;
88040
88041 /*
88042 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
88043 index fff5bdd..15194fb 100644
88044 --- a/net/ipv6/icmp.c
88045 +++ b/net/ipv6/icmp.c
88046 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
88047
88048 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
88049 {
88050 - struct ctl_table *table;
88051 + ctl_table_no_const *table;
88052
88053 table = kmemdup(ipv6_icmp_table_template,
88054 sizeof(ipv6_icmp_table_template),
88055 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
88056 index 95d13c7..791fe2f 100644
88057 --- a/net/ipv6/ip6_gre.c
88058 +++ b/net/ipv6/ip6_gre.c
88059 @@ -73,7 +73,7 @@ struct ip6gre_net {
88060 struct net_device *fb_tunnel_dev;
88061 };
88062
88063 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
88064 +static struct rtnl_link_ops ip6gre_link_ops;
88065 static int ip6gre_tunnel_init(struct net_device *dev);
88066 static void ip6gre_tunnel_setup(struct net_device *dev);
88067 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
88068 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
88069 }
88070
88071
88072 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
88073 +static struct inet6_protocol ip6gre_protocol = {
88074 .handler = ip6gre_rcv,
88075 .err_handler = ip6gre_err,
88076 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
88077 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
88078 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
88079 };
88080
88081 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88082 +static struct rtnl_link_ops ip6gre_link_ops = {
88083 .kind = "ip6gre",
88084 .maxtype = IFLA_GRE_MAX,
88085 .policy = ip6gre_policy,
88086 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88087 .fill_info = ip6gre_fill_info,
88088 };
88089
88090 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
88091 +static struct rtnl_link_ops ip6gre_tap_ops = {
88092 .kind = "ip6gretap",
88093 .maxtype = IFLA_GRE_MAX,
88094 .policy = ip6gre_policy,
88095 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
88096 index 851fdae..9d4d1fd 100644
88097 --- a/net/ipv6/ip6_output.c
88098 +++ b/net/ipv6/ip6_output.c
88099 @@ -822,11 +822,17 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
88100 const struct flowi6 *fl6)
88101 {
88102 struct ipv6_pinfo *np = inet6_sk(sk);
88103 - struct rt6_info *rt = (struct rt6_info *)dst;
88104 + struct rt6_info *rt;
88105
88106 if (!dst)
88107 goto out;
88108
88109 + if (dst->ops->family != AF_INET6) {
88110 + dst_release(dst);
88111 + return NULL;
88112 + }
88113 +
88114 + rt = (struct rt6_info *)dst;
88115 /* Yes, checking route validity in not connected
88116 * case is not very simple. Take into account,
88117 * that we do not support routing by source, TOS,
88118 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
88119 index fff83cb..82d49dd 100644
88120 --- a/net/ipv6/ip6_tunnel.c
88121 +++ b/net/ipv6/ip6_tunnel.c
88122 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
88123
88124 static int ip6_tnl_dev_init(struct net_device *dev);
88125 static void ip6_tnl_dev_setup(struct net_device *dev);
88126 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
88127 +static struct rtnl_link_ops ip6_link_ops;
88128
88129 static int ip6_tnl_net_id __read_mostly;
88130 struct ip6_tnl_net {
88131 @@ -1684,7 +1684,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
88132 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
88133 };
88134
88135 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
88136 +static struct rtnl_link_ops ip6_link_ops = {
88137 .kind = "ip6tnl",
88138 .maxtype = IFLA_IPTUN_MAX,
88139 .policy = ip6_tnl_policy,
88140 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
88141 index d1e2e8e..51c19ae 100644
88142 --- a/net/ipv6/ipv6_sockglue.c
88143 +++ b/net/ipv6/ipv6_sockglue.c
88144 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
88145 if (sk->sk_type != SOCK_STREAM)
88146 return -ENOPROTOOPT;
88147
88148 - msg.msg_control = optval;
88149 + msg.msg_control = (void __force_kernel *)optval;
88150 msg.msg_controllen = len;
88151 msg.msg_flags = flags;
88152
88153 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
88154 index 341b54a..591e8ed 100644
88155 --- a/net/ipv6/netfilter/ip6_tables.c
88156 +++ b/net/ipv6/netfilter/ip6_tables.c
88157 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
88158 #endif
88159
88160 static int get_info(struct net *net, void __user *user,
88161 - const int *len, int compat)
88162 + int len, int compat)
88163 {
88164 char name[XT_TABLE_MAXNAMELEN];
88165 struct xt_table *t;
88166 int ret;
88167
88168 - if (*len != sizeof(struct ip6t_getinfo)) {
88169 - duprintf("length %u != %zu\n", *len,
88170 + if (len != sizeof(struct ip6t_getinfo)) {
88171 + duprintf("length %u != %zu\n", len,
88172 sizeof(struct ip6t_getinfo));
88173 return -EINVAL;
88174 }
88175 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
88176 info.size = private->size;
88177 strcpy(info.name, name);
88178
88179 - if (copy_to_user(user, &info, *len) != 0)
88180 + if (copy_to_user(user, &info, len) != 0)
88181 ret = -EFAULT;
88182 else
88183 ret = 0;
88184 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88185
88186 switch (cmd) {
88187 case IP6T_SO_GET_INFO:
88188 - ret = get_info(sock_net(sk), user, len, 1);
88189 + ret = get_info(sock_net(sk), user, *len, 1);
88190 break;
88191 case IP6T_SO_GET_ENTRIES:
88192 ret = compat_get_entries(sock_net(sk), user, len);
88193 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88194
88195 switch (cmd) {
88196 case IP6T_SO_GET_INFO:
88197 - ret = get_info(sock_net(sk), user, len, 0);
88198 + ret = get_info(sock_net(sk), user, *len, 0);
88199 break;
88200
88201 case IP6T_SO_GET_ENTRIES:
88202 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
88203 index 6700069..1e50f42 100644
88204 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
88205 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
88206 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
88207
88208 static int nf_ct_frag6_sysctl_register(struct net *net)
88209 {
88210 - struct ctl_table *table;
88211 + ctl_table_no_const *table = NULL;
88212 struct ctl_table_header *hdr;
88213
88214 - table = nf_ct_frag6_sysctl_table;
88215 if (!net_eq(net, &init_net)) {
88216 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
88217 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
88218 GFP_KERNEL);
88219 if (table == NULL)
88220 goto err_alloc;
88221 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88222 table[0].data = &net->nf_frag.frags.timeout;
88223 table[1].data = &net->nf_frag.frags.low_thresh;
88224 table[2].data = &net->nf_frag.frags.high_thresh;
88225 - }
88226 -
88227 - hdr = register_net_sysctl(net, "net/netfilter", table);
88228 + hdr = register_net_sysctl(net, "net/netfilter", table);
88229 + } else
88230 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
88231 if (hdr == NULL)
88232 goto err_reg;
88233
88234 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88235 return 0;
88236
88237 err_reg:
88238 - if (!net_eq(net, &init_net))
88239 - kfree(table);
88240 + kfree(table);
88241 err_alloc:
88242 return -ENOMEM;
88243 }
88244 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
88245 index 330b5e7..796fbf1 100644
88246 --- a/net/ipv6/raw.c
88247 +++ b/net/ipv6/raw.c
88248 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
88249 {
88250 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
88251 skb_checksum_complete(skb)) {
88252 - atomic_inc(&sk->sk_drops);
88253 + atomic_inc_unchecked(&sk->sk_drops);
88254 kfree_skb(skb);
88255 return NET_RX_DROP;
88256 }
88257 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88258 struct raw6_sock *rp = raw6_sk(sk);
88259
88260 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
88261 - atomic_inc(&sk->sk_drops);
88262 + atomic_inc_unchecked(&sk->sk_drops);
88263 kfree_skb(skb);
88264 return NET_RX_DROP;
88265 }
88266 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88267
88268 if (inet->hdrincl) {
88269 if (skb_checksum_complete(skb)) {
88270 - atomic_inc(&sk->sk_drops);
88271 + atomic_inc_unchecked(&sk->sk_drops);
88272 kfree_skb(skb);
88273 return NET_RX_DROP;
88274 }
88275 @@ -603,7 +603,7 @@ out:
88276 return err;
88277 }
88278
88279 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
88280 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
88281 struct flowi6 *fl6, struct dst_entry **dstp,
88282 unsigned int flags)
88283 {
88284 @@ -915,12 +915,15 @@ do_confirm:
88285 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
88286 char __user *optval, int optlen)
88287 {
88288 + struct icmp6_filter filter;
88289 +
88290 switch (optname) {
88291 case ICMPV6_FILTER:
88292 if (optlen > sizeof(struct icmp6_filter))
88293 optlen = sizeof(struct icmp6_filter);
88294 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
88295 + if (copy_from_user(&filter, optval, optlen))
88296 return -EFAULT;
88297 + raw6_sk(sk)->filter = filter;
88298 return 0;
88299 default:
88300 return -ENOPROTOOPT;
88301 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88302 char __user *optval, int __user *optlen)
88303 {
88304 int len;
88305 + struct icmp6_filter filter;
88306
88307 switch (optname) {
88308 case ICMPV6_FILTER:
88309 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88310 len = sizeof(struct icmp6_filter);
88311 if (put_user(len, optlen))
88312 return -EFAULT;
88313 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88314 + filter = raw6_sk(sk)->filter;
88315 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88316 return -EFAULT;
88317 return 0;
88318 default:
88319 @@ -1252,7 +1257,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88320 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88321 0,
88322 sock_i_ino(sp),
88323 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88324 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88325 }
88326
88327 static int raw6_seq_show(struct seq_file *seq, void *v)
88328 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88329 index 0ba10e5..c14a4f6 100644
88330 --- a/net/ipv6/reassembly.c
88331 +++ b/net/ipv6/reassembly.c
88332 @@ -602,12 +602,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88333
88334 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88335 {
88336 - struct ctl_table *table;
88337 + ctl_table_no_const *table = NULL;
88338 struct ctl_table_header *hdr;
88339
88340 - table = ip6_frags_ns_ctl_table;
88341 if (!net_eq(net, &init_net)) {
88342 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88343 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88344 if (table == NULL)
88345 goto err_alloc;
88346
88347 @@ -618,9 +617,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88348 /* Don't export sysctls to unprivileged users */
88349 if (net->user_ns != &init_user_ns)
88350 table[0].procname = NULL;
88351 - }
88352 + hdr = register_net_sysctl(net, "net/ipv6", table);
88353 + } else
88354 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88355
88356 - hdr = register_net_sysctl(net, "net/ipv6", table);
88357 if (hdr == NULL)
88358 goto err_reg;
88359
88360 @@ -628,8 +628,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88361 return 0;
88362
88363 err_reg:
88364 - if (!net_eq(net, &init_net))
88365 - kfree(table);
88366 + kfree(table);
88367 err_alloc:
88368 return -ENOMEM;
88369 }
88370 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88371 index e5fe004..9fe3e8e 100644
88372 --- a/net/ipv6/route.c
88373 +++ b/net/ipv6/route.c
88374 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
88375
88376 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88377 {
88378 - struct ctl_table *table;
88379 + ctl_table_no_const *table;
88380
88381 table = kmemdup(ipv6_route_table_template,
88382 sizeof(ipv6_route_table_template),
88383 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88384 index 02f96dc..4a5a6e5 100644
88385 --- a/net/ipv6/sit.c
88386 +++ b/net/ipv6/sit.c
88387 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
88388 static void ipip6_dev_free(struct net_device *dev);
88389 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
88390 __be32 *v4dst);
88391 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88392 +static struct rtnl_link_ops sit_link_ops;
88393
88394 static int sit_net_id __read_mostly;
88395 struct sit_net {
88396 @@ -1486,7 +1486,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88397 #endif
88398 };
88399
88400 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88401 +static struct rtnl_link_ops sit_link_ops = {
88402 .kind = "sit",
88403 .maxtype = IFLA_IPTUN_MAX,
88404 .policy = ipip6_policy,
88405 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88406 index e85c48b..b8268d3 100644
88407 --- a/net/ipv6/sysctl_net_ipv6.c
88408 +++ b/net/ipv6/sysctl_net_ipv6.c
88409 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88410
88411 static int __net_init ipv6_sysctl_net_init(struct net *net)
88412 {
88413 - struct ctl_table *ipv6_table;
88414 + ctl_table_no_const *ipv6_table;
88415 struct ctl_table *ipv6_route_table;
88416 struct ctl_table *ipv6_icmp_table;
88417 int err;
88418 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88419 index 0fce928..c52a518 100644
88420 --- a/net/ipv6/tcp_ipv6.c
88421 +++ b/net/ipv6/tcp_ipv6.c
88422 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88423 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88424 }
88425
88426 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88427 +extern int grsec_enable_blackhole;
88428 +#endif
88429 +
88430 static void tcp_v6_hash(struct sock *sk)
88431 {
88432 if (sk->sk_state != TCP_CLOSE) {
88433 @@ -1446,6 +1450,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88434 return 0;
88435
88436 reset:
88437 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88438 + if (!grsec_enable_blackhole)
88439 +#endif
88440 tcp_v6_send_reset(sk, skb);
88441 discard:
88442 if (opt_skb)
88443 @@ -1527,12 +1534,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88444 TCP_SKB_CB(skb)->sacked = 0;
88445
88446 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88447 - if (!sk)
88448 + if (!sk) {
88449 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88450 + ret = 1;
88451 +#endif
88452 goto no_tcp_socket;
88453 + }
88454
88455 process:
88456 - if (sk->sk_state == TCP_TIME_WAIT)
88457 + if (sk->sk_state == TCP_TIME_WAIT) {
88458 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88459 + ret = 2;
88460 +#endif
88461 goto do_time_wait;
88462 + }
88463
88464 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88465 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88466 @@ -1581,6 +1596,10 @@ no_tcp_socket:
88467 bad_packet:
88468 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88469 } else {
88470 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88471 + if (!grsec_enable_blackhole || (ret == 1 &&
88472 + (skb->dev->flags & IFF_LOOPBACK)))
88473 +#endif
88474 tcp_v6_send_reset(NULL, skb);
88475 }
88476
88477 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88478 index 27f0f8e..949e7ee 100644
88479 --- a/net/ipv6/udp.c
88480 +++ b/net/ipv6/udp.c
88481 @@ -52,6 +52,10 @@
88482 #include <trace/events/skb.h>
88483 #include "udp_impl.h"
88484
88485 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88486 +extern int grsec_enable_blackhole;
88487 +#endif
88488 +
88489 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88490 {
88491 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88492 @@ -419,7 +423,7 @@ try_again:
88493 if (unlikely(err)) {
88494 trace_kfree_skb(skb, udpv6_recvmsg);
88495 if (!peeked) {
88496 - atomic_inc(&sk->sk_drops);
88497 + atomic_inc_unchecked(&sk->sk_drops);
88498 if (is_udp4)
88499 UDP_INC_STATS_USER(sock_net(sk),
88500 UDP_MIB_INERRORS,
88501 @@ -657,7 +661,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88502 return rc;
88503 drop:
88504 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88505 - atomic_inc(&sk->sk_drops);
88506 + atomic_inc_unchecked(&sk->sk_drops);
88507 kfree_skb(skb);
88508 return -1;
88509 }
88510 @@ -715,7 +719,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88511 if (likely(skb1 == NULL))
88512 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88513 if (!skb1) {
88514 - atomic_inc(&sk->sk_drops);
88515 + atomic_inc_unchecked(&sk->sk_drops);
88516 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88517 IS_UDPLITE(sk));
88518 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88519 @@ -852,6 +856,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88520 goto discard;
88521
88522 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88523 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88524 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88525 +#endif
88526 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88527
88528 kfree_skb(skb);
88529 @@ -1377,7 +1384,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88530 0,
88531 sock_i_ino(sp),
88532 atomic_read(&sp->sk_refcnt), sp,
88533 - atomic_read(&sp->sk_drops));
88534 + atomic_read_unchecked(&sp->sk_drops));
88535 }
88536
88537 int udp6_seq_show(struct seq_file *seq, void *v)
88538 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
88539 index 23ed03d..465a71d 100644
88540 --- a/net/ipv6/xfrm6_policy.c
88541 +++ b/net/ipv6/xfrm6_policy.c
88542 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
88543
88544 static int __net_init xfrm6_net_init(struct net *net)
88545 {
88546 - struct ctl_table *table;
88547 + ctl_table_no_const *table = NULL;
88548 struct ctl_table_header *hdr;
88549
88550 - table = xfrm6_policy_table;
88551 if (!net_eq(net, &init_net)) {
88552 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
88553 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
88554 if (!table)
88555 goto err_alloc;
88556
88557 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
88558 - }
88559 + hdr = register_net_sysctl(net, "net/ipv6", table);
88560 + } else
88561 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
88562
88563 - hdr = register_net_sysctl(net, "net/ipv6", table);
88564 if (!hdr)
88565 goto err_reg;
88566
88567 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
88568 return 0;
88569
88570 err_reg:
88571 - if (!net_eq(net, &init_net))
88572 - kfree(table);
88573 + kfree(table);
88574 err_alloc:
88575 return -ENOMEM;
88576 }
88577 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88578 index 362ba47..66196f4 100644
88579 --- a/net/irda/ircomm/ircomm_tty.c
88580 +++ b/net/irda/ircomm/ircomm_tty.c
88581 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88582 add_wait_queue(&port->open_wait, &wait);
88583
88584 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88585 - __FILE__, __LINE__, tty->driver->name, port->count);
88586 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88587
88588 spin_lock_irqsave(&port->lock, flags);
88589 if (!tty_hung_up_p(filp))
88590 - port->count--;
88591 + atomic_dec(&port->count);
88592 port->blocked_open++;
88593 spin_unlock_irqrestore(&port->lock, flags);
88594
88595 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88596 }
88597
88598 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88599 - __FILE__, __LINE__, tty->driver->name, port->count);
88600 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88601
88602 schedule();
88603 }
88604 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88605
88606 spin_lock_irqsave(&port->lock, flags);
88607 if (!tty_hung_up_p(filp))
88608 - port->count++;
88609 + atomic_inc(&port->count);
88610 port->blocked_open--;
88611 spin_unlock_irqrestore(&port->lock, flags);
88612
88613 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88614 - __FILE__, __LINE__, tty->driver->name, port->count);
88615 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88616
88617 if (!retval)
88618 port->flags |= ASYNC_NORMAL_ACTIVE;
88619 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88620
88621 /* ++ is not atomic, so this should be protected - Jean II */
88622 spin_lock_irqsave(&self->port.lock, flags);
88623 - self->port.count++;
88624 + atomic_inc(&self->port.count);
88625 spin_unlock_irqrestore(&self->port.lock, flags);
88626 tty_port_tty_set(&self->port, tty);
88627
88628 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88629 - self->line, self->port.count);
88630 + self->line, atomic_read(&self->port.count));
88631
88632 /* Not really used by us, but lets do it anyway */
88633 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88634 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88635 tty_kref_put(port->tty);
88636 }
88637 port->tty = NULL;
88638 - port->count = 0;
88639 + atomic_set(&port->count, 0);
88640 spin_unlock_irqrestore(&port->lock, flags);
88641
88642 wake_up_interruptible(&port->open_wait);
88643 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88644 seq_putc(m, '\n');
88645
88646 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88647 - seq_printf(m, "Open count: %d\n", self->port.count);
88648 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88649 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88650 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88651
88652 diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c
88653 index 8c00416..9ea0c93 100644
88654 --- a/net/irda/irlap_frame.c
88655 +++ b/net/irda/irlap_frame.c
88656 @@ -544,7 +544,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
88657 /*
88658 * We now have some discovery info to deliver!
88659 */
88660 - discovery = kmalloc(sizeof(discovery_t), GFP_ATOMIC);
88661 + discovery = kzalloc(sizeof(discovery_t), GFP_ATOMIC);
88662 if (!discovery) {
88663 IRDA_WARNING("%s: unable to malloc!\n", __func__);
88664 return;
88665 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88666 index 206ce6d..cfb27cd 100644
88667 --- a/net/iucv/af_iucv.c
88668 +++ b/net/iucv/af_iucv.c
88669 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
88670
88671 write_lock_bh(&iucv_sk_list.lock);
88672
88673 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88674 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88675 while (__iucv_get_sock_by_name(name)) {
88676 sprintf(name, "%08x",
88677 - atomic_inc_return(&iucv_sk_list.autobind_name));
88678 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88679 }
88680
88681 write_unlock_bh(&iucv_sk_list.lock);
88682 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88683 index 4fe76ff..426a904 100644
88684 --- a/net/iucv/iucv.c
88685 +++ b/net/iucv/iucv.c
88686 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88687 return NOTIFY_OK;
88688 }
88689
88690 -static struct notifier_block __refdata iucv_cpu_notifier = {
88691 +static struct notifier_block iucv_cpu_notifier = {
88692 .notifier_call = iucv_cpu_notify,
88693 };
88694
88695 diff --git a/net/key/af_key.c b/net/key/af_key.c
88696 index 5b1e5af..1b929e7 100644
88697 --- a/net/key/af_key.c
88698 +++ b/net/key/af_key.c
88699 @@ -1710,6 +1710,7 @@ static int key_notify_sa_flush(const struct km_event *c)
88700 hdr->sadb_msg_version = PF_KEY_V2;
88701 hdr->sadb_msg_errno = (uint8_t) 0;
88702 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
88703 + hdr->sadb_msg_reserved = 0;
88704
88705 pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
88706
88707 @@ -2695,6 +2696,7 @@ static int key_notify_policy_flush(const struct km_event *c)
88708 hdr->sadb_msg_errno = (uint8_t) 0;
88709 hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC;
88710 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
88711 + hdr->sadb_msg_reserved = 0;
88712 pfkey_broadcast(skb_out, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
88713 return 0;
88714
88715 @@ -3041,10 +3043,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88716 static u32 get_acqseq(void)
88717 {
88718 u32 res;
88719 - static atomic_t acqseq;
88720 + static atomic_unchecked_t acqseq;
88721
88722 do {
88723 - res = atomic_inc_return(&acqseq);
88724 + res = atomic_inc_return_unchecked(&acqseq);
88725 } while (!res);
88726 return res;
88727 }
88728 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88729 index 843d8c4..cb04fa1 100644
88730 --- a/net/mac80211/cfg.c
88731 +++ b/net/mac80211/cfg.c
88732 @@ -799,7 +799,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88733 ret = ieee80211_vif_use_channel(sdata, chandef,
88734 IEEE80211_CHANCTX_EXCLUSIVE);
88735 }
88736 - } else if (local->open_count == local->monitors) {
88737 + } else if (local_read(&local->open_count) == local->monitors) {
88738 local->_oper_channel = chandef->chan;
88739 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88740 ieee80211_hw_config(local, 0);
88741 @@ -2834,7 +2834,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88742 else
88743 local->probe_req_reg--;
88744
88745 - if (!local->open_count)
88746 + if (!local_read(&local->open_count))
88747 break;
88748
88749 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88750 @@ -3297,8 +3297,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
88751 if (chanctx_conf) {
88752 *chandef = chanctx_conf->def;
88753 ret = 0;
88754 - } else if (local->open_count > 0 &&
88755 - local->open_count == local->monitors &&
88756 + } else if (local_read(&local->open_count) > 0 &&
88757 + local_read(&local->open_count) == local->monitors &&
88758 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
88759 if (local->use_chanctx)
88760 *chandef = local->monitor_chandef;
88761 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88762 index 5672533..6738c93 100644
88763 --- a/net/mac80211/ieee80211_i.h
88764 +++ b/net/mac80211/ieee80211_i.h
88765 @@ -28,6 +28,7 @@
88766 #include <net/ieee80211_radiotap.h>
88767 #include <net/cfg80211.h>
88768 #include <net/mac80211.h>
88769 +#include <asm/local.h>
88770 #include "key.h"
88771 #include "sta_info.h"
88772 #include "debug.h"
88773 @@ -897,7 +898,7 @@ struct ieee80211_local {
88774 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88775 spinlock_t queue_stop_reason_lock;
88776
88777 - int open_count;
88778 + local_t open_count;
88779 int monitors, cooked_mntrs;
88780 /* number of interfaces with corresponding FIF_ flags */
88781 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88782 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88783 index 9cbebc2..14879bb 100644
88784 --- a/net/mac80211/iface.c
88785 +++ b/net/mac80211/iface.c
88786 @@ -495,7 +495,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88787 break;
88788 }
88789
88790 - if (local->open_count == 0) {
88791 + if (local_read(&local->open_count) == 0) {
88792 res = drv_start(local);
88793 if (res)
88794 goto err_del_bss;
88795 @@ -540,7 +540,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88796 break;
88797 }
88798
88799 - if (local->monitors == 0 && local->open_count == 0) {
88800 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88801 res = ieee80211_add_virtual_monitor(local);
88802 if (res)
88803 goto err_stop;
88804 @@ -649,7 +649,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88805 atomic_inc(&local->iff_promiscs);
88806
88807 if (coming_up)
88808 - local->open_count++;
88809 + local_inc(&local->open_count);
88810
88811 if (hw_reconf_flags)
88812 ieee80211_hw_config(local, hw_reconf_flags);
88813 @@ -663,7 +663,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88814 err_del_interface:
88815 drv_remove_interface(local, sdata);
88816 err_stop:
88817 - if (!local->open_count)
88818 + if (!local_read(&local->open_count))
88819 drv_stop(local);
88820 err_del_bss:
88821 sdata->bss = NULL;
88822 @@ -806,7 +806,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88823 }
88824
88825 if (going_down)
88826 - local->open_count--;
88827 + local_dec(&local->open_count);
88828
88829 switch (sdata->vif.type) {
88830 case NL80211_IFTYPE_AP_VLAN:
88831 @@ -871,7 +871,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88832
88833 ieee80211_recalc_ps(local, -1);
88834
88835 - if (local->open_count == 0) {
88836 + if (local_read(&local->open_count) == 0) {
88837 if (local->ops->napi_poll)
88838 napi_disable(&local->napi);
88839 ieee80211_clear_tx_pending(local);
88840 @@ -897,7 +897,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88841 }
88842 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88843
88844 - if (local->monitors == local->open_count && local->monitors > 0)
88845 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88846 ieee80211_add_virtual_monitor(local);
88847 }
88848
88849 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88850 index 1a8591b..ef5db54 100644
88851 --- a/net/mac80211/main.c
88852 +++ b/net/mac80211/main.c
88853 @@ -180,7 +180,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88854 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88855 IEEE80211_CONF_CHANGE_POWER);
88856
88857 - if (changed && local->open_count) {
88858 + if (changed && local_read(&local->open_count)) {
88859 ret = drv_config(local, changed);
88860 /*
88861 * Goal:
88862 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88863 index 835584c..be46e67 100644
88864 --- a/net/mac80211/pm.c
88865 +++ b/net/mac80211/pm.c
88866 @@ -33,7 +33,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88867 struct sta_info *sta;
88868 struct ieee80211_chanctx *ctx;
88869
88870 - if (!local->open_count)
88871 + if (!local_read(&local->open_count))
88872 goto suspend;
88873
88874 ieee80211_scan_cancel(local);
88875 @@ -75,7 +75,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88876 cancel_work_sync(&local->dynamic_ps_enable_work);
88877 del_timer_sync(&local->dynamic_ps_timer);
88878
88879 - local->wowlan = wowlan && local->open_count;
88880 + local->wowlan = wowlan && local_read(&local->open_count);
88881 if (local->wowlan) {
88882 int err = drv_suspend(local, wowlan);
88883 if (err < 0) {
88884 @@ -214,7 +214,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88885 mutex_unlock(&local->chanctx_mtx);
88886
88887 /* stop hardware - this must stop RX */
88888 - if (local->open_count)
88889 + if (local_read(&local->open_count))
88890 ieee80211_stop_device(local);
88891
88892 suspend:
88893 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88894 index dd88381..eef4dd6 100644
88895 --- a/net/mac80211/rate.c
88896 +++ b/net/mac80211/rate.c
88897 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88898
88899 ASSERT_RTNL();
88900
88901 - if (local->open_count)
88902 + if (local_read(&local->open_count))
88903 return -EBUSY;
88904
88905 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88906 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88907 index c97a065..ff61928 100644
88908 --- a/net/mac80211/rc80211_pid_debugfs.c
88909 +++ b/net/mac80211/rc80211_pid_debugfs.c
88910 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88911
88912 spin_unlock_irqrestore(&events->lock, status);
88913
88914 - if (copy_to_user(buf, pb, p))
88915 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88916 return -EFAULT;
88917
88918 return p;
88919 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88920 index 0f38f43..e53d4a8 100644
88921 --- a/net/mac80211/util.c
88922 +++ b/net/mac80211/util.c
88923 @@ -1388,7 +1388,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88924 }
88925 #endif
88926 /* everything else happens only if HW was up & running */
88927 - if (!local->open_count)
88928 + if (!local_read(&local->open_count))
88929 goto wake_up;
88930
88931 /*
88932 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88933 index 56d22ca..87c778f 100644
88934 --- a/net/netfilter/Kconfig
88935 +++ b/net/netfilter/Kconfig
88936 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
88937
88938 To compile it as a module, choose M here. If unsure, say N.
88939
88940 +config NETFILTER_XT_MATCH_GRADM
88941 + tristate '"gradm" match support'
88942 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88943 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88944 + ---help---
88945 + The gradm match allows to match on grsecurity RBAC being enabled.
88946 + It is useful when iptables rules are applied early on bootup to
88947 + prevent connections to the machine (except from a trusted host)
88948 + while the RBAC system is disabled.
88949 +
88950 config NETFILTER_XT_MATCH_HASHLIMIT
88951 tristate '"hashlimit" match support'
88952 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88953 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88954 index a1abf87..dbcb7ee 100644
88955 --- a/net/netfilter/Makefile
88956 +++ b/net/netfilter/Makefile
88957 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88958 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88959 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88960 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88961 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88962 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88963 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88964 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88965 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88966 index 1ba9dbc..e39f4ca 100644
88967 --- a/net/netfilter/ipset/ip_set_core.c
88968 +++ b/net/netfilter/ipset/ip_set_core.c
88969 @@ -1801,7 +1801,7 @@ done:
88970 return ret;
88971 }
88972
88973 -static struct nf_sockopt_ops so_set __read_mostly = {
88974 +static struct nf_sockopt_ops so_set = {
88975 .pf = PF_INET,
88976 .get_optmin = SO_IP_SET,
88977 .get_optmax = SO_IP_SET + 1,
88978 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88979 index 704e514..d644cc2 100644
88980 --- a/net/netfilter/ipvs/ip_vs_conn.c
88981 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88982 @@ -551,7 +551,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88983 /* Increase the refcnt counter of the dest */
88984 atomic_inc(&dest->refcnt);
88985
88986 - conn_flags = atomic_read(&dest->conn_flags);
88987 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88988 if (cp->protocol != IPPROTO_UDP)
88989 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88990 flags = cp->flags;
88991 @@ -895,7 +895,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88992 atomic_set(&cp->refcnt, 1);
88993
88994 atomic_set(&cp->n_control, 0);
88995 - atomic_set(&cp->in_pkts, 0);
88996 + atomic_set_unchecked(&cp->in_pkts, 0);
88997
88998 atomic_inc(&ipvs->conn_count);
88999 if (flags & IP_VS_CONN_F_NO_CPORT)
89000 @@ -1174,7 +1174,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
89001
89002 /* Don't drop the entry if its number of incoming packets is not
89003 located in [0, 8] */
89004 - i = atomic_read(&cp->in_pkts);
89005 + i = atomic_read_unchecked(&cp->in_pkts);
89006 if (i > 8 || i < 0) return 0;
89007
89008 if (!todrop_rate[i]) return 0;
89009 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
89010 index 61f49d2..6c8c5bc 100644
89011 --- a/net/netfilter/ipvs/ip_vs_core.c
89012 +++ b/net/netfilter/ipvs/ip_vs_core.c
89013 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
89014 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
89015 /* do not touch skb anymore */
89016
89017 - atomic_inc(&cp->in_pkts);
89018 + atomic_inc_unchecked(&cp->in_pkts);
89019 ip_vs_conn_put(cp);
89020 return ret;
89021 }
89022 @@ -1689,7 +1689,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
89023 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
89024 pkts = sysctl_sync_threshold(ipvs);
89025 else
89026 - pkts = atomic_add_return(1, &cp->in_pkts);
89027 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89028
89029 if (ipvs->sync_state & IP_VS_STATE_MASTER)
89030 ip_vs_sync_conn(net, cp, pkts);
89031 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
89032 index 9e2d1cc..6ed0748 100644
89033 --- a/net/netfilter/ipvs/ip_vs_ctl.c
89034 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
89035 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
89036 ip_vs_rs_hash(ipvs, dest);
89037 write_unlock_bh(&ipvs->rs_lock);
89038 }
89039 - atomic_set(&dest->conn_flags, conn_flags);
89040 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
89041
89042 /* bind the service */
89043 if (!dest->svc) {
89044 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
89045 * align with netns init in ip_vs_control_net_init()
89046 */
89047
89048 -static struct ctl_table vs_vars[] = {
89049 +static ctl_table_no_const vs_vars[] __read_only = {
89050 {
89051 .procname = "amemthresh",
89052 .maxlen = sizeof(int),
89053 @@ -2087,7 +2087,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89054 " %-7s %-6d %-10d %-10d\n",
89055 &dest->addr.in6,
89056 ntohs(dest->port),
89057 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89058 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89059 atomic_read(&dest->weight),
89060 atomic_read(&dest->activeconns),
89061 atomic_read(&dest->inactconns));
89062 @@ -2098,7 +2098,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89063 "%-7s %-6d %-10d %-10d\n",
89064 ntohl(dest->addr.ip),
89065 ntohs(dest->port),
89066 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89067 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89068 atomic_read(&dest->weight),
89069 atomic_read(&dest->activeconns),
89070 atomic_read(&dest->inactconns));
89071 @@ -2562,13 +2562,14 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
89072 struct ip_vs_dest *dest;
89073 struct ip_vs_dest_entry entry;
89074
89075 + memset(&entry, 0, sizeof(entry));
89076 list_for_each_entry(dest, &svc->destinations, n_list) {
89077 if (count >= get->num_dests)
89078 break;
89079
89080 entry.addr = dest->addr.ip;
89081 entry.port = dest->port;
89082 - entry.conn_flags = atomic_read(&dest->conn_flags);
89083 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
89084 entry.weight = atomic_read(&dest->weight);
89085 entry.u_threshold = dest->u_threshold;
89086 entry.l_threshold = dest->l_threshold;
89087 @@ -3104,7 +3105,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
89088 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
89089 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
89090 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
89091 - (atomic_read(&dest->conn_flags) &
89092 + (atomic_read_unchecked(&dest->conn_flags) &
89093 IP_VS_CONN_F_FWD_MASK)) ||
89094 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
89095 atomic_read(&dest->weight)) ||
89096 @@ -3694,7 +3695,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
89097 {
89098 int idx;
89099 struct netns_ipvs *ipvs = net_ipvs(net);
89100 - struct ctl_table *tbl;
89101 + ctl_table_no_const *tbl;
89102
89103 atomic_set(&ipvs->dropentry, 0);
89104 spin_lock_init(&ipvs->dropentry_lock);
89105 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
89106 index fdd89b9..bd96aa9 100644
89107 --- a/net/netfilter/ipvs/ip_vs_lblc.c
89108 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
89109 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
89110 * IPVS LBLC sysctl table
89111 */
89112 #ifdef CONFIG_SYSCTL
89113 -static ctl_table vs_vars_table[] = {
89114 +static ctl_table_no_const vs_vars_table[] __read_only = {
89115 {
89116 .procname = "lblc_expiration",
89117 .data = NULL,
89118 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
89119 index c03b6a3..8ce3681 100644
89120 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
89121 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
89122 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
89123 * IPVS LBLCR sysctl table
89124 */
89125
89126 -static ctl_table vs_vars_table[] = {
89127 +static ctl_table_no_const vs_vars_table[] __read_only = {
89128 {
89129 .procname = "lblcr_expiration",
89130 .data = NULL,
89131 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
89132 index 44fd10c..2a163b3 100644
89133 --- a/net/netfilter/ipvs/ip_vs_sync.c
89134 +++ b/net/netfilter/ipvs/ip_vs_sync.c
89135 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
89136 cp = cp->control;
89137 if (cp) {
89138 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89139 - pkts = atomic_add_return(1, &cp->in_pkts);
89140 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89141 else
89142 pkts = sysctl_sync_threshold(ipvs);
89143 ip_vs_sync_conn(net, cp->control, pkts);
89144 @@ -758,7 +758,7 @@ control:
89145 if (!cp)
89146 return;
89147 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89148 - pkts = atomic_add_return(1, &cp->in_pkts);
89149 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89150 else
89151 pkts = sysctl_sync_threshold(ipvs);
89152 goto sloop;
89153 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
89154
89155 if (opt)
89156 memcpy(&cp->in_seq, opt, sizeof(*opt));
89157 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89158 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89159 cp->state = state;
89160 cp->old_state = cp->state;
89161 /*
89162 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
89163 index ee6b7a9..f9a89f6 100644
89164 --- a/net/netfilter/ipvs/ip_vs_xmit.c
89165 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
89166 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
89167 else
89168 rc = NF_ACCEPT;
89169 /* do not touch skb anymore */
89170 - atomic_inc(&cp->in_pkts);
89171 + atomic_inc_unchecked(&cp->in_pkts);
89172 goto out;
89173 }
89174
89175 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
89176 else
89177 rc = NF_ACCEPT;
89178 /* do not touch skb anymore */
89179 - atomic_inc(&cp->in_pkts);
89180 + atomic_inc_unchecked(&cp->in_pkts);
89181 goto out;
89182 }
89183
89184 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
89185 index 2d3030a..7ba1c0a 100644
89186 --- a/net/netfilter/nf_conntrack_acct.c
89187 +++ b/net/netfilter/nf_conntrack_acct.c
89188 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
89189 #ifdef CONFIG_SYSCTL
89190 static int nf_conntrack_acct_init_sysctl(struct net *net)
89191 {
89192 - struct ctl_table *table;
89193 + ctl_table_no_const *table;
89194
89195 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
89196 GFP_KERNEL);
89197 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
89198 index c8e001a..f842a8b 100644
89199 --- a/net/netfilter/nf_conntrack_core.c
89200 +++ b/net/netfilter/nf_conntrack_core.c
89201 @@ -1594,6 +1594,10 @@ void nf_conntrack_init_end(void)
89202 #define DYING_NULLS_VAL ((1<<30)+1)
89203 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
89204
89205 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89206 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
89207 +#endif
89208 +
89209 int nf_conntrack_init_net(struct net *net)
89210 {
89211 int ret;
89212 @@ -1608,7 +1612,11 @@ int nf_conntrack_init_net(struct net *net)
89213 goto err_stat;
89214 }
89215
89216 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89217 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
89218 +#else
89219 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
89220 +#endif
89221 if (!net->ct.slabname) {
89222 ret = -ENOMEM;
89223 goto err_slabname;
89224 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
89225 index b5d2eb8..61ef19a 100644
89226 --- a/net/netfilter/nf_conntrack_ecache.c
89227 +++ b/net/netfilter/nf_conntrack_ecache.c
89228 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
89229 #ifdef CONFIG_SYSCTL
89230 static int nf_conntrack_event_init_sysctl(struct net *net)
89231 {
89232 - struct ctl_table *table;
89233 + ctl_table_no_const *table;
89234
89235 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
89236 GFP_KERNEL);
89237 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
89238 index 94b4b98..97cf0ad 100644
89239 --- a/net/netfilter/nf_conntrack_helper.c
89240 +++ b/net/netfilter/nf_conntrack_helper.c
89241 @@ -56,7 +56,7 @@ static struct ctl_table helper_sysctl_table[] = {
89242
89243 static int nf_conntrack_helper_init_sysctl(struct net *net)
89244 {
89245 - struct ctl_table *table;
89246 + ctl_table_no_const *table;
89247
89248 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
89249 GFP_KERNEL);
89250 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
89251 index 58ab405..50eb8d3 100644
89252 --- a/net/netfilter/nf_conntrack_proto.c
89253 +++ b/net/netfilter/nf_conntrack_proto.c
89254 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
89255
89256 static void
89257 nf_ct_unregister_sysctl(struct ctl_table_header **header,
89258 - struct ctl_table **table,
89259 + ctl_table_no_const **table,
89260 unsigned int users)
89261 {
89262 if (users > 0)
89263 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
89264 index ba65b20..2a4d937 100644
89265 --- a/net/netfilter/nf_conntrack_proto_dccp.c
89266 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
89267 @@ -456,7 +456,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
89268
89269 out_invalid:
89270 if (LOG_INVALID(net, IPPROTO_DCCP))
89271 - nf_log_packet(nf_ct_l3num(ct), 0, skb, NULL, NULL, NULL, msg);
89272 + nf_log_packet(nf_ct_l3num(ct), 0, skb, NULL, NULL, NULL, "%s", msg);
89273 return false;
89274 }
89275
89276 @@ -613,7 +613,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
89277
89278 out_invalid:
89279 if (LOG_INVALID(net, IPPROTO_DCCP))
89280 - nf_log_packet(pf, 0, skb, NULL, NULL, NULL, msg);
89281 + nf_log_packet(pf, 0, skb, NULL, NULL, NULL, "%s", msg);
89282 return -NF_ACCEPT;
89283 }
89284
89285 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
89286 index fedee39..d62a93d 100644
89287 --- a/net/netfilter/nf_conntrack_standalone.c
89288 +++ b/net/netfilter/nf_conntrack_standalone.c
89289 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
89290
89291 static int nf_conntrack_standalone_init_sysctl(struct net *net)
89292 {
89293 - struct ctl_table *table;
89294 + ctl_table_no_const *table;
89295
89296 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
89297 GFP_KERNEL);
89298 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
89299 index 902fb0a..87f7fdb 100644
89300 --- a/net/netfilter/nf_conntrack_timestamp.c
89301 +++ b/net/netfilter/nf_conntrack_timestamp.c
89302 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
89303 #ifdef CONFIG_SYSCTL
89304 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
89305 {
89306 - struct ctl_table *table;
89307 + ctl_table_no_const *table;
89308
89309 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
89310 GFP_KERNEL);
89311 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
89312 index 9e31269..bc4c1b7 100644
89313 --- a/net/netfilter/nf_log.c
89314 +++ b/net/netfilter/nf_log.c
89315 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
89316
89317 #ifdef CONFIG_SYSCTL
89318 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
89319 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
89320 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
89321 static struct ctl_table_header *nf_log_dir_header;
89322
89323 static int nf_log_proc_dostring(ctl_table *table, int write,
89324 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
89325 rcu_assign_pointer(nf_loggers[tindex], logger);
89326 mutex_unlock(&nf_log_mutex);
89327 } else {
89328 + ctl_table_no_const nf_log_table = *table;
89329 +
89330 mutex_lock(&nf_log_mutex);
89331 logger = rcu_dereference_protected(nf_loggers[tindex],
89332 lockdep_is_held(&nf_log_mutex));
89333 if (!logger)
89334 - table->data = "NONE";
89335 + nf_log_table.data = "NONE";
89336 else
89337 - table->data = logger->name;
89338 - r = proc_dostring(table, write, buffer, lenp, ppos);
89339 + nf_log_table.data = logger->name;
89340 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
89341 mutex_unlock(&nf_log_mutex);
89342 }
89343
89344 diff --git a/net/netfilter/nf_nat_sip.c b/net/netfilter/nf_nat_sip.c
89345 index 96ccdf7..dac11f7 100644
89346 --- a/net/netfilter/nf_nat_sip.c
89347 +++ b/net/netfilter/nf_nat_sip.c
89348 @@ -230,9 +230,10 @@ static unsigned int nf_nat_sip(struct sk_buff *skb, unsigned int protoff,
89349 &ct->tuplehash[!dir].tuple.src.u3,
89350 false);
89351 if (!mangle_packet(skb, protoff, dataoff, dptr, datalen,
89352 - poff, plen, buffer, buflen))
89353 + poff, plen, buffer, buflen)) {
89354 nf_ct_helper_log(skb, ct, "cannot mangle received");
89355 return NF_DROP;
89356 + }
89357 }
89358
89359 /* The rport= parameter (RFC 3581) contains the port number
89360 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
89361 index f042ae5..30ea486 100644
89362 --- a/net/netfilter/nf_sockopt.c
89363 +++ b/net/netfilter/nf_sockopt.c
89364 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
89365 }
89366 }
89367
89368 - list_add(&reg->list, &nf_sockopts);
89369 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
89370 out:
89371 mutex_unlock(&nf_sockopt_mutex);
89372 return ret;
89373 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
89374 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
89375 {
89376 mutex_lock(&nf_sockopt_mutex);
89377 - list_del(&reg->list);
89378 + pax_list_del((struct list_head *)&reg->list);
89379 mutex_unlock(&nf_sockopt_mutex);
89380 }
89381 EXPORT_SYMBOL(nf_unregister_sockopt);
89382 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
89383 index f248db5..3778ad9 100644
89384 --- a/net/netfilter/nfnetlink_log.c
89385 +++ b/net/netfilter/nfnetlink_log.c
89386 @@ -72,7 +72,7 @@ struct nfulnl_instance {
89387 };
89388
89389 static DEFINE_SPINLOCK(instances_lock);
89390 -static atomic_t global_seq;
89391 +static atomic_unchecked_t global_seq;
89392
89393 #define INSTANCE_BUCKETS 16
89394 static struct hlist_head instance_table[INSTANCE_BUCKETS];
89395 @@ -536,7 +536,7 @@ __build_packet_message(struct nfulnl_instance *inst,
89396 /* global sequence number */
89397 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89398 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89399 - htonl(atomic_inc_return(&global_seq))))
89400 + htonl(atomic_inc_return_unchecked(&global_seq))))
89401 goto nla_put_failure;
89402
89403 if (data_len) {
89404 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89405 new file mode 100644
89406 index 0000000..c566332
89407 --- /dev/null
89408 +++ b/net/netfilter/xt_gradm.c
89409 @@ -0,0 +1,51 @@
89410 +/*
89411 + * gradm match for netfilter
89412 + * Copyright © Zbigniew Krzystolik, 2010
89413 + *
89414 + * This program is free software; you can redistribute it and/or modify
89415 + * it under the terms of the GNU General Public License; either version
89416 + * 2 or 3 as published by the Free Software Foundation.
89417 + */
89418 +#include <linux/module.h>
89419 +#include <linux/moduleparam.h>
89420 +#include <linux/skbuff.h>
89421 +#include <linux/netfilter/x_tables.h>
89422 +#include <linux/grsecurity.h>
89423 +#include <linux/netfilter/xt_gradm.h>
89424 +
89425 +static bool
89426 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89427 +{
89428 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89429 + bool retval = false;
89430 + if (gr_acl_is_enabled())
89431 + retval = true;
89432 + return retval ^ info->invflags;
89433 +}
89434 +
89435 +static struct xt_match gradm_mt_reg __read_mostly = {
89436 + .name = "gradm",
89437 + .revision = 0,
89438 + .family = NFPROTO_UNSPEC,
89439 + .match = gradm_mt,
89440 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89441 + .me = THIS_MODULE,
89442 +};
89443 +
89444 +static int __init gradm_mt_init(void)
89445 +{
89446 + return xt_register_match(&gradm_mt_reg);
89447 +}
89448 +
89449 +static void __exit gradm_mt_exit(void)
89450 +{
89451 + xt_unregister_match(&gradm_mt_reg);
89452 +}
89453 +
89454 +module_init(gradm_mt_init);
89455 +module_exit(gradm_mt_exit);
89456 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89457 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89458 +MODULE_LICENSE("GPL");
89459 +MODULE_ALIAS("ipt_gradm");
89460 +MODULE_ALIAS("ip6t_gradm");
89461 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89462 index 4fe4fb4..87a89e5 100644
89463 --- a/net/netfilter/xt_statistic.c
89464 +++ b/net/netfilter/xt_statistic.c
89465 @@ -19,7 +19,7 @@
89466 #include <linux/module.h>
89467
89468 struct xt_statistic_priv {
89469 - atomic_t count;
89470 + atomic_unchecked_t count;
89471 } ____cacheline_aligned_in_smp;
89472
89473 MODULE_LICENSE("GPL");
89474 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89475 break;
89476 case XT_STATISTIC_MODE_NTH:
89477 do {
89478 - oval = atomic_read(&info->master->count);
89479 + oval = atomic_read_unchecked(&info->master->count);
89480 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89481 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89482 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89483 if (nval == 0)
89484 ret = !ret;
89485 break;
89486 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89487 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89488 if (info->master == NULL)
89489 return -ENOMEM;
89490 - atomic_set(&info->master->count, info->u.nth.count);
89491 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89492
89493 return 0;
89494 }
89495 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89496 index 1e3fd5b..ad397ea 100644
89497 --- a/net/netlink/af_netlink.c
89498 +++ b/net/netlink/af_netlink.c
89499 @@ -781,7 +781,7 @@ static void netlink_overrun(struct sock *sk)
89500 sk->sk_error_report(sk);
89501 }
89502 }
89503 - atomic_inc(&sk->sk_drops);
89504 + atomic_inc_unchecked(&sk->sk_drops);
89505 }
89506
89507 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89508 @@ -2063,7 +2063,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89509 sk_wmem_alloc_get(s),
89510 nlk->cb,
89511 atomic_read(&s->sk_refcnt),
89512 - atomic_read(&s->sk_drops),
89513 + atomic_read_unchecked(&s->sk_drops),
89514 sock_i_ino(s)
89515 );
89516
89517 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89518 index 5a55be3..7630745 100644
89519 --- a/net/netlink/genetlink.c
89520 +++ b/net/netlink/genetlink.c
89521 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89522 goto errout;
89523 }
89524
89525 + pax_open_kernel();
89526 if (ops->dumpit)
89527 - ops->flags |= GENL_CMD_CAP_DUMP;
89528 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89529 if (ops->doit)
89530 - ops->flags |= GENL_CMD_CAP_DO;
89531 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89532 if (ops->policy)
89533 - ops->flags |= GENL_CMD_CAP_HASPOL;
89534 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89535 + pax_close_kernel();
89536
89537 genl_lock();
89538 - list_add_tail(&ops->ops_list, &family->ops_list);
89539 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89540 genl_unlock();
89541
89542 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89543 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89544 err = 0;
89545 errout:
89546 return err;
89547 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89548 genl_lock();
89549 list_for_each_entry(rc, &family->ops_list, ops_list) {
89550 if (rc == ops) {
89551 - list_del(&ops->ops_list);
89552 + pax_list_del((struct list_head *)&ops->ops_list);
89553 genl_unlock();
89554 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89555 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89556 return 0;
89557 }
89558 }
89559 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89560 index 103bd70..f21aad3 100644
89561 --- a/net/netrom/af_netrom.c
89562 +++ b/net/netrom/af_netrom.c
89563 @@ -834,6 +834,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89564 struct sock *sk = sock->sk;
89565 struct nr_sock *nr = nr_sk(sk);
89566
89567 + memset(sax, 0, sizeof(*sax));
89568 lock_sock(sk);
89569 if (peer != 0) {
89570 if (sk->sk_state != TCP_ESTABLISHED) {
89571 @@ -848,7 +849,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89572 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89573 } else {
89574 sax->fsa_ax25.sax25_family = AF_NETROM;
89575 - sax->fsa_ax25.sax25_ndigis = 0;
89576 sax->fsa_ax25.sax25_call = nr->source_addr;
89577 *uaddr_len = sizeof(struct sockaddr_ax25);
89578 }
89579 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89580 index e50f72a..f71867d 100644
89581 --- a/net/packet/af_packet.c
89582 +++ b/net/packet/af_packet.c
89583 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89584
89585 spin_lock(&sk->sk_receive_queue.lock);
89586 po->stats.tp_packets++;
89587 - skb->dropcount = atomic_read(&sk->sk_drops);
89588 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89589 __skb_queue_tail(&sk->sk_receive_queue, skb);
89590 spin_unlock(&sk->sk_receive_queue.lock);
89591 sk->sk_data_ready(sk, skb->len);
89592 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89593 drop_n_acct:
89594 spin_lock(&sk->sk_receive_queue.lock);
89595 po->stats.tp_drops++;
89596 - atomic_inc(&sk->sk_drops);
89597 + atomic_inc_unchecked(&sk->sk_drops);
89598 spin_unlock(&sk->sk_receive_queue.lock);
89599
89600 drop_n_restore:
89601 @@ -2579,6 +2579,7 @@ out:
89602
89603 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89604 {
89605 + struct sock_extended_err ee;
89606 struct sock_exterr_skb *serr;
89607 struct sk_buff *skb, *skb2;
89608 int copied, err;
89609 @@ -2600,8 +2601,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89610 sock_recv_timestamp(msg, sk, skb);
89611
89612 serr = SKB_EXT_ERR(skb);
89613 + ee = serr->ee;
89614 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89615 - sizeof(serr->ee), &serr->ee);
89616 + sizeof ee, &ee);
89617
89618 msg->msg_flags |= MSG_ERRQUEUE;
89619 err = copied;
89620 @@ -3225,7 +3227,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89621 case PACKET_HDRLEN:
89622 if (len > sizeof(int))
89623 len = sizeof(int);
89624 - if (copy_from_user(&val, optval, len))
89625 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89626 return -EFAULT;
89627 switch (val) {
89628 case TPACKET_V1:
89629 @@ -3267,7 +3269,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89630 len = lv;
89631 if (put_user(len, optlen))
89632 return -EFAULT;
89633 - if (copy_to_user(optval, data, len))
89634 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89635 return -EFAULT;
89636 return 0;
89637 }
89638 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89639 index 5a940db..d6a502d 100644
89640 --- a/net/phonet/af_phonet.c
89641 +++ b/net/phonet/af_phonet.c
89642 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89643 {
89644 int err = 0;
89645
89646 - if (protocol >= PHONET_NPROTO)
89647 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89648 return -EINVAL;
89649
89650 err = proto_register(pp->prot, 1);
89651 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89652 index e774117..900b8b7 100644
89653 --- a/net/phonet/pep.c
89654 +++ b/net/phonet/pep.c
89655 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89656
89657 case PNS_PEP_CTRL_REQ:
89658 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89659 - atomic_inc(&sk->sk_drops);
89660 + atomic_inc_unchecked(&sk->sk_drops);
89661 break;
89662 }
89663 __skb_pull(skb, 4);
89664 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89665 }
89666
89667 if (pn->rx_credits == 0) {
89668 - atomic_inc(&sk->sk_drops);
89669 + atomic_inc_unchecked(&sk->sk_drops);
89670 err = -ENOBUFS;
89671 break;
89672 }
89673 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89674 }
89675
89676 if (pn->rx_credits == 0) {
89677 - atomic_inc(&sk->sk_drops);
89678 + atomic_inc_unchecked(&sk->sk_drops);
89679 err = NET_RX_DROP;
89680 break;
89681 }
89682 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89683 index 1afd138..0b42453 100644
89684 --- a/net/phonet/socket.c
89685 +++ b/net/phonet/socket.c
89686 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89687 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89688 sock_i_ino(sk),
89689 atomic_read(&sk->sk_refcnt), sk,
89690 - atomic_read(&sk->sk_drops), &len);
89691 + atomic_read_unchecked(&sk->sk_drops), &len);
89692 }
89693 seq_printf(seq, "%*s\n", 127 - len, "");
89694 return 0;
89695 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89696 index d6bbbbd..61561e4 100644
89697 --- a/net/phonet/sysctl.c
89698 +++ b/net/phonet/sysctl.c
89699 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89700 {
89701 int ret;
89702 int range[2] = {local_port_range[0], local_port_range[1]};
89703 - ctl_table tmp = {
89704 + ctl_table_no_const tmp = {
89705 .data = &range,
89706 .maxlen = sizeof(range),
89707 .mode = table->mode,
89708 diff --git a/net/rds/cong.c b/net/rds/cong.c
89709 index e5b65ac..f3b6fb7 100644
89710 --- a/net/rds/cong.c
89711 +++ b/net/rds/cong.c
89712 @@ -78,7 +78,7 @@
89713 * finds that the saved generation number is smaller than the global generation
89714 * number, it wakes up the process.
89715 */
89716 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89717 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89718
89719 /*
89720 * Congestion monitoring
89721 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89722 rdsdebug("waking map %p for %pI4\n",
89723 map, &map->m_addr);
89724 rds_stats_inc(s_cong_update_received);
89725 - atomic_inc(&rds_cong_generation);
89726 + atomic_inc_unchecked(&rds_cong_generation);
89727 if (waitqueue_active(&map->m_waitq))
89728 wake_up(&map->m_waitq);
89729 if (waitqueue_active(&rds_poll_waitq))
89730 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89731
89732 int rds_cong_updated_since(unsigned long *recent)
89733 {
89734 - unsigned long gen = atomic_read(&rds_cong_generation);
89735 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89736
89737 if (likely(*recent == gen))
89738 return 0;
89739 diff --git a/net/rds/ib.h b/net/rds/ib.h
89740 index 7280ab8..e04f4ea 100644
89741 --- a/net/rds/ib.h
89742 +++ b/net/rds/ib.h
89743 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89744 /* sending acks */
89745 unsigned long i_ack_flags;
89746 #ifdef KERNEL_HAS_ATOMIC64
89747 - atomic64_t i_ack_next; /* next ACK to send */
89748 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89749 #else
89750 spinlock_t i_ack_lock; /* protect i_ack_next */
89751 u64 i_ack_next; /* next ACK to send */
89752 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89753 index 31b74f5..dc1fbfa 100644
89754 --- a/net/rds/ib_cm.c
89755 +++ b/net/rds/ib_cm.c
89756 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89757 /* Clear the ACK state */
89758 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89759 #ifdef KERNEL_HAS_ATOMIC64
89760 - atomic64_set(&ic->i_ack_next, 0);
89761 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89762 #else
89763 ic->i_ack_next = 0;
89764 #endif
89765 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89766 index 8eb9501..0c386ff 100644
89767 --- a/net/rds/ib_recv.c
89768 +++ b/net/rds/ib_recv.c
89769 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89770 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89771 int ack_required)
89772 {
89773 - atomic64_set(&ic->i_ack_next, seq);
89774 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89775 if (ack_required) {
89776 smp_mb__before_clear_bit();
89777 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89778 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89779 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89780 smp_mb__after_clear_bit();
89781
89782 - return atomic64_read(&ic->i_ack_next);
89783 + return atomic64_read_unchecked(&ic->i_ack_next);
89784 }
89785 #endif
89786
89787 diff --git a/net/rds/iw.h b/net/rds/iw.h
89788 index 04ce3b1..48119a6 100644
89789 --- a/net/rds/iw.h
89790 +++ b/net/rds/iw.h
89791 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89792 /* sending acks */
89793 unsigned long i_ack_flags;
89794 #ifdef KERNEL_HAS_ATOMIC64
89795 - atomic64_t i_ack_next; /* next ACK to send */
89796 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89797 #else
89798 spinlock_t i_ack_lock; /* protect i_ack_next */
89799 u64 i_ack_next; /* next ACK to send */
89800 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89801 index a91e1db..cf3053f 100644
89802 --- a/net/rds/iw_cm.c
89803 +++ b/net/rds/iw_cm.c
89804 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89805 /* Clear the ACK state */
89806 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89807 #ifdef KERNEL_HAS_ATOMIC64
89808 - atomic64_set(&ic->i_ack_next, 0);
89809 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89810 #else
89811 ic->i_ack_next = 0;
89812 #endif
89813 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89814 index 4503335..db566b4 100644
89815 --- a/net/rds/iw_recv.c
89816 +++ b/net/rds/iw_recv.c
89817 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89818 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89819 int ack_required)
89820 {
89821 - atomic64_set(&ic->i_ack_next, seq);
89822 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89823 if (ack_required) {
89824 smp_mb__before_clear_bit();
89825 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89826 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89827 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89828 smp_mb__after_clear_bit();
89829
89830 - return atomic64_read(&ic->i_ack_next);
89831 + return atomic64_read_unchecked(&ic->i_ack_next);
89832 }
89833 #endif
89834
89835 diff --git a/net/rds/rds.h b/net/rds/rds.h
89836 index ec1d731..90a3a8d 100644
89837 --- a/net/rds/rds.h
89838 +++ b/net/rds/rds.h
89839 @@ -449,7 +449,7 @@ struct rds_transport {
89840 void (*sync_mr)(void *trans_private, int direction);
89841 void (*free_mr)(void *trans_private, int invalidate);
89842 void (*flush_mrs)(void);
89843 -};
89844 +} __do_const;
89845
89846 struct rds_sock {
89847 struct sock rs_sk;
89848 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89849 index edac9ef..16bcb98 100644
89850 --- a/net/rds/tcp.c
89851 +++ b/net/rds/tcp.c
89852 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89853 int val = 1;
89854
89855 set_fs(KERNEL_DS);
89856 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89857 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89858 sizeof(val));
89859 set_fs(oldfs);
89860 }
89861 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89862 index 81cf5a4..b5826ff 100644
89863 --- a/net/rds/tcp_send.c
89864 +++ b/net/rds/tcp_send.c
89865 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89866
89867 oldfs = get_fs();
89868 set_fs(KERNEL_DS);
89869 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89870 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89871 sizeof(val));
89872 set_fs(oldfs);
89873 }
89874 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89875 index e61aa60..f07cc89 100644
89876 --- a/net/rxrpc/af_rxrpc.c
89877 +++ b/net/rxrpc/af_rxrpc.c
89878 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89879 __be32 rxrpc_epoch;
89880
89881 /* current debugging ID */
89882 -atomic_t rxrpc_debug_id;
89883 +atomic_unchecked_t rxrpc_debug_id;
89884
89885 /* count of skbs currently in use */
89886 atomic_t rxrpc_n_skbs;
89887 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89888 index e4d9cbc..b229649 100644
89889 --- a/net/rxrpc/ar-ack.c
89890 +++ b/net/rxrpc/ar-ack.c
89891 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89892
89893 _enter("{%d,%d,%d,%d},",
89894 call->acks_hard, call->acks_unacked,
89895 - atomic_read(&call->sequence),
89896 + atomic_read_unchecked(&call->sequence),
89897 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89898
89899 stop = 0;
89900 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89901
89902 /* each Tx packet has a new serial number */
89903 sp->hdr.serial =
89904 - htonl(atomic_inc_return(&call->conn->serial));
89905 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89906
89907 hdr = (struct rxrpc_header *) txb->head;
89908 hdr->serial = sp->hdr.serial;
89909 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89910 */
89911 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89912 {
89913 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89914 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89915 }
89916
89917 /*
89918 @@ -629,7 +629,7 @@ process_further:
89919
89920 latest = ntohl(sp->hdr.serial);
89921 hard = ntohl(ack.firstPacket);
89922 - tx = atomic_read(&call->sequence);
89923 + tx = atomic_read_unchecked(&call->sequence);
89924
89925 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89926 latest,
89927 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89928 goto maybe_reschedule;
89929
89930 send_ACK_with_skew:
89931 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89932 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89933 ntohl(ack.serial));
89934 send_ACK:
89935 mtu = call->conn->trans->peer->if_mtu;
89936 @@ -1173,7 +1173,7 @@ send_ACK:
89937 ackinfo.rxMTU = htonl(5692);
89938 ackinfo.jumbo_max = htonl(4);
89939
89940 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89941 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89942 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89943 ntohl(hdr.serial),
89944 ntohs(ack.maxSkew),
89945 @@ -1191,7 +1191,7 @@ send_ACK:
89946 send_message:
89947 _debug("send message");
89948
89949 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89950 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89951 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89952 send_message_2:
89953
89954 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89955 index a3bbb36..3341fb9 100644
89956 --- a/net/rxrpc/ar-call.c
89957 +++ b/net/rxrpc/ar-call.c
89958 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89959 spin_lock_init(&call->lock);
89960 rwlock_init(&call->state_lock);
89961 atomic_set(&call->usage, 1);
89962 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89963 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89964 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89965
89966 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89967 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89968 index 4106ca9..a338d7a 100644
89969 --- a/net/rxrpc/ar-connection.c
89970 +++ b/net/rxrpc/ar-connection.c
89971 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89972 rwlock_init(&conn->lock);
89973 spin_lock_init(&conn->state_lock);
89974 atomic_set(&conn->usage, 1);
89975 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89976 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89977 conn->avail_calls = RXRPC_MAXCALLS;
89978 conn->size_align = 4;
89979 conn->header_size = sizeof(struct rxrpc_header);
89980 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89981 index e7ed43a..6afa140 100644
89982 --- a/net/rxrpc/ar-connevent.c
89983 +++ b/net/rxrpc/ar-connevent.c
89984 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89985
89986 len = iov[0].iov_len + iov[1].iov_len;
89987
89988 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89989 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89990 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89991
89992 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89993 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89994 index 529572f..c758ca7 100644
89995 --- a/net/rxrpc/ar-input.c
89996 +++ b/net/rxrpc/ar-input.c
89997 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89998 /* track the latest serial number on this connection for ACK packet
89999 * information */
90000 serial = ntohl(sp->hdr.serial);
90001 - hi_serial = atomic_read(&call->conn->hi_serial);
90002 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
90003 while (serial > hi_serial)
90004 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
90005 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
90006 serial);
90007
90008 /* request ACK generation for any ACK or DATA packet that requests
90009 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
90010 index a693aca..81e7293 100644
90011 --- a/net/rxrpc/ar-internal.h
90012 +++ b/net/rxrpc/ar-internal.h
90013 @@ -272,8 +272,8 @@ struct rxrpc_connection {
90014 int error; /* error code for local abort */
90015 int debug_id; /* debug ID for printks */
90016 unsigned int call_counter; /* call ID counter */
90017 - atomic_t serial; /* packet serial number counter */
90018 - atomic_t hi_serial; /* highest serial number received */
90019 + atomic_unchecked_t serial; /* packet serial number counter */
90020 + atomic_unchecked_t hi_serial; /* highest serial number received */
90021 u8 avail_calls; /* number of calls available */
90022 u8 size_align; /* data size alignment (for security) */
90023 u8 header_size; /* rxrpc + security header size */
90024 @@ -346,7 +346,7 @@ struct rxrpc_call {
90025 spinlock_t lock;
90026 rwlock_t state_lock; /* lock for state transition */
90027 atomic_t usage;
90028 - atomic_t sequence; /* Tx data packet sequence counter */
90029 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
90030 u32 abort_code; /* local/remote abort code */
90031 enum { /* current state of call */
90032 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
90033 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
90034 */
90035 extern atomic_t rxrpc_n_skbs;
90036 extern __be32 rxrpc_epoch;
90037 -extern atomic_t rxrpc_debug_id;
90038 +extern atomic_unchecked_t rxrpc_debug_id;
90039 extern struct workqueue_struct *rxrpc_workqueue;
90040
90041 /*
90042 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
90043 index 87f7135..74d3703 100644
90044 --- a/net/rxrpc/ar-local.c
90045 +++ b/net/rxrpc/ar-local.c
90046 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
90047 spin_lock_init(&local->lock);
90048 rwlock_init(&local->services_lock);
90049 atomic_set(&local->usage, 1);
90050 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
90051 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90052 memcpy(&local->srx, srx, sizeof(*srx));
90053 }
90054
90055 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
90056 index e1ac183..b43e10e 100644
90057 --- a/net/rxrpc/ar-output.c
90058 +++ b/net/rxrpc/ar-output.c
90059 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
90060 sp->hdr.cid = call->cid;
90061 sp->hdr.callNumber = call->call_id;
90062 sp->hdr.seq =
90063 - htonl(atomic_inc_return(&call->sequence));
90064 + htonl(atomic_inc_return_unchecked(&call->sequence));
90065 sp->hdr.serial =
90066 - htonl(atomic_inc_return(&conn->serial));
90067 + htonl(atomic_inc_return_unchecked(&conn->serial));
90068 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
90069 sp->hdr.userStatus = 0;
90070 sp->hdr.securityIndex = conn->security_ix;
90071 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
90072 index bebaa43..2644591 100644
90073 --- a/net/rxrpc/ar-peer.c
90074 +++ b/net/rxrpc/ar-peer.c
90075 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
90076 INIT_LIST_HEAD(&peer->error_targets);
90077 spin_lock_init(&peer->lock);
90078 atomic_set(&peer->usage, 1);
90079 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
90080 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90081 memcpy(&peer->srx, srx, sizeof(*srx));
90082
90083 rxrpc_assess_MTU_size(peer);
90084 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
90085 index 38047f7..9f48511 100644
90086 --- a/net/rxrpc/ar-proc.c
90087 +++ b/net/rxrpc/ar-proc.c
90088 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
90089 atomic_read(&conn->usage),
90090 rxrpc_conn_states[conn->state],
90091 key_serial(conn->key),
90092 - atomic_read(&conn->serial),
90093 - atomic_read(&conn->hi_serial));
90094 + atomic_read_unchecked(&conn->serial),
90095 + atomic_read_unchecked(&conn->hi_serial));
90096
90097 return 0;
90098 }
90099 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
90100 index 92df566..87ec1bf 100644
90101 --- a/net/rxrpc/ar-transport.c
90102 +++ b/net/rxrpc/ar-transport.c
90103 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
90104 spin_lock_init(&trans->client_lock);
90105 rwlock_init(&trans->conn_lock);
90106 atomic_set(&trans->usage, 1);
90107 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
90108 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90109
90110 if (peer->srx.transport.family == AF_INET) {
90111 switch (peer->srx.transport_type) {
90112 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
90113 index f226709..0e735a8 100644
90114 --- a/net/rxrpc/rxkad.c
90115 +++ b/net/rxrpc/rxkad.c
90116 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
90117
90118 len = iov[0].iov_len + iov[1].iov_len;
90119
90120 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90121 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90122 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
90123
90124 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90125 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
90126
90127 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
90128
90129 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
90130 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90131 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
90132
90133 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
90134 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
90135 index 391a245..296b3d7 100644
90136 --- a/net/sctp/ipv6.c
90137 +++ b/net/sctp/ipv6.c
90138 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
90139 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
90140 };
90141
90142 -static struct sctp_af sctp_af_inet6 = {
90143 +static struct sctp_af sctp_af_inet6 __read_only = {
90144 .sa_family = AF_INET6,
90145 .sctp_xmit = sctp_v6_xmit,
90146 .setsockopt = ipv6_setsockopt,
90147 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
90148 #endif
90149 };
90150
90151 -static struct sctp_pf sctp_pf_inet6 = {
90152 +static struct sctp_pf sctp_pf_inet6 __read_only = {
90153 .event_msgname = sctp_inet6_event_msgname,
90154 .skb_msgname = sctp_inet6_skb_msgname,
90155 .af_supported = sctp_inet6_af_supported,
90156 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
90157
90158 void sctp_v6_pf_exit(void)
90159 {
90160 - list_del(&sctp_af_inet6.list);
90161 + pax_list_del(&sctp_af_inet6.list);
90162 }
90163
90164 /* Initialize IPv6 support and register with socket layer. */
90165 diff --git a/net/sctp/probe.c b/net/sctp/probe.c
90166 index ad0dba8..e62c225 100644
90167 --- a/net/sctp/probe.c
90168 +++ b/net/sctp/probe.c
90169 @@ -63,7 +63,7 @@ static struct {
90170 struct timespec tstart;
90171 } sctpw;
90172
90173 -static void printl(const char *fmt, ...)
90174 +static __printf(1, 2) void printl(const char *fmt, ...)
90175 {
90176 va_list args;
90177 int len;
90178 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
90179 index ab3bba8..2fbab4e 100644
90180 --- a/net/sctp/proc.c
90181 +++ b/net/sctp/proc.c
90182 @@ -336,7 +336,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
90183 seq_printf(seq,
90184 "%8pK %8pK %-3d %-3d %-2d %-4d "
90185 "%4d %8d %8d %7d %5lu %-5d %5d ",
90186 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
90187 + assoc, sk,
90188 + sctp_sk(sk)->type, sk->sk_state,
90189 assoc->state, hash,
90190 assoc->assoc_id,
90191 assoc->sndbuf_used,
90192 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
90193 index 1c2e46c..f91cf5e 100644
90194 --- a/net/sctp/protocol.c
90195 +++ b/net/sctp/protocol.c
90196 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
90197 return 0;
90198 }
90199
90200 + pax_open_kernel();
90201 INIT_LIST_HEAD(&af->list);
90202 - list_add_tail(&af->list, &sctp_address_families);
90203 + pax_close_kernel();
90204 + pax_list_add_tail(&af->list, &sctp_address_families);
90205 return 1;
90206 }
90207
90208 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
90209
90210 static struct sctp_af sctp_af_inet;
90211
90212 -static struct sctp_pf sctp_pf_inet = {
90213 +static struct sctp_pf sctp_pf_inet __read_only = {
90214 .event_msgname = sctp_inet_event_msgname,
90215 .skb_msgname = sctp_inet_skb_msgname,
90216 .af_supported = sctp_inet_af_supported,
90217 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
90218 };
90219
90220 /* IPv4 address related functions. */
90221 -static struct sctp_af sctp_af_inet = {
90222 +static struct sctp_af sctp_af_inet __read_only = {
90223 .sa_family = AF_INET,
90224 .sctp_xmit = sctp_v4_xmit,
90225 .setsockopt = ip_setsockopt,
90226 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
90227
90228 static void sctp_v4_pf_exit(void)
90229 {
90230 - list_del(&sctp_af_inet.list);
90231 + pax_list_del(&sctp_af_inet.list);
90232 }
90233
90234 static int sctp_v4_protosw_init(void)
90235 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
90236 index 8aab894..f6b7e7d 100644
90237 --- a/net/sctp/sm_sideeffect.c
90238 +++ b/net/sctp/sm_sideeffect.c
90239 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
90240 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
90241 }
90242
90243 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90244 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90245 NULL,
90246 sctp_generate_t1_cookie_event,
90247 sctp_generate_t1_init_event,
90248 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
90249 index 02c43e4..7bea2ca 100644
90250 --- a/net/sctp/socket.c
90251 +++ b/net/sctp/socket.c
90252 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
90253 {
90254 struct sctp_association *asoc;
90255 struct sctp_ulpevent *event;
90256 + struct sctp_event_subscribe subscribe;
90257
90258 if (optlen > sizeof(struct sctp_event_subscribe))
90259 return -EINVAL;
90260 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
90261 + if (copy_from_user(&subscribe, optval, optlen))
90262 return -EFAULT;
90263 + sctp_sk(sk)->subscribe = subscribe;
90264
90265 /*
90266 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
90267 @@ -4221,13 +4223,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
90268 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90269 int __user *optlen)
90270 {
90271 + struct sctp_event_subscribe subscribe;
90272 +
90273 if (len <= 0)
90274 return -EINVAL;
90275 if (len > sizeof(struct sctp_event_subscribe))
90276 len = sizeof(struct sctp_event_subscribe);
90277 if (put_user(len, optlen))
90278 return -EFAULT;
90279 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
90280 + subscribe = sctp_sk(sk)->subscribe;
90281 + if (copy_to_user(optval, &subscribe, len))
90282 return -EFAULT;
90283 return 0;
90284 }
90285 @@ -4245,6 +4250,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90286 */
90287 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
90288 {
90289 + __u32 autoclose;
90290 +
90291 /* Applicable to UDP-style socket only */
90292 if (sctp_style(sk, TCP))
90293 return -EOPNOTSUPP;
90294 @@ -4253,7 +4260,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
90295 len = sizeof(int);
90296 if (put_user(len, optlen))
90297 return -EFAULT;
90298 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
90299 + autoclose = sctp_sk(sk)->autoclose;
90300 + if (copy_to_user(optval, &autoclose, sizeof(int)))
90301 return -EFAULT;
90302 return 0;
90303 }
90304 @@ -4625,12 +4633,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
90305 */
90306 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
90307 {
90308 + struct sctp_initmsg initmsg;
90309 +
90310 if (len < sizeof(struct sctp_initmsg))
90311 return -EINVAL;
90312 len = sizeof(struct sctp_initmsg);
90313 if (put_user(len, optlen))
90314 return -EFAULT;
90315 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
90316 + initmsg = sctp_sk(sk)->initmsg;
90317 + if (copy_to_user(optval, &initmsg, len))
90318 return -EFAULT;
90319 return 0;
90320 }
90321 @@ -4671,6 +4682,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
90322 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
90323 if (space_left < addrlen)
90324 return -ENOMEM;
90325 + if (addrlen > sizeof(temp) || addrlen < 0)
90326 + return -EFAULT;
90327 if (copy_to_user(to, &temp, addrlen))
90328 return -EFAULT;
90329 to += addrlen;
90330 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
90331 index bf3c6e8..376d8d0 100644
90332 --- a/net/sctp/sysctl.c
90333 +++ b/net/sctp/sysctl.c
90334 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90335 {
90336 struct net *net = current->nsproxy->net_ns;
90337 char tmp[8];
90338 - ctl_table tbl;
90339 + ctl_table_no_const tbl;
90340 int ret;
90341 int changed = 0;
90342 char *none = "none";
90343 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90344
90345 int sctp_sysctl_net_register(struct net *net)
90346 {
90347 - struct ctl_table *table;
90348 + ctl_table_no_const *table;
90349 int i;
90350
90351 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90352 diff --git a/net/socket.c b/net/socket.c
90353 index e216502..74be616 100644
90354 --- a/net/socket.c
90355 +++ b/net/socket.c
90356 @@ -88,6 +88,7 @@
90357 #include <linux/magic.h>
90358 #include <linux/slab.h>
90359 #include <linux/xattr.h>
90360 +#include <linux/in.h>
90361
90362 #include <asm/uaccess.h>
90363 #include <asm/unistd.h>
90364 @@ -105,6 +106,8 @@
90365 #include <linux/sockios.h>
90366 #include <linux/atalk.h>
90367
90368 +#include <linux/grsock.h>
90369 +
90370 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90371 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90372 unsigned long nr_segs, loff_t pos);
90373 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90374 &sockfs_dentry_operations, SOCKFS_MAGIC);
90375 }
90376
90377 -static struct vfsmount *sock_mnt __read_mostly;
90378 +struct vfsmount *sock_mnt __read_mostly;
90379
90380 static struct file_system_type sock_fs_type = {
90381 .name = "sockfs",
90382 @@ -1268,6 +1271,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90383 return -EAFNOSUPPORT;
90384 if (type < 0 || type >= SOCK_MAX)
90385 return -EINVAL;
90386 + if (protocol < 0)
90387 + return -EINVAL;
90388
90389 /* Compatibility.
90390
90391 @@ -1399,6 +1404,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90392 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90393 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90394
90395 + if(!gr_search_socket(family, type, protocol)) {
90396 + retval = -EACCES;
90397 + goto out;
90398 + }
90399 +
90400 + if (gr_handle_sock_all(family, type, protocol)) {
90401 + retval = -EACCES;
90402 + goto out;
90403 + }
90404 +
90405 retval = sock_create(family, type, protocol, &sock);
90406 if (retval < 0)
90407 goto out;
90408 @@ -1526,6 +1541,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90409 if (sock) {
90410 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90411 if (err >= 0) {
90412 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90413 + err = -EACCES;
90414 + goto error;
90415 + }
90416 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90417 + if (err)
90418 + goto error;
90419 +
90420 err = security_socket_bind(sock,
90421 (struct sockaddr *)&address,
90422 addrlen);
90423 @@ -1534,6 +1557,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90424 (struct sockaddr *)
90425 &address, addrlen);
90426 }
90427 +error:
90428 fput_light(sock->file, fput_needed);
90429 }
90430 return err;
90431 @@ -1557,10 +1581,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90432 if ((unsigned int)backlog > somaxconn)
90433 backlog = somaxconn;
90434
90435 + if (gr_handle_sock_server_other(sock->sk)) {
90436 + err = -EPERM;
90437 + goto error;
90438 + }
90439 +
90440 + err = gr_search_listen(sock);
90441 + if (err)
90442 + goto error;
90443 +
90444 err = security_socket_listen(sock, backlog);
90445 if (!err)
90446 err = sock->ops->listen(sock, backlog);
90447
90448 +error:
90449 fput_light(sock->file, fput_needed);
90450 }
90451 return err;
90452 @@ -1604,6 +1638,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90453 newsock->type = sock->type;
90454 newsock->ops = sock->ops;
90455
90456 + if (gr_handle_sock_server_other(sock->sk)) {
90457 + err = -EPERM;
90458 + sock_release(newsock);
90459 + goto out_put;
90460 + }
90461 +
90462 + err = gr_search_accept(sock);
90463 + if (err) {
90464 + sock_release(newsock);
90465 + goto out_put;
90466 + }
90467 +
90468 /*
90469 * We don't need try_module_get here, as the listening socket (sock)
90470 * has the protocol module (sock->ops->owner) held.
90471 @@ -1649,6 +1695,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90472 fd_install(newfd, newfile);
90473 err = newfd;
90474
90475 + gr_attach_curr_ip(newsock->sk);
90476 +
90477 out_put:
90478 fput_light(sock->file, fput_needed);
90479 out:
90480 @@ -1681,6 +1729,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90481 int, addrlen)
90482 {
90483 struct socket *sock;
90484 + struct sockaddr *sck;
90485 struct sockaddr_storage address;
90486 int err, fput_needed;
90487
90488 @@ -1691,6 +1740,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90489 if (err < 0)
90490 goto out_put;
90491
90492 + sck = (struct sockaddr *)&address;
90493 +
90494 + if (gr_handle_sock_client(sck)) {
90495 + err = -EACCES;
90496 + goto out_put;
90497 + }
90498 +
90499 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90500 + if (err)
90501 + goto out_put;
90502 +
90503 err =
90504 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90505 if (err)
90506 @@ -1772,6 +1832,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90507 * the protocol.
90508 */
90509
90510 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90511 +
90512 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90513 unsigned int, flags, struct sockaddr __user *, addr,
90514 int, addr_len)
90515 @@ -1838,7 +1900,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90516 struct socket *sock;
90517 struct iovec iov;
90518 struct msghdr msg;
90519 - struct sockaddr_storage address;
90520 + struct sockaddr_storage address = { };
90521 int err, err2;
90522 int fput_needed;
90523
90524 @@ -2045,7 +2107,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90525 * checking falls down on this.
90526 */
90527 if (copy_from_user(ctl_buf,
90528 - (void __user __force *)msg_sys->msg_control,
90529 + (void __force_user *)msg_sys->msg_control,
90530 ctl_len))
90531 goto out_freectl;
90532 msg_sys->msg_control = ctl_buf;
90533 @@ -2196,7 +2258,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90534 int err, total_len, len;
90535
90536 /* kernel mode address */
90537 - struct sockaddr_storage addr;
90538 + struct sockaddr_storage addr = { };
90539
90540 /* user mode address pointers */
90541 struct sockaddr __user *uaddr;
90542 @@ -2224,7 +2286,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90543 * kernel msghdr to use the kernel address space)
90544 */
90545
90546 - uaddr = (__force void __user *)msg_sys->msg_name;
90547 + uaddr = (void __force_user *)msg_sys->msg_name;
90548 uaddr_len = COMPAT_NAMELEN(msg);
90549 if (MSG_CMSG_COMPAT & flags) {
90550 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90551 @@ -2975,7 +3037,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90552 old_fs = get_fs();
90553 set_fs(KERNEL_DS);
90554 err = dev_ioctl(net, cmd,
90555 - (struct ifreq __user __force *) &kifr);
90556 + (struct ifreq __force_user *) &kifr);
90557 set_fs(old_fs);
90558
90559 return err;
90560 @@ -3084,7 +3146,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90561
90562 old_fs = get_fs();
90563 set_fs(KERNEL_DS);
90564 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90565 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90566 set_fs(old_fs);
90567
90568 if (cmd == SIOCGIFMAP && !err) {
90569 @@ -3189,7 +3251,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90570 ret |= __get_user(rtdev, &(ur4->rt_dev));
90571 if (rtdev) {
90572 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90573 - r4.rt_dev = (char __user __force *)devname;
90574 + r4.rt_dev = (char __force_user *)devname;
90575 devname[15] = 0;
90576 } else
90577 r4.rt_dev = NULL;
90578 @@ -3415,8 +3477,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90579 int __user *uoptlen;
90580 int err;
90581
90582 - uoptval = (char __user __force *) optval;
90583 - uoptlen = (int __user __force *) optlen;
90584 + uoptval = (char __force_user *) optval;
90585 + uoptlen = (int __force_user *) optlen;
90586
90587 set_fs(KERNEL_DS);
90588 if (level == SOL_SOCKET)
90589 @@ -3436,7 +3498,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90590 char __user *uoptval;
90591 int err;
90592
90593 - uoptval = (char __user __force *) optval;
90594 + uoptval = (char __force_user *) optval;
90595
90596 set_fs(KERNEL_DS);
90597 if (level == SOL_SOCKET)
90598 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90599 index d5f35f1..da2680b5 100644
90600 --- a/net/sunrpc/clnt.c
90601 +++ b/net/sunrpc/clnt.c
90602 @@ -1283,7 +1283,9 @@ call_start(struct rpc_task *task)
90603 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90604
90605 /* Increment call count */
90606 - task->tk_msg.rpc_proc->p_count++;
90607 + pax_open_kernel();
90608 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90609 + pax_close_kernel();
90610 clnt->cl_stats->rpccnt++;
90611 task->tk_action = call_reserve;
90612 }
90613 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90614 index 5356b12..c0f4c29 100644
90615 --- a/net/sunrpc/sched.c
90616 +++ b/net/sunrpc/sched.c
90617 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90618 #ifdef RPC_DEBUG
90619 static void rpc_task_set_debuginfo(struct rpc_task *task)
90620 {
90621 - static atomic_t rpc_pid;
90622 + static atomic_unchecked_t rpc_pid;
90623
90624 - task->tk_pid = atomic_inc_return(&rpc_pid);
90625 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90626 }
90627 #else
90628 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90629 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90630 index 89a588b..678ed90 100644
90631 --- a/net/sunrpc/svc.c
90632 +++ b/net/sunrpc/svc.c
90633 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
90634
90635 __module_get(serv->sv_module);
90636 task = kthread_create_on_node(serv->sv_function, rqstp,
90637 - node, serv->sv_name);
90638 + node, "%s", serv->sv_name);
90639 if (IS_ERR(task)) {
90640 error = PTR_ERR(task);
90641 module_put(serv->sv_module);
90642 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90643 svc_putnl(resv, RPC_SUCCESS);
90644
90645 /* Bump per-procedure stats counter */
90646 - procp->pc_count++;
90647 + pax_open_kernel();
90648 + (*(unsigned int *)&procp->pc_count)++;
90649 + pax_close_kernel();
90650
90651 /* Initialize storage for argp and resp */
90652 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90653 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90654 index 8343737..677025e 100644
90655 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90656 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90657 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90658 static unsigned int min_max_inline = 4096;
90659 static unsigned int max_max_inline = 65536;
90660
90661 -atomic_t rdma_stat_recv;
90662 -atomic_t rdma_stat_read;
90663 -atomic_t rdma_stat_write;
90664 -atomic_t rdma_stat_sq_starve;
90665 -atomic_t rdma_stat_rq_starve;
90666 -atomic_t rdma_stat_rq_poll;
90667 -atomic_t rdma_stat_rq_prod;
90668 -atomic_t rdma_stat_sq_poll;
90669 -atomic_t rdma_stat_sq_prod;
90670 +atomic_unchecked_t rdma_stat_recv;
90671 +atomic_unchecked_t rdma_stat_read;
90672 +atomic_unchecked_t rdma_stat_write;
90673 +atomic_unchecked_t rdma_stat_sq_starve;
90674 +atomic_unchecked_t rdma_stat_rq_starve;
90675 +atomic_unchecked_t rdma_stat_rq_poll;
90676 +atomic_unchecked_t rdma_stat_rq_prod;
90677 +atomic_unchecked_t rdma_stat_sq_poll;
90678 +atomic_unchecked_t rdma_stat_sq_prod;
90679
90680 /* Temporary NFS request map and context caches */
90681 struct kmem_cache *svc_rdma_map_cachep;
90682 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90683 len -= *ppos;
90684 if (len > *lenp)
90685 len = *lenp;
90686 - if (len && copy_to_user(buffer, str_buf, len))
90687 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90688 return -EFAULT;
90689 *lenp = len;
90690 *ppos += len;
90691 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90692 {
90693 .procname = "rdma_stat_read",
90694 .data = &rdma_stat_read,
90695 - .maxlen = sizeof(atomic_t),
90696 + .maxlen = sizeof(atomic_unchecked_t),
90697 .mode = 0644,
90698 .proc_handler = read_reset_stat,
90699 },
90700 {
90701 .procname = "rdma_stat_recv",
90702 .data = &rdma_stat_recv,
90703 - .maxlen = sizeof(atomic_t),
90704 + .maxlen = sizeof(atomic_unchecked_t),
90705 .mode = 0644,
90706 .proc_handler = read_reset_stat,
90707 },
90708 {
90709 .procname = "rdma_stat_write",
90710 .data = &rdma_stat_write,
90711 - .maxlen = sizeof(atomic_t),
90712 + .maxlen = sizeof(atomic_unchecked_t),
90713 .mode = 0644,
90714 .proc_handler = read_reset_stat,
90715 },
90716 {
90717 .procname = "rdma_stat_sq_starve",
90718 .data = &rdma_stat_sq_starve,
90719 - .maxlen = sizeof(atomic_t),
90720 + .maxlen = sizeof(atomic_unchecked_t),
90721 .mode = 0644,
90722 .proc_handler = read_reset_stat,
90723 },
90724 {
90725 .procname = "rdma_stat_rq_starve",
90726 .data = &rdma_stat_rq_starve,
90727 - .maxlen = sizeof(atomic_t),
90728 + .maxlen = sizeof(atomic_unchecked_t),
90729 .mode = 0644,
90730 .proc_handler = read_reset_stat,
90731 },
90732 {
90733 .procname = "rdma_stat_rq_poll",
90734 .data = &rdma_stat_rq_poll,
90735 - .maxlen = sizeof(atomic_t),
90736 + .maxlen = sizeof(atomic_unchecked_t),
90737 .mode = 0644,
90738 .proc_handler = read_reset_stat,
90739 },
90740 {
90741 .procname = "rdma_stat_rq_prod",
90742 .data = &rdma_stat_rq_prod,
90743 - .maxlen = sizeof(atomic_t),
90744 + .maxlen = sizeof(atomic_unchecked_t),
90745 .mode = 0644,
90746 .proc_handler = read_reset_stat,
90747 },
90748 {
90749 .procname = "rdma_stat_sq_poll",
90750 .data = &rdma_stat_sq_poll,
90751 - .maxlen = sizeof(atomic_t),
90752 + .maxlen = sizeof(atomic_unchecked_t),
90753 .mode = 0644,
90754 .proc_handler = read_reset_stat,
90755 },
90756 {
90757 .procname = "rdma_stat_sq_prod",
90758 .data = &rdma_stat_sq_prod,
90759 - .maxlen = sizeof(atomic_t),
90760 + .maxlen = sizeof(atomic_unchecked_t),
90761 .mode = 0644,
90762 .proc_handler = read_reset_stat,
90763 },
90764 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90765 index 0ce7552..d074459 100644
90766 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90767 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90768 @@ -501,7 +501,7 @@ next_sge:
90769 svc_rdma_put_context(ctxt, 0);
90770 goto out;
90771 }
90772 - atomic_inc(&rdma_stat_read);
90773 + atomic_inc_unchecked(&rdma_stat_read);
90774
90775 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90776 chl_map->ch[ch_no].count -= read_wr.num_sge;
90777 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90778 dto_q);
90779 list_del_init(&ctxt->dto_q);
90780 } else {
90781 - atomic_inc(&rdma_stat_rq_starve);
90782 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90783 clear_bit(XPT_DATA, &xprt->xpt_flags);
90784 ctxt = NULL;
90785 }
90786 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90787 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90788 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90789 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90790 - atomic_inc(&rdma_stat_recv);
90791 + atomic_inc_unchecked(&rdma_stat_recv);
90792
90793 /* Build up the XDR from the receive buffers. */
90794 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90795 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90796 index c1d124d..acfc59e 100644
90797 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90798 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90799 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90800 write_wr.wr.rdma.remote_addr = to;
90801
90802 /* Post It */
90803 - atomic_inc(&rdma_stat_write);
90804 + atomic_inc_unchecked(&rdma_stat_write);
90805 if (svc_rdma_send(xprt, &write_wr))
90806 goto err;
90807 return 0;
90808 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90809 index 62e4f9b..dd3f2d7 100644
90810 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90811 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90812 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90813 return;
90814
90815 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90816 - atomic_inc(&rdma_stat_rq_poll);
90817 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90818
90819 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90820 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90821 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90822 }
90823
90824 if (ctxt)
90825 - atomic_inc(&rdma_stat_rq_prod);
90826 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90827
90828 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90829 /*
90830 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90831 return;
90832
90833 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90834 - atomic_inc(&rdma_stat_sq_poll);
90835 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90836 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90837 if (wc.status != IB_WC_SUCCESS)
90838 /* Close the transport */
90839 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90840 }
90841
90842 if (ctxt)
90843 - atomic_inc(&rdma_stat_sq_prod);
90844 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90845 }
90846
90847 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90848 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90849 spin_lock_bh(&xprt->sc_lock);
90850 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90851 spin_unlock_bh(&xprt->sc_lock);
90852 - atomic_inc(&rdma_stat_sq_starve);
90853 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90854
90855 /* See if we can opportunistically reap SQ WR to make room */
90856 sq_cq_reap(xprt);
90857 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90858 index 9bc6db0..47ac8c0 100644
90859 --- a/net/sysctl_net.c
90860 +++ b/net/sysctl_net.c
90861 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90862 kgid_t root_gid = make_kgid(net->user_ns, 0);
90863
90864 /* Allow network administrator to have same access as root. */
90865 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90866 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90867 uid_eq(root_uid, current_uid())) {
90868 int mode = (table->mode >> 6) & 7;
90869 return (mode << 6) | (mode << 3) | mode;
90870 diff --git a/net/tipc/link.c b/net/tipc/link.c
90871 index daa6080..2bbbe70 100644
90872 --- a/net/tipc/link.c
90873 +++ b/net/tipc/link.c
90874 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90875 struct tipc_msg fragm_hdr;
90876 struct sk_buff *buf, *buf_chain, *prev;
90877 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90878 - const unchar *sect_crs;
90879 + const unchar __user *sect_crs;
90880 int curr_sect;
90881 u32 fragm_no;
90882
90883 @@ -1242,7 +1242,7 @@ again:
90884
90885 if (!sect_rest) {
90886 sect_rest = msg_sect[++curr_sect].iov_len;
90887 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90888 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90889 }
90890
90891 if (sect_rest < fragm_rest)
90892 @@ -1261,7 +1261,7 @@ error:
90893 }
90894 } else
90895 skb_copy_to_linear_data_offset(buf, fragm_crs,
90896 - sect_crs, sz);
90897 + (const void __force_kernel *)sect_crs, sz);
90898 sect_crs += sz;
90899 sect_rest -= sz;
90900 fragm_crs += sz;
90901 @@ -2306,8 +2306,11 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
90902 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
90903 u32 msg_typ = msg_type(tunnel_msg);
90904 u32 msg_count = msg_msgcnt(tunnel_msg);
90905 + u32 bearer_id = msg_bearer_id(tunnel_msg);
90906
90907 - dest_link = (*l_ptr)->owner->links[msg_bearer_id(tunnel_msg)];
90908 + if (bearer_id >= MAX_BEARERS)
90909 + goto exit;
90910 + dest_link = (*l_ptr)->owner->links[bearer_id];
90911 if (!dest_link)
90912 goto exit;
90913 if (dest_link == *l_ptr) {
90914 @@ -2521,14 +2524,16 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
90915 struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm);
90916 u32 msg_sz = msg_size(imsg);
90917 u32 fragm_sz = msg_data_sz(fragm);
90918 - u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
90919 + u32 exp_fragm_cnt;
90920 u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE;
90921 +
90922 if (msg_type(imsg) == TIPC_MCAST_MSG)
90923 max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE;
90924 - if (msg_size(imsg) > max) {
90925 + if (fragm_sz == 0 || msg_size(imsg) > max) {
90926 kfree_skb(fbuf);
90927 return 0;
90928 }
90929 + exp_fragm_cnt = msg_sz / fragm_sz + !!(msg_sz % fragm_sz);
90930 pbuf = tipc_buf_acquire(msg_size(imsg));
90931 if (pbuf != NULL) {
90932 pbuf->next = *pending;
90933 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90934 index f2db8a8..9245aa4 100644
90935 --- a/net/tipc/msg.c
90936 +++ b/net/tipc/msg.c
90937 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90938 msg_sect[cnt].iov_len);
90939 else
90940 skb_copy_to_linear_data_offset(*buf, pos,
90941 - msg_sect[cnt].iov_base,
90942 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90943 msg_sect[cnt].iov_len);
90944 pos += msg_sect[cnt].iov_len;
90945 }
90946 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90947 index 6b42d47..2ac24d5 100644
90948 --- a/net/tipc/subscr.c
90949 +++ b/net/tipc/subscr.c
90950 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90951 {
90952 struct iovec msg_sect;
90953
90954 - msg_sect.iov_base = (void *)&sub->evt;
90955 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90956 msg_sect.iov_len = sizeof(struct tipc_event);
90957
90958 sub->evt.event = htohl(event, sub->swap);
90959 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90960 index 2db702d..09a77488 100644
90961 --- a/net/unix/af_unix.c
90962 +++ b/net/unix/af_unix.c
90963 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
90964 err = -ECONNREFUSED;
90965 if (!S_ISSOCK(inode->i_mode))
90966 goto put_fail;
90967 +
90968 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90969 + err = -EACCES;
90970 + goto put_fail;
90971 + }
90972 +
90973 u = unix_find_socket_byinode(inode);
90974 if (!u)
90975 goto put_fail;
90976 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
90977 if (u) {
90978 struct dentry *dentry;
90979 dentry = unix_sk(u)->path.dentry;
90980 +
90981 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90982 + err = -EPERM;
90983 + sock_put(u);
90984 + goto fail;
90985 + }
90986 +
90987 if (dentry)
90988 touch_atime(&unix_sk(u)->path);
90989 } else
90990 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90991 */
90992 err = security_path_mknod(&path, dentry, mode, 0);
90993 if (!err) {
90994 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90995 + err = -EACCES;
90996 + goto out;
90997 + }
90998 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90999 if (!err) {
91000 res->mnt = mntget(path.mnt);
91001 res->dentry = dget(dentry);
91002 + gr_handle_create(dentry, path.mnt);
91003 }
91004 }
91005 +out:
91006 done_path_create(&path, dentry);
91007 return err;
91008 }
91009 @@ -2323,9 +2342,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91010 seq_puts(seq, "Num RefCount Protocol Flags Type St "
91011 "Inode Path\n");
91012 else {
91013 - struct sock *s = v;
91014 + struct sock *s = v, *peer;
91015 struct unix_sock *u = unix_sk(s);
91016 unix_state_lock(s);
91017 + peer = unix_peer(s);
91018 + unix_state_unlock(s);
91019 +
91020 + unix_state_double_lock(s, peer);
91021
91022 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
91023 s,
91024 @@ -2352,8 +2375,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91025 }
91026 for ( ; i < len; i++)
91027 seq_putc(seq, u->addr->name->sun_path[i]);
91028 - }
91029 - unix_state_unlock(s);
91030 + } else if (peer)
91031 + seq_printf(seq, " P%lu", sock_i_ino(peer));
91032 +
91033 + unix_state_double_unlock(s, peer);
91034 seq_putc(seq, '\n');
91035 }
91036
91037 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
91038 index 8800604..0526440 100644
91039 --- a/net/unix/sysctl_net_unix.c
91040 +++ b/net/unix/sysctl_net_unix.c
91041 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
91042
91043 int __net_init unix_sysctl_register(struct net *net)
91044 {
91045 - struct ctl_table *table;
91046 + ctl_table_no_const *table;
91047
91048 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
91049 if (table == NULL)
91050 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
91051 index c8717c1..08539f5 100644
91052 --- a/net/wireless/wext-core.c
91053 +++ b/net/wireless/wext-core.c
91054 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91055 */
91056
91057 /* Support for very large requests */
91058 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
91059 - (user_length > descr->max_tokens)) {
91060 + if (user_length > descr->max_tokens) {
91061 /* Allow userspace to GET more than max so
91062 * we can support any size GET requests.
91063 * There is still a limit : -ENOMEM.
91064 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91065 }
91066 }
91067
91068 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
91069 - /*
91070 - * If this is a GET, but not NOMAX, it means that the extra
91071 - * data is not bounded by userspace, but by max_tokens. Thus
91072 - * set the length to max_tokens. This matches the extra data
91073 - * allocation.
91074 - * The driver should fill it with the number of tokens it
91075 - * provided, and it may check iwp->length rather than having
91076 - * knowledge of max_tokens. If the driver doesn't change the
91077 - * iwp->length, this ioctl just copies back max_token tokens
91078 - * filled with zeroes. Hopefully the driver isn't claiming
91079 - * them to be valid data.
91080 - */
91081 - iwp->length = descr->max_tokens;
91082 - }
91083 -
91084 err = handler(dev, info, (union iwreq_data *) iwp, extra);
91085
91086 iwp->length += essid_compat;
91087 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
91088 index 167c67d..3f2ae427 100644
91089 --- a/net/xfrm/xfrm_policy.c
91090 +++ b/net/xfrm/xfrm_policy.c
91091 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
91092 {
91093 policy->walk.dead = 1;
91094
91095 - atomic_inc(&policy->genid);
91096 + atomic_inc_unchecked(&policy->genid);
91097
91098 del_timer(&policy->polq.hold_timer);
91099 xfrm_queue_purge(&policy->polq.hold_queue);
91100 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
91101 hlist_add_head(&policy->bydst, chain);
91102 xfrm_pol_hold(policy);
91103 net->xfrm.policy_count[dir]++;
91104 - atomic_inc(&flow_cache_genid);
91105 + atomic_inc_unchecked(&flow_cache_genid);
91106 rt_genid_bump(net);
91107 if (delpol) {
91108 xfrm_policy_requeue(delpol, policy);
91109 @@ -1611,7 +1611,7 @@ free_dst:
91110 goto out;
91111 }
91112
91113 -static int inline
91114 +static inline int
91115 xfrm_dst_alloc_copy(void **target, const void *src, int size)
91116 {
91117 if (!*target) {
91118 @@ -1623,7 +1623,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
91119 return 0;
91120 }
91121
91122 -static int inline
91123 +static inline int
91124 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91125 {
91126 #ifdef CONFIG_XFRM_SUB_POLICY
91127 @@ -1635,7 +1635,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91128 #endif
91129 }
91130
91131 -static int inline
91132 +static inline int
91133 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
91134 {
91135 #ifdef CONFIG_XFRM_SUB_POLICY
91136 @@ -1729,7 +1729,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
91137
91138 xdst->num_pols = num_pols;
91139 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
91140 - xdst->policy_genid = atomic_read(&pols[0]->genid);
91141 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
91142
91143 return xdst;
91144 }
91145 @@ -2598,7 +2598,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
91146 if (xdst->xfrm_genid != dst->xfrm->genid)
91147 return 0;
91148 if (xdst->num_pols > 0 &&
91149 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
91150 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
91151 return 0;
91152
91153 mtu = dst_mtu(dst->child);
91154 @@ -2686,8 +2686,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
91155 dst_ops->link_failure = xfrm_link_failure;
91156 if (likely(dst_ops->neigh_lookup == NULL))
91157 dst_ops->neigh_lookup = xfrm_neigh_lookup;
91158 - if (likely(afinfo->garbage_collect == NULL))
91159 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91160 + if (likely(afinfo->garbage_collect == NULL)) {
91161 + pax_open_kernel();
91162 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91163 + pax_close_kernel();
91164 + }
91165 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
91166 }
91167 spin_unlock(&xfrm_policy_afinfo_lock);
91168 @@ -2741,7 +2744,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
91169 dst_ops->check = NULL;
91170 dst_ops->negative_advice = NULL;
91171 dst_ops->link_failure = NULL;
91172 - afinfo->garbage_collect = NULL;
91173 + pax_open_kernel();
91174 + *(void **)&afinfo->garbage_collect = NULL;
91175 + pax_close_kernel();
91176 }
91177 return err;
91178 }
91179 @@ -3124,7 +3129,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
91180 sizeof(pol->xfrm_vec[i].saddr));
91181 pol->xfrm_vec[i].encap_family = mp->new_family;
91182 /* flush bundles */
91183 - atomic_inc(&pol->genid);
91184 + atomic_inc_unchecked(&pol->genid);
91185 }
91186 }
91187
91188 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
91189 index 2c341bd..4404211 100644
91190 --- a/net/xfrm/xfrm_state.c
91191 +++ b/net/xfrm/xfrm_state.c
91192 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
91193
91194 if (unlikely(afinfo == NULL))
91195 return -EAFNOSUPPORT;
91196 - typemap = afinfo->type_map;
91197 + typemap = (const struct xfrm_type **)afinfo->type_map;
91198 spin_lock_bh(&xfrm_type_lock);
91199
91200 - if (likely(typemap[type->proto] == NULL))
91201 + if (likely(typemap[type->proto] == NULL)) {
91202 + pax_open_kernel();
91203 typemap[type->proto] = type;
91204 - else
91205 + pax_close_kernel();
91206 + } else
91207 err = -EEXIST;
91208 spin_unlock_bh(&xfrm_type_lock);
91209 xfrm_state_put_afinfo(afinfo);
91210 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
91211
91212 if (unlikely(afinfo == NULL))
91213 return -EAFNOSUPPORT;
91214 - typemap = afinfo->type_map;
91215 + typemap = (const struct xfrm_type **)afinfo->type_map;
91216 spin_lock_bh(&xfrm_type_lock);
91217
91218 if (unlikely(typemap[type->proto] != type))
91219 err = -ENOENT;
91220 - else
91221 + else {
91222 + pax_open_kernel();
91223 typemap[type->proto] = NULL;
91224 + pax_close_kernel();
91225 + }
91226 spin_unlock_bh(&xfrm_type_lock);
91227 xfrm_state_put_afinfo(afinfo);
91228 return err;
91229 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
91230 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
91231 {
91232 struct xfrm_state_afinfo *afinfo;
91233 - const struct xfrm_type **typemap;
91234 const struct xfrm_type *type;
91235 int modload_attempted = 0;
91236
91237 @@ -222,9 +226,8 @@ retry:
91238 afinfo = xfrm_state_get_afinfo(family);
91239 if (unlikely(afinfo == NULL))
91240 return NULL;
91241 - typemap = afinfo->type_map;
91242
91243 - type = typemap[proto];
91244 + type = afinfo->type_map[proto];
91245 if (unlikely(type && !try_module_get(type->owner)))
91246 type = NULL;
91247 if (!type && !modload_attempted) {
91248 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91249 return -EAFNOSUPPORT;
91250
91251 err = -EEXIST;
91252 - modemap = afinfo->mode_map;
91253 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91254 spin_lock_bh(&xfrm_mode_lock);
91255 if (modemap[mode->encap])
91256 goto out;
91257 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91258 if (!try_module_get(afinfo->owner))
91259 goto out;
91260
91261 - mode->afinfo = afinfo;
91262 + pax_open_kernel();
91263 + *(const void **)&mode->afinfo = afinfo;
91264 modemap[mode->encap] = mode;
91265 + pax_close_kernel();
91266 err = 0;
91267
91268 out:
91269 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
91270 return -EAFNOSUPPORT;
91271
91272 err = -ENOENT;
91273 - modemap = afinfo->mode_map;
91274 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91275 spin_lock_bh(&xfrm_mode_lock);
91276 if (likely(modemap[mode->encap] == mode)) {
91277 + pax_open_kernel();
91278 modemap[mode->encap] = NULL;
91279 + pax_close_kernel();
91280 module_put(mode->afinfo->owner);
91281 err = 0;
91282 }
91283 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
91284 index 05a6e3d..6716ec9 100644
91285 --- a/net/xfrm/xfrm_sysctl.c
91286 +++ b/net/xfrm/xfrm_sysctl.c
91287 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
91288
91289 int __net_init xfrm_sysctl_init(struct net *net)
91290 {
91291 - struct ctl_table *table;
91292 + ctl_table_no_const *table;
91293
91294 __xfrm_sysctl_init(net);
91295
91296 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
91297 index 0e801c3..5c8ad3b 100644
91298 --- a/scripts/Makefile.build
91299 +++ b/scripts/Makefile.build
91300 @@ -111,7 +111,7 @@ endif
91301 endif
91302
91303 # Do not include host rules unless needed
91304 -ifneq ($(hostprogs-y)$(hostprogs-m),)
91305 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
91306 include scripts/Makefile.host
91307 endif
91308
91309 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
91310 index 686cb0d..9d653bf 100644
91311 --- a/scripts/Makefile.clean
91312 +++ b/scripts/Makefile.clean
91313 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91314 __clean-files := $(extra-y) $(always) \
91315 $(targets) $(clean-files) \
91316 $(host-progs) \
91317 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91318 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91319 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91320
91321 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91322
91323 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91324 index 1ac414f..38575f7 100644
91325 --- a/scripts/Makefile.host
91326 +++ b/scripts/Makefile.host
91327 @@ -31,6 +31,8 @@
91328 # Note: Shared libraries consisting of C++ files are not supported
91329
91330 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91331 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91332 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91333
91334 # C code
91335 # Executables compiled from a single .c file
91336 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91337 # Shared libaries (only .c supported)
91338 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91339 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91340 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91341 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91342 # Remove .so files from "xxx-objs"
91343 host-cobjs := $(filter-out %.so,$(host-cobjs))
91344 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91345
91346 -#Object (.o) files used by the shared libaries
91347 +# Object (.o) files used by the shared libaries
91348 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91349 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91350
91351 # output directory for programs/.o files
91352 # hostprogs-y := tools/build may have been specified. Retrieve directory
91353 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91354 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91355 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91356 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91357 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91358 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91359 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91360 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91361
91362 obj-dirs += $(host-objdirs)
91363 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91364 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91365 $(call if_changed_dep,host-cshobjs)
91366
91367 +# Compile .c file, create position independent .o file
91368 +# host-cxxshobjs -> .o
91369 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91370 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91371 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91372 + $(call if_changed_dep,host-cxxshobjs)
91373 +
91374 # Link a shared library, based on position independent .o files
91375 # *.o -> .so shared library (host-cshlib)
91376 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91377 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91378 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91379 $(call if_changed,host-cshlib)
91380
91381 +# Link a shared library, based on position independent .o files
91382 +# *.o -> .so shared library (host-cxxshlib)
91383 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91384 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91385 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91386 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91387 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91388 + $(call if_changed,host-cxxshlib)
91389 +
91390 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91391 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91392 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91393
91394 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91395 index 7f6425e..9864506 100644
91396 --- a/scripts/basic/fixdep.c
91397 +++ b/scripts/basic/fixdep.c
91398 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91399 /*
91400 * Lookup a value in the configuration string.
91401 */
91402 -static int is_defined_config(const char *name, int len, unsigned int hash)
91403 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91404 {
91405 struct item *aux;
91406
91407 @@ -211,10 +211,10 @@ static void clear_config(void)
91408 /*
91409 * Record the use of a CONFIG_* word.
91410 */
91411 -static void use_config(const char *m, int slen)
91412 +static void use_config(const char *m, unsigned int slen)
91413 {
91414 unsigned int hash = strhash(m, slen);
91415 - int c, i;
91416 + unsigned int c, i;
91417
91418 if (is_defined_config(m, slen, hash))
91419 return;
91420 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91421
91422 static void parse_config_file(const char *map, size_t len)
91423 {
91424 - const int *end = (const int *) (map + len);
91425 + const unsigned int *end = (const unsigned int *) (map + len);
91426 /* start at +1, so that p can never be < map */
91427 - const int *m = (const int *) map + 1;
91428 + const unsigned int *m = (const unsigned int *) map + 1;
91429 const char *p, *q;
91430
91431 for (; m < end; m++) {
91432 @@ -406,7 +406,7 @@ static void print_deps(void)
91433 static void traps(void)
91434 {
91435 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91436 - int *p = (int *)test;
91437 + unsigned int *p = (unsigned int *)test;
91438
91439 if (*p != INT_CONF) {
91440 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
91441 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91442 new file mode 100644
91443 index 0000000..5e0222d
91444 --- /dev/null
91445 +++ b/scripts/gcc-plugin.sh
91446 @@ -0,0 +1,17 @@
91447 +#!/bin/bash
91448 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91449 +#include "gcc-plugin.h"
91450 +#include "tree.h"
91451 +#include "tm.h"
91452 +#include "rtl.h"
91453 +#ifdef ENABLE_BUILD_WITH_CXX
91454 +#warning $2
91455 +#else
91456 +#warning $1
91457 +#endif
91458 +EOF`
91459 +if [ $? -eq 0 ]
91460 +then
91461 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91462 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91463 +fi
91464 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91465 index 581ca99..a6ff02e 100644
91466 --- a/scripts/headers_install.pl
91467 +++ b/scripts/headers_install.pl
91468 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91469 $line =~ s/([\s(])__user\s/$1/g;
91470 $line =~ s/([\s(])__force\s/$1/g;
91471 $line =~ s/([\s(])__iomem\s/$1/g;
91472 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91473 $line =~ s/\s__attribute_const__\s/ /g;
91474 $line =~ s/\s__attribute_const__$//g;
91475 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91476 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91477 index 3d569d6..0c09522 100644
91478 --- a/scripts/link-vmlinux.sh
91479 +++ b/scripts/link-vmlinux.sh
91480 @@ -159,7 +159,7 @@ else
91481 fi;
91482
91483 # final build of init/
91484 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91485 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91486
91487 kallsymso=""
91488 kallsyms_vmlinux=""
91489 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91490 index 771ac17..9f0d3ee 100644
91491 --- a/scripts/mod/file2alias.c
91492 +++ b/scripts/mod/file2alias.c
91493 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
91494 unsigned long size, unsigned long id_size,
91495 void *symval)
91496 {
91497 - int i;
91498 + unsigned int i;
91499
91500 if (size % id_size || size < id_size) {
91501 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
91502 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
91503 /* USB is special because the bcdDevice can be matched against a numeric range */
91504 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91505 static void do_usb_entry(void *symval,
91506 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91507 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91508 unsigned char range_lo, unsigned char range_hi,
91509 unsigned char max, struct module *mod)
91510 {
91511 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
91512 {
91513 unsigned int devlo, devhi;
91514 unsigned char chi, clo, max;
91515 - int ndigits;
91516 + unsigned int ndigits;
91517
91518 DEF_FIELD(symval, usb_device_id, match_flags);
91519 DEF_FIELD(symval, usb_device_id, idVendor);
91520 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91521 for (i = 0; i < count; i++) {
91522 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
91523 char acpi_id[sizeof(*id)];
91524 - int j;
91525 + unsigned int j;
91526
91527 buf_printf(&mod->dev_table_buf,
91528 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
91529 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91530
91531 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91532 const char *id = (char *)(*devs)[j].id;
91533 - int i2, j2;
91534 + unsigned int i2, j2;
91535 int dup = 0;
91536
91537 if (!id[0])
91538 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91539 /* add an individual alias for every device entry */
91540 if (!dup) {
91541 char acpi_id[PNP_ID_LEN];
91542 - int k;
91543 + unsigned int k;
91544
91545 buf_printf(&mod->dev_table_buf,
91546 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91547 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91548 static int do_dmi_entry(const char *filename, void *symval,
91549 char *alias)
91550 {
91551 - int i, j;
91552 + unsigned int i, j;
91553 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
91554 sprintf(alias, "dmi*");
91555
91556 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91557 index 78b30c1..536850d 100644
91558 --- a/scripts/mod/modpost.c
91559 +++ b/scripts/mod/modpost.c
91560 @@ -931,6 +931,7 @@ enum mismatch {
91561 ANY_INIT_TO_ANY_EXIT,
91562 ANY_EXIT_TO_ANY_INIT,
91563 EXPORT_TO_INIT_EXIT,
91564 + DATA_TO_TEXT
91565 };
91566
91567 struct sectioncheck {
91568 @@ -1045,6 +1046,12 @@ const struct sectioncheck sectioncheck[] = {
91569 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91570 .mismatch = EXPORT_TO_INIT_EXIT,
91571 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91572 +},
91573 +/* Do not reference code from writable data */
91574 +{
91575 + .fromsec = { DATA_SECTIONS, NULL },
91576 + .tosec = { TEXT_SECTIONS, NULL },
91577 + .mismatch = DATA_TO_TEXT
91578 }
91579 };
91580
91581 @@ -1167,10 +1174,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91582 continue;
91583 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91584 continue;
91585 - if (sym->st_value == addr)
91586 - return sym;
91587 /* Find a symbol nearby - addr are maybe negative */
91588 d = sym->st_value - addr;
91589 + if (d == 0)
91590 + return sym;
91591 if (d < 0)
91592 d = addr - sym->st_value;
91593 if (d < distance) {
91594 @@ -1449,6 +1456,14 @@ static void report_sec_mismatch(const char *modname,
91595 tosym, prl_to, prl_to, tosym);
91596 free(prl_to);
91597 break;
91598 + case DATA_TO_TEXT:
91599 +#if 0
91600 + fprintf(stderr,
91601 + "The %s %s:%s references\n"
91602 + "the %s %s:%s%s\n",
91603 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91604 +#endif
91605 + break;
91606 }
91607 fprintf(stderr, "\n");
91608 }
91609 @@ -1683,7 +1698,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91610 static void check_sec_ref(struct module *mod, const char *modname,
91611 struct elf_info *elf)
91612 {
91613 - int i;
91614 + unsigned int i;
91615 Elf_Shdr *sechdrs = elf->sechdrs;
91616
91617 /* Walk through all sections */
91618 @@ -1781,7 +1796,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91619 va_end(ap);
91620 }
91621
91622 -void buf_write(struct buffer *buf, const char *s, int len)
91623 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91624 {
91625 if (buf->size - buf->pos < len) {
91626 buf->size += len + SZ;
91627 @@ -1999,7 +2014,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91628 if (fstat(fileno(file), &st) < 0)
91629 goto close_write;
91630
91631 - if (st.st_size != b->pos)
91632 + if (st.st_size != (off_t)b->pos)
91633 goto close_write;
91634
91635 tmp = NOFAIL(malloc(b->pos));
91636 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91637 index 51207e4..f7d603d 100644
91638 --- a/scripts/mod/modpost.h
91639 +++ b/scripts/mod/modpost.h
91640 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91641
91642 struct buffer {
91643 char *p;
91644 - int pos;
91645 - int size;
91646 + unsigned int pos;
91647 + unsigned int size;
91648 };
91649
91650 void __attribute__((format(printf, 2, 3)))
91651 buf_printf(struct buffer *buf, const char *fmt, ...);
91652
91653 void
91654 -buf_write(struct buffer *buf, const char *s, int len);
91655 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91656
91657 struct module {
91658 struct module *next;
91659 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91660 index 9dfcd6d..099068e 100644
91661 --- a/scripts/mod/sumversion.c
91662 +++ b/scripts/mod/sumversion.c
91663 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91664 goto out;
91665 }
91666
91667 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91668 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91669 warn("writing sum in %s failed: %s\n",
91670 filename, strerror(errno));
91671 goto out;
91672 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91673 index acb8650..b8c5f02 100644
91674 --- a/scripts/package/builddeb
91675 +++ b/scripts/package/builddeb
91676 @@ -246,6 +246,7 @@ fi
91677 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91678 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91679 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91680 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91681 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91682 mkdir -p "$destdir"
91683 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91684 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91685 index 68bb4ef..2f419e1 100644
91686 --- a/scripts/pnmtologo.c
91687 +++ b/scripts/pnmtologo.c
91688 @@ -244,14 +244,14 @@ static void write_header(void)
91689 fprintf(out, " * Linux logo %s\n", logoname);
91690 fputs(" */\n\n", out);
91691 fputs("#include <linux/linux_logo.h>\n\n", out);
91692 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91693 + fprintf(out, "static unsigned char %s_data[] = {\n",
91694 logoname);
91695 }
91696
91697 static void write_footer(void)
91698 {
91699 fputs("\n};\n\n", out);
91700 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91701 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91702 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91703 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91704 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91705 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91706 fputs("\n};\n\n", out);
91707
91708 /* write logo clut */
91709 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91710 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91711 logoname);
91712 write_hex_cnt = 0;
91713 for (i = 0; i < logo_clutsize; i++) {
91714 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91715 index f5eb43d..1814de8 100644
91716 --- a/scripts/sortextable.h
91717 +++ b/scripts/sortextable.h
91718 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91719 const char *secstrtab;
91720 const char *strtab;
91721 char *extab_image;
91722 - int extab_index = 0;
91723 - int i;
91724 - int idx;
91725 + unsigned int extab_index = 0;
91726 + unsigned int i;
91727 + unsigned int idx;
91728
91729 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91730 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91731 diff --git a/security/Kconfig b/security/Kconfig
91732 index e9c6ac7..66bf8e9 100644
91733 --- a/security/Kconfig
91734 +++ b/security/Kconfig
91735 @@ -4,6 +4,945 @@
91736
91737 menu "Security options"
91738
91739 +menu "Grsecurity"
91740 +
91741 + config ARCH_TRACK_EXEC_LIMIT
91742 + bool
91743 +
91744 + config PAX_KERNEXEC_PLUGIN
91745 + bool
91746 +
91747 + config PAX_PER_CPU_PGD
91748 + bool
91749 +
91750 + config TASK_SIZE_MAX_SHIFT
91751 + int
91752 + depends on X86_64
91753 + default 47 if !PAX_PER_CPU_PGD
91754 + default 42 if PAX_PER_CPU_PGD
91755 +
91756 + config PAX_ENABLE_PAE
91757 + bool
91758 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91759 +
91760 + config PAX_USERCOPY_SLABS
91761 + bool
91762 +
91763 +config GRKERNSEC
91764 + bool "Grsecurity"
91765 + select CRYPTO
91766 + select CRYPTO_SHA256
91767 + select PROC_FS
91768 + select STOP_MACHINE
91769 + select TTY
91770 + help
91771 + If you say Y here, you will be able to configure many features
91772 + that will enhance the security of your system. It is highly
91773 + recommended that you say Y here and read through the help
91774 + for each option so that you fully understand the features and
91775 + can evaluate their usefulness for your machine.
91776 +
91777 +choice
91778 + prompt "Configuration Method"
91779 + depends on GRKERNSEC
91780 + default GRKERNSEC_CONFIG_CUSTOM
91781 + help
91782 +
91783 +config GRKERNSEC_CONFIG_AUTO
91784 + bool "Automatic"
91785 + help
91786 + If you choose this configuration method, you'll be able to answer a small
91787 + number of simple questions about how you plan to use this kernel.
91788 + The settings of grsecurity and PaX will be automatically configured for
91789 + the highest commonly-used settings within the provided constraints.
91790 +
91791 + If you require additional configuration, custom changes can still be made
91792 + from the "custom configuration" menu.
91793 +
91794 +config GRKERNSEC_CONFIG_CUSTOM
91795 + bool "Custom"
91796 + help
91797 + If you choose this configuration method, you'll be able to configure all
91798 + grsecurity and PaX settings manually. Via this method, no options are
91799 + automatically enabled.
91800 +
91801 +endchoice
91802 +
91803 +choice
91804 + prompt "Usage Type"
91805 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91806 + default GRKERNSEC_CONFIG_SERVER
91807 + help
91808 +
91809 +config GRKERNSEC_CONFIG_SERVER
91810 + bool "Server"
91811 + help
91812 + Choose this option if you plan to use this kernel on a server.
91813 +
91814 +config GRKERNSEC_CONFIG_DESKTOP
91815 + bool "Desktop"
91816 + help
91817 + Choose this option if you plan to use this kernel on a desktop.
91818 +
91819 +endchoice
91820 +
91821 +choice
91822 + prompt "Virtualization Type"
91823 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91824 + default GRKERNSEC_CONFIG_VIRT_NONE
91825 + help
91826 +
91827 +config GRKERNSEC_CONFIG_VIRT_NONE
91828 + bool "None"
91829 + help
91830 + Choose this option if this kernel will be run on bare metal.
91831 +
91832 +config GRKERNSEC_CONFIG_VIRT_GUEST
91833 + bool "Guest"
91834 + help
91835 + Choose this option if this kernel will be run as a VM guest.
91836 +
91837 +config GRKERNSEC_CONFIG_VIRT_HOST
91838 + bool "Host"
91839 + help
91840 + Choose this option if this kernel will be run as a VM host.
91841 +
91842 +endchoice
91843 +
91844 +choice
91845 + prompt "Virtualization Hardware"
91846 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91847 + help
91848 +
91849 +config GRKERNSEC_CONFIG_VIRT_EPT
91850 + bool "EPT/RVI Processor Support"
91851 + depends on X86
91852 + help
91853 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91854 + hardware virtualization. This allows for additional kernel hardening protections
91855 + to operate without additional performance impact.
91856 +
91857 + To see if your Intel processor supports EPT, see:
91858 + http://ark.intel.com/Products/VirtualizationTechnology
91859 + (Most Core i3/5/7 support EPT)
91860 +
91861 + To see if your AMD processor supports RVI, see:
91862 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91863 +
91864 +config GRKERNSEC_CONFIG_VIRT_SOFT
91865 + bool "First-gen/No Hardware Virtualization"
91866 + help
91867 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91868 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91869 +
91870 +endchoice
91871 +
91872 +choice
91873 + prompt "Virtualization Software"
91874 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91875 + help
91876 +
91877 +config GRKERNSEC_CONFIG_VIRT_XEN
91878 + bool "Xen"
91879 + help
91880 + Choose this option if this kernel is running as a Xen guest or host.
91881 +
91882 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91883 + bool "VMWare"
91884 + help
91885 + Choose this option if this kernel is running as a VMWare guest or host.
91886 +
91887 +config GRKERNSEC_CONFIG_VIRT_KVM
91888 + bool "KVM"
91889 + help
91890 + Choose this option if this kernel is running as a KVM guest or host.
91891 +
91892 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91893 + bool "VirtualBox"
91894 + help
91895 + Choose this option if this kernel is running as a VirtualBox guest or host.
91896 +
91897 +endchoice
91898 +
91899 +choice
91900 + prompt "Required Priorities"
91901 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91902 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91903 + help
91904 +
91905 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91906 + bool "Performance"
91907 + help
91908 + Choose this option if performance is of highest priority for this deployment
91909 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91910 + clearing of structures intended for userland, and freed memory sanitizing will
91911 + be disabled.
91912 +
91913 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91914 + bool "Security"
91915 + help
91916 + Choose this option if security is of highest priority for this deployment of
91917 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91918 + for userland, and freed memory sanitizing will be enabled for this kernel.
91919 + In a worst-case scenario, these features can introduce a 20% performance hit
91920 + (UDEREF on x64 contributing half of this hit).
91921 +
91922 +endchoice
91923 +
91924 +menu "Default Special Groups"
91925 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91926 +
91927 +config GRKERNSEC_PROC_GID
91928 + int "GID exempted from /proc restrictions"
91929 + default 1001
91930 + help
91931 + Setting this GID determines which group will be exempted from
91932 + grsecurity's /proc restrictions, allowing users of the specified
91933 + group to view network statistics and the existence of other users'
91934 + processes on the system. This GID may also be chosen at boot time
91935 + via "grsec_proc_gid=" on the kernel commandline.
91936 +
91937 +config GRKERNSEC_TPE_UNTRUSTED_GID
91938 + int "GID for TPE-untrusted users"
91939 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91940 + default 1005
91941 + help
91942 + Setting this GID determines which group untrusted users should
91943 + be added to. These users will be placed under grsecurity's Trusted Path
91944 + Execution mechanism, preventing them from executing their own binaries.
91945 + The users will only be able to execute binaries in directories owned and
91946 + writable only by the root user. If the sysctl option is enabled, a sysctl
91947 + option with name "tpe_gid" is created.
91948 +
91949 +config GRKERNSEC_TPE_TRUSTED_GID
91950 + int "GID for TPE-trusted users"
91951 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91952 + default 1005
91953 + help
91954 + Setting this GID determines what group TPE restrictions will be
91955 + *disabled* for. If the sysctl option is enabled, a sysctl option
91956 + with name "tpe_gid" is created.
91957 +
91958 +config GRKERNSEC_SYMLINKOWN_GID
91959 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91960 + depends on GRKERNSEC_CONFIG_SERVER
91961 + default 1006
91962 + help
91963 + Setting this GID determines what group kernel-enforced
91964 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91965 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91966 +
91967 +
91968 +endmenu
91969 +
91970 +menu "Customize Configuration"
91971 +depends on GRKERNSEC
91972 +
91973 +menu "PaX"
91974 +
91975 +config PAX
91976 + bool "Enable various PaX features"
91977 + default y if GRKERNSEC_CONFIG_AUTO
91978 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91979 + help
91980 + This allows you to enable various PaX features. PaX adds
91981 + intrusion prevention mechanisms to the kernel that reduce
91982 + the risks posed by exploitable memory corruption bugs.
91983 +
91984 +menu "PaX Control"
91985 + depends on PAX
91986 +
91987 +config PAX_SOFTMODE
91988 + bool 'Support soft mode'
91989 + help
91990 + Enabling this option will allow you to run PaX in soft mode, that
91991 + is, PaX features will not be enforced by default, only on executables
91992 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91993 + support as they are the only way to mark executables for soft mode use.
91994 +
91995 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91996 + line option on boot. Furthermore you can control various PaX features
91997 + at runtime via the entries in /proc/sys/kernel/pax.
91998 +
91999 +config PAX_EI_PAX
92000 + bool 'Use legacy ELF header marking'
92001 + default y if GRKERNSEC_CONFIG_AUTO
92002 + help
92003 + Enabling this option will allow you to control PaX features on
92004 + a per executable basis via the 'chpax' utility available at
92005 + http://pax.grsecurity.net/. The control flags will be read from
92006 + an otherwise reserved part of the ELF header. This marking has
92007 + numerous drawbacks (no support for soft-mode, toolchain does not
92008 + know about the non-standard use of the ELF header) therefore it
92009 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
92010 + support.
92011 +
92012 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
92013 + support as well, they will override the legacy EI_PAX marks.
92014 +
92015 + If you enable none of the marking options then all applications
92016 + will run with PaX enabled on them by default.
92017 +
92018 +config PAX_PT_PAX_FLAGS
92019 + bool 'Use ELF program header marking'
92020 + default y if GRKERNSEC_CONFIG_AUTO
92021 + help
92022 + Enabling this option will allow you to control PaX features on
92023 + a per executable basis via the 'paxctl' utility available at
92024 + http://pax.grsecurity.net/. The control flags will be read from
92025 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
92026 + has the benefits of supporting both soft mode and being fully
92027 + integrated into the toolchain (the binutils patch is available
92028 + from http://pax.grsecurity.net).
92029 +
92030 + Note that if you enable the legacy EI_PAX marking support as well,
92031 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
92032 +
92033 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92034 + must make sure that the marks are the same if a binary has both marks.
92035 +
92036 + If you enable none of the marking options then all applications
92037 + will run with PaX enabled on them by default.
92038 +
92039 +config PAX_XATTR_PAX_FLAGS
92040 + bool 'Use filesystem extended attributes marking'
92041 + default y if GRKERNSEC_CONFIG_AUTO
92042 + select CIFS_XATTR if CIFS
92043 + select EXT2_FS_XATTR if EXT2_FS
92044 + select EXT3_FS_XATTR if EXT3_FS
92045 + select EXT4_FS_XATTR if EXT4_FS
92046 + select JFFS2_FS_XATTR if JFFS2_FS
92047 + select REISERFS_FS_XATTR if REISERFS_FS
92048 + select SQUASHFS_XATTR if SQUASHFS
92049 + select TMPFS_XATTR if TMPFS
92050 + select UBIFS_FS_XATTR if UBIFS_FS
92051 + help
92052 + Enabling this option will allow you to control PaX features on
92053 + a per executable basis via the 'setfattr' utility. The control
92054 + flags will be read from the user.pax.flags extended attribute of
92055 + the file. This marking has the benefit of supporting binary-only
92056 + applications that self-check themselves (e.g., skype) and would
92057 + not tolerate chpax/paxctl changes. The main drawback is that
92058 + extended attributes are not supported by some filesystems (e.g.,
92059 + isofs, udf, vfat) so copying files through such filesystems will
92060 + lose the extended attributes and these PaX markings.
92061 +
92062 + Note that if you enable the legacy EI_PAX marking support as well,
92063 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
92064 +
92065 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92066 + must make sure that the marks are the same if a binary has both marks.
92067 +
92068 + If you enable none of the marking options then all applications
92069 + will run with PaX enabled on them by default.
92070 +
92071 +choice
92072 + prompt 'MAC system integration'
92073 + default PAX_HAVE_ACL_FLAGS
92074 + help
92075 + Mandatory Access Control systems have the option of controlling
92076 + PaX flags on a per executable basis, choose the method supported
92077 + by your particular system.
92078 +
92079 + - "none": if your MAC system does not interact with PaX,
92080 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
92081 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
92082 +
92083 + NOTE: this option is for developers/integrators only.
92084 +
92085 + config PAX_NO_ACL_FLAGS
92086 + bool 'none'
92087 +
92088 + config PAX_HAVE_ACL_FLAGS
92089 + bool 'direct'
92090 +
92091 + config PAX_HOOK_ACL_FLAGS
92092 + bool 'hook'
92093 +endchoice
92094 +
92095 +endmenu
92096 +
92097 +menu "Non-executable pages"
92098 + depends on PAX
92099 +
92100 +config PAX_NOEXEC
92101 + bool "Enforce non-executable pages"
92102 + default y if GRKERNSEC_CONFIG_AUTO
92103 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
92104 + help
92105 + By design some architectures do not allow for protecting memory
92106 + pages against execution or even if they do, Linux does not make
92107 + use of this feature. In practice this means that if a page is
92108 + readable (such as the stack or heap) it is also executable.
92109 +
92110 + There is a well known exploit technique that makes use of this
92111 + fact and a common programming mistake where an attacker can
92112 + introduce code of his choice somewhere in the attacked program's
92113 + memory (typically the stack or the heap) and then execute it.
92114 +
92115 + If the attacked program was running with different (typically
92116 + higher) privileges than that of the attacker, then he can elevate
92117 + his own privilege level (e.g. get a root shell, write to files for
92118 + which he does not have write access to, etc).
92119 +
92120 + Enabling this option will let you choose from various features
92121 + that prevent the injection and execution of 'foreign' code in
92122 + a program.
92123 +
92124 + This will also break programs that rely on the old behaviour and
92125 + expect that dynamically allocated memory via the malloc() family
92126 + of functions is executable (which it is not). Notable examples
92127 + are the XFree86 4.x server, the java runtime and wine.
92128 +
92129 +config PAX_PAGEEXEC
92130 + bool "Paging based non-executable pages"
92131 + default y if GRKERNSEC_CONFIG_AUTO
92132 + 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)
92133 + select S390_SWITCH_AMODE if S390
92134 + select S390_EXEC_PROTECT if S390
92135 + select ARCH_TRACK_EXEC_LIMIT if X86_32
92136 + help
92137 + This implementation is based on the paging feature of the CPU.
92138 + On i386 without hardware non-executable bit support there is a
92139 + variable but usually low performance impact, however on Intel's
92140 + P4 core based CPUs it is very high so you should not enable this
92141 + for kernels meant to be used on such CPUs.
92142 +
92143 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
92144 + with hardware non-executable bit support there is no performance
92145 + impact, on ppc the impact is negligible.
92146 +
92147 + Note that several architectures require various emulations due to
92148 + badly designed userland ABIs, this will cause a performance impact
92149 + but will disappear as soon as userland is fixed. For example, ppc
92150 + userland MUST have been built with secure-plt by a recent toolchain.
92151 +
92152 +config PAX_SEGMEXEC
92153 + bool "Segmentation based non-executable pages"
92154 + default y if GRKERNSEC_CONFIG_AUTO
92155 + depends on PAX_NOEXEC && X86_32
92156 + help
92157 + This implementation is based on the segmentation feature of the
92158 + CPU and has a very small performance impact, however applications
92159 + will be limited to a 1.5 GB address space instead of the normal
92160 + 3 GB.
92161 +
92162 +config PAX_EMUTRAMP
92163 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
92164 + default y if PARISC
92165 + help
92166 + There are some programs and libraries that for one reason or
92167 + another attempt to execute special small code snippets from
92168 + non-executable memory pages. Most notable examples are the
92169 + signal handler return code generated by the kernel itself and
92170 + the GCC trampolines.
92171 +
92172 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
92173 + such programs will no longer work under your kernel.
92174 +
92175 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
92176 + utilities to enable trampoline emulation for the affected programs
92177 + yet still have the protection provided by the non-executable pages.
92178 +
92179 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
92180 + your system will not even boot.
92181 +
92182 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
92183 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
92184 + for the affected files.
92185 +
92186 + NOTE: enabling this feature *may* open up a loophole in the
92187 + protection provided by non-executable pages that an attacker
92188 + could abuse. Therefore the best solution is to not have any
92189 + files on your system that would require this option. This can
92190 + be achieved by not using libc5 (which relies on the kernel
92191 + signal handler return code) and not using or rewriting programs
92192 + that make use of the nested function implementation of GCC.
92193 + Skilled users can just fix GCC itself so that it implements
92194 + nested function calls in a way that does not interfere with PaX.
92195 +
92196 +config PAX_EMUSIGRT
92197 + bool "Automatically emulate sigreturn trampolines"
92198 + depends on PAX_EMUTRAMP && PARISC
92199 + default y
92200 + help
92201 + Enabling this option will have the kernel automatically detect
92202 + and emulate signal return trampolines executing on the stack
92203 + that would otherwise lead to task termination.
92204 +
92205 + This solution is intended as a temporary one for users with
92206 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
92207 + Modula-3 runtime, etc) or executables linked to such, basically
92208 + everything that does not specify its own SA_RESTORER function in
92209 + normal executable memory like glibc 2.1+ does.
92210 +
92211 + On parisc you MUST enable this option, otherwise your system will
92212 + not even boot.
92213 +
92214 + NOTE: this feature cannot be disabled on a per executable basis
92215 + and since it *does* open up a loophole in the protection provided
92216 + by non-executable pages, the best solution is to not have any
92217 + files on your system that would require this option.
92218 +
92219 +config PAX_MPROTECT
92220 + bool "Restrict mprotect()"
92221 + default y if GRKERNSEC_CONFIG_AUTO
92222 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
92223 + help
92224 + Enabling this option will prevent programs from
92225 + - changing the executable status of memory pages that were
92226 + not originally created as executable,
92227 + - making read-only executable pages writable again,
92228 + - creating executable pages from anonymous memory,
92229 + - making read-only-after-relocations (RELRO) data pages writable again.
92230 +
92231 + You should say Y here to complete the protection provided by
92232 + the enforcement of non-executable pages.
92233 +
92234 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92235 + this feature on a per file basis.
92236 +
92237 +config PAX_MPROTECT_COMPAT
92238 + bool "Use legacy/compat protection demoting (read help)"
92239 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92240 + depends on PAX_MPROTECT
92241 + help
92242 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
92243 + by sending the proper error code to the application. For some broken
92244 + userland, this can cause problems with Python or other applications. The
92245 + current implementation however allows for applications like clamav to
92246 + detect if JIT compilation/execution is allowed and to fall back gracefully
92247 + to an interpreter-based mode if it does not. While we encourage everyone
92248 + to use the current implementation as-is and push upstream to fix broken
92249 + userland (note that the RWX logging option can assist with this), in some
92250 + environments this may not be possible. Having to disable MPROTECT
92251 + completely on certain binaries reduces the security benefit of PaX,
92252 + so this option is provided for those environments to revert to the old
92253 + behavior.
92254 +
92255 +config PAX_ELFRELOCS
92256 + bool "Allow ELF text relocations (read help)"
92257 + depends on PAX_MPROTECT
92258 + default n
92259 + help
92260 + Non-executable pages and mprotect() restrictions are effective
92261 + in preventing the introduction of new executable code into an
92262 + attacked task's address space. There remain only two venues
92263 + for this kind of attack: if the attacker can execute already
92264 + existing code in the attacked task then he can either have it
92265 + create and mmap() a file containing his code or have it mmap()
92266 + an already existing ELF library that does not have position
92267 + independent code in it and use mprotect() on it to make it
92268 + writable and copy his code there. While protecting against
92269 + the former approach is beyond PaX, the latter can be prevented
92270 + by having only PIC ELF libraries on one's system (which do not
92271 + need to relocate their code). If you are sure this is your case,
92272 + as is the case with all modern Linux distributions, then leave
92273 + this option disabled. You should say 'n' here.
92274 +
92275 +config PAX_ETEXECRELOCS
92276 + bool "Allow ELF ET_EXEC text relocations"
92277 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
92278 + select PAX_ELFRELOCS
92279 + default y
92280 + help
92281 + On some architectures there are incorrectly created applications
92282 + that require text relocations and would not work without enabling
92283 + this option. If you are an alpha, ia64 or parisc user, you should
92284 + enable this option and disable it once you have made sure that
92285 + none of your applications need it.
92286 +
92287 +config PAX_EMUPLT
92288 + bool "Automatically emulate ELF PLT"
92289 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
92290 + default y
92291 + help
92292 + Enabling this option will have the kernel automatically detect
92293 + and emulate the Procedure Linkage Table entries in ELF files.
92294 + On some architectures such entries are in writable memory, and
92295 + become non-executable leading to task termination. Therefore
92296 + it is mandatory that you enable this option on alpha, parisc,
92297 + sparc and sparc64, otherwise your system would not even boot.
92298 +
92299 + NOTE: this feature *does* open up a loophole in the protection
92300 + provided by the non-executable pages, therefore the proper
92301 + solution is to modify the toolchain to produce a PLT that does
92302 + not need to be writable.
92303 +
92304 +config PAX_DLRESOLVE
92305 + bool 'Emulate old glibc resolver stub'
92306 + depends on PAX_EMUPLT && SPARC
92307 + default n
92308 + help
92309 + This option is needed if userland has an old glibc (before 2.4)
92310 + that puts a 'save' instruction into the runtime generated resolver
92311 + stub that needs special emulation.
92312 +
92313 +config PAX_KERNEXEC
92314 + bool "Enforce non-executable kernel pages"
92315 + 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))
92316 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92317 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92318 + select PAX_KERNEXEC_PLUGIN if X86_64
92319 + help
92320 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92321 + that is, enabling this option will make it harder to inject
92322 + and execute 'foreign' code in kernel memory itself.
92323 +
92324 +choice
92325 + prompt "Return Address Instrumentation Method"
92326 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92327 + depends on PAX_KERNEXEC_PLUGIN
92328 + help
92329 + Select the method used to instrument function pointer dereferences.
92330 + Note that binary modules cannot be instrumented by this approach.
92331 +
92332 + Note that the implementation requires a gcc with plugin support,
92333 + i.e., gcc 4.5 or newer. You may need to install the supporting
92334 + headers explicitly in addition to the normal gcc package.
92335 +
92336 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92337 + bool "bts"
92338 + help
92339 + This method is compatible with binary only modules but has
92340 + a higher runtime overhead.
92341 +
92342 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92343 + bool "or"
92344 + depends on !PARAVIRT
92345 + help
92346 + This method is incompatible with binary only modules but has
92347 + a lower runtime overhead.
92348 +endchoice
92349 +
92350 +config PAX_KERNEXEC_PLUGIN_METHOD
92351 + string
92352 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92353 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92354 + default ""
92355 +
92356 +config PAX_KERNEXEC_MODULE_TEXT
92357 + int "Minimum amount of memory reserved for module code"
92358 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92359 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92360 + depends on PAX_KERNEXEC && X86_32
92361 + help
92362 + Due to implementation details the kernel must reserve a fixed
92363 + amount of memory for runtime allocated code (such as modules)
92364 + at compile time that cannot be changed at runtime. Here you
92365 + can specify the minimum amount in MB that will be reserved.
92366 + Due to the same implementation details this size will always
92367 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
92368 + the actually available memory for runtime allocated code will
92369 + usually be more than this minimum.
92370 +
92371 + The default 4 MB should be enough for most users but if you have
92372 + an excessive number of modules (e.g., most distribution configs
92373 + compile many drivers as modules) or use huge modules such as
92374 + nvidia's kernel driver, you will need to adjust this amount.
92375 + A good rule of thumb is to look at your currently loaded kernel
92376 + modules and add up their sizes.
92377 +
92378 +endmenu
92379 +
92380 +menu "Address Space Layout Randomization"
92381 + depends on PAX
92382 +
92383 +config PAX_ASLR
92384 + bool "Address Space Layout Randomization"
92385 + default y if GRKERNSEC_CONFIG_AUTO
92386 + help
92387 + Many if not most exploit techniques rely on the knowledge of
92388 + certain addresses in the attacked program. The following options
92389 + will allow the kernel to apply a certain amount of randomization
92390 + to specific parts of the program thereby forcing an attacker to
92391 + guess them in most cases. Any failed guess will most likely crash
92392 + the attacked program which allows the kernel to detect such attempts
92393 + and react on them. PaX itself provides no reaction mechanisms,
92394 + instead it is strongly encouraged that you make use of Nergal's
92395 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92396 + (http://www.grsecurity.net/) built-in crash detection features or
92397 + develop one yourself.
92398 +
92399 + By saying Y here you can choose to randomize the following areas:
92400 + - top of the task's kernel stack
92401 + - top of the task's userland stack
92402 + - base address for mmap() requests that do not specify one
92403 + (this includes all libraries)
92404 + - base address of the main executable
92405 +
92406 + It is strongly recommended to say Y here as address space layout
92407 + randomization has negligible impact on performance yet it provides
92408 + a very effective protection.
92409 +
92410 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92411 + this feature on a per file basis.
92412 +
92413 +config PAX_RANDKSTACK
92414 + bool "Randomize kernel stack base"
92415 + default y if GRKERNSEC_CONFIG_AUTO
92416 + depends on X86_TSC && X86
92417 + help
92418 + By saying Y here the kernel will randomize every task's kernel
92419 + stack on every system call. This will not only force an attacker
92420 + to guess it but also prevent him from making use of possible
92421 + leaked information about it.
92422 +
92423 + Since the kernel stack is a rather scarce resource, randomization
92424 + may cause unexpected stack overflows, therefore you should very
92425 + carefully test your system. Note that once enabled in the kernel
92426 + configuration, this feature cannot be disabled on a per file basis.
92427 +
92428 +config PAX_RANDUSTACK
92429 + bool "Randomize user stack base"
92430 + default y if GRKERNSEC_CONFIG_AUTO
92431 + depends on PAX_ASLR
92432 + help
92433 + By saying Y here the kernel will randomize every task's userland
92434 + stack. The randomization is done in two steps where the second
92435 + one may apply a big amount of shift to the top of the stack and
92436 + cause problems for programs that want to use lots of memory (more
92437 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92438 + For this reason the second step can be controlled by 'chpax' or
92439 + 'paxctl' on a per file basis.
92440 +
92441 +config PAX_RANDMMAP
92442 + bool "Randomize mmap() base"
92443 + default y if GRKERNSEC_CONFIG_AUTO
92444 + depends on PAX_ASLR
92445 + help
92446 + By saying Y here the kernel will use a randomized base address for
92447 + mmap() requests that do not specify one themselves. As a result
92448 + all dynamically loaded libraries will appear at random addresses
92449 + and therefore be harder to exploit by a technique where an attacker
92450 + attempts to execute library code for his purposes (e.g. spawn a
92451 + shell from an exploited program that is running at an elevated
92452 + privilege level).
92453 +
92454 + Furthermore, if a program is relinked as a dynamic ELF file, its
92455 + base address will be randomized as well, completing the full
92456 + randomization of the address space layout. Attacking such programs
92457 + becomes a guess game. You can find an example of doing this at
92458 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92459 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92460 +
92461 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92462 + feature on a per file basis.
92463 +
92464 +endmenu
92465 +
92466 +menu "Miscellaneous hardening features"
92467 +
92468 +config PAX_MEMORY_SANITIZE
92469 + bool "Sanitize all freed memory"
92470 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92471 + depends on !HIBERNATION
92472 + help
92473 + By saying Y here the kernel will erase memory pages as soon as they
92474 + are freed. This in turn reduces the lifetime of data stored in the
92475 + pages, making it less likely that sensitive information such as
92476 + passwords, cryptographic secrets, etc stay in memory for too long.
92477 +
92478 + This is especially useful for programs whose runtime is short, long
92479 + lived processes and the kernel itself benefit from this as long as
92480 + they operate on whole memory pages and ensure timely freeing of pages
92481 + that may hold sensitive information.
92482 +
92483 + The tradeoff is performance impact, on a single CPU system kernel
92484 + compilation sees a 3% slowdown, other systems and workloads may vary
92485 + and you are advised to test this feature on your expected workload
92486 + before deploying it.
92487 +
92488 + Note that this feature does not protect data stored in live pages,
92489 + e.g., process memory swapped to disk may stay there for a long time.
92490 +
92491 +config PAX_MEMORY_STACKLEAK
92492 + bool "Sanitize kernel stack"
92493 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92494 + depends on X86
92495 + help
92496 + By saying Y here the kernel will erase the kernel stack before it
92497 + returns from a system call. This in turn reduces the information
92498 + that a kernel stack leak bug can reveal.
92499 +
92500 + Note that such a bug can still leak information that was put on
92501 + the stack by the current system call (the one eventually triggering
92502 + the bug) but traces of earlier system calls on the kernel stack
92503 + cannot leak anymore.
92504 +
92505 + The tradeoff is performance impact: on a single CPU system kernel
92506 + compilation sees a 1% slowdown, other systems and workloads may vary
92507 + and you are advised to test this feature on your expected workload
92508 + before deploying it.
92509 +
92510 + Note that the full feature requires a gcc with plugin support,
92511 + i.e., gcc 4.5 or newer. You may need to install the supporting
92512 + headers explicitly in addition to the normal gcc package. Using
92513 + older gcc versions means that functions with large enough stack
92514 + frames may leave uninitialized memory behind that may be exposed
92515 + to a later syscall leaking the stack.
92516 +
92517 +config PAX_MEMORY_STRUCTLEAK
92518 + bool "Forcibly initialize local variables copied to userland"
92519 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92520 + help
92521 + By saying Y here the kernel will zero initialize some local
92522 + variables that are going to be copied to userland. This in
92523 + turn prevents unintended information leakage from the kernel
92524 + stack should later code forget to explicitly set all parts of
92525 + the copied variable.
92526 +
92527 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92528 + at a much smaller coverage.
92529 +
92530 + Note that the implementation requires a gcc with plugin support,
92531 + i.e., gcc 4.5 or newer. You may need to install the supporting
92532 + headers explicitly in addition to the normal gcc package.
92533 +
92534 +config PAX_MEMORY_UDEREF
92535 + bool "Prevent invalid userland pointer dereference"
92536 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92537 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92538 + select PAX_PER_CPU_PGD if X86_64
92539 + help
92540 + By saying Y here the kernel will be prevented from dereferencing
92541 + userland pointers in contexts where the kernel expects only kernel
92542 + pointers. This is both a useful runtime debugging feature and a
92543 + security measure that prevents exploiting a class of kernel bugs.
92544 +
92545 + The tradeoff is that some virtualization solutions may experience
92546 + a huge slowdown and therefore you should not enable this feature
92547 + for kernels meant to run in such environments. Whether a given VM
92548 + solution is affected or not is best determined by simply trying it
92549 + out, the performance impact will be obvious right on boot as this
92550 + mechanism engages from very early on. A good rule of thumb is that
92551 + VMs running on CPUs without hardware virtualization support (i.e.,
92552 + the majority of IA-32 CPUs) will likely experience the slowdown.
92553 +
92554 +config PAX_REFCOUNT
92555 + bool "Prevent various kernel object reference counter overflows"
92556 + default y if GRKERNSEC_CONFIG_AUTO
92557 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92558 + help
92559 + By saying Y here the kernel will detect and prevent overflowing
92560 + various (but not all) kinds of object reference counters. Such
92561 + overflows can normally occur due to bugs only and are often, if
92562 + not always, exploitable.
92563 +
92564 + The tradeoff is that data structures protected by an overflowed
92565 + refcount will never be freed and therefore will leak memory. Note
92566 + that this leak also happens even without this protection but in
92567 + that case the overflow can eventually trigger the freeing of the
92568 + data structure while it is still being used elsewhere, resulting
92569 + in the exploitable situation that this feature prevents.
92570 +
92571 + Since this has a negligible performance impact, you should enable
92572 + this feature.
92573 +
92574 +config PAX_CONSTIFY_PLUGIN
92575 + bool "Automatically constify eligible structures"
92576 + default y
92577 + depends on !UML && PAX_KERNEXEC
92578 + help
92579 + By saying Y here the compiler will automatically constify a class
92580 + of types that contain only function pointers. This reduces the
92581 + kernel's attack surface and also produces a better memory layout.
92582 +
92583 + Note that the implementation requires a gcc with plugin support,
92584 + i.e., gcc 4.5 or newer. You may need to install the supporting
92585 + headers explicitly in addition to the normal gcc package.
92586 +
92587 + Note that if some code really has to modify constified variables
92588 + then the source code will have to be patched to allow it. Examples
92589 + can be found in PaX itself (the no_const attribute) and for some
92590 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92591 +
92592 +config PAX_USERCOPY
92593 + bool "Harden heap object copies between kernel and userland"
92594 + default y if GRKERNSEC_CONFIG_AUTO
92595 + depends on ARM || IA64 || PPC || SPARC || X86
92596 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92597 + select PAX_USERCOPY_SLABS
92598 + help
92599 + By saying Y here the kernel will enforce the size of heap objects
92600 + when they are copied in either direction between the kernel and
92601 + userland, even if only a part of the heap object is copied.
92602 +
92603 + Specifically, this checking prevents information leaking from the
92604 + kernel heap during kernel to userland copies (if the kernel heap
92605 + object is otherwise fully initialized) and prevents kernel heap
92606 + overflows during userland to kernel copies.
92607 +
92608 + Note that the current implementation provides the strictest bounds
92609 + checks for the SLUB allocator.
92610 +
92611 + Enabling this option also enables per-slab cache protection against
92612 + data in a given cache being copied into/out of via userland
92613 + accessors. Though the whitelist of regions will be reduced over
92614 + time, it notably protects important data structures like task structs.
92615 +
92616 + If frame pointers are enabled on x86, this option will also restrict
92617 + copies into and out of the kernel stack to local variables within a
92618 + single frame.
92619 +
92620 + Since this has a negligible performance impact, you should enable
92621 + this feature.
92622 +
92623 +config PAX_USERCOPY_DEBUG
92624 + bool
92625 + depends on X86 && PAX_USERCOPY
92626 + default n
92627 +
92628 +config PAX_SIZE_OVERFLOW
92629 + bool "Prevent various integer overflows in function size parameters"
92630 + default y if GRKERNSEC_CONFIG_AUTO
92631 + depends on X86
92632 + help
92633 + By saying Y here the kernel recomputes expressions of function
92634 + arguments marked by a size_overflow attribute with double integer
92635 + precision (DImode/TImode for 32/64 bit integer types).
92636 +
92637 + The recomputed argument is checked against TYPE_MAX and an event
92638 + is logged on overflow and the triggering process is killed.
92639 +
92640 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92641 +
92642 + Note that the implementation requires a gcc with plugin support,
92643 + i.e., gcc 4.5 or newer. You may need to install the supporting
92644 + headers explicitly in addition to the normal gcc package.
92645 +
92646 +config PAX_LATENT_ENTROPY
92647 + bool "Generate some entropy during boot"
92648 + default y if GRKERNSEC_CONFIG_AUTO
92649 + help
92650 + By saying Y here the kernel will instrument early boot code to
92651 + extract some entropy from both original and artificially created
92652 + program state. This will help especially embedded systems where
92653 + there is little 'natural' source of entropy normally. The cost
92654 + is some slowdown of the boot process.
92655 +
92656 + When pax_extra_latent_entropy is passed on the kernel command line,
92657 + entropy will be extracted from up to the first 4GB of RAM while the
92658 + runtime memory allocator is being initialized. This costs even more
92659 + slowdown of the boot process.
92660 +
92661 + Note that the implementation requires a gcc with plugin support,
92662 + i.e., gcc 4.5 or newer. You may need to install the supporting
92663 + headers explicitly in addition to the normal gcc package.
92664 +
92665 + Note that entropy extracted this way is not cryptographically
92666 + secure!
92667 +
92668 +endmenu
92669 +
92670 +endmenu
92671 +
92672 +source grsecurity/Kconfig
92673 +
92674 +endmenu
92675 +
92676 +endmenu
92677 +
92678 source security/keys/Kconfig
92679
92680 config SECURITY_DMESG_RESTRICT
92681 @@ -103,7 +1042,7 @@ config INTEL_TXT
92682 config LSM_MMAP_MIN_ADDR
92683 int "Low address space for LSM to protect from user allocation"
92684 depends on SECURITY && SECURITY_SELINUX
92685 - default 32768 if ARM
92686 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92687 default 65536
92688 help
92689 This is the portion of low virtual memory which should be protected
92690 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
92691 index 9b9013b..51ebf96 100644
92692 --- a/security/apparmor/Kconfig
92693 +++ b/security/apparmor/Kconfig
92694 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
92695 boot.
92696
92697 If you are unsure how to answer this question, answer 1.
92698 +
92699 +config SECURITY_APPARMOR_COMPAT_24
92700 + bool "Enable AppArmor 2.4 compatability"
92701 + depends on SECURITY_APPARMOR
92702 + default y
92703 + help
92704 + This option enables compatability with AppArmor 2.4. It is
92705 + recommended if compatability with older versions of AppArmor
92706 + is desired.
92707 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
92708 index 16c15ec..42b7c9f 100644
92709 --- a/security/apparmor/apparmorfs.c
92710 +++ b/security/apparmor/apparmorfs.c
92711 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
92712 .release = single_release,
92713 };
92714
92715 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
92716 +/**
92717 + * __next_namespace - find the next namespace to list
92718 + * @root: root namespace to stop search at (NOT NULL)
92719 + * @ns: current ns position (NOT NULL)
92720 + *
92721 + * Find the next namespace from @ns under @root and handle all locking needed
92722 + * while switching current namespace.
92723 + *
92724 + * Returns: next namespace or NULL if at last namespace under @root
92725 + * NOTE: will not unlock root->lock
92726 + */
92727 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
92728 + struct aa_namespace *ns)
92729 +{
92730 + struct aa_namespace *parent;
92731 +
92732 + /* is next namespace a child */
92733 + if (!list_empty(&ns->sub_ns)) {
92734 + struct aa_namespace *next;
92735 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
92736 + read_lock(&next->lock);
92737 + return next;
92738 + }
92739 +
92740 + /* check if the next ns is a sibling, parent, gp, .. */
92741 + parent = ns->parent;
92742 + while (parent) {
92743 + read_unlock(&ns->lock);
92744 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
92745 + read_lock(&ns->lock);
92746 + return ns;
92747 + }
92748 + if (parent == root)
92749 + return NULL;
92750 + ns = parent;
92751 + parent = parent->parent;
92752 + }
92753 +
92754 + return NULL;
92755 +}
92756 +
92757 +/**
92758 + * __first_profile - find the first profile in a namespace
92759 + * @root: namespace that is root of profiles being displayed (NOT NULL)
92760 + * @ns: namespace to start in (NOT NULL)
92761 + *
92762 + * Returns: unrefcounted profile or NULL if no profile
92763 + */
92764 +static struct aa_profile *__first_profile(struct aa_namespace *root,
92765 + struct aa_namespace *ns)
92766 +{
92767 + for ( ; ns; ns = __next_namespace(root, ns)) {
92768 + if (!list_empty(&ns->base.profiles))
92769 + return list_first_entry(&ns->base.profiles,
92770 + struct aa_profile, base.list);
92771 + }
92772 + return NULL;
92773 +}
92774 +
92775 +/**
92776 + * __next_profile - step to the next profile in a profile tree
92777 + * @profile: current profile in tree (NOT NULL)
92778 + *
92779 + * Perform a depth first taversal on the profile tree in a namespace
92780 + *
92781 + * Returns: next profile or NULL if done
92782 + * Requires: profile->ns.lock to be held
92783 + */
92784 +static struct aa_profile *__next_profile(struct aa_profile *p)
92785 +{
92786 + struct aa_profile *parent;
92787 + struct aa_namespace *ns = p->ns;
92788 +
92789 + /* is next profile a child */
92790 + if (!list_empty(&p->base.profiles))
92791 + return list_first_entry(&p->base.profiles, typeof(*p),
92792 + base.list);
92793 +
92794 + /* is next profile a sibling, parent sibling, gp, subling, .. */
92795 + parent = p->parent;
92796 + while (parent) {
92797 + list_for_each_entry_continue(p, &parent->base.profiles,
92798 + base.list)
92799 + return p;
92800 + p = parent;
92801 + parent = parent->parent;
92802 + }
92803 +
92804 + /* is next another profile in the namespace */
92805 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
92806 + return p;
92807 +
92808 + return NULL;
92809 +}
92810 +
92811 +/**
92812 + * next_profile - step to the next profile in where ever it may be
92813 + * @root: root namespace (NOT NULL)
92814 + * @profile: current profile (NOT NULL)
92815 + *
92816 + * Returns: next profile or NULL if there isn't one
92817 + */
92818 +static struct aa_profile *next_profile(struct aa_namespace *root,
92819 + struct aa_profile *profile)
92820 +{
92821 + struct aa_profile *next = __next_profile(profile);
92822 + if (next)
92823 + return next;
92824 +
92825 + /* finished all profiles in namespace move to next namespace */
92826 + return __first_profile(root, __next_namespace(root, profile->ns));
92827 +}
92828 +
92829 +/**
92830 + * p_start - start a depth first traversal of profile tree
92831 + * @f: seq_file to fill
92832 + * @pos: current position
92833 + *
92834 + * Returns: first profile under current namespace or NULL if none found
92835 + *
92836 + * acquires first ns->lock
92837 + */
92838 +static void *p_start(struct seq_file *f, loff_t *pos)
92839 + __acquires(root->lock)
92840 +{
92841 + struct aa_profile *profile = NULL;
92842 + struct aa_namespace *root = aa_current_profile()->ns;
92843 + loff_t l = *pos;
92844 + f->private = aa_get_namespace(root);
92845 +
92846 +
92847 + /* find the first profile */
92848 + read_lock(&root->lock);
92849 + profile = __first_profile(root, root);
92850 +
92851 + /* skip to position */
92852 + for (; profile && l > 0; l--)
92853 + profile = next_profile(root, profile);
92854 +
92855 + return profile;
92856 +}
92857 +
92858 +/**
92859 + * p_next - read the next profile entry
92860 + * @f: seq_file to fill
92861 + * @p: profile previously returned
92862 + * @pos: current position
92863 + *
92864 + * Returns: next profile after @p or NULL if none
92865 + *
92866 + * may acquire/release locks in namespace tree as necessary
92867 + */
92868 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
92869 +{
92870 + struct aa_profile *profile = p;
92871 + struct aa_namespace *root = f->private;
92872 + (*pos)++;
92873 +
92874 + return next_profile(root, profile);
92875 +}
92876 +
92877 +/**
92878 + * p_stop - stop depth first traversal
92879 + * @f: seq_file we are filling
92880 + * @p: the last profile writen
92881 + *
92882 + * Release all locking done by p_start/p_next on namespace tree
92883 + */
92884 +static void p_stop(struct seq_file *f, void *p)
92885 + __releases(root->lock)
92886 +{
92887 + struct aa_profile *profile = p;
92888 + struct aa_namespace *root = f->private, *ns;
92889 +
92890 + if (profile) {
92891 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
92892 + read_unlock(&ns->lock);
92893 + }
92894 + read_unlock(&root->lock);
92895 + aa_put_namespace(root);
92896 +}
92897 +
92898 +/**
92899 + * seq_show_profile - show a profile entry
92900 + * @f: seq_file to file
92901 + * @p: current position (profile) (NOT NULL)
92902 + *
92903 + * Returns: error on failure
92904 + */
92905 +static int seq_show_profile(struct seq_file *f, void *p)
92906 +{
92907 + struct aa_profile *profile = (struct aa_profile *)p;
92908 + struct aa_namespace *root = f->private;
92909 +
92910 + if (profile->ns != root)
92911 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
92912 + seq_printf(f, "%s (%s)\n", profile->base.hname,
92913 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
92914 +
92915 + return 0;
92916 +}
92917 +
92918 +static const struct seq_operations aa_fs_profiles_op = {
92919 + .start = p_start,
92920 + .next = p_next,
92921 + .stop = p_stop,
92922 + .show = seq_show_profile,
92923 +};
92924 +
92925 +static int profiles_open(struct inode *inode, struct file *file)
92926 +{
92927 + return seq_open(file, &aa_fs_profiles_op);
92928 +}
92929 +
92930 +static int profiles_release(struct inode *inode, struct file *file)
92931 +{
92932 + return seq_release(inode, file);
92933 +}
92934 +
92935 +const struct file_operations aa_fs_profiles_fops = {
92936 + .open = profiles_open,
92937 + .read = seq_read,
92938 + .llseek = seq_lseek,
92939 + .release = profiles_release,
92940 +};
92941 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
92942 +
92943 /** Base file system setup **/
92944
92945 static struct aa_fs_entry aa_fs_entry_file[] = {
92946 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
92947 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
92948 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
92949 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
92950 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
92951 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
92952 +#endif
92953 AA_FS_DIR("features", aa_fs_entry_features),
92954 { }
92955 };
92956 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92957 index b21830e..a7d1a17 100644
92958 --- a/security/apparmor/lsm.c
92959 +++ b/security/apparmor/lsm.c
92960 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92961 return error;
92962 }
92963
92964 -static struct security_operations apparmor_ops = {
92965 +static struct security_operations apparmor_ops __read_only = {
92966 .name = "apparmor",
92967
92968 .ptrace_access_check = apparmor_ptrace_access_check,
92969 diff --git a/security/commoncap.c b/security/commoncap.c
92970 index c44b6fe..932df30 100644
92971 --- a/security/commoncap.c
92972 +++ b/security/commoncap.c
92973 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92974 return 0;
92975 }
92976
92977 +/* returns:
92978 + 1 for suid privilege
92979 + 2 for sgid privilege
92980 + 3 for fscap privilege
92981 +*/
92982 +int is_privileged_binary(const struct dentry *dentry)
92983 +{
92984 + struct cpu_vfs_cap_data capdata;
92985 + struct inode *inode = dentry->d_inode;
92986 +
92987 + if (!inode || S_ISDIR(inode->i_mode))
92988 + return 0;
92989 +
92990 + if (inode->i_mode & S_ISUID)
92991 + return 1;
92992 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92993 + return 2;
92994 +
92995 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92996 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92997 + return 3;
92998 + }
92999 +
93000 + return 0;
93001 +}
93002 +
93003 /*
93004 * Attempt to get the on-exec apply capability sets for an executable file from
93005 * its xattrs and, if present, apply them to the proposed credentials being
93006 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
93007 const struct cred *cred = current_cred();
93008 kuid_t root_uid = make_kuid(cred->user_ns, 0);
93009
93010 + if (gr_acl_enable_at_secure())
93011 + return 1;
93012 +
93013 if (!uid_eq(cred->uid, root_uid)) {
93014 if (bprm->cap_effective)
93015 return 1;
93016 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
93017 index a41c9c1..83da6dd 100644
93018 --- a/security/integrity/ima/ima.h
93019 +++ b/security/integrity/ima/ima.h
93020 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
93021 extern spinlock_t ima_queue_lock;
93022
93023 struct ima_h_table {
93024 - atomic_long_t len; /* number of stored measurements in the list */
93025 - atomic_long_t violations;
93026 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
93027 + atomic_long_unchecked_t violations;
93028 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
93029 };
93030 extern struct ima_h_table ima_htable;
93031 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
93032 index 1c03e8f1..398a941 100644
93033 --- a/security/integrity/ima/ima_api.c
93034 +++ b/security/integrity/ima/ima_api.c
93035 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
93036 int result;
93037
93038 /* can overflow, only indicator */
93039 - atomic_long_inc(&ima_htable.violations);
93040 + atomic_long_inc_unchecked(&ima_htable.violations);
93041
93042 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
93043 if (!entry) {
93044 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
93045 index 38477c9..87a60c7 100644
93046 --- a/security/integrity/ima/ima_fs.c
93047 +++ b/security/integrity/ima/ima_fs.c
93048 @@ -28,12 +28,12 @@
93049 static int valid_policy = 1;
93050 #define TMPBUFLEN 12
93051 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
93052 - loff_t *ppos, atomic_long_t *val)
93053 + loff_t *ppos, atomic_long_unchecked_t *val)
93054 {
93055 char tmpbuf[TMPBUFLEN];
93056 ssize_t len;
93057
93058 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
93059 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
93060 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
93061 }
93062
93063 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
93064 index ff63fe0..809cd96 100644
93065 --- a/security/integrity/ima/ima_queue.c
93066 +++ b/security/integrity/ima/ima_queue.c
93067 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
93068 INIT_LIST_HEAD(&qe->later);
93069 list_add_tail_rcu(&qe->later, &ima_measurements);
93070
93071 - atomic_long_inc(&ima_htable.len);
93072 + atomic_long_inc_unchecked(&ima_htable.len);
93073 key = ima_hash_key(entry->digest);
93074 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
93075 return 0;
93076 diff --git a/security/keys/compat.c b/security/keys/compat.c
93077 index d65fa7f..cbfe366 100644
93078 --- a/security/keys/compat.c
93079 +++ b/security/keys/compat.c
93080 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
93081 if (ret == 0)
93082 goto no_payload_free;
93083
93084 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93085 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93086 err:
93087 if (iov != iovstack)
93088 kfree(iov);
93089 diff --git a/security/keys/internal.h b/security/keys/internal.h
93090 index 8bbefc3..299d03f 100644
93091 --- a/security/keys/internal.h
93092 +++ b/security/keys/internal.h
93093 @@ -240,7 +240,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
93094 extern long keyctl_invalidate_key(key_serial_t);
93095
93096 extern long keyctl_instantiate_key_common(key_serial_t,
93097 - const struct iovec *,
93098 + const struct iovec __user *,
93099 unsigned, size_t, key_serial_t);
93100
93101 /*
93102 diff --git a/security/keys/key.c b/security/keys/key.c
93103 index 8fb7c7b..ba3610d 100644
93104 --- a/security/keys/key.c
93105 +++ b/security/keys/key.c
93106 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
93107
93108 atomic_set(&key->usage, 1);
93109 init_rwsem(&key->sem);
93110 - lockdep_set_class(&key->sem, &type->lock_class);
93111 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
93112 key->type = type;
93113 key->user = user;
93114 key->quotalen = quotalen;
93115 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
93116 struct key_type *p;
93117 int ret;
93118
93119 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
93120 + pax_open_kernel();
93121 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
93122 + pax_close_kernel();
93123
93124 ret = -EEXIST;
93125 down_write(&key_types_sem);
93126 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
93127 }
93128
93129 /* store the type */
93130 - list_add(&ktype->link, &key_types_list);
93131 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
93132
93133 pr_notice("Key type %s registered\n", ktype->name);
93134 ret = 0;
93135 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
93136 void unregister_key_type(struct key_type *ktype)
93137 {
93138 down_write(&key_types_sem);
93139 - list_del_init(&ktype->link);
93140 + pax_list_del_init((struct list_head *)&ktype->link);
93141 downgrade_write(&key_types_sem);
93142 key_gc_keytype(ktype);
93143 pr_notice("Key type %s unregistered\n", ktype->name);
93144 @@ -1084,10 +1086,10 @@ void __init key_init(void)
93145 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
93146
93147 /* add the special key types */
93148 - list_add_tail(&key_type_keyring.link, &key_types_list);
93149 - list_add_tail(&key_type_dead.link, &key_types_list);
93150 - list_add_tail(&key_type_user.link, &key_types_list);
93151 - list_add_tail(&key_type_logon.link, &key_types_list);
93152 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
93153 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
93154 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
93155 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
93156
93157 /* record the root user tracking */
93158 rb_link_node(&root_key_user.node,
93159 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
93160 index 4b5c948..2054dc1 100644
93161 --- a/security/keys/keyctl.c
93162 +++ b/security/keys/keyctl.c
93163 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
93164 /*
93165 * Copy the iovec data from userspace
93166 */
93167 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93168 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
93169 unsigned ioc)
93170 {
93171 for (; ioc > 0; ioc--) {
93172 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93173 * If successful, 0 will be returned.
93174 */
93175 long keyctl_instantiate_key_common(key_serial_t id,
93176 - const struct iovec *payload_iov,
93177 + const struct iovec __user *payload_iov,
93178 unsigned ioc,
93179 size_t plen,
93180 key_serial_t ringid)
93181 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
93182 [0].iov_len = plen
93183 };
93184
93185 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
93186 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
93187 }
93188
93189 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
93190 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
93191 if (ret == 0)
93192 goto no_payload_free;
93193
93194 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93195 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93196 err:
93197 if (iov != iovstack)
93198 kfree(iov);
93199 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
93200 index 6ece7f2..ecdb55c 100644
93201 --- a/security/keys/keyring.c
93202 +++ b/security/keys/keyring.c
93203 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
93204 ret = -EFAULT;
93205
93206 for (loop = 0; loop < klist->nkeys; loop++) {
93207 + key_serial_t serial;
93208 key = rcu_deref_link_locked(klist, loop,
93209 keyring);
93210 + serial = key->serial;
93211
93212 tmp = sizeof(key_serial_t);
93213 if (tmp > buflen)
93214 tmp = buflen;
93215
93216 - if (copy_to_user(buffer,
93217 - &key->serial,
93218 - tmp) != 0)
93219 + if (copy_to_user(buffer, &serial, tmp))
93220 goto error;
93221
93222 buflen -= tmp;
93223 diff --git a/security/min_addr.c b/security/min_addr.c
93224 index f728728..6457a0c 100644
93225 --- a/security/min_addr.c
93226 +++ b/security/min_addr.c
93227 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
93228 */
93229 static void update_mmap_min_addr(void)
93230 {
93231 +#ifndef SPARC
93232 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
93233 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
93234 mmap_min_addr = dac_mmap_min_addr;
93235 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
93236 #else
93237 mmap_min_addr = dac_mmap_min_addr;
93238 #endif
93239 +#endif
93240 }
93241
93242 /*
93243 diff --git a/security/security.c b/security/security.c
93244 index 03f248b..5710c33 100644
93245 --- a/security/security.c
93246 +++ b/security/security.c
93247 @@ -20,6 +20,7 @@
93248 #include <linux/ima.h>
93249 #include <linux/evm.h>
93250 #include <linux/fsnotify.h>
93251 +#include <linux/mm.h>
93252 #include <linux/mman.h>
93253 #include <linux/mount.h>
93254 #include <linux/personality.h>
93255 @@ -32,8 +33,8 @@
93256 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
93257 CONFIG_DEFAULT_SECURITY;
93258
93259 -static struct security_operations *security_ops;
93260 -static struct security_operations default_security_ops = {
93261 +static struct security_operations *security_ops __read_only;
93262 +static struct security_operations default_security_ops __read_only = {
93263 .name = "default",
93264 };
93265
93266 @@ -74,7 +75,9 @@ int __init security_init(void)
93267
93268 void reset_security_ops(void)
93269 {
93270 + pax_open_kernel();
93271 security_ops = &default_security_ops;
93272 + pax_close_kernel();
93273 }
93274
93275 /* Save user chosen LSM */
93276 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
93277 index 7171a95..c35e879 100644
93278 --- a/security/selinux/hooks.c
93279 +++ b/security/selinux/hooks.c
93280 @@ -96,8 +96,6 @@
93281
93282 #define NUM_SEL_MNT_OPTS 5
93283
93284 -extern struct security_operations *security_ops;
93285 -
93286 /* SECMARK reference count */
93287 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
93288
93289 @@ -5498,7 +5496,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
93290
93291 #endif
93292
93293 -static struct security_operations selinux_ops = {
93294 +static struct security_operations selinux_ops __read_only = {
93295 .name = "selinux",
93296
93297 .ptrace_access_check = selinux_ptrace_access_check,
93298 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
93299 index 65f67cb..3f141ef 100644
93300 --- a/security/selinux/include/xfrm.h
93301 +++ b/security/selinux/include/xfrm.h
93302 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
93303
93304 static inline void selinux_xfrm_notify_policyload(void)
93305 {
93306 - atomic_inc(&flow_cache_genid);
93307 + atomic_inc_unchecked(&flow_cache_genid);
93308 rt_genid_bump(&init_net);
93309 }
93310 #else
93311 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
93312 index fa64740..bc95b74 100644
93313 --- a/security/smack/smack_lsm.c
93314 +++ b/security/smack/smack_lsm.c
93315 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
93316 return 0;
93317 }
93318
93319 -struct security_operations smack_ops = {
93320 +struct security_operations smack_ops __read_only = {
93321 .name = "smack",
93322
93323 .ptrace_access_check = smack_ptrace_access_check,
93324 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
93325 index 390c646..f2f8db3 100644
93326 --- a/security/tomoyo/mount.c
93327 +++ b/security/tomoyo/mount.c
93328 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
93329 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
93330 need_dev = -1; /* dev_name is a directory */
93331 } else {
93332 + if (!capable(CAP_SYS_ADMIN)) {
93333 + error = -EPERM;
93334 + goto out;
93335 + }
93336 fstype = get_fs_type(type);
93337 if (!fstype) {
93338 error = -ENODEV;
93339 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
93340 index a2ee362..5754f34 100644
93341 --- a/security/tomoyo/tomoyo.c
93342 +++ b/security/tomoyo/tomoyo.c
93343 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
93344 * tomoyo_security_ops is a "struct security_operations" which is used for
93345 * registering TOMOYO.
93346 */
93347 -static struct security_operations tomoyo_security_ops = {
93348 +static struct security_operations tomoyo_security_ops __read_only = {
93349 .name = "tomoyo",
93350 .cred_alloc_blank = tomoyo_cred_alloc_blank,
93351 .cred_prepare = tomoyo_cred_prepare,
93352 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
93353 index 20ef514..4182bed 100644
93354 --- a/security/yama/Kconfig
93355 +++ b/security/yama/Kconfig
93356 @@ -1,6 +1,6 @@
93357 config SECURITY_YAMA
93358 bool "Yama support"
93359 - depends on SECURITY
93360 + depends on SECURITY && !GRKERNSEC
93361 select SECURITYFS
93362 select SECURITY_PATH
93363 default n
93364 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
93365 index 13c88fbc..f8c115e 100644
93366 --- a/security/yama/yama_lsm.c
93367 +++ b/security/yama/yama_lsm.c
93368 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
93369 }
93370
93371 #ifndef CONFIG_SECURITY_YAMA_STACKED
93372 -static struct security_operations yama_ops = {
93373 +static struct security_operations yama_ops __read_only = {
93374 .name = "yama",
93375
93376 .ptrace_access_check = yama_ptrace_access_check,
93377 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
93378 #endif
93379
93380 #ifdef CONFIG_SYSCTL
93381 +static int zero __read_only;
93382 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
93383 +
93384 static int yama_dointvec_minmax(struct ctl_table *table, int write,
93385 void __user *buffer, size_t *lenp, loff_t *ppos)
93386 {
93387 - int rc;
93388 + ctl_table_no_const yama_table;
93389
93390 if (write && !capable(CAP_SYS_PTRACE))
93391 return -EPERM;
93392
93393 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
93394 - if (rc)
93395 - return rc;
93396 -
93397 + yama_table = *table;
93398 /* Lock the max value if it ever gets set. */
93399 - if (write && *(int *)table->data == *(int *)table->extra2)
93400 - table->extra1 = table->extra2;
93401 -
93402 - return rc;
93403 + if (ptrace_scope == max_scope)
93404 + yama_table.extra1 = &max_scope;
93405 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
93406 }
93407
93408 -static int zero;
93409 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
93410 -
93411 struct ctl_path yama_sysctl_path[] = {
93412 { .procname = "kernel", },
93413 { .procname = "yama", },
93414 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
93415 index 4cedc69..e59d8a3 100644
93416 --- a/sound/aoa/codecs/onyx.c
93417 +++ b/sound/aoa/codecs/onyx.c
93418 @@ -54,7 +54,7 @@ struct onyx {
93419 spdif_locked:1,
93420 analog_locked:1,
93421 original_mute:2;
93422 - int open_count;
93423 + local_t open_count;
93424 struct codec_info *codec_info;
93425
93426 /* mutex serializes concurrent access to the device
93427 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
93428 struct onyx *onyx = cii->codec_data;
93429
93430 mutex_lock(&onyx->mutex);
93431 - onyx->open_count++;
93432 + local_inc(&onyx->open_count);
93433 mutex_unlock(&onyx->mutex);
93434
93435 return 0;
93436 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
93437 struct onyx *onyx = cii->codec_data;
93438
93439 mutex_lock(&onyx->mutex);
93440 - onyx->open_count--;
93441 - if (!onyx->open_count)
93442 + if (local_dec_and_test(&onyx->open_count))
93443 onyx->spdif_locked = onyx->analog_locked = 0;
93444 mutex_unlock(&onyx->mutex);
93445
93446 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
93447 index ffd2025..df062c9 100644
93448 --- a/sound/aoa/codecs/onyx.h
93449 +++ b/sound/aoa/codecs/onyx.h
93450 @@ -11,6 +11,7 @@
93451 #include <linux/i2c.h>
93452 #include <asm/pmac_low_i2c.h>
93453 #include <asm/prom.h>
93454 +#include <asm/local.h>
93455
93456 /* PCM3052 register definitions */
93457
93458 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
93459 index 4c1cc51..16040040 100644
93460 --- a/sound/core/oss/pcm_oss.c
93461 +++ b/sound/core/oss/pcm_oss.c
93462 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
93463 if (in_kernel) {
93464 mm_segment_t fs;
93465 fs = snd_enter_user();
93466 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93467 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93468 snd_leave_user(fs);
93469 } else {
93470 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93471 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93472 }
93473 if (ret != -EPIPE && ret != -ESTRPIPE)
93474 break;
93475 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
93476 if (in_kernel) {
93477 mm_segment_t fs;
93478 fs = snd_enter_user();
93479 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93480 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93481 snd_leave_user(fs);
93482 } else {
93483 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93484 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93485 }
93486 if (ret == -EPIPE) {
93487 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
93488 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
93489 struct snd_pcm_plugin_channel *channels;
93490 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
93491 if (!in_kernel) {
93492 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
93493 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
93494 return -EFAULT;
93495 buf = runtime->oss.buffer;
93496 }
93497 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
93498 }
93499 } else {
93500 tmp = snd_pcm_oss_write2(substream,
93501 - (const char __force *)buf,
93502 + (const char __force_kernel *)buf,
93503 runtime->oss.period_bytes, 0);
93504 if (tmp <= 0)
93505 goto err;
93506 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
93507 struct snd_pcm_runtime *runtime = substream->runtime;
93508 snd_pcm_sframes_t frames, frames1;
93509 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
93510 - char __user *final_dst = (char __force __user *)buf;
93511 + char __user *final_dst = (char __force_user *)buf;
93512 if (runtime->oss.plugin_first) {
93513 struct snd_pcm_plugin_channel *channels;
93514 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
93515 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
93516 xfer += tmp;
93517 runtime->oss.buffer_used -= tmp;
93518 } else {
93519 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
93520 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
93521 runtime->oss.period_bytes, 0);
93522 if (tmp <= 0)
93523 goto err;
93524 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
93525 size1);
93526 size1 /= runtime->channels; /* frames */
93527 fs = snd_enter_user();
93528 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
93529 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
93530 snd_leave_user(fs);
93531 }
93532 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
93533 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
93534 index af49721..e85058e 100644
93535 --- a/sound/core/pcm_compat.c
93536 +++ b/sound/core/pcm_compat.c
93537 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
93538 int err;
93539
93540 fs = snd_enter_user();
93541 - err = snd_pcm_delay(substream, &delay);
93542 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
93543 snd_leave_user(fs);
93544 if (err < 0)
93545 return err;
93546 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
93547 index eb560fa..69a4995 100644
93548 --- a/sound/core/pcm_native.c
93549 +++ b/sound/core/pcm_native.c
93550 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
93551 switch (substream->stream) {
93552 case SNDRV_PCM_STREAM_PLAYBACK:
93553 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
93554 - (void __user *)arg);
93555 + (void __force_user *)arg);
93556 break;
93557 case SNDRV_PCM_STREAM_CAPTURE:
93558 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
93559 - (void __user *)arg);
93560 + (void __force_user *)arg);
93561 break;
93562 default:
93563 result = -EINVAL;
93564 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
93565 index 040c60e..989a19a 100644
93566 --- a/sound/core/seq/seq_device.c
93567 +++ b/sound/core/seq/seq_device.c
93568 @@ -64,7 +64,7 @@ struct ops_list {
93569 int argsize; /* argument size */
93570
93571 /* operators */
93572 - struct snd_seq_dev_ops ops;
93573 + struct snd_seq_dev_ops *ops;
93574
93575 /* registered devices */
93576 struct list_head dev_list; /* list of devices */
93577 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
93578
93579 mutex_lock(&ops->reg_mutex);
93580 /* copy driver operators */
93581 - ops->ops = *entry;
93582 + ops->ops = entry;
93583 ops->driver |= DRIVER_LOADED;
93584 ops->argsize = argsize;
93585
93586 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
93587 dev->name, ops->id, ops->argsize, dev->argsize);
93588 return -EINVAL;
93589 }
93590 - if (ops->ops.init_device(dev) >= 0) {
93591 + if (ops->ops->init_device(dev) >= 0) {
93592 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
93593 ops->num_init_devices++;
93594 } else {
93595 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
93596 dev->name, ops->id, ops->argsize, dev->argsize);
93597 return -EINVAL;
93598 }
93599 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
93600 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
93601 dev->status = SNDRV_SEQ_DEVICE_FREE;
93602 dev->driver_data = NULL;
93603 ops->num_init_devices--;
93604 diff --git a/sound/core/sound.c b/sound/core/sound.c
93605 index 70ccdab..50f2e10 100644
93606 --- a/sound/core/sound.c
93607 +++ b/sound/core/sound.c
93608 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
93609 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
93610 default: return;
93611 }
93612 - request_module(str);
93613 + request_module("%s", str);
93614 }
93615
93616 #endif /* modular kernel */
93617 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
93618 index 4e0dd22..7a1f32c 100644
93619 --- a/sound/drivers/mts64.c
93620 +++ b/sound/drivers/mts64.c
93621 @@ -29,6 +29,7 @@
93622 #include <sound/initval.h>
93623 #include <sound/rawmidi.h>
93624 #include <sound/control.h>
93625 +#include <asm/local.h>
93626
93627 #define CARD_NAME "Miditerminal 4140"
93628 #define DRIVER_NAME "MTS64"
93629 @@ -67,7 +68,7 @@ struct mts64 {
93630 struct pardevice *pardev;
93631 int pardev_claimed;
93632
93633 - int open_count;
93634 + local_t open_count;
93635 int current_midi_output_port;
93636 int current_midi_input_port;
93637 u8 mode[MTS64_NUM_INPUT_PORTS];
93638 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93639 {
93640 struct mts64 *mts = substream->rmidi->private_data;
93641
93642 - if (mts->open_count == 0) {
93643 + if (local_read(&mts->open_count) == 0) {
93644 /* We don't need a spinlock here, because this is just called
93645 if the device has not been opened before.
93646 So there aren't any IRQs from the device */
93647 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93648
93649 msleep(50);
93650 }
93651 - ++(mts->open_count);
93652 + local_inc(&mts->open_count);
93653
93654 return 0;
93655 }
93656 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93657 struct mts64 *mts = substream->rmidi->private_data;
93658 unsigned long flags;
93659
93660 - --(mts->open_count);
93661 - if (mts->open_count == 0) {
93662 + if (local_dec_return(&mts->open_count) == 0) {
93663 /* We need the spinlock_irqsave here because we can still
93664 have IRQs at this point */
93665 spin_lock_irqsave(&mts->lock, flags);
93666 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93667
93668 msleep(500);
93669
93670 - } else if (mts->open_count < 0)
93671 - mts->open_count = 0;
93672 + } else if (local_read(&mts->open_count) < 0)
93673 + local_set(&mts->open_count, 0);
93674
93675 return 0;
93676 }
93677 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93678 index b953fb4..1999c01 100644
93679 --- a/sound/drivers/opl4/opl4_lib.c
93680 +++ b/sound/drivers/opl4/opl4_lib.c
93681 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93682 MODULE_DESCRIPTION("OPL4 driver");
93683 MODULE_LICENSE("GPL");
93684
93685 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93686 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93687 {
93688 int timeout = 10;
93689 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93690 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93691 index 991018d..8984740 100644
93692 --- a/sound/drivers/portman2x4.c
93693 +++ b/sound/drivers/portman2x4.c
93694 @@ -48,6 +48,7 @@
93695 #include <sound/initval.h>
93696 #include <sound/rawmidi.h>
93697 #include <sound/control.h>
93698 +#include <asm/local.h>
93699
93700 #define CARD_NAME "Portman 2x4"
93701 #define DRIVER_NAME "portman"
93702 @@ -85,7 +86,7 @@ struct portman {
93703 struct pardevice *pardev;
93704 int pardev_claimed;
93705
93706 - int open_count;
93707 + local_t open_count;
93708 int mode[PORTMAN_NUM_INPUT_PORTS];
93709 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93710 };
93711 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93712 index ea995af..f1bfa37 100644
93713 --- a/sound/firewire/amdtp.c
93714 +++ b/sound/firewire/amdtp.c
93715 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93716 ptr = s->pcm_buffer_pointer + data_blocks;
93717 if (ptr >= pcm->runtime->buffer_size)
93718 ptr -= pcm->runtime->buffer_size;
93719 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93720 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93721
93722 s->pcm_period_pointer += data_blocks;
93723 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93724 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93725 */
93726 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93727 {
93728 - ACCESS_ONCE(s->source_node_id_field) =
93729 + ACCESS_ONCE_RW(s->source_node_id_field) =
93730 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93731 }
93732 EXPORT_SYMBOL(amdtp_out_stream_update);
93733 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93734 index b680c5e..061b7a0 100644
93735 --- a/sound/firewire/amdtp.h
93736 +++ b/sound/firewire/amdtp.h
93737 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93738 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93739 struct snd_pcm_substream *pcm)
93740 {
93741 - ACCESS_ONCE(s->pcm) = pcm;
93742 + ACCESS_ONCE_RW(s->pcm) = pcm;
93743 }
93744
93745 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93746 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93747 index d428ffe..751ef78 100644
93748 --- a/sound/firewire/isight.c
93749 +++ b/sound/firewire/isight.c
93750 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93751 ptr += count;
93752 if (ptr >= runtime->buffer_size)
93753 ptr -= runtime->buffer_size;
93754 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93755 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93756
93757 isight->period_counter += count;
93758 if (isight->period_counter >= runtime->period_size) {
93759 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93760 if (err < 0)
93761 return err;
93762
93763 - ACCESS_ONCE(isight->pcm_active) = true;
93764 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93765
93766 return 0;
93767 }
93768 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93769 {
93770 struct isight *isight = substream->private_data;
93771
93772 - ACCESS_ONCE(isight->pcm_active) = false;
93773 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93774
93775 mutex_lock(&isight->mutex);
93776 isight_stop_streaming(isight);
93777 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93778
93779 switch (cmd) {
93780 case SNDRV_PCM_TRIGGER_START:
93781 - ACCESS_ONCE(isight->pcm_running) = true;
93782 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93783 break;
93784 case SNDRV_PCM_TRIGGER_STOP:
93785 - ACCESS_ONCE(isight->pcm_running) = false;
93786 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93787 break;
93788 default:
93789 return -EINVAL;
93790 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93791 index 844a555..985ab83 100644
93792 --- a/sound/firewire/scs1x.c
93793 +++ b/sound/firewire/scs1x.c
93794 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93795 {
93796 struct scs *scs = stream->rmidi->private_data;
93797
93798 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93799 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93800 if (up) {
93801 scs->output_idle = false;
93802 tasklet_schedule(&scs->tasklet);
93803 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93804 {
93805 struct scs *scs = stream->rmidi->private_data;
93806
93807 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93808 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93809 }
93810
93811 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93812 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93813
93814 snd_card_disconnect(scs->card);
93815
93816 - ACCESS_ONCE(scs->output) = NULL;
93817 - ACCESS_ONCE(scs->input) = NULL;
93818 + ACCESS_ONCE_RW(scs->output) = NULL;
93819 + ACCESS_ONCE_RW(scs->input) = NULL;
93820
93821 wait_event(scs->idle_wait, scs->output_idle);
93822
93823 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93824 index 048439a..3be9f6f 100644
93825 --- a/sound/oss/sb_audio.c
93826 +++ b/sound/oss/sb_audio.c
93827 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93828 buf16 = (signed short *)(localbuf + localoffs);
93829 while (c)
93830 {
93831 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93832 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93833 if (copy_from_user(lbuf8,
93834 userbuf+useroffs + p,
93835 locallen))
93836 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93837 index 7d8803a..559f8d0 100644
93838 --- a/sound/oss/swarm_cs4297a.c
93839 +++ b/sound/oss/swarm_cs4297a.c
93840 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93841 {
93842 struct cs4297a_state *s;
93843 u32 pwr, id;
93844 - mm_segment_t fs;
93845 int rval;
93846 #ifndef CONFIG_BCM_CS4297A_CSWARM
93847 u64 cfg;
93848 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93849 if (!rval) {
93850 char *sb1250_duart_present;
93851
93852 +#if 0
93853 + mm_segment_t fs;
93854 fs = get_fs();
93855 set_fs(KERNEL_DS);
93856 -#if 0
93857 val = SOUND_MASK_LINE;
93858 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93859 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93860 val = initvol[i].vol;
93861 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93862 }
93863 + set_fs(fs);
93864 // cs4297a_write_ac97(s, 0x18, 0x0808);
93865 #else
93866 // cs4297a_write_ac97(s, 0x5e, 0x180);
93867 cs4297a_write_ac97(s, 0x02, 0x0808);
93868 cs4297a_write_ac97(s, 0x18, 0x0808);
93869 #endif
93870 - set_fs(fs);
93871
93872 list_add(&s->list, &cs4297a_devs);
93873
93874 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93875 index 4631a23..001ae57 100644
93876 --- a/sound/pci/ymfpci/ymfpci.h
93877 +++ b/sound/pci/ymfpci/ymfpci.h
93878 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93879 spinlock_t reg_lock;
93880 spinlock_t voice_lock;
93881 wait_queue_head_t interrupt_sleep;
93882 - atomic_t interrupt_sleep_count;
93883 + atomic_unchecked_t interrupt_sleep_count;
93884 struct snd_info_entry *proc_entry;
93885 const struct firmware *dsp_microcode;
93886 const struct firmware *controller_microcode;
93887 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93888 index 22056c5..25d3244 100644
93889 --- a/sound/pci/ymfpci/ymfpci_main.c
93890 +++ b/sound/pci/ymfpci/ymfpci_main.c
93891 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93892 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93893 break;
93894 }
93895 - if (atomic_read(&chip->interrupt_sleep_count)) {
93896 - atomic_set(&chip->interrupt_sleep_count, 0);
93897 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93898 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93899 wake_up(&chip->interrupt_sleep);
93900 }
93901 __end:
93902 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93903 continue;
93904 init_waitqueue_entry(&wait, current);
93905 add_wait_queue(&chip->interrupt_sleep, &wait);
93906 - atomic_inc(&chip->interrupt_sleep_count);
93907 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93908 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93909 remove_wait_queue(&chip->interrupt_sleep, &wait);
93910 }
93911 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93912 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93913 spin_unlock(&chip->reg_lock);
93914
93915 - if (atomic_read(&chip->interrupt_sleep_count)) {
93916 - atomic_set(&chip->interrupt_sleep_count, 0);
93917 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93918 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93919 wake_up(&chip->interrupt_sleep);
93920 }
93921 }
93922 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93923 spin_lock_init(&chip->reg_lock);
93924 spin_lock_init(&chip->voice_lock);
93925 init_waitqueue_head(&chip->interrupt_sleep);
93926 - atomic_set(&chip->interrupt_sleep_count, 0);
93927 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93928 chip->card = card;
93929 chip->pci = pci;
93930 chip->irq = -1;
93931 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
93932 index 7decbd9..d17d9d0 100644
93933 --- a/sound/soc/fsl/fsl_ssi.c
93934 +++ b/sound/soc/fsl/fsl_ssi.c
93935 @@ -643,7 +643,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
93936 {
93937 struct fsl_ssi_private *ssi_private;
93938 int ret = 0;
93939 - struct device_attribute *dev_attr = NULL;
93940 + device_attribute_no_const *dev_attr = NULL;
93941 struct device_node *np = pdev->dev.of_node;
93942 const char *p, *sprop;
93943 const uint32_t *iprop;
93944 diff --git a/sound/sound_core.c b/sound/sound_core.c
93945 index bb23009..db346c2 100644
93946 --- a/sound/sound_core.c
93947 +++ b/sound/sound_core.c
93948 @@ -292,7 +292,7 @@ retry:
93949 }
93950
93951 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
93952 - NULL, s->name+6);
93953 + NULL, "%s", s->name+6);
93954 return s->unit_minor;
93955
93956 fail:
93957 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93958 new file mode 100644
93959 index 0000000..50f2f2f
93960 --- /dev/null
93961 +++ b/tools/gcc/.gitignore
93962 @@ -0,0 +1 @@
93963 +size_overflow_hash.h
93964 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93965 new file mode 100644
93966 index 0000000..144dbee
93967 --- /dev/null
93968 +++ b/tools/gcc/Makefile
93969 @@ -0,0 +1,45 @@
93970 +#CC := gcc
93971 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93972 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93973 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93974 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93975 +
93976 +ifeq ($(PLUGINCC),$(HOSTCC))
93977 +HOSTLIBS := hostlibs
93978 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93979 +else
93980 +HOSTLIBS := hostcxxlibs
93981 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93982 +endif
93983 +
93984 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93985 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93986 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93987 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93988 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93989 +$(HOSTLIBS)-y += colorize_plugin.so
93990 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93991 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93992 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93993 +
93994 +always := $($(HOSTLIBS)-y)
93995 +
93996 +constify_plugin-objs := constify_plugin.o
93997 +stackleak_plugin-objs := stackleak_plugin.o
93998 +kallocstat_plugin-objs := kallocstat_plugin.o
93999 +kernexec_plugin-objs := kernexec_plugin.o
94000 +checker_plugin-objs := checker_plugin.o
94001 +colorize_plugin-objs := colorize_plugin.o
94002 +size_overflow_plugin-objs := size_overflow_plugin.o
94003 +latent_entropy_plugin-objs := latent_entropy_plugin.o
94004 +structleak_plugin-objs := structleak_plugin.o
94005 +
94006 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
94007 +
94008 +quiet_cmd_build_size_overflow_hash = GENHASH $@
94009 + cmd_build_size_overflow_hash = \
94010 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
94011 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
94012 + $(call if_changed,build_size_overflow_hash)
94013 +
94014 +targets += size_overflow_hash.h
94015 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
94016 new file mode 100644
94017 index 0000000..22f03c0
94018 --- /dev/null
94019 +++ b/tools/gcc/checker_plugin.c
94020 @@ -0,0 +1,172 @@
94021 +/*
94022 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
94023 + * Licensed under the GPL v2
94024 + *
94025 + * Note: the choice of the license means that the compilation process is
94026 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94027 + * but for the kernel it doesn't matter since it doesn't link against
94028 + * any of the gcc libraries
94029 + *
94030 + * gcc plugin to implement various sparse (source code checker) features
94031 + *
94032 + * TODO:
94033 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
94034 + *
94035 + * BUGS:
94036 + * - none known
94037 + */
94038 +#include "gcc-plugin.h"
94039 +#include "config.h"
94040 +#include "system.h"
94041 +#include "coretypes.h"
94042 +#include "tree.h"
94043 +#include "tree-pass.h"
94044 +#include "flags.h"
94045 +#include "intl.h"
94046 +#include "toplev.h"
94047 +#include "plugin.h"
94048 +//#include "expr.h" where are you...
94049 +#include "diagnostic.h"
94050 +#include "plugin-version.h"
94051 +#include "tm.h"
94052 +#include "function.h"
94053 +#include "basic-block.h"
94054 +#include "gimple.h"
94055 +#include "rtl.h"
94056 +#include "emit-rtl.h"
94057 +#include "tree-flow.h"
94058 +#include "target.h"
94059 +
94060 +extern void c_register_addr_space (const char *str, addr_space_t as);
94061 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
94062 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
94063 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
94064 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
94065 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
94066 +
94067 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94068 +extern rtx emit_move_insn(rtx x, rtx y);
94069 +
94070 +int plugin_is_GPL_compatible;
94071 +
94072 +static struct plugin_info checker_plugin_info = {
94073 + .version = "201111150100",
94074 + .help = NULL,
94075 +};
94076 +
94077 +#define ADDR_SPACE_KERNEL 0
94078 +#define ADDR_SPACE_FORCE_KERNEL 1
94079 +#define ADDR_SPACE_USER 2
94080 +#define ADDR_SPACE_FORCE_USER 3
94081 +#define ADDR_SPACE_IOMEM 0
94082 +#define ADDR_SPACE_FORCE_IOMEM 0
94083 +#define ADDR_SPACE_PERCPU 0
94084 +#define ADDR_SPACE_FORCE_PERCPU 0
94085 +#define ADDR_SPACE_RCU 0
94086 +#define ADDR_SPACE_FORCE_RCU 0
94087 +
94088 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
94089 +{
94090 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
94091 +}
94092 +
94093 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
94094 +{
94095 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
94096 +}
94097 +
94098 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
94099 +{
94100 + return default_addr_space_valid_pointer_mode(mode, as);
94101 +}
94102 +
94103 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
94104 +{
94105 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
94106 +}
94107 +
94108 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
94109 +{
94110 + return default_addr_space_legitimize_address(x, oldx, mode, as);
94111 +}
94112 +
94113 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
94114 +{
94115 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
94116 + return true;
94117 +
94118 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
94119 + return true;
94120 +
94121 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
94122 + return true;
94123 +
94124 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
94125 + return true;
94126 +
94127 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
94128 + return true;
94129 +
94130 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
94131 + return true;
94132 +
94133 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
94134 + return true;
94135 +
94136 + return subset == superset;
94137 +}
94138 +
94139 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
94140 +{
94141 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
94142 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
94143 +
94144 + return op;
94145 +}
94146 +
94147 +static void register_checker_address_spaces(void *event_data, void *data)
94148 +{
94149 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
94150 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
94151 + c_register_addr_space("__user", ADDR_SPACE_USER);
94152 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
94153 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
94154 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
94155 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
94156 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
94157 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
94158 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
94159 +
94160 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
94161 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
94162 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
94163 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
94164 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
94165 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
94166 + targetm.addr_space.convert = checker_addr_space_convert;
94167 +}
94168 +
94169 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94170 +{
94171 + const char * const plugin_name = plugin_info->base_name;
94172 + const int argc = plugin_info->argc;
94173 + const struct plugin_argument * const argv = plugin_info->argv;
94174 + int i;
94175 +
94176 + if (!plugin_default_version_check(version, &gcc_version)) {
94177 + error(G_("incompatible gcc/plugin versions"));
94178 + return 1;
94179 + }
94180 +
94181 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
94182 +
94183 + for (i = 0; i < argc; ++i)
94184 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94185 +
94186 + if (TARGET_64BIT == 0)
94187 + return 0;
94188 +
94189 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
94190 +
94191 + return 0;
94192 +}
94193 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
94194 new file mode 100644
94195 index 0000000..414fe5e
94196 --- /dev/null
94197 +++ b/tools/gcc/colorize_plugin.c
94198 @@ -0,0 +1,151 @@
94199 +/*
94200 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
94201 + * Licensed under the GPL v2
94202 + *
94203 + * Note: the choice of the license means that the compilation process is
94204 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94205 + * but for the kernel it doesn't matter since it doesn't link against
94206 + * any of the gcc libraries
94207 + *
94208 + * gcc plugin to colorize diagnostic output
94209 + *
94210 + */
94211 +
94212 +#include "gcc-plugin.h"
94213 +#include "config.h"
94214 +#include "system.h"
94215 +#include "coretypes.h"
94216 +#include "tree.h"
94217 +#include "tree-pass.h"
94218 +#include "flags.h"
94219 +#include "intl.h"
94220 +#include "toplev.h"
94221 +#include "plugin.h"
94222 +#include "diagnostic.h"
94223 +#include "plugin-version.h"
94224 +#include "tm.h"
94225 +
94226 +int plugin_is_GPL_compatible;
94227 +
94228 +static struct plugin_info colorize_plugin_info = {
94229 + .version = "201302112000",
94230 + .help = NULL,
94231 +};
94232 +
94233 +#define GREEN "\033[32m\033[2m"
94234 +#define LIGHTGREEN "\033[32m\033[1m"
94235 +#define YELLOW "\033[33m\033[2m"
94236 +#define LIGHTYELLOW "\033[33m\033[1m"
94237 +#define RED "\033[31m\033[2m"
94238 +#define LIGHTRED "\033[31m\033[1m"
94239 +#define BLUE "\033[34m\033[2m"
94240 +#define LIGHTBLUE "\033[34m\033[1m"
94241 +#define BRIGHT "\033[m\033[1m"
94242 +#define NORMAL "\033[m"
94243 +
94244 +static diagnostic_starter_fn old_starter;
94245 +static diagnostic_finalizer_fn old_finalizer;
94246 +
94247 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94248 +{
94249 + const char *color;
94250 + char *newprefix;
94251 +
94252 + switch (diagnostic->kind) {
94253 + case DK_NOTE:
94254 + color = LIGHTBLUE;
94255 + break;
94256 +
94257 + case DK_PEDWARN:
94258 + case DK_WARNING:
94259 + color = LIGHTYELLOW;
94260 + break;
94261 +
94262 + case DK_ERROR:
94263 + case DK_FATAL:
94264 + case DK_ICE:
94265 + case DK_PERMERROR:
94266 + case DK_SORRY:
94267 + color = LIGHTRED;
94268 + break;
94269 +
94270 + default:
94271 + color = NORMAL;
94272 + }
94273 +
94274 + old_starter(context, diagnostic);
94275 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
94276 + return;
94277 + pp_destroy_prefix(context->printer);
94278 + pp_set_prefix(context->printer, newprefix);
94279 +}
94280 +
94281 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94282 +{
94283 + old_finalizer(context, diagnostic);
94284 +}
94285 +
94286 +static void colorize_arm(void)
94287 +{
94288 + old_starter = diagnostic_starter(global_dc);
94289 + old_finalizer = diagnostic_finalizer(global_dc);
94290 +
94291 + diagnostic_starter(global_dc) = start_colorize;
94292 + diagnostic_finalizer(global_dc) = finalize_colorize;
94293 +}
94294 +
94295 +static unsigned int execute_colorize_rearm(void)
94296 +{
94297 + if (diagnostic_starter(global_dc) == start_colorize)
94298 + return 0;
94299 +
94300 + colorize_arm();
94301 + return 0;
94302 +}
94303 +
94304 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
94305 + .pass = {
94306 + .type = SIMPLE_IPA_PASS,
94307 + .name = "colorize_rearm",
94308 +#if BUILDING_GCC_VERSION >= 4008
94309 + .optinfo_flags = OPTGROUP_NONE,
94310 +#endif
94311 + .gate = NULL,
94312 + .execute = execute_colorize_rearm,
94313 + .sub = NULL,
94314 + .next = NULL,
94315 + .static_pass_number = 0,
94316 + .tv_id = TV_NONE,
94317 + .properties_required = 0,
94318 + .properties_provided = 0,
94319 + .properties_destroyed = 0,
94320 + .todo_flags_start = 0,
94321 + .todo_flags_finish = 0
94322 + }
94323 +};
94324 +
94325 +static void colorize_start_unit(void *gcc_data, void *user_data)
94326 +{
94327 + colorize_arm();
94328 +}
94329 +
94330 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94331 +{
94332 + const char * const plugin_name = plugin_info->base_name;
94333 + struct register_pass_info colorize_rearm_pass_info = {
94334 + .pass = &pass_ipa_colorize_rearm.pass,
94335 + .reference_pass_name = "*free_lang_data",
94336 + .ref_pass_instance_number = 1,
94337 + .pos_op = PASS_POS_INSERT_AFTER
94338 + };
94339 +
94340 + if (!plugin_default_version_check(version, &gcc_version)) {
94341 + error(G_("incompatible gcc/plugin versions"));
94342 + return 1;
94343 + }
94344 +
94345 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
94346 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
94347 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
94348 + return 0;
94349 +}
94350 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
94351 new file mode 100644
94352 index 0000000..c17312d
94353 --- /dev/null
94354 +++ b/tools/gcc/constify_plugin.c
94355 @@ -0,0 +1,560 @@
94356 +/*
94357 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
94358 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
94359 + * Licensed under the GPL v2, or (at your option) v3
94360 + *
94361 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
94362 + *
94363 + * Homepage:
94364 + * http://www.grsecurity.net/~ephox/const_plugin/
94365 + *
94366 + * Usage:
94367 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
94368 + * $ gcc -fplugin=constify_plugin.so test.c -O2
94369 + */
94370 +
94371 +#include "gcc-plugin.h"
94372 +#include "config.h"
94373 +#include "system.h"
94374 +#include "coretypes.h"
94375 +#include "tree.h"
94376 +#include "tree-pass.h"
94377 +#include "flags.h"
94378 +#include "intl.h"
94379 +#include "toplev.h"
94380 +#include "plugin.h"
94381 +#include "diagnostic.h"
94382 +#include "plugin-version.h"
94383 +#include "tm.h"
94384 +#include "function.h"
94385 +#include "basic-block.h"
94386 +#include "gimple.h"
94387 +#include "rtl.h"
94388 +#include "emit-rtl.h"
94389 +#include "tree-flow.h"
94390 +#include "target.h"
94391 +#include "langhooks.h"
94392 +
94393 +// should come from c-tree.h if only it were installed for gcc 4.5...
94394 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
94395 +
94396 +// unused type flag in all versions 4.5-4.8
94397 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
94398 +
94399 +int plugin_is_GPL_compatible;
94400 +
94401 +static struct plugin_info const_plugin_info = {
94402 + .version = "201305231310",
94403 + .help = "no-constify\tturn off constification\n",
94404 +};
94405 +
94406 +typedef struct {
94407 + bool has_fptr_field;
94408 + bool has_writable_field;
94409 + bool has_do_const_field;
94410 + bool has_no_const_field;
94411 +} constify_info;
94412 +
94413 +static const_tree get_field_type(const_tree field)
94414 +{
94415 + return strip_array_types(TREE_TYPE(field));
94416 +}
94417 +
94418 +static bool is_fptr(const_tree field)
94419 +{
94420 + const_tree ptr = get_field_type(field);
94421 +
94422 + if (TREE_CODE(ptr) != POINTER_TYPE)
94423 + return false;
94424 +
94425 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
94426 +}
94427 +
94428 +/*
94429 + * determine whether the given structure type meets the requirements for automatic constification,
94430 + * including the constification attributes on nested structure types
94431 + */
94432 +static void constifiable(const_tree node, constify_info *cinfo)
94433 +{
94434 + const_tree field;
94435 +
94436 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94437 +
94438 + // e.g., pointer to structure fields while still constructing the structure type
94439 + if (TYPE_FIELDS(node) == NULL_TREE)
94440 + return;
94441 +
94442 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
94443 + const_tree type = get_field_type(field);
94444 + enum tree_code code = TREE_CODE(type);
94445 +
94446 + if (node == type)
94447 + continue;
94448 +
94449 + if (is_fptr(field))
94450 + cinfo->has_fptr_field = true;
94451 + else if (!TREE_READONLY(field))
94452 + cinfo->has_writable_field = true;
94453 +
94454 + if (code == RECORD_TYPE || code == UNION_TYPE) {
94455 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94456 + cinfo->has_do_const_field = true;
94457 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
94458 + cinfo->has_no_const_field = true;
94459 + else
94460 + constifiable(type, cinfo);
94461 + }
94462 + }
94463 +}
94464 +
94465 +static bool constified(const_tree node)
94466 +{
94467 + constify_info cinfo = {
94468 + .has_fptr_field = false,
94469 + .has_writable_field = false,
94470 + .has_do_const_field = false,
94471 + .has_no_const_field = false
94472 + };
94473 +
94474 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94475 +
94476 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
94477 + gcc_assert(!TYPE_READONLY(node));
94478 + return false;
94479 + }
94480 +
94481 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
94482 + gcc_assert(TYPE_READONLY(node));
94483 + return true;
94484 + }
94485 +
94486 + constifiable(node, &cinfo);
94487 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
94488 + return false;
94489 +
94490 + return TYPE_READONLY(node);
94491 +}
94492 +
94493 +static void deconstify_tree(tree node);
94494 +
94495 +static void deconstify_type(tree type)
94496 +{
94497 + tree field;
94498 +
94499 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
94500 +
94501 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
94502 + const_tree fieldtype = get_field_type(field);
94503 +
94504 + // special case handling of simple ptr-to-same-array-type members
94505 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
94506 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
94507 +
94508 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
94509 + continue;
94510 + if (TREE_TYPE(TREE_TYPE(field)) == type)
94511 + continue;
94512 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
94513 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
94514 + TREE_TYPE(TREE_TYPE(field)) = type;
94515 + }
94516 + continue;
94517 + }
94518 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
94519 + continue;
94520 + if (!constified(fieldtype))
94521 + continue;
94522 +
94523 + deconstify_tree(field);
94524 + TREE_READONLY(field) = 0;
94525 + }
94526 + TYPE_READONLY(type) = 0;
94527 + C_TYPE_FIELDS_READONLY(type) = 0;
94528 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94529 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
94530 +}
94531 +
94532 +static void deconstify_tree(tree node)
94533 +{
94534 + tree old_type, new_type, field;
94535 +
94536 + old_type = TREE_TYPE(node);
94537 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
94538 + node = TREE_TYPE(node) = copy_node(old_type);
94539 + old_type = TREE_TYPE(old_type);
94540 + }
94541 +
94542 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
94543 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
94544 +
94545 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
94546 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
94547 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
94548 + DECL_FIELD_CONTEXT(field) = new_type;
94549 +
94550 + deconstify_type(new_type);
94551 +
94552 + TREE_TYPE(node) = new_type;
94553 +}
94554 +
94555 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94556 +{
94557 + tree type;
94558 + constify_info cinfo = {
94559 + .has_fptr_field = false,
94560 + .has_writable_field = false,
94561 + .has_do_const_field = false,
94562 + .has_no_const_field = false
94563 + };
94564 +
94565 + *no_add_attrs = true;
94566 + if (TREE_CODE(*node) == FUNCTION_DECL) {
94567 + error("%qE attribute does not apply to functions", name);
94568 + return NULL_TREE;
94569 + }
94570 +
94571 + if (TREE_CODE(*node) == PARM_DECL) {
94572 + error("%qE attribute does not apply to function parameters", name);
94573 + return NULL_TREE;
94574 + }
94575 +
94576 + if (TREE_CODE(*node) == VAR_DECL) {
94577 + error("%qE attribute does not apply to variables", name);
94578 + return NULL_TREE;
94579 + }
94580 +
94581 + if (TYPE_P(*node)) {
94582 + *no_add_attrs = false;
94583 + type = *node;
94584 + } else {
94585 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
94586 + type = TREE_TYPE(*node);
94587 + }
94588 +
94589 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
94590 + error("%qE attribute applies to struct and union types only", name);
94591 + return NULL_TREE;
94592 + }
94593 +
94594 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
94595 + error("%qE attribute is already applied to the type", name);
94596 + return NULL_TREE;
94597 + }
94598 +
94599 + if (TYPE_P(*node)) {
94600 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94601 + error("%qE attribute is incompatible with 'do_const'", name);
94602 + return NULL_TREE;
94603 + }
94604 +
94605 + constifiable(type, &cinfo);
94606 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94607 + deconstify_tree(*node);
94608 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
94609 + return NULL_TREE;
94610 + }
94611 +
94612 + error("%qE attribute used on type that is not constified", name);
94613 + return NULL_TREE;
94614 +}
94615 +
94616 +static void constify_type(tree type)
94617 +{
94618 + TYPE_READONLY(type) = 1;
94619 + C_TYPE_FIELDS_READONLY(type) = 1;
94620 + TYPE_CONSTIFY_VISITED(type) = 1;
94621 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
94622 +}
94623 +
94624 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94625 +{
94626 + *no_add_attrs = true;
94627 + if (!TYPE_P(*node)) {
94628 + error("%qE attribute applies to types only", name);
94629 + return NULL_TREE;
94630 + }
94631 +
94632 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94633 + error("%qE attribute applies to struct and union types only", name);
94634 + return NULL_TREE;
94635 + }
94636 +
94637 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94638 + error("%qE attribute is already applied to the type", name);
94639 + return NULL_TREE;
94640 + }
94641 +
94642 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
94643 + error("%qE attribute is incompatible with 'no_const'", name);
94644 + return NULL_TREE;
94645 + }
94646 +
94647 + *no_add_attrs = false;
94648 + return NULL_TREE;
94649 +}
94650 +
94651 +static struct attribute_spec no_const_attr = {
94652 + .name = "no_const",
94653 + .min_length = 0,
94654 + .max_length = 0,
94655 + .decl_required = false,
94656 + .type_required = false,
94657 + .function_type_required = false,
94658 + .handler = handle_no_const_attribute,
94659 +#if BUILDING_GCC_VERSION >= 4007
94660 + .affects_type_identity = true
94661 +#endif
94662 +};
94663 +
94664 +static struct attribute_spec do_const_attr = {
94665 + .name = "do_const",
94666 + .min_length = 0,
94667 + .max_length = 0,
94668 + .decl_required = false,
94669 + .type_required = false,
94670 + .function_type_required = false,
94671 + .handler = handle_do_const_attribute,
94672 +#if BUILDING_GCC_VERSION >= 4007
94673 + .affects_type_identity = true
94674 +#endif
94675 +};
94676 +
94677 +static void register_attributes(void *event_data, void *data)
94678 +{
94679 + register_attribute(&no_const_attr);
94680 + register_attribute(&do_const_attr);
94681 +}
94682 +
94683 +static void finish_type(void *event_data, void *data)
94684 +{
94685 + tree type = (tree)event_data;
94686 + constify_info cinfo = {
94687 + .has_fptr_field = false,
94688 + .has_writable_field = false,
94689 + .has_do_const_field = false,
94690 + .has_no_const_field = false
94691 + };
94692 +
94693 + if (type == NULL_TREE || type == error_mark_node)
94694 + return;
94695 +
94696 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94697 + return;
94698 +
94699 + constifiable(type, &cinfo);
94700 +
94701 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94702 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94703 + return;
94704 + if (cinfo.has_writable_field)
94705 + return;
94706 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94707 + return;
94708 + }
94709 +
94710 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94711 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94712 + deconstify_type(type);
94713 + TYPE_CONSTIFY_VISITED(type) = 1;
94714 + } else
94715 + error("'no_const' attribute used on type that is not constified");
94716 + return;
94717 + }
94718 +
94719 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94720 + constify_type(type);
94721 + return;
94722 + }
94723 +
94724 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94725 + constify_type(type);
94726 + return;
94727 + }
94728 +
94729 + deconstify_type(type);
94730 + TYPE_CONSTIFY_VISITED(type) = 1;
94731 +}
94732 +
94733 +static void check_global_variables(void)
94734 +{
94735 + struct varpool_node *node;
94736 +
94737 +#if BUILDING_GCC_VERSION <= 4007
94738 + for (node = varpool_nodes; node; node = node->next) {
94739 + tree var = node->decl;
94740 +#else
94741 + FOR_EACH_VARIABLE(node) {
94742 + tree var = node->symbol.decl;
94743 +#endif
94744 + tree type = TREE_TYPE(var);
94745 +
94746 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94747 + continue;
94748 +
94749 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94750 + continue;
94751 +
94752 + if (!TYPE_CONSTIFY_VISITED(type))
94753 + continue;
94754 +
94755 + if (DECL_EXTERNAL(var))
94756 + continue;
94757 +
94758 + if (DECL_INITIAL(var))
94759 + continue;
94760 +
94761 + // this works around a gcc bug/feature where uninitialized globals
94762 + // are moved into the .bss section regardless of any constification
94763 + DECL_INITIAL(var) = build_constructor(type, NULL);
94764 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
94765 + }
94766 +}
94767 +
94768 +static unsigned int check_local_variables(void)
94769 +{
94770 + unsigned int ret = 0;
94771 + tree var;
94772 +
94773 +#if BUILDING_GCC_VERSION == 4005
94774 + tree vars;
94775 +#else
94776 + unsigned int i;
94777 +#endif
94778 +
94779 +#if BUILDING_GCC_VERSION == 4005
94780 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94781 + var = TREE_VALUE(vars);
94782 +#else
94783 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94784 +#endif
94785 + tree type = TREE_TYPE(var);
94786 +
94787 + gcc_assert(DECL_P(var));
94788 + if (is_global_var(var))
94789 + continue;
94790 +
94791 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94792 + continue;
94793 +
94794 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94795 + continue;
94796 +
94797 + if (!TYPE_CONSTIFY_VISITED(type))
94798 + continue;
94799 +
94800 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94801 + ret = 1;
94802 + }
94803 + return ret;
94804 +}
94805 +
94806 +static unsigned int check_variables(void)
94807 +{
94808 + check_global_variables();
94809 + return check_local_variables();
94810 +}
94811 +
94812 + unsigned int ret = 0;
94813 +static struct gimple_opt_pass pass_local_variable = {
94814 + {
94815 + .type = GIMPLE_PASS,
94816 + .name = "check_variables",
94817 +#if BUILDING_GCC_VERSION >= 4008
94818 + .optinfo_flags = OPTGROUP_NONE,
94819 +#endif
94820 + .gate = NULL,
94821 + .execute = check_variables,
94822 + .sub = NULL,
94823 + .next = NULL,
94824 + .static_pass_number = 0,
94825 + .tv_id = TV_NONE,
94826 + .properties_required = 0,
94827 + .properties_provided = 0,
94828 + .properties_destroyed = 0,
94829 + .todo_flags_start = 0,
94830 + .todo_flags_finish = 0
94831 + }
94832 +};
94833 +
94834 +static struct {
94835 + const char *name;
94836 + const char *asm_op;
94837 +} sections[] = {
94838 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94839 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94840 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94841 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94842 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94843 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94844 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94845 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94846 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94847 +};
94848 +
94849 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94850 +
94851 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94852 +{
94853 + size_t i;
94854 +
94855 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94856 + if (!strcmp(sections[i].name, name))
94857 + return 0;
94858 + return old_section_type_flags(decl, name, reloc);
94859 +}
94860 +
94861 +static void constify_start_unit(void *gcc_data, void *user_data)
94862 +{
94863 +// size_t i;
94864 +
94865 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94866 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94867 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94868 +
94869 + old_section_type_flags = targetm.section_type_flags;
94870 + targetm.section_type_flags = constify_section_type_flags;
94871 +}
94872 +
94873 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94874 +{
94875 + const char * const plugin_name = plugin_info->base_name;
94876 + const int argc = plugin_info->argc;
94877 + const struct plugin_argument * const argv = plugin_info->argv;
94878 + int i;
94879 + bool constify = true;
94880 +
94881 + struct register_pass_info local_variable_pass_info = {
94882 + .pass = &pass_local_variable.pass,
94883 + .reference_pass_name = "ssa",
94884 + .ref_pass_instance_number = 1,
94885 + .pos_op = PASS_POS_INSERT_BEFORE
94886 + };
94887 +
94888 + if (!plugin_default_version_check(version, &gcc_version)) {
94889 + error(G_("incompatible gcc/plugin versions"));
94890 + return 1;
94891 + }
94892 +
94893 + for (i = 0; i < argc; ++i) {
94894 + if (!(strcmp(argv[i].key, "no-constify"))) {
94895 + constify = false;
94896 + continue;
94897 + }
94898 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94899 + }
94900 +
94901 + if (strcmp(lang_hooks.name, "GNU C")) {
94902 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94903 + constify = false;
94904 + }
94905 +
94906 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94907 + if (constify) {
94908 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94909 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94910 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94911 + }
94912 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94913 +
94914 + return 0;
94915 +}
94916 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94917 new file mode 100644
94918 index 0000000..e518932
94919 --- /dev/null
94920 +++ b/tools/gcc/generate_size_overflow_hash.sh
94921 @@ -0,0 +1,94 @@
94922 +#!/bin/bash
94923 +
94924 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94925 +
94926 +header1="size_overflow_hash.h"
94927 +database="size_overflow_hash.data"
94928 +n=65536
94929 +
94930 +usage() {
94931 +cat <<EOF
94932 +usage: $0 options
94933 +OPTIONS:
94934 + -h|--help help
94935 + -o header file
94936 + -d database file
94937 + -n hash array size
94938 +EOF
94939 + return 0
94940 +}
94941 +
94942 +while true
94943 +do
94944 + case "$1" in
94945 + -h|--help) usage && exit 0;;
94946 + -n) n=$2; shift 2;;
94947 + -o) header1="$2"; shift 2;;
94948 + -d) database="$2"; shift 2;;
94949 + --) shift 1; break ;;
94950 + *) break ;;
94951 + esac
94952 +done
94953 +
94954 +create_defines() {
94955 + for i in `seq 0 31`
94956 + do
94957 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94958 + done
94959 + echo >> "$header1"
94960 +}
94961 +
94962 +create_structs() {
94963 + rm -f "$header1"
94964 +
94965 + create_defines
94966 +
94967 + cat "$database" | while read data
94968 + do
94969 + data_array=($data)
94970 + struct_hash_name="${data_array[0]}"
94971 + funcn="${data_array[1]}"
94972 + params="${data_array[2]}"
94973 + next="${data_array[4]}"
94974 +
94975 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94976 +
94977 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94978 + echo -en "\t.param\t= " >> "$header1"
94979 + line=
94980 + for param_num in ${params//-/ };
94981 + do
94982 + line="${line}PARAM"$param_num"|"
94983 + done
94984 +
94985 + echo -e "${line%?},\n};\n" >> "$header1"
94986 + done
94987 +}
94988 +
94989 +create_headers() {
94990 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94991 +}
94992 +
94993 +create_array_elements() {
94994 + index=0
94995 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94996 + do
94997 + data_array=($data)
94998 + i="${data_array[3]}"
94999 + hash="${data_array[0]}"
95000 + while [[ $index -lt $i ]]
95001 + do
95002 + echo -e "\t["$index"]\t= NULL," >> "$header1"
95003 + index=$(($index + 1))
95004 + done
95005 + index=$(($index + 1))
95006 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
95007 + done
95008 + echo '};' >> $header1
95009 +}
95010 +
95011 +create_structs
95012 +create_headers
95013 +create_array_elements
95014 +
95015 +exit 0
95016 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
95017 new file mode 100644
95018 index 0000000..568b360
95019 --- /dev/null
95020 +++ b/tools/gcc/kallocstat_plugin.c
95021 @@ -0,0 +1,170 @@
95022 +/*
95023 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95024 + * Licensed under the GPL v2
95025 + *
95026 + * Note: the choice of the license means that the compilation process is
95027 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95028 + * but for the kernel it doesn't matter since it doesn't link against
95029 + * any of the gcc libraries
95030 + *
95031 + * gcc plugin to find the distribution of k*alloc sizes
95032 + *
95033 + * TODO:
95034 + *
95035 + * BUGS:
95036 + * - none known
95037 + */
95038 +#include "gcc-plugin.h"
95039 +#include "config.h"
95040 +#include "system.h"
95041 +#include "coretypes.h"
95042 +#include "tree.h"
95043 +#include "tree-pass.h"
95044 +#include "flags.h"
95045 +#include "intl.h"
95046 +#include "toplev.h"
95047 +#include "plugin.h"
95048 +//#include "expr.h" where are you...
95049 +#include "diagnostic.h"
95050 +#include "plugin-version.h"
95051 +#include "tm.h"
95052 +#include "function.h"
95053 +#include "basic-block.h"
95054 +#include "gimple.h"
95055 +#include "rtl.h"
95056 +#include "emit-rtl.h"
95057 +
95058 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95059 +
95060 +int plugin_is_GPL_compatible;
95061 +
95062 +static const char * const kalloc_functions[] = {
95063 + "__kmalloc",
95064 + "kmalloc",
95065 + "kmalloc_large",
95066 + "kmalloc_node",
95067 + "kmalloc_order",
95068 + "kmalloc_order_trace",
95069 + "kmalloc_slab",
95070 + "kzalloc",
95071 + "kzalloc_node",
95072 +};
95073 +
95074 +static struct plugin_info kallocstat_plugin_info = {
95075 + .version = "201302112000",
95076 +};
95077 +
95078 +static unsigned int execute_kallocstat(void);
95079 +
95080 +static struct gimple_opt_pass kallocstat_pass = {
95081 + .pass = {
95082 + .type = GIMPLE_PASS,
95083 + .name = "kallocstat",
95084 +#if BUILDING_GCC_VERSION >= 4008
95085 + .optinfo_flags = OPTGROUP_NONE,
95086 +#endif
95087 + .gate = NULL,
95088 + .execute = execute_kallocstat,
95089 + .sub = NULL,
95090 + .next = NULL,
95091 + .static_pass_number = 0,
95092 + .tv_id = TV_NONE,
95093 + .properties_required = 0,
95094 + .properties_provided = 0,
95095 + .properties_destroyed = 0,
95096 + .todo_flags_start = 0,
95097 + .todo_flags_finish = 0
95098 + }
95099 +};
95100 +
95101 +static bool is_kalloc(const char *fnname)
95102 +{
95103 + size_t i;
95104 +
95105 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
95106 + if (!strcmp(fnname, kalloc_functions[i]))
95107 + return true;
95108 + return false;
95109 +}
95110 +
95111 +static unsigned int execute_kallocstat(void)
95112 +{
95113 + basic_block bb;
95114 +
95115 + // 1. loop through BBs and GIMPLE statements
95116 + FOR_EACH_BB(bb) {
95117 + gimple_stmt_iterator gsi;
95118 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95119 + // gimple match:
95120 + tree fndecl, size;
95121 + gimple call_stmt;
95122 + const char *fnname;
95123 +
95124 + // is it a call
95125 + call_stmt = gsi_stmt(gsi);
95126 + if (!is_gimple_call(call_stmt))
95127 + continue;
95128 + fndecl = gimple_call_fndecl(call_stmt);
95129 + if (fndecl == NULL_TREE)
95130 + continue;
95131 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
95132 + continue;
95133 +
95134 + // is it a call to k*alloc
95135 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
95136 + if (!is_kalloc(fnname))
95137 + continue;
95138 +
95139 + // is the size arg the result of a simple const assignment
95140 + size = gimple_call_arg(call_stmt, 0);
95141 + while (true) {
95142 + gimple def_stmt;
95143 + expanded_location xloc;
95144 + size_t size_val;
95145 +
95146 + if (TREE_CODE(size) != SSA_NAME)
95147 + break;
95148 + def_stmt = SSA_NAME_DEF_STMT(size);
95149 + if (!def_stmt || !is_gimple_assign(def_stmt))
95150 + break;
95151 + if (gimple_num_ops(def_stmt) != 2)
95152 + break;
95153 + size = gimple_assign_rhs1(def_stmt);
95154 + if (!TREE_CONSTANT(size))
95155 + continue;
95156 + xloc = expand_location(gimple_location(def_stmt));
95157 + if (!xloc.file)
95158 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
95159 + size_val = TREE_INT_CST_LOW(size);
95160 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
95161 + break;
95162 + }
95163 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95164 +//debug_tree(gimple_call_fn(call_stmt));
95165 +//print_node(stderr, "pax", fndecl, 4);
95166 + }
95167 + }
95168 +
95169 + return 0;
95170 +}
95171 +
95172 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95173 +{
95174 + const char * const plugin_name = plugin_info->base_name;
95175 + struct register_pass_info kallocstat_pass_info = {
95176 + .pass = &kallocstat_pass.pass,
95177 + .reference_pass_name = "ssa",
95178 + .ref_pass_instance_number = 1,
95179 + .pos_op = PASS_POS_INSERT_AFTER
95180 + };
95181 +
95182 + if (!plugin_default_version_check(version, &gcc_version)) {
95183 + error(G_("incompatible gcc/plugin versions"));
95184 + return 1;
95185 + }
95186 +
95187 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
95188 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
95189 +
95190 + return 0;
95191 +}
95192 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
95193 new file mode 100644
95194 index 0000000..0408e06
95195 --- /dev/null
95196 +++ b/tools/gcc/kernexec_plugin.c
95197 @@ -0,0 +1,465 @@
95198 +/*
95199 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95200 + * Licensed under the GPL v2
95201 + *
95202 + * Note: the choice of the license means that the compilation process is
95203 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95204 + * but for the kernel it doesn't matter since it doesn't link against
95205 + * any of the gcc libraries
95206 + *
95207 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
95208 + *
95209 + * TODO:
95210 + *
95211 + * BUGS:
95212 + * - none known
95213 + */
95214 +#include "gcc-plugin.h"
95215 +#include "config.h"
95216 +#include "system.h"
95217 +#include "coretypes.h"
95218 +#include "tree.h"
95219 +#include "tree-pass.h"
95220 +#include "flags.h"
95221 +#include "intl.h"
95222 +#include "toplev.h"
95223 +#include "plugin.h"
95224 +//#include "expr.h" where are you...
95225 +#include "diagnostic.h"
95226 +#include "plugin-version.h"
95227 +#include "tm.h"
95228 +#include "function.h"
95229 +#include "basic-block.h"
95230 +#include "gimple.h"
95231 +#include "rtl.h"
95232 +#include "emit-rtl.h"
95233 +#include "tree-flow.h"
95234 +
95235 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95236 +extern rtx emit_move_insn(rtx x, rtx y);
95237 +
95238 +#if BUILDING_GCC_VERSION <= 4006
95239 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
95240 +#endif
95241 +
95242 +#if BUILDING_GCC_VERSION >= 4008
95243 +#define TODO_dump_func 0
95244 +#endif
95245 +
95246 +int plugin_is_GPL_compatible;
95247 +
95248 +static struct plugin_info kernexec_plugin_info = {
95249 + .version = "201302112000",
95250 + .help = "method=[bts|or]\tinstrumentation method\n"
95251 +};
95252 +
95253 +static unsigned int execute_kernexec_reload(void);
95254 +static unsigned int execute_kernexec_fptr(void);
95255 +static unsigned int execute_kernexec_retaddr(void);
95256 +static bool kernexec_cmodel_check(void);
95257 +
95258 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
95259 +static void (*kernexec_instrument_retaddr)(rtx);
95260 +
95261 +static struct gimple_opt_pass kernexec_reload_pass = {
95262 + .pass = {
95263 + .type = GIMPLE_PASS,
95264 + .name = "kernexec_reload",
95265 +#if BUILDING_GCC_VERSION >= 4008
95266 + .optinfo_flags = OPTGROUP_NONE,
95267 +#endif
95268 + .gate = kernexec_cmodel_check,
95269 + .execute = execute_kernexec_reload,
95270 + .sub = NULL,
95271 + .next = NULL,
95272 + .static_pass_number = 0,
95273 + .tv_id = TV_NONE,
95274 + .properties_required = 0,
95275 + .properties_provided = 0,
95276 + .properties_destroyed = 0,
95277 + .todo_flags_start = 0,
95278 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95279 + }
95280 +};
95281 +
95282 +static struct gimple_opt_pass kernexec_fptr_pass = {
95283 + .pass = {
95284 + .type = GIMPLE_PASS,
95285 + .name = "kernexec_fptr",
95286 +#if BUILDING_GCC_VERSION >= 4008
95287 + .optinfo_flags = OPTGROUP_NONE,
95288 +#endif
95289 + .gate = kernexec_cmodel_check,
95290 + .execute = execute_kernexec_fptr,
95291 + .sub = NULL,
95292 + .next = NULL,
95293 + .static_pass_number = 0,
95294 + .tv_id = TV_NONE,
95295 + .properties_required = 0,
95296 + .properties_provided = 0,
95297 + .properties_destroyed = 0,
95298 + .todo_flags_start = 0,
95299 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95300 + }
95301 +};
95302 +
95303 +static struct rtl_opt_pass kernexec_retaddr_pass = {
95304 + .pass = {
95305 + .type = RTL_PASS,
95306 + .name = "kernexec_retaddr",
95307 +#if BUILDING_GCC_VERSION >= 4008
95308 + .optinfo_flags = OPTGROUP_NONE,
95309 +#endif
95310 + .gate = kernexec_cmodel_check,
95311 + .execute = execute_kernexec_retaddr,
95312 + .sub = NULL,
95313 + .next = NULL,
95314 + .static_pass_number = 0,
95315 + .tv_id = TV_NONE,
95316 + .properties_required = 0,
95317 + .properties_provided = 0,
95318 + .properties_destroyed = 0,
95319 + .todo_flags_start = 0,
95320 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
95321 + }
95322 +};
95323 +
95324 +static bool kernexec_cmodel_check(void)
95325 +{
95326 + tree section;
95327 +
95328 + if (ix86_cmodel != CM_KERNEL)
95329 + return false;
95330 +
95331 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
95332 + if (!section || !TREE_VALUE(section))
95333 + return true;
95334 +
95335 + section = TREE_VALUE(TREE_VALUE(section));
95336 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
95337 + return true;
95338 +
95339 + return false;
95340 +}
95341 +
95342 +/*
95343 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
95344 + */
95345 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
95346 +{
95347 + gimple asm_movabs_stmt;
95348 +
95349 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
95350 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
95351 + gimple_asm_set_volatile(asm_movabs_stmt, true);
95352 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
95353 + update_stmt(asm_movabs_stmt);
95354 +}
95355 +
95356 +/*
95357 + * find all asm() stmts that clobber r10 and add a reload of r10
95358 + */
95359 +static unsigned int execute_kernexec_reload(void)
95360 +{
95361 + basic_block bb;
95362 +
95363 + // 1. loop through BBs and GIMPLE statements
95364 + FOR_EACH_BB(bb) {
95365 + gimple_stmt_iterator gsi;
95366 +
95367 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95368 + // gimple match: __asm__ ("" : : : "r10");
95369 + gimple asm_stmt;
95370 + size_t nclobbers;
95371 +
95372 + // is it an asm ...
95373 + asm_stmt = gsi_stmt(gsi);
95374 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
95375 + continue;
95376 +
95377 + // ... clobbering r10
95378 + nclobbers = gimple_asm_nclobbers(asm_stmt);
95379 + while (nclobbers--) {
95380 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
95381 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
95382 + continue;
95383 + kernexec_reload_fptr_mask(&gsi);
95384 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
95385 + break;
95386 + }
95387 + }
95388 + }
95389 +
95390 + return 0;
95391 +}
95392 +
95393 +/*
95394 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
95395 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
95396 + */
95397 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
95398 +{
95399 + gimple assign_intptr, assign_new_fptr, call_stmt;
95400 + tree intptr, old_fptr, new_fptr, kernexec_mask;
95401 +
95402 + call_stmt = gsi_stmt(*gsi);
95403 + old_fptr = gimple_call_fn(call_stmt);
95404 +
95405 + // create temporary unsigned long variable used for bitops and cast fptr to it
95406 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
95407 +#if BUILDING_GCC_VERSION <= 4007
95408 + add_referenced_var(intptr);
95409 + mark_sym_for_renaming(intptr);
95410 +#endif
95411 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
95412 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95413 + update_stmt(assign_intptr);
95414 +
95415 + // apply logical or to temporary unsigned long and bitmask
95416 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
95417 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
95418 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
95419 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95420 + update_stmt(assign_intptr);
95421 +
95422 + // cast temporary unsigned long back to a temporary fptr variable
95423 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
95424 +#if BUILDING_GCC_VERSION <= 4007
95425 + add_referenced_var(new_fptr);
95426 + mark_sym_for_renaming(new_fptr);
95427 +#endif
95428 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
95429 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
95430 + update_stmt(assign_new_fptr);
95431 +
95432 + // replace call stmt fn with the new fptr
95433 + gimple_call_set_fn(call_stmt, new_fptr);
95434 + update_stmt(call_stmt);
95435 +}
95436 +
95437 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
95438 +{
95439 + gimple asm_or_stmt, call_stmt;
95440 + tree old_fptr, new_fptr, input, output;
95441 +#if BUILDING_GCC_VERSION <= 4007
95442 + VEC(tree, gc) *inputs = NULL;
95443 + VEC(tree, gc) *outputs = NULL;
95444 +#else
95445 + vec<tree, va_gc> *inputs = NULL;
95446 + vec<tree, va_gc> *outputs = NULL;
95447 +#endif
95448 +
95449 + call_stmt = gsi_stmt(*gsi);
95450 + old_fptr = gimple_call_fn(call_stmt);
95451 +
95452 + // create temporary fptr variable
95453 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
95454 +#if BUILDING_GCC_VERSION <= 4007
95455 + add_referenced_var(new_fptr);
95456 + mark_sym_for_renaming(new_fptr);
95457 +#endif
95458 +
95459 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
95460 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
95461 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
95462 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
95463 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
95464 +#if BUILDING_GCC_VERSION <= 4007
95465 + VEC_safe_push(tree, gc, inputs, input);
95466 + VEC_safe_push(tree, gc, outputs, output);
95467 +#else
95468 + vec_safe_push(inputs, input);
95469 + vec_safe_push(outputs, output);
95470 +#endif
95471 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
95472 + gimple_asm_set_volatile(asm_or_stmt, true);
95473 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
95474 + update_stmt(asm_or_stmt);
95475 +
95476 + // replace call stmt fn with the new fptr
95477 + gimple_call_set_fn(call_stmt, new_fptr);
95478 + update_stmt(call_stmt);
95479 +}
95480 +
95481 +/*
95482 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
95483 + */
95484 +static unsigned int execute_kernexec_fptr(void)
95485 +{
95486 + basic_block bb;
95487 +
95488 + // 1. loop through BBs and GIMPLE statements
95489 + FOR_EACH_BB(bb) {
95490 + gimple_stmt_iterator gsi;
95491 +
95492 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95493 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
95494 + tree fn;
95495 + gimple call_stmt;
95496 +
95497 + // is it a call ...
95498 + call_stmt = gsi_stmt(gsi);
95499 + if (!is_gimple_call(call_stmt))
95500 + continue;
95501 + fn = gimple_call_fn(call_stmt);
95502 + if (TREE_CODE(fn) == ADDR_EXPR)
95503 + continue;
95504 + if (TREE_CODE(fn) != SSA_NAME)
95505 + gcc_unreachable();
95506 +
95507 + // ... through a function pointer
95508 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
95509 + fn = SSA_NAME_VAR(fn);
95510 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
95511 + debug_tree(fn);
95512 + gcc_unreachable();
95513 + }
95514 + }
95515 + fn = TREE_TYPE(fn);
95516 + if (TREE_CODE(fn) != POINTER_TYPE)
95517 + continue;
95518 + fn = TREE_TYPE(fn);
95519 + if (TREE_CODE(fn) != FUNCTION_TYPE)
95520 + continue;
95521 +
95522 + kernexec_instrument_fptr(&gsi);
95523 +
95524 +//debug_tree(gimple_call_fn(call_stmt));
95525 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95526 + }
95527 + }
95528 +
95529 + return 0;
95530 +}
95531 +
95532 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
95533 +static void kernexec_instrument_retaddr_bts(rtx insn)
95534 +{
95535 + rtx btsq;
95536 + rtvec argvec, constraintvec, labelvec;
95537 + int line;
95538 +
95539 + // create asm volatile("btsq $63,(%%rsp)":::)
95540 + argvec = rtvec_alloc(0);
95541 + constraintvec = rtvec_alloc(0);
95542 + labelvec = rtvec_alloc(0);
95543 + line = expand_location(RTL_LOCATION(insn)).line;
95544 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95545 + MEM_VOLATILE_P(btsq) = 1;
95546 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
95547 + emit_insn_before(btsq, insn);
95548 +}
95549 +
95550 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
95551 +static void kernexec_instrument_retaddr_or(rtx insn)
95552 +{
95553 + rtx orq;
95554 + rtvec argvec, constraintvec, labelvec;
95555 + int line;
95556 +
95557 + // create asm volatile("orq %%r10,(%%rsp)":::)
95558 + argvec = rtvec_alloc(0);
95559 + constraintvec = rtvec_alloc(0);
95560 + labelvec = rtvec_alloc(0);
95561 + line = expand_location(RTL_LOCATION(insn)).line;
95562 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95563 + MEM_VOLATILE_P(orq) = 1;
95564 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
95565 + emit_insn_before(orq, insn);
95566 +}
95567 +
95568 +/*
95569 + * find all asm level function returns and forcibly set the highest bit of the return address
95570 + */
95571 +static unsigned int execute_kernexec_retaddr(void)
95572 +{
95573 + rtx insn;
95574 +
95575 + // 1. find function returns
95576 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
95577 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
95578 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
95579 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
95580 + rtx body;
95581 +
95582 + // is it a retn
95583 + if (!JUMP_P(insn))
95584 + continue;
95585 + body = PATTERN(insn);
95586 + if (GET_CODE(body) == PARALLEL)
95587 + body = XVECEXP(body, 0, 0);
95588 + if (!ANY_RETURN_P(body))
95589 + continue;
95590 + kernexec_instrument_retaddr(insn);
95591 + }
95592 +
95593 +// print_simple_rtl(stderr, get_insns());
95594 +// print_rtl(stderr, get_insns());
95595 +
95596 + return 0;
95597 +}
95598 +
95599 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95600 +{
95601 + const char * const plugin_name = plugin_info->base_name;
95602 + const int argc = plugin_info->argc;
95603 + const struct plugin_argument * const argv = plugin_info->argv;
95604 + int i;
95605 + struct register_pass_info kernexec_reload_pass_info = {
95606 + .pass = &kernexec_reload_pass.pass,
95607 + .reference_pass_name = "ssa",
95608 + .ref_pass_instance_number = 1,
95609 + .pos_op = PASS_POS_INSERT_AFTER
95610 + };
95611 + struct register_pass_info kernexec_fptr_pass_info = {
95612 + .pass = &kernexec_fptr_pass.pass,
95613 + .reference_pass_name = "ssa",
95614 + .ref_pass_instance_number = 1,
95615 + .pos_op = PASS_POS_INSERT_AFTER
95616 + };
95617 + struct register_pass_info kernexec_retaddr_pass_info = {
95618 + .pass = &kernexec_retaddr_pass.pass,
95619 + .reference_pass_name = "pro_and_epilogue",
95620 + .ref_pass_instance_number = 1,
95621 + .pos_op = PASS_POS_INSERT_AFTER
95622 + };
95623 +
95624 + if (!plugin_default_version_check(version, &gcc_version)) {
95625 + error(G_("incompatible gcc/plugin versions"));
95626 + return 1;
95627 + }
95628 +
95629 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
95630 +
95631 + if (TARGET_64BIT == 0)
95632 + return 0;
95633 +
95634 + for (i = 0; i < argc; ++i) {
95635 + if (!strcmp(argv[i].key, "method")) {
95636 + if (!argv[i].value) {
95637 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95638 + continue;
95639 + }
95640 + if (!strcmp(argv[i].value, "bts")) {
95641 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
95642 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
95643 + } else if (!strcmp(argv[i].value, "or")) {
95644 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
95645 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
95646 + fix_register("r10", 1, 1);
95647 + } else
95648 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
95649 + continue;
95650 + }
95651 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95652 + }
95653 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
95654 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
95655 +
95656 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
95657 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
95658 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
95659 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
95660 +
95661 + return 0;
95662 +}
95663 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
95664 new file mode 100644
95665 index 0000000..b5395ba
95666 --- /dev/null
95667 +++ b/tools/gcc/latent_entropy_plugin.c
95668 @@ -0,0 +1,327 @@
95669 +/*
95670 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
95671 + * Licensed under the GPL v2
95672 + *
95673 + * Note: the choice of the license means that the compilation process is
95674 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95675 + * but for the kernel it doesn't matter since it doesn't link against
95676 + * any of the gcc libraries
95677 + *
95678 + * gcc plugin to help generate a little bit of entropy from program state,
95679 + * used during boot in the kernel
95680 + *
95681 + * TODO:
95682 + * - add ipa pass to identify not explicitly marked candidate functions
95683 + * - mix in more program state (function arguments/return values, loop variables, etc)
95684 + * - more instrumentation control via attribute parameters
95685 + *
95686 + * BUGS:
95687 + * - LTO needs -flto-partition=none for now
95688 + */
95689 +#include "gcc-plugin.h"
95690 +#include "config.h"
95691 +#include "system.h"
95692 +#include "coretypes.h"
95693 +#include "tree.h"
95694 +#include "tree-pass.h"
95695 +#include "flags.h"
95696 +#include "intl.h"
95697 +#include "toplev.h"
95698 +#include "plugin.h"
95699 +//#include "expr.h" where are you...
95700 +#include "diagnostic.h"
95701 +#include "plugin-version.h"
95702 +#include "tm.h"
95703 +#include "function.h"
95704 +#include "basic-block.h"
95705 +#include "gimple.h"
95706 +#include "rtl.h"
95707 +#include "emit-rtl.h"
95708 +#include "tree-flow.h"
95709 +#include "langhooks.h"
95710 +
95711 +#if BUILDING_GCC_VERSION >= 4008
95712 +#define TODO_dump_func 0
95713 +#endif
95714 +
95715 +int plugin_is_GPL_compatible;
95716 +
95717 +static tree latent_entropy_decl;
95718 +
95719 +static struct plugin_info latent_entropy_plugin_info = {
95720 + .version = "201303102320",
95721 + .help = NULL
95722 +};
95723 +
95724 +static unsigned int execute_latent_entropy(void);
95725 +static bool gate_latent_entropy(void);
95726 +
95727 +static struct gimple_opt_pass latent_entropy_pass = {
95728 + .pass = {
95729 + .type = GIMPLE_PASS,
95730 + .name = "latent_entropy",
95731 +#if BUILDING_GCC_VERSION >= 4008
95732 + .optinfo_flags = OPTGROUP_NONE,
95733 +#endif
95734 + .gate = gate_latent_entropy,
95735 + .execute = execute_latent_entropy,
95736 + .sub = NULL,
95737 + .next = NULL,
95738 + .static_pass_number = 0,
95739 + .tv_id = TV_NONE,
95740 + .properties_required = PROP_gimple_leh | PROP_cfg,
95741 + .properties_provided = 0,
95742 + .properties_destroyed = 0,
95743 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95744 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95745 + }
95746 +};
95747 +
95748 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95749 +{
95750 + if (TREE_CODE(*node) != FUNCTION_DECL) {
95751 + *no_add_attrs = true;
95752 + error("%qE attribute only applies to functions", name);
95753 + }
95754 + return NULL_TREE;
95755 +}
95756 +
95757 +static struct attribute_spec latent_entropy_attr = {
95758 + .name = "latent_entropy",
95759 + .min_length = 0,
95760 + .max_length = 0,
95761 + .decl_required = true,
95762 + .type_required = false,
95763 + .function_type_required = false,
95764 + .handler = handle_latent_entropy_attribute,
95765 +#if BUILDING_GCC_VERSION >= 4007
95766 + .affects_type_identity = false
95767 +#endif
95768 +};
95769 +
95770 +static void register_attributes(void *event_data, void *data)
95771 +{
95772 + register_attribute(&latent_entropy_attr);
95773 +}
95774 +
95775 +static bool gate_latent_entropy(void)
95776 +{
95777 + tree latent_entropy_attr;
95778 +
95779 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95780 + return latent_entropy_attr != NULL_TREE;
95781 +}
95782 +
95783 +static unsigned HOST_WIDE_INT seed;
95784 +static unsigned HOST_WIDE_INT get_random_const(void)
95785 +{
95786 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95787 + return seed;
95788 +}
95789 +
95790 +static enum tree_code get_op(tree *rhs)
95791 +{
95792 + static enum tree_code op;
95793 + unsigned HOST_WIDE_INT random_const;
95794 +
95795 + random_const = get_random_const();
95796 +
95797 + switch (op) {
95798 + case BIT_XOR_EXPR:
95799 + op = PLUS_EXPR;
95800 + break;
95801 +
95802 + case PLUS_EXPR:
95803 + if (rhs) {
95804 + op = LROTATE_EXPR;
95805 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95806 + break;
95807 + }
95808 +
95809 + case LROTATE_EXPR:
95810 + default:
95811 + op = BIT_XOR_EXPR;
95812 + break;
95813 + }
95814 + if (rhs)
95815 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95816 + return op;
95817 +}
95818 +
95819 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95820 +{
95821 + gimple_stmt_iterator gsi;
95822 + gimple assign;
95823 + tree addxorrol, rhs;
95824 + enum tree_code op;
95825 +
95826 + op = get_op(&rhs);
95827 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95828 + assign = gimple_build_assign(local_entropy, addxorrol);
95829 +#if BUILDING_GCC_VERSION <= 4007
95830 + find_referenced_vars_in(assign);
95831 +#endif
95832 +//debug_bb(bb);
95833 + gsi = gsi_after_labels(bb);
95834 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95835 + update_stmt(assign);
95836 +}
95837 +
95838 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95839 +{
95840 + gimple_stmt_iterator gsi;
95841 + gimple assign;
95842 + tree addxorrol, temp;
95843 +
95844 + // 1. create temporary copy of latent_entropy
95845 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95846 +#if BUILDING_GCC_VERSION <= 4007
95847 + add_referenced_var(temp);
95848 + mark_sym_for_renaming(temp);
95849 +#endif
95850 +
95851 + // 2. read...
95852 + assign = gimple_build_assign(temp, latent_entropy_decl);
95853 +#if BUILDING_GCC_VERSION <= 4007
95854 + find_referenced_vars_in(assign);
95855 +#endif
95856 + gsi = gsi_after_labels(bb);
95857 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95858 + update_stmt(assign);
95859 +
95860 + // 3. ...modify...
95861 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95862 + assign = gimple_build_assign(temp, addxorrol);
95863 +#if BUILDING_GCC_VERSION <= 4007
95864 + find_referenced_vars_in(assign);
95865 +#endif
95866 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95867 + update_stmt(assign);
95868 +
95869 + // 4. ...write latent_entropy
95870 + assign = gimple_build_assign(latent_entropy_decl, temp);
95871 +#if BUILDING_GCC_VERSION <= 4007
95872 + find_referenced_vars_in(assign);
95873 +#endif
95874 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95875 + update_stmt(assign);
95876 +}
95877 +
95878 +static unsigned int execute_latent_entropy(void)
95879 +{
95880 + basic_block bb;
95881 + gimple assign;
95882 + gimple_stmt_iterator gsi;
95883 + tree local_entropy;
95884 +
95885 + if (!latent_entropy_decl) {
95886 + struct varpool_node *node;
95887 +
95888 +#if BUILDING_GCC_VERSION <= 4007
95889 + for (node = varpool_nodes; node; node = node->next) {
95890 + tree var = node->decl;
95891 +#else
95892 + FOR_EACH_VARIABLE(node) {
95893 + tree var = node->symbol.decl;
95894 +#endif
95895 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95896 + continue;
95897 + latent_entropy_decl = var;
95898 +// debug_tree(var);
95899 + break;
95900 + }
95901 + if (!latent_entropy_decl) {
95902 +// debug_tree(current_function_decl);
95903 + return 0;
95904 + }
95905 + }
95906 +
95907 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95908 +
95909 + // 1. create local entropy variable
95910 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95911 +#if BUILDING_GCC_VERSION <= 4007
95912 + add_referenced_var(local_entropy);
95913 + mark_sym_for_renaming(local_entropy);
95914 +#endif
95915 +
95916 + // 2. initialize local entropy variable
95917 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95918 + if (dom_info_available_p(CDI_DOMINATORS))
95919 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95920 + gsi = gsi_start_bb(bb);
95921 +
95922 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95923 +// gimple_set_location(assign, loc);
95924 +#if BUILDING_GCC_VERSION <= 4007
95925 + find_referenced_vars_in(assign);
95926 +#endif
95927 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95928 + update_stmt(assign);
95929 + bb = bb->next_bb;
95930 +
95931 + // 3. instrument each BB with an operation on the local entropy variable
95932 + while (bb != EXIT_BLOCK_PTR) {
95933 + perturb_local_entropy(bb, local_entropy);
95934 + bb = bb->next_bb;
95935 + };
95936 +
95937 + // 4. mix local entropy into the global entropy variable
95938 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95939 + return 0;
95940 +}
95941 +
95942 +static void start_unit_callback(void *gcc_data, void *user_data)
95943 +{
95944 + tree latent_entropy_type;
95945 +
95946 +#if BUILDING_GCC_VERSION >= 4007
95947 + seed = get_random_seed(false);
95948 +#else
95949 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95950 + seed *= seed;
95951 +#endif
95952 +
95953 + if (in_lto_p)
95954 + return;
95955 +
95956 + // extern volatile u64 latent_entropy
95957 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95958 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95959 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95960 +
95961 + TREE_STATIC(latent_entropy_decl) = 1;
95962 + TREE_PUBLIC(latent_entropy_decl) = 1;
95963 + TREE_USED(latent_entropy_decl) = 1;
95964 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95965 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95966 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95967 + DECL_INITIAL(latent_entropy_decl) = NULL;
95968 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95969 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95970 +// varpool_finalize_decl(latent_entropy_decl);
95971 +// varpool_mark_needed_node(latent_entropy_decl);
95972 +}
95973 +
95974 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95975 +{
95976 + const char * const plugin_name = plugin_info->base_name;
95977 + struct register_pass_info latent_entropy_pass_info = {
95978 + .pass = &latent_entropy_pass.pass,
95979 + .reference_pass_name = "optimized",
95980 + .ref_pass_instance_number = 1,
95981 + .pos_op = PASS_POS_INSERT_BEFORE
95982 + };
95983 +
95984 + if (!plugin_default_version_check(version, &gcc_version)) {
95985 + error(G_("incompatible gcc/plugin versions"));
95986 + return 1;
95987 + }
95988 +
95989 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95990 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95991 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95992 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95993 +
95994 + return 0;
95995 +}
95996 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95997 new file mode 100644
95998 index 0000000..7982a0c
95999 --- /dev/null
96000 +++ b/tools/gcc/size_overflow_hash.data
96001 @@ -0,0 +1,5893 @@
96002 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
96003 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
96004 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
96005 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
96006 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
96007 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
96008 +padzero_55 padzero 1 55 &sel_read_policyvers_55
96009 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
96010 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
96011 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
96012 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
96013 +load_msg_95 load_msg 2 95 NULL
96014 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
96015 +init_q_132 init_q 4 132 NULL
96016 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
96017 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
96018 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
96019 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
96020 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
96021 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
96022 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
96023 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
96024 +br_port_info_size_268 br_port_info_size 0 268 NULL
96025 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
96026 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
96027 +syslog_print_307 syslog_print 2 307 NULL
96028 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
96029 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
96030 +next_node_allowed_318 next_node_allowed 1 318 NULL
96031 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
96032 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
96033 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
96034 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
96035 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
96036 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
96037 +pidlist_resize_496 pidlist_resize 2 496 NULL
96038 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
96039 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
96040 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
96041 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
96042 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
96043 +dle_count_543 dle_count 0 543 NULL
96044 +devres_alloc_551 devres_alloc 2 551 NULL
96045 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
96046 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
96047 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
96048 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
96049 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
96050 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
96051 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
96052 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
96053 +isp1760_register_628 isp1760_register 1-2 628 NULL
96054 +clone_split_bio_633 clone_split_bio 6 633 NULL
96055 +remap_to_cache_640 remap_to_cache 3 640 NULL
96056 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
96057 +unlink_queued_645 unlink_queued 3-4 645 NULL
96058 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
96059 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
96060 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
96061 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
96062 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
96063 +disk_max_parts_719 disk_max_parts 0 719 NULL
96064 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
96065 +dvb_video_write_754 dvb_video_write 3 754 NULL
96066 +if_writecmd_815 if_writecmd 2 815 NULL
96067 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
96068 +read_fifo_826 read_fifo 3 826 NULL
96069 +um_idi_read_850 um_idi_read 3 850 NULL
96070 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
96071 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
96072 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
96073 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
96074 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
96075 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
96076 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
96077 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
96078 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
96079 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
96080 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
96081 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
96082 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
96083 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
96084 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
96085 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
96086 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
96087 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
96088 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
96089 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
96090 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
96091 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
96092 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
96093 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
96094 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
96095 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
96096 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
96097 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
96098 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
96099 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
96100 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
96101 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
96102 +nested_get_page_1252 nested_get_page 2 1252 NULL
96103 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
96104 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
96105 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
96106 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
96107 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
96108 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
96109 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
96110 +ffs_1322 ffs 0 1322 NULL
96111 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
96112 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
96113 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
96114 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
96115 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
96116 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
96117 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
96118 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
96119 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
96120 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
96121 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
96122 +zone_page_state_1393 zone_page_state 0 1393 NULL
96123 +file_read_actor_1401 file_read_actor 4 1401 NULL
96124 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
96125 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
96126 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
96127 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
96128 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
96129 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
96130 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
96131 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
96132 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
96133 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
96134 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
96135 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
96136 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
96137 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
96138 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
96139 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
96140 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
96141 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
96142 +rmap_add_1677 rmap_add 3 1677 NULL
96143 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
96144 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
96145 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
96146 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
96147 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
96148 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
96149 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
96150 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
96151 +cosa_write_1774 cosa_write 3 1774 NULL
96152 +update_macheader_1775 update_macheader 7 1775 NULL
96153 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
96154 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
96155 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
96156 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
96157 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
96158 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
96159 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
96160 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
96161 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
96162 +read_swap_header_1957 read_swap_header 0 1957 NULL
96163 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
96164 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
96165 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
96166 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
96167 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
96168 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
96169 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
96170 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
96171 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
96172 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
96173 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
96174 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
96175 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
96176 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
96177 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
96178 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
96179 +audit_expand_2098 audit_expand 2 2098 NULL
96180 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
96181 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
96182 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
96183 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
96184 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
96185 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
96186 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
96187 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
96188 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
96189 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
96190 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
96191 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
96192 +u32_array_read_2219 u32_array_read 3 2219 NULL
96193 +vhci_write_2224 vhci_write 3 2224 NULL
96194 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
96195 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
96196 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
96197 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
96198 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
96199 +do_update_counters_2259 do_update_counters 4 2259 NULL
96200 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
96201 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
96202 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
96203 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
96204 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
96205 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
96206 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
96207 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
96208 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
96209 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
96210 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
96211 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
96212 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
96213 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
96214 +raid1_size_2419 raid1_size 0-2 2419 NULL
96215 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
96216 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
96217 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
96218 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
96219 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
96220 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
96221 +update_pmkid_2481 update_pmkid 4 2481 NULL
96222 +wiphy_new_2482 wiphy_new 2 2482 NULL
96223 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
96224 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
96225 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
96226 +dm_write_2513 dm_write 3 2513 NULL
96227 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
96228 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
96229 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
96230 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
96231 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
96232 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
96233 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
96234 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
96235 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
96236 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
96237 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
96238 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
96239 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
96240 +__next_cpu_2782 __next_cpu 1 2782 NULL
96241 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
96242 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
96243 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
96244 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
96245 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
96246 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
96247 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
96248 +mq_map_2871 mq_map 2 2871 NULL
96249 +nla_padlen_2883 nla_padlen 1 2883 NULL
96250 +cmm_write_2896 cmm_write 3 2896 NULL
96251 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
96252 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
96253 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
96254 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
96255 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
96256 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
96257 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
96258 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
96259 +depth_write_3021 depth_write 3 3021 NULL
96260 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
96261 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
96262 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
96263 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
96264 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
96265 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
96266 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
96267 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
96268 +free_coherent_3082 free_coherent 4-2 3082 NULL
96269 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
96270 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
96271 +rb_alloc_3102 rb_alloc 1 3102 NULL
96272 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
96273 +print_time_3132 print_time 0 3132 NULL
96274 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
96275 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
96276 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
96277 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
96278 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
96279 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
96280 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
96281 +alloc_context_3194 alloc_context 1 3194 NULL
96282 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
96283 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
96284 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
96285 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
96286 +key_key_read_3241 key_key_read 3 3241 NULL
96287 +number_3243 number 0 3243 NULL
96288 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
96289 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
96290 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
96291 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
96292 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
96293 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
96294 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
96295 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
96296 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
96297 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
96298 +scnprintf_3360 scnprintf 0-2 3360 NULL
96299 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
96300 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
96301 +send_stream_3397 send_stream 4 3397 NULL
96302 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
96303 +msix_map_region_3411 msix_map_region 3 3411 NULL
96304 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
96305 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
96306 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
96307 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
96308 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
96309 +map_single_3449 map_single 0-2 3449 NULL
96310 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
96311 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
96312 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
96313 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
96314 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
96315 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
96316 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
96317 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
96318 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
96319 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
96320 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
96321 +evtchn_read_3569 evtchn_read 3 3569 NULL
96322 +vc_resize_3585 vc_resize 2-3 3585 NULL
96323 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
96324 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
96325 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
96326 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
96327 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
96328 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 NULL
96329 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
96330 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
96331 +create_irq_3703 create_irq 0 3703 NULL nohasharray
96332 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
96333 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
96334 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
96335 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
96336 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
96337 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
96338 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
96339 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
96340 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
96341 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
96342 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
96343 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
96344 +get_fd_set_3866 get_fd_set 1 3866 NULL
96345 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
96346 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
96347 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
96348 +nvram_write_3894 nvram_write 3 3894 NULL
96349 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
96350 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
96351 +vcs_write_3910 vcs_write 3 3910 NULL
96352 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
96353 +do_add_counters_3992 do_add_counters 3 3992 NULL
96354 +userspace_status_4004 userspace_status 4 4004 NULL
96355 +mei_write_4005 mei_write 3 4005 NULL nohasharray
96356 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
96357 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
96358 +mm_populate_4016 mm_populate 1 4016 NULL
96359 +blk_end_request_4024 blk_end_request 3 4024 NULL
96360 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
96361 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
96362 +read_file_queues_4078 read_file_queues 3 4078 NULL
96363 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
96364 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
96365 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
96366 +tm6000_read_4151 tm6000_read 3 4151 NULL
96367 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
96368 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
96369 +get_alua_req_4166 get_alua_req 3 4166 NULL
96370 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
96371 +read_file_bool_4180 read_file_bool 3 4180 NULL
96372 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
96373 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
96374 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
96375 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
96376 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
96377 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
96378 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
96379 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
96380 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
96381 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
96382 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
96383 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
96384 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
96385 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
96386 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
96387 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
96388 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
96389 +memparse_4444 memparse 0 4444 NULL
96390 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
96391 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
96392 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
96393 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
96394 +set_link_security_4502 set_link_security 4 4502 NULL
96395 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
96396 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
96397 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
96398 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
96399 +tty_register_device_4544 tty_register_device 2 4544 NULL
96400 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
96401 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
96402 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
96403 +bch_alloc_4593 bch_alloc 1 4593 NULL
96404 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
96405 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
96406 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
96407 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
96408 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
96409 +kone_receive_4690 kone_receive 4 4690 NULL
96410 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
96411 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
96412 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
96413 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
96414 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
96415 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
96416 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
96417 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
96418 +create_subvol_4791 create_subvol 4 4791 NULL
96419 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
96420 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
96421 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
96422 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
96423 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
96424 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
96425 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
96426 +sys_ipc_4889 sys_ipc 3 4889 NULL
96427 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
96428 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
96429 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
96430 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
96431 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
96432 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
96433 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
96434 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
96435 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
96436 +do_mincore_5018 do_mincore 0-1 5018 NULL
96437 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
96438 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
96439 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
96440 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
96441 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
96442 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
96443 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
96444 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
96445 +sound_write_5102 sound_write 3 5102 NULL
96446 +clear_dirty_5105 clear_dirty 3 5105 NULL
96447 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
96448 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
96449 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
96450 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
96451 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
96452 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
96453 +skb_network_header_5203 skb_network_header 0 5203 NULL
96454 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
96455 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
96456 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
96457 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
96458 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
96459 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
96460 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
96461 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
96462 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
96463 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
96464 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
96465 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
96466 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
96467 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
96468 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
96469 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
96470 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
96471 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
96472 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
96473 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
96474 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
96475 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
96476 +tty_write_5494 tty_write 3 5494 NULL
96477 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
96478 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
96479 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
96480 +spidev_message_5518 spidev_message 3 5518 NULL
96481 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
96482 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
96483 +le_readq_5557 le_readq 0 5557 NULL
96484 +inw_5558 inw 0 5558 NULL
96485 +fir16_create_5574 fir16_create 3 5574 NULL
96486 +bioset_create_5580 bioset_create 1 5580 NULL
96487 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
96488 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
96489 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
96490 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
96491 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
96492 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
96493 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
96494 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
96495 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
96496 +get_arg_5694 get_arg 3 5694 NULL
96497 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
96498 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
96499 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
96500 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
96501 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
96502 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
96503 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
96504 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
96505 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
96506 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
96507 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
96508 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
96509 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
96510 +setup_req_5848 setup_req 3 5848 NULL
96511 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
96512 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
96513 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
96514 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
96515 +port_show_regs_5904 port_show_regs 3 5904 NULL
96516 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
96517 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
96518 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
96519 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
96520 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
96521 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
96522 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
96523 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
96524 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
96525 +native_pte_val_5978 native_pte_val 0 5978 NULL
96526 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
96527 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
96528 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
96529 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
96530 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
96531 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
96532 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
96533 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
96534 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
96535 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
96536 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
96537 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
96538 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
96539 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
96540 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
96541 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
96542 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
96543 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
96544 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
96545 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
96546 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
96547 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
96548 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
96549 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
96550 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
96551 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
96552 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
96553 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
96554 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
96555 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
96556 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
96557 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
96558 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
96559 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
96560 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
96561 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
96562 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
96563 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
96564 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
96565 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
96566 +mei_read_6507 mei_read 3 6507 NULL
96567 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
96568 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
96569 +wdm_read_6549 wdm_read 3 6549 NULL
96570 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
96571 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
96572 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
96573 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
96574 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
96575 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
96576 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
96577 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
96578 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
96579 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
96580 +mpeg_read_6708 mpeg_read 3 6708 NULL
96581 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
96582 +video_proc_write_6724 video_proc_write 3 6724 NULL
96583 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
96584 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
96585 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
96586 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
96587 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
96588 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
96589 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
96590 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
96591 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
96592 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
96593 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
96594 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
96595 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
96596 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
96597 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
96598 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
96599 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
96600 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
96601 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
96602 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
96603 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
96604 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
96605 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
96606 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
96607 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
96608 +request_key_async_6990 request_key_async 4 6990 NULL
96609 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
96610 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
96611 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
96612 +wimax_msg_7030 wimax_msg 4 7030 NULL
96613 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
96614 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
96615 +event_enable_read_7074 event_enable_read 3 7074 NULL
96616 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
96617 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
96618 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
96619 +check_header_7108 check_header 0 7108 NULL
96620 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
96621 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
96622 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
96623 +get_param_h_7247 get_param_h 0 7247 NULL
96624 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
96625 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
96626 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
96627 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
96628 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
96629 +mgmt_control_7349 mgmt_control 3 7349 NULL
96630 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
96631 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
96632 +hweight_long_7388 hweight_long 0-1 7388 NULL
96633 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
96634 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
96635 +readb_7401 readb 0 7401 NULL
96636 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
96637 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
96638 +numa_emulation_7466 numa_emulation 2 7466 NULL
96639 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
96640 +garp_request_join_7471 garp_request_join 4 7471 NULL
96641 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
96642 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
96643 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
96644 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
96645 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
96646 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
96647 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
96648 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
96649 +groups_alloc_7614 groups_alloc 1 7614 NULL
96650 +sg_virt_7616 sg_virt 0 7616 NULL
96651 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
96652 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
96653 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
96654 +dev_write_7708 dev_write 3 7708 NULL
96655 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
96656 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
96657 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
96658 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
96659 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
96660 +ioread32be_7773 ioread32be 0 7773 NULL
96661 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
96662 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
96663 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
96664 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
96665 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
96666 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
96667 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
96668 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
96669 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
96670 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
96671 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
96672 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
96673 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
96674 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
96675 +sys_mbind_7990 sys_mbind 5 7990 NULL
96676 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
96677 +vcs_read_8017 vcs_read 3 8017 NULL
96678 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
96679 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
96680 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
96681 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
96682 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
96683 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
96684 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
96685 +venus_lookup_8121 venus_lookup 4 8121 NULL
96686 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
96687 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
96688 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
96689 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
96690 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
96691 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
96692 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
96693 +play_iframe_8219 play_iframe 3 8219 NULL
96694 +create_log_8225 create_log 2 8225 NULL nohasharray
96695 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
96696 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
96697 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
96698 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
96699 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
96700 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
96701 +init_cdev_8274 init_cdev 1 8274 NULL
96702 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
96703 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
96704 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
96705 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
96706 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
96707 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
96708 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
96709 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
96710 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
96711 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
96712 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
96713 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
96714 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
96715 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96716 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96717 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96718 +dev_config_8506 dev_config 3 8506 NULL
96719 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96720 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96721 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96722 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96723 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96724 +profile_remove_8556 profile_remove 3 8556 NULL
96725 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96726 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96727 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96728 +tower_write_8580 tower_write 3 8580 NULL
96729 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96730 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96731 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96732 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96733 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96734 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96735 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96736 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96737 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96738 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96739 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96740 +arcfb_write_8702 arcfb_write 3 8702 NULL
96741 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96742 +init_header_8703 init_header 0 8703 &i_size_read_8703
96743 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96744 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
96745 +f_dupfd_8730 f_dupfd 1 8730 NULL
96746 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
96747 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
96748 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
96749 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
96750 +sys_prctl_8766 sys_prctl 4 8766 NULL
96751 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
96752 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
96753 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
96754 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
96755 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
96756 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
96757 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
96758 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
96759 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
96760 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
96761 +clear_bitset_8840 clear_bitset 2 8840 NULL
96762 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
96763 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
96764 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
96765 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96766 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96767 +layout_commit_8926 layout_commit 3 8926 NULL
96768 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96769 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96770 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96771 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96772 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96773 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96774 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96775 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96776 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96777 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96778 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96779 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96780 +nla_put_9042 nla_put 3 9042 NULL
96781 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96782 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96783 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96784 +string_9080 string 0 9080 NULL
96785 +create_queues_9088 create_queues 2-3 9088 NULL
96786 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96787 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96788 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96789 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96790 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
96791 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
96792 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96793 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96794 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96795 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96796 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96797 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96798 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96799 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96800 +get_pfn_9207 get_pfn 1 9207 NULL
96801 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96802 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96803 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96804 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96805 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96806 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96807 +flakey_status_9274 flakey_status 5 9274 NULL
96808 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96809 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96810 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96811 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
96812 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96813 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96814 +read_9397 read 3 9397 NULL
96815 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96816 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96817 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96818 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96819 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96820 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96821 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96822 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96823 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96824 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96825 +lp_write_9511 lp_write 3 9511 NULL
96826 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
96827 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96828 +read_file_dma_9530 read_file_dma 3 9530 NULL
96829 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96830 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96831 +fw_node_create_9559 fw_node_create 2 9559 NULL
96832 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
96833 +kobj_map_9566 kobj_map 2-3 9566 NULL
96834 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96835 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96836 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96837 +do_sync_9604 do_sync 1 9604 NULL
96838 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96839 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96840 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
96841 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96842 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96843 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96844 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96845 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96846 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96847 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96848 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96849 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96850 +is_hole_9694 is_hole 2 9694 NULL nohasharray
96851 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
96852 +fnb_9703 fnb 2-3 9703 NULL
96853 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
96854 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
96855 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96856 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96857 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96858 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96859 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96860 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96861 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96862 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96863 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96864 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96865 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96866 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96867 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96868 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96869 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96870 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96871 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96872 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96873 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96874 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96875 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96876 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96877 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
96878 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96879 +read_file_misc_9948 read_file_misc 3 9948 NULL
96880 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96881 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96882 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96883 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96884 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96885 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96886 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96887 +handle_request_10024 handle_request 9 10024 NULL
96888 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96889 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96890 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
96891 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96892 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96893 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96894 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96895 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
96896 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
96897 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96898 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96899 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96900 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96901 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96902 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96903 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96904 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96905 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96906 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96907 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96908 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96909 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96910 +read_emulate_10310 read_emulate 2-4 10310 NULL
96911 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
96912 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96913 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96914 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96915 +get_dump_page_10338 get_dump_page 1 10338 NULL
96916 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96917 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96918 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96919 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96920 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96921 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96922 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96923 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96924 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96925 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96926 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96927 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96928 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96929 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96930 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96931 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96932 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96933 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
96934 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96935 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96936 +otp_read_10594 otp_read 2-4-5 10594 NULL
96937 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96938 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96939 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96940 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96941 +parport_write_10669 parport_write 0 10669 NULL
96942 +inl_10708 inl 0 10708 NULL nohasharray
96943 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96944 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96945 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96946 +spi_sync_10731 spi_sync 0 10731 NULL
96947 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96948 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96949 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96950 +sys_syslog_10746 sys_syslog 3 10746 NULL
96951 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96952 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96953 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
96954 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
96955 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
96956 +sys_bind_10799 sys_bind 3 10799 NULL
96957 +compat_put_int_10828 compat_put_int 1 10828 NULL
96958 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96959 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96960 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96961 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96962 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96963 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96964 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96965 +get_scq_10897 get_scq 2 10897 NULL
96966 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96967 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96968 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96969 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96970 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96971 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96972 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96973 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96974 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96975 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96976 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96977 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96978 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96979 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96980 +count_argc_11083 count_argc 0 11083 NULL
96981 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96982 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96983 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96984 +page_offset_11120 page_offset 0 11120 NULL
96985 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96986 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96987 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96988 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96989 +__swab16p_11220 __swab16p 0 11220 NULL
96990 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96991 +mmap_region_11247 mmap_region 0-2 11247 NULL
96992 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96993 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
96994 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96995 +cru_detect_11272 cru_detect 1 11272 NULL
96996 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96997 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96998 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96999 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
97000 +next_segment_11330 next_segment 0-2-1 11330 NULL
97001 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
97002 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
97003 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
97004 +sel_write_create_11353 sel_write_create 3 11353 NULL
97005 +handle_unit_11355 handle_unit 0-1 11355 NULL
97006 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
97007 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
97008 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
97009 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
97010 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
97011 +str_to_user_11411 str_to_user 2 11411 NULL
97012 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
97013 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
97014 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
97015 +trace_options_read_11419 trace_options_read 3 11419 NULL
97016 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
97017 +prepare_image_11424 prepare_image 0 11424 NULL
97018 +vring_size_11426 vring_size 0-1-2 11426 NULL
97019 +bttv_read_11432 bttv_read 3 11432 NULL
97020 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
97021 +swp_offset_11475 swp_offset 0 11475 NULL
97022 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
97023 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
97024 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
97025 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
97026 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
97027 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
97028 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
97029 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
97030 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
97031 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
97032 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
97033 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
97034 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
97035 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
97036 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
97037 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
97038 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
97039 +split_11691 split 2 11691 NULL
97040 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
97041 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
97042 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
97043 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
97044 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
97045 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
97046 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
97047 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
97048 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
97049 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
97050 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
97051 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
97052 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
97053 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
97054 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
97055 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
97056 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
97057 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
97058 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
97059 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
97060 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
97061 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
97062 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
97063 +atmel_read16_11981 atmel_read16 0 11981 NULL
97064 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
97065 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
97066 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
97067 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
97068 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
97069 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
97070 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
97071 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
97072 +set_powered_12129 set_powered 4 12129 NULL
97073 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
97074 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
97075 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
97076 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
97077 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
97078 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
97079 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
97080 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
97081 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
97082 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
97083 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
97084 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
97085 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
97086 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
97087 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
97088 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
97089 +receive_copy_12216 receive_copy 3 12216 NULL
97090 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
97091 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
97092 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
97093 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
97094 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
97095 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
97096 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
97097 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
97098 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
97099 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
97100 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
97101 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
97102 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
97103 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
97104 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
97105 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
97106 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
97107 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
97108 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
97109 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
97110 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
97111 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
97112 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
97113 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
97114 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
97115 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
97116 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
97117 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
97118 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
97119 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
97120 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
97121 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
97122 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
97123 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
97124 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
97125 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
97126 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
97127 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
97128 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
97129 +wb_create_12651 wb_create 1 12651 NULL
97130 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
97131 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
97132 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
97133 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
97134 +ivtv_write_12721 ivtv_write 3 12721 NULL
97135 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
97136 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
97137 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
97138 +listxattr_12769 listxattr 3 12769 NULL
97139 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
97140 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
97141 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
97142 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
97143 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
97144 +readq_12825 readq 0 12825 NULL
97145 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
97146 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
97147 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
97148 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
97149 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
97150 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
97151 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
97152 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
97153 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
97154 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
97155 +bm_status_write_12964 bm_status_write 3 12964 NULL
97156 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
97157 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
97158 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
97159 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
97160 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
97161 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
97162 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
97163 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
97164 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
97165 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
97166 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
97167 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
97168 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
97169 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
97170 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
97171 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
97172 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
97173 +blk_update_request_13146 blk_update_request 3 13146 NULL
97174 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
97175 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
97176 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
97177 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
97178 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
97179 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
97180 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
97181 +comedi_read_13199 comedi_read 3 13199 NULL
97182 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
97183 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
97184 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
97185 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
97186 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
97187 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
97188 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
97189 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
97190 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
97191 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
97192 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
97193 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
97194 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
97195 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
97196 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
97197 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
97198 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
97199 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
97200 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
97201 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
97202 +cache_ctr_13364 cache_ctr 2 13364 NULL
97203 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
97204 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
97205 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
97206 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
97207 +sky2_receive_13407 sky2_receive 2 13407 NULL
97208 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
97209 +keyring_read_13438 keyring_read 3 13438 NULL
97210 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
97211 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
97212 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
97213 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
97214 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
97215 +core_status_13515 core_status 4 13515 NULL
97216 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
97217 +bm_init_13529 bm_init 2 13529 NULL
97218 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL
97219 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
97220 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
97221 +sys_madvise_13569 sys_madvise 1 13569 NULL
97222 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
97223 +cache_write_13589 cache_write 3 13589 NULL
97224 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
97225 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
97226 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
97227 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
97228 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
97229 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
97230 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
97231 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
97232 +packet_snd_13634 packet_snd 3 13634 NULL
97233 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
97234 +cache_downcall_13666 cache_downcall 3 13666 NULL
97235 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
97236 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
97237 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
97238 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
97239 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
97240 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
97241 +random_read_13815 random_read 3 13815 NULL
97242 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
97243 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
97244 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
97245 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
97246 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
97247 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
97248 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
97249 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
97250 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
97251 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
97252 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
97253 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
97254 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
97255 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
97256 +com90xx_found_13974 com90xx_found 3 13974 NULL
97257 +qcam_read_13977 qcam_read 3 13977 NULL
97258 +dsp_read_13980 dsp_read 2 13980 NULL
97259 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
97260 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
97261 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
97262 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
97263 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
97264 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
97265 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
97266 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
97267 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
97268 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
97269 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
97270 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
97271 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
97272 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
97273 +em_canid_change_14150 em_canid_change 3 14150 NULL
97274 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
97275 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
97276 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
97277 +alloc_async_14208 alloc_async 1 14208 NULL
97278 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
97279 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
97280 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
97281 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
97282 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
97283 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
97284 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
97285 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
97286 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
97287 +rr_status_14293 rr_status 5 14293 NULL
97288 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
97289 +oo_objects_14319 oo_objects 0 14319 NULL
97290 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
97291 +scsi2int_14358 scsi2int 0 14358 NULL
97292 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
97293 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
97294 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
97295 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
97296 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
97297 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
97298 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
97299 +block_size_14443 block_size 0 14443 NULL
97300 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
97301 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
97302 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
97303 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
97304 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
97305 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
97306 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
97307 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
97308 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
97309 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
97310 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
97311 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
97312 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
97313 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
97314 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
97315 +dbJoin_14644 dbJoin 0 14644 NULL
97316 +profile_replace_14652 profile_replace 3 14652 NULL
97317 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
97318 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
97319 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
97320 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
97321 +get_bio_block_14714 get_bio_block 0 14714 NULL
97322 +vfd_write_14717 vfd_write 3 14717 NULL
97323 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
97324 +raid1_resize_14740 raid1_resize 2 14740 NULL
97325 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
97326 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
97327 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
97328 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
97329 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
97330 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
97331 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
97332 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
97333 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
97334 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
97335 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
97336 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
97337 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
97338 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
97339 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
97340 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
97341 +unifi_read_14899 unifi_read 3 14899 NULL
97342 +krealloc_14908 krealloc 2 14908 NULL
97343 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
97344 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
97345 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
97346 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
97347 +queue_cnt_14951 queue_cnt 0 14951 NULL
97348 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
97349 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
97350 +setkey_14987 setkey 3 14987 NULL nohasharray
97351 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
97352 +vmap_15025 vmap 2 15025 NULL
97353 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
97354 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
97355 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
97356 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
97357 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
97358 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
97359 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
97360 +start_port_15124 start_port 0 15124 NULL
97361 +memchr_15126 memchr 0 15126 NULL
97362 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
97363 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
97364 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
97365 +reserve_resources_15194 reserve_resources 3 15194 NULL
97366 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
97367 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
97368 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
97369 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
97370 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
97371 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
97372 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
97373 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
97374 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
97375 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
97376 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
97377 +ioread16_15342 ioread16 0 15342 NULL
97378 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
97379 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
97380 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
97381 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
97382 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
97383 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
97384 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
97385 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
97386 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
97387 +get_modalias_15406 get_modalias 2 15406 NULL
97388 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
97389 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
97390 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
97391 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
97392 +memweight_15450 memweight 2 15450 NULL
97393 +vmalloc_15464 vmalloc 1 15464 NULL
97394 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
97395 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
97396 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
97397 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
97398 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
97399 +persistent_status_15574 persistent_status 4 15574 NULL
97400 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
97401 +vme_user_write_15587 vme_user_write 3 15587 NULL
97402 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
97403 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
97404 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
97405 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
97406 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
97407 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
97408 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
97409 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
97410 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
97411 +fs_path_add_15648 fs_path_add 3 15648 NULL
97412 +xsd_read_15653 xsd_read 3 15653 NULL
97413 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
97414 +unix_bind_15668 unix_bind 3 15668 NULL
97415 +dm_read_15674 dm_read 3 15674 NULL
97416 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
97417 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
97418 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
97419 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
97420 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
97421 +do_test_15766 do_test 1 15766 NULL
97422 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
97423 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
97424 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
97425 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
97426 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
97427 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
97428 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
97429 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
97430 +table_size_15851 table_size 0-1-2 15851 NULL
97431 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
97432 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
97433 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
97434 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
97435 +native_read_msr_15905 native_read_msr 0 15905 NULL
97436 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
97437 +power_read_15939 power_read 3 15939 NULL
97438 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
97439 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
97440 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
97441 +frame_alloc_15981 frame_alloc 4 15981 NULL
97442 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
97443 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
97444 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
97445 +got_frame_16028 got_frame 2 16028 NULL
97446 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
97447 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
97448 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
97449 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
97450 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
97451 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
97452 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
97453 +fsm_init_16134 fsm_init 2 16134 NULL
97454 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
97455 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
97456 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
97457 +mapping_level_16188 mapping_level 2 16188 NULL
97458 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
97459 +create_table_16213 create_table 2 16213 NULL
97460 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
97461 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
97462 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
97463 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
97464 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
97465 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
97466 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
97467 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
97468 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
97469 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
97470 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
97471 +account_16283 account 0-2-4 16283 NULL nohasharray
97472 +mirror_status_16283 mirror_status 5 16283 &account_16283
97473 +retry_instruction_16285 retry_instruction 2 16285 NULL
97474 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
97475 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
97476 +wb_map_16301 wb_map 2 16301 NULL
97477 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
97478 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
97479 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
97480 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
97481 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
97482 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
97483 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
97484 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
97485 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
97486 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
97487 +raid10_resize_16537 raid10_resize 2 16537 NULL
97488 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
97489 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
97490 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
97491 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
97492 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
97493 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
97494 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
97495 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
97496 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
97497 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
97498 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
97499 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
97500 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
97501 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
97502 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
97503 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
97504 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
97505 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
97506 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
97507 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
97508 +st_write_16874 st_write 3 16874 NULL
97509 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
97510 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
97511 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
97512 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
97513 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
97514 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
97515 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
97516 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
97517 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
97518 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
97519 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
97520 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
97521 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
97522 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
97523 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
97524 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
97525 +mac_address_string_17091 mac_address_string 0 17091 NULL
97526 +entry_length_17093 entry_length 0 17093 NULL
97527 +sys_preadv_17100 sys_preadv 3 17100 NULL
97528 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
97529 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
97530 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
97531 +sep_read_17161 sep_read 3 17161 NULL
97532 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
97533 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
97534 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
97535 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
97536 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
97537 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
97538 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
97539 +to_oblock_17254 to_oblock 0-1 17254 NULL
97540 +unpack_value_17259 unpack_value 1 17259 NULL
97541 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
97542 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
97543 +alloc_ep_17269 alloc_ep 1 17269 NULL
97544 +pg_read_17276 pg_read 3 17276 NULL
97545 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
97546 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
97547 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
97548 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
97549 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
97550 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
97551 +skb_pad_17302 skb_pad 2 17302 NULL
97552 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
97553 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
97554 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
97555 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
97556 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
97557 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
97558 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
97559 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
97560 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
97561 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
97562 +compat_cmd_17465 compat_cmd 2 17465 NULL
97563 +probe_bios_17467 probe_bios 1 17467 NULL
97564 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
97565 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
97566 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
97567 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
97568 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
97569 +copy_from_user_17559 copy_from_user 3 17559 NULL
97570 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
97571 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
97572 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
97573 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
97574 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
97575 +osst_execute_17607 osst_execute 7-6 17607 NULL
97576 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
97577 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
97578 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
97579 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
97580 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
97581 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
97582 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
97583 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
97584 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
97585 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
97586 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
97587 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
97588 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
97589 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
97590 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
97591 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
97592 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
97593 +count_leafs_17842 count_leafs 0 17842 NULL
97594 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
97595 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
97596 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
97597 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
97598 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
97599 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
97600 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
97601 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
97602 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
97603 +recover_head_17904 recover_head 3 17904 NULL
97604 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
97605 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
97606 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
97607 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
97608 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
97609 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
97610 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
97611 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
97612 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
97613 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
97614 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
97615 +fill_read_18019 fill_read 0 18019 NULL
97616 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
97617 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
97618 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
97619 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
97620 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
97621 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
97622 +packet_came_18072 packet_came 3 18072 NULL
97623 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
97624 +get_vm_area_18080 get_vm_area 1 18080 NULL
97625 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
97626 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
97627 +svc_getnl_18120 svc_getnl 0 18120 NULL
97628 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
97629 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
97630 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
97631 +_has_tag_18169 _has_tag 2 18169 NULL
97632 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
97633 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
97634 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
97635 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
97636 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
97637 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
97638 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
97639 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
97640 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
97641 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
97642 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
97643 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
97644 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
97645 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
97646 +um_idi_write_18293 um_idi_write 3 18293 NULL
97647 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
97648 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
97649 +vga_r_18310 vga_r 0 18310 NULL
97650 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
97651 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
97652 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
97653 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
97654 +ep_io_18367 ep_io 0 18367 NULL
97655 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
97656 +__video_register_device_18399 __video_register_device 3 18399 NULL
97657 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
97658 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
97659 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
97660 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
97661 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
97662 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
97663 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
97664 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
97665 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
97666 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
97667 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
97668 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
97669 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
97670 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
97671 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
97672 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
97673 +debug_output_18575 debug_output 3 18575 NULL
97674 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
97675 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
97676 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL
97677 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
97678 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
97679 +from_buffer_18625 from_buffer 3 18625 NULL
97680 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
97681 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
97682 +unmap_page_18665 unmap_page 2-3 18665 NULL
97683 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
97684 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
97685 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
97686 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
97687 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
97688 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
97689 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
97690 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
97691 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
97692 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
97693 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
97694 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
97695 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
97696 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
97697 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
97698 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
97699 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
97700 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
97701 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
97702 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
97703 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
97704 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
97705 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
97706 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97707 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
97708 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97709 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97710 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97711 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97712 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97713 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
97714 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97715 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97716 +huge_page_size_19008 huge_page_size 0 19008 NULL
97717 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97718 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97719 +revalidate_19043 revalidate 2 19043 NULL
97720 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97721 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97722 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97723 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97724 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97725 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97726 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97727 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97728 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97729 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97730 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97731 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97732 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97733 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97734 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97735 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97736 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97737 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97738 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97739 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97740 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97741 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97742 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97743 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97744 +qc_capture_19298 qc_capture 3 19298 NULL
97745 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97746 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97747 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
97748 +debug_read_19322 debug_read 3 19322 NULL
97749 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
97750 +read_zero_19366 read_zero 3 19366 NULL
97751 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
97752 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
97753 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
97754 +__phys_addr_19434 __phys_addr 0 19434 NULL
97755 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
97756 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97757 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97758 +sky2_read16_19475 sky2_read16 0 19475 NULL
97759 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97760 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97761 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97762 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97763 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97764 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97765 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97766 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97767 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97768 +nfsd_read_19568 nfsd_read 5 19568 NULL
97769 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97770 +bm_status_read_19583 bm_status_read 3 19583 NULL
97771 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97772 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97773 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97774 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97775 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97776 +bio_detain_19690 bio_detain 2 19690 NULL
97777 +read_reg_19723 read_reg 0 19723 NULL
97778 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97779 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97780 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97781 +p9_client_read_19750 p9_client_read 5 19750 NULL
97782 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97783 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97784 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97785 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97786 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97787 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97788 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97789 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
97790 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97791 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97792 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97793 +__nla_put_19857 __nla_put 3 19857 NULL
97794 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97795 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
97796 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97797 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97798 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97799 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97800 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97801 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97802 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97803 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97804 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97805 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97806 +team_options_register_20091 team_options_register 3 20091 NULL
97807 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97808 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97809 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97810 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97811 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97812 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97813 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
97814 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97815 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97816 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97817 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97818 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97819 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97820 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97821 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97822 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97823 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
97824 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97825 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97826 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97827 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97828 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97829 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
97830 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97831 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97832 +read_buf_20469 read_buf 2 20469 NULL
97833 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97834 +fast_user_write_20494 fast_user_write 5 20494 NULL
97835 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97836 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97837 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97838 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97839 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97840 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97841 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97842 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97843 +venus_create_20555 venus_create 4 20555 NULL
97844 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97845 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97846 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97847 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97848 +lirc_write_20604 lirc_write 3 20604 NULL
97849 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97850 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97851 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97852 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97853 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97854 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97855 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97856 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
97857 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
97858 +cpumask_size_20683 cpumask_size 0 20683 NULL
97859 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97860 +gru_vtop_20689 gru_vtop 2 20689 NULL
97861 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97862 +__maestro_read_20700 __maestro_read 0 20700 NULL
97863 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97864 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97865 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97866 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97867 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97868 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97869 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97870 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97871 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
97872 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97873 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97874 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97875 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97876 +sys_sendto_20809 sys_sendto 6 20809 NULL
97877 +strndup_user_20819 strndup_user 2 20819 NULL
97878 +calc_layout_20829 calc_layout 3 20829 NULL
97879 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97880 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
97881 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97882 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97883 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
97884 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97885 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97886 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97887 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97888 +htable_bits_20933 htable_bits 0 20933 NULL
97889 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97890 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97891 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
97892 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97893 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97894 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97895 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97896 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
97897 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97898 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97899 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97900 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97901 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97902 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97903 +multipath_status_21094 multipath_status 5 21094 NULL
97904 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97905 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97906 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97907 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
97908 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97909 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97910 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97911 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97912 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97913 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97914 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97915 +input_ff_create_21240 input_ff_create 2 21240 NULL
97916 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97917 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97918 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97919 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
97920 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97921 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97922 +add_res_range_21310 add_res_range 4 21310 NULL
97923 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97924 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97925 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97926 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97927 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97928 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97929 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97930 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97931 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97932 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97933 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97934 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97935 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97936 +concat_writev_21451 concat_writev 3 21451 NULL
97937 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97938 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97939 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97940 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97941 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97942 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97943 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97944 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97945 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97946 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97947 +validate_nnode_21638 validate_nnode 0 21638 NULL
97948 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97949 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97950 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97951 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97952 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97953 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97954 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97955 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97956 +vm_brk_21739 vm_brk 1 21739 NULL
97957 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97958 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97959 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97960 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97961 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97962 +min_odd_21802 min_odd 0 21802 NULL
97963 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97964 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97965 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97966 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97967 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97968 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97969 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97970 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97971 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
97972 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97973 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97974 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97975 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97976 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97977 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97978 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97979 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97980 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97981 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97982 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97983 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97984 +write_opcode_22082 write_opcode 2 22082 NULL
97985 +mem_rw_22085 mem_rw 3 22085 NULL
97986 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
97987 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97988 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97989 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97990 +compat_insn_22142 compat_insn 2 22142 NULL
97991 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97992 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
97993 +fls_22210 fls 0 22210 NULL
97994 +mem_write_22232 mem_write 3 22232 NULL
97995 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97996 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97997 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97998 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97999 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
98000 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
98001 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
98002 +extend_brk_22301 extend_brk 0 22301 NULL
98003 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
98004 +get_segment_base_22324 get_segment_base 0 22324 NULL
98005 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
98006 +atomic_read_22342 atomic_read 0 22342 NULL
98007 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
98008 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
98009 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
98010 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
98011 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
98012 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
98013 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
98014 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
98015 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
98016 +zoran_write_22404 zoran_write 3 22404 NULL
98017 +queue_reply_22416 queue_reply 3 22416 NULL
98018 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
98019 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
98020 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
98021 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
98022 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
98023 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
98024 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
98025 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
98026 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
98027 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
98028 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
98029 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
98030 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
98031 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
98032 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
98033 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
98034 +snapshot_read_22601 snapshot_read 3 22601 NULL
98035 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
98036 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
98037 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
98038 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
98039 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
98040 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
98041 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
98042 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
98043 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
98044 +map_22700 map 2 22700 NULL
98045 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
98046 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
98047 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
98048 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
98049 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
98050 +print_frame_22769 print_frame 0 22769 NULL
98051 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
98052 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
98053 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
98054 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
98055 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
98056 +create_attr_set_22861 create_attr_set 1 22861 NULL
98057 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
98058 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
98059 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
98060 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
98061 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
98062 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
98063 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
98064 +vme_get_size_22964 vme_get_size 0 22964 NULL
98065 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
98066 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
98067 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
98068 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
98069 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
98070 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
98071 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
98072 +st_status_23032 st_status 5 23032 NULL
98073 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
98074 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
98075 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
98076 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
98077 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
98078 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
98079 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
98080 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
98081 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
98082 +fls_long_23096 fls_long 0 23096 NULL
98083 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
98084 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
98085 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
98086 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
98087 +__clear_user_23118 __clear_user 0 23118 NULL
98088 +dm_write_async_23120 dm_write_async 3 23120 NULL
98089 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
98090 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
98091 +read_file_ani_23161 read_file_ani 3 23161 NULL
98092 +ioremap_23172 ioremap 1-2 23172 NULL
98093 +usblp_write_23178 usblp_write 3 23178 NULL
98094 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
98095 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
98096 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
98097 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
98098 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
98099 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
98100 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
98101 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
98102 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
98103 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
98104 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
98105 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
98106 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
98107 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
98108 +doc_probe_23285 doc_probe 1 23285 NULL
98109 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
98110 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
98111 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
98112 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
98113 +page_readlink_23346 page_readlink 3 23346 NULL
98114 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
98115 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
98116 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
98117 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
98118 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
98119 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
98120 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
98121 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
98122 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
98123 +event_filter_read_23494 event_filter_read 3 23494 NULL
98124 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
98125 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
98126 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
98127 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
98128 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
98129 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
98130 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
98131 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
98132 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
98133 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
98134 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
98135 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
98136 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
98137 +sInW_23663 sInW 0 23663 NULL
98138 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
98139 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
98140 +cx18_read_23699 cx18_read 3 23699 NULL
98141 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
98142 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
98143 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
98144 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
98145 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
98146 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
98147 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
98148 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
98149 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
98150 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
98151 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
98152 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
98153 +p54_init_common_23850 p54_init_common 1 23850 NULL
98154 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
98155 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
98156 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
98157 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
98158 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
98159 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
98160 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
98161 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
98162 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
98163 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
98164 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
98165 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
98166 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
98167 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
98168 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
98169 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
98170 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
98171 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
98172 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
98173 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
98174 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
98175 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
98176 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
98177 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
98178 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
98179 +mpu401_read_24126 mpu401_read 3 24126 NULL
98180 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
98181 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
98182 +set_discard_24162 set_discard 2 24162 NULL
98183 +adu_read_24177 adu_read 3 24177 NULL
98184 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
98185 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
98186 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
98187 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
98188 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
98189 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
98190 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
98191 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
98192 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
98193 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
98194 +thin_status_24278 thin_status 5 24278 NULL
98195 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
98196 +msg_size_24288 msg_size 0 24288 NULL
98197 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
98198 +map_page_24298 map_page 3-4 24298 NULL
98199 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
98200 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
98201 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
98202 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
98203 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
98204 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
98205 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
98206 +igetword_24373 igetword 0 24373 NULL
98207 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
98208 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
98209 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
98210 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
98211 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
98212 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
98213 +smk_user_access_24440 smk_user_access 3 24440 NULL
98214 +page_address_24444 page_address 0 24444 NULL
98215 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
98216 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
98217 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
98218 +pd_video_read_24510 pd_video_read 3 24510 NULL
98219 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
98220 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
98221 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
98222 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
98223 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
98224 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
98225 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
98226 +count_preds_24600 count_preds 0 24600 NULL
98227 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
98228 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
98229 +context_alloc_24645 context_alloc 3 24645 NULL
98230 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
98231 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
98232 +read_fs_24717 read_fs 0 24717 NULL
98233 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
98234 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
98235 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
98236 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
98237 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
98238 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
98239 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
98240 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
98241 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
98242 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
98243 +cache_read_24790 cache_read 3 24790 NULL
98244 +unpack_str_24798 unpack_str 0 24798 NULL
98245 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
98246 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
98247 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
98248 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
98249 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
98250 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
98251 +setup_buffering_24872 setup_buffering 3 24872 NULL
98252 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
98253 +queues_read_24877 queues_read 3 24877 NULL
98254 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
98255 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
98256 +next_token_24929 next_token 0 24929 NULL
98257 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
98258 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
98259 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
98260 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
98261 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
98262 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
98263 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
98264 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
98265 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
98266 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
98267 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
98268 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
98269 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
98270 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
98271 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
98272 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
98273 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
98274 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
98275 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
98276 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
98277 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
98278 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
98279 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
98280 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
98281 +stripe_status_25259 stripe_status 5 25259 NULL
98282 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
98283 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
98284 +vfs_writev_25278 vfs_writev 3 25278 NULL
98285 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
98286 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
98287 +help_25316 help 5 25316 NULL nohasharray
98288 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
98289 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
98290 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
98291 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
98292 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
98293 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
98294 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
98295 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
98296 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
98297 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
98298 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
98299 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
98300 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
98301 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
98302 +sb_permission_25523 sb_permission 0 25523 NULL
98303 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
98304 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
98305 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
98306 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
98307 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
98308 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
98309 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
98310 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
98311 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
98312 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
98313 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
98314 +__direct_map_25647 __direct_map 5-6 25647 NULL
98315 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
98316 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
98317 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
98318 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
98319 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
98320 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
98321 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
98322 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
98323 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
98324 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
98325 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
98326 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
98327 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
98328 +sg_read_25799 sg_read 3 25799 NULL
98329 +system_enable_read_25815 system_enable_read 3 25815 NULL
98330 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
98331 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
98332 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
98333 +parport_read_25855 parport_read 0 25855 NULL
98334 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
98335 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
98336 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
98337 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
98338 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
98339 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
98340 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
98341 +rcname_read_25919 rcname_read 3 25919 NULL
98342 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
98343 +key_flags_read_25931 key_flags_read 3 25931 NULL
98344 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
98345 +flush_25957 flush 2 25957 NULL
98346 +video_register_device_25971 video_register_device 3 25971 NULL
98347 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
98348 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
98349 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
98350 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
98351 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
98352 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
98353 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
98354 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
98355 +tun_do_read_26047 tun_do_read 5 26047 NULL
98356 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
98357 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
98358 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
98359 +skb_cow_26138 skb_cow 2 26138 NULL
98360 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
98361 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
98362 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
98363 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
98364 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
98365 +disk_devt_26180 disk_devt 0 26180 NULL
98366 +get_registers_26187 get_registers 3 26187 NULL
98367 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
98368 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
98369 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
98370 +mce_write_26201 mce_write 3 26201 NULL
98371 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
98372 +bio_split_26235 bio_split 2 26235 NULL
98373 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
98374 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
98375 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
98376 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
98377 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
98378 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
98379 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
98380 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
98381 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
98382 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
98383 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
98384 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
98385 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
98386 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
98387 +read_vmcore_26501 read_vmcore 3 26501 NULL
98388 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
98389 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
98390 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
98391 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
98392 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
98393 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
98394 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
98395 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
98396 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
98397 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
98398 +pack_value_26625 pack_value 1 26625 NULL
98399 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
98400 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
98401 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
98402 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
98403 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
98404 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
98405 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
98406 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
98407 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
98408 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
98409 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
98410 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
98411 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
98412 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
98413 +smk_write_load_26829 smk_write_load 3 26829 NULL
98414 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
98415 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
98416 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
98417 +scnprint_id_26842 scnprint_id 3 26842 NULL
98418 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
98419 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
98420 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
98421 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
98422 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
98423 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
98424 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
98425 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
98426 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
98427 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
98428 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
98429 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
98430 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
98431 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
98432 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
98433 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
98434 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
98435 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
98436 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
98437 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
98438 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
98439 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
98440 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
98441 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
98442 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
98443 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
98444 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
98445 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
98446 +pms_capture_27142 pms_capture 4 27142 NULL
98447 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
98448 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
98449 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
98450 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
98451 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
98452 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
98453 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
98454 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
98455 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
98456 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
98457 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
98458 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
98459 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
98460 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
98461 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
98462 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
98463 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
98464 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
98465 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
98466 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
98467 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
98468 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
98469 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
98470 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
98471 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
98472 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
98473 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
98474 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
98475 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
98476 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
98477 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
98478 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
98479 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
98480 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
98481 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
98482 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
98483 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
98484 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
98485 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
98486 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
98487 +qword_get_27670 qword_get 0 27670 NULL
98488 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
98489 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
98490 +evm_write_key_27715 evm_write_key 3 27715 NULL
98491 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
98492 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
98493 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
98494 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
98495 +kcalloc_27770 kcalloc 1-2 27770 NULL
98496 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
98497 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
98498 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
98499 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
98500 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
98501 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
98502 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
98503 +read_profile_27859 read_profile 3 27859 NULL
98504 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
98505 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
98506 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
98507 +gluebi_write_27905 gluebi_write 3 27905 NULL
98508 +bm_find_next_27929 bm_find_next 2 27929 NULL
98509 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
98510 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
98511 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
98512 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
98513 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
98514 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
98515 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
98516 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
98517 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
98518 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
98519 +pool_status_28055 pool_status 5 28055 NULL
98520 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
98521 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
98522 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
98523 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
98524 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
98525 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
98526 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
98527 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
98528 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
98529 +video_read_28148 video_read 3 28148 NULL
98530 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
98531 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
98532 +vread_28173 vread 0 28173 NULL
98533 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
98534 +d_path_28198 d_path 0 28198 NULL
98535 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
98536 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
98537 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
98538 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
98539 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
98540 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
98541 +usemap_size_28281 usemap_size 0 28281 NULL
98542 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
98543 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
98544 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
98545 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
98546 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
98547 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
98548 +snapshot_write_28351 snapshot_write 3 28351 NULL
98549 +sys_writev_28384 sys_writev 3 28384 NULL
98550 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
98551 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
98552 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
98553 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
98554 +__split_large_page_28429 __split_large_page 2 28429 NULL
98555 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
98556 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
98557 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
98558 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
98559 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
98560 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
98561 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
98562 +max_response_pages_28492 max_response_pages 0 28492 NULL
98563 +clear_discard_28494 clear_discard 2 28494 NULL
98564 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
98565 +__next_node_28521 __next_node 1 28521 NULL
98566 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
98567 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
98568 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
98569 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
98570 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
98571 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
98572 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
98573 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
98574 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
98575 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
98576 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
98577 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
98578 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
98579 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
98580 +_set_range_28627 _set_range 3 28627 NULL
98581 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
98582 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
98583 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
98584 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
98585 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
98586 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
98587 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
98588 +spi_execute_28736 spi_execute 5 28736 NULL
98589 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
98590 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
98591 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
98592 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
98593 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
98594 +sel_write_member_28800 sel_write_member 3 28800 NULL
98595 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
98596 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
98597 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
98598 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
98599 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
98600 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
98601 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
98602 +to_cblock_28899 to_cblock 0-1 28899 NULL
98603 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
98604 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
98605 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
98606 +push_rx_28939 push_rx 3 28939 NULL
98607 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
98608 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
98609 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
98610 +bin_uuid_28999 bin_uuid 3 28999 NULL
98611 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
98612 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
98613 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
98614 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
98615 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
98616 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
98617 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
98618 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
98619 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
98620 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
98621 +snprintf_29125 snprintf 0 29125 NULL
98622 +iov_shorten_29130 iov_shorten 0 29130 NULL
98623 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
98624 +reshape_ring_29147 reshape_ring 2 29147 NULL
98625 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
98626 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
98627 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
98628 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
98629 +__mm_populate_29204 __mm_populate 1 29204 NULL
98630 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
98631 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
98632 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
98633 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
98634 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
98635 +recover_peb_29238 recover_peb 6-7 29238 NULL
98636 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
98637 +block_div_29268 block_div 0-1-2 29268 NULL
98638 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
98639 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
98640 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
98641 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
98642 +tun_put_user_29337 tun_put_user 5 29337 NULL
98643 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
98644 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
98645 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
98646 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
98647 +mempool_create_29437 mempool_create 1 29437 NULL
98648 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
98649 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
98650 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
98651 +do_register_entry_29478 do_register_entry 4 29478 NULL
98652 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
98653 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
98654 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
98655 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
98656 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
98657 +set_brk_29551 set_brk 1 29551 NULL nohasharray
98658 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
98659 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
98660 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
98661 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
98662 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
98663 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
98664 +slots_per_page_29601 slots_per_page 0 29601 NULL
98665 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
98666 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
98667 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
98668 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
98669 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
98670 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
98671 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
98672 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
98673 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
98674 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
98675 +probes_write_29711 probes_write 3 29711 NULL
98676 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
98677 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
98678 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
98679 +dbAlloc_29794 dbAlloc 0 29794 NULL
98680 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
98681 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
98682 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
98683 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
98684 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
98685 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
98686 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
98687 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
98688 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
98689 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
98690 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
98691 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
98692 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
98693 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
98694 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
98695 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
98696 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
98697 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
98698 +drp_wmove_30043 drp_wmove 4 30043 NULL
98699 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
98700 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
98701 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
98702 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
98703 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
98704 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98705 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98706 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98707 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98708 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98709 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98710 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98711 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98712 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98713 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98714 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98715 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98716 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
98717 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98718 +compat_readv_30273 compat_readv 3 30273 NULL
98719 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98720 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98721 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98722 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98723 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98724 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98725 +resource_from_user_30341 resource_from_user 3 30341 NULL
98726 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98727 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
98728 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98729 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98730 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98731 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98732 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98733 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98734 +mq_create_30425 mq_create 1 30425 NULL
98735 +enable_write_30456 enable_write 3 30456 NULL
98736 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98737 +urandom_read_30462 urandom_read 3 30462 NULL
98738 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98739 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
98740 +write_head_30481 write_head 4 30481 NULL
98741 +adu_write_30487 adu_write 3 30487 NULL
98742 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98743 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98744 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98745 +set_le_30581 set_le 4 30581 NULL
98746 +from_cblock_30582 from_cblock 0-1 30582 NULL
98747 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98748 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
98749 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
98750 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
98751 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
98752 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
98753 +agp_remap_30665 agp_remap 2 30665 NULL
98754 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
98755 +il_free_pages_30692 il_free_pages 2 30692 NULL
98756 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
98757 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98758 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98759 +snapshot_status_30744 snapshot_status 5 30744 NULL
98760 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98761 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98762 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98763 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98764 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
98765 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98766 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98767 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98768 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98769 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98770 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98771 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98772 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98773 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98774 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98775 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98776 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98777 +sys_mincore_31079 sys_mincore 1 31079 NULL
98778 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98779 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98780 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
98781 +depth_read_31112 depth_read 3 31112 NULL
98782 +ssb_read16_31139 ssb_read16 0 31139 NULL
98783 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98784 +size_inside_page_31141 size_inside_page 0 31141 NULL
98785 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98786 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98787 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98788 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98789 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98790 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98791 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
98792 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98793 +__read_reg_31216 __read_reg 0 31216 NULL
98794 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98795 +cyy_readb_31240 cyy_readb 0 31240 NULL
98796 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98797 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98798 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98799 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98800 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98801 +command_file_write_31318 command_file_write 3 31318 NULL
98802 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
98803 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98804 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
98805 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98806 +inb_31388 inb 0 31388 NULL
98807 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98808 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98809 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98810 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98811 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98812 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98813 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98814 +do_fcntl_31468 do_fcntl 3 31468 NULL
98815 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98816 +alg_setkey_31485 alg_setkey 3 31485 NULL
98817 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98818 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98819 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
98820 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
98821 +hidraw_write_31536 hidraw_write 3 31536 NULL
98822 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98823 +usbvision_read_31555 usbvision_read 3 31555 NULL
98824 +normalize_31566 normalize 0-1-2 31566 NULL
98825 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98826 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98827 +osst_write_31581 osst_write 3 31581 NULL
98828 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98829 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98830 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98831 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98832 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98833 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98834 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98835 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
98836 +__lgread_31668 __lgread 4 31668 NULL
98837 +symbol_string_31670 symbol_string 0 31670 NULL
98838 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98839 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98840 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98841 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98842 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
98843 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
98844 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98845 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98846 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98847 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98848 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98849 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98850 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
98851 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98852 +get_count_order_31800 get_count_order 0 31800 NULL
98853 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98854 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98855 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98856 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98857 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98858 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98859 +xattr_permission_31907 xattr_permission 0 31907 NULL
98860 +new_dir_31919 new_dir 3 31919 NULL
98861 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98862 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98863 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98864 +vb2_write_31948 vb2_write 3 31948 NULL
98865 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98866 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98867 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98868 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98869 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
98870 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98871 +calc_hmac_32010 calc_hmac 3 32010 NULL
98872 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
98873 +aead_len_32021 aead_len 0 32021 NULL
98874 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98875 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98876 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98877 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98878 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98879 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98880 +bio_alloc_32095 bio_alloc 2 32095 NULL
98881 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98882 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98883 +disk_status_32120 disk_status 4 32120 NULL
98884 +venus_link_32165 venus_link 5 32165 NULL
98885 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98886 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98887 +load_header_32183 load_header 0 32183 NULL
98888 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98889 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98890 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98891 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98892 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98893 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98894 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98895 +hex_string_32310 hex_string 0 32310 NULL
98896 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98897 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98898 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98899 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98900 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98901 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98902 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98903 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98904 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98905 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
98906 +log_text_32428 log_text 0 32428 NULL
98907 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98908 +hid_input_report_32458 hid_input_report 4 32458 NULL
98909 +cache_status_32462 cache_status 5 32462 NULL
98910 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98911 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98912 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98913 +disconnect_32521 disconnect 4 32521 NULL
98914 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98915 +ilo_read_32531 ilo_read 3 32531 NULL
98916 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
98917 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
98918 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
98919 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98920 +__first_node_32558 __first_node 0 32558 NULL
98921 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98922 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98923 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98924 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98925 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98926 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98927 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98928 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98929 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98930 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98931 +kvmalloc_32646 kvmalloc 1 32646 NULL
98932 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98933 +generic_readlink_32654 generic_readlink 3 32654 NULL
98934 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98935 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98936 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98937 +get_arg_page_32746 get_arg_page 2 32746 NULL
98938 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98939 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98940 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98941 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98942 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98943 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98944 +vga_rseq_32848 vga_rseq 0 32848 NULL
98945 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98946 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98947 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98948 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98949 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98950 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98951 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98952 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98953 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98954 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98955 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98956 +compat_filldir_32999 compat_filldir 3 32999 NULL
98957 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98958 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98959 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98960 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98961 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98962 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98963 +alloc_tio_33077 alloc_tio 3 33077 NULL
98964 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98965 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98966 +write_node_33121 write_node 4 33121 NULL
98967 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98968 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98969 +__len_within_target_33132 __len_within_target 0 33132 NULL
98970 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98971 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98972 +pp_read_33210 pp_read 3 33210 NULL
98973 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98974 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
98975 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98976 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98977 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98978 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98979 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98980 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98981 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98982 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98983 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98984 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98985 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98986 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98987 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98988 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98989 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98990 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98991 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98992 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98993 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98994 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98995 +create_entry_33479 create_entry 2 33479 NULL
98996 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98997 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98998 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98999 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
99000 +res_counter_read_33499 res_counter_read 4 33499 NULL
99001 +fb_read_33506 fb_read 3 33506 NULL
99002 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
99003 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
99004 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
99005 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
99006 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
99007 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
99008 +dup_array_33551 dup_array 3 33551 NULL
99009 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
99010 +count_subheaders_33591 count_subheaders 0 33591 NULL
99011 +scsi_execute_33596 scsi_execute 5 33596 NULL
99012 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
99013 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
99014 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
99015 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
99016 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
99017 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
99018 +inw_p_33668 inw_p 0 33668 NULL
99019 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
99020 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
99021 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
99022 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
99023 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
99024 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
99025 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
99026 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
99027 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
99028 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
99029 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
99030 +Read_hfc_33755 Read_hfc 0 33755 NULL
99031 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
99032 +hashtab_create_33769 hashtab_create 3 33769 NULL
99033 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
99034 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
99035 +find_next_offset_33804 find_next_offset 3 33804 NULL
99036 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
99037 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
99038 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
99039 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
99040 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
99041 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
99042 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
99043 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
99044 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
99045 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
99046 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
99047 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
99048 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
99049 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
99050 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
99051 +ppp_write_34034 ppp_write 3 34034 NULL
99052 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
99053 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
99054 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
99055 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
99056 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
99057 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
99058 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
99059 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
99060 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
99061 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
99062 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
99063 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
99064 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
99065 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
99066 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
99067 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
99068 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
99069 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
99070 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
99071 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
99072 +__insert_34349 __insert 2-3 34349 NULL
99073 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
99074 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
99075 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
99076 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
99077 +ea_read_34378 ea_read 0 34378 NULL
99078 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
99079 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
99080 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
99081 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
99082 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
99083 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
99084 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
99085 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
99086 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
99087 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
99088 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
99089 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
99090 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
99091 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
99092 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
99093 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
99094 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
99095 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
99096 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
99097 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
99098 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
99099 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
99100 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
99101 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
99102 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
99103 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
99104 +port_print_34704 port_print 3 34704 NULL
99105 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
99106 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
99107 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
99108 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
99109 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
99110 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
99111 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
99112 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
99113 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
99114 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
99115 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
99116 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
99117 +msg_print_text_34889 msg_print_text 0 34889 NULL
99118 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
99119 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
99120 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
99121 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
99122 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
99123 +Realloc_34961 Realloc 2 34961 NULL
99124 +mq_lookup_34990 mq_lookup 2 34990 NULL
99125 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
99126 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
99127 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
99128 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
99129 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
99130 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
99131 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
99132 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
99133 +store_ifalias_35088 store_ifalias 4 35088 NULL
99134 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
99135 +capi_write_35104 capi_write 3 35104 NULL nohasharray
99136 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
99137 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
99138 +pointer_35138 pointer 0 35138 NULL
99139 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
99140 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
99141 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
99142 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
99143 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
99144 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
99145 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
99146 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
99147 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
99148 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
99149 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
99150 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
99151 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
99152 +set_fd_set_35249 set_fd_set 1 35249 NULL
99153 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
99154 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
99155 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
99156 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
99157 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
99158 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
99159 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
99160 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
99161 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
99162 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
99163 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
99164 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
99165 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
99166 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
99167 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
99168 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
99169 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
99170 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
99171 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
99172 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
99173 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
99174 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
99175 +async_setkey_35521 async_setkey 3 35521 NULL
99176 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
99177 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
99178 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
99179 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
99180 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
99181 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
99182 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
99183 +ReadZReg_35604 ReadZReg 0 35604 NULL
99184 +kernel_readv_35617 kernel_readv 3 35617 NULL
99185 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
99186 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
99187 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
99188 +store_debug_level_35652 store_debug_level 3 35652 NULL
99189 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
99190 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
99191 +dm_table_create_35687 dm_table_create 3 35687 NULL
99192 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
99193 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
99194 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
99195 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
99196 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
99197 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
99198 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
99199 +fls64_35862 fls64 0 35862 NULL
99200 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
99201 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
99202 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
99203 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
99204 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
99205 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
99206 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
99207 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
99208 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
99209 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
99210 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
99211 +acl_alloc_35979 acl_alloc 1 35979 NULL
99212 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
99213 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
99214 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
99215 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
99216 +account_shadowed_36048 account_shadowed 2 36048 NULL
99217 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
99218 +write_emulate_36065 write_emulate 2-4 36065 NULL
99219 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
99220 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
99221 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
99222 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
99223 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
99224 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
99225 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
99226 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
99227 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
99228 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
99229 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
99230 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
99231 +twl_set_36154 twl_set 2 36154 NULL
99232 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
99233 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
99234 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
99235 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
99236 +is_dirty_36223 is_dirty 2 36223 NULL
99237 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
99238 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
99239 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
99240 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
99241 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
99242 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
99243 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
99244 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
99245 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
99246 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
99247 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
99248 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
99249 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
99250 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
99251 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
99252 +lc_create_36332 lc_create 4 36332 NULL
99253 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
99254 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
99255 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
99256 +to_sector_36361 to_sector 0-1 36361 NULL
99257 +tunables_read_36385 tunables_read 3 36385 NULL
99258 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
99259 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
99260 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
99261 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
99262 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
99263 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
99264 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
99265 +get_param_l_36518 get_param_l 0 36518 NULL
99266 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
99267 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
99268 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
99269 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
99270 +get_entry_len_36549 get_entry_len 0 36549 NULL
99271 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
99272 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
99273 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
99274 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
99275 +__erst_read_36579 __erst_read 0 36579 NULL
99276 +put_cmsg_36589 put_cmsg 4 36589 NULL
99277 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
99278 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
99279 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
99280 +format_decode_36638 format_decode 0 36638 NULL
99281 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
99282 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
99283 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
99284 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
99285 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
99286 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
99287 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
99288 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
99289 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
99290 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
99291 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
99292 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
99293 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
99294 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
99295 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
99296 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
99297 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
99298 +cm_write_36858 cm_write 3 36858 NULL
99299 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
99300 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
99301 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
99302 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
99303 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
99304 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
99305 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
99306 +build_key_36931 build_key 1 36931 NULL
99307 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
99308 +write_leb_36957 write_leb 5 36957 NULL
99309 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
99310 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
99311 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
99312 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
99313 +setxattr_37006 setxattr 4 37006 NULL
99314 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
99315 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
99316 +parse_command_37079 parse_command 2 37079 NULL
99317 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
99318 +tun_get_user_37094 tun_get_user 5 37094 NULL
99319 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
99320 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
99321 +msg_word_37164 msg_word 0 37164 NULL
99322 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
99323 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
99324 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
99325 +__do_replace_37227 __do_replace 5 37227 NULL
99326 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
99327 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
99328 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
99329 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
99330 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
99331 +c101_run_37279 c101_run 2 37279 NULL
99332 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
99333 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
99334 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
99335 +send_msg_37323 send_msg 4 37323 NULL
99336 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
99337 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
99338 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
99339 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
99340 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
99341 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
99342 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
99343 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
99344 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
99345 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
99346 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
99347 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
99348 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
99349 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
99350 +__remove_37457 __remove 2 37457 NULL
99351 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
99352 +get_est_timing_37484 get_est_timing 0 37484 NULL
99353 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
99354 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
99355 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
99356 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
99357 +hdr_size_37536 hdr_size 0 37536 NULL
99358 +a2p_37544 a2p 0-1 37544 NULL
99359 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
99360 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
99361 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
99362 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
99363 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
99364 +policy_residency_37629 policy_residency 0 37629 NULL
99365 +check_pt_base_37635 check_pt_base 3 37635 NULL
99366 +alloc_fd_37637 alloc_fd 1 37637 NULL
99367 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
99368 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
99369 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
99370 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
99371 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
99372 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
99373 +nametbl_header_37698 nametbl_header 2 37698 NULL
99374 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
99375 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
99376 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
99377 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
99378 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
99379 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
99380 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
99381 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
99382 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
99383 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
99384 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
99385 +deny_write_access_37813 deny_write_access 0 37813 NULL
99386 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
99387 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
99388 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
99389 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
99390 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
99391 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
99392 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
99393 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
99394 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
99395 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
99396 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
99397 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
99398 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
99399 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
99400 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
99401 +vfs_readv_38011 vfs_readv 3 38011 NULL
99402 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
99403 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
99404 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
99405 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
99406 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
99407 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
99408 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
99409 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
99410 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
99411 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
99412 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
99413 +ep0_read_38095 ep0_read 3 38095 NULL
99414 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
99415 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
99416 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
99417 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
99418 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
99419 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
99420 +cdev_add_38176 cdev_add 2-3 38176 NULL
99421 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
99422 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
99423 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
99424 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
99425 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
99426 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
99427 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
99428 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
99429 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
99430 +from_dblock_38256 from_dblock 0-1 38256 NULL
99431 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
99432 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
99433 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
99434 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
99435 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
99436 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
99437 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
99438 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
99439 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
99440 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
99441 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
99442 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
99443 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
99444 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
99445 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
99446 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
99447 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
99448 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
99449 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
99450 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
99451 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
99452 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
99453 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
99454 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
99455 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
99456 +dev_names_read_38509 dev_names_read 3 38509 NULL
99457 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
99458 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
99459 +set_queue_count_38519 set_queue_count 0 38519 NULL
99460 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
99461 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
99462 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
99463 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
99464 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
99465 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
99466 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
99467 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
99468 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
99469 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
99470 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
99471 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
99472 +cma_create_area_38642 cma_create_area 2 38642 NULL
99473 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
99474 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
99475 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
99476 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
99477 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
99478 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
99479 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
99480 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
99481 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
99482 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
99483 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
99484 +udf_readpages_38761 udf_readpages 4 38761 NULL
99485 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
99486 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
99487 +err_decode_38804 err_decode 2 38804 NULL
99488 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
99489 +sys_select_38827 sys_select 1 38827 NULL
99490 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
99491 +direct_entry_38836 direct_entry 3 38836 NULL
99492 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
99493 +interfaces_38859 interfaces 2 38859 NULL
99494 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
99495 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
99496 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
99497 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
99498 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
99499 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
99500 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
99501 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
99502 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
99503 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
99504 +udf_new_block_38999 udf_new_block 4 38999 NULL
99505 +get_nodes_39012 get_nodes 3 39012 NULL
99506 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
99507 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
99508 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
99509 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
99510 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
99511 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
99512 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
99513 +ea_foreach_39133 ea_foreach 0 39133 NULL
99514 +generic_permission_39150 generic_permission 0 39150 NULL
99515 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
99516 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
99517 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
99518 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
99519 +init_list_set_39188 init_list_set 2-3 39188 NULL
99520 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
99521 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
99522 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
99523 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
99524 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
99525 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
99526 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
99527 +drm_order_39244 drm_order 0 39244 NULL
99528 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
99529 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
99530 +__skb_cow_39254 __skb_cow 2 39254 NULL
99531 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
99532 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
99533 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
99534 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
99535 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
99536 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
99537 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
99538 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
99539 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
99540 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
99541 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
99542 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
99543 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
99544 +__send_to_port_39386 __send_to_port 3 39386 NULL
99545 +user_power_read_39414 user_power_read 3 39414 NULL
99546 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
99547 +sys_semop_39457 sys_semop 3 39457 NULL
99548 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
99549 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
99550 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
99551 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
99552 +int_proc_write_39542 int_proc_write 3 39542 NULL
99553 +pp_write_39554 pp_write 3 39554 NULL
99554 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
99555 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
99556 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
99557 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
99558 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
99559 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
99560 +ext_depth_39607 ext_depth 0 39607 NULL
99561 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
99562 +sdio_readb_39618 sdio_readb 0 39618 NULL
99563 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
99564 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
99565 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
99566 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
99567 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
99568 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
99569 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
99570 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
99571 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
99572 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
99573 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
99574 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
99575 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
99576 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
99577 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
99578 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
99579 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
99580 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
99581 +pkt_add_39897 pkt_add 3 39897 NULL
99582 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
99583 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
99584 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
99585 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
99586 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
99587 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
99588 +__spi_async_39932 __spi_async 0 39932 NULL
99589 +__get_order_39935 __get_order 0 39935 NULL
99590 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
99591 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
99592 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
99593 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
99594 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
99595 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
99596 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
99597 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
99598 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
99599 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
99600 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
99601 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
99602 +add_tty_40055 add_tty 1 40055 NULL nohasharray
99603 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
99604 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
99605 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
99606 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
99607 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
99608 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
99609 +pt_write_40159 pt_write 3 40159 NULL
99610 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
99611 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
99612 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
99613 +allocate_probes_40204 allocate_probes 1 40204 NULL
99614 +compat_put_long_40214 compat_put_long 1 40214 NULL
99615 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
99616 +osst_read_40237 osst_read 3 40237 NULL
99617 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
99618 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
99619 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
99620 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
99621 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
99622 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
99623 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
99624 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
99625 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
99626 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
99627 +mmio_read_40348 mmio_read 4 40348 NULL
99628 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
99629 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
99630 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
99631 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
99632 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
99633 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
99634 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
99635 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
99636 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
99637 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
99638 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
99639 +tty_write_room_40495 tty_write_room 0 40495 NULL
99640 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
99641 +sg_phys_40507 sg_phys 0 40507 NULL
99642 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
99643 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
99644 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
99645 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
99646 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
99647 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
99648 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
99649 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
99650 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
99651 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
99652 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
99653 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
99654 +fops_read_40672 fops_read 3 40672 NULL
99655 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
99656 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
99657 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
99658 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
99659 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
99660 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
99661 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
99662 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
99663 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
99664 +card_send_command_40757 card_send_command 3 40757 NULL
99665 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
99666 +pg_write_40766 pg_write 3 40766 NULL
99667 +show_list_40775 show_list 3 40775 NULL
99668 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
99669 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
99670 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
99671 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
99672 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
99673 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
99674 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
99675 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
99676 +read_file_queue_40895 read_file_queue 3 40895 NULL
99677 +waiters_read_40902 waiters_read 3 40902 NULL
99678 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
99679 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
99680 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
99681 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
99682 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
99683 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
99684 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
99685 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
99686 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
99687 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
99688 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
99689 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
99690 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
99691 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
99692 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
99693 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
99694 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
99695 +dma_attach_41094 dma_attach 5-6 41094 NULL
99696 +provide_user_output_41105 provide_user_output 3 41105 NULL
99697 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
99698 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
99699 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
99700 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
99701 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
99702 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
99703 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
99704 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
99705 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
99706 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
99707 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99708 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99709 +erst_read_41260 erst_read 0 41260 NULL
99710 +__fprog_create_41263 __fprog_create 2 41263 NULL
99711 +alloc_context_41283 alloc_context 1 41283 NULL
99712 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99713 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99714 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99715 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99716 +kmp_init_41373 kmp_init 2 41373 NULL
99717 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99718 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
99719 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99720 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99721 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99722 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
99723 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99724 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99725 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99726 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99727 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99728 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99729 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99730 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99731 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99732 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99733 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99734 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99735 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99736 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99737 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99738 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99739 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99740 +vga_io_r_41609 vga_io_r 0 41609 NULL
99741 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
99742 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99743 +a2mp_send_41615 a2mp_send 4 41615 NULL
99744 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99745 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99746 +get_std_timing_41654 get_std_timing 0 41654 NULL
99747 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99748 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
99749 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
99750 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
99751 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
99752 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
99753 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
99754 +fillonedir_41746 fillonedir 3 41746 NULL
99755 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
99756 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
99757 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
99758 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99759 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
99760 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99761 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99762 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99763 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99764 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99765 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99766 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99767 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99768 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99769 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99770 +portnames_read_41958 portnames_read 3 41958 NULL
99771 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99772 +dst_mtu_41969 dst_mtu 0 41969 NULL
99773 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99774 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99775 +lguest_map_42008 lguest_map 1-2 42008 NULL
99776 +pool_allocate_42012 pool_allocate 3 42012 NULL
99777 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99778 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99779 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99780 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99781 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99782 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99783 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99784 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99785 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
99786 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99787 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99788 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99789 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
99790 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
99791 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99792 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99793 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99794 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
99795 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99796 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99797 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99798 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99799 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99800 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99801 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99802 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99803 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99804 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99805 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
99806 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99807 +free_cblock_42318 free_cblock 2 42318 NULL
99808 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99809 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
99810 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99811 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99812 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99813 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99814 +krng_get_random_42420 krng_get_random 3 42420 NULL
99815 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99816 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99817 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99818 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99819 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99820 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99821 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99822 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99823 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99824 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99825 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99826 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99827 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99828 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99829 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99830 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99831 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99832 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99833 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99834 +map_state_42602 map_state 1 42602 NULL nohasharray
99835 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99836 +nd_get_link_42603 nd_get_link 0 42603 NULL
99837 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99838 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99839 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99840 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99841 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99842 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99843 +vb2_read_42703 vb2_read 3 42703 NULL
99844 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99845 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99846 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99847 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99848 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99849 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99850 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99851 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99852 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99853 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99854 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99855 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99856 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99857 +set_arg_42824 set_arg 3 42824 NULL
99858 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99859 +prandom_u32_42853 prandom_u32 0 42853 NULL
99860 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99861 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99862 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99863 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99864 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99865 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99866 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99867 +hd_end_request_42904 hd_end_request 2 42904 NULL
99868 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99869 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99870 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99871 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99872 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99873 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99874 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99875 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99876 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99877 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99878 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99879 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99880 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
99881 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99882 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99883 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99884 +uuid_string_43154 uuid_string 0 43154 NULL
99885 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99886 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99887 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99888 +process_measurement_43190 process_measurement 0 43190 NULL
99889 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99890 +uio_write_43202 uio_write 3 43202 NULL
99891 +iso_callback_43208 iso_callback 3 43208 NULL
99892 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99893 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99894 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99895 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99896 +fixup_leb_43256 fixup_leb 3 43256 NULL
99897 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99898 +evtchn_write_43278 evtchn_write 3 43278 NULL
99899 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99900 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99901 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99902 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
99903 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99904 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
99905 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99906 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
99907 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
99908 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99909 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
99910 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99911 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99912 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99913 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99914 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99915 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99916 +do_readlink_43518 do_readlink 2 43518 NULL
99917 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99918 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99919 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99920 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99921 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99922 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99923 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99924 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99925 +proc_read_43614 proc_read 3 43614 NULL
99926 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99927 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
99928 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99929 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99930 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99931 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99932 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99933 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99934 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99935 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99936 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99937 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99938 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99939 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99940 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99941 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99942 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99943 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99944 +read_flush_43851 read_flush 3 43851 NULL
99945 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99946 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
99947 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99948 +SendString_43928 SendString 3 43928 NULL
99949 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99950 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99951 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99952 +nla_reserve_43984 nla_reserve 3 43984 NULL
99953 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
99954 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99955 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99956 +emit_flags_44006 emit_flags 4-3 44006 NULL
99957 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99958 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
99959 +load_discard_44083 load_discard 3 44083 NULL
99960 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99961 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99962 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99963 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99964 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99965 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99966 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99967 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99968 +__set_free_44211 __set_free 2 44211 NULL
99969 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99970 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99971 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99972 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99973 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99974 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
99975 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99976 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99977 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99978 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
99979 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99980 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99981 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99982 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99983 +__is_discarded_44359 __is_discarded 2 44359 NULL
99984 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99985 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99986 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99987 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99988 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
99989 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99990 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99991 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
99992 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99993 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99994 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99995 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99996 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99997 +spidev_write_44510 spidev_write 3 44510 NULL
99998 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99999 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
100000 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
100001 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
100002 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
100003 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
100004 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
100005 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
100006 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
100007 +mpi_resize_44674 mpi_resize 2 44674 NULL
100008 +ts_read_44687 ts_read 3 44687 NULL
100009 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
100010 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
100011 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
100012 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
100013 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
100014 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
100015 +set_brk_44749 set_brk 1 44749 NULL
100016 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
100017 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
100018 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
100019 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
100020 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
100021 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
100022 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
100023 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
100024 +sisusb_write_44834 sisusb_write 3 44834 NULL
100025 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
100026 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
100027 +skb_availroom_44883 skb_availroom 0 44883 NULL
100028 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
100029 +do_tty_write_44896 do_tty_write 5 44896 NULL
100030 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
100031 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
100032 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
100033 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
100034 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
100035 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
100036 +sel_write_user_45060 sel_write_user 3 45060 NULL
100037 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
100038 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
100039 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
100040 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
100041 +usbdev_read_45114 usbdev_read 3 45114 NULL
100042 +send_to_tty_45141 send_to_tty 3 45141 NULL
100043 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
100044 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
100045 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
100046 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
100047 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
100048 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
100049 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
100050 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
100051 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
100052 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
100053 +add_child_45201 add_child 4 45201 NULL
100054 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
100055 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
100056 +__dirty_45228 __dirty 2 45228 NULL
100057 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
100058 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
100059 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
100060 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
100061 +pte_val_45313 pte_val 0 45313 NULL
100062 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
100063 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
100064 +keymap_store_45406 keymap_store 4 45406 NULL
100065 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
100066 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
100067 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
100068 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
100069 +__node_remap_45458 __node_remap 4 45458 NULL
100070 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
100071 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
100072 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
100073 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
100074 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
100075 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
100076 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
100077 +copy_macs_45534 copy_macs 4 45534 NULL
100078 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
100079 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
100080 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
100081 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
100082 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
100083 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
100084 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
100085 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
100086 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
100087 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
100088 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
100089 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
100090 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
100091 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
100092 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
100093 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
100094 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
100095 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
100096 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
100097 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
100098 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
100099 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
100100 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
100101 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
100102 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
100103 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
100104 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
100105 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
100106 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
100107 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
100108 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
100109 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
100110 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
100111 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
100112 +isdn_write_45863 isdn_write 3 45863 NULL
100113 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
100114 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
100115 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
100116 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
100117 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
100118 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
100119 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
100120 +alloc_mr_45935 alloc_mr 1 45935 NULL
100121 +split_large_page_45941 split_large_page 2 45941 NULL
100122 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
100123 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
100124 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
100125 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
100126 +get_free_entries_46030 get_free_entries 1 46030 NULL
100127 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
100128 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
100129 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
100130 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
100131 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
100132 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
100133 +slhc_toss_46066 slhc_toss 0 46066 NULL
100134 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
100135 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
100136 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
100137 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
100138 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
100139 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
100140 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
100141 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
100142 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
100143 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
100144 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
100145 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
100146 +add_conn_list_46197 add_conn_list 3 46197 NULL
100147 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
100148 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
100149 +dsp_write_46218 dsp_write 2 46218 NULL
100150 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
100151 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
100152 +ReadReg_46277 ReadReg 0 46277 NULL
100153 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
100154 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
100155 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
100156 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
100157 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
100158 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
100159 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
100160 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
100161 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
100162 +filldir64_46469 filldir64 3 46469 NULL
100163 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
100164 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
100165 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
100166 +kmsg_read_46514 kmsg_read 3 46514 NULL
100167 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
100168 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
100169 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
100170 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
100171 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
100172 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
100173 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
100174 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
100175 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
100176 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
100177 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
100178 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
100179 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
100180 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
100181 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
100182 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
100183 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
100184 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
100185 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
100186 +prepare_copy_46725 prepare_copy 2 46725 NULL
100187 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
100188 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
100189 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
100190 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
100191 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
100192 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
100193 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
100194 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
100195 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
100196 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
100197 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
100198 +spi_async_46857 spi_async 0 46857 NULL
100199 +vsnprintf_46863 vsnprintf 0 46863 NULL
100200 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
100201 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
100202 +rvmalloc_46873 rvmalloc 1 46873 NULL
100203 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
100204 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
100205 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
100206 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
100207 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
100208 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
100209 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
100210 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
100211 +fb_write_46924 fb_write 3 46924 NULL
100212 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
100213 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
100214 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
100215 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
100216 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
100217 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
100218 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
100219 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
100220 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
100221 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
100222 +__map_single_47020 __map_single 3-4-7 47020 NULL
100223 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
100224 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
100225 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
100226 +fs_path_len_47060 fs_path_len 0 47060 NULL
100227 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
100228 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
100229 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
100230 +mousedev_read_47123 mousedev_read 3 47123 NULL
100231 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
100232 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
100233 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
100234 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
100235 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
100236 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
100237 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
100238 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
100239 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
100240 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
100241 +l2headersize_47238 l2headersize 0 47238 NULL
100242 +options_write_47243 options_write 3 47243 NULL
100243 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
100244 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
100245 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
100246 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
100247 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
100248 +vsnprintf_47291 vsnprintf 0 47291 NULL
100249 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
100250 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
100251 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
100252 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
100253 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
100254 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
100255 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
100256 +nametbl_list_47391 nametbl_list 2 47391 NULL
100257 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
100258 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
100259 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
100260 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
100261 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
100262 +vzalloc_47421 vzalloc 1 47421 NULL
100263 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
100264 +__load_mapping_47460 __load_mapping 2 47460 NULL
100265 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
100266 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
100267 +core_sys_select_47494 core_sys_select 1 47494 NULL
100268 +unlink_simple_47506 unlink_simple 3 47506 NULL
100269 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
100270 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
100271 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
100272 +oz_events_read_47535 oz_events_read 3 47535 NULL
100273 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
100274 +read_ldt_47570 read_ldt 2 47570 NULL
100275 +pci_iomap_47575 pci_iomap 3 47575 NULL
100276 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
100277 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
100278 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
100279 +uea_request_47613 uea_request 4 47613 NULL
100280 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
100281 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
100282 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
100283 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
100284 +save_microcode_47717 save_microcode 3 47717 NULL
100285 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
100286 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
100287 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
100288 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
100289 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
100290 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
100291 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
100292 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
100293 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
100294 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
100295 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
100296 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
100297 +vhci_read_47878 vhci_read 3 47878 NULL
100298 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
100299 +load_mapping_47904 load_mapping 3 47904 NULL
100300 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
100301 +comedi_write_47926 comedi_write 3 47926 NULL
100302 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
100303 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
100304 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
100305 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
100306 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
100307 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
100308 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
100309 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
100310 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
100311 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
100312 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
100313 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
100314 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
100315 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
100316 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
100317 +set_discoverable_48141 set_discoverable 4 48141 NULL
100318 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
100319 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
100320 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
100321 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
100322 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
100323 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
100324 +init_ipath_48187 init_ipath 1 48187 NULL
100325 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
100326 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
100327 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
100328 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
100329 +read_file_recv_48232 read_file_recv 3 48232 NULL
100330 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
100331 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
100332 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
100333 +send_set_info_48288 send_set_info 7 48288 NULL
100334 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
100335 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
100336 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
100337 +hash_setkey_48310 hash_setkey 3 48310 NULL
100338 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
100339 +skb_add_data_48363 skb_add_data 3 48363 NULL
100340 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
100341 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
100342 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
100343 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
100344 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
100345 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
100346 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
100347 +send_control_msg_48498 send_control_msg 6 48498 NULL
100348 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
100349 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
100350 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
100351 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
100352 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
100353 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
100354 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
100355 +named_distribute_48544 named_distribute 4 48544 NULL
100356 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
100357 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
100358 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
100359 +mtd_read_48655 mtd_read 0 48655 NULL
100360 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
100361 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
100362 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
100363 +altera_drscan_48698 altera_drscan 2 48698 NULL
100364 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
100365 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
100366 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
100367 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
100368 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
100369 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
100370 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
100371 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
100372 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
100373 +azx_get_position_48841 azx_get_position 0 48841 NULL
100374 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
100375 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
100376 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
100377 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
100378 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
100379 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
100380 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
100381 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
100382 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
100383 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
100384 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
100385 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
100386 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
100387 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
100388 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
100389 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
100390 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
100391 +transient_status_49027 transient_status 4 49027 NULL
100392 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
100393 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
100394 +ubi_read_49061 ubi_read 0 49061 NULL
100395 +scsi_register_49094 scsi_register 2 49094 NULL
100396 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
100397 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
100398 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
100399 +pt_read_49136 pt_read 3 49136 NULL
100400 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
100401 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
100402 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
100403 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
100404 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
100405 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
100406 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
100407 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
100408 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
100409 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
100410 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
100411 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
100412 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
100413 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
100414 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
100415 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
100416 +uio_read_49300 uio_read 3 49300 NULL
100417 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
100418 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
100419 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
100420 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
100421 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
100422 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
100423 +px_raw_event_49371 px_raw_event 4 49371 NULL
100424 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
100425 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
100426 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
100427 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
100428 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
100429 +md_domain_init_49432 md_domain_init 2 49432 NULL
100430 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
100431 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
100432 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
100433 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
100434 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
100435 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
100436 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
100437 +smk_write_access_49561 smk_write_access 3 49561 NULL
100438 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
100439 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
100440 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
100441 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
100442 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
100443 +heap_init_49617 heap_init 2 49617 NULL
100444 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
100445 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
100446 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
100447 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
100448 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
100449 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
100450 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
100451 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
100452 +check_frame_49741 check_frame 0 49741 NULL
100453 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
100454 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
100455 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
100456 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
100457 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
100458 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
100459 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
100460 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
100461 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
100462 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
100463 +add_uuid_49831 add_uuid 4 49831 NULL
100464 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
100465 +twl4030_write_49846 twl4030_write 2 49846 NULL
100466 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
100467 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
100468 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
100469 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
100470 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
100471 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
100472 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
100473 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
100474 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
100475 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
100476 +__module_alloc_50004 __module_alloc 1 50004 NULL
100477 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
100478 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
100479 +isdn_read_50021 isdn_read 3 50021 NULL
100480 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
100481 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
100482 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
100483 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
100484 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
100485 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
100486 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
100487 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
100488 +read_file_slot_50111 read_file_slot 3 50111 NULL
100489 +copy_items_50140 copy_items 6 50140 NULL
100490 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
100491 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
100492 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
100493 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
100494 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
100495 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
100496 +odev_update_50169 odev_update 2 50169 NULL
100497 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
100498 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
100499 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
100500 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
100501 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
100502 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
100503 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
100504 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
100505 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
100506 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
100507 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
100508 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
100509 +do_launder_page_50329 do_launder_page 0 50329 NULL
100510 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
100511 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
100512 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
100513 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
100514 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
100515 +tpm_read_50344 tpm_read 3 50344 NULL
100516 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
100517 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
100518 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
100519 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
100520 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
100521 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
100522 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
100523 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
100524 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
100525 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
100526 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
100527 +force_mapping_50464 force_mapping 2 50464 NULL
100528 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
100529 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
100530 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
100531 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
100532 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
100533 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
100534 +fat_readpages_50582 fat_readpages 4 50582 NULL
100535 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
100536 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
100537 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
100538 +__ffs_50625 __ffs 0 50625 NULL
100539 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
100540 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
100541 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
100542 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
100543 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
100544 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
100545 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
100546 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
100547 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
100548 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
100549 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
100550 +skb_padto_50759 skb_padto 2 50759 NULL
100551 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
100552 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
100553 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
100554 +tpm_write_50798 tpm_write 3 50798 NULL
100555 +write_flush_50803 write_flush 3 50803 NULL
100556 +dvb_play_50814 dvb_play 3 50814 NULL
100557 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
100558 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
100559 +SetArea_50835 SetArea 4 50835 NULL nohasharray
100560 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
100561 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
100562 +self_check_write_50856 self_check_write 5 50856 NULL
100563 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
100564 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
100565 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
100566 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
100567 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
100568 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
100569 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
100570 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
100571 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
100572 +timeout_write_50991 timeout_write 3 50991 NULL
100573 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
100574 +proc_write_51003 proc_write 3 51003 NULL
100575 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
100576 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
100577 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
100578 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
100579 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
100580 +dump_midi_51040 dump_midi 3 51040 NULL
100581 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
100582 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
100583 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
100584 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
100585 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
100586 +ti_recv_51110 ti_recv 3 51110 NULL
100587 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
100588 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
100589 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
100590 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
100591 +set_dirty_51144 set_dirty 3 51144 NULL
100592 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
100593 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
100594 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
100595 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
100596 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
100597 +tipc_send_51238 tipc_send 4 51238 NULL
100598 +drm_property_create_51239 drm_property_create 4 51239 NULL
100599 +st_read_51251 st_read 3 51251 NULL
100600 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
100601 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
100602 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
100603 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
100604 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
100605 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
100606 +get_cell_51316 get_cell 2 51316 NULL
100607 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
100608 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
100609 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
100610 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
100611 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
100612 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
100613 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
100614 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
100615 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
100616 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
100617 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
100618 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
100619 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
100620 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
100621 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
100622 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
100623 +vaddr_51480 vaddr 0 51480 NULL
100624 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
100625 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
100626 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
100627 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
100628 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
100629 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
100630 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
100631 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
100632 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
100633 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
100634 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
100635 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
100636 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
100637 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
100638 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
100639 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
100640 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
100641 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
100642 +sel_write_access_51704 sel_write_access 3 51704 NULL
100643 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
100644 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
100645 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
100646 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
100647 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
100648 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
100649 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
100650 +if_write_51756 if_write 3 51756 NULL
100651 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
100652 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
100653 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
100654 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
100655 +ioread32_51847 ioread32 0 51847 NULL nohasharray
100656 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
100657 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
100658 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
100659 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
100660 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
100661 +user_read_51881 user_read 3 51881 NULL
100662 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
100663 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
100664 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
100665 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
100666 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
100667 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
100668 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
100669 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
100670 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
100671 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
100672 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
100673 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
100674 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
100675 +rdmalt_52022 rdmalt 0 52022 NULL
100676 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
100677 +override_release_52032 override_release 2 52032 NULL
100678 +end_port_52042 end_port 0 52042 NULL
100679 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
100680 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
100681 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
100682 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
100683 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
100684 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
100685 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
100686 +retry_count_read_52129 retry_count_read 3 52129 NULL
100687 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
100688 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
100689 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
100690 +htable_size_52148 htable_size 0-1 52148 NULL
100691 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
100692 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
100693 +alix_present_52165 alix_present 1 52165 NULL
100694 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
100695 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
100696 +print_prefix_52176 print_prefix 0 52176 NULL
100697 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
100698 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
100699 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
100700 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
100701 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
100702 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
100703 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
100704 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
100705 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
100706 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100707 +read_file_reset_52310 read_file_reset 3 52310 NULL
100708 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100709 +hwflags_read_52318 hwflags_read 3 52318 NULL
100710 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100711 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100712 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100713 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100714 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
100715 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100716 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100717 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100718 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100719 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100720 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100721 +delay_status_52431 delay_status 5 52431 NULL
100722 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100723 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100724 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100725 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100726 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100727 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100728 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
100729 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100730 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100731 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
100732 +from_oblock_52546 from_oblock 0-1 52546 NULL
100733 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100734 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100735 +emit_code_52583 emit_code 0-3 52583 NULL
100736 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
100737 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100738 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100739 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100740 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100741 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100742 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100743 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100744 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
100745 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100746 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100747 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100748 +twlreg_write_52880 twlreg_write 3 52880 NULL
100749 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
100750 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
100751 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
100752 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
100753 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
100754 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
100755 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
100756 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100757 +send_packet_52960 send_packet 4 52960 NULL
100758 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100759 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
100760 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
100761 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100762 +num_node_state_52989 num_node_state 0 52989 NULL
100763 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100764 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100765 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100766 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100767 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100768 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100769 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100770 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100771 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100772 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100773 +verity_status_53120 verity_status 5 53120 NULL
100774 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100775 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100776 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
100777 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100778 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100779 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
100780 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100781 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
100782 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100783 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100784 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100785 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100786 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100787 +vm_mmap_53339 vm_mmap 0 53339 NULL
100788 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100789 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100790 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100791 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100792 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100793 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100794 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100795 +n2_run_53459 n2_run 3 53459 NULL
100796 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100797 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100798 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100799 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100800 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100801 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100802 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100803 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100804 +check_acl_53512 check_acl 0 53512 NULL
100805 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
100806 +set_registers_53582 set_registers 3 53582 NULL
100807 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100808 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
100809 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
100810 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100811 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100812 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100813 +_preload_range_53676 _preload_range 2-3 53676 NULL
100814 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100815 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100816 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
100817 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
100818 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100819 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100820 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100821 +wdm_write_53735 wdm_write 3 53735 NULL
100822 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100823 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100824 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100825 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100826 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100827 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100828 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
100829 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100830 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
100831 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100832 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100833 +pms_read_53873 pms_read 3 53873 NULL
100834 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100835 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100836 +proc_file_read_53905 proc_file_read 3 53905 NULL
100837 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
100838 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100839 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100840 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100841 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100842 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
100843 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100844 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100845 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100846 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100847 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100848 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100849 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100850 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100851 +_malloc_54077 _malloc 1 54077 NULL
100852 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100853 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100854 +create_xattr_54106 create_xattr 5 54106 NULL
100855 +strn_len_54122 strn_len 0 54122 NULL
100856 +isku_receive_54130 isku_receive 4 54130 NULL
100857 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100858 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100859 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100860 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100861 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100862 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100863 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100864 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100865 +reada_add_block_54247 reada_add_block 2 54247 NULL
100866 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100867 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100868 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100869 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100870 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100871 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100872 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100873 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100874 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
100875 +sprintf_54306 sprintf 0 54306 NULL
100876 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100877 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100878 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100879 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100880 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100881 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100882 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100883 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100884 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100885 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100886 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100887 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100888 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100889 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100890 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100891 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100892 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
100893 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
100894 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100895 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
100896 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100897 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
100898 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
100899 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100900 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
100901 +viacam_read_54526 viacam_read 3 54526 NULL
100902 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100903 +setsockopt_54539 setsockopt 5 54539 NULL
100904 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100905 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100906 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100907 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100908 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100909 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100910 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100911 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100912 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
100913 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100914 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100915 +evm_read_key_54674 evm_read_key 3 54674 NULL
100916 +resource_string_54699 resource_string 0 54699 NULL
100917 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100918 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100919 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100920 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100921 +kzalloc_54740 kzalloc 1 54740 NULL
100922 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100923 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100924 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100925 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100926 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100927 +domain_init_54797 domain_init 2 54797 NULL
100928 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100929 +get_dev_size_54807 get_dev_size 0 54807 NULL
100930 +nfsd_write_54809 nfsd_write 6 54809 NULL
100931 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100932 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100933 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100934 +write_rio_54837 write_rio 3 54837 NULL
100935 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100936 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100937 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100938 +printer_read_54851 printer_read 3 54851 NULL
100939 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
100940 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100941 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100942 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100943 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100944 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100945 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100946 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100947 +add_port_54941 add_port 2 54941 NULL
100948 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100949 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100950 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100951 +c4_add_card_54968 c4_add_card 3 54968 NULL
100952 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100953 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100954 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100955 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
100956 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100957 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
100958 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100959 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100960 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100961 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100962 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
100963 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100964 +corrupt_data_55120 corrupt_data 0 55120 NULL
100965 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100966 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100967 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100968 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100969 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100970 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100971 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100972 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100973 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
100974 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
100975 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100976 +dump_command_55220 dump_command 1 55220 NULL
100977 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100978 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100979 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100980 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100981 +ptrace_request_55288 ptrace_request 3 55288 NULL
100982 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100983 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100984 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
100985 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
100986 +do_shmat_55336 do_shmat 5 55336 NULL
100987 +vme_user_read_55338 vme_user_read 3 55338 NULL
100988 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100989 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100990 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
100991 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100992 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100993 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100994 +alloc_skb_55439 alloc_skb 1 55439 NULL
100995 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100996 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100997 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100998 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100999 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
101000 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
101001 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
101002 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
101003 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
101004 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
101005 +ea_get_55522 ea_get 0 55522 NULL
101006 +buffer_size_55534 buffer_size 0 55534 NULL
101007 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
101008 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
101009 +add_partition_55588 add_partition 2 55588 NULL
101010 +free_pages_55603 free_pages 1 55603 NULL
101011 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
101012 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
101013 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
101014 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
101015 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
101016 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
101017 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
101018 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
101019 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
101020 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
101021 +read_oldmem_55658 read_oldmem 3 55658 NULL
101022 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
101023 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
101024 +get_info_55681 get_info 3 55681 NULL
101025 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
101026 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
101027 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
101028 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
101029 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
101030 +set_local_name_55757 set_local_name 4 55757 NULL
101031 +strlen_55778 strlen 0 55778 NULL
101032 +set_spte_55783 set_spte 5-4 55783 NULL
101033 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
101034 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
101035 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
101036 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
101037 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
101038 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
101039 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
101040 +hsc_write_55875 hsc_write 3 55875 NULL
101041 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
101042 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
101043 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
101044 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
101045 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
101046 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
101047 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
101048 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
101049 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
101050 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
101051 +__set_discard_56081 __set_discard 2 56081 NULL
101052 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
101053 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
101054 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
101055 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
101056 +map_addr_56144 map_addr 7 56144 NULL
101057 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
101058 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
101059 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
101060 +skb_headroom_56200 skb_headroom 0 56200 NULL
101061 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
101062 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
101063 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
101064 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
101065 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
101066 +fd_copyin_56247 fd_copyin 3 56247 NULL
101067 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
101068 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
101069 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
101070 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
101071 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
101072 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
101073 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
101074 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
101075 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
101076 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
101077 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
101078 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
101079 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
101080 +dev_read_56369 dev_read 3 56369 NULL
101081 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
101082 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
101083 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
101084 +store_msg_56417 store_msg 3 56417 NULL
101085 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
101086 +fl_create_56435 fl_create 5 56435 NULL
101087 +gnttab_map_56439 gnttab_map 2 56439 NULL
101088 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
101089 +set_connectable_56458 set_connectable 4 56458 NULL
101090 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
101091 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
101092 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
101093 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
101094 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
101095 +ip_options_get_56538 ip_options_get 4 56538 NULL
101096 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
101097 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
101098 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
101099 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
101100 +event_filter_write_56609 event_filter_write 3 56609 NULL
101101 +gather_array_56641 gather_array 3 56641 NULL
101102 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
101103 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
101104 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
101105 +build_map_info_56696 build_map_info 2 56696 NULL
101106 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
101107 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
101108 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
101109 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
101110 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
101111 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
101112 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
101113 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
101114 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
101115 +hash_lookup_56792 hash_lookup 2 56792 NULL
101116 +do_syslog_56807 do_syslog 3 56807 NULL
101117 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
101118 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
101119 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
101120 +wb_lookup_56858 wb_lookup 2 56858 NULL
101121 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
101122 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
101123 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
101124 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
101125 +strcspn_56913 strcspn 0 56913 NULL
101126 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
101127 +check_header_56930 check_header 2 56930 NULL
101128 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
101129 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
101130 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
101131 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
101132 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
101133 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
101134 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
101135 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
101136 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
101137 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
101138 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
101139 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
101140 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
101141 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
101142 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
101143 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
101144 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
101145 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
101146 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
101147 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
101148 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
101149 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
101150 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
101151 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
101152 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
101153 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
101154 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
101155 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
101156 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
101157 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
101158 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
101159 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
101160 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
101161 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
101162 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
101163 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
101164 +fw_file_size_57307 fw_file_size 0 57307 NULL
101165 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
101166 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
101167 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
101168 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
101169 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
101170 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
101171 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
101172 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
101173 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
101174 +read_file_blob_57406 read_file_blob 3 57406 NULL
101175 +enclosure_register_57412 enclosure_register 3 57412 NULL
101176 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
101177 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
101178 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
101179 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
101180 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
101181 +ReadReg_57453 ReadReg 0 57453 NULL
101182 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
101183 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
101184 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
101185 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
101186 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
101187 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
101188 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
101189 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
101190 +skb_headlen_57501 skb_headlen 0 57501 NULL
101191 +copy_in_user_57502 copy_in_user 3 57502 NULL
101192 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
101193 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
101194 +init_tag_map_57515 init_tag_map 3 57515 NULL
101195 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
101196 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
101197 +inode_permission_57531 inode_permission 0 57531 NULL
101198 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
101199 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
101200 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
101201 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
101202 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
101203 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
101204 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
101205 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
101206 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
101207 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
101208 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
101209 +mem_read_57631 mem_read 3 57631 NULL
101210 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
101211 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
101212 +r3964_write_57662 r3964_write 4 57662 NULL
101213 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
101214 +__lgwrite_57669 __lgwrite 4 57669 NULL
101215 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
101216 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
101217 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
101218 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
101219 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
101220 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
101221 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
101222 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
101223 +ld2_57794 ld2 0 57794 NULL
101224 +ivtv_read_57796 ivtv_read 3 57796 NULL
101225 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
101226 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
101227 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
101228 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
101229 +copy_to_user_57835 copy_to_user 3 57835 NULL
101230 +flash_read_57843 flash_read 3 57843 NULL
101231 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
101232 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
101233 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
101234 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
101235 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
101236 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
101237 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
101238 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
101239 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
101240 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
101241 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
101242 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
101243 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
101244 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
101245 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
101246 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
101247 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
101248 +mce_async_out_58056 mce_async_out 3 58056 NULL
101249 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
101250 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
101251 +cm4040_write_58079 cm4040_write 3 58079 NULL
101252 +udi_log_event_58105 udi_log_event 3 58105 NULL
101253 +savemem_58129 savemem 3 58129 NULL
101254 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
101255 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
101256 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
101257 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
101258 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
101259 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
101260 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
101261 +read_file_debug_58256 read_file_debug 3 58256 NULL
101262 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
101263 +profile_load_58267 profile_load 3 58267 NULL
101264 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
101265 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
101266 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
101267 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
101268 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
101269 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
101270 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
101271 +next_pidmap_58347 next_pidmap 2 58347 NULL
101272 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
101273 +save_hint_58359 save_hint 2 58359 NULL
101274 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
101275 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
101276 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
101277 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
101278 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
101279 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
101280 +capabilities_read_58457 capabilities_read 3 58457 NULL
101281 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
101282 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
101283 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
101284 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
101285 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
101286 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
101287 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
101288 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
101289 +__clear_discard_58546 __clear_discard 2 58546 NULL
101290 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
101291 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
101292 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
101293 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
101294 +xip_file_read_58592 xip_file_read 3 58592 NULL
101295 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
101296 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
101297 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
101298 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
101299 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
101300 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
101301 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
101302 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
101303 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
101304 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
101305 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
101306 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
101307 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
101308 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
101309 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
101310 +acpi_map_58725 acpi_map 1-2 58725 NULL
101311 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
101312 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
101313 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
101314 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
101315 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
101316 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
101317 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
101318 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
101319 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
101320 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
101321 +ep_read_58813 ep_read 3 58813 NULL
101322 +command_write_58841 command_write 3 58841 NULL
101323 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
101324 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
101325 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
101326 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
101327 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
101328 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
101329 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
101330 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
101331 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
101332 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
101333 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
101334 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
101335 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
101336 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
101337 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
101338 +ep_write_59008 ep_write 3 59008 NULL
101339 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
101340 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
101341 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
101342 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
101343 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
101344 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
101345 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
101346 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
101347 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
101348 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
101349 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
101350 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
101351 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
101352 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
101353 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
101354 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
101355 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
101356 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
101357 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
101358 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
101359 +dt3155_read_59226 dt3155_read 3 59226 NULL
101360 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
101361 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
101362 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
101363 +nla_len_59258 nla_len 0 59258 NULL
101364 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
101365 +fd_copyout_59323 fd_copyout 3 59323 NULL
101366 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
101367 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
101368 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
101369 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
101370 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
101371 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
101372 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
101373 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
101374 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
101375 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
101376 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
101377 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
101378 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
101379 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
101380 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
101381 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
101382 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
101383 +tunables_write_59563 tunables_write 3 59563 NULL
101384 +memdup_user_59590 memdup_user 2 59590 NULL
101385 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
101386 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
101387 +mtrr_write_59622 mtrr_write 3 59622 NULL
101388 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
101389 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
101390 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
101391 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
101392 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
101393 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
101394 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
101395 +sriov_enable_59689 sriov_enable 2 59689 NULL
101396 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
101397 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
101398 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
101399 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
101400 +strnlen_59746 strnlen 0 59746 NULL
101401 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
101402 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
101403 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
101404 +venus_remove_59781 venus_remove 4 59781 NULL
101405 +ipw_write_59807 ipw_write 3 59807 NULL
101406 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
101407 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
101408 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
101409 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
101410 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
101411 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
101412 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
101413 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
101414 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
101415 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
101416 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
101417 +lookup_node_59953 lookup_node 2 59953 NULL
101418 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
101419 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
101420 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
101421 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
101422 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
101423 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
101424 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
101425 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
101426 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
101427 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
101428 +register_device_60015 register_device 2-3 60015 NULL
101429 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
101430 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
101431 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
101432 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
101433 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
101434 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
101435 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
101436 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
101437 +compat_writev_60063 compat_writev 3 60063 NULL
101438 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
101439 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
101440 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
101441 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
101442 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
101443 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
101444 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
101445 +init_state_60165 init_state 2 60165 NULL
101446 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
101447 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
101448 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
101449 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
101450 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
101451 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
101452 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
101453 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
101454 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
101455 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
101456 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
101457 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
101458 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
101459 +printer_write_60276 printer_write 3 60276 NULL
101460 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
101461 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
101462 +getDataLength_60301 getDataLength 0 60301 NULL
101463 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
101464 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
101465 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
101466 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
101467 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
101468 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
101469 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
101470 +driver_names_read_60399 driver_names_read 3 60399 NULL
101471 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
101472 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
101473 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
101474 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
101475 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
101476 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
101477 +rx_data_60442 rx_data 4 60442 NULL
101478 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
101479 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
101480 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
101481 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
101482 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
101483 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
101484 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
101485 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
101486 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
101487 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
101488 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
101489 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
101490 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
101491 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
101492 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
101493 +init_data_container_60709 init_data_container 1 60709 NULL
101494 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
101495 +raid_status_60755 raid_status 5 60755 NULL
101496 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
101497 +opticon_write_60775 opticon_write 4 60775 NULL
101498 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
101499 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
101500 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
101501 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
101502 +generic_writepages_60871 generic_writepages 0 60871 NULL
101503 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
101504 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
101505 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
101506 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
101507 +sys_mlock_60932 sys_mlock 1 60932 NULL
101508 +pti_char_write_60960 pti_char_write 3 60960 NULL
101509 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
101510 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
101511 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
101512 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
101513 +symtab_init_61050 symtab_init 2 61050 NULL
101514 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
101515 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
101516 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
101517 +get_derived_key_61100 get_derived_key 4 61100 NULL
101518 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
101519 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
101520 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
101521 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
101522 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
101523 +__vmalloc_61168 __vmalloc 1 61168 NULL
101524 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
101525 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
101526 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
101527 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
101528 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
101529 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
101530 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
101531 +sys_add_key_61288 sys_add_key 4 61288 NULL
101532 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
101533 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
101534 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
101535 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
101536 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
101537 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
101538 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
101539 +change_xattr_61390 change_xattr 5 61390 NULL
101540 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
101541 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
101542 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
101543 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
101544 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
101545 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
101546 +erst_errno_61526 erst_errno 0 61526 NULL
101547 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
101548 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
101549 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
101550 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
101551 +seq_open_private_61589 seq_open_private 3 61589 NULL
101552 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
101553 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
101554 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
101555 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
101556 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
101557 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
101558 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
101559 +resize_stripes_61650 resize_stripes 2 61650 NULL
101560 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
101561 +insert_one_name_61668 insert_one_name 7 61668 NULL
101562 +lock_loop_61681 lock_loop 1 61681 NULL
101563 +filter_read_61692 filter_read 3 61692 NULL
101564 +iov_length_61716 iov_length 0 61716 NULL
101565 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
101566 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
101567 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
101568 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
101569 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
101570 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
101571 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
101572 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
101573 +get_fw_name_61874 get_fw_name 3 61874 NULL
101574 +free_init_pages_61875 free_init_pages 2 61875 NULL
101575 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
101576 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
101577 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
101578 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
101579 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
101580 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
101581 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
101582 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
101583 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
101584 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
101585 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
101586 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
101587 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
101588 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
101589 +cow_file_range_61979 cow_file_range 3 61979 NULL
101590 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
101591 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
101592 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
101593 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
101594 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
101595 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
101596 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
101597 +do_pselect_62061 do_pselect 1 62061 NULL
101598 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
101599 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
101600 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
101601 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
101602 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
101603 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
101604 +ql_status_62135 ql_status 5 62135 NULL
101605 +video_usercopy_62151 video_usercopy 2 62151 NULL
101606 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
101607 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
101608 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
101609 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
101610 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
101611 +allocate_partition_62245 allocate_partition 4 62245 NULL
101612 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
101613 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
101614 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
101615 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
101616 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
101617 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
101618 +subseq_list_62332 subseq_list 3-0 62332 NULL
101619 +flash_write_62354 flash_write 3 62354 NULL
101620 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
101621 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
101622 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
101623 +altera_irscan_62396 altera_irscan 2 62396 NULL
101624 +set_ssp_62411 set_ssp 4 62411 NULL
101625 +unmap_single_62423 unmap_single 2 62423 NULL
101626 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
101627 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
101628 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
101629 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
101630 +remove_mapping_62491 remove_mapping 2 62491 NULL
101631 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
101632 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
101633 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
101634 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
101635 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
101636 +debugfs_read_62535 debugfs_read 3 62535 NULL
101637 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
101638 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
101639 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
101640 +get_subdir_62581 get_subdir 3 62581 NULL
101641 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
101642 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
101643 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
101644 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
101645 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
101646 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
101647 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
101648 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
101649 +write_62671 write 3 62671 NULL
101650 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
101651 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
101652 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
101653 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
101654 +rdm_62719 rdm 0 62719 NULL
101655 +key_replays_read_62746 key_replays_read 3 62746 NULL
101656 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
101657 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
101658 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
101659 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
101660 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
101661 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
101662 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
101663 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
101664 +set_swbp_62853 set_swbp 3 62853 NULL
101665 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
101666 +aoechr_write_62883 aoechr_write 3 62883 NULL
101667 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
101668 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
101669 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
101670 +getdqbuf_62908 getdqbuf 1 62908 NULL
101671 +try_async_pf_62914 try_async_pf 3 62914 NULL
101672 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
101673 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
101674 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
101675 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
101676 +unlink1_63059 unlink1 3 63059 NULL
101677 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
101678 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
101679 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
101680 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
101681 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
101682 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
101683 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
101684 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
101685 +vme_master_read_63221 vme_master_read 0 63221 NULL
101686 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
101687 +ptp_read_63251 ptp_read 4 63251 NULL
101688 +raid5_resize_63306 raid5_resize 2 63306 NULL
101689 +proc_info_read_63344 proc_info_read 3 63344 NULL
101690 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
101691 +idmouse_read_63374 idmouse_read 3 63374 NULL
101692 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
101693 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
101694 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
101695 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
101696 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
101697 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
101698 +kone_send_63435 kone_send 4 63435 NULL
101699 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
101700 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
101701 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
101702 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
101703 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
101704 +read_kcore_63488 read_kcore 3 63488 NULL
101705 +save_hint_63497 save_hint 2 63497 NULL
101706 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
101707 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
101708 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
101709 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
101710 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
101711 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
101712 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
101713 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
101714 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
101715 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101716 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101717 +module_alloc_63630 module_alloc 1 63630 NULL
101718 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101719 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101720 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101721 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101722 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101723 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101724 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101725 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101726 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101727 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101728 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101729 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101730 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101731 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101732 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101733 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101734 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101735 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101736 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101737 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101738 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101739 +sel_write_load_63830 sel_write_load 3 63830 NULL
101740 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101741 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101742 +divas_write_63901 divas_write 3 63901 NULL
101743 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101744 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101745 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101746 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101747 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101748 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
101749 +__team_options_register_63941 __team_options_register 3 63941 NULL
101750 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
101751 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
101752 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
101753 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
101754 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
101755 +kmemdup_64015 kmemdup 2 64015 NULL
101756 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
101757 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
101758 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
101759 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
101760 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
101761 +get_u8_64076 get_u8 0 64076 NULL
101762 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
101763 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
101764 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
101765 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
101766 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101767 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101768 +init_bch_64130 init_bch 1-2 64130 NULL
101769 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101770 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101771 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101772 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
101773 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101774 +read_pulse_64227 read_pulse 0-3 64227 NULL
101775 +header_len_64232 header_len 0 64232 NULL
101776 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101777 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101778 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101779 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101780 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101781 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101782 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101783 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101784 +ffz_64324 ffz 0 64324 NULL
101785 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101786 +ts_write_64336 ts_write 3 64336 NULL
101787 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101788 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101789 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101790 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
101791 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101792 +ilo_write_64378 ilo_write 3 64378 NULL
101793 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101794 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
101795 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101796 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101797 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101798 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101799 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101800 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101801 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101802 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101803 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
101804 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
101805 +cap_capable_64462 cap_capable 0 64462 NULL
101806 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101807 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101808 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101809 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
101810 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
101811 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101812 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101813 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101814 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101815 +__spi_sync_64561 __spi_sync 0 64561 NULL
101816 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101817 +fanotify_write_64623 fanotify_write 3 64623 NULL
101818 +to_dblock_64655 to_dblock 0-1 64655 NULL
101819 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101820 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101821 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101822 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101823 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101824 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101825 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101826 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101827 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101828 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101829 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101830 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101831 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101832 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101833 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101834 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101835 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101836 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101837 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101838 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
101839 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
101840 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101841 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101842 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
101843 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101844 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101845 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101846 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101847 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101848 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101849 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101850 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101851 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101852 +pskb_pull_65005 pskb_pull 2 65005 NULL
101853 +unifi_write_65012 unifi_write 3 65012 NULL
101854 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101855 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101856 +insert_dent_65034 insert_dent 7 65034 NULL
101857 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101858 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101859 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
101860 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101861 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101862 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101863 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
101864 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101865 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101866 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101867 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101868 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
101869 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101870 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101871 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101872 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101873 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101874 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101875 +get_var_len_65304 get_var_len 0 65304 NULL
101876 +unpack_array_65318 unpack_array 0 65318 NULL
101877 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101878 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101879 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101880 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101881 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101882 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
101883 +strchr_65372 strchr 0 65372 NULL
101884 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
101885 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101886 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101887 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101888 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101889 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101890 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101891 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101892 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101893 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101894 +alloc_dr_65495 alloc_dr 2 65495 NULL
101895 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101896 new file mode 100644
101897 index 0000000..9db0d0e
101898 --- /dev/null
101899 +++ b/tools/gcc/size_overflow_plugin.c
101900 @@ -0,0 +1,2114 @@
101901 +/*
101902 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101903 + * Licensed under the GPL v2, or (at your option) v3
101904 + *
101905 + * Homepage:
101906 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101907 + *
101908 + * Documentation:
101909 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101910 + *
101911 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101912 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101913 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101914 + *
101915 + * Usage:
101916 + * $ 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
101917 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101918 + */
101919 +
101920 +#include "gcc-plugin.h"
101921 +#include "config.h"
101922 +#include "system.h"
101923 +#include "coretypes.h"
101924 +#include "tree.h"
101925 +#include "tree-pass.h"
101926 +#include "intl.h"
101927 +#include "plugin-version.h"
101928 +#include "tm.h"
101929 +#include "toplev.h"
101930 +#include "function.h"
101931 +#include "tree-flow.h"
101932 +#include "plugin.h"
101933 +#include "gimple.h"
101934 +#include "diagnostic.h"
101935 +#include "cfgloop.h"
101936 +
101937 +#if BUILDING_GCC_VERSION >= 4008
101938 +#define TODO_dump_func 0
101939 +#endif
101940 +
101941 +struct size_overflow_hash {
101942 + const struct size_overflow_hash * const next;
101943 + const char * const name;
101944 + const unsigned int param;
101945 +};
101946 +
101947 +#include "size_overflow_hash.h"
101948 +
101949 +enum mark {
101950 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101951 +};
101952 +
101953 +enum err_code_conditions {
101954 + CAST_ONLY, FROM_CONST
101955 +};
101956 +
101957 +static unsigned int call_count = 0;
101958 +
101959 +#define __unused __attribute__((__unused__))
101960 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101961 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101962 +#define BEFORE_STMT true
101963 +#define AFTER_STMT false
101964 +#define CREATE_NEW_VAR NULL_TREE
101965 +#define CODES_LIMIT 32
101966 +#define MAX_PARAM 31
101967 +#define MY_STMT GF_PLF_1
101968 +#define NO_CAST_CHECK GF_PLF_2
101969 +#define FROM_ARG true
101970 +#define FROM_RET false
101971 +
101972 +#if BUILDING_GCC_VERSION == 4005
101973 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101974 +#endif
101975 +
101976 +int plugin_is_GPL_compatible;
101977 +void debug_gimple_stmt(gimple gs);
101978 +
101979 +static tree expand(struct pointer_set_t *visited, tree lhs);
101980 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101981 +static tree report_size_overflow_decl;
101982 +static const_tree const_char_ptr_type_node;
101983 +static unsigned int handle_function(void);
101984 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101985 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101986 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101987 +static void print_missing_msg(tree func, unsigned int argnum);
101988 +
101989 +static struct plugin_info size_overflow_plugin_info = {
101990 + .version = "20130410beta",
101991 + .help = "no-size-overflow\tturn off size overflow checking\n",
101992 +};
101993 +
101994 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101995 +{
101996 + unsigned int arg_count;
101997 + enum tree_code code = TREE_CODE(*node);
101998 +
101999 + switch (code) {
102000 + case FUNCTION_DECL:
102001 + arg_count = type_num_arguments(TREE_TYPE(*node));
102002 + break;
102003 + case FUNCTION_TYPE:
102004 + case METHOD_TYPE:
102005 + arg_count = type_num_arguments(*node);
102006 + break;
102007 + default:
102008 + *no_add_attrs = true;
102009 + error("%s: %qE attribute only applies to functions", __func__, name);
102010 + return NULL_TREE;
102011 + }
102012 +
102013 + for (; args; args = TREE_CHAIN(args)) {
102014 + tree position = TREE_VALUE(args);
102015 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102016 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102017 + *no_add_attrs = true;
102018 + }
102019 + }
102020 + return NULL_TREE;
102021 +}
102022 +
102023 +static const char* get_asm_name(tree node)
102024 +{
102025 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
102026 +}
102027 +
102028 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
102029 +{
102030 + unsigned int arg_count, arg_num;
102031 + enum tree_code code = TREE_CODE(*node);
102032 +
102033 + switch (code) {
102034 + case FUNCTION_DECL:
102035 + arg_count = type_num_arguments(TREE_TYPE(*node));
102036 + break;
102037 + case FUNCTION_TYPE:
102038 + case METHOD_TYPE:
102039 + arg_count = type_num_arguments(*node);
102040 + break;
102041 + case FIELD_DECL:
102042 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
102043 + if (arg_num != 0) {
102044 + *no_add_attrs = true;
102045 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
102046 + }
102047 + return NULL_TREE;
102048 + default:
102049 + *no_add_attrs = true;
102050 + error("%qE attribute only applies to functions", name);
102051 + return NULL_TREE;
102052 + }
102053 +
102054 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
102055 + return NULL_TREE;
102056 +
102057 + for (; args; args = TREE_CHAIN(args)) {
102058 + tree position = TREE_VALUE(args);
102059 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102060 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102061 + *no_add_attrs = true;
102062 + }
102063 + }
102064 + return NULL_TREE;
102065 +}
102066 +
102067 +static struct attribute_spec size_overflow_attr = {
102068 + .name = "size_overflow",
102069 + .min_length = 1,
102070 + .max_length = -1,
102071 + .decl_required = true,
102072 + .type_required = false,
102073 + .function_type_required = false,
102074 + .handler = handle_size_overflow_attribute,
102075 +#if BUILDING_GCC_VERSION >= 4007
102076 + .affects_type_identity = false
102077 +#endif
102078 +};
102079 +
102080 +static struct attribute_spec intentional_overflow_attr = {
102081 + .name = "intentional_overflow",
102082 + .min_length = 1,
102083 + .max_length = -1,
102084 + .decl_required = true,
102085 + .type_required = false,
102086 + .function_type_required = false,
102087 + .handler = handle_intentional_overflow_attribute,
102088 +#if BUILDING_GCC_VERSION >= 4007
102089 + .affects_type_identity = false
102090 +#endif
102091 +};
102092 +
102093 +static void register_attributes(void __unused *event_data, void __unused *data)
102094 +{
102095 + register_attribute(&size_overflow_attr);
102096 + register_attribute(&intentional_overflow_attr);
102097 +}
102098 +
102099 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
102100 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
102101 +{
102102 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
102103 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
102104 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
102105 +
102106 + unsigned int m = 0x57559429;
102107 + unsigned int n = 0x5052acdb;
102108 + const unsigned int *key4 = (const unsigned int *)key;
102109 + unsigned int h = len;
102110 + unsigned int k = len + seed + n;
102111 + unsigned long long p;
102112 +
102113 + while (len >= 8) {
102114 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
102115 + len -= 8;
102116 + }
102117 + if (len >= 4) {
102118 + cwmixb(key4[0]) key4 += 1;
102119 + len -= 4;
102120 + }
102121 + if (len)
102122 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
102123 + cwmixb(h ^ (k + n));
102124 + return k ^ h;
102125 +
102126 +#undef cwfold
102127 +#undef cwmixa
102128 +#undef cwmixb
102129 +}
102130 +
102131 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
102132 +{
102133 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
102134 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
102135 + return fn ^ codes;
102136 +}
102137 +
102138 +static inline tree get_original_function_decl(tree fndecl)
102139 +{
102140 + if (DECL_ABSTRACT_ORIGIN(fndecl))
102141 + return DECL_ABSTRACT_ORIGIN(fndecl);
102142 + return fndecl;
102143 +}
102144 +
102145 +static inline gimple get_def_stmt(const_tree node)
102146 +{
102147 + gcc_assert(node != NULL_TREE);
102148 + if (TREE_CODE(node) != SSA_NAME)
102149 + return NULL;
102150 + return SSA_NAME_DEF_STMT(node);
102151 +}
102152 +
102153 +static unsigned char get_tree_code(const_tree type)
102154 +{
102155 + switch (TREE_CODE(type)) {
102156 + case ARRAY_TYPE:
102157 + return 0;
102158 + case BOOLEAN_TYPE:
102159 + return 1;
102160 + case ENUMERAL_TYPE:
102161 + return 2;
102162 + case FUNCTION_TYPE:
102163 + return 3;
102164 + case INTEGER_TYPE:
102165 + return 4;
102166 + case POINTER_TYPE:
102167 + return 5;
102168 + case RECORD_TYPE:
102169 + return 6;
102170 + case UNION_TYPE:
102171 + return 7;
102172 + case VOID_TYPE:
102173 + return 8;
102174 + case REAL_TYPE:
102175 + return 9;
102176 + case VECTOR_TYPE:
102177 + return 10;
102178 + case REFERENCE_TYPE:
102179 + return 11;
102180 + case OFFSET_TYPE:
102181 + return 12;
102182 + case COMPLEX_TYPE:
102183 + return 13;
102184 + default:
102185 + debug_tree((tree)type);
102186 + gcc_unreachable();
102187 + }
102188 +}
102189 +
102190 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
102191 +{
102192 + gcc_assert(type != NULL_TREE);
102193 +
102194 + while (type && len < CODES_LIMIT) {
102195 + tree_codes[len] = get_tree_code(type);
102196 + len++;
102197 + type = TREE_TYPE(type);
102198 + }
102199 + return len;
102200 +}
102201 +
102202 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
102203 +{
102204 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
102205 + enum tree_code code = TREE_CODE(type);
102206 + size_t len = 0;
102207 +
102208 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
102209 +
102210 + arg = TYPE_ARG_TYPES(type);
102211 + // skip builtins __builtin_constant_p
102212 + if (!arg && DECL_BUILT_IN(fndecl))
102213 + return 0;
102214 +
102215 + if (TREE_CODE_CLASS(code) == tcc_type)
102216 + result = type;
102217 + else
102218 + result = DECL_RESULT(fndecl);
102219 +
102220 + gcc_assert(result != NULL_TREE);
102221 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
102222 +
102223 + if (arg == NULL_TREE) {
102224 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
102225 + arg_field = DECL_ARGUMENT_FLD(fndecl);
102226 + if (arg_field == NULL_TREE)
102227 + return 0;
102228 + arg = TREE_TYPE(arg_field);
102229 + len = add_type_codes(arg, tree_codes, len);
102230 + gcc_assert(len != 0);
102231 + return len;
102232 + }
102233 +
102234 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
102235 + while (arg && len < CODES_LIMIT) {
102236 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
102237 + arg = TREE_CHAIN(arg);
102238 + }
102239 +
102240 + gcc_assert(len != 0);
102241 + return len;
102242 +}
102243 +
102244 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
102245 +{
102246 + unsigned int hash;
102247 + const struct size_overflow_hash *entry;
102248 + unsigned char tree_codes[CODES_LIMIT];
102249 + size_t len;
102250 + const char *func_name;
102251 +
102252 + fndecl = get_original_function_decl(fndecl);
102253 + len = get_function_decl(fndecl, tree_codes);
102254 + if (len == 0)
102255 + return NULL;
102256 +
102257 + func_name = get_asm_name(fndecl);
102258 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
102259 +
102260 + entry = size_overflow_hash[hash];
102261 + while (entry) {
102262 + if (!strcmp(entry->name, func_name))
102263 + return entry;
102264 + entry = entry->next;
102265 + }
102266 +
102267 + return NULL;
102268 +}
102269 +
102270 +static bool is_bool(const_tree node)
102271 +{
102272 + const_tree type;
102273 +
102274 + if (node == NULL_TREE)
102275 + return false;
102276 +
102277 + type = TREE_TYPE(node);
102278 + if (!INTEGRAL_TYPE_P(type))
102279 + return false;
102280 + if (TREE_CODE(type) == BOOLEAN_TYPE)
102281 + return true;
102282 + if (TYPE_PRECISION(type) == 1)
102283 + return true;
102284 + return false;
102285 +}
102286 +
102287 +static bool skip_types(const_tree var)
102288 +{
102289 + tree type;
102290 +
102291 + if (is_gimple_constant(var))
102292 + return true;
102293 +
102294 + switch (TREE_CODE(var)) {
102295 + case ADDR_EXPR:
102296 +#if BUILDING_GCC_VERSION >= 4006
102297 + case MEM_REF:
102298 +#endif
102299 + case ARRAY_REF:
102300 + case BIT_FIELD_REF:
102301 + case INDIRECT_REF:
102302 + case TARGET_MEM_REF:
102303 + return true;
102304 + case PARM_DECL:
102305 + case VAR_DECL:
102306 + case COMPONENT_REF:
102307 + return false;
102308 + default:
102309 + break;
102310 + }
102311 +
102312 + gcc_assert(TREE_CODE(var) == SSA_NAME);
102313 +
102314 + type = TREE_TYPE(var);
102315 + switch (TREE_CODE(type)) {
102316 + case INTEGER_TYPE:
102317 + case ENUMERAL_TYPE:
102318 + return false;
102319 + case BOOLEAN_TYPE:
102320 + return is_bool(var);
102321 + default:
102322 + break;
102323 + }
102324 +
102325 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
102326 +
102327 + type = TREE_TYPE(type);
102328 + gcc_assert(type != NULL_TREE);
102329 + switch (TREE_CODE(type)) {
102330 + case RECORD_TYPE:
102331 + case POINTER_TYPE:
102332 + case ARRAY_TYPE:
102333 + return true;
102334 + case VOID_TYPE:
102335 + case INTEGER_TYPE:
102336 + case UNION_TYPE:
102337 + return false;
102338 + default:
102339 + break;
102340 + }
102341 +
102342 + debug_tree((tree)var);
102343 + gcc_unreachable();
102344 +}
102345 +
102346 +static unsigned int find_arg_number(const_tree arg, tree func)
102347 +{
102348 + tree var;
102349 + unsigned int argnum = 1;
102350 +
102351 + if (TREE_CODE(arg) == SSA_NAME)
102352 + arg = SSA_NAME_VAR(arg);
102353 +
102354 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
102355 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
102356 + continue;
102357 + if (!skip_types(var))
102358 + return argnum;
102359 + }
102360 +
102361 + return 0;
102362 +}
102363 +
102364 +static tree create_new_var(tree type)
102365 +{
102366 + tree new_var = create_tmp_var(type, "cicus");
102367 +
102368 +#if BUILDING_GCC_VERSION <= 4007
102369 + add_referenced_var(new_var);
102370 + mark_sym_for_renaming(new_var);
102371 +#endif
102372 + return new_var;
102373 +}
102374 +
102375 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
102376 +{
102377 + gimple assign;
102378 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102379 + tree type = TREE_TYPE(rhs1);
102380 + tree lhs = create_new_var(type);
102381 +
102382 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
102383 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
102384 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102385 +
102386 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102387 + update_stmt(assign);
102388 + gimple_set_plf(assign, MY_STMT, true);
102389 + return assign;
102390 +}
102391 +
102392 +static tree cast_a_tree(tree type, tree var)
102393 +{
102394 + gcc_assert(type != NULL_TREE);
102395 + gcc_assert(var != NULL_TREE);
102396 + gcc_assert(fold_convertible_p(type, var));
102397 +
102398 + return fold_convert(type, var);
102399 +}
102400 +
102401 +static tree get_lhs(const_gimple stmt)
102402 +{
102403 + switch (gimple_code(stmt)) {
102404 + case GIMPLE_ASSIGN:
102405 + return gimple_get_lhs(stmt);
102406 + case GIMPLE_PHI:
102407 + return gimple_phi_result(stmt);
102408 + case GIMPLE_CALL:
102409 + return gimple_call_lhs(stmt);
102410 + default:
102411 + return NULL_TREE;
102412 + }
102413 +}
102414 +
102415 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
102416 +{
102417 + const_gimple def_stmt = get_def_stmt(rhs);
102418 +
102419 + if (force)
102420 + return false;
102421 +
102422 + if (is_gimple_constant(rhs))
102423 + return false;
102424 +
102425 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102426 + return false;
102427 +
102428 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
102429 + return false;
102430 +
102431 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
102432 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102433 + return false;
102434 +
102435 + return true;
102436 +}
102437 +
102438 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
102439 +{
102440 + gimple assign, def_stmt;
102441 +
102442 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
102443 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
102444 + gcc_unreachable();
102445 +
102446 + def_stmt = get_def_stmt(rhs);
102447 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
102448 + return def_stmt;
102449 +
102450 + if (lhs == CREATE_NEW_VAR)
102451 + lhs = create_new_var(dst_type);
102452 +
102453 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
102454 +
102455 + if (!gsi_end_p(*gsi)) {
102456 + location_t loc = gimple_location(gsi_stmt(*gsi));
102457 + gimple_set_location(assign, loc);
102458 + }
102459 +
102460 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102461 +
102462 + if (before)
102463 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
102464 + else
102465 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
102466 + update_stmt(assign);
102467 + gimple_set_plf(assign, MY_STMT, true);
102468 +
102469 + return assign;
102470 +}
102471 +
102472 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
102473 +{
102474 + gimple_stmt_iterator gsi;
102475 + tree lhs;
102476 + const_gimple new_stmt;
102477 +
102478 + if (rhs == NULL_TREE)
102479 + return NULL_TREE;
102480 +
102481 + gsi = gsi_for_stmt(stmt);
102482 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
102483 +
102484 + lhs = get_lhs(new_stmt);
102485 + gcc_assert(lhs != NULL_TREE);
102486 + return lhs;
102487 +}
102488 +
102489 +static tree cast_to_TI_type(gimple stmt, tree node)
102490 +{
102491 + gimple_stmt_iterator gsi;
102492 + gimple cast_stmt;
102493 + tree type = TREE_TYPE(node);
102494 +
102495 + if (types_compatible_p(type, intTI_type_node))
102496 + return node;
102497 +
102498 + gsi = gsi_for_stmt(stmt);
102499 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102500 + return gimple_get_lhs(cast_stmt);
102501 +}
102502 +
102503 +static void check_function_hash(const_gimple stmt)
102504 +{
102505 + tree func;
102506 + const struct size_overflow_hash *hash;
102507 +
102508 + if (gimple_code(stmt) != GIMPLE_CALL)
102509 + return;
102510 +
102511 + func = gimple_call_fndecl(stmt);
102512 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
102513 + if (func == NULL_TREE)
102514 + return;
102515 +
102516 + hash = get_function_hash(func);
102517 + if (!hash)
102518 + print_missing_msg(func, 0);
102519 +}
102520 +
102521 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
102522 +{
102523 + tree lhs, new_lhs;
102524 + gimple_stmt_iterator gsi;
102525 +
102526 + if (rhs1 == NULL_TREE) {
102527 + debug_gimple_stmt(oldstmt);
102528 + error("%s: rhs1 is NULL_TREE", __func__);
102529 + gcc_unreachable();
102530 + }
102531 +
102532 + switch (gimple_code(oldstmt)) {
102533 + case GIMPLE_ASM:
102534 + lhs = rhs1;
102535 + break;
102536 + case GIMPLE_CALL:
102537 + lhs = gimple_call_lhs(oldstmt);
102538 + break;
102539 + case GIMPLE_ASSIGN:
102540 + lhs = gimple_get_lhs(oldstmt);
102541 + break;
102542 + default:
102543 + debug_gimple_stmt(oldstmt);
102544 + gcc_unreachable();
102545 + }
102546 +
102547 + gsi = gsi_for_stmt(oldstmt);
102548 + pointer_set_insert(visited, oldstmt);
102549 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
102550 + basic_block next_bb, cur_bb;
102551 + const_edge e;
102552 +
102553 + gcc_assert(before == false);
102554 + gcc_assert(stmt_can_throw_internal(oldstmt));
102555 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
102556 + gcc_assert(!gsi_end_p(gsi));
102557 +
102558 + cur_bb = gimple_bb(oldstmt);
102559 + next_bb = cur_bb->next_bb;
102560 + e = find_edge(cur_bb, next_bb);
102561 + gcc_assert(e != NULL);
102562 + gcc_assert(e->flags & EDGE_FALLTHRU);
102563 +
102564 + gsi = gsi_after_labels(next_bb);
102565 + gcc_assert(!gsi_end_p(gsi));
102566 +
102567 + before = true;
102568 + oldstmt = gsi_stmt(gsi);
102569 + }
102570 +
102571 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
102572 + return new_lhs;
102573 +}
102574 +
102575 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
102576 +{
102577 + gimple stmt;
102578 + gimple_stmt_iterator gsi;
102579 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
102580 +
102581 + if (gimple_plf(oldstmt, MY_STMT))
102582 + return lhs;
102583 +
102584 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
102585 + rhs1 = gimple_assign_rhs1(oldstmt);
102586 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
102587 + }
102588 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
102589 + rhs2 = gimple_assign_rhs2(oldstmt);
102590 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
102591 + }
102592 +
102593 + stmt = gimple_copy(oldstmt);
102594 + gimple_set_location(stmt, gimple_location(oldstmt));
102595 + gimple_set_plf(stmt, MY_STMT, true);
102596 +
102597 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
102598 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
102599 +
102600 + size_overflow_type = get_size_overflow_type(oldstmt, node);
102601 +
102602 + new_var = create_new_var(size_overflow_type);
102603 + new_var = make_ssa_name(new_var, stmt);
102604 + gimple_set_lhs(stmt, new_var);
102605 +
102606 + if (rhs1 != NULL_TREE)
102607 + gimple_assign_set_rhs1(stmt, rhs1);
102608 +
102609 + if (rhs2 != NULL_TREE)
102610 + gimple_assign_set_rhs2(stmt, rhs2);
102611 +#if BUILDING_GCC_VERSION >= 4007
102612 + if (rhs3 != NULL_TREE)
102613 + gimple_assign_set_rhs3(stmt, rhs3);
102614 +#endif
102615 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
102616 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
102617 +
102618 + gsi = gsi_for_stmt(oldstmt);
102619 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
102620 + update_stmt(stmt);
102621 + pointer_set_insert(visited, oldstmt);
102622 + return gimple_get_lhs(stmt);
102623 +}
102624 +
102625 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
102626 +{
102627 + basic_block first_bb;
102628 + gimple assign;
102629 + gimple_stmt_iterator gsi;
102630 +
102631 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102632 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102633 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
102634 +
102635 + gsi = gsi_start_bb(first_bb);
102636 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102637 + return gimple_get_lhs(assign);
102638 +}
102639 +
102640 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
102641 +{
102642 + gimple_stmt_iterator gsi;
102643 + const_gimple assign;
102644 + gimple def_stmt = get_def_stmt(new_arg);
102645 +
102646 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
102647 + gsi = gsi_after_labels(gimple_bb(def_stmt));
102648 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
102649 + } else {
102650 + gsi = gsi_for_stmt(def_stmt);
102651 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
102652 + }
102653 +
102654 + return gimple_get_lhs(assign);
102655 +}
102656 +
102657 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
102658 +{
102659 + basic_block bb;
102660 + gimple_stmt_iterator gsi;
102661 + const_gimple assign, def_stmt;
102662 +
102663 + def_stmt = get_def_stmt(arg);
102664 + bb = gimple_bb(def_stmt);
102665 + gcc_assert(bb->index != 0);
102666 + gsi = gsi_after_labels(bb);
102667 +
102668 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102669 + return gimple_get_lhs(assign);
102670 +}
102671 +
102672 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
102673 +{
102674 + tree size_overflow_type;
102675 + const_gimple def_stmt = get_def_stmt(arg);
102676 +
102677 + if (phi_ssa_name != NULL_TREE)
102678 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
102679 +
102680 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
102681 +
102682 + if (new_arg != NULL_TREE) {
102683 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
102684 + return use_phi_ssa_name(phi_ssa_name, new_arg);
102685 + }
102686 +
102687 + switch(gimple_code(def_stmt)) {
102688 + case GIMPLE_PHI:
102689 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
102690 + case GIMPLE_NOP:
102691 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
102692 + default:
102693 + debug_gimple_stmt((gimple)def_stmt);
102694 + gcc_unreachable();
102695 + }
102696 +}
102697 +
102698 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
102699 +{
102700 + basic_block bb;
102701 + gimple phi;
102702 + gimple_seq seq;
102703 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
102704 +
102705 + bb = gsi_bb(gsi);
102706 +
102707 + phi = create_phi_node(result, bb);
102708 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
102709 + seq = phi_nodes(bb);
102710 + gsi = gsi_last(seq);
102711 + gsi_remove(&gsi, false);
102712 +
102713 + gsi = gsi_for_stmt(oldstmt);
102714 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
102715 + gimple_set_bb(phi, bb);
102716 + gimple_set_plf(phi, MY_STMT, true);
102717 + return phi;
102718 +}
102719 +
102720 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102721 +{
102722 + gimple new_phi = NULL;
102723 + gimple oldstmt = get_def_stmt(orig_result);
102724 + tree phi_ssa_name = NULL_TREE;
102725 + unsigned int i;
102726 +
102727 + pointer_set_insert(visited, oldstmt);
102728 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102729 + tree arg, new_arg;
102730 +
102731 + arg = gimple_phi_arg_def(oldstmt, i);
102732 +
102733 + new_arg = expand(visited, arg);
102734 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102735 + if (i == 0) {
102736 + phi_ssa_name = new_arg;
102737 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102738 + }
102739 +
102740 + gcc_assert(new_phi != NULL);
102741 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102742 + }
102743 +
102744 + gcc_assert(new_phi != NULL);
102745 + update_stmt(new_phi);
102746 + return gimple_phi_result(new_phi);
102747 +}
102748 +
102749 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
102750 +{
102751 + const_gimple assign;
102752 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102753 + tree origtype = TREE_TYPE(orig_rhs);
102754 +
102755 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
102756 +
102757 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102758 + return gimple_get_lhs(assign);
102759 +}
102760 +
102761 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
102762 +{
102763 + const_tree rhs1, lhs, rhs1_type, lhs_type;
102764 + enum machine_mode lhs_mode, rhs_mode;
102765 + gimple def_stmt = get_def_stmt(no_const_rhs);
102766 +
102767 + if (!gimple_assign_cast_p(def_stmt))
102768 + return false;
102769 +
102770 + rhs1 = gimple_assign_rhs1(def_stmt);
102771 + lhs = gimple_get_lhs(def_stmt);
102772 + rhs1_type = TREE_TYPE(rhs1);
102773 + lhs_type = TREE_TYPE(lhs);
102774 + rhs_mode = TYPE_MODE(rhs1_type);
102775 + lhs_mode = TYPE_MODE(lhs_type);
102776 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102777 + return false;
102778 +
102779 + return true;
102780 +}
102781 +
102782 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102783 +{
102784 + tree rhs1 = gimple_assign_rhs1(stmt);
102785 + tree lhs = gimple_get_lhs(stmt);
102786 + const_tree rhs1_type = TREE_TYPE(rhs1);
102787 + const_tree lhs_type = TREE_TYPE(lhs);
102788 +
102789 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102790 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102791 +
102792 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102793 +}
102794 +
102795 +static bool no_uses(tree node)
102796 +{
102797 + imm_use_iterator imm_iter;
102798 + use_operand_p use_p;
102799 +
102800 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102801 + const_gimple use_stmt = USE_STMT(use_p);
102802 + if (use_stmt == NULL)
102803 + return true;
102804 + if (is_gimple_debug(use_stmt))
102805 + continue;
102806 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102807 + continue;
102808 + return false;
102809 + }
102810 + return true;
102811 +}
102812 +
102813 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102814 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102815 +{
102816 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102817 + gimple def_stmt = get_def_stmt(lhs);
102818 +
102819 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102820 + return false;
102821 +
102822 + rhs1 = gimple_assign_rhs1(def_stmt);
102823 + rhs_type = TREE_TYPE(rhs1);
102824 + lhs_type = TREE_TYPE(lhs);
102825 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102826 + return false;
102827 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102828 + return false;
102829 +
102830 + def_stmt = get_def_stmt(rhs1);
102831 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102832 + return false;
102833 +
102834 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102835 + return false;
102836 +
102837 + rhs1 = gimple_assign_rhs1(def_stmt);
102838 + rhs2 = gimple_assign_rhs2(def_stmt);
102839 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102840 + return false;
102841 +
102842 + if (is_gimple_constant(rhs2))
102843 + not_const_rhs = rhs1;
102844 + else
102845 + not_const_rhs = rhs2;
102846 +
102847 + return no_uses(not_const_rhs);
102848 +}
102849 +
102850 +static bool skip_lhs_cast_check(const_gimple stmt)
102851 +{
102852 + const_tree rhs = gimple_assign_rhs1(stmt);
102853 + const_gimple def_stmt = get_def_stmt(rhs);
102854 +
102855 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102856 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102857 + return true;
102858 +
102859 + if (is_const_plus_unsigned_signed_truncation(rhs))
102860 + return true;
102861 +
102862 + return false;
102863 +}
102864 +
102865 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102866 +{
102867 + bool cast_lhs, cast_rhs;
102868 + tree lhs = gimple_get_lhs(stmt);
102869 + tree rhs = gimple_assign_rhs1(stmt);
102870 + const_tree lhs_type = TREE_TYPE(lhs);
102871 + const_tree rhs_type = TREE_TYPE(rhs);
102872 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102873 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102874 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102875 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102876 +
102877 + static bool check_lhs[3][4] = {
102878 + // ss su us uu
102879 + { false, true, true, false }, // lhs > rhs
102880 + { false, false, false, false }, // lhs = rhs
102881 + { true, true, true, true }, // lhs < rhs
102882 + };
102883 +
102884 + static bool check_rhs[3][4] = {
102885 + // ss su us uu
102886 + { true, false, true, true }, // lhs > rhs
102887 + { true, false, true, true }, // lhs = rhs
102888 + { true, false, true, true }, // lhs < rhs
102889 + };
102890 +
102891 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102892 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102893 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102894 +
102895 + if (lhs_size > rhs_size) {
102896 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102897 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102898 + } else if (lhs_size == rhs_size) {
102899 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102900 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102901 + } else {
102902 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102903 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102904 + }
102905 +
102906 + if (!cast_lhs && !cast_rhs)
102907 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102908 +
102909 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102910 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102911 +
102912 + if (cast_rhs)
102913 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102914 +
102915 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102916 +}
102917 +
102918 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102919 +{
102920 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102921 +
102922 + if (gimple_plf(stmt, MY_STMT))
102923 + return lhs;
102924 +
102925 + rhs1 = gimple_assign_rhs1(stmt);
102926 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102927 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102928 +
102929 + new_rhs1 = expand(visited, rhs1);
102930 +
102931 + if (new_rhs1 == NULL_TREE)
102932 + return create_cast_assign(visited, stmt);
102933 +
102934 + if (gimple_plf(stmt, NO_CAST_CHECK))
102935 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102936 +
102937 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102938 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102939 +
102940 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102941 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102942 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102943 + }
102944 +
102945 + if (!gimple_assign_cast_p(stmt))
102946 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102947 +
102948 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102949 +}
102950 +
102951 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102952 +{
102953 + tree rhs1, lhs = gimple_get_lhs(stmt);
102954 + gimple def_stmt = get_def_stmt(lhs);
102955 +
102956 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102957 + rhs1 = gimple_assign_rhs1(def_stmt);
102958 +
102959 + if (is_gimple_constant(rhs1))
102960 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102961 +
102962 + switch (TREE_CODE(rhs1)) {
102963 + case SSA_NAME:
102964 + return handle_unary_rhs(visited, def_stmt);
102965 + case ARRAY_REF:
102966 + case BIT_FIELD_REF:
102967 + case ADDR_EXPR:
102968 + case COMPONENT_REF:
102969 + case INDIRECT_REF:
102970 +#if BUILDING_GCC_VERSION >= 4006
102971 + case MEM_REF:
102972 +#endif
102973 + case TARGET_MEM_REF:
102974 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102975 + case PARM_DECL:
102976 + case VAR_DECL:
102977 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102978 +
102979 + default:
102980 + debug_gimple_stmt(def_stmt);
102981 + debug_tree(rhs1);
102982 + gcc_unreachable();
102983 + }
102984 +}
102985 +
102986 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102987 +{
102988 + gimple cond_stmt;
102989 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102990 +
102991 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102992 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102993 + update_stmt(cond_stmt);
102994 +}
102995 +
102996 +static tree create_string_param(tree string)
102997 +{
102998 + tree i_type, a_type;
102999 + const int length = TREE_STRING_LENGTH(string);
103000 +
103001 + gcc_assert(length > 0);
103002 +
103003 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
103004 + a_type = build_array_type(char_type_node, i_type);
103005 +
103006 + TREE_TYPE(string) = a_type;
103007 + TREE_CONSTANT(string) = 1;
103008 + TREE_READONLY(string) = 1;
103009 +
103010 + return build1(ADDR_EXPR, ptr_type_node, string);
103011 +}
103012 +
103013 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
103014 +{
103015 + gimple func_stmt;
103016 + const_gimple def_stmt;
103017 + const_tree loc_line;
103018 + tree loc_file, ssa_name, current_func;
103019 + expanded_location xloc;
103020 + char *ssa_name_buf;
103021 + int len;
103022 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
103023 +
103024 + def_stmt = get_def_stmt(arg);
103025 + xloc = expand_location(gimple_location(def_stmt));
103026 +
103027 + if (!gimple_has_location(def_stmt)) {
103028 + xloc = expand_location(gimple_location(stmt));
103029 + if (!gimple_has_location(stmt))
103030 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
103031 + }
103032 +
103033 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
103034 +
103035 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
103036 + loc_file = create_string_param(loc_file);
103037 +
103038 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
103039 + current_func = create_string_param(current_func);
103040 +
103041 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
103042 + call_count++;
103043 + 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);
103044 + gcc_assert(len > 0);
103045 + ssa_name = build_string(len + 1, ssa_name_buf);
103046 + free(ssa_name_buf);
103047 + ssa_name = create_string_param(ssa_name);
103048 +
103049 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
103050 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
103051 +
103052 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
103053 +}
103054 +
103055 +static void __unused print_the_code_insertions(const_gimple stmt)
103056 +{
103057 + location_t loc = gimple_location(stmt);
103058 +
103059 + inform(loc, "Integer size_overflow check applied here.");
103060 +}
103061 +
103062 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
103063 +{
103064 + basic_block cond_bb, join_bb, bb_true;
103065 + edge e;
103066 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103067 +
103068 + cond_bb = gimple_bb(stmt);
103069 + if (before)
103070 + gsi_prev(&gsi);
103071 + if (gsi_end_p(gsi))
103072 + e = split_block_after_labels(cond_bb);
103073 + else
103074 + e = split_block(cond_bb, gsi_stmt(gsi));
103075 + cond_bb = e->src;
103076 + join_bb = e->dest;
103077 + e->flags = EDGE_FALSE_VALUE;
103078 + e->probability = REG_BR_PROB_BASE;
103079 +
103080 + bb_true = create_empty_bb(cond_bb);
103081 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
103082 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
103083 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
103084 +
103085 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
103086 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
103087 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
103088 +
103089 + if (current_loops != NULL) {
103090 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
103091 + add_bb_to_loop(bb_true, cond_bb->loop_father);
103092 + }
103093 +
103094 + insert_cond(cond_bb, arg, cond_code, type_value);
103095 + insert_cond_result(bb_true, stmt, arg, min);
103096 +
103097 +// print_the_code_insertions(stmt);
103098 +}
103099 +
103100 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
103101 +{
103102 + const_tree rhs_type = TREE_TYPE(rhs);
103103 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
103104 +
103105 + gcc_assert(rhs_type != NULL_TREE);
103106 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
103107 + return;
103108 +
103109 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
103110 +
103111 + if (is_const_plus_unsigned_signed_truncation(rhs))
103112 + return;
103113 +
103114 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
103115 + // typemax (-1) < typemin (0)
103116 + if (TREE_OVERFLOW(type_max))
103117 + return;
103118 +
103119 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
103120 +
103121 + cast_rhs_type = TREE_TYPE(cast_rhs);
103122 + type_max_type = TREE_TYPE(type_max);
103123 + type_min_type = TREE_TYPE(type_min);
103124 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
103125 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
103126 +
103127 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
103128 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
103129 +}
103130 +
103131 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
103132 +{
103133 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
103134 + return false;
103135 + if (!is_gimple_constant(rhs))
103136 + return false;
103137 + return true;
103138 +}
103139 +
103140 +static tree get_def_stmt_rhs(const_tree var)
103141 +{
103142 + tree rhs1, def_stmt_rhs1;
103143 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
103144 +
103145 + def_stmt = get_def_stmt(var);
103146 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
103147 +
103148 + rhs1 = gimple_assign_rhs1(def_stmt);
103149 + rhs1_def_stmt = get_def_stmt(rhs1);
103150 + if (!gimple_assign_cast_p(rhs1_def_stmt))
103151 + return rhs1;
103152 +
103153 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103154 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
103155 +
103156 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
103157 + case GIMPLE_CALL:
103158 + case GIMPLE_NOP:
103159 + case GIMPLE_ASM:
103160 + case GIMPLE_PHI:
103161 + return def_stmt_rhs1;
103162 + case GIMPLE_ASSIGN:
103163 + return rhs1;
103164 + default:
103165 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
103166 + gcc_unreachable();
103167 + }
103168 +}
103169 +
103170 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
103171 +{
103172 + tree new_rhs, orig_rhs;
103173 + void (*gimple_assign_set_rhs)(gimple, tree);
103174 + tree rhs1 = gimple_assign_rhs1(stmt);
103175 + tree rhs2 = gimple_assign_rhs2(stmt);
103176 + tree lhs = gimple_get_lhs(stmt);
103177 +
103178 + if (!check_overflow)
103179 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103180 +
103181 + if (change_rhs == NULL_TREE)
103182 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103183 +
103184 + if (new_rhs2 == NULL_TREE) {
103185 + orig_rhs = rhs1;
103186 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
103187 + } else {
103188 + orig_rhs = rhs2;
103189 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
103190 + }
103191 +
103192 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
103193 +
103194 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
103195 + gimple_assign_set_rhs(stmt, new_rhs);
103196 + update_stmt(stmt);
103197 +
103198 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103199 +}
103200 +
103201 +static bool is_subtraction_special(const_gimple stmt)
103202 +{
103203 + gimple rhs1_def_stmt, rhs2_def_stmt;
103204 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
103205 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
103206 + const_tree rhs1 = gimple_assign_rhs1(stmt);
103207 + const_tree rhs2 = gimple_assign_rhs2(stmt);
103208 +
103209 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
103210 + return false;
103211 +
103212 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
103213 +
103214 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
103215 + return false;
103216 +
103217 + rhs1_def_stmt = get_def_stmt(rhs1);
103218 + rhs2_def_stmt = get_def_stmt(rhs2);
103219 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
103220 + return false;
103221 +
103222 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103223 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
103224 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
103225 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
103226 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
103227 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
103228 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
103229 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
103230 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
103231 + return false;
103232 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
103233 + return false;
103234 +
103235 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
103236 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
103237 + return true;
103238 +}
103239 +
103240 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
103241 +{
103242 + tree new_rhs1, new_rhs2;
103243 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
103244 + gimple assign, stmt = get_def_stmt(lhs);
103245 + tree rhs1 = gimple_assign_rhs1(stmt);
103246 + tree rhs2 = gimple_assign_rhs2(stmt);
103247 +
103248 + if (!is_subtraction_special(stmt))
103249 + return NULL_TREE;
103250 +
103251 + new_rhs1 = expand(visited, rhs1);
103252 + new_rhs2 = expand(visited, rhs2);
103253 +
103254 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
103255 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
103256 +
103257 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
103258 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
103259 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
103260 + }
103261 +
103262 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
103263 + new_lhs = gimple_get_lhs(assign);
103264 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
103265 +
103266 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103267 +}
103268 +
103269 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
103270 +{
103271 + const_gimple def_stmt;
103272 +
103273 + if (TREE_CODE(rhs) != SSA_NAME)
103274 + return false;
103275 +
103276 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
103277 + return false;
103278 +
103279 + def_stmt = get_def_stmt(rhs);
103280 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
103281 + return false;
103282 +
103283 + return true;
103284 +}
103285 +
103286 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
103287 +{
103288 + tree rhs1, rhs2, new_lhs;
103289 + gimple def_stmt = get_def_stmt(lhs);
103290 + tree new_rhs1 = NULL_TREE;
103291 + tree new_rhs2 = NULL_TREE;
103292 +
103293 + rhs1 = gimple_assign_rhs1(def_stmt);
103294 + rhs2 = gimple_assign_rhs2(def_stmt);
103295 +
103296 + /* no DImode/TImode division in the 32/64 bit kernel */
103297 + switch (gimple_assign_rhs_code(def_stmt)) {
103298 + case RDIV_EXPR:
103299 + case TRUNC_DIV_EXPR:
103300 + case CEIL_DIV_EXPR:
103301 + case FLOOR_DIV_EXPR:
103302 + case ROUND_DIV_EXPR:
103303 + case TRUNC_MOD_EXPR:
103304 + case CEIL_MOD_EXPR:
103305 + case FLOOR_MOD_EXPR:
103306 + case ROUND_MOD_EXPR:
103307 + case EXACT_DIV_EXPR:
103308 + case POINTER_PLUS_EXPR:
103309 + case BIT_AND_EXPR:
103310 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103311 + default:
103312 + break;
103313 + }
103314 +
103315 + new_lhs = handle_integer_truncation(visited, lhs);
103316 + if (new_lhs != NULL_TREE)
103317 + return new_lhs;
103318 +
103319 + if (TREE_CODE(rhs1) == SSA_NAME)
103320 + new_rhs1 = expand(visited, rhs1);
103321 + if (TREE_CODE(rhs2) == SSA_NAME)
103322 + new_rhs2 = expand(visited, rhs2);
103323 +
103324 + if (is_a_neg_overflow(def_stmt, rhs2))
103325 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
103326 + if (is_a_neg_overflow(def_stmt, rhs1))
103327 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
103328 +
103329 +
103330 + if (is_a_constant_overflow(def_stmt, rhs2))
103331 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
103332 + if (is_a_constant_overflow(def_stmt, rhs1))
103333 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
103334 +
103335 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103336 +}
103337 +
103338 +#if BUILDING_GCC_VERSION >= 4007
103339 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
103340 +{
103341 + if (is_gimple_constant(rhs))
103342 + return cast_a_tree(size_overflow_type, rhs);
103343 + if (TREE_CODE(rhs) != SSA_NAME)
103344 + return NULL_TREE;
103345 + return expand(visited, rhs);
103346 +}
103347 +
103348 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
103349 +{
103350 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
103351 + gimple def_stmt = get_def_stmt(lhs);
103352 +
103353 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
103354 +
103355 + rhs1 = gimple_assign_rhs1(def_stmt);
103356 + rhs2 = gimple_assign_rhs2(def_stmt);
103357 + rhs3 = gimple_assign_rhs3(def_stmt);
103358 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
103359 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
103360 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
103361 +
103362 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
103363 +}
103364 +#endif
103365 +
103366 +static tree get_size_overflow_type(gimple stmt, const_tree node)
103367 +{
103368 + const_tree type;
103369 + tree new_type;
103370 +
103371 + gcc_assert(node != NULL_TREE);
103372 +
103373 + type = TREE_TYPE(node);
103374 +
103375 + if (gimple_plf(stmt, MY_STMT))
103376 + return TREE_TYPE(node);
103377 +
103378 + switch (TYPE_MODE(type)) {
103379 + case QImode:
103380 + new_type = intHI_type_node;
103381 + break;
103382 + case HImode:
103383 + new_type = intSI_type_node;
103384 + break;
103385 + case SImode:
103386 + new_type = intDI_type_node;
103387 + break;
103388 + case DImode:
103389 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
103390 + new_type = intDI_type_node;
103391 + else
103392 + new_type = intTI_type_node;
103393 + break;
103394 + default:
103395 + debug_tree((tree)node);
103396 + error("%s: unsupported gcc configuration.", __func__);
103397 + gcc_unreachable();
103398 + }
103399 +
103400 + if (TYPE_QUALS(type) != 0)
103401 + return build_qualified_type(new_type, TYPE_QUALS(type));
103402 + return new_type;
103403 +}
103404 +
103405 +static tree expand_visited(gimple def_stmt)
103406 +{
103407 + const_gimple next_stmt;
103408 + gimple_stmt_iterator gsi;
103409 + enum gimple_code code = gimple_code(def_stmt);
103410 +
103411 + if (code == GIMPLE_ASM)
103412 + return NULL_TREE;
103413 +
103414 + gsi = gsi_for_stmt(def_stmt);
103415 + gsi_next(&gsi);
103416 +
103417 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
103418 + return NULL_TREE;
103419 + gcc_assert(!gsi_end_p(gsi));
103420 + next_stmt = gsi_stmt(gsi);
103421 +
103422 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
103423 + return NULL_TREE;
103424 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
103425 +
103426 + return get_lhs(next_stmt);
103427 +}
103428 +
103429 +static tree expand(struct pointer_set_t *visited, tree lhs)
103430 +{
103431 + gimple def_stmt;
103432 +
103433 + if (skip_types(lhs))
103434 + return NULL_TREE;
103435 +
103436 + def_stmt = get_def_stmt(lhs);
103437 +
103438 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
103439 + return NULL_TREE;
103440 +
103441 + if (gimple_plf(def_stmt, MY_STMT))
103442 + return lhs;
103443 +
103444 + if (pointer_set_contains(visited, def_stmt))
103445 + return expand_visited(def_stmt);
103446 +
103447 + switch (gimple_code(def_stmt)) {
103448 + case GIMPLE_PHI:
103449 + return handle_phi(visited, lhs);
103450 + case GIMPLE_CALL:
103451 + case GIMPLE_ASM:
103452 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103453 + case GIMPLE_ASSIGN:
103454 + switch (gimple_num_ops(def_stmt)) {
103455 + case 2:
103456 + return handle_unary_ops(visited, def_stmt);
103457 + case 3:
103458 + return handle_binary_ops(visited, lhs);
103459 +#if BUILDING_GCC_VERSION >= 4007
103460 + case 4:
103461 + return handle_ternary_ops(visited, lhs);
103462 +#endif
103463 + }
103464 + default:
103465 + debug_gimple_stmt(def_stmt);
103466 + error("%s: unknown gimple code", __func__);
103467 + gcc_unreachable();
103468 + }
103469 +}
103470 +
103471 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
103472 +{
103473 + const_gimple assign;
103474 + tree orig_type = TREE_TYPE(orig_node);
103475 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103476 +
103477 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
103478 + return gimple_get_lhs(assign);
103479 +}
103480 +
103481 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
103482 +{
103483 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
103484 + update_stmt(stmt);
103485 +}
103486 +
103487 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
103488 +{
103489 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
103490 + update_stmt(stmt);
103491 +}
103492 +
103493 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
103494 +{
103495 + tree arg;
103496 + const_tree origarg;
103497 +
103498 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
103499 + return true;
103500 +
103501 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
103502 + while (origarg && *argnum) {
103503 + (*argnum)--;
103504 + origarg = TREE_CHAIN(origarg);
103505 + }
103506 +
103507 + gcc_assert(*argnum == 0);
103508 +
103509 + gcc_assert(origarg != NULL_TREE);
103510 + *argnum = 0;
103511 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
103512 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
103513 + return true;
103514 + return false;
103515 +}
103516 +
103517 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
103518 +{
103519 + gimple phi = get_def_stmt(result);
103520 + unsigned int i, n = gimple_phi_num_args(phi);
103521 +
103522 + if (!phi)
103523 + return MARK_NO;
103524 +
103525 + pointer_set_insert(visited, phi);
103526 + for (i = 0; i < n; i++) {
103527 + enum mark marked;
103528 + const_tree arg = gimple_phi_arg_def(phi, i);
103529 + marked = pre_expand(visited, search_err_code, arg);
103530 + if (marked != MARK_NO)
103531 + return marked;
103532 + }
103533 + return MARK_NO;
103534 +}
103535 +
103536 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103537 +{
103538 + gimple def_stmt = get_def_stmt(lhs);
103539 + const_tree rhs;
103540 +
103541 + if (!def_stmt)
103542 + return MARK_NO;
103543 +
103544 + rhs = gimple_assign_rhs1(def_stmt);
103545 +
103546 + def_stmt = get_def_stmt(rhs);
103547 + if (is_gimple_constant(rhs))
103548 + search_err_code[FROM_CONST] = true;
103549 +
103550 + return pre_expand(visited, search_err_code, rhs);
103551 +}
103552 +
103553 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103554 +{
103555 + gimple def_stmt = get_def_stmt(lhs);
103556 + const_tree rhs1, rhs2;
103557 + enum mark marked;
103558 +
103559 + if (!def_stmt)
103560 + return MARK_NO;
103561 +
103562 + search_err_code[CAST_ONLY] = false;
103563 +
103564 + rhs1 = gimple_assign_rhs1(def_stmt);
103565 + rhs2 = gimple_assign_rhs2(def_stmt);
103566 + marked = pre_expand(visited, search_err_code, rhs1);
103567 + if (marked != MARK_NO)
103568 + return marked;
103569 + return pre_expand(visited, search_err_code, rhs2);
103570 +}
103571 +
103572 +static const_tree search_field_decl(const_tree comp_ref)
103573 +{
103574 + const_tree field = NULL_TREE;
103575 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
103576 +
103577 + for (i = 0; i < len; i++) {
103578 + field = TREE_OPERAND(comp_ref, i);
103579 + if (TREE_CODE(field) == FIELD_DECL)
103580 + break;
103581 + }
103582 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
103583 + return field;
103584 +}
103585 +
103586 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
103587 +{
103588 + const_tree attr, p;
103589 +
103590 + // 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);
103591 + if (fndecl == NULL_TREE)
103592 + return MARK_NO;
103593 +
103594 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
103595 + if (!attr || !TREE_VALUE(attr))
103596 + return MARK_NO;
103597 +
103598 + p = TREE_VALUE(attr);
103599 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
103600 + return MARK_TURN_OFF;
103601 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
103602 + return MARK_NOT_INTENTIONAL;
103603 + if (argnum == 0) {
103604 + gcc_assert(current_function_decl == fndecl);
103605 + return MARK_NO;
103606 + }
103607 +
103608 + do {
103609 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
103610 + return MARK_YES;
103611 + p = TREE_CHAIN(p);
103612 + } while (p);
103613 +
103614 + return MARK_NO;
103615 +}
103616 +
103617 +static void print_missing_msg(tree func, unsigned int argnum)
103618 +{
103619 + unsigned int new_hash;
103620 + size_t len;
103621 + unsigned char tree_codes[CODES_LIMIT];
103622 + location_t loc;
103623 + const char *curfunc;
103624 +
103625 + func = get_original_function_decl(func);
103626 + loc = DECL_SOURCE_LOCATION(func);
103627 + curfunc = get_asm_name(func);
103628 +
103629 + len = get_function_decl(func, tree_codes);
103630 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
103631 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
103632 +}
103633 +
103634 +static unsigned int search_missing_attribute(const_tree arg)
103635 +{
103636 + unsigned int argnum;
103637 + const struct size_overflow_hash *hash;
103638 + const_tree type = TREE_TYPE(arg);
103639 + tree func = get_original_function_decl(current_function_decl);
103640 +
103641 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
103642 +
103643 + if (TREE_CODE(type) == POINTER_TYPE)
103644 + return 0;
103645 +
103646 + argnum = find_arg_number(arg, func);
103647 + if (argnum == 0)
103648 + return 0;
103649 +
103650 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
103651 + return argnum;
103652 +
103653 + hash = get_function_hash(func);
103654 + if (!hash || !(hash->param & (1U << argnum))) {
103655 + print_missing_msg(func, argnum);
103656 + return 0;
103657 + }
103658 + return argnum;
103659 +}
103660 +
103661 +static enum mark is_already_marked(const_tree lhs)
103662 +{
103663 + unsigned int argnum;
103664 + const_tree fndecl;
103665 +
103666 + argnum = search_missing_attribute(lhs);
103667 + fndecl = get_original_function_decl(current_function_decl);
103668 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
103669 + return MARK_YES;
103670 + return MARK_NO;
103671 +}
103672 +
103673 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103674 +{
103675 + const_gimple def_stmt;
103676 +
103677 + if (skip_types(lhs))
103678 + return MARK_NO;
103679 +
103680 + if (TREE_CODE(lhs) == PARM_DECL)
103681 + return is_already_marked(lhs);
103682 +
103683 + if (TREE_CODE(lhs) == COMPONENT_REF) {
103684 + const_tree field, attr;
103685 +
103686 + field = search_field_decl(lhs);
103687 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
103688 + if (!attr || !TREE_VALUE(attr))
103689 + return MARK_NO;
103690 + return MARK_YES;
103691 + }
103692 +
103693 + def_stmt = get_def_stmt(lhs);
103694 +
103695 + if (!def_stmt)
103696 + return MARK_NO;
103697 +
103698 + if (pointer_set_contains(visited, def_stmt))
103699 + return MARK_NO;
103700 +
103701 + switch (gimple_code(def_stmt)) {
103702 + case GIMPLE_NOP:
103703 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
103704 + return is_already_marked(lhs);
103705 + return MARK_NO;
103706 + case GIMPLE_PHI:
103707 + return walk_phi(visited, search_err_code, lhs);
103708 + case GIMPLE_CALL:
103709 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
103710 + return MARK_TURN_OFF;
103711 + check_function_hash(def_stmt);
103712 + return MARK_NO;
103713 + case GIMPLE_ASM:
103714 + search_err_code[CAST_ONLY] = false;
103715 + return MARK_NO;
103716 + case GIMPLE_ASSIGN:
103717 + switch (gimple_num_ops(def_stmt)) {
103718 + case 2:
103719 + return walk_unary_ops(visited, search_err_code, lhs);
103720 + case 3:
103721 + return walk_binary_ops(visited, search_err_code, lhs);
103722 + }
103723 + default:
103724 + debug_gimple_stmt((gimple)def_stmt);
103725 + error("%s: unknown gimple code", __func__);
103726 + gcc_unreachable();
103727 + }
103728 +}
103729 +
103730 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103731 +static bool skip_asm(const_tree arg)
103732 +{
103733 + gimple def_stmt = get_def_stmt(arg);
103734 +
103735 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103736 + return false;
103737 +
103738 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103739 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103740 +}
103741 +
103742 +/*
103743 +0</MARK_YES: no dup, search attributes (so, int)
103744 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103745 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103746 +*/
103747 +
103748 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
103749 +{
103750 + struct pointer_set_t *visited;
103751 + enum mark is_marked, is_found;
103752 + location_t loc;
103753 + bool search_err_code[2] = {true, false};
103754 +
103755 + is_marked = mark_status(current_function_decl, 0);
103756 + if (is_marked == MARK_TURN_OFF)
103757 + return true;
103758 +
103759 + is_marked = mark_status(fndecl, argnum + 1);
103760 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
103761 + return true;
103762 +
103763 + visited = pointer_set_create();
103764 + is_found = pre_expand(visited, search_err_code, arg);
103765 + pointer_set_destroy(visited);
103766 +
103767 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
103768 + return true;
103769 +
103770 + if (where == FROM_ARG && skip_asm(arg))
103771 + return true;
103772 +
103773 + if (is_found == MARK_TURN_OFF)
103774 + return true;
103775 +
103776 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103777 + return true;
103778 +
103779 + if (is_found == MARK_YES) {
103780 + loc = DECL_SOURCE_LOCATION(fndecl);
103781 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103782 + return true;
103783 + }
103784 + return false;
103785 +}
103786 +
103787 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103788 +{
103789 + struct pointer_set_t *visited;
103790 + tree arg, new_arg;
103791 + bool match;
103792 +
103793 + if (argnum == 0)
103794 + return;
103795 +
103796 + argnum--;
103797 +
103798 + match = get_function_arg(&argnum, fndecl);
103799 + if (!match)
103800 + return;
103801 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103802 + arg = gimple_call_arg(stmt, argnum);
103803 + if (arg == NULL_TREE)
103804 + return;
103805 +
103806 + if (skip_types(arg))
103807 + return;
103808 +
103809 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103810 + return;
103811 +
103812 + visited = pointer_set_create();
103813 + new_arg = expand(visited, arg);
103814 + pointer_set_destroy(visited);
103815 +
103816 + if (new_arg == NULL_TREE)
103817 + return;
103818 +
103819 + change_function_arg(stmt, arg, argnum, new_arg);
103820 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103821 +}
103822 +
103823 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103824 +{
103825 + tree p = TREE_VALUE(attr);
103826 + do {
103827 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103828 + p = TREE_CHAIN(p);
103829 + } while (p);
103830 +}
103831 +
103832 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103833 +{
103834 + unsigned int num;
103835 + const struct size_overflow_hash *hash;
103836 +
103837 + hash = get_function_hash(fndecl);
103838 + if (!hash)
103839 + return;
103840 +
103841 + for (num = 0; num <= MAX_PARAM; num++)
103842 + if (hash->param & (1U << num))
103843 + handle_function_arg(stmt, fndecl, num);
103844 +}
103845 +
103846 +static bool check_return_value(void)
103847 +{
103848 + const struct size_overflow_hash *hash;
103849 +
103850 + hash = get_function_hash(current_function_decl);
103851 + if (!hash || !(hash->param & 1U << 0))
103852 + return false;
103853 +
103854 + return true;
103855 +}
103856 +
103857 +static void handle_return_value(gimple ret_stmt)
103858 +{
103859 + struct pointer_set_t *visited;
103860 + tree ret, new_ret;
103861 +
103862 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103863 + return;
103864 +
103865 + ret = gimple_return_retval(ret_stmt);
103866 +
103867 + if (skip_types(ret))
103868 + return;
103869 +
103870 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103871 + return;
103872 +
103873 + visited = pointer_set_create();
103874 + new_ret = expand(visited, ret);
103875 + pointer_set_destroy(visited);
103876 +
103877 + change_function_return(ret_stmt, ret, new_ret);
103878 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103879 +}
103880 +
103881 +static void set_plf_false(void)
103882 +{
103883 + basic_block bb;
103884 +
103885 + FOR_ALL_BB(bb) {
103886 + gimple_stmt_iterator si;
103887 +
103888 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103889 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103890 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103891 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103892 + }
103893 +}
103894 +
103895 +static unsigned int handle_function(void)
103896 +{
103897 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103898 + bool check_ret;
103899 +
103900 + set_plf_false();
103901 +
103902 + check_ret = check_return_value();
103903 +
103904 + do {
103905 + gimple_stmt_iterator gsi;
103906 + next = bb->next_bb;
103907 +
103908 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103909 + tree fndecl, attr;
103910 + gimple stmt = gsi_stmt(gsi);
103911 +
103912 + if (check_ret)
103913 + handle_return_value(stmt);
103914 +
103915 + if (!(is_gimple_call(stmt)))
103916 + continue;
103917 + fndecl = gimple_call_fndecl(stmt);
103918 + if (fndecl == NULL_TREE)
103919 + continue;
103920 + if (gimple_call_num_args(stmt) == 0)
103921 + continue;
103922 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103923 + if (!attr || !TREE_VALUE(attr))
103924 + handle_function_by_hash(stmt, fndecl);
103925 + else
103926 + handle_function_by_attribute(stmt, attr, fndecl);
103927 + gsi = gsi_for_stmt(stmt);
103928 + next = gimple_bb(stmt)->next_bb;
103929 + }
103930 + bb = next;
103931 + } while (bb);
103932 + return 0;
103933 +}
103934 +
103935 +static struct gimple_opt_pass size_overflow_pass = {
103936 + .pass = {
103937 + .type = GIMPLE_PASS,
103938 + .name = "size_overflow",
103939 +#if BUILDING_GCC_VERSION >= 4008
103940 + .optinfo_flags = OPTGROUP_NONE,
103941 +#endif
103942 + .gate = NULL,
103943 + .execute = handle_function,
103944 + .sub = NULL,
103945 + .next = NULL,
103946 + .static_pass_number = 0,
103947 + .tv_id = TV_NONE,
103948 + .properties_required = PROP_cfg,
103949 + .properties_provided = 0,
103950 + .properties_destroyed = 0,
103951 + .todo_flags_start = 0,
103952 + .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
103953 + }
103954 +};
103955 +
103956 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103957 +{
103958 + tree fntype;
103959 +
103960 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103961 +
103962 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103963 + fntype = build_function_type_list(void_type_node,
103964 + const_char_ptr_type_node,
103965 + unsigned_type_node,
103966 + const_char_ptr_type_node,
103967 + const_char_ptr_type_node,
103968 + NULL_TREE);
103969 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103970 +
103971 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103972 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103973 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103974 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103975 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103976 +}
103977 +
103978 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103979 +{
103980 + int i;
103981 + const char * const plugin_name = plugin_info->base_name;
103982 + const int argc = plugin_info->argc;
103983 + const struct plugin_argument * const argv = plugin_info->argv;
103984 + bool enable = true;
103985 +
103986 + struct register_pass_info size_overflow_pass_info = {
103987 + .pass = &size_overflow_pass.pass,
103988 + .reference_pass_name = "ssa",
103989 + .ref_pass_instance_number = 1,
103990 + .pos_op = PASS_POS_INSERT_AFTER
103991 + };
103992 +
103993 + if (!plugin_default_version_check(version, &gcc_version)) {
103994 + error(G_("incompatible gcc/plugin versions"));
103995 + return 1;
103996 + }
103997 +
103998 + for (i = 0; i < argc; ++i) {
103999 + if (!strcmp(argv[i].key, "no-size-overflow")) {
104000 + enable = false;
104001 + continue;
104002 + }
104003 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104004 + }
104005 +
104006 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
104007 + if (enable) {
104008 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
104009 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
104010 + }
104011 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104012 +
104013 + return 0;
104014 +}
104015 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
104016 new file mode 100644
104017 index 0000000..ac2901e
104018 --- /dev/null
104019 +++ b/tools/gcc/stackleak_plugin.c
104020 @@ -0,0 +1,327 @@
104021 +/*
104022 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
104023 + * Licensed under the GPL v2
104024 + *
104025 + * Note: the choice of the license means that the compilation process is
104026 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104027 + * but for the kernel it doesn't matter since it doesn't link against
104028 + * any of the gcc libraries
104029 + *
104030 + * gcc plugin to help implement various PaX features
104031 + *
104032 + * - track lowest stack pointer
104033 + *
104034 + * TODO:
104035 + * - initialize all local variables
104036 + *
104037 + * BUGS:
104038 + * - none known
104039 + */
104040 +#include "gcc-plugin.h"
104041 +#include "config.h"
104042 +#include "system.h"
104043 +#include "coretypes.h"
104044 +#include "tree.h"
104045 +#include "tree-pass.h"
104046 +#include "flags.h"
104047 +#include "intl.h"
104048 +#include "toplev.h"
104049 +#include "plugin.h"
104050 +//#include "expr.h" where are you...
104051 +#include "diagnostic.h"
104052 +#include "plugin-version.h"
104053 +#include "tm.h"
104054 +#include "function.h"
104055 +#include "basic-block.h"
104056 +#include "gimple.h"
104057 +#include "rtl.h"
104058 +#include "emit-rtl.h"
104059 +
104060 +#if BUILDING_GCC_VERSION >= 4008
104061 +#define TODO_dump_func 0
104062 +#endif
104063 +
104064 +extern void print_gimple_stmt(FILE *, gimple, int, int);
104065 +
104066 +int plugin_is_GPL_compatible;
104067 +
104068 +static int track_frame_size = -1;
104069 +static const char track_function[] = "pax_track_stack";
104070 +static const char check_function[] = "pax_check_alloca";
104071 +static bool init_locals;
104072 +
104073 +static struct plugin_info stackleak_plugin_info = {
104074 + .version = "201302112000",
104075 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
104076 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
104077 +};
104078 +
104079 +static bool gate_stackleak_track_stack(void);
104080 +static unsigned int execute_stackleak_tree_instrument(void);
104081 +static unsigned int execute_stackleak_final(void);
104082 +
104083 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
104084 + .pass = {
104085 + .type = GIMPLE_PASS,
104086 + .name = "stackleak_tree_instrument",
104087 +#if BUILDING_GCC_VERSION >= 4008
104088 + .optinfo_flags = OPTGROUP_NONE,
104089 +#endif
104090 + .gate = gate_stackleak_track_stack,
104091 + .execute = execute_stackleak_tree_instrument,
104092 + .sub = NULL,
104093 + .next = NULL,
104094 + .static_pass_number = 0,
104095 + .tv_id = TV_NONE,
104096 + .properties_required = PROP_gimple_leh | PROP_cfg,
104097 + .properties_provided = 0,
104098 + .properties_destroyed = 0,
104099 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
104100 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
104101 + }
104102 +};
104103 +
104104 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
104105 + .pass = {
104106 + .type = RTL_PASS,
104107 + .name = "stackleak_final",
104108 +#if BUILDING_GCC_VERSION >= 4008
104109 + .optinfo_flags = OPTGROUP_NONE,
104110 +#endif
104111 + .gate = gate_stackleak_track_stack,
104112 + .execute = execute_stackleak_final,
104113 + .sub = NULL,
104114 + .next = NULL,
104115 + .static_pass_number = 0,
104116 + .tv_id = TV_NONE,
104117 + .properties_required = 0,
104118 + .properties_provided = 0,
104119 + .properties_destroyed = 0,
104120 + .todo_flags_start = 0,
104121 + .todo_flags_finish = TODO_dump_func
104122 + }
104123 +};
104124 +
104125 +static bool gate_stackleak_track_stack(void)
104126 +{
104127 + return track_frame_size >= 0;
104128 +}
104129 +
104130 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
104131 +{
104132 + gimple check_alloca;
104133 + tree fntype, fndecl, alloca_size;
104134 +
104135 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
104136 + fndecl = build_fn_decl(check_function, fntype);
104137 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104138 +
104139 + // insert call to void pax_check_alloca(unsigned long size)
104140 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
104141 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
104142 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
104143 +}
104144 +
104145 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
104146 +{
104147 + gimple track_stack;
104148 + tree fntype, fndecl;
104149 +
104150 + fntype = build_function_type_list(void_type_node, NULL_TREE);
104151 + fndecl = build_fn_decl(track_function, fntype);
104152 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104153 +
104154 + // insert call to void pax_track_stack(void)
104155 + track_stack = gimple_build_call(fndecl, 0);
104156 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
104157 +}
104158 +
104159 +#if BUILDING_GCC_VERSION == 4005
104160 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
104161 +{
104162 + tree fndecl;
104163 +
104164 + if (!is_gimple_call(stmt))
104165 + return false;
104166 + fndecl = gimple_call_fndecl(stmt);
104167 + if (!fndecl)
104168 + return false;
104169 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
104170 + return false;
104171 +// print_node(stderr, "pax", fndecl, 4);
104172 + return DECL_FUNCTION_CODE(fndecl) == code;
104173 +}
104174 +#endif
104175 +
104176 +static bool is_alloca(gimple stmt)
104177 +{
104178 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
104179 + return true;
104180 +
104181 +#if BUILDING_GCC_VERSION >= 4007
104182 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
104183 + return true;
104184 +#endif
104185 +
104186 + return false;
104187 +}
104188 +
104189 +static unsigned int execute_stackleak_tree_instrument(void)
104190 +{
104191 + basic_block bb, entry_bb;
104192 + bool prologue_instrumented = false, is_leaf = true;
104193 +
104194 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
104195 +
104196 + // 1. loop through BBs and GIMPLE statements
104197 + FOR_EACH_BB(bb) {
104198 + gimple_stmt_iterator gsi;
104199 +
104200 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104201 + gimple stmt;
104202 +
104203 + stmt = gsi_stmt(gsi);
104204 +
104205 + if (is_gimple_call(stmt))
104206 + is_leaf = false;
104207 +
104208 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
104209 + if (!is_alloca(stmt))
104210 + continue;
104211 +
104212 + // 2. insert stack overflow check before each __builtin_alloca call
104213 + stackleak_check_alloca(&gsi);
104214 +
104215 + // 3. insert track call after each __builtin_alloca call
104216 + stackleak_add_instrumentation(&gsi);
104217 + if (bb == entry_bb)
104218 + prologue_instrumented = true;
104219 + }
104220 + }
104221 +
104222 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
104223 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
104224 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
104225 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
104226 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
104227 + return 0;
104228 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
104229 + return 0;
104230 +
104231 + // 4. insert track call at the beginning
104232 + if (!prologue_instrumented) {
104233 + gimple_stmt_iterator gsi;
104234 +
104235 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104236 + if (dom_info_available_p(CDI_DOMINATORS))
104237 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104238 + gsi = gsi_start_bb(bb);
104239 + stackleak_add_instrumentation(&gsi);
104240 + }
104241 +
104242 + return 0;
104243 +}
104244 +
104245 +static unsigned int execute_stackleak_final(void)
104246 +{
104247 + rtx insn, next;
104248 +
104249 + if (cfun->calls_alloca)
104250 + return 0;
104251 +
104252 + // keep calls only if function frame is big enough
104253 + if (get_frame_size() >= track_frame_size)
104254 + return 0;
104255 +
104256 + // 1. find pax_track_stack calls
104257 + for (insn = get_insns(); insn; insn = next) {
104258 + // 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))
104259 + rtx body;
104260 +
104261 + next = NEXT_INSN(insn);
104262 + if (!CALL_P(insn))
104263 + continue;
104264 + body = PATTERN(insn);
104265 + if (GET_CODE(body) != CALL)
104266 + continue;
104267 + body = XEXP(body, 0);
104268 + if (GET_CODE(body) != MEM)
104269 + continue;
104270 + body = XEXP(body, 0);
104271 + if (GET_CODE(body) != SYMBOL_REF)
104272 + continue;
104273 + if (strcmp(XSTR(body, 0), track_function))
104274 + continue;
104275 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104276 + // 2. delete call
104277 + delete_insn_and_edges(insn);
104278 +#if BUILDING_GCC_VERSION >= 4007
104279 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
104280 + insn = next;
104281 + next = NEXT_INSN(insn);
104282 + delete_insn_and_edges(insn);
104283 + }
104284 +#endif
104285 + }
104286 +
104287 +// print_simple_rtl(stderr, get_insns());
104288 +// print_rtl(stderr, get_insns());
104289 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104290 +
104291 + return 0;
104292 +}
104293 +
104294 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104295 +{
104296 + const char * const plugin_name = plugin_info->base_name;
104297 + const int argc = plugin_info->argc;
104298 + const struct plugin_argument * const argv = plugin_info->argv;
104299 + int i;
104300 + struct register_pass_info stackleak_tree_instrument_pass_info = {
104301 + .pass = &stackleak_tree_instrument_pass.pass,
104302 +// .reference_pass_name = "tree_profile",
104303 + .reference_pass_name = "optimized",
104304 + .ref_pass_instance_number = 1,
104305 + .pos_op = PASS_POS_INSERT_BEFORE
104306 + };
104307 + struct register_pass_info stackleak_final_pass_info = {
104308 + .pass = &stackleak_final_rtl_opt_pass.pass,
104309 + .reference_pass_name = "final",
104310 + .ref_pass_instance_number = 1,
104311 + .pos_op = PASS_POS_INSERT_BEFORE
104312 + };
104313 +
104314 + if (!plugin_default_version_check(version, &gcc_version)) {
104315 + error(G_("incompatible gcc/plugin versions"));
104316 + return 1;
104317 + }
104318 +
104319 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
104320 +
104321 + for (i = 0; i < argc; ++i) {
104322 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
104323 + if (!argv[i].value) {
104324 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104325 + continue;
104326 + }
104327 + track_frame_size = atoi(argv[i].value);
104328 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
104329 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104330 + continue;
104331 + }
104332 + if (!strcmp(argv[i].key, "initialize-locals")) {
104333 + if (argv[i].value) {
104334 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104335 + continue;
104336 + }
104337 + init_locals = true;
104338 + continue;
104339 + }
104340 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104341 + }
104342 +
104343 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
104344 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
104345 +
104346 + return 0;
104347 +}
104348 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
104349 new file mode 100644
104350 index 0000000..4fae911
104351 --- /dev/null
104352 +++ b/tools/gcc/structleak_plugin.c
104353 @@ -0,0 +1,277 @@
104354 +/*
104355 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
104356 + * Licensed under the GPL v2
104357 + *
104358 + * Note: the choice of the license means that the compilation process is
104359 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104360 + * but for the kernel it doesn't matter since it doesn't link against
104361 + * any of the gcc libraries
104362 + *
104363 + * gcc plugin to forcibly initialize certain local variables that could
104364 + * otherwise leak kernel stack to userland if they aren't properly initialized
104365 + * by later code
104366 + *
104367 + * Homepage: http://pax.grsecurity.net/
104368 + *
104369 + * Usage:
104370 + * $ # for 4.5/4.6/C based 4.7
104371 + * $ 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
104372 + * $ # for C++ based 4.7/4.8+
104373 + * $ 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
104374 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
104375 + *
104376 + * TODO: eliminate redundant initializers
104377 + * increase type coverage
104378 + */
104379 +
104380 +#include "gcc-plugin.h"
104381 +#include "config.h"
104382 +#include "system.h"
104383 +#include "coretypes.h"
104384 +#include "tree.h"
104385 +#include "tree-pass.h"
104386 +#include "intl.h"
104387 +#include "plugin-version.h"
104388 +#include "tm.h"
104389 +#include "toplev.h"
104390 +#include "function.h"
104391 +#include "tree-flow.h"
104392 +#include "plugin.h"
104393 +#include "gimple.h"
104394 +#include "diagnostic.h"
104395 +#include "cfgloop.h"
104396 +#include "langhooks.h"
104397 +
104398 +#if BUILDING_GCC_VERSION >= 4008
104399 +#define TODO_dump_func 0
104400 +#endif
104401 +
104402 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
104403 +
104404 +// unused type flag in all versions 4.5-4.8
104405 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
104406 +
104407 +int plugin_is_GPL_compatible;
104408 +void debug_gimple_stmt(gimple gs);
104409 +
104410 +static struct plugin_info structleak_plugin_info = {
104411 + .version = "201304082245",
104412 + .help = "disable\tdo not activate plugin\n",
104413 +};
104414 +
104415 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
104416 +{
104417 + *no_add_attrs = true;
104418 +
104419 + // check for types? for now accept everything linux has to offer
104420 + if (TREE_CODE(*node) != FIELD_DECL)
104421 + return NULL_TREE;
104422 +
104423 + *no_add_attrs = false;
104424 + return NULL_TREE;
104425 +}
104426 +
104427 +static struct attribute_spec user_attr = {
104428 + .name = "user",
104429 + .min_length = 0,
104430 + .max_length = 0,
104431 + .decl_required = false,
104432 + .type_required = false,
104433 + .function_type_required = false,
104434 + .handler = handle_user_attribute,
104435 +#if BUILDING_GCC_VERSION >= 4007
104436 + .affects_type_identity = true
104437 +#endif
104438 +};
104439 +
104440 +static void register_attributes(void *event_data, void *data)
104441 +{
104442 + register_attribute(&user_attr);
104443 +// register_attribute(&force_attr);
104444 +}
104445 +
104446 +static tree get_field_type(tree field)
104447 +{
104448 + return strip_array_types(TREE_TYPE(field));
104449 +}
104450 +
104451 +static bool is_userspace_type(tree type)
104452 +{
104453 + tree field;
104454 +
104455 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
104456 + tree fieldtype = get_field_type(field);
104457 + enum tree_code code = TREE_CODE(fieldtype);
104458 +
104459 + if (code == RECORD_TYPE || code == UNION_TYPE)
104460 + if (is_userspace_type(fieldtype))
104461 + return true;
104462 +
104463 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
104464 + return true;
104465 + }
104466 + return false;
104467 +}
104468 +
104469 +static void finish_type(void *event_data, void *data)
104470 +{
104471 + tree type = (tree)event_data;
104472 +
104473 + if (TYPE_USERSPACE(type))
104474 + return;
104475 +
104476 + if (is_userspace_type(type))
104477 + TYPE_USERSPACE(type) = 1;
104478 +}
104479 +
104480 +static void initialize(tree var)
104481 +{
104482 + basic_block bb;
104483 + gimple_stmt_iterator gsi;
104484 + tree initializer;
104485 + gimple init_stmt;
104486 +
104487 + // this is the original entry bb before the forced split
104488 + // TODO: check further BBs in case more splits occured before us
104489 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
104490 +
104491 + // first check if the variable is already initialized, warn otherwise
104492 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104493 + gimple stmt = gsi_stmt(gsi);
104494 + tree rhs1;
104495 +
104496 + // we're looking for an assignment of a single rhs...
104497 + if (!gimple_assign_single_p(stmt))
104498 + continue;
104499 + rhs1 = gimple_assign_rhs1(stmt);
104500 +#if BUILDING_GCC_VERSION >= 4007
104501 + // ... of a non-clobbering expression...
104502 + if (TREE_CLOBBER_P(rhs1))
104503 + continue;
104504 +#endif
104505 + // ... to our variable...
104506 + if (gimple_get_lhs(stmt) != var)
104507 + continue;
104508 + // if it's an initializer then we're good
104509 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
104510 + return;
104511 + }
104512 +
104513 + // these aren't the 0days you're looking for
104514 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
104515 +
104516 + // build the initializer expression
104517 + initializer = build_constructor(TREE_TYPE(var), NULL);
104518 +
104519 + // build the initializer stmt
104520 + init_stmt = gimple_build_assign(var, initializer);
104521 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
104522 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
104523 + update_stmt(init_stmt);
104524 +}
104525 +
104526 +static unsigned int handle_function(void)
104527 +{
104528 + basic_block bb;
104529 + unsigned int ret = 0;
104530 + tree var;
104531 +
104532 +#if BUILDING_GCC_VERSION == 4005
104533 + tree vars;
104534 +#else
104535 + unsigned int i;
104536 +#endif
104537 +
104538 + // split the first bb where we can put the forced initializers
104539 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104540 + if (dom_info_available_p(CDI_DOMINATORS))
104541 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104542 +
104543 + // enumarate all local variables and forcibly initialize our targets
104544 +#if BUILDING_GCC_VERSION == 4005
104545 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
104546 + var = TREE_VALUE(vars);
104547 +#else
104548 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
104549 +#endif
104550 + tree type = TREE_TYPE(var);
104551 +
104552 + gcc_assert(DECL_P(var));
104553 + if (!auto_var_in_fn_p(var, current_function_decl))
104554 + continue;
104555 +
104556 + // only care about structure types
104557 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
104558 + continue;
104559 +
104560 + // if the type is of interest, examine the variable
104561 + if (TYPE_USERSPACE(type))
104562 + initialize(var);
104563 + }
104564 +
104565 + return ret;
104566 +}
104567 +
104568 +static struct gimple_opt_pass structleak_pass = {
104569 + .pass = {
104570 + .type = GIMPLE_PASS,
104571 + .name = "structleak",
104572 +#if BUILDING_GCC_VERSION >= 4008
104573 + .optinfo_flags = OPTGROUP_NONE,
104574 +#endif
104575 + .gate = NULL,
104576 + .execute = handle_function,
104577 + .sub = NULL,
104578 + .next = NULL,
104579 + .static_pass_number = 0,
104580 + .tv_id = TV_NONE,
104581 + .properties_required = PROP_cfg,
104582 + .properties_provided = 0,
104583 + .properties_destroyed = 0,
104584 + .todo_flags_start = 0,
104585 + .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
104586 + }
104587 +};
104588 +
104589 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104590 +{
104591 + int i;
104592 + const char * const plugin_name = plugin_info->base_name;
104593 + const int argc = plugin_info->argc;
104594 + const struct plugin_argument * const argv = plugin_info->argv;
104595 + bool enable = true;
104596 +
104597 + struct register_pass_info structleak_pass_info = {
104598 + .pass = &structleak_pass.pass,
104599 + .reference_pass_name = "ssa",
104600 + .ref_pass_instance_number = 1,
104601 + .pos_op = PASS_POS_INSERT_AFTER
104602 + };
104603 +
104604 + if (!plugin_default_version_check(version, &gcc_version)) {
104605 + error(G_("incompatible gcc/plugin versions"));
104606 + return 1;
104607 + }
104608 +
104609 + if (strcmp(lang_hooks.name, "GNU C")) {
104610 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
104611 + enable = false;
104612 + }
104613 +
104614 + for (i = 0; i < argc; ++i) {
104615 + if (!strcmp(argv[i].key, "disable")) {
104616 + enable = false;
104617 + continue;
104618 + }
104619 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104620 + }
104621 +
104622 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
104623 + if (enable) {
104624 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
104625 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
104626 + }
104627 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104628 +
104629 + return 0;
104630 +}
104631 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
104632 index 6789d78..4afd019e 100644
104633 --- a/tools/perf/util/include/asm/alternative-asm.h
104634 +++ b/tools/perf/util/include/asm/alternative-asm.h
104635 @@ -5,4 +5,7 @@
104636
104637 #define altinstruction_entry #
104638
104639 + .macro pax_force_retaddr rip=0, reload=0
104640 + .endm
104641 +
104642 #endif
104643 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
104644 index 96b919d..c49bb74 100644
104645 --- a/tools/perf/util/include/linux/compiler.h
104646 +++ b/tools/perf/util/include/linux/compiler.h
104647 @@ -18,4 +18,12 @@
104648 #define __force
104649 #endif
104650
104651 +#ifndef __size_overflow
104652 +# define __size_overflow(...)
104653 +#endif
104654 +
104655 +#ifndef __intentional_overflow
104656 +# define __intentional_overflow(...)
104657 +#endif
104658 +
104659 #endif
104660 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
104661 index f18013f..90421df 100644
104662 --- a/virt/kvm/kvm_main.c
104663 +++ b/virt/kvm/kvm_main.c
104664 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
104665
104666 static cpumask_var_t cpus_hardware_enabled;
104667 static int kvm_usage_count = 0;
104668 -static atomic_t hardware_enable_failed;
104669 +static atomic_unchecked_t hardware_enable_failed;
104670
104671 struct kmem_cache *kvm_vcpu_cache;
104672 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
104673
104674 -static __read_mostly struct preempt_ops kvm_preempt_ops;
104675 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
104676 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
104677 +static struct preempt_ops kvm_preempt_ops = {
104678 + .sched_in = kvm_sched_in,
104679 + .sched_out = kvm_sched_out,
104680 +};
104681
104682 struct dentry *kvm_debugfs_dir;
104683
104684 @@ -769,7 +774,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
104685 /* We can read the guest memory with __xxx_user() later on. */
104686 if (user_alloc &&
104687 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
104688 - !access_ok(VERIFY_WRITE,
104689 + !__access_ok(VERIFY_WRITE,
104690 (void __user *)(unsigned long)mem->userspace_addr,
104691 mem->memory_size)))
104692 goto out;
104693 @@ -1881,7 +1886,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
104694 return 0;
104695 }
104696
104697 -static struct file_operations kvm_vcpu_fops = {
104698 +static file_operations_no_const kvm_vcpu_fops __read_only = {
104699 .release = kvm_vcpu_release,
104700 .unlocked_ioctl = kvm_vcpu_ioctl,
104701 #ifdef CONFIG_COMPAT
104702 @@ -2402,7 +2407,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
104703 return 0;
104704 }
104705
104706 -static struct file_operations kvm_vm_fops = {
104707 +static file_operations_no_const kvm_vm_fops __read_only = {
104708 .release = kvm_vm_release,
104709 .unlocked_ioctl = kvm_vm_ioctl,
104710 #ifdef CONFIG_COMPAT
104711 @@ -2500,7 +2505,7 @@ out:
104712 return r;
104713 }
104714
104715 -static struct file_operations kvm_chardev_ops = {
104716 +static file_operations_no_const kvm_chardev_ops __read_only = {
104717 .unlocked_ioctl = kvm_dev_ioctl,
104718 .compat_ioctl = kvm_dev_ioctl,
104719 .llseek = noop_llseek,
104720 @@ -2526,7 +2531,7 @@ static void hardware_enable_nolock(void *junk)
104721
104722 if (r) {
104723 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104724 - atomic_inc(&hardware_enable_failed);
104725 + atomic_inc_unchecked(&hardware_enable_failed);
104726 printk(KERN_INFO "kvm: enabling virtualization on "
104727 "CPU%d failed\n", cpu);
104728 }
104729 @@ -2580,10 +2585,10 @@ static int hardware_enable_all(void)
104730
104731 kvm_usage_count++;
104732 if (kvm_usage_count == 1) {
104733 - atomic_set(&hardware_enable_failed, 0);
104734 + atomic_set_unchecked(&hardware_enable_failed, 0);
104735 on_each_cpu(hardware_enable_nolock, NULL, 1);
104736
104737 - if (atomic_read(&hardware_enable_failed)) {
104738 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104739 hardware_disable_all_nolock();
104740 r = -EBUSY;
104741 }
104742 @@ -2941,7 +2946,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104743 kvm_arch_vcpu_put(vcpu);
104744 }
104745
104746 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104747 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104748 struct module *module)
104749 {
104750 int r;
104751 @@ -2977,7 +2982,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104752 if (!vcpu_align)
104753 vcpu_align = __alignof__(struct kvm_vcpu);
104754 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
104755 - 0, NULL);
104756 + SLAB_USERCOPY, NULL);
104757 if (!kvm_vcpu_cache) {
104758 r = -ENOMEM;
104759 goto out_free_3;
104760 @@ -2987,9 +2992,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104761 if (r)
104762 goto out_free;
104763
104764 + pax_open_kernel();
104765 kvm_chardev_ops.owner = module;
104766 kvm_vm_fops.owner = module;
104767 kvm_vcpu_fops.owner = module;
104768 + pax_close_kernel();
104769
104770 r = misc_register(&kvm_dev);
104771 if (r) {
104772 @@ -2999,9 +3006,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104773
104774 register_syscore_ops(&kvm_syscore_ops);
104775
104776 - kvm_preempt_ops.sched_in = kvm_sched_in;
104777 - kvm_preempt_ops.sched_out = kvm_sched_out;
104778 -
104779 r = kvm_init_debug();
104780 if (r) {
104781 printk(KERN_ERR "kvm: create debugfs files failed\n");