]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.9.7-201306261901.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.9.7-201306261901.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 a129b15..548231d 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 1cacda4..2cef624 100644
815 --- a/arch/arm/Kconfig
816 +++ b/arch/arm/Kconfig
817 @@ -1850,7 +1850,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/drivers.c b/arch/parisc/kernel/drivers.c
5758 index 5709c5e..14285ca 100644
5759 --- a/arch/parisc/kernel/drivers.c
5760 +++ b/arch/parisc/kernel/drivers.c
5761 @@ -394,7 +394,7 @@ EXPORT_SYMBOL(print_pci_hwpath);
5762 static void setup_bus_id(struct parisc_device *padev)
5763 {
5764 struct hardware_path path;
5765 - char name[20];
5766 + char name[28];
5767 char *output = name;
5768 int i;
5769
5770 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5771 index 2a625fb..9908930 100644
5772 --- a/arch/parisc/kernel/module.c
5773 +++ b/arch/parisc/kernel/module.c
5774 @@ -98,16 +98,38 @@
5775
5776 /* three functions to determine where in the module core
5777 * or init pieces the location is */
5778 +static inline int in_init_rx(struct module *me, void *loc)
5779 +{
5780 + return (loc >= me->module_init_rx &&
5781 + loc < (me->module_init_rx + me->init_size_rx));
5782 +}
5783 +
5784 +static inline int in_init_rw(struct module *me, void *loc)
5785 +{
5786 + return (loc >= me->module_init_rw &&
5787 + loc < (me->module_init_rw + me->init_size_rw));
5788 +}
5789 +
5790 static inline int in_init(struct module *me, void *loc)
5791 {
5792 - return (loc >= me->module_init &&
5793 - loc <= (me->module_init + me->init_size));
5794 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5795 +}
5796 +
5797 +static inline int in_core_rx(struct module *me, void *loc)
5798 +{
5799 + return (loc >= me->module_core_rx &&
5800 + loc < (me->module_core_rx + me->core_size_rx));
5801 +}
5802 +
5803 +static inline int in_core_rw(struct module *me, void *loc)
5804 +{
5805 + return (loc >= me->module_core_rw &&
5806 + loc < (me->module_core_rw + me->core_size_rw));
5807 }
5808
5809 static inline int in_core(struct module *me, void *loc)
5810 {
5811 - return (loc >= me->module_core &&
5812 - loc <= (me->module_core + me->core_size));
5813 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5814 }
5815
5816 static inline int in_local(struct module *me, void *loc)
5817 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5818 }
5819
5820 /* align things a bit */
5821 - me->core_size = ALIGN(me->core_size, 16);
5822 - me->arch.got_offset = me->core_size;
5823 - me->core_size += gots * sizeof(struct got_entry);
5824 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5825 + me->arch.got_offset = me->core_size_rw;
5826 + me->core_size_rw += gots * sizeof(struct got_entry);
5827
5828 - me->core_size = ALIGN(me->core_size, 16);
5829 - me->arch.fdesc_offset = me->core_size;
5830 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5831 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5832 + me->arch.fdesc_offset = me->core_size_rw;
5833 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5834
5835 me->arch.got_max = gots;
5836 me->arch.fdesc_max = fdescs;
5837 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5838
5839 BUG_ON(value == 0);
5840
5841 - got = me->module_core + me->arch.got_offset;
5842 + got = me->module_core_rw + me->arch.got_offset;
5843 for (i = 0; got[i].addr; i++)
5844 if (got[i].addr == value)
5845 goto out;
5846 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5847 #ifdef CONFIG_64BIT
5848 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5849 {
5850 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5851 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5852
5853 if (!value) {
5854 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5855 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5856
5857 /* Create new one */
5858 fdesc->addr = value;
5859 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5860 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5861 return (Elf_Addr)fdesc;
5862 }
5863 #endif /* CONFIG_64BIT */
5864 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5865
5866 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5867 end = table + sechdrs[me->arch.unwind_section].sh_size;
5868 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5869 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5870
5871 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5872 me->arch.unwind_section, table, end, gp);
5873 diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
5874 index a3328c2..3b812eb 100644
5875 --- a/arch/parisc/kernel/setup.c
5876 +++ b/arch/parisc/kernel/setup.c
5877 @@ -69,7 +69,8 @@ void __init setup_cmdline(char **cmdline_p)
5878 /* called from hpux boot loader */
5879 boot_command_line[0] = '\0';
5880 } else {
5881 - strcpy(boot_command_line, (char *)__va(boot_args[1]));
5882 + strlcpy(boot_command_line, (char *)__va(boot_args[1]),
5883 + COMMAND_LINE_SIZE);
5884
5885 #ifdef CONFIG_BLK_DEV_INITRD
5886 if (boot_args[2] != 0) /* did palo pass us a ramdisk? */
5887 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5888 index 5dfd248..64914ac 100644
5889 --- a/arch/parisc/kernel/sys_parisc.c
5890 +++ b/arch/parisc/kernel/sys_parisc.c
5891 @@ -33,9 +33,11 @@
5892 #include <linux/utsname.h>
5893 #include <linux/personality.h>
5894
5895 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5896 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5897 + unsigned long flags)
5898 {
5899 struct vm_unmapped_area_info info;
5900 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5901
5902 info.flags = 0;
5903 info.length = len;
5904 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5905 info.high_limit = TASK_SIZE;
5906 info.align_mask = 0;
5907 info.align_offset = 0;
5908 + info.threadstack_offset = offset;
5909 return vm_unmapped_area(&info);
5910 }
5911
5912 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5913 return (unsigned long) mapping >> 8;
5914 }
5915
5916 -static unsigned long get_shared_area(struct address_space *mapping,
5917 - unsigned long addr, unsigned long len, unsigned long pgoff)
5918 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5919 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5920 {
5921 struct vm_unmapped_area_info info;
5922 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5923
5924 info.flags = 0;
5925 info.length = len;
5926 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5927 info.high_limit = TASK_SIZE;
5928 info.align_mask = PAGE_MASK & (SHMLBA - 1);
5929 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
5930 + info.threadstack_offset = offset;
5931 return vm_unmapped_area(&info);
5932 }
5933
5934 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5935 return -EINVAL;
5936 return addr;
5937 }
5938 - if (!addr)
5939 + if (!addr) {
5940 addr = TASK_UNMAPPED_BASE;
5941
5942 +#ifdef CONFIG_PAX_RANDMMAP
5943 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
5944 + addr += current->mm->delta_mmap;
5945 +#endif
5946 +
5947 + }
5948 +
5949 if (filp) {
5950 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
5951 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
5952 } else if(flags & MAP_SHARED) {
5953 - addr = get_shared_area(NULL, addr, len, pgoff);
5954 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
5955 } else {
5956 - addr = get_unshared_area(addr, len);
5957 + addr = get_unshared_area(filp, addr, len, flags);
5958 }
5959 return addr;
5960 }
5961 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
5962 index aeb8f8f..27a6c2f 100644
5963 --- a/arch/parisc/kernel/traps.c
5964 +++ b/arch/parisc/kernel/traps.c
5965 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
5966
5967 down_read(&current->mm->mmap_sem);
5968 vma = find_vma(current->mm,regs->iaoq[0]);
5969 - if (vma && (regs->iaoq[0] >= vma->vm_start)
5970 - && (vma->vm_flags & VM_EXEC)) {
5971 -
5972 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
5973 fault_address = regs->iaoq[0];
5974 fault_space = regs->iasq[0];
5975
5976 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
5977 index f247a34..dc0f219 100644
5978 --- a/arch/parisc/mm/fault.c
5979 +++ b/arch/parisc/mm/fault.c
5980 @@ -15,6 +15,7 @@
5981 #include <linux/sched.h>
5982 #include <linux/interrupt.h>
5983 #include <linux/module.h>
5984 +#include <linux/unistd.h>
5985
5986 #include <asm/uaccess.h>
5987 #include <asm/traps.h>
5988 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
5989 static unsigned long
5990 parisc_acctyp(unsigned long code, unsigned int inst)
5991 {
5992 - if (code == 6 || code == 16)
5993 + if (code == 6 || code == 7 || code == 16)
5994 return VM_EXEC;
5995
5996 switch (inst & 0xf0000000) {
5997 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
5998 }
5999 #endif
6000
6001 +#ifdef CONFIG_PAX_PAGEEXEC
6002 +/*
6003 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6004 + *
6005 + * returns 1 when task should be killed
6006 + * 2 when rt_sigreturn trampoline was detected
6007 + * 3 when unpatched PLT trampoline was detected
6008 + */
6009 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6010 +{
6011 +
6012 +#ifdef CONFIG_PAX_EMUPLT
6013 + int err;
6014 +
6015 + do { /* PaX: unpatched PLT emulation */
6016 + unsigned int bl, depwi;
6017 +
6018 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6019 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6020 +
6021 + if (err)
6022 + break;
6023 +
6024 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6025 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6026 +
6027 + err = get_user(ldw, (unsigned int *)addr);
6028 + err |= get_user(bv, (unsigned int *)(addr+4));
6029 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6030 +
6031 + if (err)
6032 + break;
6033 +
6034 + if (ldw == 0x0E801096U &&
6035 + bv == 0xEAC0C000U &&
6036 + ldw2 == 0x0E881095U)
6037 + {
6038 + unsigned int resolver, map;
6039 +
6040 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6041 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6042 + if (err)
6043 + break;
6044 +
6045 + regs->gr[20] = instruction_pointer(regs)+8;
6046 + regs->gr[21] = map;
6047 + regs->gr[22] = resolver;
6048 + regs->iaoq[0] = resolver | 3UL;
6049 + regs->iaoq[1] = regs->iaoq[0] + 4;
6050 + return 3;
6051 + }
6052 + }
6053 + } while (0);
6054 +#endif
6055 +
6056 +#ifdef CONFIG_PAX_EMUTRAMP
6057 +
6058 +#ifndef CONFIG_PAX_EMUSIGRT
6059 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6060 + return 1;
6061 +#endif
6062 +
6063 + do { /* PaX: rt_sigreturn emulation */
6064 + unsigned int ldi1, ldi2, bel, nop;
6065 +
6066 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6067 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6068 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6069 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6070 +
6071 + if (err)
6072 + break;
6073 +
6074 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6075 + ldi2 == 0x3414015AU &&
6076 + bel == 0xE4008200U &&
6077 + nop == 0x08000240U)
6078 + {
6079 + regs->gr[25] = (ldi1 & 2) >> 1;
6080 + regs->gr[20] = __NR_rt_sigreturn;
6081 + regs->gr[31] = regs->iaoq[1] + 16;
6082 + regs->sr[0] = regs->iasq[1];
6083 + regs->iaoq[0] = 0x100UL;
6084 + regs->iaoq[1] = regs->iaoq[0] + 4;
6085 + regs->iasq[0] = regs->sr[2];
6086 + regs->iasq[1] = regs->sr[2];
6087 + return 2;
6088 + }
6089 + } while (0);
6090 +#endif
6091 +
6092 + return 1;
6093 +}
6094 +
6095 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6096 +{
6097 + unsigned long i;
6098 +
6099 + printk(KERN_ERR "PAX: bytes at PC: ");
6100 + for (i = 0; i < 5; i++) {
6101 + unsigned int c;
6102 + if (get_user(c, (unsigned int *)pc+i))
6103 + printk(KERN_CONT "???????? ");
6104 + else
6105 + printk(KERN_CONT "%08x ", c);
6106 + }
6107 + printk("\n");
6108 +}
6109 +#endif
6110 +
6111 int fixup_exception(struct pt_regs *regs)
6112 {
6113 const struct exception_table_entry *fix;
6114 @@ -194,8 +305,33 @@ good_area:
6115
6116 acc_type = parisc_acctyp(code,regs->iir);
6117
6118 - if ((vma->vm_flags & acc_type) != acc_type)
6119 + if ((vma->vm_flags & acc_type) != acc_type) {
6120 +
6121 +#ifdef CONFIG_PAX_PAGEEXEC
6122 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6123 + (address & ~3UL) == instruction_pointer(regs))
6124 + {
6125 + up_read(&mm->mmap_sem);
6126 + switch (pax_handle_fetch_fault(regs)) {
6127 +
6128 +#ifdef CONFIG_PAX_EMUPLT
6129 + case 3:
6130 + return;
6131 +#endif
6132 +
6133 +#ifdef CONFIG_PAX_EMUTRAMP
6134 + case 2:
6135 + return;
6136 +#endif
6137 +
6138 + }
6139 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6140 + do_group_exit(SIGKILL);
6141 + }
6142 +#endif
6143 +
6144 goto bad_area;
6145 + }
6146
6147 /*
6148 * If for any reason at all we couldn't handle the fault, make
6149 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6150 index e3b1d41..8e81edf 100644
6151 --- a/arch/powerpc/include/asm/atomic.h
6152 +++ b/arch/powerpc/include/asm/atomic.h
6153 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6154 return t1;
6155 }
6156
6157 +#define atomic64_read_unchecked(v) atomic64_read(v)
6158 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6159 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6160 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6161 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6162 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6163 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6164 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6165 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6166 +
6167 #endif /* __powerpc64__ */
6168
6169 #endif /* __KERNEL__ */
6170 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6171 index 9e495c9..b6878e5 100644
6172 --- a/arch/powerpc/include/asm/cache.h
6173 +++ b/arch/powerpc/include/asm/cache.h
6174 @@ -3,6 +3,7 @@
6175
6176 #ifdef __KERNEL__
6177
6178 +#include <linux/const.h>
6179
6180 /* bytes per L1 cache line */
6181 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6182 @@ -22,7 +23,7 @@
6183 #define L1_CACHE_SHIFT 7
6184 #endif
6185
6186 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6187 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6188
6189 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6190
6191 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6192 index ac9790f..6d30741 100644
6193 --- a/arch/powerpc/include/asm/elf.h
6194 +++ b/arch/powerpc/include/asm/elf.h
6195 @@ -28,8 +28,19 @@
6196 the loader. We need to make sure that it is out of the way of the program
6197 that it will "exec", and that there is sufficient room for the brk. */
6198
6199 -extern unsigned long randomize_et_dyn(unsigned long base);
6200 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6201 +#define ELF_ET_DYN_BASE (0x20000000)
6202 +
6203 +#ifdef CONFIG_PAX_ASLR
6204 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6205 +
6206 +#ifdef __powerpc64__
6207 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6208 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6209 +#else
6210 +#define PAX_DELTA_MMAP_LEN 15
6211 +#define PAX_DELTA_STACK_LEN 15
6212 +#endif
6213 +#endif
6214
6215 /*
6216 * Our registers are always unsigned longs, whether we're a 32 bit
6217 @@ -122,10 +133,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6218 (0x7ff >> (PAGE_SHIFT - 12)) : \
6219 (0x3ffff >> (PAGE_SHIFT - 12)))
6220
6221 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6222 -#define arch_randomize_brk arch_randomize_brk
6223 -
6224 -
6225 #ifdef CONFIG_SPU_BASE
6226 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6227 #define NT_SPU 1
6228 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6229 index 8196e9c..d83a9f3 100644
6230 --- a/arch/powerpc/include/asm/exec.h
6231 +++ b/arch/powerpc/include/asm/exec.h
6232 @@ -4,6 +4,6 @@
6233 #ifndef _ASM_POWERPC_EXEC_H
6234 #define _ASM_POWERPC_EXEC_H
6235
6236 -extern unsigned long arch_align_stack(unsigned long sp);
6237 +#define arch_align_stack(x) ((x) & ~0xfUL)
6238
6239 #endif /* _ASM_POWERPC_EXEC_H */
6240 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6241 index 5acabbd..7ea14fa 100644
6242 --- a/arch/powerpc/include/asm/kmap_types.h
6243 +++ b/arch/powerpc/include/asm/kmap_types.h
6244 @@ -10,7 +10,7 @@
6245 * 2 of the License, or (at your option) any later version.
6246 */
6247
6248 -#define KM_TYPE_NR 16
6249 +#define KM_TYPE_NR 17
6250
6251 #endif /* __KERNEL__ */
6252 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6253 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6254 index 8565c25..2865190 100644
6255 --- a/arch/powerpc/include/asm/mman.h
6256 +++ b/arch/powerpc/include/asm/mman.h
6257 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6258 }
6259 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6260
6261 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6262 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6263 {
6264 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6265 }
6266 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6267 index f072e97..b436dee 100644
6268 --- a/arch/powerpc/include/asm/page.h
6269 +++ b/arch/powerpc/include/asm/page.h
6270 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6271 * and needs to be executable. This means the whole heap ends
6272 * up being executable.
6273 */
6274 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6275 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6276 +#define VM_DATA_DEFAULT_FLAGS32 \
6277 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6278 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6279
6280 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6281 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6282 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6283 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6284 #endif
6285
6286 +#define ktla_ktva(addr) (addr)
6287 +#define ktva_ktla(addr) (addr)
6288 +
6289 /*
6290 * Use the top bit of the higher-level page table entries to indicate whether
6291 * the entries we point to contain hugepages. This works because we know that
6292 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6293 index cd915d6..c10cee8 100644
6294 --- a/arch/powerpc/include/asm/page_64.h
6295 +++ b/arch/powerpc/include/asm/page_64.h
6296 @@ -154,15 +154,18 @@ do { \
6297 * stack by default, so in the absence of a PT_GNU_STACK program header
6298 * we turn execute permission off.
6299 */
6300 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6301 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6302 +#define VM_STACK_DEFAULT_FLAGS32 \
6303 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6304 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6305
6306 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6307 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6308
6309 +#ifndef CONFIG_PAX_PAGEEXEC
6310 #define VM_STACK_DEFAULT_FLAGS \
6311 (is_32bit_task() ? \
6312 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6313 +#endif
6314
6315 #include <asm-generic/getorder.h>
6316
6317 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6318 index 292725c..f87ae14 100644
6319 --- a/arch/powerpc/include/asm/pgalloc-64.h
6320 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6321 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6322 #ifndef CONFIG_PPC_64K_PAGES
6323
6324 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6325 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6326
6327 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6328 {
6329 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6330 pud_set(pud, (unsigned long)pmd);
6331 }
6332
6333 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6334 +{
6335 + pud_populate(mm, pud, pmd);
6336 +}
6337 +
6338 #define pmd_populate(mm, pmd, pte_page) \
6339 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6340 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6341 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6342 #else /* CONFIG_PPC_64K_PAGES */
6343
6344 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6345 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6346
6347 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6348 pte_t *pte)
6349 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6350 index a9cbd3b..3b67efa 100644
6351 --- a/arch/powerpc/include/asm/pgtable.h
6352 +++ b/arch/powerpc/include/asm/pgtable.h
6353 @@ -2,6 +2,7 @@
6354 #define _ASM_POWERPC_PGTABLE_H
6355 #ifdef __KERNEL__
6356
6357 +#include <linux/const.h>
6358 #ifndef __ASSEMBLY__
6359 #include <asm/processor.h> /* For TASK_SIZE */
6360 #include <asm/mmu.h>
6361 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6362 index 4aad413..85d86bf 100644
6363 --- a/arch/powerpc/include/asm/pte-hash32.h
6364 +++ b/arch/powerpc/include/asm/pte-hash32.h
6365 @@ -21,6 +21,7 @@
6366 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6367 #define _PAGE_USER 0x004 /* usermode access allowed */
6368 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6369 +#define _PAGE_EXEC _PAGE_GUARDED
6370 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6371 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6372 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6373 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6374 index 3b097a8..8f8c774 100644
6375 --- a/arch/powerpc/include/asm/reg.h
6376 +++ b/arch/powerpc/include/asm/reg.h
6377 @@ -234,6 +234,7 @@
6378 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6379 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6380 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6381 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6382 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6383 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6384 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6385 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6386 index 195ce2a..ab5c614 100644
6387 --- a/arch/powerpc/include/asm/smp.h
6388 +++ b/arch/powerpc/include/asm/smp.h
6389 @@ -50,7 +50,7 @@ struct smp_ops_t {
6390 int (*cpu_disable)(void);
6391 void (*cpu_die)(unsigned int nr);
6392 int (*cpu_bootable)(unsigned int nr);
6393 -};
6394 +} __no_const;
6395
6396 extern void smp_send_debugger_break(void);
6397 extern void start_secondary_resume(void);
6398 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6399 index 406b7b9..af63426 100644
6400 --- a/arch/powerpc/include/asm/thread_info.h
6401 +++ b/arch/powerpc/include/asm/thread_info.h
6402 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6403 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6404 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6405 #define TIF_SINGLESTEP 8 /* singlestepping active */
6406 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6407 #define TIF_SECCOMP 10 /* secure computing */
6408 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6409 #define TIF_NOERROR 12 /* Force successful syscall return */
6410 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6411 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6412 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6413 for stack store? */
6414 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6415 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6416 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6417
6418 /* as above, but as bit values */
6419 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6420 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6421 #define _TIF_UPROBE (1<<TIF_UPROBE)
6422 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6423 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6424 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6425 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6426 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6427 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6428 + _TIF_GRSEC_SETXID)
6429
6430 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6431 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6432 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6433 index 4db4959..aba5c41 100644
6434 --- a/arch/powerpc/include/asm/uaccess.h
6435 +++ b/arch/powerpc/include/asm/uaccess.h
6436 @@ -318,52 +318,6 @@ do { \
6437 extern unsigned long __copy_tofrom_user(void __user *to,
6438 const void __user *from, unsigned long size);
6439
6440 -#ifndef __powerpc64__
6441 -
6442 -static inline unsigned long copy_from_user(void *to,
6443 - const void __user *from, unsigned long n)
6444 -{
6445 - unsigned long over;
6446 -
6447 - if (access_ok(VERIFY_READ, from, n))
6448 - return __copy_tofrom_user((__force void __user *)to, from, n);
6449 - if ((unsigned long)from < TASK_SIZE) {
6450 - over = (unsigned long)from + n - TASK_SIZE;
6451 - return __copy_tofrom_user((__force void __user *)to, from,
6452 - n - over) + over;
6453 - }
6454 - return n;
6455 -}
6456 -
6457 -static inline unsigned long copy_to_user(void __user *to,
6458 - const void *from, unsigned long n)
6459 -{
6460 - unsigned long over;
6461 -
6462 - if (access_ok(VERIFY_WRITE, to, n))
6463 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6464 - if ((unsigned long)to < TASK_SIZE) {
6465 - over = (unsigned long)to + n - TASK_SIZE;
6466 - return __copy_tofrom_user(to, (__force void __user *)from,
6467 - n - over) + over;
6468 - }
6469 - return n;
6470 -}
6471 -
6472 -#else /* __powerpc64__ */
6473 -
6474 -#define __copy_in_user(to, from, size) \
6475 - __copy_tofrom_user((to), (from), (size))
6476 -
6477 -extern unsigned long copy_from_user(void *to, const void __user *from,
6478 - unsigned long n);
6479 -extern unsigned long copy_to_user(void __user *to, const void *from,
6480 - unsigned long n);
6481 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6482 - unsigned long n);
6483 -
6484 -#endif /* __powerpc64__ */
6485 -
6486 static inline unsigned long __copy_from_user_inatomic(void *to,
6487 const void __user *from, unsigned long n)
6488 {
6489 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6490 if (ret == 0)
6491 return 0;
6492 }
6493 +
6494 + if (!__builtin_constant_p(n))
6495 + check_object_size(to, n, false);
6496 +
6497 return __copy_tofrom_user((__force void __user *)to, from, n);
6498 }
6499
6500 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6501 if (ret == 0)
6502 return 0;
6503 }
6504 +
6505 + if (!__builtin_constant_p(n))
6506 + check_object_size(from, n, true);
6507 +
6508 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6509 }
6510
6511 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6512 return __copy_to_user_inatomic(to, from, size);
6513 }
6514
6515 +#ifndef __powerpc64__
6516 +
6517 +static inline unsigned long __must_check copy_from_user(void *to,
6518 + const void __user *from, unsigned long n)
6519 +{
6520 + unsigned long over;
6521 +
6522 + if ((long)n < 0)
6523 + return n;
6524 +
6525 + if (access_ok(VERIFY_READ, from, n)) {
6526 + if (!__builtin_constant_p(n))
6527 + check_object_size(to, n, false);
6528 + return __copy_tofrom_user((__force void __user *)to, from, n);
6529 + }
6530 + if ((unsigned long)from < TASK_SIZE) {
6531 + over = (unsigned long)from + n - TASK_SIZE;
6532 + if (!__builtin_constant_p(n - over))
6533 + check_object_size(to, n - over, false);
6534 + return __copy_tofrom_user((__force void __user *)to, from,
6535 + n - over) + over;
6536 + }
6537 + return n;
6538 +}
6539 +
6540 +static inline unsigned long __must_check copy_to_user(void __user *to,
6541 + const void *from, unsigned long n)
6542 +{
6543 + unsigned long over;
6544 +
6545 + if ((long)n < 0)
6546 + return n;
6547 +
6548 + if (access_ok(VERIFY_WRITE, to, n)) {
6549 + if (!__builtin_constant_p(n))
6550 + check_object_size(from, n, true);
6551 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6552 + }
6553 + if ((unsigned long)to < TASK_SIZE) {
6554 + over = (unsigned long)to + n - TASK_SIZE;
6555 + if (!__builtin_constant_p(n))
6556 + check_object_size(from, n - over, true);
6557 + return __copy_tofrom_user(to, (__force void __user *)from,
6558 + n - over) + over;
6559 + }
6560 + return n;
6561 +}
6562 +
6563 +#else /* __powerpc64__ */
6564 +
6565 +#define __copy_in_user(to, from, size) \
6566 + __copy_tofrom_user((to), (from), (size))
6567 +
6568 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6569 +{
6570 + if ((long)n < 0 || n > INT_MAX)
6571 + return n;
6572 +
6573 + if (!__builtin_constant_p(n))
6574 + check_object_size(to, n, false);
6575 +
6576 + if (likely(access_ok(VERIFY_READ, from, n)))
6577 + n = __copy_from_user(to, from, n);
6578 + else
6579 + memset(to, 0, n);
6580 + return n;
6581 +}
6582 +
6583 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6584 +{
6585 + if ((long)n < 0 || n > INT_MAX)
6586 + return n;
6587 +
6588 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6589 + if (!__builtin_constant_p(n))
6590 + check_object_size(from, n, true);
6591 + n = __copy_to_user(to, from, n);
6592 + }
6593 + return n;
6594 +}
6595 +
6596 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6597 + unsigned long n);
6598 +
6599 +#endif /* __powerpc64__ */
6600 +
6601 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6602
6603 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6604 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6605 index ae54553..cf2184d 100644
6606 --- a/arch/powerpc/kernel/exceptions-64e.S
6607 +++ b/arch/powerpc/kernel/exceptions-64e.S
6608 @@ -716,6 +716,7 @@ storage_fault_common:
6609 std r14,_DAR(r1)
6610 std r15,_DSISR(r1)
6611 addi r3,r1,STACK_FRAME_OVERHEAD
6612 + bl .save_nvgprs
6613 mr r4,r14
6614 mr r5,r15
6615 ld r14,PACA_EXGEN+EX_R14(r13)
6616 @@ -724,8 +725,7 @@ storage_fault_common:
6617 cmpdi r3,0
6618 bne- 1f
6619 b .ret_from_except_lite
6620 -1: bl .save_nvgprs
6621 - mr r5,r3
6622 +1: mr r5,r3
6623 addi r3,r1,STACK_FRAME_OVERHEAD
6624 ld r4,_DAR(r1)
6625 bl .bad_page_fault
6626 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6627 index 644378e..b6f2c26 100644
6628 --- a/arch/powerpc/kernel/exceptions-64s.S
6629 +++ b/arch/powerpc/kernel/exceptions-64s.S
6630 @@ -1390,10 +1390,10 @@ handle_page_fault:
6631 11: ld r4,_DAR(r1)
6632 ld r5,_DSISR(r1)
6633 addi r3,r1,STACK_FRAME_OVERHEAD
6634 + bl .save_nvgprs
6635 bl .do_page_fault
6636 cmpdi r3,0
6637 beq+ 12f
6638 - bl .save_nvgprs
6639 mr r5,r3
6640 addi r3,r1,STACK_FRAME_OVERHEAD
6641 lwz r4,_DAR(r1)
6642 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6643 index 2e3200c..72095ce 100644
6644 --- a/arch/powerpc/kernel/module_32.c
6645 +++ b/arch/powerpc/kernel/module_32.c
6646 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6647 me->arch.core_plt_section = i;
6648 }
6649 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6650 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6651 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6652 return -ENOEXEC;
6653 }
6654
6655 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6656
6657 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6658 /* Init, or core PLT? */
6659 - if (location >= mod->module_core
6660 - && location < mod->module_core + mod->core_size)
6661 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6662 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6663 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6664 - else
6665 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6666 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6667 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6668 + else {
6669 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6670 + return ~0UL;
6671 + }
6672
6673 /* Find this entry, or if that fails, the next avail. entry */
6674 while (entry->jump[0]) {
6675 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6676 index 0d86c8a..df4c5f2 100644
6677 --- a/arch/powerpc/kernel/process.c
6678 +++ b/arch/powerpc/kernel/process.c
6679 @@ -871,8 +871,8 @@ void show_regs(struct pt_regs * regs)
6680 * Lookup NIP late so we have the best change of getting the
6681 * above info out without failing
6682 */
6683 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6684 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6685 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6686 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6687 #endif
6688 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6689 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6690 @@ -1331,10 +1331,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6691 newsp = stack[0];
6692 ip = stack[STACK_FRAME_LR_SAVE];
6693 if (!firstframe || ip != lr) {
6694 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6695 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6696 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6697 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6698 - printk(" (%pS)",
6699 + printk(" (%pA)",
6700 (void *)current->ret_stack[curr_frame].ret);
6701 curr_frame--;
6702 }
6703 @@ -1354,7 +1354,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6704 struct pt_regs *regs = (struct pt_regs *)
6705 (sp + STACK_FRAME_OVERHEAD);
6706 lr = regs->link;
6707 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6708 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6709 regs->trap, (void *)regs->nip, (void *)lr);
6710 firstframe = 1;
6711 }
6712 @@ -1396,58 +1396,3 @@ void notrace __ppc64_runlatch_off(void)
6713 mtspr(SPRN_CTRLT, ctrl);
6714 }
6715 #endif /* CONFIG_PPC64 */
6716 -
6717 -unsigned long arch_align_stack(unsigned long sp)
6718 -{
6719 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6720 - sp -= get_random_int() & ~PAGE_MASK;
6721 - return sp & ~0xf;
6722 -}
6723 -
6724 -static inline unsigned long brk_rnd(void)
6725 -{
6726 - unsigned long rnd = 0;
6727 -
6728 - /* 8MB for 32bit, 1GB for 64bit */
6729 - if (is_32bit_task())
6730 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6731 - else
6732 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6733 -
6734 - return rnd << PAGE_SHIFT;
6735 -}
6736 -
6737 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6738 -{
6739 - unsigned long base = mm->brk;
6740 - unsigned long ret;
6741 -
6742 -#ifdef CONFIG_PPC_STD_MMU_64
6743 - /*
6744 - * If we are using 1TB segments and we are allowed to randomise
6745 - * the heap, we can put it above 1TB so it is backed by a 1TB
6746 - * segment. Otherwise the heap will be in the bottom 1TB
6747 - * which always uses 256MB segments and this may result in a
6748 - * performance penalty.
6749 - */
6750 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6751 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6752 -#endif
6753 -
6754 - ret = PAGE_ALIGN(base + brk_rnd());
6755 -
6756 - if (ret < mm->brk)
6757 - return mm->brk;
6758 -
6759 - return ret;
6760 -}
6761 -
6762 -unsigned long randomize_et_dyn(unsigned long base)
6763 -{
6764 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6765 -
6766 - if (ret < base)
6767 - return base;
6768 -
6769 - return ret;
6770 -}
6771 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6772 index f9b30c6..d72e7a3 100644
6773 --- a/arch/powerpc/kernel/ptrace.c
6774 +++ b/arch/powerpc/kernel/ptrace.c
6775 @@ -1771,6 +1771,10 @@ long arch_ptrace(struct task_struct *child, long request,
6776 return ret;
6777 }
6778
6779 +#ifdef CONFIG_GRKERNSEC_SETXID
6780 +extern void gr_delayed_cred_worker(void);
6781 +#endif
6782 +
6783 /*
6784 * We must return the syscall number to actually look up in the table.
6785 * This can be -1L to skip running any syscall at all.
6786 @@ -1781,6 +1785,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6787
6788 secure_computing_strict(regs->gpr[0]);
6789
6790 +#ifdef CONFIG_GRKERNSEC_SETXID
6791 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6792 + gr_delayed_cred_worker();
6793 +#endif
6794 +
6795 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6796 tracehook_report_syscall_entry(regs))
6797 /*
6798 @@ -1815,6 +1824,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6799 {
6800 int step;
6801
6802 +#ifdef CONFIG_GRKERNSEC_SETXID
6803 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6804 + gr_delayed_cred_worker();
6805 +#endif
6806 +
6807 audit_syscall_exit(regs);
6808
6809 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6810 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6811 index 201385c..0f01828 100644
6812 --- a/arch/powerpc/kernel/signal_32.c
6813 +++ b/arch/powerpc/kernel/signal_32.c
6814 @@ -976,7 +976,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6815 /* Save user registers on the stack */
6816 frame = &rt_sf->uc.uc_mcontext;
6817 addr = frame;
6818 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6819 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6820 sigret = 0;
6821 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6822 } else {
6823 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6824 index 3459473..2d40783 100644
6825 --- a/arch/powerpc/kernel/signal_64.c
6826 +++ b/arch/powerpc/kernel/signal_64.c
6827 @@ -749,7 +749,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6828 #endif
6829
6830 /* Set up to return from userspace. */
6831 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6832 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6833 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6834 } else {
6835 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6836 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6837 index 3ce1f86..c30e629 100644
6838 --- a/arch/powerpc/kernel/sysfs.c
6839 +++ b/arch/powerpc/kernel/sysfs.c
6840 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6841 return NOTIFY_OK;
6842 }
6843
6844 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6845 +static struct notifier_block sysfs_cpu_nb = {
6846 .notifier_call = sysfs_cpu_notify,
6847 };
6848
6849 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6850 index bf33ace..e836d8b 100644
6851 --- a/arch/powerpc/kernel/traps.c
6852 +++ b/arch/powerpc/kernel/traps.c
6853 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6854 return flags;
6855 }
6856
6857 +extern void gr_handle_kernel_exploit(void);
6858 +
6859 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6860 int signr)
6861 {
6862 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6863 panic("Fatal exception in interrupt");
6864 if (panic_on_oops)
6865 panic("Fatal exception");
6866 +
6867 + gr_handle_kernel_exploit();
6868 +
6869 do_exit(signr);
6870 }
6871
6872 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6873 index 1b2076f..835e4be 100644
6874 --- a/arch/powerpc/kernel/vdso.c
6875 +++ b/arch/powerpc/kernel/vdso.c
6876 @@ -34,6 +34,7 @@
6877 #include <asm/firmware.h>
6878 #include <asm/vdso.h>
6879 #include <asm/vdso_datapage.h>
6880 +#include <asm/mman.h>
6881
6882 #include "setup.h"
6883
6884 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6885 vdso_base = VDSO32_MBASE;
6886 #endif
6887
6888 - current->mm->context.vdso_base = 0;
6889 + current->mm->context.vdso_base = ~0UL;
6890
6891 /* vDSO has a problem and was disabled, just don't "enable" it for the
6892 * process
6893 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6894 vdso_base = get_unmapped_area(NULL, vdso_base,
6895 (vdso_pages << PAGE_SHIFT) +
6896 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6897 - 0, 0);
6898 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6899 if (IS_ERR_VALUE(vdso_base)) {
6900 rc = vdso_base;
6901 goto fail_mmapsem;
6902 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6903 index 5eea6f3..5d10396 100644
6904 --- a/arch/powerpc/lib/usercopy_64.c
6905 +++ b/arch/powerpc/lib/usercopy_64.c
6906 @@ -9,22 +9,6 @@
6907 #include <linux/module.h>
6908 #include <asm/uaccess.h>
6909
6910 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6911 -{
6912 - if (likely(access_ok(VERIFY_READ, from, n)))
6913 - n = __copy_from_user(to, from, n);
6914 - else
6915 - memset(to, 0, n);
6916 - return n;
6917 -}
6918 -
6919 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6920 -{
6921 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6922 - n = __copy_to_user(to, from, n);
6923 - return n;
6924 -}
6925 -
6926 unsigned long copy_in_user(void __user *to, const void __user *from,
6927 unsigned long n)
6928 {
6929 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6930 return n;
6931 }
6932
6933 -EXPORT_SYMBOL(copy_from_user);
6934 -EXPORT_SYMBOL(copy_to_user);
6935 EXPORT_SYMBOL(copy_in_user);
6936
6937 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6938 index 229951f..cdeca42 100644
6939 --- a/arch/powerpc/mm/fault.c
6940 +++ b/arch/powerpc/mm/fault.c
6941 @@ -32,6 +32,10 @@
6942 #include <linux/perf_event.h>
6943 #include <linux/magic.h>
6944 #include <linux/ratelimit.h>
6945 +#include <linux/slab.h>
6946 +#include <linux/pagemap.h>
6947 +#include <linux/compiler.h>
6948 +#include <linux/unistd.h>
6949
6950 #include <asm/firmware.h>
6951 #include <asm/page.h>
6952 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
6953 }
6954 #endif
6955
6956 +#ifdef CONFIG_PAX_PAGEEXEC
6957 +/*
6958 + * PaX: decide what to do with offenders (regs->nip = fault address)
6959 + *
6960 + * returns 1 when task should be killed
6961 + */
6962 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6963 +{
6964 + return 1;
6965 +}
6966 +
6967 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6968 +{
6969 + unsigned long i;
6970 +
6971 + printk(KERN_ERR "PAX: bytes at PC: ");
6972 + for (i = 0; i < 5; i++) {
6973 + unsigned int c;
6974 + if (get_user(c, (unsigned int __user *)pc+i))
6975 + printk(KERN_CONT "???????? ");
6976 + else
6977 + printk(KERN_CONT "%08x ", c);
6978 + }
6979 + printk("\n");
6980 +}
6981 +#endif
6982 +
6983 /*
6984 * Check whether the instruction at regs->nip is a store using
6985 * an update addressing form which will update r1.
6986 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
6987 * indicate errors in DSISR but can validly be set in SRR1.
6988 */
6989 if (trap == 0x400)
6990 - error_code &= 0x48200000;
6991 + error_code &= 0x58200000;
6992 else
6993 is_write = error_code & DSISR_ISSTORE;
6994 #else
6995 @@ -364,7 +395,7 @@ good_area:
6996 * "undefined". Of those that can be set, this is the only
6997 * one which seems bad.
6998 */
6999 - if (error_code & 0x10000000)
7000 + if (error_code & DSISR_GUARDED)
7001 /* Guarded storage error. */
7002 goto bad_area;
7003 #endif /* CONFIG_8xx */
7004 @@ -379,7 +410,7 @@ good_area:
7005 * processors use the same I/D cache coherency mechanism
7006 * as embedded.
7007 */
7008 - if (error_code & DSISR_PROTFAULT)
7009 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7010 goto bad_area;
7011 #endif /* CONFIG_PPC_STD_MMU */
7012
7013 @@ -462,6 +493,23 @@ bad_area:
7014 bad_area_nosemaphore:
7015 /* User mode accesses cause a SIGSEGV */
7016 if (user_mode(regs)) {
7017 +
7018 +#ifdef CONFIG_PAX_PAGEEXEC
7019 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7020 +#ifdef CONFIG_PPC_STD_MMU
7021 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7022 +#else
7023 + if (is_exec && regs->nip == address) {
7024 +#endif
7025 + switch (pax_handle_fetch_fault(regs)) {
7026 + }
7027 +
7028 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7029 + do_group_exit(SIGKILL);
7030 + }
7031 + }
7032 +#endif
7033 +
7034 _exception(SIGSEGV, regs, code, address);
7035 return 0;
7036 }
7037 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7038 index 67a42ed..cd463e0 100644
7039 --- a/arch/powerpc/mm/mmap_64.c
7040 +++ b/arch/powerpc/mm/mmap_64.c
7041 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7042 {
7043 unsigned long rnd = 0;
7044
7045 +#ifdef CONFIG_PAX_RANDMMAP
7046 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7047 +#endif
7048 +
7049 if (current->flags & PF_RANDOMIZE) {
7050 /* 8MB for 32bit, 1GB for 64bit */
7051 if (is_32bit_task())
7052 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7053 */
7054 if (mmap_is_legacy()) {
7055 mm->mmap_base = TASK_UNMAPPED_BASE;
7056 +
7057 +#ifdef CONFIG_PAX_RANDMMAP
7058 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7059 + mm->mmap_base += mm->delta_mmap;
7060 +#endif
7061 +
7062 mm->get_unmapped_area = arch_get_unmapped_area;
7063 mm->unmap_area = arch_unmap_area;
7064 } else {
7065 mm->mmap_base = mmap_base();
7066 +
7067 +#ifdef CONFIG_PAX_RANDMMAP
7068 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7069 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7070 +#endif
7071 +
7072 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7073 mm->unmap_area = arch_unmap_area_topdown;
7074 }
7075 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7076 index e779642..e5bb889 100644
7077 --- a/arch/powerpc/mm/mmu_context_nohash.c
7078 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7079 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7080 return NOTIFY_OK;
7081 }
7082
7083 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7084 +static struct notifier_block mmu_context_cpu_nb = {
7085 .notifier_call = mmu_context_cpu_notify,
7086 };
7087
7088 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7089 index 6a252c4..3024d81 100644
7090 --- a/arch/powerpc/mm/numa.c
7091 +++ b/arch/powerpc/mm/numa.c
7092 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7093 return ret;
7094 }
7095
7096 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7097 +static struct notifier_block ppc64_numa_nb = {
7098 .notifier_call = cpu_numa_callback,
7099 .priority = 1 /* Must run before sched domains notifier. */
7100 };
7101 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7102 index cf9dada..241529f 100644
7103 --- a/arch/powerpc/mm/slice.c
7104 +++ b/arch/powerpc/mm/slice.c
7105 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7106 if ((mm->task_size - len) < addr)
7107 return 0;
7108 vma = find_vma(mm, addr);
7109 - return (!vma || (addr + len) <= vma->vm_start);
7110 + return check_heap_stack_gap(vma, addr, len, 0);
7111 }
7112
7113 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7114 @@ -272,7 +272,7 @@ full_search:
7115 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7116 continue;
7117 }
7118 - if (!vma || addr + len <= vma->vm_start) {
7119 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7120 /*
7121 * Remember the place where we stopped the search:
7122 */
7123 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7124 }
7125 }
7126
7127 - addr = mm->mmap_base;
7128 - while (addr > len) {
7129 + if (mm->mmap_base < len)
7130 + addr = -ENOMEM;
7131 + else
7132 + addr = mm->mmap_base - len;
7133 +
7134 + while (!IS_ERR_VALUE(addr)) {
7135 /* Go down by chunk size */
7136 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7137 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7138
7139 /* Check for hit with different page size */
7140 mask = slice_range_to_mask(addr, len);
7141 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7142 * return with success:
7143 */
7144 vma = find_vma(mm, addr);
7145 - if (!vma || (addr + len) <= vma->vm_start) {
7146 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7147 /* remember the address as a hint for next time */
7148 if (use_cache)
7149 mm->free_area_cache = addr;
7150 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7151 mm->cached_hole_size = vma->vm_start - addr;
7152
7153 /* try just below the current vma->vm_start */
7154 - addr = vma->vm_start;
7155 + addr = skip_heap_stack_gap(vma, len, 0);
7156 }
7157
7158 /*
7159 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7160 if (fixed && addr > (mm->task_size - len))
7161 return -EINVAL;
7162
7163 +#ifdef CONFIG_PAX_RANDMMAP
7164 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7165 + addr = 0;
7166 +#endif
7167 +
7168 /* If hint, make sure it matches our alignment restrictions */
7169 if (!fixed && addr) {
7170 addr = _ALIGN_UP(addr, 1ul << pshift);
7171 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7172 index 68c57d3..1fdcfb2 100644
7173 --- a/arch/powerpc/platforms/cell/spufs/file.c
7174 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7175 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7176 return VM_FAULT_NOPAGE;
7177 }
7178
7179 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7180 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7181 unsigned long address,
7182 - void *buf, int len, int write)
7183 + void *buf, size_t len, int write)
7184 {
7185 struct spu_context *ctx = vma->vm_file->private_data;
7186 unsigned long offset = address - vma->vm_start;
7187 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7188 index bdb738a..49c9f95 100644
7189 --- a/arch/powerpc/platforms/powermac/smp.c
7190 +++ b/arch/powerpc/platforms/powermac/smp.c
7191 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7192 return NOTIFY_OK;
7193 }
7194
7195 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7196 +static struct notifier_block smp_core99_cpu_nb = {
7197 .notifier_call = smp_core99_cpu_notify,
7198 };
7199 #endif /* CONFIG_HOTPLUG_CPU */
7200 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7201 index c797832..ce575c8 100644
7202 --- a/arch/s390/include/asm/atomic.h
7203 +++ b/arch/s390/include/asm/atomic.h
7204 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7205 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7206 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7207
7208 +#define atomic64_read_unchecked(v) atomic64_read(v)
7209 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7210 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7211 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7212 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7213 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7214 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7215 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7216 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7217 +
7218 #define smp_mb__before_atomic_dec() smp_mb()
7219 #define smp_mb__after_atomic_dec() smp_mb()
7220 #define smp_mb__before_atomic_inc() smp_mb()
7221 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7222 index 4d7ccac..d03d0ad 100644
7223 --- a/arch/s390/include/asm/cache.h
7224 +++ b/arch/s390/include/asm/cache.h
7225 @@ -9,8 +9,10 @@
7226 #ifndef __ARCH_S390_CACHE_H
7227 #define __ARCH_S390_CACHE_H
7228
7229 -#define L1_CACHE_BYTES 256
7230 +#include <linux/const.h>
7231 +
7232 #define L1_CACHE_SHIFT 8
7233 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7234 #define NET_SKB_PAD 32
7235
7236 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7237 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7238 index 1bfdf24..9c9ab2e 100644
7239 --- a/arch/s390/include/asm/elf.h
7240 +++ b/arch/s390/include/asm/elf.h
7241 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7242 the loader. We need to make sure that it is out of the way of the program
7243 that it will "exec", and that there is sufficient room for the brk. */
7244
7245 -extern unsigned long randomize_et_dyn(unsigned long base);
7246 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7247 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7248 +
7249 +#ifdef CONFIG_PAX_ASLR
7250 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7251 +
7252 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7253 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7254 +#endif
7255
7256 /* This yields a mask that user programs can use to figure out what
7257 instruction set this CPU supports. */
7258 @@ -207,9 +213,6 @@ struct linux_binprm;
7259 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7260 int arch_setup_additional_pages(struct linux_binprm *, int);
7261
7262 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7263 -#define arch_randomize_brk arch_randomize_brk
7264 -
7265 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7266
7267 #endif
7268 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7269 index c4a93d6..4d2a9b4 100644
7270 --- a/arch/s390/include/asm/exec.h
7271 +++ b/arch/s390/include/asm/exec.h
7272 @@ -7,6 +7,6 @@
7273 #ifndef __ASM_EXEC_H
7274 #define __ASM_EXEC_H
7275
7276 -extern unsigned long arch_align_stack(unsigned long sp);
7277 +#define arch_align_stack(x) ((x) & ~0xfUL)
7278
7279 #endif /* __ASM_EXEC_H */
7280 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7281 index 9c33ed4..e40cbef 100644
7282 --- a/arch/s390/include/asm/uaccess.h
7283 +++ b/arch/s390/include/asm/uaccess.h
7284 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7285 copy_to_user(void __user *to, const void *from, unsigned long n)
7286 {
7287 might_fault();
7288 +
7289 + if ((long)n < 0)
7290 + return n;
7291 +
7292 return __copy_to_user(to, from, n);
7293 }
7294
7295 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7296 static inline unsigned long __must_check
7297 __copy_from_user(void *to, const void __user *from, unsigned long n)
7298 {
7299 + if ((long)n < 0)
7300 + return n;
7301 +
7302 if (__builtin_constant_p(n) && (n <= 256))
7303 return uaccess.copy_from_user_small(n, from, to);
7304 else
7305 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7306 static inline unsigned long __must_check
7307 copy_from_user(void *to, const void __user *from, unsigned long n)
7308 {
7309 - unsigned int sz = __compiletime_object_size(to);
7310 + size_t sz = __compiletime_object_size(to);
7311
7312 might_fault();
7313 - if (unlikely(sz != -1 && sz < n)) {
7314 +
7315 + if ((long)n < 0)
7316 + return n;
7317 +
7318 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7319 copy_from_user_overflow();
7320 return n;
7321 }
7322 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7323 index 7845e15..59c4353 100644
7324 --- a/arch/s390/kernel/module.c
7325 +++ b/arch/s390/kernel/module.c
7326 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7327
7328 /* Increase core size by size of got & plt and set start
7329 offsets for got and plt. */
7330 - me->core_size = ALIGN(me->core_size, 4);
7331 - me->arch.got_offset = me->core_size;
7332 - me->core_size += me->arch.got_size;
7333 - me->arch.plt_offset = me->core_size;
7334 - me->core_size += me->arch.plt_size;
7335 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7336 + me->arch.got_offset = me->core_size_rw;
7337 + me->core_size_rw += me->arch.got_size;
7338 + me->arch.plt_offset = me->core_size_rx;
7339 + me->core_size_rx += me->arch.plt_size;
7340 return 0;
7341 }
7342
7343 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7344 if (info->got_initialized == 0) {
7345 Elf_Addr *gotent;
7346
7347 - gotent = me->module_core + me->arch.got_offset +
7348 + gotent = me->module_core_rw + me->arch.got_offset +
7349 info->got_offset;
7350 *gotent = val;
7351 info->got_initialized = 1;
7352 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7353 rc = apply_rela_bits(loc, val, 0, 64, 0);
7354 else if (r_type == R_390_GOTENT ||
7355 r_type == R_390_GOTPLTENT) {
7356 - val += (Elf_Addr) me->module_core - loc;
7357 + val += (Elf_Addr) me->module_core_rw - loc;
7358 rc = apply_rela_bits(loc, val, 1, 32, 1);
7359 }
7360 break;
7361 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7362 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7363 if (info->plt_initialized == 0) {
7364 unsigned int *ip;
7365 - ip = me->module_core + me->arch.plt_offset +
7366 + ip = me->module_core_rx + me->arch.plt_offset +
7367 info->plt_offset;
7368 #ifndef CONFIG_64BIT
7369 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7370 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7371 val - loc + 0xffffUL < 0x1ffffeUL) ||
7372 (r_type == R_390_PLT32DBL &&
7373 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7374 - val = (Elf_Addr) me->module_core +
7375 + val = (Elf_Addr) me->module_core_rx +
7376 me->arch.plt_offset +
7377 info->plt_offset;
7378 val += rela->r_addend - loc;
7379 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7380 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7381 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7382 val = val + rela->r_addend -
7383 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7384 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7385 if (r_type == R_390_GOTOFF16)
7386 rc = apply_rela_bits(loc, val, 0, 16, 0);
7387 else if (r_type == R_390_GOTOFF32)
7388 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7389 break;
7390 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7391 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7392 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7393 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7394 rela->r_addend - loc;
7395 if (r_type == R_390_GOTPC)
7396 rc = apply_rela_bits(loc, val, 1, 32, 0);
7397 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7398 index 536d645..4a5bd9e 100644
7399 --- a/arch/s390/kernel/process.c
7400 +++ b/arch/s390/kernel/process.c
7401 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7402 }
7403 return 0;
7404 }
7405 -
7406 -unsigned long arch_align_stack(unsigned long sp)
7407 -{
7408 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7409 - sp -= get_random_int() & ~PAGE_MASK;
7410 - return sp & ~0xf;
7411 -}
7412 -
7413 -static inline unsigned long brk_rnd(void)
7414 -{
7415 - /* 8MB for 32bit, 1GB for 64bit */
7416 - if (is_32bit_task())
7417 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7418 - else
7419 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7420 -}
7421 -
7422 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7423 -{
7424 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7425 -
7426 - if (ret < mm->brk)
7427 - return mm->brk;
7428 - return ret;
7429 -}
7430 -
7431 -unsigned long randomize_et_dyn(unsigned long base)
7432 -{
7433 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7434 -
7435 - if (!(current->flags & PF_RANDOMIZE))
7436 - return base;
7437 - if (ret < base)
7438 - return base;
7439 - return ret;
7440 -}
7441 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7442 index 06bafec..2bca531 100644
7443 --- a/arch/s390/mm/mmap.c
7444 +++ b/arch/s390/mm/mmap.c
7445 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7446 */
7447 if (mmap_is_legacy()) {
7448 mm->mmap_base = TASK_UNMAPPED_BASE;
7449 +
7450 +#ifdef CONFIG_PAX_RANDMMAP
7451 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7452 + mm->mmap_base += mm->delta_mmap;
7453 +#endif
7454 +
7455 mm->get_unmapped_area = arch_get_unmapped_area;
7456 mm->unmap_area = arch_unmap_area;
7457 } else {
7458 mm->mmap_base = mmap_base();
7459 +
7460 +#ifdef CONFIG_PAX_RANDMMAP
7461 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7462 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7463 +#endif
7464 +
7465 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7466 mm->unmap_area = arch_unmap_area_topdown;
7467 }
7468 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7469 */
7470 if (mmap_is_legacy()) {
7471 mm->mmap_base = TASK_UNMAPPED_BASE;
7472 +
7473 +#ifdef CONFIG_PAX_RANDMMAP
7474 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7475 + mm->mmap_base += mm->delta_mmap;
7476 +#endif
7477 +
7478 mm->get_unmapped_area = s390_get_unmapped_area;
7479 mm->unmap_area = arch_unmap_area;
7480 } else {
7481 mm->mmap_base = mmap_base();
7482 +
7483 +#ifdef CONFIG_PAX_RANDMMAP
7484 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7485 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7486 +#endif
7487 +
7488 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7489 mm->unmap_area = arch_unmap_area_topdown;
7490 }
7491 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7492 index ae3d59f..f65f075 100644
7493 --- a/arch/score/include/asm/cache.h
7494 +++ b/arch/score/include/asm/cache.h
7495 @@ -1,7 +1,9 @@
7496 #ifndef _ASM_SCORE_CACHE_H
7497 #define _ASM_SCORE_CACHE_H
7498
7499 +#include <linux/const.h>
7500 +
7501 #define L1_CACHE_SHIFT 4
7502 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7503 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7504
7505 #endif /* _ASM_SCORE_CACHE_H */
7506 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7507 index f9f3cd5..58ff438 100644
7508 --- a/arch/score/include/asm/exec.h
7509 +++ b/arch/score/include/asm/exec.h
7510 @@ -1,6 +1,6 @@
7511 #ifndef _ASM_SCORE_EXEC_H
7512 #define _ASM_SCORE_EXEC_H
7513
7514 -extern unsigned long arch_align_stack(unsigned long sp);
7515 +#define arch_align_stack(x) (x)
7516
7517 #endif /* _ASM_SCORE_EXEC_H */
7518 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7519 index 7956846..5f37677 100644
7520 --- a/arch/score/kernel/process.c
7521 +++ b/arch/score/kernel/process.c
7522 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7523
7524 return task_pt_regs(task)->cp0_epc;
7525 }
7526 -
7527 -unsigned long arch_align_stack(unsigned long sp)
7528 -{
7529 - return sp;
7530 -}
7531 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7532 index ef9e555..331bd29 100644
7533 --- a/arch/sh/include/asm/cache.h
7534 +++ b/arch/sh/include/asm/cache.h
7535 @@ -9,10 +9,11 @@
7536 #define __ASM_SH_CACHE_H
7537 #ifdef __KERNEL__
7538
7539 +#include <linux/const.h>
7540 #include <linux/init.h>
7541 #include <cpu/cache.h>
7542
7543 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7544 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7545
7546 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7547
7548 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7549 index 03f2b55..b0270327 100644
7550 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7551 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7552 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7553 return NOTIFY_OK;
7554 }
7555
7556 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7557 +static struct notifier_block shx3_cpu_notifier = {
7558 .notifier_call = shx3_cpu_callback,
7559 };
7560
7561 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7562 index 6777177..cb5e44f 100644
7563 --- a/arch/sh/mm/mmap.c
7564 +++ b/arch/sh/mm/mmap.c
7565 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7566 struct mm_struct *mm = current->mm;
7567 struct vm_area_struct *vma;
7568 int do_colour_align;
7569 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7570 struct vm_unmapped_area_info info;
7571
7572 if (flags & MAP_FIXED) {
7573 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7574 if (filp || (flags & MAP_SHARED))
7575 do_colour_align = 1;
7576
7577 +#ifdef CONFIG_PAX_RANDMMAP
7578 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7579 +#endif
7580 +
7581 if (addr) {
7582 if (do_colour_align)
7583 addr = COLOUR_ALIGN(addr, pgoff);
7584 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7585 addr = PAGE_ALIGN(addr);
7586
7587 vma = find_vma(mm, addr);
7588 - if (TASK_SIZE - len >= addr &&
7589 - (!vma || addr + len <= vma->vm_start))
7590 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7591 return addr;
7592 }
7593
7594 info.flags = 0;
7595 info.length = len;
7596 - info.low_limit = TASK_UNMAPPED_BASE;
7597 + info.low_limit = mm->mmap_base;
7598 info.high_limit = TASK_SIZE;
7599 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7600 info.align_offset = pgoff << PAGE_SHIFT;
7601 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7602 struct mm_struct *mm = current->mm;
7603 unsigned long addr = addr0;
7604 int do_colour_align;
7605 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7606 struct vm_unmapped_area_info info;
7607
7608 if (flags & MAP_FIXED) {
7609 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7610 if (filp || (flags & MAP_SHARED))
7611 do_colour_align = 1;
7612
7613 +#ifdef CONFIG_PAX_RANDMMAP
7614 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7615 +#endif
7616 +
7617 /* requesting a specific address */
7618 if (addr) {
7619 if (do_colour_align)
7620 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7621 addr = PAGE_ALIGN(addr);
7622
7623 vma = find_vma(mm, addr);
7624 - if (TASK_SIZE - len >= addr &&
7625 - (!vma || addr + len <= vma->vm_start))
7626 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7627 return addr;
7628 }
7629
7630 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7631 VM_BUG_ON(addr != -ENOMEM);
7632 info.flags = 0;
7633 info.low_limit = TASK_UNMAPPED_BASE;
7634 +
7635 +#ifdef CONFIG_PAX_RANDMMAP
7636 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7637 + info.low_limit += mm->delta_mmap;
7638 +#endif
7639 +
7640 info.high_limit = TASK_SIZE;
7641 addr = vm_unmapped_area(&info);
7642 }
7643 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7644 index be56a24..443328f 100644
7645 --- a/arch/sparc/include/asm/atomic_64.h
7646 +++ b/arch/sparc/include/asm/atomic_64.h
7647 @@ -14,18 +14,40 @@
7648 #define ATOMIC64_INIT(i) { (i) }
7649
7650 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7651 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7652 +{
7653 + return v->counter;
7654 +}
7655 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7656 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7657 +{
7658 + return v->counter;
7659 +}
7660
7661 #define atomic_set(v, i) (((v)->counter) = i)
7662 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7663 +{
7664 + v->counter = i;
7665 +}
7666 #define atomic64_set(v, i) (((v)->counter) = i)
7667 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7668 +{
7669 + v->counter = i;
7670 +}
7671
7672 extern void atomic_add(int, atomic_t *);
7673 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7674 extern void atomic64_add(long, atomic64_t *);
7675 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7676 extern void atomic_sub(int, atomic_t *);
7677 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7678 extern void atomic64_sub(long, atomic64_t *);
7679 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7680
7681 extern int atomic_add_ret(int, atomic_t *);
7682 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7683 extern long atomic64_add_ret(long, atomic64_t *);
7684 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7685 extern int atomic_sub_ret(int, atomic_t *);
7686 extern long atomic64_sub_ret(long, atomic64_t *);
7687
7688 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7689 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7690
7691 #define atomic_inc_return(v) atomic_add_ret(1, v)
7692 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7693 +{
7694 + return atomic_add_ret_unchecked(1, v);
7695 +}
7696 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7697 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7698 +{
7699 + return atomic64_add_ret_unchecked(1, v);
7700 +}
7701
7702 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7703 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7704
7705 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7706 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7707 +{
7708 + return atomic_add_ret_unchecked(i, v);
7709 +}
7710 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7711 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7712 +{
7713 + return atomic64_add_ret_unchecked(i, v);
7714 +}
7715
7716 /*
7717 * atomic_inc_and_test - increment and test
7718 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7719 * other cases.
7720 */
7721 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7722 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7723 +{
7724 + return atomic_inc_return_unchecked(v) == 0;
7725 +}
7726 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7727
7728 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7729 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7730 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7731
7732 #define atomic_inc(v) atomic_add(1, v)
7733 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7734 +{
7735 + atomic_add_unchecked(1, v);
7736 +}
7737 #define atomic64_inc(v) atomic64_add(1, v)
7738 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7739 +{
7740 + atomic64_add_unchecked(1, v);
7741 +}
7742
7743 #define atomic_dec(v) atomic_sub(1, v)
7744 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7745 +{
7746 + atomic_sub_unchecked(1, v);
7747 +}
7748 #define atomic64_dec(v) atomic64_sub(1, v)
7749 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7750 +{
7751 + atomic64_sub_unchecked(1, v);
7752 +}
7753
7754 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7755 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7756
7757 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7758 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7759 +{
7760 + return cmpxchg(&v->counter, old, new);
7761 +}
7762 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7763 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7764 +{
7765 + return xchg(&v->counter, new);
7766 +}
7767
7768 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7769 {
7770 - int c, old;
7771 + int c, old, new;
7772 c = atomic_read(v);
7773 for (;;) {
7774 - if (unlikely(c == (u)))
7775 + if (unlikely(c == u))
7776 break;
7777 - old = atomic_cmpxchg((v), c, c + (a));
7778 +
7779 + asm volatile("addcc %2, %0, %0\n"
7780 +
7781 +#ifdef CONFIG_PAX_REFCOUNT
7782 + "tvs %%icc, 6\n"
7783 +#endif
7784 +
7785 + : "=r" (new)
7786 + : "0" (c), "ir" (a)
7787 + : "cc");
7788 +
7789 + old = atomic_cmpxchg(v, c, new);
7790 if (likely(old == c))
7791 break;
7792 c = old;
7793 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7794 #define atomic64_cmpxchg(v, o, n) \
7795 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7796 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7797 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7798 +{
7799 + return xchg(&v->counter, new);
7800 +}
7801
7802 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7803 {
7804 - long c, old;
7805 + long c, old, new;
7806 c = atomic64_read(v);
7807 for (;;) {
7808 - if (unlikely(c == (u)))
7809 + if (unlikely(c == u))
7810 break;
7811 - old = atomic64_cmpxchg((v), c, c + (a));
7812 +
7813 + asm volatile("addcc %2, %0, %0\n"
7814 +
7815 +#ifdef CONFIG_PAX_REFCOUNT
7816 + "tvs %%xcc, 6\n"
7817 +#endif
7818 +
7819 + : "=r" (new)
7820 + : "0" (c), "ir" (a)
7821 + : "cc");
7822 +
7823 + old = atomic64_cmpxchg(v, c, new);
7824 if (likely(old == c))
7825 break;
7826 c = old;
7827 }
7828 - return c != (u);
7829 + return c != u;
7830 }
7831
7832 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7833 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7834 index 5bb6991..5c2132e 100644
7835 --- a/arch/sparc/include/asm/cache.h
7836 +++ b/arch/sparc/include/asm/cache.h
7837 @@ -7,10 +7,12 @@
7838 #ifndef _SPARC_CACHE_H
7839 #define _SPARC_CACHE_H
7840
7841 +#include <linux/const.h>
7842 +
7843 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7844
7845 #define L1_CACHE_SHIFT 5
7846 -#define L1_CACHE_BYTES 32
7847 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7848
7849 #ifdef CONFIG_SPARC32
7850 #define SMP_CACHE_BYTES_SHIFT 5
7851 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7852 index a24e41f..47677ff 100644
7853 --- a/arch/sparc/include/asm/elf_32.h
7854 +++ b/arch/sparc/include/asm/elf_32.h
7855 @@ -114,6 +114,13 @@ typedef struct {
7856
7857 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7858
7859 +#ifdef CONFIG_PAX_ASLR
7860 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7861 +
7862 +#define PAX_DELTA_MMAP_LEN 16
7863 +#define PAX_DELTA_STACK_LEN 16
7864 +#endif
7865 +
7866 /* This yields a mask that user programs can use to figure out what
7867 instruction set this cpu supports. This can NOT be done in userspace
7868 on Sparc. */
7869 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7870 index 370ca1e..d4f4a98 100644
7871 --- a/arch/sparc/include/asm/elf_64.h
7872 +++ b/arch/sparc/include/asm/elf_64.h
7873 @@ -189,6 +189,13 @@ typedef struct {
7874 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7875 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7876
7877 +#ifdef CONFIG_PAX_ASLR
7878 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7879 +
7880 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7881 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7882 +#endif
7883 +
7884 extern unsigned long sparc64_elf_hwcap;
7885 #define ELF_HWCAP sparc64_elf_hwcap
7886
7887 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7888 index 9b1c36d..209298b 100644
7889 --- a/arch/sparc/include/asm/pgalloc_32.h
7890 +++ b/arch/sparc/include/asm/pgalloc_32.h
7891 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7892 }
7893
7894 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7895 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7896
7897 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7898 unsigned long address)
7899 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7900 index bcfe063..b333142 100644
7901 --- a/arch/sparc/include/asm/pgalloc_64.h
7902 +++ b/arch/sparc/include/asm/pgalloc_64.h
7903 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7904 }
7905
7906 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7907 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7908
7909 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7910 {
7911 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7912 index 6fc1348..390c50a 100644
7913 --- a/arch/sparc/include/asm/pgtable_32.h
7914 +++ b/arch/sparc/include/asm/pgtable_32.h
7915 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7916 #define PAGE_SHARED SRMMU_PAGE_SHARED
7917 #define PAGE_COPY SRMMU_PAGE_COPY
7918 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7919 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7920 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7921 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7922 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7923
7924 /* Top-level page directory - dummy used by init-mm.
7925 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7926
7927 /* xwr */
7928 #define __P000 PAGE_NONE
7929 -#define __P001 PAGE_READONLY
7930 -#define __P010 PAGE_COPY
7931 -#define __P011 PAGE_COPY
7932 +#define __P001 PAGE_READONLY_NOEXEC
7933 +#define __P010 PAGE_COPY_NOEXEC
7934 +#define __P011 PAGE_COPY_NOEXEC
7935 #define __P100 PAGE_READONLY
7936 #define __P101 PAGE_READONLY
7937 #define __P110 PAGE_COPY
7938 #define __P111 PAGE_COPY
7939
7940 #define __S000 PAGE_NONE
7941 -#define __S001 PAGE_READONLY
7942 -#define __S010 PAGE_SHARED
7943 -#define __S011 PAGE_SHARED
7944 +#define __S001 PAGE_READONLY_NOEXEC
7945 +#define __S010 PAGE_SHARED_NOEXEC
7946 +#define __S011 PAGE_SHARED_NOEXEC
7947 #define __S100 PAGE_READONLY
7948 #define __S101 PAGE_READONLY
7949 #define __S110 PAGE_SHARED
7950 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7951 index 79da178..c2eede8 100644
7952 --- a/arch/sparc/include/asm/pgtsrmmu.h
7953 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7954 @@ -115,6 +115,11 @@
7955 SRMMU_EXEC | SRMMU_REF)
7956 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7957 SRMMU_EXEC | SRMMU_REF)
7958 +
7959 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7960 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7961 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7962 +
7963 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7964 SRMMU_DIRTY | SRMMU_REF)
7965
7966 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7967 index 9689176..63c18ea 100644
7968 --- a/arch/sparc/include/asm/spinlock_64.h
7969 +++ b/arch/sparc/include/asm/spinlock_64.h
7970 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7971
7972 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7973
7974 -static void inline arch_read_lock(arch_rwlock_t *lock)
7975 +static inline void arch_read_lock(arch_rwlock_t *lock)
7976 {
7977 unsigned long tmp1, tmp2;
7978
7979 __asm__ __volatile__ (
7980 "1: ldsw [%2], %0\n"
7981 " brlz,pn %0, 2f\n"
7982 -"4: add %0, 1, %1\n"
7983 +"4: 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 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
7993 " .previous"
7994 : "=&r" (tmp1), "=&r" (tmp2)
7995 : "r" (lock)
7996 - : "memory");
7997 + : "memory", "cc");
7998 }
7999
8000 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8001 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8002 {
8003 int tmp1, tmp2;
8004
8005 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8006 "1: ldsw [%2], %0\n"
8007 " brlz,a,pn %0, 2f\n"
8008 " mov 0, %0\n"
8009 -" add %0, 1, %1\n"
8010 +" addcc %0, 1, %1\n"
8011 +
8012 +#ifdef CONFIG_PAX_REFCOUNT
8013 +" tvs %%icc, 6\n"
8014 +#endif
8015 +
8016 " cas [%2], %0, %1\n"
8017 " cmp %0, %1\n"
8018 " bne,pn %%icc, 1b\n"
8019 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8020 return tmp1;
8021 }
8022
8023 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8024 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8025 {
8026 unsigned long tmp1, tmp2;
8027
8028 __asm__ __volatile__(
8029 "1: lduw [%2], %0\n"
8030 -" sub %0, 1, %1\n"
8031 +" subcc %0, 1, %1\n"
8032 +
8033 +#ifdef CONFIG_PAX_REFCOUNT
8034 +" tvs %%icc, 6\n"
8035 +#endif
8036 +
8037 " cas [%2], %0, %1\n"
8038 " cmp %0, %1\n"
8039 " bne,pn %%xcc, 1b\n"
8040 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8041 : "memory");
8042 }
8043
8044 -static void inline arch_write_lock(arch_rwlock_t *lock)
8045 +static inline void arch_write_lock(arch_rwlock_t *lock)
8046 {
8047 unsigned long mask, tmp1, tmp2;
8048
8049 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8050 : "memory");
8051 }
8052
8053 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8054 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8055 {
8056 __asm__ __volatile__(
8057 " stw %%g0, [%0]"
8058 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8059 : "memory");
8060 }
8061
8062 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8063 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8064 {
8065 unsigned long mask, tmp1, tmp2, result;
8066
8067 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8068 index 25849ae..924c54b 100644
8069 --- a/arch/sparc/include/asm/thread_info_32.h
8070 +++ b/arch/sparc/include/asm/thread_info_32.h
8071 @@ -49,6 +49,8 @@ struct thread_info {
8072 unsigned long w_saved;
8073
8074 struct restart_block restart_block;
8075 +
8076 + unsigned long lowest_stack;
8077 };
8078
8079 /*
8080 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8081 index 269bd92..e46a9b8 100644
8082 --- a/arch/sparc/include/asm/thread_info_64.h
8083 +++ b/arch/sparc/include/asm/thread_info_64.h
8084 @@ -63,6 +63,8 @@ struct thread_info {
8085 struct pt_regs *kern_una_regs;
8086 unsigned int kern_una_insn;
8087
8088 + unsigned long lowest_stack;
8089 +
8090 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8091 };
8092
8093 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8094 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8095 /* flag bit 6 is available */
8096 #define TIF_32BIT 7 /* 32-bit binary */
8097 -/* flag bit 8 is available */
8098 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8099 #define TIF_SECCOMP 9 /* secure computing */
8100 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8101 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8102 +
8103 /* NOTE: Thread flags >= 12 should be ones we have no interest
8104 * in using in assembly, else we can't use the mask as
8105 * an immediate value in instructions such as andcc.
8106 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8107 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8108 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8109 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8110 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8111
8112 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8113 _TIF_DO_NOTIFY_RESUME_MASK | \
8114 _TIF_NEED_RESCHED)
8115 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8116
8117 +#define _TIF_WORK_SYSCALL \
8118 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8119 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8120 +
8121 +
8122 /*
8123 * Thread-synchronous status.
8124 *
8125 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8126 index 0167d26..767bb0c 100644
8127 --- a/arch/sparc/include/asm/uaccess.h
8128 +++ b/arch/sparc/include/asm/uaccess.h
8129 @@ -1,5 +1,6 @@
8130 #ifndef ___ASM_SPARC_UACCESS_H
8131 #define ___ASM_SPARC_UACCESS_H
8132 +
8133 #if defined(__sparc__) && defined(__arch64__)
8134 #include <asm/uaccess_64.h>
8135 #else
8136 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8137 index 53a28dd..50c38c3 100644
8138 --- a/arch/sparc/include/asm/uaccess_32.h
8139 +++ b/arch/sparc/include/asm/uaccess_32.h
8140 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8141
8142 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8143 {
8144 - if (n && __access_ok((unsigned long) to, n))
8145 + if ((long)n < 0)
8146 + return n;
8147 +
8148 + if (n && __access_ok((unsigned long) to, n)) {
8149 + if (!__builtin_constant_p(n))
8150 + check_object_size(from, n, true);
8151 return __copy_user(to, (__force void __user *) from, n);
8152 - else
8153 + } else
8154 return n;
8155 }
8156
8157 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8158 {
8159 + if ((long)n < 0)
8160 + return n;
8161 +
8162 + if (!__builtin_constant_p(n))
8163 + check_object_size(from, n, true);
8164 +
8165 return __copy_user(to, (__force void __user *) from, n);
8166 }
8167
8168 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8169 {
8170 - if (n && __access_ok((unsigned long) from, n))
8171 + if ((long)n < 0)
8172 + return n;
8173 +
8174 + if (n && __access_ok((unsigned long) from, n)) {
8175 + if (!__builtin_constant_p(n))
8176 + check_object_size(to, n, false);
8177 return __copy_user((__force void __user *) to, from, n);
8178 - else
8179 + } else
8180 return n;
8181 }
8182
8183 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8184 {
8185 + if ((long)n < 0)
8186 + return n;
8187 +
8188 return __copy_user((__force void __user *) to, from, n);
8189 }
8190
8191 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8192 index e562d3c..191f176 100644
8193 --- a/arch/sparc/include/asm/uaccess_64.h
8194 +++ b/arch/sparc/include/asm/uaccess_64.h
8195 @@ -10,6 +10,7 @@
8196 #include <linux/compiler.h>
8197 #include <linux/string.h>
8198 #include <linux/thread_info.h>
8199 +#include <linux/kernel.h>
8200 #include <asm/asi.h>
8201 #include <asm/spitfire.h>
8202 #include <asm-generic/uaccess-unaligned.h>
8203 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8204 static inline unsigned long __must_check
8205 copy_from_user(void *to, const void __user *from, unsigned long size)
8206 {
8207 - unsigned long ret = ___copy_from_user(to, from, size);
8208 + unsigned long ret;
8209
8210 + if ((long)size < 0 || size > INT_MAX)
8211 + return size;
8212 +
8213 + if (!__builtin_constant_p(size))
8214 + check_object_size(to, size, false);
8215 +
8216 + ret = ___copy_from_user(to, from, size);
8217 if (unlikely(ret))
8218 ret = copy_from_user_fixup(to, from, size);
8219
8220 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8221 static inline unsigned long __must_check
8222 copy_to_user(void __user *to, const void *from, unsigned long size)
8223 {
8224 - unsigned long ret = ___copy_to_user(to, from, size);
8225 + unsigned long ret;
8226
8227 + if ((long)size < 0 || size > INT_MAX)
8228 + return size;
8229 +
8230 + if (!__builtin_constant_p(size))
8231 + check_object_size(from, size, true);
8232 +
8233 + ret = ___copy_to_user(to, from, size);
8234 if (unlikely(ret))
8235 ret = copy_to_user_fixup(to, from, size);
8236 return ret;
8237 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8238 index 6cf591b..b49e65a 100644
8239 --- a/arch/sparc/kernel/Makefile
8240 +++ b/arch/sparc/kernel/Makefile
8241 @@ -3,7 +3,7 @@
8242 #
8243
8244 asflags-y := -ansi
8245 -ccflags-y := -Werror
8246 +#ccflags-y := -Werror
8247
8248 extra-y := head_$(BITS).o
8249
8250 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8251 index 62eede1..9c5b904 100644
8252 --- a/arch/sparc/kernel/process_32.c
8253 +++ b/arch/sparc/kernel/process_32.c
8254 @@ -125,14 +125,14 @@ void show_regs(struct pt_regs *r)
8255
8256 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8257 r->psr, r->pc, r->npc, r->y, print_tainted());
8258 - printk("PC: <%pS>\n", (void *) r->pc);
8259 + printk("PC: <%pA>\n", (void *) r->pc);
8260 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8261 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8262 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8263 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8264 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8265 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8266 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8267 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8268
8269 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8270 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8271 @@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8272 rw = (struct reg_window32 *) fp;
8273 pc = rw->ins[7];
8274 printk("[%08lx : ", pc);
8275 - printk("%pS ] ", (void *) pc);
8276 + printk("%pA ] ", (void *) pc);
8277 fp = rw->ins[6];
8278 } while (++count < 16);
8279 printk("\n");
8280 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8281 index cdb80b2..5ca141d 100644
8282 --- a/arch/sparc/kernel/process_64.c
8283 +++ b/arch/sparc/kernel/process_64.c
8284 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8285 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8286 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8287 if (regs->tstate & TSTATE_PRIV)
8288 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8289 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8290 }
8291
8292 void show_regs(struct pt_regs *regs)
8293 {
8294 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8295 regs->tpc, regs->tnpc, regs->y, print_tainted());
8296 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8297 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8298 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8299 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8300 regs->u_regs[3]);
8301 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8302 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8303 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8304 regs->u_regs[15]);
8305 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8306 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8307 show_regwindow(regs);
8308 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8309 }
8310 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8311 ((tp && tp->task) ? tp->task->pid : -1));
8312
8313 if (gp->tstate & TSTATE_PRIV) {
8314 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8315 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8316 (void *) gp->tpc,
8317 (void *) gp->o7,
8318 (void *) gp->i7,
8319 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8320 index 9f20566..67eb41b 100644
8321 --- a/arch/sparc/kernel/prom_common.c
8322 +++ b/arch/sparc/kernel/prom_common.c
8323 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8324
8325 unsigned int prom_early_allocated __initdata;
8326
8327 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8328 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8329 .nextprop = prom_common_nextprop,
8330 .getproplen = prom_getproplen,
8331 .getproperty = prom_getproperty,
8332 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8333 index 7ff45e4..a58f271 100644
8334 --- a/arch/sparc/kernel/ptrace_64.c
8335 +++ b/arch/sparc/kernel/ptrace_64.c
8336 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8337 return ret;
8338 }
8339
8340 +#ifdef CONFIG_GRKERNSEC_SETXID
8341 +extern void gr_delayed_cred_worker(void);
8342 +#endif
8343 +
8344 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8345 {
8346 int ret = 0;
8347 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8348 /* do the secure computing check first */
8349 secure_computing_strict(regs->u_regs[UREG_G1]);
8350
8351 +#ifdef CONFIG_GRKERNSEC_SETXID
8352 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8353 + gr_delayed_cred_worker();
8354 +#endif
8355 +
8356 if (test_thread_flag(TIF_SYSCALL_TRACE))
8357 ret = tracehook_report_syscall_entry(regs);
8358
8359 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8360
8361 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8362 {
8363 +#ifdef CONFIG_GRKERNSEC_SETXID
8364 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8365 + gr_delayed_cred_worker();
8366 +#endif
8367 +
8368 audit_syscall_exit(regs);
8369
8370 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8371 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8372 index 3a8d184..49498a8 100644
8373 --- a/arch/sparc/kernel/sys_sparc_32.c
8374 +++ b/arch/sparc/kernel/sys_sparc_32.c
8375 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8376 if (len > TASK_SIZE - PAGE_SIZE)
8377 return -ENOMEM;
8378 if (!addr)
8379 - addr = TASK_UNMAPPED_BASE;
8380 + addr = current->mm->mmap_base;
8381
8382 info.flags = 0;
8383 info.length = len;
8384 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8385 index 708bc29..6bfdfad 100644
8386 --- a/arch/sparc/kernel/sys_sparc_64.c
8387 +++ b/arch/sparc/kernel/sys_sparc_64.c
8388 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8389 struct vm_area_struct * vma;
8390 unsigned long task_size = TASK_SIZE;
8391 int do_color_align;
8392 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8393 struct vm_unmapped_area_info info;
8394
8395 if (flags & MAP_FIXED) {
8396 /* We do not accept a shared mapping if it would violate
8397 * cache aliasing constraints.
8398 */
8399 - if ((flags & MAP_SHARED) &&
8400 + if ((filp || (flags & MAP_SHARED)) &&
8401 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8402 return -EINVAL;
8403 return addr;
8404 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8405 if (filp || (flags & MAP_SHARED))
8406 do_color_align = 1;
8407
8408 +#ifdef CONFIG_PAX_RANDMMAP
8409 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8410 +#endif
8411 +
8412 if (addr) {
8413 if (do_color_align)
8414 addr = COLOR_ALIGN(addr, pgoff);
8415 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8416 addr = PAGE_ALIGN(addr);
8417
8418 vma = find_vma(mm, addr);
8419 - if (task_size - len >= addr &&
8420 - (!vma || addr + len <= vma->vm_start))
8421 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8422 return addr;
8423 }
8424
8425 info.flags = 0;
8426 info.length = len;
8427 - info.low_limit = TASK_UNMAPPED_BASE;
8428 + info.low_limit = mm->mmap_base;
8429 info.high_limit = min(task_size, VA_EXCLUDE_START);
8430 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8431 info.align_offset = pgoff << PAGE_SHIFT;
8432 + info.threadstack_offset = offset;
8433 addr = vm_unmapped_area(&info);
8434
8435 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8436 VM_BUG_ON(addr != -ENOMEM);
8437 info.low_limit = VA_EXCLUDE_END;
8438 +
8439 +#ifdef CONFIG_PAX_RANDMMAP
8440 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8441 + info.low_limit += mm->delta_mmap;
8442 +#endif
8443 +
8444 info.high_limit = task_size;
8445 addr = vm_unmapped_area(&info);
8446 }
8447 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8448 unsigned long task_size = STACK_TOP32;
8449 unsigned long addr = addr0;
8450 int do_color_align;
8451 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8452 struct vm_unmapped_area_info info;
8453
8454 /* This should only ever run for 32-bit processes. */
8455 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8456 /* We do not accept a shared mapping if it would violate
8457 * cache aliasing constraints.
8458 */
8459 - if ((flags & MAP_SHARED) &&
8460 + if ((filp || (flags & MAP_SHARED)) &&
8461 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8462 return -EINVAL;
8463 return addr;
8464 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8465 if (filp || (flags & MAP_SHARED))
8466 do_color_align = 1;
8467
8468 +#ifdef CONFIG_PAX_RANDMMAP
8469 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8470 +#endif
8471 +
8472 /* requesting a specific address */
8473 if (addr) {
8474 if (do_color_align)
8475 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8476 addr = PAGE_ALIGN(addr);
8477
8478 vma = find_vma(mm, addr);
8479 - if (task_size - len >= addr &&
8480 - (!vma || addr + len <= vma->vm_start))
8481 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8482 return addr;
8483 }
8484
8485 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8486 info.high_limit = mm->mmap_base;
8487 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8488 info.align_offset = pgoff << PAGE_SHIFT;
8489 + info.threadstack_offset = offset;
8490 addr = vm_unmapped_area(&info);
8491
8492 /*
8493 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8494 VM_BUG_ON(addr != -ENOMEM);
8495 info.flags = 0;
8496 info.low_limit = TASK_UNMAPPED_BASE;
8497 +
8498 +#ifdef CONFIG_PAX_RANDMMAP
8499 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8500 + info.low_limit += mm->delta_mmap;
8501 +#endif
8502 +
8503 info.high_limit = STACK_TOP32;
8504 addr = vm_unmapped_area(&info);
8505 }
8506 @@ -264,6 +286,10 @@ static unsigned long mmap_rnd(void)
8507 {
8508 unsigned long rnd = 0UL;
8509
8510 +#ifdef CONFIG_PAX_RANDMMAP
8511 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8512 +#endif
8513 +
8514 if (current->flags & PF_RANDOMIZE) {
8515 unsigned long val = get_random_int();
8516 if (test_thread_flag(TIF_32BIT))
8517 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8518 gap == RLIM_INFINITY ||
8519 sysctl_legacy_va_layout) {
8520 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8521 +
8522 +#ifdef CONFIG_PAX_RANDMMAP
8523 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8524 + mm->mmap_base += mm->delta_mmap;
8525 +#endif
8526 +
8527 mm->get_unmapped_area = arch_get_unmapped_area;
8528 mm->unmap_area = arch_unmap_area;
8529 } else {
8530 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8531 gap = (task_size / 6 * 5);
8532
8533 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8534 +
8535 +#ifdef CONFIG_PAX_RANDMMAP
8536 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8537 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8538 +#endif
8539 +
8540 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8541 mm->unmap_area = arch_unmap_area_topdown;
8542 }
8543 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8544 index 22a1098..6255eb9 100644
8545 --- a/arch/sparc/kernel/syscalls.S
8546 +++ b/arch/sparc/kernel/syscalls.S
8547 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8548 #endif
8549 .align 32
8550 1: ldx [%g6 + TI_FLAGS], %l5
8551 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8552 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8553 be,pt %icc, rtrap
8554 nop
8555 call syscall_trace_leave
8556 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8557
8558 srl %i5, 0, %o5 ! IEU1
8559 srl %i2, 0, %o2 ! IEU0 Group
8560 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8561 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8562 bne,pn %icc, linux_syscall_trace32 ! CTI
8563 mov %i0, %l5 ! IEU1
8564 call %l7 ! CTI Group brk forced
8565 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8566
8567 mov %i3, %o3 ! IEU1
8568 mov %i4, %o4 ! IEU0 Group
8569 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8570 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8571 bne,pn %icc, linux_syscall_trace ! CTI Group
8572 mov %i0, %l5 ! IEU0
8573 2: call %l7 ! CTI Group brk forced
8574 @@ -223,7 +223,7 @@ ret_sys_call:
8575
8576 cmp %o0, -ERESTART_RESTARTBLOCK
8577 bgeu,pn %xcc, 1f
8578 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8579 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8580 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8581
8582 2:
8583 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8584 index 654e8aa..45f431b 100644
8585 --- a/arch/sparc/kernel/sysfs.c
8586 +++ b/arch/sparc/kernel/sysfs.c
8587 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8588 return NOTIFY_OK;
8589 }
8590
8591 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8592 +static struct notifier_block sysfs_cpu_nb = {
8593 .notifier_call = sysfs_cpu_notify,
8594 };
8595
8596 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8597 index 6629829..036032d 100644
8598 --- a/arch/sparc/kernel/traps_32.c
8599 +++ b/arch/sparc/kernel/traps_32.c
8600 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8601 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8602 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8603
8604 +extern void gr_handle_kernel_exploit(void);
8605 +
8606 void die_if_kernel(char *str, struct pt_regs *regs)
8607 {
8608 static int die_counter;
8609 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8610 count++ < 30 &&
8611 (((unsigned long) rw) >= PAGE_OFFSET) &&
8612 !(((unsigned long) rw) & 0x7)) {
8613 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8614 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8615 (void *) rw->ins[7]);
8616 rw = (struct reg_window32 *)rw->ins[6];
8617 }
8618 }
8619 printk("Instruction DUMP:");
8620 instruction_dump ((unsigned long *) regs->pc);
8621 - if(regs->psr & PSR_PS)
8622 + if(regs->psr & PSR_PS) {
8623 + gr_handle_kernel_exploit();
8624 do_exit(SIGKILL);
8625 + }
8626 do_exit(SIGSEGV);
8627 }
8628
8629 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8630 index 8d38ca9..845b1d6 100644
8631 --- a/arch/sparc/kernel/traps_64.c
8632 +++ b/arch/sparc/kernel/traps_64.c
8633 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8634 i + 1,
8635 p->trapstack[i].tstate, p->trapstack[i].tpc,
8636 p->trapstack[i].tnpc, p->trapstack[i].tt);
8637 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8638 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8639 }
8640 }
8641
8642 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8643
8644 lvl -= 0x100;
8645 if (regs->tstate & TSTATE_PRIV) {
8646 +
8647 +#ifdef CONFIG_PAX_REFCOUNT
8648 + if (lvl == 6)
8649 + pax_report_refcount_overflow(regs);
8650 +#endif
8651 +
8652 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8653 die_if_kernel(buffer, regs);
8654 }
8655 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8656 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8657 {
8658 char buffer[32];
8659 -
8660 +
8661 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8662 0, lvl, SIGTRAP) == NOTIFY_STOP)
8663 return;
8664
8665 +#ifdef CONFIG_PAX_REFCOUNT
8666 + if (lvl == 6)
8667 + pax_report_refcount_overflow(regs);
8668 +#endif
8669 +
8670 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8671
8672 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8673 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8674 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8675 printk("%s" "ERROR(%d): ",
8676 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8677 - printk("TPC<%pS>\n", (void *) regs->tpc);
8678 + printk("TPC<%pA>\n", (void *) regs->tpc);
8679 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8680 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8681 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8682 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8683 smp_processor_id(),
8684 (type & 0x1) ? 'I' : 'D',
8685 regs->tpc);
8686 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8687 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8688 panic("Irrecoverable Cheetah+ parity error.");
8689 }
8690
8691 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8692 smp_processor_id(),
8693 (type & 0x1) ? 'I' : 'D',
8694 regs->tpc);
8695 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8696 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8697 }
8698
8699 struct sun4v_error_entry {
8700 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8701
8702 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8703 regs->tpc, tl);
8704 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8705 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8706 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8707 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8708 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8709 (void *) regs->u_regs[UREG_I7]);
8710 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8711 "pte[%lx] error[%lx]\n",
8712 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8713
8714 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8715 regs->tpc, tl);
8716 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8717 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8718 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8719 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8720 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8721 (void *) regs->u_regs[UREG_I7]);
8722 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8723 "pte[%lx] error[%lx]\n",
8724 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8725 fp = (unsigned long)sf->fp + STACK_BIAS;
8726 }
8727
8728 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8729 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8730 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8731 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8732 int index = tsk->curr_ret_stack;
8733 if (tsk->ret_stack && index >= graph) {
8734 pc = tsk->ret_stack[index - graph].ret;
8735 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8736 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8737 graph++;
8738 }
8739 }
8740 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8741 return (struct reg_window *) (fp + STACK_BIAS);
8742 }
8743
8744 +extern void gr_handle_kernel_exploit(void);
8745 +
8746 void die_if_kernel(char *str, struct pt_regs *regs)
8747 {
8748 static int die_counter;
8749 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8750 while (rw &&
8751 count++ < 30 &&
8752 kstack_valid(tp, (unsigned long) rw)) {
8753 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8754 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8755 (void *) rw->ins[7]);
8756
8757 rw = kernel_stack_up(rw);
8758 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8759 }
8760 user_instruction_dump ((unsigned int __user *) regs->tpc);
8761 }
8762 - if (regs->tstate & TSTATE_PRIV)
8763 + if (regs->tstate & TSTATE_PRIV) {
8764 + gr_handle_kernel_exploit();
8765 do_exit(SIGKILL);
8766 + }
8767 do_exit(SIGSEGV);
8768 }
8769 EXPORT_SYMBOL(die_if_kernel);
8770 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8771 index 8201c25e..072a2a7 100644
8772 --- a/arch/sparc/kernel/unaligned_64.c
8773 +++ b/arch/sparc/kernel/unaligned_64.c
8774 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8775 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8776
8777 if (__ratelimit(&ratelimit)) {
8778 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8779 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8780 regs->tpc, (void *) regs->tpc);
8781 }
8782 }
8783 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
8784 index eb1624b..55100de 100644
8785 --- a/arch/sparc/kernel/us3_cpufreq.c
8786 +++ b/arch/sparc/kernel/us3_cpufreq.c
8787 @@ -18,14 +18,12 @@
8788 #include <asm/head.h>
8789 #include <asm/timer.h>
8790
8791 -static struct cpufreq_driver *cpufreq_us3_driver;
8792 -
8793 struct us3_freq_percpu_info {
8794 struct cpufreq_frequency_table table[4];
8795 };
8796
8797 /* Indexed by cpu number. */
8798 -static struct us3_freq_percpu_info *us3_freq_table;
8799 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
8800
8801 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
8802 * in the Safari config register.
8803 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
8804
8805 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
8806 {
8807 - if (cpufreq_us3_driver)
8808 - us3_set_cpu_divider_index(policy->cpu, 0);
8809 + us3_set_cpu_divider_index(policy->cpu, 0);
8810
8811 return 0;
8812 }
8813
8814 +static int __init us3_freq_init(void);
8815 +static void __exit us3_freq_exit(void);
8816 +
8817 +static struct cpufreq_driver cpufreq_us3_driver = {
8818 + .init = us3_freq_cpu_init,
8819 + .verify = us3_freq_verify,
8820 + .target = us3_freq_target,
8821 + .get = us3_freq_get,
8822 + .exit = us3_freq_cpu_exit,
8823 + .owner = THIS_MODULE,
8824 + .name = "UltraSPARC-III",
8825 +
8826 +};
8827 +
8828 static int __init us3_freq_init(void)
8829 {
8830 unsigned long manuf, impl, ver;
8831 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
8832 (impl == CHEETAH_IMPL ||
8833 impl == CHEETAH_PLUS_IMPL ||
8834 impl == JAGUAR_IMPL ||
8835 - impl == PANTHER_IMPL)) {
8836 - struct cpufreq_driver *driver;
8837 -
8838 - ret = -ENOMEM;
8839 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
8840 - if (!driver)
8841 - goto err_out;
8842 -
8843 - us3_freq_table = kzalloc(
8844 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
8845 - GFP_KERNEL);
8846 - if (!us3_freq_table)
8847 - goto err_out;
8848 -
8849 - driver->init = us3_freq_cpu_init;
8850 - driver->verify = us3_freq_verify;
8851 - driver->target = us3_freq_target;
8852 - driver->get = us3_freq_get;
8853 - driver->exit = us3_freq_cpu_exit;
8854 - driver->owner = THIS_MODULE,
8855 - strcpy(driver->name, "UltraSPARC-III");
8856 -
8857 - cpufreq_us3_driver = driver;
8858 - ret = cpufreq_register_driver(driver);
8859 - if (ret)
8860 - goto err_out;
8861 -
8862 - return 0;
8863 -
8864 -err_out:
8865 - if (driver) {
8866 - kfree(driver);
8867 - cpufreq_us3_driver = NULL;
8868 - }
8869 - kfree(us3_freq_table);
8870 - us3_freq_table = NULL;
8871 - return ret;
8872 - }
8873 + impl == PANTHER_IMPL))
8874 + return cpufreq_register_driver(&cpufreq_us3_driver);
8875
8876 return -ENODEV;
8877 }
8878
8879 static void __exit us3_freq_exit(void)
8880 {
8881 - if (cpufreq_us3_driver) {
8882 - cpufreq_unregister_driver(cpufreq_us3_driver);
8883 - kfree(cpufreq_us3_driver);
8884 - cpufreq_us3_driver = NULL;
8885 - kfree(us3_freq_table);
8886 - us3_freq_table = NULL;
8887 - }
8888 + cpufreq_unregister_driver(&cpufreq_us3_driver);
8889 }
8890
8891 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
8892 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8893 index 8410065f2..4fd4ca22 100644
8894 --- a/arch/sparc/lib/Makefile
8895 +++ b/arch/sparc/lib/Makefile
8896 @@ -2,7 +2,7 @@
8897 #
8898
8899 asflags-y := -ansi -DST_DIV0=0x02
8900 -ccflags-y := -Werror
8901 +#ccflags-y := -Werror
8902
8903 lib-$(CONFIG_SPARC32) += ashrdi3.o
8904 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8905 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8906 index 85c233d..68500e0 100644
8907 --- a/arch/sparc/lib/atomic_64.S
8908 +++ b/arch/sparc/lib/atomic_64.S
8909 @@ -17,7 +17,12 @@
8910 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8911 BACKOFF_SETUP(%o2)
8912 1: lduw [%o1], %g1
8913 - add %g1, %o0, %g7
8914 + addcc %g1, %o0, %g7
8915 +
8916 +#ifdef CONFIG_PAX_REFCOUNT
8917 + tvs %icc, 6
8918 +#endif
8919 +
8920 cas [%o1], %g1, %g7
8921 cmp %g1, %g7
8922 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8923 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8924 2: BACKOFF_SPIN(%o2, %o3, 1b)
8925 ENDPROC(atomic_add)
8926
8927 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8928 + BACKOFF_SETUP(%o2)
8929 +1: lduw [%o1], %g1
8930 + add %g1, %o0, %g7
8931 + cas [%o1], %g1, %g7
8932 + cmp %g1, %g7
8933 + bne,pn %icc, 2f
8934 + nop
8935 + retl
8936 + nop
8937 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8938 +ENDPROC(atomic_add_unchecked)
8939 +
8940 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8941 BACKOFF_SETUP(%o2)
8942 1: lduw [%o1], %g1
8943 - sub %g1, %o0, %g7
8944 + subcc %g1, %o0, %g7
8945 +
8946 +#ifdef CONFIG_PAX_REFCOUNT
8947 + tvs %icc, 6
8948 +#endif
8949 +
8950 cas [%o1], %g1, %g7
8951 cmp %g1, %g7
8952 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8953 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8954 2: BACKOFF_SPIN(%o2, %o3, 1b)
8955 ENDPROC(atomic_sub)
8956
8957 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8958 + BACKOFF_SETUP(%o2)
8959 +1: lduw [%o1], %g1
8960 + sub %g1, %o0, %g7
8961 + cas [%o1], %g1, %g7
8962 + cmp %g1, %g7
8963 + bne,pn %icc, 2f
8964 + nop
8965 + retl
8966 + nop
8967 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8968 +ENDPROC(atomic_sub_unchecked)
8969 +
8970 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8971 BACKOFF_SETUP(%o2)
8972 1: lduw [%o1], %g1
8973 - add %g1, %o0, %g7
8974 + addcc %g1, %o0, %g7
8975 +
8976 +#ifdef CONFIG_PAX_REFCOUNT
8977 + tvs %icc, 6
8978 +#endif
8979 +
8980 cas [%o1], %g1, %g7
8981 cmp %g1, %g7
8982 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8983 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8984 2: BACKOFF_SPIN(%o2, %o3, 1b)
8985 ENDPROC(atomic_add_ret)
8986
8987 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8988 + BACKOFF_SETUP(%o2)
8989 +1: lduw [%o1], %g1
8990 + addcc %g1, %o0, %g7
8991 + cas [%o1], %g1, %g7
8992 + cmp %g1, %g7
8993 + bne,pn %icc, 2f
8994 + add %g7, %o0, %g7
8995 + sra %g7, 0, %o0
8996 + retl
8997 + nop
8998 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8999 +ENDPROC(atomic_add_ret_unchecked)
9000 +
9001 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9002 BACKOFF_SETUP(%o2)
9003 1: lduw [%o1], %g1
9004 - sub %g1, %o0, %g7
9005 + subcc %g1, %o0, %g7
9006 +
9007 +#ifdef CONFIG_PAX_REFCOUNT
9008 + tvs %icc, 6
9009 +#endif
9010 +
9011 cas [%o1], %g1, %g7
9012 cmp %g1, %g7
9013 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9014 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9015 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9016 BACKOFF_SETUP(%o2)
9017 1: ldx [%o1], %g1
9018 - add %g1, %o0, %g7
9019 + addcc %g1, %o0, %g7
9020 +
9021 +#ifdef CONFIG_PAX_REFCOUNT
9022 + tvs %xcc, 6
9023 +#endif
9024 +
9025 casx [%o1], %g1, %g7
9026 cmp %g1, %g7
9027 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9028 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9029 2: BACKOFF_SPIN(%o2, %o3, 1b)
9030 ENDPROC(atomic64_add)
9031
9032 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9033 + BACKOFF_SETUP(%o2)
9034 +1: ldx [%o1], %g1
9035 + addcc %g1, %o0, %g7
9036 + casx [%o1], %g1, %g7
9037 + cmp %g1, %g7
9038 + bne,pn %xcc, 2f
9039 + nop
9040 + retl
9041 + nop
9042 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9043 +ENDPROC(atomic64_add_unchecked)
9044 +
9045 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9046 BACKOFF_SETUP(%o2)
9047 1: ldx [%o1], %g1
9048 - sub %g1, %o0, %g7
9049 + subcc %g1, %o0, %g7
9050 +
9051 +#ifdef CONFIG_PAX_REFCOUNT
9052 + tvs %xcc, 6
9053 +#endif
9054 +
9055 casx [%o1], %g1, %g7
9056 cmp %g1, %g7
9057 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9058 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9059 2: BACKOFF_SPIN(%o2, %o3, 1b)
9060 ENDPROC(atomic64_sub)
9061
9062 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9063 + BACKOFF_SETUP(%o2)
9064 +1: ldx [%o1], %g1
9065 + subcc %g1, %o0, %g7
9066 + casx [%o1], %g1, %g7
9067 + cmp %g1, %g7
9068 + bne,pn %xcc, 2f
9069 + nop
9070 + retl
9071 + nop
9072 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9073 +ENDPROC(atomic64_sub_unchecked)
9074 +
9075 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9076 BACKOFF_SETUP(%o2)
9077 1: ldx [%o1], %g1
9078 - add %g1, %o0, %g7
9079 + addcc %g1, %o0, %g7
9080 +
9081 +#ifdef CONFIG_PAX_REFCOUNT
9082 + tvs %xcc, 6
9083 +#endif
9084 +
9085 casx [%o1], %g1, %g7
9086 cmp %g1, %g7
9087 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9088 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9089 2: BACKOFF_SPIN(%o2, %o3, 1b)
9090 ENDPROC(atomic64_add_ret)
9091
9092 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9093 + BACKOFF_SETUP(%o2)
9094 +1: ldx [%o1], %g1
9095 + addcc %g1, %o0, %g7
9096 + casx [%o1], %g1, %g7
9097 + cmp %g1, %g7
9098 + bne,pn %xcc, 2f
9099 + add %g7, %o0, %g7
9100 + mov %g7, %o0
9101 + retl
9102 + nop
9103 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9104 +ENDPROC(atomic64_add_ret_unchecked)
9105 +
9106 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9107 BACKOFF_SETUP(%o2)
9108 1: ldx [%o1], %g1
9109 - sub %g1, %o0, %g7
9110 + subcc %g1, %o0, %g7
9111 +
9112 +#ifdef CONFIG_PAX_REFCOUNT
9113 + tvs %xcc, 6
9114 +#endif
9115 +
9116 casx [%o1], %g1, %g7
9117 cmp %g1, %g7
9118 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9119 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9120 index 0c4e35e..745d3e4 100644
9121 --- a/arch/sparc/lib/ksyms.c
9122 +++ b/arch/sparc/lib/ksyms.c
9123 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9124
9125 /* Atomic counter implementation. */
9126 EXPORT_SYMBOL(atomic_add);
9127 +EXPORT_SYMBOL(atomic_add_unchecked);
9128 EXPORT_SYMBOL(atomic_add_ret);
9129 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9130 EXPORT_SYMBOL(atomic_sub);
9131 +EXPORT_SYMBOL(atomic_sub_unchecked);
9132 EXPORT_SYMBOL(atomic_sub_ret);
9133 EXPORT_SYMBOL(atomic64_add);
9134 +EXPORT_SYMBOL(atomic64_add_unchecked);
9135 EXPORT_SYMBOL(atomic64_add_ret);
9136 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9137 EXPORT_SYMBOL(atomic64_sub);
9138 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9139 EXPORT_SYMBOL(atomic64_sub_ret);
9140 EXPORT_SYMBOL(atomic64_dec_if_positive);
9141
9142 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9143 index 30c3ecc..736f015 100644
9144 --- a/arch/sparc/mm/Makefile
9145 +++ b/arch/sparc/mm/Makefile
9146 @@ -2,7 +2,7 @@
9147 #
9148
9149 asflags-y := -ansi
9150 -ccflags-y := -Werror
9151 +#ccflags-y := -Werror
9152
9153 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9154 obj-y += fault_$(BITS).o
9155 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9156 index e98bfda..ea8d221 100644
9157 --- a/arch/sparc/mm/fault_32.c
9158 +++ b/arch/sparc/mm/fault_32.c
9159 @@ -21,6 +21,9 @@
9160 #include <linux/perf_event.h>
9161 #include <linux/interrupt.h>
9162 #include <linux/kdebug.h>
9163 +#include <linux/slab.h>
9164 +#include <linux/pagemap.h>
9165 +#include <linux/compiler.h>
9166
9167 #include <asm/page.h>
9168 #include <asm/pgtable.h>
9169 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9170 return safe_compute_effective_address(regs, insn);
9171 }
9172
9173 +#ifdef CONFIG_PAX_PAGEEXEC
9174 +#ifdef CONFIG_PAX_DLRESOLVE
9175 +static void pax_emuplt_close(struct vm_area_struct *vma)
9176 +{
9177 + vma->vm_mm->call_dl_resolve = 0UL;
9178 +}
9179 +
9180 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9181 +{
9182 + unsigned int *kaddr;
9183 +
9184 + vmf->page = alloc_page(GFP_HIGHUSER);
9185 + if (!vmf->page)
9186 + return VM_FAULT_OOM;
9187 +
9188 + kaddr = kmap(vmf->page);
9189 + memset(kaddr, 0, PAGE_SIZE);
9190 + kaddr[0] = 0x9DE3BFA8U; /* save */
9191 + flush_dcache_page(vmf->page);
9192 + kunmap(vmf->page);
9193 + return VM_FAULT_MAJOR;
9194 +}
9195 +
9196 +static const struct vm_operations_struct pax_vm_ops = {
9197 + .close = pax_emuplt_close,
9198 + .fault = pax_emuplt_fault
9199 +};
9200 +
9201 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9202 +{
9203 + int ret;
9204 +
9205 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9206 + vma->vm_mm = current->mm;
9207 + vma->vm_start = addr;
9208 + vma->vm_end = addr + PAGE_SIZE;
9209 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9210 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9211 + vma->vm_ops = &pax_vm_ops;
9212 +
9213 + ret = insert_vm_struct(current->mm, vma);
9214 + if (ret)
9215 + return ret;
9216 +
9217 + ++current->mm->total_vm;
9218 + return 0;
9219 +}
9220 +#endif
9221 +
9222 +/*
9223 + * PaX: decide what to do with offenders (regs->pc = fault address)
9224 + *
9225 + * returns 1 when task should be killed
9226 + * 2 when patched PLT trampoline was detected
9227 + * 3 when unpatched PLT trampoline was detected
9228 + */
9229 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9230 +{
9231 +
9232 +#ifdef CONFIG_PAX_EMUPLT
9233 + int err;
9234 +
9235 + do { /* PaX: patched PLT emulation #1 */
9236 + unsigned int sethi1, sethi2, jmpl;
9237 +
9238 + err = get_user(sethi1, (unsigned int *)regs->pc);
9239 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9240 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9241 +
9242 + if (err)
9243 + break;
9244 +
9245 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9246 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9247 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9248 + {
9249 + unsigned int addr;
9250 +
9251 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9252 + addr = regs->u_regs[UREG_G1];
9253 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9254 + regs->pc = addr;
9255 + regs->npc = addr+4;
9256 + return 2;
9257 + }
9258 + } while (0);
9259 +
9260 + do { /* PaX: patched PLT emulation #2 */
9261 + unsigned int ba;
9262 +
9263 + err = get_user(ba, (unsigned int *)regs->pc);
9264 +
9265 + if (err)
9266 + break;
9267 +
9268 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9269 + unsigned int addr;
9270 +
9271 + if ((ba & 0xFFC00000U) == 0x30800000U)
9272 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9273 + else
9274 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9275 + regs->pc = addr;
9276 + regs->npc = addr+4;
9277 + return 2;
9278 + }
9279 + } while (0);
9280 +
9281 + do { /* PaX: patched PLT emulation #3 */
9282 + unsigned int sethi, bajmpl, nop;
9283 +
9284 + err = get_user(sethi, (unsigned int *)regs->pc);
9285 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9286 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9287 +
9288 + if (err)
9289 + break;
9290 +
9291 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9292 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9293 + nop == 0x01000000U)
9294 + {
9295 + unsigned int addr;
9296 +
9297 + addr = (sethi & 0x003FFFFFU) << 10;
9298 + regs->u_regs[UREG_G1] = addr;
9299 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9300 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9301 + else
9302 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9303 + regs->pc = addr;
9304 + regs->npc = addr+4;
9305 + return 2;
9306 + }
9307 + } while (0);
9308 +
9309 + do { /* PaX: unpatched PLT emulation step 1 */
9310 + unsigned int sethi, ba, nop;
9311 +
9312 + err = get_user(sethi, (unsigned int *)regs->pc);
9313 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9314 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9315 +
9316 + if (err)
9317 + break;
9318 +
9319 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9320 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9321 + nop == 0x01000000U)
9322 + {
9323 + unsigned int addr, save, call;
9324 +
9325 + if ((ba & 0xFFC00000U) == 0x30800000U)
9326 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9327 + else
9328 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9329 +
9330 + err = get_user(save, (unsigned int *)addr);
9331 + err |= get_user(call, (unsigned int *)(addr+4));
9332 + err |= get_user(nop, (unsigned int *)(addr+8));
9333 + if (err)
9334 + break;
9335 +
9336 +#ifdef CONFIG_PAX_DLRESOLVE
9337 + if (save == 0x9DE3BFA8U &&
9338 + (call & 0xC0000000U) == 0x40000000U &&
9339 + nop == 0x01000000U)
9340 + {
9341 + struct vm_area_struct *vma;
9342 + unsigned long call_dl_resolve;
9343 +
9344 + down_read(&current->mm->mmap_sem);
9345 + call_dl_resolve = current->mm->call_dl_resolve;
9346 + up_read(&current->mm->mmap_sem);
9347 + if (likely(call_dl_resolve))
9348 + goto emulate;
9349 +
9350 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9351 +
9352 + down_write(&current->mm->mmap_sem);
9353 + if (current->mm->call_dl_resolve) {
9354 + call_dl_resolve = current->mm->call_dl_resolve;
9355 + up_write(&current->mm->mmap_sem);
9356 + if (vma)
9357 + kmem_cache_free(vm_area_cachep, vma);
9358 + goto emulate;
9359 + }
9360 +
9361 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9362 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9363 + up_write(&current->mm->mmap_sem);
9364 + if (vma)
9365 + kmem_cache_free(vm_area_cachep, vma);
9366 + return 1;
9367 + }
9368 +
9369 + if (pax_insert_vma(vma, call_dl_resolve)) {
9370 + up_write(&current->mm->mmap_sem);
9371 + kmem_cache_free(vm_area_cachep, vma);
9372 + return 1;
9373 + }
9374 +
9375 + current->mm->call_dl_resolve = call_dl_resolve;
9376 + up_write(&current->mm->mmap_sem);
9377 +
9378 +emulate:
9379 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9380 + regs->pc = call_dl_resolve;
9381 + regs->npc = addr+4;
9382 + return 3;
9383 + }
9384 +#endif
9385 +
9386 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9387 + if ((save & 0xFFC00000U) == 0x05000000U &&
9388 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9389 + nop == 0x01000000U)
9390 + {
9391 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9392 + regs->u_regs[UREG_G2] = addr + 4;
9393 + addr = (save & 0x003FFFFFU) << 10;
9394 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9395 + regs->pc = addr;
9396 + regs->npc = addr+4;
9397 + return 3;
9398 + }
9399 + }
9400 + } while (0);
9401 +
9402 + do { /* PaX: unpatched PLT emulation step 2 */
9403 + unsigned int save, call, nop;
9404 +
9405 + err = get_user(save, (unsigned int *)(regs->pc-4));
9406 + err |= get_user(call, (unsigned int *)regs->pc);
9407 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9408 + if (err)
9409 + break;
9410 +
9411 + if (save == 0x9DE3BFA8U &&
9412 + (call & 0xC0000000U) == 0x40000000U &&
9413 + nop == 0x01000000U)
9414 + {
9415 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9416 +
9417 + regs->u_regs[UREG_RETPC] = regs->pc;
9418 + regs->pc = dl_resolve;
9419 + regs->npc = dl_resolve+4;
9420 + return 3;
9421 + }
9422 + } while (0);
9423 +#endif
9424 +
9425 + return 1;
9426 +}
9427 +
9428 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9429 +{
9430 + unsigned long i;
9431 +
9432 + printk(KERN_ERR "PAX: bytes at PC: ");
9433 + for (i = 0; i < 8; i++) {
9434 + unsigned int c;
9435 + if (get_user(c, (unsigned int *)pc+i))
9436 + printk(KERN_CONT "???????? ");
9437 + else
9438 + printk(KERN_CONT "%08x ", c);
9439 + }
9440 + printk("\n");
9441 +}
9442 +#endif
9443 +
9444 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9445 int text_fault)
9446 {
9447 @@ -230,6 +504,24 @@ good_area:
9448 if (!(vma->vm_flags & VM_WRITE))
9449 goto bad_area;
9450 } else {
9451 +
9452 +#ifdef CONFIG_PAX_PAGEEXEC
9453 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9454 + up_read(&mm->mmap_sem);
9455 + switch (pax_handle_fetch_fault(regs)) {
9456 +
9457 +#ifdef CONFIG_PAX_EMUPLT
9458 + case 2:
9459 + case 3:
9460 + return;
9461 +#endif
9462 +
9463 + }
9464 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9465 + do_group_exit(SIGKILL);
9466 + }
9467 +#endif
9468 +
9469 /* Allow reads even for write-only mappings */
9470 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9471 goto bad_area;
9472 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9473 index 5062ff3..e0b75f3 100644
9474 --- a/arch/sparc/mm/fault_64.c
9475 +++ b/arch/sparc/mm/fault_64.c
9476 @@ -21,6 +21,9 @@
9477 #include <linux/kprobes.h>
9478 #include <linux/kdebug.h>
9479 #include <linux/percpu.h>
9480 +#include <linux/slab.h>
9481 +#include <linux/pagemap.h>
9482 +#include <linux/compiler.h>
9483
9484 #include <asm/page.h>
9485 #include <asm/pgtable.h>
9486 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9487 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9488 regs->tpc);
9489 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9490 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9491 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9492 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9493 dump_stack();
9494 unhandled_fault(regs->tpc, current, regs);
9495 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9496 show_regs(regs);
9497 }
9498
9499 +#ifdef CONFIG_PAX_PAGEEXEC
9500 +#ifdef CONFIG_PAX_DLRESOLVE
9501 +static void pax_emuplt_close(struct vm_area_struct *vma)
9502 +{
9503 + vma->vm_mm->call_dl_resolve = 0UL;
9504 +}
9505 +
9506 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9507 +{
9508 + unsigned int *kaddr;
9509 +
9510 + vmf->page = alloc_page(GFP_HIGHUSER);
9511 + if (!vmf->page)
9512 + return VM_FAULT_OOM;
9513 +
9514 + kaddr = kmap(vmf->page);
9515 + memset(kaddr, 0, PAGE_SIZE);
9516 + kaddr[0] = 0x9DE3BFA8U; /* save */
9517 + flush_dcache_page(vmf->page);
9518 + kunmap(vmf->page);
9519 + return VM_FAULT_MAJOR;
9520 +}
9521 +
9522 +static const struct vm_operations_struct pax_vm_ops = {
9523 + .close = pax_emuplt_close,
9524 + .fault = pax_emuplt_fault
9525 +};
9526 +
9527 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9528 +{
9529 + int ret;
9530 +
9531 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9532 + vma->vm_mm = current->mm;
9533 + vma->vm_start = addr;
9534 + vma->vm_end = addr + PAGE_SIZE;
9535 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9536 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9537 + vma->vm_ops = &pax_vm_ops;
9538 +
9539 + ret = insert_vm_struct(current->mm, vma);
9540 + if (ret)
9541 + return ret;
9542 +
9543 + ++current->mm->total_vm;
9544 + return 0;
9545 +}
9546 +#endif
9547 +
9548 +/*
9549 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9550 + *
9551 + * returns 1 when task should be killed
9552 + * 2 when patched PLT trampoline was detected
9553 + * 3 when unpatched PLT trampoline was detected
9554 + */
9555 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9556 +{
9557 +
9558 +#ifdef CONFIG_PAX_EMUPLT
9559 + int err;
9560 +
9561 + do { /* PaX: patched PLT emulation #1 */
9562 + unsigned int sethi1, sethi2, jmpl;
9563 +
9564 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9565 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9566 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9567 +
9568 + if (err)
9569 + break;
9570 +
9571 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9572 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9573 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9574 + {
9575 + unsigned long addr;
9576 +
9577 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9578 + addr = regs->u_regs[UREG_G1];
9579 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9580 +
9581 + if (test_thread_flag(TIF_32BIT))
9582 + addr &= 0xFFFFFFFFUL;
9583 +
9584 + regs->tpc = addr;
9585 + regs->tnpc = addr+4;
9586 + return 2;
9587 + }
9588 + } while (0);
9589 +
9590 + do { /* PaX: patched PLT emulation #2 */
9591 + unsigned int ba;
9592 +
9593 + err = get_user(ba, (unsigned int *)regs->tpc);
9594 +
9595 + if (err)
9596 + break;
9597 +
9598 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9599 + unsigned long addr;
9600 +
9601 + if ((ba & 0xFFC00000U) == 0x30800000U)
9602 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9603 + else
9604 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9605 +
9606 + if (test_thread_flag(TIF_32BIT))
9607 + addr &= 0xFFFFFFFFUL;
9608 +
9609 + regs->tpc = addr;
9610 + regs->tnpc = addr+4;
9611 + return 2;
9612 + }
9613 + } while (0);
9614 +
9615 + do { /* PaX: patched PLT emulation #3 */
9616 + unsigned int sethi, bajmpl, nop;
9617 +
9618 + err = get_user(sethi, (unsigned int *)regs->tpc);
9619 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9620 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9621 +
9622 + if (err)
9623 + break;
9624 +
9625 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9626 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9627 + nop == 0x01000000U)
9628 + {
9629 + unsigned long addr;
9630 +
9631 + addr = (sethi & 0x003FFFFFU) << 10;
9632 + regs->u_regs[UREG_G1] = addr;
9633 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9634 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9635 + else
9636 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9637 +
9638 + if (test_thread_flag(TIF_32BIT))
9639 + addr &= 0xFFFFFFFFUL;
9640 +
9641 + regs->tpc = addr;
9642 + regs->tnpc = addr+4;
9643 + return 2;
9644 + }
9645 + } while (0);
9646 +
9647 + do { /* PaX: patched PLT emulation #4 */
9648 + unsigned int sethi, mov1, call, mov2;
9649 +
9650 + err = get_user(sethi, (unsigned int *)regs->tpc);
9651 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9652 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9653 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9654 +
9655 + if (err)
9656 + break;
9657 +
9658 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9659 + mov1 == 0x8210000FU &&
9660 + (call & 0xC0000000U) == 0x40000000U &&
9661 + mov2 == 0x9E100001U)
9662 + {
9663 + unsigned long addr;
9664 +
9665 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9666 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9667 +
9668 + if (test_thread_flag(TIF_32BIT))
9669 + addr &= 0xFFFFFFFFUL;
9670 +
9671 + regs->tpc = addr;
9672 + regs->tnpc = addr+4;
9673 + return 2;
9674 + }
9675 + } while (0);
9676 +
9677 + do { /* PaX: patched PLT emulation #5 */
9678 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9679 +
9680 + err = get_user(sethi, (unsigned int *)regs->tpc);
9681 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9682 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9683 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9684 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9685 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9686 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9687 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9688 +
9689 + if (err)
9690 + break;
9691 +
9692 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9693 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9694 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9695 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9696 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9697 + sllx == 0x83287020U &&
9698 + jmpl == 0x81C04005U &&
9699 + nop == 0x01000000U)
9700 + {
9701 + unsigned long addr;
9702 +
9703 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9704 + regs->u_regs[UREG_G1] <<= 32;
9705 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9706 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9707 + regs->tpc = addr;
9708 + regs->tnpc = addr+4;
9709 + return 2;
9710 + }
9711 + } while (0);
9712 +
9713 + do { /* PaX: patched PLT emulation #6 */
9714 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9715 +
9716 + err = get_user(sethi, (unsigned int *)regs->tpc);
9717 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9718 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9719 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9720 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9721 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9722 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9723 +
9724 + if (err)
9725 + break;
9726 +
9727 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9728 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9729 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9730 + sllx == 0x83287020U &&
9731 + (or & 0xFFFFE000U) == 0x8A116000U &&
9732 + jmpl == 0x81C04005U &&
9733 + nop == 0x01000000U)
9734 + {
9735 + unsigned long addr;
9736 +
9737 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9738 + regs->u_regs[UREG_G1] <<= 32;
9739 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9740 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9741 + regs->tpc = addr;
9742 + regs->tnpc = addr+4;
9743 + return 2;
9744 + }
9745 + } while (0);
9746 +
9747 + do { /* PaX: unpatched PLT emulation step 1 */
9748 + unsigned int sethi, ba, nop;
9749 +
9750 + err = get_user(sethi, (unsigned int *)regs->tpc);
9751 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9752 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9753 +
9754 + if (err)
9755 + break;
9756 +
9757 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9758 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9759 + nop == 0x01000000U)
9760 + {
9761 + unsigned long addr;
9762 + unsigned int save, call;
9763 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9764 +
9765 + if ((ba & 0xFFC00000U) == 0x30800000U)
9766 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9767 + else
9768 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9769 +
9770 + if (test_thread_flag(TIF_32BIT))
9771 + addr &= 0xFFFFFFFFUL;
9772 +
9773 + err = get_user(save, (unsigned int *)addr);
9774 + err |= get_user(call, (unsigned int *)(addr+4));
9775 + err |= get_user(nop, (unsigned int *)(addr+8));
9776 + if (err)
9777 + break;
9778 +
9779 +#ifdef CONFIG_PAX_DLRESOLVE
9780 + if (save == 0x9DE3BFA8U &&
9781 + (call & 0xC0000000U) == 0x40000000U &&
9782 + nop == 0x01000000U)
9783 + {
9784 + struct vm_area_struct *vma;
9785 + unsigned long call_dl_resolve;
9786 +
9787 + down_read(&current->mm->mmap_sem);
9788 + call_dl_resolve = current->mm->call_dl_resolve;
9789 + up_read(&current->mm->mmap_sem);
9790 + if (likely(call_dl_resolve))
9791 + goto emulate;
9792 +
9793 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9794 +
9795 + down_write(&current->mm->mmap_sem);
9796 + if (current->mm->call_dl_resolve) {
9797 + call_dl_resolve = current->mm->call_dl_resolve;
9798 + up_write(&current->mm->mmap_sem);
9799 + if (vma)
9800 + kmem_cache_free(vm_area_cachep, vma);
9801 + goto emulate;
9802 + }
9803 +
9804 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9805 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9806 + up_write(&current->mm->mmap_sem);
9807 + if (vma)
9808 + kmem_cache_free(vm_area_cachep, vma);
9809 + return 1;
9810 + }
9811 +
9812 + if (pax_insert_vma(vma, call_dl_resolve)) {
9813 + up_write(&current->mm->mmap_sem);
9814 + kmem_cache_free(vm_area_cachep, vma);
9815 + return 1;
9816 + }
9817 +
9818 + current->mm->call_dl_resolve = call_dl_resolve;
9819 + up_write(&current->mm->mmap_sem);
9820 +
9821 +emulate:
9822 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9823 + regs->tpc = call_dl_resolve;
9824 + regs->tnpc = addr+4;
9825 + return 3;
9826 + }
9827 +#endif
9828 +
9829 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9830 + if ((save & 0xFFC00000U) == 0x05000000U &&
9831 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9832 + nop == 0x01000000U)
9833 + {
9834 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9835 + regs->u_regs[UREG_G2] = addr + 4;
9836 + addr = (save & 0x003FFFFFU) << 10;
9837 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9838 +
9839 + if (test_thread_flag(TIF_32BIT))
9840 + addr &= 0xFFFFFFFFUL;
9841 +
9842 + regs->tpc = addr;
9843 + regs->tnpc = addr+4;
9844 + return 3;
9845 + }
9846 +
9847 + /* PaX: 64-bit PLT stub */
9848 + err = get_user(sethi1, (unsigned int *)addr);
9849 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9850 + err |= get_user(or1, (unsigned int *)(addr+8));
9851 + err |= get_user(or2, (unsigned int *)(addr+12));
9852 + err |= get_user(sllx, (unsigned int *)(addr+16));
9853 + err |= get_user(add, (unsigned int *)(addr+20));
9854 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9855 + err |= get_user(nop, (unsigned int *)(addr+28));
9856 + if (err)
9857 + break;
9858 +
9859 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9860 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9861 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9862 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9863 + sllx == 0x89293020U &&
9864 + add == 0x8A010005U &&
9865 + jmpl == 0x89C14000U &&
9866 + nop == 0x01000000U)
9867 + {
9868 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9869 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9870 + regs->u_regs[UREG_G4] <<= 32;
9871 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9872 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9873 + regs->u_regs[UREG_G4] = addr + 24;
9874 + addr = regs->u_regs[UREG_G5];
9875 + regs->tpc = addr;
9876 + regs->tnpc = addr+4;
9877 + return 3;
9878 + }
9879 + }
9880 + } while (0);
9881 +
9882 +#ifdef CONFIG_PAX_DLRESOLVE
9883 + do { /* PaX: unpatched PLT emulation step 2 */
9884 + unsigned int save, call, nop;
9885 +
9886 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9887 + err |= get_user(call, (unsigned int *)regs->tpc);
9888 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9889 + if (err)
9890 + break;
9891 +
9892 + if (save == 0x9DE3BFA8U &&
9893 + (call & 0xC0000000U) == 0x40000000U &&
9894 + nop == 0x01000000U)
9895 + {
9896 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9897 +
9898 + if (test_thread_flag(TIF_32BIT))
9899 + dl_resolve &= 0xFFFFFFFFUL;
9900 +
9901 + regs->u_regs[UREG_RETPC] = regs->tpc;
9902 + regs->tpc = dl_resolve;
9903 + regs->tnpc = dl_resolve+4;
9904 + return 3;
9905 + }
9906 + } while (0);
9907 +#endif
9908 +
9909 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9910 + unsigned int sethi, ba, nop;
9911 +
9912 + err = get_user(sethi, (unsigned int *)regs->tpc);
9913 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9914 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9915 +
9916 + if (err)
9917 + break;
9918 +
9919 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9920 + (ba & 0xFFF00000U) == 0x30600000U &&
9921 + nop == 0x01000000U)
9922 + {
9923 + unsigned long addr;
9924 +
9925 + addr = (sethi & 0x003FFFFFU) << 10;
9926 + regs->u_regs[UREG_G1] = addr;
9927 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9928 +
9929 + if (test_thread_flag(TIF_32BIT))
9930 + addr &= 0xFFFFFFFFUL;
9931 +
9932 + regs->tpc = addr;
9933 + regs->tnpc = addr+4;
9934 + return 2;
9935 + }
9936 + } while (0);
9937 +
9938 +#endif
9939 +
9940 + return 1;
9941 +}
9942 +
9943 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9944 +{
9945 + unsigned long i;
9946 +
9947 + printk(KERN_ERR "PAX: bytes at PC: ");
9948 + for (i = 0; i < 8; i++) {
9949 + unsigned int c;
9950 + if (get_user(c, (unsigned int *)pc+i))
9951 + printk(KERN_CONT "???????? ");
9952 + else
9953 + printk(KERN_CONT "%08x ", c);
9954 + }
9955 + printk("\n");
9956 +}
9957 +#endif
9958 +
9959 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9960 {
9961 struct mm_struct *mm = current->mm;
9962 @@ -341,6 +804,29 @@ retry:
9963 if (!vma)
9964 goto bad_area;
9965
9966 +#ifdef CONFIG_PAX_PAGEEXEC
9967 + /* PaX: detect ITLB misses on non-exec pages */
9968 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9969 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9970 + {
9971 + if (address != regs->tpc)
9972 + goto good_area;
9973 +
9974 + up_read(&mm->mmap_sem);
9975 + switch (pax_handle_fetch_fault(regs)) {
9976 +
9977 +#ifdef CONFIG_PAX_EMUPLT
9978 + case 2:
9979 + case 3:
9980 + return;
9981 +#endif
9982 +
9983 + }
9984 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9985 + do_group_exit(SIGKILL);
9986 + }
9987 +#endif
9988 +
9989 /* Pure DTLB misses do not tell us whether the fault causing
9990 * load/store/atomic was a write or not, it only says that there
9991 * was no match. So in such a case we (carefully) read the
9992 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9993 index d2b5944..bd813f2 100644
9994 --- a/arch/sparc/mm/hugetlbpage.c
9995 +++ b/arch/sparc/mm/hugetlbpage.c
9996 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9997
9998 info.flags = 0;
9999 info.length = len;
10000 - info.low_limit = TASK_UNMAPPED_BASE;
10001 + info.low_limit = mm->mmap_base;
10002 info.high_limit = min(task_size, VA_EXCLUDE_START);
10003 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10004 info.align_offset = 0;
10005 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10006 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10007 VM_BUG_ON(addr != -ENOMEM);
10008 info.low_limit = VA_EXCLUDE_END;
10009 +
10010 +#ifdef CONFIG_PAX_RANDMMAP
10011 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10012 + info.low_limit += mm->delta_mmap;
10013 +#endif
10014 +
10015 info.high_limit = task_size;
10016 addr = vm_unmapped_area(&info);
10017 }
10018 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10019 VM_BUG_ON(addr != -ENOMEM);
10020 info.flags = 0;
10021 info.low_limit = TASK_UNMAPPED_BASE;
10022 +
10023 +#ifdef CONFIG_PAX_RANDMMAP
10024 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10025 + info.low_limit += mm->delta_mmap;
10026 +#endif
10027 +
10028 info.high_limit = STACK_TOP32;
10029 addr = vm_unmapped_area(&info);
10030 }
10031 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10032 struct mm_struct *mm = current->mm;
10033 struct vm_area_struct *vma;
10034 unsigned long task_size = TASK_SIZE;
10035 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10036
10037 if (test_thread_flag(TIF_32BIT))
10038 task_size = STACK_TOP32;
10039 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10040 return addr;
10041 }
10042
10043 +#ifdef CONFIG_PAX_RANDMMAP
10044 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10045 +#endif
10046 +
10047 if (addr) {
10048 addr = ALIGN(addr, HPAGE_SIZE);
10049 vma = find_vma(mm, addr);
10050 - if (task_size - len >= addr &&
10051 - (!vma || addr + len <= vma->vm_start))
10052 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10053 return addr;
10054 }
10055 if (mm->get_unmapped_area == arch_get_unmapped_area)
10056 diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
10057 index 83d89bc..37e7bc4 100644
10058 --- a/arch/sparc/mm/tlb.c
10059 +++ b/arch/sparc/mm/tlb.c
10060 @@ -85,8 +85,8 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,
10061 }
10062
10063 if (!tb->active) {
10064 - global_flush_tlb_page(mm, vaddr);
10065 flush_tsb_user_page(mm, vaddr);
10066 + global_flush_tlb_page(mm, vaddr);
10067 goto out;
10068 }
10069
10070 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10071 index f4500c6..889656c 100644
10072 --- a/arch/tile/include/asm/atomic_64.h
10073 +++ b/arch/tile/include/asm/atomic_64.h
10074 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10075
10076 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10077
10078 +#define atomic64_read_unchecked(v) atomic64_read(v)
10079 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10080 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10081 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10082 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10083 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10084 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10085 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10086 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10087 +
10088 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10089 #define smp_mb__before_atomic_dec() smp_mb()
10090 #define smp_mb__after_atomic_dec() smp_mb()
10091 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10092 index a9a5299..0fce79e 100644
10093 --- a/arch/tile/include/asm/cache.h
10094 +++ b/arch/tile/include/asm/cache.h
10095 @@ -15,11 +15,12 @@
10096 #ifndef _ASM_TILE_CACHE_H
10097 #define _ASM_TILE_CACHE_H
10098
10099 +#include <linux/const.h>
10100 #include <arch/chip.h>
10101
10102 /* bytes per L1 data cache line */
10103 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10104 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10105 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10106
10107 /* bytes per L2 cache line */
10108 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10109 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10110 index 9ab078a..d6635c2 100644
10111 --- a/arch/tile/include/asm/uaccess.h
10112 +++ b/arch/tile/include/asm/uaccess.h
10113 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10114 const void __user *from,
10115 unsigned long n)
10116 {
10117 - int sz = __compiletime_object_size(to);
10118 + size_t sz = __compiletime_object_size(to);
10119
10120 - if (likely(sz == -1 || sz >= n))
10121 + if (likely(sz == (size_t)-1 || sz >= n))
10122 n = _copy_from_user(to, from, n);
10123 else
10124 copy_from_user_overflow();
10125 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10126 index 650ccff..45fe2d6 100644
10127 --- a/arch/tile/mm/hugetlbpage.c
10128 +++ b/arch/tile/mm/hugetlbpage.c
10129 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10130 info.high_limit = TASK_SIZE;
10131 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10132 info.align_offset = 0;
10133 + info.threadstack_offset = 0;
10134 return vm_unmapped_area(&info);
10135 }
10136
10137 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10138 info.high_limit = current->mm->mmap_base;
10139 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10140 info.align_offset = 0;
10141 + info.threadstack_offset = 0;
10142 addr = vm_unmapped_area(&info);
10143
10144 /*
10145 diff --git a/arch/um/Makefile b/arch/um/Makefile
10146 index 133f7de..1d6f2f1 100644
10147 --- a/arch/um/Makefile
10148 +++ b/arch/um/Makefile
10149 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10150 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10151 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10152
10153 +ifdef CONSTIFY_PLUGIN
10154 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10155 +endif
10156 +
10157 #This will adjust *FLAGS accordingly to the platform.
10158 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10159
10160 diff --git a/arch/um/defconfig b/arch/um/defconfig
10161 index 08107a7..ab22afe 100644
10162 --- a/arch/um/defconfig
10163 +++ b/arch/um/defconfig
10164 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10165 CONFIG_X86_L1_CACHE_SHIFT=5
10166 CONFIG_X86_XADD=y
10167 CONFIG_X86_PPRO_FENCE=y
10168 -CONFIG_X86_WP_WORKS_OK=y
10169 CONFIG_X86_INVLPG=y
10170 CONFIG_X86_BSWAP=y
10171 CONFIG_X86_POPAD_OK=y
10172 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10173 index 19e1bdd..3665b77 100644
10174 --- a/arch/um/include/asm/cache.h
10175 +++ b/arch/um/include/asm/cache.h
10176 @@ -1,6 +1,7 @@
10177 #ifndef __UM_CACHE_H
10178 #define __UM_CACHE_H
10179
10180 +#include <linux/const.h>
10181
10182 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10183 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10184 @@ -12,6 +13,6 @@
10185 # define L1_CACHE_SHIFT 5
10186 #endif
10187
10188 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10189 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10190
10191 #endif
10192 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10193 index 2e0a6b1..a64d0f5 100644
10194 --- a/arch/um/include/asm/kmap_types.h
10195 +++ b/arch/um/include/asm/kmap_types.h
10196 @@ -8,6 +8,6 @@
10197
10198 /* No more #include "asm/arch/kmap_types.h" ! */
10199
10200 -#define KM_TYPE_NR 14
10201 +#define KM_TYPE_NR 15
10202
10203 #endif
10204 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10205 index 5ff53d9..5850cdf 100644
10206 --- a/arch/um/include/asm/page.h
10207 +++ b/arch/um/include/asm/page.h
10208 @@ -14,6 +14,9 @@
10209 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10210 #define PAGE_MASK (~(PAGE_SIZE-1))
10211
10212 +#define ktla_ktva(addr) (addr)
10213 +#define ktva_ktla(addr) (addr)
10214 +
10215 #ifndef __ASSEMBLY__
10216
10217 struct page;
10218 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10219 index 0032f92..cd151e0 100644
10220 --- a/arch/um/include/asm/pgtable-3level.h
10221 +++ b/arch/um/include/asm/pgtable-3level.h
10222 @@ -58,6 +58,7 @@
10223 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10224 #define pud_populate(mm, pud, pmd) \
10225 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10226 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10227
10228 #ifdef CONFIG_64BIT
10229 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10230 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10231 index b462b13..e7a19aa 100644
10232 --- a/arch/um/kernel/process.c
10233 +++ b/arch/um/kernel/process.c
10234 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10235 return 2;
10236 }
10237
10238 -/*
10239 - * Only x86 and x86_64 have an arch_align_stack().
10240 - * All other arches have "#define arch_align_stack(x) (x)"
10241 - * in their asm/system.h
10242 - * As this is included in UML from asm-um/system-generic.h,
10243 - * we can use it to behave as the subarch does.
10244 - */
10245 -#ifndef arch_align_stack
10246 -unsigned long arch_align_stack(unsigned long sp)
10247 -{
10248 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10249 - sp -= get_random_int() % 8192;
10250 - return sp & ~0xf;
10251 -}
10252 -#endif
10253 -
10254 unsigned long get_wchan(struct task_struct *p)
10255 {
10256 unsigned long stack_page, sp, ip;
10257 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10258 index ad8f795..2c7eec6 100644
10259 --- a/arch/unicore32/include/asm/cache.h
10260 +++ b/arch/unicore32/include/asm/cache.h
10261 @@ -12,8 +12,10 @@
10262 #ifndef __UNICORE_CACHE_H__
10263 #define __UNICORE_CACHE_H__
10264
10265 -#define L1_CACHE_SHIFT (5)
10266 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10267 +#include <linux/const.h>
10268 +
10269 +#define L1_CACHE_SHIFT 5
10270 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10271
10272 /*
10273 * Memory returned by kmalloc() may be used for DMA, so we must make
10274 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10275 index 6ef2a37..74ad6ad 100644
10276 --- a/arch/x86/Kconfig
10277 +++ b/arch/x86/Kconfig
10278 @@ -243,7 +243,7 @@ config X86_HT
10279
10280 config X86_32_LAZY_GS
10281 def_bool y
10282 - depends on X86_32 && !CC_STACKPROTECTOR
10283 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10284
10285 config ARCH_HWEIGHT_CFLAGS
10286 string
10287 @@ -1076,6 +1076,7 @@ config MICROCODE_EARLY
10288
10289 config X86_MSR
10290 tristate "/dev/cpu/*/msr - Model-specific register support"
10291 + depends on !GRKERNSEC_KMEM
10292 ---help---
10293 This device gives privileged processes access to the x86
10294 Model-Specific Registers (MSRs). It is a character device with
10295 @@ -1099,7 +1100,7 @@ choice
10296
10297 config NOHIGHMEM
10298 bool "off"
10299 - depends on !X86_NUMAQ
10300 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10301 ---help---
10302 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10303 However, the address space of 32-bit x86 processors is only 4
10304 @@ -1136,7 +1137,7 @@ config NOHIGHMEM
10305
10306 config HIGHMEM4G
10307 bool "4GB"
10308 - depends on !X86_NUMAQ
10309 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10310 ---help---
10311 Select this if you have a 32-bit processor and between 1 and 4
10312 gigabytes of physical RAM.
10313 @@ -1189,7 +1190,7 @@ config PAGE_OFFSET
10314 hex
10315 default 0xB0000000 if VMSPLIT_3G_OPT
10316 default 0x80000000 if VMSPLIT_2G
10317 - default 0x78000000 if VMSPLIT_2G_OPT
10318 + default 0x70000000 if VMSPLIT_2G_OPT
10319 default 0x40000000 if VMSPLIT_1G
10320 default 0xC0000000
10321 depends on X86_32
10322 @@ -1587,6 +1588,7 @@ config SECCOMP
10323
10324 config CC_STACKPROTECTOR
10325 bool "Enable -fstack-protector buffer overflow detection"
10326 + depends on X86_64 || !PAX_MEMORY_UDEREF
10327 ---help---
10328 This option turns on the -fstack-protector GCC feature. This
10329 feature puts, at the beginning of functions, a canary value on
10330 @@ -1706,6 +1708,8 @@ config X86_NEED_RELOCS
10331 config PHYSICAL_ALIGN
10332 hex "Alignment value to which kernel should be aligned" if X86_32
10333 default "0x1000000"
10334 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10335 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10336 range 0x2000 0x1000000
10337 ---help---
10338 This value puts the alignment restrictions on physical address
10339 @@ -1781,9 +1785,10 @@ config DEBUG_HOTPLUG_CPU0
10340 If unsure, say N.
10341
10342 config COMPAT_VDSO
10343 - def_bool y
10344 + def_bool n
10345 prompt "Compat VDSO support"
10346 depends on X86_32 || IA32_EMULATION
10347 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10348 ---help---
10349 Map the 32-bit VDSO to the predictable old-style address too.
10350
10351 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10352 index c026cca..14657ae 100644
10353 --- a/arch/x86/Kconfig.cpu
10354 +++ b/arch/x86/Kconfig.cpu
10355 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10356
10357 config X86_F00F_BUG
10358 def_bool y
10359 - depends on M586MMX || M586TSC || M586 || M486
10360 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10361
10362 config X86_INVD_BUG
10363 def_bool y
10364 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10365
10366 config X86_ALIGNMENT_16
10367 def_bool y
10368 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10369 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10370
10371 config X86_INTEL_USERCOPY
10372 def_bool y
10373 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10374 # generates cmov.
10375 config X86_CMOV
10376 def_bool y
10377 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10378 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10379
10380 config X86_MINIMUM_CPU_FAMILY
10381 int
10382 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10383 index b322f12..652d0d9 100644
10384 --- a/arch/x86/Kconfig.debug
10385 +++ b/arch/x86/Kconfig.debug
10386 @@ -84,7 +84,7 @@ config X86_PTDUMP
10387 config DEBUG_RODATA
10388 bool "Write protect kernel read-only data structures"
10389 default y
10390 - depends on DEBUG_KERNEL
10391 + depends on DEBUG_KERNEL && BROKEN
10392 ---help---
10393 Mark the kernel read-only data as write-protected in the pagetables,
10394 in order to catch accidental (and incorrect) writes to such const
10395 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10396
10397 config DEBUG_SET_MODULE_RONX
10398 bool "Set loadable kernel module data as NX and text as RO"
10399 - depends on MODULES
10400 + depends on MODULES && BROKEN
10401 ---help---
10402 This option helps catch unintended modifications to loadable
10403 kernel module's text and read-only data. It also prevents execution
10404 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10405
10406 config DEBUG_STRICT_USER_COPY_CHECKS
10407 bool "Strict copy size checks"
10408 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10409 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10410 ---help---
10411 Enabling this option turns a certain set of sanity checks for user
10412 copy operations into compile time failures.
10413 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10414 index 5c47726..8c4fa67 100644
10415 --- a/arch/x86/Makefile
10416 +++ b/arch/x86/Makefile
10417 @@ -54,6 +54,7 @@ else
10418 UTS_MACHINE := x86_64
10419 CHECKFLAGS += -D__x86_64__ -m64
10420
10421 + biarch := $(call cc-option,-m64)
10422 KBUILD_AFLAGS += -m64
10423 KBUILD_CFLAGS += -m64
10424
10425 @@ -234,3 +235,12 @@ define archhelp
10426 echo ' FDARGS="..." arguments for the booted kernel'
10427 echo ' FDINITRD=file initrd for the booted kernel'
10428 endef
10429 +
10430 +define OLD_LD
10431 +
10432 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10433 +*** Please upgrade your binutils to 2.18 or newer
10434 +endef
10435 +
10436 +archprepare:
10437 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10438 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10439 index 379814b..add62ce 100644
10440 --- a/arch/x86/boot/Makefile
10441 +++ b/arch/x86/boot/Makefile
10442 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10443 $(call cc-option, -fno-stack-protector) \
10444 $(call cc-option, -mpreferred-stack-boundary=2)
10445 KBUILD_CFLAGS += $(call cc-option, -m32)
10446 +ifdef CONSTIFY_PLUGIN
10447 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10448 +endif
10449 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10450 GCOV_PROFILE := n
10451
10452 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10453 index 878e4b9..20537ab 100644
10454 --- a/arch/x86/boot/bitops.h
10455 +++ b/arch/x86/boot/bitops.h
10456 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10457 u8 v;
10458 const u32 *p = (const u32 *)addr;
10459
10460 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10461 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10462 return v;
10463 }
10464
10465 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10466
10467 static inline void set_bit(int nr, void *addr)
10468 {
10469 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10470 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10471 }
10472
10473 #endif /* BOOT_BITOPS_H */
10474 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10475 index 5b75319..331a4ca 100644
10476 --- a/arch/x86/boot/boot.h
10477 +++ b/arch/x86/boot/boot.h
10478 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10479 static inline u16 ds(void)
10480 {
10481 u16 seg;
10482 - asm("movw %%ds,%0" : "=rm" (seg));
10483 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10484 return seg;
10485 }
10486
10487 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10488 static inline int memcmp(const void *s1, const void *s2, size_t len)
10489 {
10490 u8 diff;
10491 - asm("repe; cmpsb; setnz %0"
10492 + asm volatile("repe; cmpsb; setnz %0"
10493 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10494 return diff;
10495 }
10496 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10497 index 5ef205c..342191d 100644
10498 --- a/arch/x86/boot/compressed/Makefile
10499 +++ b/arch/x86/boot/compressed/Makefile
10500 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10501 KBUILD_CFLAGS += $(cflags-y)
10502 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10503 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10504 +ifdef CONSTIFY_PLUGIN
10505 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10506 +endif
10507
10508 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10509 GCOV_PROFILE := n
10510 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10511 index c205035..5853587 100644
10512 --- a/arch/x86/boot/compressed/eboot.c
10513 +++ b/arch/x86/boot/compressed/eboot.c
10514 @@ -150,7 +150,6 @@ again:
10515 *addr = max_addr;
10516 }
10517
10518 -free_pool:
10519 efi_call_phys1(sys_table->boottime->free_pool, map);
10520
10521 fail:
10522 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10523 if (i == map_size / desc_size)
10524 status = EFI_NOT_FOUND;
10525
10526 -free_pool:
10527 efi_call_phys1(sys_table->boottime->free_pool, map);
10528 fail:
10529 return status;
10530 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
10531 index a53440e..c3dbf1e 100644
10532 --- a/arch/x86/boot/compressed/efi_stub_32.S
10533 +++ b/arch/x86/boot/compressed/efi_stub_32.S
10534 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
10535 * parameter 2, ..., param n. To make things easy, we save the return
10536 * address of efi_call_phys in a global variable.
10537 */
10538 - popl %ecx
10539 - movl %ecx, saved_return_addr(%edx)
10540 - /* get the function pointer into ECX*/
10541 - popl %ecx
10542 - movl %ecx, efi_rt_function_ptr(%edx)
10543 + popl saved_return_addr(%edx)
10544 + popl efi_rt_function_ptr(%edx)
10545
10546 /*
10547 * 3. Call the physical function.
10548 */
10549 - call *%ecx
10550 + call *efi_rt_function_ptr(%edx)
10551
10552 /*
10553 * 4. Balance the stack. And because EAX contain the return value,
10554 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
10555 1: popl %edx
10556 subl $1b, %edx
10557
10558 - movl efi_rt_function_ptr(%edx), %ecx
10559 - pushl %ecx
10560 + pushl efi_rt_function_ptr(%edx)
10561
10562 /*
10563 * 10. Push the saved return address onto the stack and return.
10564 */
10565 - movl saved_return_addr(%edx), %ecx
10566 - pushl %ecx
10567 - ret
10568 + jmpl *saved_return_addr(%edx)
10569 ENDPROC(efi_call_phys)
10570 .previous
10571
10572 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10573 index 1e3184f..0d11e2e 100644
10574 --- a/arch/x86/boot/compressed/head_32.S
10575 +++ b/arch/x86/boot/compressed/head_32.S
10576 @@ -118,7 +118,7 @@ preferred_addr:
10577 notl %eax
10578 andl %eax, %ebx
10579 #else
10580 - movl $LOAD_PHYSICAL_ADDR, %ebx
10581 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10582 #endif
10583
10584 /* Target address to relocate to for decompression */
10585 @@ -204,7 +204,7 @@ relocated:
10586 * and where it was actually loaded.
10587 */
10588 movl %ebp, %ebx
10589 - subl $LOAD_PHYSICAL_ADDR, %ebx
10590 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10591 jz 2f /* Nothing to be done if loaded at compiled addr. */
10592 /*
10593 * Process relocations.
10594 @@ -212,8 +212,7 @@ relocated:
10595
10596 1: subl $4, %edi
10597 movl (%edi), %ecx
10598 - testl %ecx, %ecx
10599 - jz 2f
10600 + jecxz 2f
10601 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10602 jmp 1b
10603 2:
10604 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10605 index c1d383d..57ab51c 100644
10606 --- a/arch/x86/boot/compressed/head_64.S
10607 +++ b/arch/x86/boot/compressed/head_64.S
10608 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10609 notl %eax
10610 andl %eax, %ebx
10611 #else
10612 - movl $LOAD_PHYSICAL_ADDR, %ebx
10613 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10614 #endif
10615
10616 /* Target address to relocate to for decompression */
10617 @@ -272,7 +272,7 @@ preferred_addr:
10618 notq %rax
10619 andq %rax, %rbp
10620 #else
10621 - movq $LOAD_PHYSICAL_ADDR, %rbp
10622 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10623 #endif
10624
10625 /* Target address to relocate to for decompression */
10626 @@ -363,8 +363,8 @@ gdt:
10627 .long gdt
10628 .word 0
10629 .quad 0x0000000000000000 /* NULL descriptor */
10630 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10631 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10632 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10633 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10634 .quad 0x0080890000000000 /* TS descriptor */
10635 .quad 0x0000000000000000 /* TS continued */
10636 gdt_end:
10637 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10638 index 7cb56c6..d382d84 100644
10639 --- a/arch/x86/boot/compressed/misc.c
10640 +++ b/arch/x86/boot/compressed/misc.c
10641 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10642 case PT_LOAD:
10643 #ifdef CONFIG_RELOCATABLE
10644 dest = output;
10645 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10646 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10647 #else
10648 dest = (void *)(phdr->p_paddr);
10649 #endif
10650 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10651 error("Destination address too large");
10652 #endif
10653 #ifndef CONFIG_RELOCATABLE
10654 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10655 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10656 error("Wrong destination address");
10657 #endif
10658
10659 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10660 index 4d3ff03..e4972ff 100644
10661 --- a/arch/x86/boot/cpucheck.c
10662 +++ b/arch/x86/boot/cpucheck.c
10663 @@ -74,7 +74,7 @@ static int has_fpu(void)
10664 u16 fcw = -1, fsw = -1;
10665 u32 cr0;
10666
10667 - asm("movl %%cr0,%0" : "=r" (cr0));
10668 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10669 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10670 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10671 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10672 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10673 {
10674 u32 f0, f1;
10675
10676 - asm("pushfl ; "
10677 + asm volatile("pushfl ; "
10678 "pushfl ; "
10679 "popl %0 ; "
10680 "movl %0,%1 ; "
10681 @@ -115,7 +115,7 @@ static void get_flags(void)
10682 set_bit(X86_FEATURE_FPU, cpu.flags);
10683
10684 if (has_eflag(X86_EFLAGS_ID)) {
10685 - asm("cpuid"
10686 + asm volatile("cpuid"
10687 : "=a" (max_intel_level),
10688 "=b" (cpu_vendor[0]),
10689 "=d" (cpu_vendor[1]),
10690 @@ -124,7 +124,7 @@ static void get_flags(void)
10691
10692 if (max_intel_level >= 0x00000001 &&
10693 max_intel_level <= 0x0000ffff) {
10694 - asm("cpuid"
10695 + asm volatile("cpuid"
10696 : "=a" (tfms),
10697 "=c" (cpu.flags[4]),
10698 "=d" (cpu.flags[0])
10699 @@ -136,7 +136,7 @@ static void get_flags(void)
10700 cpu.model += ((tfms >> 16) & 0xf) << 4;
10701 }
10702
10703 - asm("cpuid"
10704 + asm volatile("cpuid"
10705 : "=a" (max_amd_level)
10706 : "a" (0x80000000)
10707 : "ebx", "ecx", "edx");
10708 @@ -144,7 +144,7 @@ static void get_flags(void)
10709 if (max_amd_level >= 0x80000001 &&
10710 max_amd_level <= 0x8000ffff) {
10711 u32 eax = 0x80000001;
10712 - asm("cpuid"
10713 + asm volatile("cpuid"
10714 : "+a" (eax),
10715 "=c" (cpu.flags[6]),
10716 "=d" (cpu.flags[1])
10717 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10718 u32 ecx = MSR_K7_HWCR;
10719 u32 eax, edx;
10720
10721 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10722 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10723 eax &= ~(1 << 15);
10724 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10725 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10726
10727 get_flags(); /* Make sure it really did something */
10728 err = check_flags();
10729 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10730 u32 ecx = MSR_VIA_FCR;
10731 u32 eax, edx;
10732
10733 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10734 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10735 eax |= (1<<1)|(1<<7);
10736 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10737 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10738
10739 set_bit(X86_FEATURE_CX8, cpu.flags);
10740 err = check_flags();
10741 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10742 u32 eax, edx;
10743 u32 level = 1;
10744
10745 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10746 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10747 - asm("cpuid"
10748 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10749 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10750 + asm volatile("cpuid"
10751 : "+a" (level), "=d" (cpu.flags[0])
10752 : : "ecx", "ebx");
10753 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10754 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10755
10756 err = check_flags();
10757 }
10758 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10759 index 9ec06a1..2c25e79 100644
10760 --- a/arch/x86/boot/header.S
10761 +++ b/arch/x86/boot/header.S
10762 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10763 # single linked list of
10764 # struct setup_data
10765
10766 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10767 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10768
10769 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10770 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10771 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10772 +#else
10773 #define VO_INIT_SIZE (VO__end - VO__text)
10774 +#endif
10775 #if ZO_INIT_SIZE > VO_INIT_SIZE
10776 #define INIT_SIZE ZO_INIT_SIZE
10777 #else
10778 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10779 index db75d07..8e6d0af 100644
10780 --- a/arch/x86/boot/memory.c
10781 +++ b/arch/x86/boot/memory.c
10782 @@ -19,7 +19,7 @@
10783
10784 static int detect_memory_e820(void)
10785 {
10786 - int count = 0;
10787 + unsigned int count = 0;
10788 struct biosregs ireg, oreg;
10789 struct e820entry *desc = boot_params.e820_map;
10790 static struct e820entry buf; /* static so it is zeroed */
10791 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10792 index 11e8c6e..fdbb1ed 100644
10793 --- a/arch/x86/boot/video-vesa.c
10794 +++ b/arch/x86/boot/video-vesa.c
10795 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10796
10797 boot_params.screen_info.vesapm_seg = oreg.es;
10798 boot_params.screen_info.vesapm_off = oreg.di;
10799 + boot_params.screen_info.vesapm_size = oreg.cx;
10800 }
10801
10802 /*
10803 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10804 index 43eda28..5ab5fdb 100644
10805 --- a/arch/x86/boot/video.c
10806 +++ b/arch/x86/boot/video.c
10807 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10808 static unsigned int get_entry(void)
10809 {
10810 char entry_buf[4];
10811 - int i, len = 0;
10812 + unsigned int i, len = 0;
10813 int key;
10814 unsigned int v;
10815
10816 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10817 index 9105655..5e37f27 100644
10818 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10819 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10820 @@ -8,6 +8,8 @@
10821 * including this sentence is retained in full.
10822 */
10823
10824 +#include <asm/alternative-asm.h>
10825 +
10826 .extern crypto_ft_tab
10827 .extern crypto_it_tab
10828 .extern crypto_fl_tab
10829 @@ -70,6 +72,8 @@
10830 je B192; \
10831 leaq 32(r9),r9;
10832
10833 +#define ret pax_force_retaddr 0, 1; ret
10834 +
10835 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10836 movq r1,r2; \
10837 movq r3,r4; \
10838 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10839 index 04b7977..402f223 100644
10840 --- a/arch/x86/crypto/aesni-intel_asm.S
10841 +++ b/arch/x86/crypto/aesni-intel_asm.S
10842 @@ -31,6 +31,7 @@
10843
10844 #include <linux/linkage.h>
10845 #include <asm/inst.h>
10846 +#include <asm/alternative-asm.h>
10847
10848 #ifdef __x86_64__
10849 .data
10850 @@ -1435,6 +1436,7 @@ _return_T_done_decrypt:
10851 pop %r14
10852 pop %r13
10853 pop %r12
10854 + pax_force_retaddr 0, 1
10855 ret
10856 ENDPROC(aesni_gcm_dec)
10857
10858 @@ -1699,6 +1701,7 @@ _return_T_done_encrypt:
10859 pop %r14
10860 pop %r13
10861 pop %r12
10862 + pax_force_retaddr 0, 1
10863 ret
10864 ENDPROC(aesni_gcm_enc)
10865
10866 @@ -1716,6 +1719,7 @@ _key_expansion_256a:
10867 pxor %xmm1, %xmm0
10868 movaps %xmm0, (TKEYP)
10869 add $0x10, TKEYP
10870 + pax_force_retaddr_bts
10871 ret
10872 ENDPROC(_key_expansion_128)
10873 ENDPROC(_key_expansion_256a)
10874 @@ -1742,6 +1746,7 @@ _key_expansion_192a:
10875 shufps $0b01001110, %xmm2, %xmm1
10876 movaps %xmm1, 0x10(TKEYP)
10877 add $0x20, TKEYP
10878 + pax_force_retaddr_bts
10879 ret
10880 ENDPROC(_key_expansion_192a)
10881
10882 @@ -1762,6 +1767,7 @@ _key_expansion_192b:
10883
10884 movaps %xmm0, (TKEYP)
10885 add $0x10, TKEYP
10886 + pax_force_retaddr_bts
10887 ret
10888 ENDPROC(_key_expansion_192b)
10889
10890 @@ -1775,6 +1781,7 @@ _key_expansion_256b:
10891 pxor %xmm1, %xmm2
10892 movaps %xmm2, (TKEYP)
10893 add $0x10, TKEYP
10894 + pax_force_retaddr_bts
10895 ret
10896 ENDPROC(_key_expansion_256b)
10897
10898 @@ -1888,6 +1895,7 @@ ENTRY(aesni_set_key)
10899 #ifndef __x86_64__
10900 popl KEYP
10901 #endif
10902 + pax_force_retaddr 0, 1
10903 ret
10904 ENDPROC(aesni_set_key)
10905
10906 @@ -1910,6 +1918,7 @@ ENTRY(aesni_enc)
10907 popl KLEN
10908 popl KEYP
10909 #endif
10910 + pax_force_retaddr 0, 1
10911 ret
10912 ENDPROC(aesni_enc)
10913
10914 @@ -1968,6 +1977,7 @@ _aesni_enc1:
10915 AESENC KEY STATE
10916 movaps 0x70(TKEYP), KEY
10917 AESENCLAST KEY STATE
10918 + pax_force_retaddr_bts
10919 ret
10920 ENDPROC(_aesni_enc1)
10921
10922 @@ -2077,6 +2087,7 @@ _aesni_enc4:
10923 AESENCLAST KEY STATE2
10924 AESENCLAST KEY STATE3
10925 AESENCLAST KEY STATE4
10926 + pax_force_retaddr_bts
10927 ret
10928 ENDPROC(_aesni_enc4)
10929
10930 @@ -2100,6 +2111,7 @@ ENTRY(aesni_dec)
10931 popl KLEN
10932 popl KEYP
10933 #endif
10934 + pax_force_retaddr 0, 1
10935 ret
10936 ENDPROC(aesni_dec)
10937
10938 @@ -2158,6 +2170,7 @@ _aesni_dec1:
10939 AESDEC KEY STATE
10940 movaps 0x70(TKEYP), KEY
10941 AESDECLAST KEY STATE
10942 + pax_force_retaddr_bts
10943 ret
10944 ENDPROC(_aesni_dec1)
10945
10946 @@ -2267,6 +2280,7 @@ _aesni_dec4:
10947 AESDECLAST KEY STATE2
10948 AESDECLAST KEY STATE3
10949 AESDECLAST KEY STATE4
10950 + pax_force_retaddr_bts
10951 ret
10952 ENDPROC(_aesni_dec4)
10953
10954 @@ -2325,6 +2339,7 @@ ENTRY(aesni_ecb_enc)
10955 popl KEYP
10956 popl LEN
10957 #endif
10958 + pax_force_retaddr 0, 1
10959 ret
10960 ENDPROC(aesni_ecb_enc)
10961
10962 @@ -2384,6 +2399,7 @@ ENTRY(aesni_ecb_dec)
10963 popl KEYP
10964 popl LEN
10965 #endif
10966 + pax_force_retaddr 0, 1
10967 ret
10968 ENDPROC(aesni_ecb_dec)
10969
10970 @@ -2426,6 +2442,7 @@ ENTRY(aesni_cbc_enc)
10971 popl LEN
10972 popl IVP
10973 #endif
10974 + pax_force_retaddr 0, 1
10975 ret
10976 ENDPROC(aesni_cbc_enc)
10977
10978 @@ -2517,6 +2534,7 @@ ENTRY(aesni_cbc_dec)
10979 popl LEN
10980 popl IVP
10981 #endif
10982 + pax_force_retaddr 0, 1
10983 ret
10984 ENDPROC(aesni_cbc_dec)
10985
10986 @@ -2544,6 +2562,7 @@ _aesni_inc_init:
10987 mov $1, TCTR_LOW
10988 MOVQ_R64_XMM TCTR_LOW INC
10989 MOVQ_R64_XMM CTR TCTR_LOW
10990 + pax_force_retaddr_bts
10991 ret
10992 ENDPROC(_aesni_inc_init)
10993
10994 @@ -2573,6 +2592,7 @@ _aesni_inc:
10995 .Linc_low:
10996 movaps CTR, IV
10997 PSHUFB_XMM BSWAP_MASK IV
10998 + pax_force_retaddr_bts
10999 ret
11000 ENDPROC(_aesni_inc)
11001
11002 @@ -2634,6 +2654,7 @@ ENTRY(aesni_ctr_enc)
11003 .Lctr_enc_ret:
11004 movups IV, (IVP)
11005 .Lctr_enc_just_ret:
11006 + pax_force_retaddr 0, 1
11007 ret
11008 ENDPROC(aesni_ctr_enc)
11009 #endif
11010 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11011 index 246c670..4d1ed00 100644
11012 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11013 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11014 @@ -21,6 +21,7 @@
11015 */
11016
11017 #include <linux/linkage.h>
11018 +#include <asm/alternative-asm.h>
11019
11020 .file "blowfish-x86_64-asm.S"
11021 .text
11022 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
11023 jnz .L__enc_xor;
11024
11025 write_block();
11026 + pax_force_retaddr 0, 1
11027 ret;
11028 .L__enc_xor:
11029 xor_block();
11030 + pax_force_retaddr 0, 1
11031 ret;
11032 ENDPROC(__blowfish_enc_blk)
11033
11034 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
11035
11036 movq %r11, %rbp;
11037
11038 + pax_force_retaddr 0, 1
11039 ret;
11040 ENDPROC(blowfish_dec_blk)
11041
11042 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
11043
11044 popq %rbx;
11045 popq %rbp;
11046 + pax_force_retaddr 0, 1
11047 ret;
11048
11049 .L__enc_xor4:
11050 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
11051
11052 popq %rbx;
11053 popq %rbp;
11054 + pax_force_retaddr 0, 1
11055 ret;
11056 ENDPROC(__blowfish_enc_blk_4way)
11057
11058 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
11059 popq %rbx;
11060 popq %rbp;
11061
11062 + pax_force_retaddr 0, 1
11063 ret;
11064 ENDPROC(blowfish_dec_blk_4way)
11065 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11066 index 310319c..ce174a4 100644
11067 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11068 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11069 @@ -21,6 +21,7 @@
11070 */
11071
11072 #include <linux/linkage.h>
11073 +#include <asm/alternative-asm.h>
11074
11075 .file "camellia-x86_64-asm_64.S"
11076 .text
11077 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11078 enc_outunpack(mov, RT1);
11079
11080 movq RRBP, %rbp;
11081 + pax_force_retaddr 0, 1
11082 ret;
11083
11084 .L__enc_xor:
11085 enc_outunpack(xor, RT1);
11086
11087 movq RRBP, %rbp;
11088 + pax_force_retaddr 0, 1
11089 ret;
11090 ENDPROC(__camellia_enc_blk)
11091
11092 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11093 dec_outunpack();
11094
11095 movq RRBP, %rbp;
11096 + pax_force_retaddr 0, 1
11097 ret;
11098 ENDPROC(camellia_dec_blk)
11099
11100 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11101
11102 movq RRBP, %rbp;
11103 popq %rbx;
11104 + pax_force_retaddr 0, 1
11105 ret;
11106
11107 .L__enc2_xor:
11108 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11109
11110 movq RRBP, %rbp;
11111 popq %rbx;
11112 + pax_force_retaddr 0, 1
11113 ret;
11114 ENDPROC(__camellia_enc_blk_2way)
11115
11116 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11117
11118 movq RRBP, %rbp;
11119 movq RXOR, %rbx;
11120 + pax_force_retaddr 0, 1
11121 ret;
11122 ENDPROC(camellia_dec_blk_2way)
11123 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11124 index c35fd5d..c1ee236 100644
11125 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11126 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11127 @@ -24,6 +24,7 @@
11128 */
11129
11130 #include <linux/linkage.h>
11131 +#include <asm/alternative-asm.h>
11132
11133 .file "cast5-avx-x86_64-asm_64.S"
11134
11135 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11136 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11137 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11138
11139 + pax_force_retaddr 0, 1
11140 ret;
11141 ENDPROC(__cast5_enc_blk16)
11142
11143 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11144 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11145 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11146
11147 + pax_force_retaddr 0, 1
11148 ret;
11149
11150 .L__skip_dec:
11151 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11152 vmovdqu RR4, (6*4*4)(%r11);
11153 vmovdqu RL4, (7*4*4)(%r11);
11154
11155 + pax_force_retaddr
11156 ret;
11157 ENDPROC(cast5_ecb_enc_16way)
11158
11159 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11160 vmovdqu RR4, (6*4*4)(%r11);
11161 vmovdqu RL4, (7*4*4)(%r11);
11162
11163 + pax_force_retaddr
11164 ret;
11165 ENDPROC(cast5_ecb_dec_16way)
11166
11167 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11168
11169 popq %r12;
11170
11171 + pax_force_retaddr
11172 ret;
11173 ENDPROC(cast5_cbc_dec_16way)
11174
11175 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11176
11177 popq %r12;
11178
11179 + pax_force_retaddr
11180 ret;
11181 ENDPROC(cast5_ctr_16way)
11182 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11183 index f93b610..c09bf40 100644
11184 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11185 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11186 @@ -24,6 +24,7 @@
11187 */
11188
11189 #include <linux/linkage.h>
11190 +#include <asm/alternative-asm.h>
11191 #include "glue_helper-asm-avx.S"
11192
11193 .file "cast6-avx-x86_64-asm_64.S"
11194 @@ -293,6 +294,7 @@ __cast6_enc_blk8:
11195 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11196 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11197
11198 + pax_force_retaddr 0, 1
11199 ret;
11200 ENDPROC(__cast6_enc_blk8)
11201
11202 @@ -338,6 +340,7 @@ __cast6_dec_blk8:
11203 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11204 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11205
11206 + pax_force_retaddr 0, 1
11207 ret;
11208 ENDPROC(__cast6_dec_blk8)
11209
11210 @@ -356,6 +359,7 @@ ENTRY(cast6_ecb_enc_8way)
11211
11212 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11213
11214 + pax_force_retaddr
11215 ret;
11216 ENDPROC(cast6_ecb_enc_8way)
11217
11218 @@ -374,6 +378,7 @@ ENTRY(cast6_ecb_dec_8way)
11219
11220 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11221
11222 + pax_force_retaddr
11223 ret;
11224 ENDPROC(cast6_ecb_dec_8way)
11225
11226 @@ -397,6 +402,7 @@ ENTRY(cast6_cbc_dec_8way)
11227
11228 popq %r12;
11229
11230 + pax_force_retaddr
11231 ret;
11232 ENDPROC(cast6_cbc_dec_8way)
11233
11234 @@ -422,5 +428,6 @@ ENTRY(cast6_ctr_8way)
11235
11236 popq %r12;
11237
11238 + pax_force_retaddr
11239 ret;
11240 ENDPROC(cast6_ctr_8way)
11241 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11242 index 9279e0b..9270820 100644
11243 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11244 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11245 @@ -1,4 +1,5 @@
11246 #include <linux/linkage.h>
11247 +#include <asm/alternative-asm.h>
11248
11249 # enter salsa20_encrypt_bytes
11250 ENTRY(salsa20_encrypt_bytes)
11251 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11252 add %r11,%rsp
11253 mov %rdi,%rax
11254 mov %rsi,%rdx
11255 + pax_force_retaddr 0, 1
11256 ret
11257 # bytesatleast65:
11258 ._bytesatleast65:
11259 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11260 add %r11,%rsp
11261 mov %rdi,%rax
11262 mov %rsi,%rdx
11263 + pax_force_retaddr
11264 ret
11265 ENDPROC(salsa20_keysetup)
11266
11267 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11268 add %r11,%rsp
11269 mov %rdi,%rax
11270 mov %rsi,%rdx
11271 + pax_force_retaddr
11272 ret
11273 ENDPROC(salsa20_ivsetup)
11274 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11275 index 43c9386..a0e2d60 100644
11276 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11277 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11278 @@ -25,6 +25,7 @@
11279 */
11280
11281 #include <linux/linkage.h>
11282 +#include <asm/alternative-asm.h>
11283 #include "glue_helper-asm-avx.S"
11284
11285 .file "serpent-avx-x86_64-asm_64.S"
11286 @@ -617,6 +618,7 @@ __serpent_enc_blk8_avx:
11287 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11288 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11289
11290 + pax_force_retaddr
11291 ret;
11292 ENDPROC(__serpent_enc_blk8_avx)
11293
11294 @@ -671,6 +673,7 @@ __serpent_dec_blk8_avx:
11295 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11296 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11297
11298 + pax_force_retaddr
11299 ret;
11300 ENDPROC(__serpent_dec_blk8_avx)
11301
11302 @@ -687,6 +690,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11303
11304 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11305
11306 + pax_force_retaddr
11307 ret;
11308 ENDPROC(serpent_ecb_enc_8way_avx)
11309
11310 @@ -703,6 +707,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11311
11312 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11313
11314 + pax_force_retaddr
11315 ret;
11316 ENDPROC(serpent_ecb_dec_8way_avx)
11317
11318 @@ -719,6 +724,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11319
11320 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11321
11322 + pax_force_retaddr
11323 ret;
11324 ENDPROC(serpent_cbc_dec_8way_avx)
11325
11326 @@ -737,5 +743,6 @@ ENTRY(serpent_ctr_8way_avx)
11327
11328 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11329
11330 + pax_force_retaddr
11331 ret;
11332 ENDPROC(serpent_ctr_8way_avx)
11333 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11334 index acc066c..1559cc4 100644
11335 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11336 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11337 @@ -25,6 +25,7 @@
11338 */
11339
11340 #include <linux/linkage.h>
11341 +#include <asm/alternative-asm.h>
11342
11343 .file "serpent-sse2-x86_64-asm_64.S"
11344 .text
11345 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11346 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11347 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11348
11349 + pax_force_retaddr
11350 ret;
11351
11352 .L__enc_xor8:
11353 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11354 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11355
11356 + pax_force_retaddr
11357 ret;
11358 ENDPROC(__serpent_enc_blk_8way)
11359
11360 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11361 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11362 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11363
11364 + pax_force_retaddr
11365 ret;
11366 ENDPROC(serpent_dec_blk_8way)
11367 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11368 index a410950..3356d42 100644
11369 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11370 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11371 @@ -29,6 +29,7 @@
11372 */
11373
11374 #include <linux/linkage.h>
11375 +#include <asm/alternative-asm.h>
11376
11377 #define CTX %rdi // arg1
11378 #define BUF %rsi // arg2
11379 @@ -104,6 +105,7 @@
11380 pop %r12
11381 pop %rbp
11382 pop %rbx
11383 + pax_force_retaddr 0, 1
11384 ret
11385
11386 ENDPROC(\name)
11387 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11388 index 8d3e113..898b161 100644
11389 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11390 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11391 @@ -24,6 +24,7 @@
11392 */
11393
11394 #include <linux/linkage.h>
11395 +#include <asm/alternative-asm.h>
11396 #include "glue_helper-asm-avx.S"
11397
11398 .file "twofish-avx-x86_64-asm_64.S"
11399 @@ -282,6 +283,7 @@ __twofish_enc_blk8:
11400 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11401 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11402
11403 + pax_force_retaddr 0, 1
11404 ret;
11405 ENDPROC(__twofish_enc_blk8)
11406
11407 @@ -322,6 +324,7 @@ __twofish_dec_blk8:
11408 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11409 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11410
11411 + pax_force_retaddr 0, 1
11412 ret;
11413 ENDPROC(__twofish_dec_blk8)
11414
11415 @@ -340,6 +343,7 @@ ENTRY(twofish_ecb_enc_8way)
11416
11417 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11418
11419 + pax_force_retaddr 0, 1
11420 ret;
11421 ENDPROC(twofish_ecb_enc_8way)
11422
11423 @@ -358,6 +362,7 @@ ENTRY(twofish_ecb_dec_8way)
11424
11425 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11426
11427 + pax_force_retaddr 0, 1
11428 ret;
11429 ENDPROC(twofish_ecb_dec_8way)
11430
11431 @@ -381,6 +386,7 @@ ENTRY(twofish_cbc_dec_8way)
11432
11433 popq %r12;
11434
11435 + pax_force_retaddr 0, 1
11436 ret;
11437 ENDPROC(twofish_cbc_dec_8way)
11438
11439 @@ -406,5 +412,6 @@ ENTRY(twofish_ctr_8way)
11440
11441 popq %r12;
11442
11443 + pax_force_retaddr 0, 1
11444 ret;
11445 ENDPROC(twofish_ctr_8way)
11446 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11447 index 1c3b7ce..b365c5e 100644
11448 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11449 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11450 @@ -21,6 +21,7 @@
11451 */
11452
11453 #include <linux/linkage.h>
11454 +#include <asm/alternative-asm.h>
11455
11456 .file "twofish-x86_64-asm-3way.S"
11457 .text
11458 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11459 popq %r13;
11460 popq %r14;
11461 popq %r15;
11462 + pax_force_retaddr 0, 1
11463 ret;
11464
11465 .L__enc_xor3:
11466 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11467 popq %r13;
11468 popq %r14;
11469 popq %r15;
11470 + pax_force_retaddr 0, 1
11471 ret;
11472 ENDPROC(__twofish_enc_blk_3way)
11473
11474 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11475 popq %r13;
11476 popq %r14;
11477 popq %r15;
11478 + pax_force_retaddr 0, 1
11479 ret;
11480 ENDPROC(twofish_dec_blk_3way)
11481 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11482 index a039d21..29e7615 100644
11483 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11484 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11485 @@ -22,6 +22,7 @@
11486
11487 #include <linux/linkage.h>
11488 #include <asm/asm-offsets.h>
11489 +#include <asm/alternative-asm.h>
11490
11491 #define a_offset 0
11492 #define b_offset 4
11493 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11494
11495 popq R1
11496 movq $1,%rax
11497 + pax_force_retaddr 0, 1
11498 ret
11499 ENDPROC(twofish_enc_blk)
11500
11501 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11502
11503 popq R1
11504 movq $1,%rax
11505 + pax_force_retaddr 0, 1
11506 ret
11507 ENDPROC(twofish_dec_blk)
11508 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11509 index 03abf9b..a42ba29 100644
11510 --- a/arch/x86/ia32/ia32_aout.c
11511 +++ b/arch/x86/ia32/ia32_aout.c
11512 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11513 unsigned long dump_start, dump_size;
11514 struct user32 dump;
11515
11516 + memset(&dump, 0, sizeof(dump));
11517 +
11518 fs = get_fs();
11519 set_fs(KERNEL_DS);
11520 has_dumped = 1;
11521 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11522 index cf1a471..3bc4cf8 100644
11523 --- a/arch/x86/ia32/ia32_signal.c
11524 +++ b/arch/x86/ia32/ia32_signal.c
11525 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11526 sp -= frame_size;
11527 /* Align the stack pointer according to the i386 ABI,
11528 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11529 - sp = ((sp + 4) & -16ul) - 4;
11530 + sp = ((sp - 12) & -16ul) - 4;
11531 return (void __user *) sp;
11532 }
11533
11534 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11535 * These are actually not used anymore, but left because some
11536 * gdb versions depend on them as a marker.
11537 */
11538 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11539 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11540 } put_user_catch(err);
11541
11542 if (err)
11543 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11544 0xb8,
11545 __NR_ia32_rt_sigreturn,
11546 0x80cd,
11547 - 0,
11548 + 0
11549 };
11550
11551 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11552 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11553
11554 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11555 restorer = ksig->ka.sa.sa_restorer;
11556 + else if (current->mm->context.vdso)
11557 + /* Return stub is in 32bit vsyscall page */
11558 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11559 else
11560 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11561 - rt_sigreturn);
11562 + restorer = &frame->retcode;
11563 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11564
11565 /*
11566 * Not actually used anymore, but left because some gdb
11567 * versions need it.
11568 */
11569 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11570 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11571 } put_user_catch(err);
11572
11573 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11574 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11575 index 474dc1b..be7bff5 100644
11576 --- a/arch/x86/ia32/ia32entry.S
11577 +++ b/arch/x86/ia32/ia32entry.S
11578 @@ -15,8 +15,10 @@
11579 #include <asm/irqflags.h>
11580 #include <asm/asm.h>
11581 #include <asm/smap.h>
11582 +#include <asm/pgtable.h>
11583 #include <linux/linkage.h>
11584 #include <linux/err.h>
11585 +#include <asm/alternative-asm.h>
11586
11587 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11588 #include <linux/elf-em.h>
11589 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11590 ENDPROC(native_irq_enable_sysexit)
11591 #endif
11592
11593 + .macro pax_enter_kernel_user
11594 + pax_set_fptr_mask
11595 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11596 + call pax_enter_kernel_user
11597 +#endif
11598 + .endm
11599 +
11600 + .macro pax_exit_kernel_user
11601 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11602 + call pax_exit_kernel_user
11603 +#endif
11604 +#ifdef CONFIG_PAX_RANDKSTACK
11605 + pushq %rax
11606 + pushq %r11
11607 + call pax_randomize_kstack
11608 + popq %r11
11609 + popq %rax
11610 +#endif
11611 + .endm
11612 +
11613 +.macro pax_erase_kstack
11614 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11615 + call pax_erase_kstack
11616 +#endif
11617 +.endm
11618 +
11619 /*
11620 * 32bit SYSENTER instruction entry.
11621 *
11622 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11623 CFI_REGISTER rsp,rbp
11624 SWAPGS_UNSAFE_STACK
11625 movq PER_CPU_VAR(kernel_stack), %rsp
11626 - addq $(KERNEL_STACK_OFFSET),%rsp
11627 - /*
11628 - * No need to follow this irqs on/off section: the syscall
11629 - * disabled irqs, here we enable it straight after entry:
11630 - */
11631 - ENABLE_INTERRUPTS(CLBR_NONE)
11632 movl %ebp,%ebp /* zero extension */
11633 pushq_cfi $__USER32_DS
11634 /*CFI_REL_OFFSET ss,0*/
11635 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11636 CFI_REL_OFFSET rsp,0
11637 pushfq_cfi
11638 /*CFI_REL_OFFSET rflags,0*/
11639 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11640 - CFI_REGISTER rip,r10
11641 + orl $X86_EFLAGS_IF,(%rsp)
11642 + GET_THREAD_INFO(%r11)
11643 + movl TI_sysenter_return(%r11), %r11d
11644 + CFI_REGISTER rip,r11
11645 pushq_cfi $__USER32_CS
11646 /*CFI_REL_OFFSET cs,0*/
11647 movl %eax, %eax
11648 - pushq_cfi %r10
11649 + pushq_cfi %r11
11650 CFI_REL_OFFSET rip,0
11651 pushq_cfi %rax
11652 cld
11653 SAVE_ARGS 0,1,0
11654 + pax_enter_kernel_user
11655 +
11656 +#ifdef CONFIG_PAX_RANDKSTACK
11657 + pax_erase_kstack
11658 +#endif
11659 +
11660 + /*
11661 + * No need to follow this irqs on/off section: the syscall
11662 + * disabled irqs, here we enable it straight after entry:
11663 + */
11664 + ENABLE_INTERRUPTS(CLBR_NONE)
11665 /* no need to do an access_ok check here because rbp has been
11666 32bit zero extended */
11667 +
11668 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11669 + mov pax_user_shadow_base,%r11
11670 + add %r11,%rbp
11671 +#endif
11672 +
11673 ASM_STAC
11674 1: movl (%rbp),%ebp
11675 _ASM_EXTABLE(1b,ia32_badarg)
11676 ASM_CLAC
11677 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11678 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11679 + GET_THREAD_INFO(%r11)
11680 + orl $TS_COMPAT,TI_status(%r11)
11681 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11682 CFI_REMEMBER_STATE
11683 jnz sysenter_tracesys
11684 cmpq $(IA32_NR_syscalls-1),%rax
11685 @@ -162,12 +204,15 @@ sysenter_do_call:
11686 sysenter_dispatch:
11687 call *ia32_sys_call_table(,%rax,8)
11688 movq %rax,RAX-ARGOFFSET(%rsp)
11689 + GET_THREAD_INFO(%r11)
11690 DISABLE_INTERRUPTS(CLBR_NONE)
11691 TRACE_IRQS_OFF
11692 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11693 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11694 jnz sysexit_audit
11695 sysexit_from_sys_call:
11696 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11697 + pax_exit_kernel_user
11698 + pax_erase_kstack
11699 + andl $~TS_COMPAT,TI_status(%r11)
11700 /* clear IF, that popfq doesn't enable interrupts early */
11701 andl $~0x200,EFLAGS-R11(%rsp)
11702 movl RIP-R11(%rsp),%edx /* User %eip */
11703 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11704 movl %eax,%esi /* 2nd arg: syscall number */
11705 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11706 call __audit_syscall_entry
11707 +
11708 + pax_erase_kstack
11709 +
11710 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11711 cmpq $(IA32_NR_syscalls-1),%rax
11712 ja ia32_badsys
11713 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11714 .endm
11715
11716 .macro auditsys_exit exit
11717 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11718 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11719 jnz ia32_ret_from_sys_call
11720 TRACE_IRQS_ON
11721 ENABLE_INTERRUPTS(CLBR_NONE)
11722 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11723 1: setbe %al /* 1 if error, 0 if not */
11724 movzbl %al,%edi /* zero-extend that into %edi */
11725 call __audit_syscall_exit
11726 + GET_THREAD_INFO(%r11)
11727 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11728 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11729 DISABLE_INTERRUPTS(CLBR_NONE)
11730 TRACE_IRQS_OFF
11731 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11732 + testl %edi,TI_flags(%r11)
11733 jz \exit
11734 CLEAR_RREGS -ARGOFFSET
11735 jmp int_with_check
11736 @@ -237,7 +286,7 @@ sysexit_audit:
11737
11738 sysenter_tracesys:
11739 #ifdef CONFIG_AUDITSYSCALL
11740 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11741 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11742 jz sysenter_auditsys
11743 #endif
11744 SAVE_REST
11745 @@ -249,6 +298,9 @@ sysenter_tracesys:
11746 RESTORE_REST
11747 cmpq $(IA32_NR_syscalls-1),%rax
11748 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11749 +
11750 + pax_erase_kstack
11751 +
11752 jmp sysenter_do_call
11753 CFI_ENDPROC
11754 ENDPROC(ia32_sysenter_target)
11755 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11756 ENTRY(ia32_cstar_target)
11757 CFI_STARTPROC32 simple
11758 CFI_SIGNAL_FRAME
11759 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11760 + CFI_DEF_CFA rsp,0
11761 CFI_REGISTER rip,rcx
11762 /*CFI_REGISTER rflags,r11*/
11763 SWAPGS_UNSAFE_STACK
11764 movl %esp,%r8d
11765 CFI_REGISTER rsp,r8
11766 movq PER_CPU_VAR(kernel_stack),%rsp
11767 + SAVE_ARGS 8*6,0,0
11768 + pax_enter_kernel_user
11769 +
11770 +#ifdef CONFIG_PAX_RANDKSTACK
11771 + pax_erase_kstack
11772 +#endif
11773 +
11774 /*
11775 * No need to follow this irqs on/off section: the syscall
11776 * disabled irqs and here we enable it straight after entry:
11777 */
11778 ENABLE_INTERRUPTS(CLBR_NONE)
11779 - SAVE_ARGS 8,0,0
11780 movl %eax,%eax /* zero extension */
11781 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11782 movq %rcx,RIP-ARGOFFSET(%rsp)
11783 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11784 /* no need to do an access_ok check here because r8 has been
11785 32bit zero extended */
11786 /* hardware stack frame is complete now */
11787 +
11788 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11789 + mov pax_user_shadow_base,%r11
11790 + add %r11,%r8
11791 +#endif
11792 +
11793 ASM_STAC
11794 1: movl (%r8),%r9d
11795 _ASM_EXTABLE(1b,ia32_badarg)
11796 ASM_CLAC
11797 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11798 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11799 + GET_THREAD_INFO(%r11)
11800 + orl $TS_COMPAT,TI_status(%r11)
11801 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11802 CFI_REMEMBER_STATE
11803 jnz cstar_tracesys
11804 cmpq $IA32_NR_syscalls-1,%rax
11805 @@ -319,12 +384,15 @@ cstar_do_call:
11806 cstar_dispatch:
11807 call *ia32_sys_call_table(,%rax,8)
11808 movq %rax,RAX-ARGOFFSET(%rsp)
11809 + GET_THREAD_INFO(%r11)
11810 DISABLE_INTERRUPTS(CLBR_NONE)
11811 TRACE_IRQS_OFF
11812 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11813 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11814 jnz sysretl_audit
11815 sysretl_from_sys_call:
11816 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11817 + pax_exit_kernel_user
11818 + pax_erase_kstack
11819 + andl $~TS_COMPAT,TI_status(%r11)
11820 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11821 movl RIP-ARGOFFSET(%rsp),%ecx
11822 CFI_REGISTER rip,rcx
11823 @@ -352,7 +420,7 @@ sysretl_audit:
11824
11825 cstar_tracesys:
11826 #ifdef CONFIG_AUDITSYSCALL
11827 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11828 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11829 jz cstar_auditsys
11830 #endif
11831 xchgl %r9d,%ebp
11832 @@ -366,6 +434,9 @@ cstar_tracesys:
11833 xchgl %ebp,%r9d
11834 cmpq $(IA32_NR_syscalls-1),%rax
11835 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11836 +
11837 + pax_erase_kstack
11838 +
11839 jmp cstar_do_call
11840 END(ia32_cstar_target)
11841
11842 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11843 CFI_REL_OFFSET rip,RIP-RIP
11844 PARAVIRT_ADJUST_EXCEPTION_FRAME
11845 SWAPGS
11846 - /*
11847 - * No need to follow this irqs on/off section: the syscall
11848 - * disabled irqs and here we enable it straight after entry:
11849 - */
11850 - ENABLE_INTERRUPTS(CLBR_NONE)
11851 movl %eax,%eax
11852 pushq_cfi %rax
11853 cld
11854 /* note the registers are not zero extended to the sf.
11855 this could be a problem. */
11856 SAVE_ARGS 0,1,0
11857 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11858 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11859 + pax_enter_kernel_user
11860 +
11861 +#ifdef CONFIG_PAX_RANDKSTACK
11862 + pax_erase_kstack
11863 +#endif
11864 +
11865 + /*
11866 + * No need to follow this irqs on/off section: the syscall
11867 + * disabled irqs and here we enable it straight after entry:
11868 + */
11869 + ENABLE_INTERRUPTS(CLBR_NONE)
11870 + GET_THREAD_INFO(%r11)
11871 + orl $TS_COMPAT,TI_status(%r11)
11872 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11873 jnz ia32_tracesys
11874 cmpq $(IA32_NR_syscalls-1),%rax
11875 ja ia32_badsys
11876 @@ -442,6 +520,9 @@ ia32_tracesys:
11877 RESTORE_REST
11878 cmpq $(IA32_NR_syscalls-1),%rax
11879 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11880 +
11881 + pax_erase_kstack
11882 +
11883 jmp ia32_do_call
11884 END(ia32_syscall)
11885
11886 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11887 index ad7a20c..1ffa3c1 100644
11888 --- a/arch/x86/ia32/sys_ia32.c
11889 +++ b/arch/x86/ia32/sys_ia32.c
11890 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11891 */
11892 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11893 {
11894 - typeof(ubuf->st_uid) uid = 0;
11895 - typeof(ubuf->st_gid) gid = 0;
11896 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11897 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11898 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11899 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11900 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11901 @@ -205,7 +205,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
11902 return -EFAULT;
11903
11904 set_fs(KERNEL_DS);
11905 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
11906 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
11907 count);
11908 set_fs(old_fs);
11909
11910 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11911 index 372231c..a5aa1a1 100644
11912 --- a/arch/x86/include/asm/alternative-asm.h
11913 +++ b/arch/x86/include/asm/alternative-asm.h
11914 @@ -18,6 +18,45 @@
11915 .endm
11916 #endif
11917
11918 +#ifdef KERNEXEC_PLUGIN
11919 + .macro pax_force_retaddr_bts rip=0
11920 + btsq $63,\rip(%rsp)
11921 + .endm
11922 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11923 + .macro pax_force_retaddr rip=0, reload=0
11924 + btsq $63,\rip(%rsp)
11925 + .endm
11926 + .macro pax_force_fptr ptr
11927 + btsq $63,\ptr
11928 + .endm
11929 + .macro pax_set_fptr_mask
11930 + .endm
11931 +#endif
11932 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11933 + .macro pax_force_retaddr rip=0, reload=0
11934 + .if \reload
11935 + pax_set_fptr_mask
11936 + .endif
11937 + orq %r10,\rip(%rsp)
11938 + .endm
11939 + .macro pax_force_fptr ptr
11940 + orq %r10,\ptr
11941 + .endm
11942 + .macro pax_set_fptr_mask
11943 + movabs $0x8000000000000000,%r10
11944 + .endm
11945 +#endif
11946 +#else
11947 + .macro pax_force_retaddr rip=0, reload=0
11948 + .endm
11949 + .macro pax_force_fptr ptr
11950 + .endm
11951 + .macro pax_force_retaddr_bts rip=0
11952 + .endm
11953 + .macro pax_set_fptr_mask
11954 + .endm
11955 +#endif
11956 +
11957 .macro altinstruction_entry orig alt feature orig_len alt_len
11958 .long \orig - .
11959 .long \alt - .
11960 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11961 index 58ed6d9..f1cbe58 100644
11962 --- a/arch/x86/include/asm/alternative.h
11963 +++ b/arch/x86/include/asm/alternative.h
11964 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11965 ".pushsection .discard,\"aw\",@progbits\n" \
11966 DISCARD_ENTRY(1) \
11967 ".popsection\n" \
11968 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11969 + ".pushsection .altinstr_replacement, \"a\"\n" \
11970 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11971 ".popsection"
11972
11973 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11974 DISCARD_ENTRY(1) \
11975 DISCARD_ENTRY(2) \
11976 ".popsection\n" \
11977 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11978 + ".pushsection .altinstr_replacement, \"a\"\n" \
11979 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11980 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11981 ".popsection"
11982 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11983 index 3388034..050f0b9 100644
11984 --- a/arch/x86/include/asm/apic.h
11985 +++ b/arch/x86/include/asm/apic.h
11986 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11987
11988 #ifdef CONFIG_X86_LOCAL_APIC
11989
11990 -extern unsigned int apic_verbosity;
11991 +extern int apic_verbosity;
11992 extern int local_apic_timer_c2_ok;
11993
11994 extern int disable_apic;
11995 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11996 index 20370c6..a2eb9b0 100644
11997 --- a/arch/x86/include/asm/apm.h
11998 +++ b/arch/x86/include/asm/apm.h
11999 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12000 __asm__ __volatile__(APM_DO_ZERO_SEGS
12001 "pushl %%edi\n\t"
12002 "pushl %%ebp\n\t"
12003 - "lcall *%%cs:apm_bios_entry\n\t"
12004 + "lcall *%%ss:apm_bios_entry\n\t"
12005 "setc %%al\n\t"
12006 "popl %%ebp\n\t"
12007 "popl %%edi\n\t"
12008 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12009 __asm__ __volatile__(APM_DO_ZERO_SEGS
12010 "pushl %%edi\n\t"
12011 "pushl %%ebp\n\t"
12012 - "lcall *%%cs:apm_bios_entry\n\t"
12013 + "lcall *%%ss:apm_bios_entry\n\t"
12014 "setc %%bl\n\t"
12015 "popl %%ebp\n\t"
12016 "popl %%edi\n\t"
12017 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12018 index 722aa3b..3a0bb27 100644
12019 --- a/arch/x86/include/asm/atomic.h
12020 +++ b/arch/x86/include/asm/atomic.h
12021 @@ -22,7 +22,18 @@
12022 */
12023 static inline int atomic_read(const atomic_t *v)
12024 {
12025 - return (*(volatile int *)&(v)->counter);
12026 + return (*(volatile const int *)&(v)->counter);
12027 +}
12028 +
12029 +/**
12030 + * atomic_read_unchecked - read atomic variable
12031 + * @v: pointer of type atomic_unchecked_t
12032 + *
12033 + * Atomically reads the value of @v.
12034 + */
12035 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12036 +{
12037 + return (*(volatile const int *)&(v)->counter);
12038 }
12039
12040 /**
12041 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12042 }
12043
12044 /**
12045 + * atomic_set_unchecked - set atomic variable
12046 + * @v: pointer of type atomic_unchecked_t
12047 + * @i: required value
12048 + *
12049 + * Atomically sets the value of @v to @i.
12050 + */
12051 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12052 +{
12053 + v->counter = i;
12054 +}
12055 +
12056 +/**
12057 * atomic_add - add integer to atomic variable
12058 * @i: integer value to add
12059 * @v: pointer of type atomic_t
12060 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12061 */
12062 static inline void atomic_add(int i, atomic_t *v)
12063 {
12064 - asm volatile(LOCK_PREFIX "addl %1,%0"
12065 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12066 +
12067 +#ifdef CONFIG_PAX_REFCOUNT
12068 + "jno 0f\n"
12069 + LOCK_PREFIX "subl %1,%0\n"
12070 + "int $4\n0:\n"
12071 + _ASM_EXTABLE(0b, 0b)
12072 +#endif
12073 +
12074 + : "+m" (v->counter)
12075 + : "ir" (i));
12076 +}
12077 +
12078 +/**
12079 + * atomic_add_unchecked - add integer to atomic variable
12080 + * @i: integer value to add
12081 + * @v: pointer of type atomic_unchecked_t
12082 + *
12083 + * Atomically adds @i to @v.
12084 + */
12085 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12086 +{
12087 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12088 : "+m" (v->counter)
12089 : "ir" (i));
12090 }
12091 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12092 */
12093 static inline void atomic_sub(int i, atomic_t *v)
12094 {
12095 - asm volatile(LOCK_PREFIX "subl %1,%0"
12096 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12097 +
12098 +#ifdef CONFIG_PAX_REFCOUNT
12099 + "jno 0f\n"
12100 + LOCK_PREFIX "addl %1,%0\n"
12101 + "int $4\n0:\n"
12102 + _ASM_EXTABLE(0b, 0b)
12103 +#endif
12104 +
12105 + : "+m" (v->counter)
12106 + : "ir" (i));
12107 +}
12108 +
12109 +/**
12110 + * atomic_sub_unchecked - subtract integer from atomic variable
12111 + * @i: integer value to subtract
12112 + * @v: pointer of type atomic_unchecked_t
12113 + *
12114 + * Atomically subtracts @i from @v.
12115 + */
12116 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12117 +{
12118 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12119 : "+m" (v->counter)
12120 : "ir" (i));
12121 }
12122 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12123 {
12124 unsigned char c;
12125
12126 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12127 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12128 +
12129 +#ifdef CONFIG_PAX_REFCOUNT
12130 + "jno 0f\n"
12131 + LOCK_PREFIX "addl %2,%0\n"
12132 + "int $4\n0:\n"
12133 + _ASM_EXTABLE(0b, 0b)
12134 +#endif
12135 +
12136 + "sete %1\n"
12137 : "+m" (v->counter), "=qm" (c)
12138 : "ir" (i) : "memory");
12139 return c;
12140 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12141 */
12142 static inline void atomic_inc(atomic_t *v)
12143 {
12144 - asm volatile(LOCK_PREFIX "incl %0"
12145 + asm volatile(LOCK_PREFIX "incl %0\n"
12146 +
12147 +#ifdef CONFIG_PAX_REFCOUNT
12148 + "jno 0f\n"
12149 + LOCK_PREFIX "decl %0\n"
12150 + "int $4\n0:\n"
12151 + _ASM_EXTABLE(0b, 0b)
12152 +#endif
12153 +
12154 + : "+m" (v->counter));
12155 +}
12156 +
12157 +/**
12158 + * atomic_inc_unchecked - increment atomic variable
12159 + * @v: pointer of type atomic_unchecked_t
12160 + *
12161 + * Atomically increments @v by 1.
12162 + */
12163 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12164 +{
12165 + asm volatile(LOCK_PREFIX "incl %0\n"
12166 : "+m" (v->counter));
12167 }
12168
12169 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12170 */
12171 static inline void atomic_dec(atomic_t *v)
12172 {
12173 - asm volatile(LOCK_PREFIX "decl %0"
12174 + asm volatile(LOCK_PREFIX "decl %0\n"
12175 +
12176 +#ifdef CONFIG_PAX_REFCOUNT
12177 + "jno 0f\n"
12178 + LOCK_PREFIX "incl %0\n"
12179 + "int $4\n0:\n"
12180 + _ASM_EXTABLE(0b, 0b)
12181 +#endif
12182 +
12183 + : "+m" (v->counter));
12184 +}
12185 +
12186 +/**
12187 + * atomic_dec_unchecked - decrement atomic variable
12188 + * @v: pointer of type atomic_unchecked_t
12189 + *
12190 + * Atomically decrements @v by 1.
12191 + */
12192 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12193 +{
12194 + asm volatile(LOCK_PREFIX "decl %0\n"
12195 : "+m" (v->counter));
12196 }
12197
12198 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12199 {
12200 unsigned char c;
12201
12202 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12203 + asm volatile(LOCK_PREFIX "decl %0\n"
12204 +
12205 +#ifdef CONFIG_PAX_REFCOUNT
12206 + "jno 0f\n"
12207 + LOCK_PREFIX "incl %0\n"
12208 + "int $4\n0:\n"
12209 + _ASM_EXTABLE(0b, 0b)
12210 +#endif
12211 +
12212 + "sete %1\n"
12213 : "+m" (v->counter), "=qm" (c)
12214 : : "memory");
12215 return c != 0;
12216 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12217 {
12218 unsigned char c;
12219
12220 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12221 + asm volatile(LOCK_PREFIX "incl %0\n"
12222 +
12223 +#ifdef CONFIG_PAX_REFCOUNT
12224 + "jno 0f\n"
12225 + LOCK_PREFIX "decl %0\n"
12226 + "int $4\n0:\n"
12227 + _ASM_EXTABLE(0b, 0b)
12228 +#endif
12229 +
12230 + "sete %1\n"
12231 + : "+m" (v->counter), "=qm" (c)
12232 + : : "memory");
12233 + return c != 0;
12234 +}
12235 +
12236 +/**
12237 + * atomic_inc_and_test_unchecked - increment and test
12238 + * @v: pointer of type atomic_unchecked_t
12239 + *
12240 + * Atomically increments @v by 1
12241 + * and returns true if the result is zero, or false for all
12242 + * other cases.
12243 + */
12244 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12245 +{
12246 + unsigned char c;
12247 +
12248 + asm volatile(LOCK_PREFIX "incl %0\n"
12249 + "sete %1\n"
12250 : "+m" (v->counter), "=qm" (c)
12251 : : "memory");
12252 return c != 0;
12253 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12254 {
12255 unsigned char c;
12256
12257 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12258 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12259 +
12260 +#ifdef CONFIG_PAX_REFCOUNT
12261 + "jno 0f\n"
12262 + LOCK_PREFIX "subl %2,%0\n"
12263 + "int $4\n0:\n"
12264 + _ASM_EXTABLE(0b, 0b)
12265 +#endif
12266 +
12267 + "sets %1\n"
12268 : "+m" (v->counter), "=qm" (c)
12269 : "ir" (i) : "memory");
12270 return c;
12271 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12272 */
12273 static inline int atomic_add_return(int i, atomic_t *v)
12274 {
12275 + return i + xadd_check_overflow(&v->counter, i);
12276 +}
12277 +
12278 +/**
12279 + * atomic_add_return_unchecked - add integer and return
12280 + * @i: integer value to add
12281 + * @v: pointer of type atomic_unchecked_t
12282 + *
12283 + * Atomically adds @i to @v and returns @i + @v
12284 + */
12285 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12286 +{
12287 return i + xadd(&v->counter, i);
12288 }
12289
12290 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12291 }
12292
12293 #define atomic_inc_return(v) (atomic_add_return(1, v))
12294 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12295 +{
12296 + return atomic_add_return_unchecked(1, v);
12297 +}
12298 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12299
12300 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12301 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12302 return cmpxchg(&v->counter, old, new);
12303 }
12304
12305 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12306 +{
12307 + return cmpxchg(&v->counter, old, new);
12308 +}
12309 +
12310 static inline int atomic_xchg(atomic_t *v, int new)
12311 {
12312 return xchg(&v->counter, new);
12313 }
12314
12315 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12316 +{
12317 + return xchg(&v->counter, new);
12318 +}
12319 +
12320 /**
12321 * __atomic_add_unless - add unless the number is already a given value
12322 * @v: pointer of type atomic_t
12323 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12324 */
12325 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12326 {
12327 - int c, old;
12328 + int c, old, new;
12329 c = atomic_read(v);
12330 for (;;) {
12331 - if (unlikely(c == (u)))
12332 + if (unlikely(c == u))
12333 break;
12334 - old = atomic_cmpxchg((v), c, c + (a));
12335 +
12336 + asm volatile("addl %2,%0\n"
12337 +
12338 +#ifdef CONFIG_PAX_REFCOUNT
12339 + "jno 0f\n"
12340 + "subl %2,%0\n"
12341 + "int $4\n0:\n"
12342 + _ASM_EXTABLE(0b, 0b)
12343 +#endif
12344 +
12345 + : "=r" (new)
12346 + : "0" (c), "ir" (a));
12347 +
12348 + old = atomic_cmpxchg(v, c, new);
12349 if (likely(old == c))
12350 break;
12351 c = old;
12352 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12353 }
12354
12355 /**
12356 + * atomic_inc_not_zero_hint - increment if not null
12357 + * @v: pointer of type atomic_t
12358 + * @hint: probable value of the atomic before the increment
12359 + *
12360 + * This version of atomic_inc_not_zero() gives a hint of probable
12361 + * value of the atomic. This helps processor to not read the memory
12362 + * before doing the atomic read/modify/write cycle, lowering
12363 + * number of bus transactions on some arches.
12364 + *
12365 + * Returns: 0 if increment was not done, 1 otherwise.
12366 + */
12367 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12368 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12369 +{
12370 + int val, c = hint, new;
12371 +
12372 + /* sanity test, should be removed by compiler if hint is a constant */
12373 + if (!hint)
12374 + return __atomic_add_unless(v, 1, 0);
12375 +
12376 + do {
12377 + asm volatile("incl %0\n"
12378 +
12379 +#ifdef CONFIG_PAX_REFCOUNT
12380 + "jno 0f\n"
12381 + "decl %0\n"
12382 + "int $4\n0:\n"
12383 + _ASM_EXTABLE(0b, 0b)
12384 +#endif
12385 +
12386 + : "=r" (new)
12387 + : "0" (c));
12388 +
12389 + val = atomic_cmpxchg(v, c, new);
12390 + if (val == c)
12391 + return 1;
12392 + c = val;
12393 + } while (c);
12394 +
12395 + return 0;
12396 +}
12397 +
12398 +/**
12399 * atomic_inc_short - increment of a short integer
12400 * @v: pointer to type int
12401 *
12402 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12403 #endif
12404
12405 /* These are x86-specific, used by some header files */
12406 -#define atomic_clear_mask(mask, addr) \
12407 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12408 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12409 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12410 +{
12411 + asm volatile(LOCK_PREFIX "andl %1,%0"
12412 + : "+m" (v->counter)
12413 + : "r" (~(mask))
12414 + : "memory");
12415 +}
12416
12417 -#define atomic_set_mask(mask, addr) \
12418 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12419 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12420 - : "memory")
12421 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12422 +{
12423 + asm volatile(LOCK_PREFIX "andl %1,%0"
12424 + : "+m" (v->counter)
12425 + : "r" (~(mask))
12426 + : "memory");
12427 +}
12428 +
12429 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12430 +{
12431 + asm volatile(LOCK_PREFIX "orl %1,%0"
12432 + : "+m" (v->counter)
12433 + : "r" (mask)
12434 + : "memory");
12435 +}
12436 +
12437 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12438 +{
12439 + asm volatile(LOCK_PREFIX "orl %1,%0"
12440 + : "+m" (v->counter)
12441 + : "r" (mask)
12442 + : "memory");
12443 +}
12444
12445 /* Atomic operations are already serializing on x86 */
12446 #define smp_mb__before_atomic_dec() barrier()
12447 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12448 index b154de7..aadebd8 100644
12449 --- a/arch/x86/include/asm/atomic64_32.h
12450 +++ b/arch/x86/include/asm/atomic64_32.h
12451 @@ -12,6 +12,14 @@ typedef struct {
12452 u64 __aligned(8) counter;
12453 } atomic64_t;
12454
12455 +#ifdef CONFIG_PAX_REFCOUNT
12456 +typedef struct {
12457 + u64 __aligned(8) counter;
12458 +} atomic64_unchecked_t;
12459 +#else
12460 +typedef atomic64_t atomic64_unchecked_t;
12461 +#endif
12462 +
12463 #define ATOMIC64_INIT(val) { (val) }
12464
12465 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12466 @@ -37,21 +45,31 @@ typedef struct {
12467 ATOMIC64_DECL_ONE(sym##_386)
12468
12469 ATOMIC64_DECL_ONE(add_386);
12470 +ATOMIC64_DECL_ONE(add_unchecked_386);
12471 ATOMIC64_DECL_ONE(sub_386);
12472 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12473 ATOMIC64_DECL_ONE(inc_386);
12474 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12475 ATOMIC64_DECL_ONE(dec_386);
12476 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12477 #endif
12478
12479 #define alternative_atomic64(f, out, in...) \
12480 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12481
12482 ATOMIC64_DECL(read);
12483 +ATOMIC64_DECL(read_unchecked);
12484 ATOMIC64_DECL(set);
12485 +ATOMIC64_DECL(set_unchecked);
12486 ATOMIC64_DECL(xchg);
12487 ATOMIC64_DECL(add_return);
12488 +ATOMIC64_DECL(add_return_unchecked);
12489 ATOMIC64_DECL(sub_return);
12490 +ATOMIC64_DECL(sub_return_unchecked);
12491 ATOMIC64_DECL(inc_return);
12492 +ATOMIC64_DECL(inc_return_unchecked);
12493 ATOMIC64_DECL(dec_return);
12494 +ATOMIC64_DECL(dec_return_unchecked);
12495 ATOMIC64_DECL(dec_if_positive);
12496 ATOMIC64_DECL(inc_not_zero);
12497 ATOMIC64_DECL(add_unless);
12498 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12499 }
12500
12501 /**
12502 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12503 + * @p: pointer to type atomic64_unchecked_t
12504 + * @o: expected value
12505 + * @n: new value
12506 + *
12507 + * Atomically sets @v to @n if it was equal to @o and returns
12508 + * the old value.
12509 + */
12510 +
12511 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12512 +{
12513 + return cmpxchg64(&v->counter, o, n);
12514 +}
12515 +
12516 +/**
12517 * atomic64_xchg - xchg atomic64 variable
12518 * @v: pointer to type atomic64_t
12519 * @n: value to assign
12520 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12521 }
12522
12523 /**
12524 + * atomic64_set_unchecked - set atomic64 variable
12525 + * @v: pointer to type atomic64_unchecked_t
12526 + * @n: value to assign
12527 + *
12528 + * Atomically sets the value of @v to @n.
12529 + */
12530 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12531 +{
12532 + unsigned high = (unsigned)(i >> 32);
12533 + unsigned low = (unsigned)i;
12534 + alternative_atomic64(set, /* no output */,
12535 + "S" (v), "b" (low), "c" (high)
12536 + : "eax", "edx", "memory");
12537 +}
12538 +
12539 +/**
12540 * atomic64_read - read atomic64 variable
12541 * @v: pointer to type atomic64_t
12542 *
12543 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12544 }
12545
12546 /**
12547 + * atomic64_read_unchecked - read atomic64 variable
12548 + * @v: pointer to type atomic64_unchecked_t
12549 + *
12550 + * Atomically reads the value of @v and returns it.
12551 + */
12552 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12553 +{
12554 + long long r;
12555 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12556 + return r;
12557 + }
12558 +
12559 +/**
12560 * atomic64_add_return - add and return
12561 * @i: integer value to add
12562 * @v: pointer to type atomic64_t
12563 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12564 return i;
12565 }
12566
12567 +/**
12568 + * atomic64_add_return_unchecked - add and return
12569 + * @i: integer value to add
12570 + * @v: pointer to type atomic64_unchecked_t
12571 + *
12572 + * Atomically adds @i to @v and returns @i + *@v
12573 + */
12574 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12575 +{
12576 + alternative_atomic64(add_return_unchecked,
12577 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12578 + ASM_NO_INPUT_CLOBBER("memory"));
12579 + return i;
12580 +}
12581 +
12582 /*
12583 * Other variants with different arithmetic operators:
12584 */
12585 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12586 return a;
12587 }
12588
12589 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12590 +{
12591 + long long a;
12592 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12593 + "S" (v) : "memory", "ecx");
12594 + return a;
12595 +}
12596 +
12597 static inline long long atomic64_dec_return(atomic64_t *v)
12598 {
12599 long long a;
12600 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12601 }
12602
12603 /**
12604 + * atomic64_add_unchecked - add integer to atomic64 variable
12605 + * @i: integer value to add
12606 + * @v: pointer to type atomic64_unchecked_t
12607 + *
12608 + * Atomically adds @i to @v.
12609 + */
12610 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12611 +{
12612 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12613 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12614 + ASM_NO_INPUT_CLOBBER("memory"));
12615 + return i;
12616 +}
12617 +
12618 +/**
12619 * atomic64_sub - subtract the atomic64 variable
12620 * @i: integer value to subtract
12621 * @v: pointer to type atomic64_t
12622 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12623 index 0e1cbfc..5623683 100644
12624 --- a/arch/x86/include/asm/atomic64_64.h
12625 +++ b/arch/x86/include/asm/atomic64_64.h
12626 @@ -18,7 +18,19 @@
12627 */
12628 static inline long atomic64_read(const atomic64_t *v)
12629 {
12630 - return (*(volatile long *)&(v)->counter);
12631 + return (*(volatile const long *)&(v)->counter);
12632 +}
12633 +
12634 +/**
12635 + * atomic64_read_unchecked - read atomic64 variable
12636 + * @v: pointer of type atomic64_unchecked_t
12637 + *
12638 + * Atomically reads the value of @v.
12639 + * Doesn't imply a read memory barrier.
12640 + */
12641 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12642 +{
12643 + return (*(volatile const long *)&(v)->counter);
12644 }
12645
12646 /**
12647 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12648 }
12649
12650 /**
12651 + * atomic64_set_unchecked - set atomic64 variable
12652 + * @v: pointer to type atomic64_unchecked_t
12653 + * @i: required value
12654 + *
12655 + * Atomically sets the value of @v to @i.
12656 + */
12657 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12658 +{
12659 + v->counter = i;
12660 +}
12661 +
12662 +/**
12663 * atomic64_add - add integer to atomic64 variable
12664 * @i: integer value to add
12665 * @v: pointer to type atomic64_t
12666 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12667 */
12668 static inline void atomic64_add(long i, atomic64_t *v)
12669 {
12670 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12671 +
12672 +#ifdef CONFIG_PAX_REFCOUNT
12673 + "jno 0f\n"
12674 + LOCK_PREFIX "subq %1,%0\n"
12675 + "int $4\n0:\n"
12676 + _ASM_EXTABLE(0b, 0b)
12677 +#endif
12678 +
12679 + : "=m" (v->counter)
12680 + : "er" (i), "m" (v->counter));
12681 +}
12682 +
12683 +/**
12684 + * atomic64_add_unchecked - add integer to atomic64 variable
12685 + * @i: integer value to add
12686 + * @v: pointer to type atomic64_unchecked_t
12687 + *
12688 + * Atomically adds @i to @v.
12689 + */
12690 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12691 +{
12692 asm volatile(LOCK_PREFIX "addq %1,%0"
12693 : "=m" (v->counter)
12694 : "er" (i), "m" (v->counter));
12695 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12696 */
12697 static inline void atomic64_sub(long i, atomic64_t *v)
12698 {
12699 - asm volatile(LOCK_PREFIX "subq %1,%0"
12700 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12701 +
12702 +#ifdef CONFIG_PAX_REFCOUNT
12703 + "jno 0f\n"
12704 + LOCK_PREFIX "addq %1,%0\n"
12705 + "int $4\n0:\n"
12706 + _ASM_EXTABLE(0b, 0b)
12707 +#endif
12708 +
12709 + : "=m" (v->counter)
12710 + : "er" (i), "m" (v->counter));
12711 +}
12712 +
12713 +/**
12714 + * atomic64_sub_unchecked - subtract the atomic64 variable
12715 + * @i: integer value to subtract
12716 + * @v: pointer to type atomic64_unchecked_t
12717 + *
12718 + * Atomically subtracts @i from @v.
12719 + */
12720 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12721 +{
12722 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12723 : "=m" (v->counter)
12724 : "er" (i), "m" (v->counter));
12725 }
12726 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12727 {
12728 unsigned char c;
12729
12730 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12731 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12732 +
12733 +#ifdef CONFIG_PAX_REFCOUNT
12734 + "jno 0f\n"
12735 + LOCK_PREFIX "addq %2,%0\n"
12736 + "int $4\n0:\n"
12737 + _ASM_EXTABLE(0b, 0b)
12738 +#endif
12739 +
12740 + "sete %1\n"
12741 : "=m" (v->counter), "=qm" (c)
12742 : "er" (i), "m" (v->counter) : "memory");
12743 return c;
12744 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12745 */
12746 static inline void atomic64_inc(atomic64_t *v)
12747 {
12748 + asm volatile(LOCK_PREFIX "incq %0\n"
12749 +
12750 +#ifdef CONFIG_PAX_REFCOUNT
12751 + "jno 0f\n"
12752 + LOCK_PREFIX "decq %0\n"
12753 + "int $4\n0:\n"
12754 + _ASM_EXTABLE(0b, 0b)
12755 +#endif
12756 +
12757 + : "=m" (v->counter)
12758 + : "m" (v->counter));
12759 +}
12760 +
12761 +/**
12762 + * atomic64_inc_unchecked - increment atomic64 variable
12763 + * @v: pointer to type atomic64_unchecked_t
12764 + *
12765 + * Atomically increments @v by 1.
12766 + */
12767 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12768 +{
12769 asm volatile(LOCK_PREFIX "incq %0"
12770 : "=m" (v->counter)
12771 : "m" (v->counter));
12772 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12773 */
12774 static inline void atomic64_dec(atomic64_t *v)
12775 {
12776 - asm volatile(LOCK_PREFIX "decq %0"
12777 + asm volatile(LOCK_PREFIX "decq %0\n"
12778 +
12779 +#ifdef CONFIG_PAX_REFCOUNT
12780 + "jno 0f\n"
12781 + LOCK_PREFIX "incq %0\n"
12782 + "int $4\n0:\n"
12783 + _ASM_EXTABLE(0b, 0b)
12784 +#endif
12785 +
12786 + : "=m" (v->counter)
12787 + : "m" (v->counter));
12788 +}
12789 +
12790 +/**
12791 + * atomic64_dec_unchecked - decrement atomic64 variable
12792 + * @v: pointer to type atomic64_t
12793 + *
12794 + * Atomically decrements @v by 1.
12795 + */
12796 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12797 +{
12798 + asm volatile(LOCK_PREFIX "decq %0\n"
12799 : "=m" (v->counter)
12800 : "m" (v->counter));
12801 }
12802 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12803 {
12804 unsigned char c;
12805
12806 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12807 + asm volatile(LOCK_PREFIX "decq %0\n"
12808 +
12809 +#ifdef CONFIG_PAX_REFCOUNT
12810 + "jno 0f\n"
12811 + LOCK_PREFIX "incq %0\n"
12812 + "int $4\n0:\n"
12813 + _ASM_EXTABLE(0b, 0b)
12814 +#endif
12815 +
12816 + "sete %1\n"
12817 : "=m" (v->counter), "=qm" (c)
12818 : "m" (v->counter) : "memory");
12819 return c != 0;
12820 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12821 {
12822 unsigned char c;
12823
12824 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12825 + asm volatile(LOCK_PREFIX "incq %0\n"
12826 +
12827 +#ifdef CONFIG_PAX_REFCOUNT
12828 + "jno 0f\n"
12829 + LOCK_PREFIX "decq %0\n"
12830 + "int $4\n0:\n"
12831 + _ASM_EXTABLE(0b, 0b)
12832 +#endif
12833 +
12834 + "sete %1\n"
12835 : "=m" (v->counter), "=qm" (c)
12836 : "m" (v->counter) : "memory");
12837 return c != 0;
12838 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12839 {
12840 unsigned char c;
12841
12842 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12843 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12844 +
12845 +#ifdef CONFIG_PAX_REFCOUNT
12846 + "jno 0f\n"
12847 + LOCK_PREFIX "subq %2,%0\n"
12848 + "int $4\n0:\n"
12849 + _ASM_EXTABLE(0b, 0b)
12850 +#endif
12851 +
12852 + "sets %1\n"
12853 : "=m" (v->counter), "=qm" (c)
12854 : "er" (i), "m" (v->counter) : "memory");
12855 return c;
12856 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12857 */
12858 static inline long atomic64_add_return(long i, atomic64_t *v)
12859 {
12860 + return i + xadd_check_overflow(&v->counter, i);
12861 +}
12862 +
12863 +/**
12864 + * atomic64_add_return_unchecked - add and return
12865 + * @i: integer value to add
12866 + * @v: pointer to type atomic64_unchecked_t
12867 + *
12868 + * Atomically adds @i to @v and returns @i + @v
12869 + */
12870 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12871 +{
12872 return i + xadd(&v->counter, i);
12873 }
12874
12875 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12876 }
12877
12878 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12879 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12880 +{
12881 + return atomic64_add_return_unchecked(1, v);
12882 +}
12883 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12884
12885 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12886 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12887 return cmpxchg(&v->counter, old, new);
12888 }
12889
12890 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12891 +{
12892 + return cmpxchg(&v->counter, old, new);
12893 +}
12894 +
12895 static inline long atomic64_xchg(atomic64_t *v, long new)
12896 {
12897 return xchg(&v->counter, new);
12898 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12899 */
12900 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12901 {
12902 - long c, old;
12903 + long c, old, new;
12904 c = atomic64_read(v);
12905 for (;;) {
12906 - if (unlikely(c == (u)))
12907 + if (unlikely(c == u))
12908 break;
12909 - old = atomic64_cmpxchg((v), c, c + (a));
12910 +
12911 + asm volatile("add %2,%0\n"
12912 +
12913 +#ifdef CONFIG_PAX_REFCOUNT
12914 + "jno 0f\n"
12915 + "sub %2,%0\n"
12916 + "int $4\n0:\n"
12917 + _ASM_EXTABLE(0b, 0b)
12918 +#endif
12919 +
12920 + : "=r" (new)
12921 + : "0" (c), "ir" (a));
12922 +
12923 + old = atomic64_cmpxchg(v, c, new);
12924 if (likely(old == c))
12925 break;
12926 c = old;
12927 }
12928 - return c != (u);
12929 + return c != u;
12930 }
12931
12932 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12933 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12934 index 6dfd019..28e188d 100644
12935 --- a/arch/x86/include/asm/bitops.h
12936 +++ b/arch/x86/include/asm/bitops.h
12937 @@ -40,7 +40,7 @@
12938 * a mask operation on a byte.
12939 */
12940 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12941 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12942 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12943 #define CONST_MASK(nr) (1 << ((nr) & 7))
12944
12945 /**
12946 @@ -486,7 +486,7 @@ static inline int fls(int x)
12947 * at position 64.
12948 */
12949 #ifdef CONFIG_X86_64
12950 -static __always_inline int fls64(__u64 x)
12951 +static __always_inline long fls64(__u64 x)
12952 {
12953 int bitpos = -1;
12954 /*
12955 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12956 index 4fa687a..60f2d39 100644
12957 --- a/arch/x86/include/asm/boot.h
12958 +++ b/arch/x86/include/asm/boot.h
12959 @@ -6,10 +6,15 @@
12960 #include <uapi/asm/boot.h>
12961
12962 /* Physical address where kernel should be loaded. */
12963 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12964 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12965 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12966 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12967
12968 +#ifndef __ASSEMBLY__
12969 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12970 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12971 +#endif
12972 +
12973 /* Minimum kernel alignment, as a power of two */
12974 #ifdef CONFIG_X86_64
12975 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12976 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12977 index 48f99f1..d78ebf9 100644
12978 --- a/arch/x86/include/asm/cache.h
12979 +++ b/arch/x86/include/asm/cache.h
12980 @@ -5,12 +5,13 @@
12981
12982 /* L1 cache line size */
12983 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12984 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12985 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12986
12987 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12988 +#define __read_only __attribute__((__section__(".data..read_only")))
12989
12990 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12991 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12992 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12993
12994 #ifdef CONFIG_X86_VSMP
12995 #ifdef CONFIG_SMP
12996 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12997 index 9863ee3..4a1f8e1 100644
12998 --- a/arch/x86/include/asm/cacheflush.h
12999 +++ b/arch/x86/include/asm/cacheflush.h
13000 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13001 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13002
13003 if (pg_flags == _PGMT_DEFAULT)
13004 - return -1;
13005 + return ~0UL;
13006 else if (pg_flags == _PGMT_WC)
13007 return _PAGE_CACHE_WC;
13008 else if (pg_flags == _PGMT_UC_MINUS)
13009 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13010 index 46fc474..b02b0f9 100644
13011 --- a/arch/x86/include/asm/checksum_32.h
13012 +++ b/arch/x86/include/asm/checksum_32.h
13013 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13014 int len, __wsum sum,
13015 int *src_err_ptr, int *dst_err_ptr);
13016
13017 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13018 + int len, __wsum sum,
13019 + int *src_err_ptr, int *dst_err_ptr);
13020 +
13021 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13022 + int len, __wsum sum,
13023 + int *src_err_ptr, int *dst_err_ptr);
13024 +
13025 /*
13026 * Note: when you get a NULL pointer exception here this means someone
13027 * passed in an incorrect kernel address to one of these functions.
13028 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13029 int *err_ptr)
13030 {
13031 might_sleep();
13032 - return csum_partial_copy_generic((__force void *)src, dst,
13033 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13034 len, sum, err_ptr, NULL);
13035 }
13036
13037 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13038 {
13039 might_sleep();
13040 if (access_ok(VERIFY_WRITE, dst, len))
13041 - return csum_partial_copy_generic(src, (__force void *)dst,
13042 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13043 len, sum, NULL, err_ptr);
13044
13045 if (len)
13046 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13047 index 8d871ea..c1a0dc9 100644
13048 --- a/arch/x86/include/asm/cmpxchg.h
13049 +++ b/arch/x86/include/asm/cmpxchg.h
13050 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13051 __compiletime_error("Bad argument size for cmpxchg");
13052 extern void __xadd_wrong_size(void)
13053 __compiletime_error("Bad argument size for xadd");
13054 +extern void __xadd_check_overflow_wrong_size(void)
13055 + __compiletime_error("Bad argument size for xadd_check_overflow");
13056 extern void __add_wrong_size(void)
13057 __compiletime_error("Bad argument size for add");
13058 +extern void __add_check_overflow_wrong_size(void)
13059 + __compiletime_error("Bad argument size for add_check_overflow");
13060
13061 /*
13062 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13063 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13064 __ret; \
13065 })
13066
13067 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13068 + ({ \
13069 + __typeof__ (*(ptr)) __ret = (arg); \
13070 + switch (sizeof(*(ptr))) { \
13071 + case __X86_CASE_L: \
13072 + asm volatile (lock #op "l %0, %1\n" \
13073 + "jno 0f\n" \
13074 + "mov %0,%1\n" \
13075 + "int $4\n0:\n" \
13076 + _ASM_EXTABLE(0b, 0b) \
13077 + : "+r" (__ret), "+m" (*(ptr)) \
13078 + : : "memory", "cc"); \
13079 + break; \
13080 + case __X86_CASE_Q: \
13081 + asm volatile (lock #op "q %q0, %1\n" \
13082 + "jno 0f\n" \
13083 + "mov %0,%1\n" \
13084 + "int $4\n0:\n" \
13085 + _ASM_EXTABLE(0b, 0b) \
13086 + : "+r" (__ret), "+m" (*(ptr)) \
13087 + : : "memory", "cc"); \
13088 + break; \
13089 + default: \
13090 + __ ## op ## _check_overflow_wrong_size(); \
13091 + } \
13092 + __ret; \
13093 + })
13094 +
13095 /*
13096 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13097 * Since this is generally used to protect other memory information, we
13098 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13099 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13100 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13101
13102 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13103 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13104 +
13105 #define __add(ptr, inc, lock) \
13106 ({ \
13107 __typeof__ (*(ptr)) __ret = (inc); \
13108 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13109 index 59c6c40..5e0b22c 100644
13110 --- a/arch/x86/include/asm/compat.h
13111 +++ b/arch/x86/include/asm/compat.h
13112 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13113 typedef u32 compat_uint_t;
13114 typedef u32 compat_ulong_t;
13115 typedef u64 __attribute__((aligned(4))) compat_u64;
13116 -typedef u32 compat_uptr_t;
13117 +typedef u32 __user compat_uptr_t;
13118
13119 struct compat_timespec {
13120 compat_time_t tv_sec;
13121 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13122 index 93fe929..90858b7 100644
13123 --- a/arch/x86/include/asm/cpufeature.h
13124 +++ b/arch/x86/include/asm/cpufeature.h
13125 @@ -207,7 +207,7 @@
13126 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13127 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13128 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13129 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13130 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13131 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13132 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13133 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13134 @@ -377,7 +377,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13135 ".section .discard,\"aw\",@progbits\n"
13136 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13137 ".previous\n"
13138 - ".section .altinstr_replacement,\"ax\"\n"
13139 + ".section .altinstr_replacement,\"a\"\n"
13140 "3: movb $1,%0\n"
13141 "4:\n"
13142 ".previous\n"
13143 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13144 index 8bf1c06..b6ae785 100644
13145 --- a/arch/x86/include/asm/desc.h
13146 +++ b/arch/x86/include/asm/desc.h
13147 @@ -4,6 +4,7 @@
13148 #include <asm/desc_defs.h>
13149 #include <asm/ldt.h>
13150 #include <asm/mmu.h>
13151 +#include <asm/pgtable.h>
13152
13153 #include <linux/smp.h>
13154 #include <linux/percpu.h>
13155 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13156
13157 desc->type = (info->read_exec_only ^ 1) << 1;
13158 desc->type |= info->contents << 2;
13159 + desc->type |= info->seg_not_present ^ 1;
13160
13161 desc->s = 1;
13162 desc->dpl = 0x3;
13163 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13164 }
13165
13166 extern struct desc_ptr idt_descr;
13167 -extern gate_desc idt_table[];
13168 extern struct desc_ptr nmi_idt_descr;
13169 -extern gate_desc nmi_idt_table[];
13170 -
13171 -struct gdt_page {
13172 - struct desc_struct gdt[GDT_ENTRIES];
13173 -} __attribute__((aligned(PAGE_SIZE)));
13174 -
13175 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13176 +extern gate_desc idt_table[256];
13177 +extern gate_desc nmi_idt_table[256];
13178
13179 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13180 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13181 {
13182 - return per_cpu(gdt_page, cpu).gdt;
13183 + return cpu_gdt_table[cpu];
13184 }
13185
13186 #ifdef CONFIG_X86_64
13187 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13188 unsigned long base, unsigned dpl, unsigned flags,
13189 unsigned short seg)
13190 {
13191 - gate->a = (seg << 16) | (base & 0xffff);
13192 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13193 + gate->gate.offset_low = base;
13194 + gate->gate.seg = seg;
13195 + gate->gate.reserved = 0;
13196 + gate->gate.type = type;
13197 + gate->gate.s = 0;
13198 + gate->gate.dpl = dpl;
13199 + gate->gate.p = 1;
13200 + gate->gate.offset_high = base >> 16;
13201 }
13202
13203 #endif
13204 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13205
13206 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13207 {
13208 + pax_open_kernel();
13209 memcpy(&idt[entry], gate, sizeof(*gate));
13210 + pax_close_kernel();
13211 }
13212
13213 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13214 {
13215 + pax_open_kernel();
13216 memcpy(&ldt[entry], desc, 8);
13217 + pax_close_kernel();
13218 }
13219
13220 static inline void
13221 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13222 default: size = sizeof(*gdt); break;
13223 }
13224
13225 + pax_open_kernel();
13226 memcpy(&gdt[entry], desc, size);
13227 + pax_close_kernel();
13228 }
13229
13230 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13231 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13232
13233 static inline void native_load_tr_desc(void)
13234 {
13235 + pax_open_kernel();
13236 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13237 + pax_close_kernel();
13238 }
13239
13240 static inline void native_load_gdt(const struct desc_ptr *dtr)
13241 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13242 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13243 unsigned int i;
13244
13245 + pax_open_kernel();
13246 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13247 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13248 + pax_close_kernel();
13249 }
13250
13251 #define _LDT_empty(info) \
13252 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13253 preempt_enable();
13254 }
13255
13256 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13257 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13258 {
13259 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13260 }
13261 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13262 }
13263
13264 #ifdef CONFIG_X86_64
13265 -static inline void set_nmi_gate(int gate, void *addr)
13266 +static inline void set_nmi_gate(int gate, const void *addr)
13267 {
13268 gate_desc s;
13269
13270 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13271 }
13272 #endif
13273
13274 -static inline void _set_gate(int gate, unsigned type, void *addr,
13275 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13276 unsigned dpl, unsigned ist, unsigned seg)
13277 {
13278 gate_desc s;
13279 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13280 * Pentium F0 0F bugfix can have resulted in the mapped
13281 * IDT being write-protected.
13282 */
13283 -static inline void set_intr_gate(unsigned int n, void *addr)
13284 +static inline void set_intr_gate(unsigned int n, const void *addr)
13285 {
13286 BUG_ON((unsigned)n > 0xFF);
13287 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13288 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13289 /*
13290 * This routine sets up an interrupt gate at directory privilege level 3.
13291 */
13292 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13293 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13294 {
13295 BUG_ON((unsigned)n > 0xFF);
13296 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13297 }
13298
13299 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13300 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13301 {
13302 BUG_ON((unsigned)n > 0xFF);
13303 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13304 }
13305
13306 -static inline void set_trap_gate(unsigned int n, void *addr)
13307 +static inline void set_trap_gate(unsigned int n, const void *addr)
13308 {
13309 BUG_ON((unsigned)n > 0xFF);
13310 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13311 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13312 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13313 {
13314 BUG_ON((unsigned)n > 0xFF);
13315 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13316 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13317 }
13318
13319 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13320 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13321 {
13322 BUG_ON((unsigned)n > 0xFF);
13323 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13324 }
13325
13326 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13327 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13328 {
13329 BUG_ON((unsigned)n > 0xFF);
13330 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13331 }
13332
13333 +#ifdef CONFIG_X86_32
13334 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13335 +{
13336 + struct desc_struct d;
13337 +
13338 + if (likely(limit))
13339 + limit = (limit - 1UL) >> PAGE_SHIFT;
13340 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13341 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13342 +}
13343 +#endif
13344 +
13345 #endif /* _ASM_X86_DESC_H */
13346 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13347 index 278441f..b95a174 100644
13348 --- a/arch/x86/include/asm/desc_defs.h
13349 +++ b/arch/x86/include/asm/desc_defs.h
13350 @@ -31,6 +31,12 @@ struct desc_struct {
13351 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13352 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13353 };
13354 + struct {
13355 + u16 offset_low;
13356 + u16 seg;
13357 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13358 + unsigned offset_high: 16;
13359 + } gate;
13360 };
13361 } __attribute__((packed));
13362
13363 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13364 index ced283a..ffe04cc 100644
13365 --- a/arch/x86/include/asm/div64.h
13366 +++ b/arch/x86/include/asm/div64.h
13367 @@ -39,7 +39,7 @@
13368 __mod; \
13369 })
13370
13371 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13372 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13373 {
13374 union {
13375 u64 v64;
13376 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13377 index 9c999c1..3860cb8 100644
13378 --- a/arch/x86/include/asm/elf.h
13379 +++ b/arch/x86/include/asm/elf.h
13380 @@ -243,7 +243,25 @@ extern int force_personality32;
13381 the loader. We need to make sure that it is out of the way of the program
13382 that it will "exec", and that there is sufficient room for the brk. */
13383
13384 +#ifdef CONFIG_PAX_SEGMEXEC
13385 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13386 +#else
13387 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13388 +#endif
13389 +
13390 +#ifdef CONFIG_PAX_ASLR
13391 +#ifdef CONFIG_X86_32
13392 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13393 +
13394 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13395 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13396 +#else
13397 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13398 +
13399 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13400 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13401 +#endif
13402 +#endif
13403
13404 /* This yields a mask that user programs can use to figure out what
13405 instruction set this CPU supports. This could be done in user space,
13406 @@ -296,16 +314,12 @@ do { \
13407
13408 #define ARCH_DLINFO \
13409 do { \
13410 - if (vdso_enabled) \
13411 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13412 - (unsigned long)current->mm->context.vdso); \
13413 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13414 } while (0)
13415
13416 #define ARCH_DLINFO_X32 \
13417 do { \
13418 - if (vdso_enabled) \
13419 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13420 - (unsigned long)current->mm->context.vdso); \
13421 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13422 } while (0)
13423
13424 #define AT_SYSINFO 32
13425 @@ -320,7 +334,7 @@ else \
13426
13427 #endif /* !CONFIG_X86_32 */
13428
13429 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13430 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13431
13432 #define VDSO_ENTRY \
13433 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13434 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13435 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13436 #define compat_arch_setup_additional_pages syscall32_setup_pages
13437
13438 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13439 -#define arch_randomize_brk arch_randomize_brk
13440 -
13441 /*
13442 * True on X86_32 or when emulating IA32 on X86_64
13443 */
13444 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13445 index 75ce3f4..882e801 100644
13446 --- a/arch/x86/include/asm/emergency-restart.h
13447 +++ b/arch/x86/include/asm/emergency-restart.h
13448 @@ -13,6 +13,6 @@ enum reboot_type {
13449
13450 extern enum reboot_type reboot_type;
13451
13452 -extern void machine_emergency_restart(void);
13453 +extern void machine_emergency_restart(void) __noreturn;
13454
13455 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13456 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13457 index e25cc33..425d099 100644
13458 --- a/arch/x86/include/asm/fpu-internal.h
13459 +++ b/arch/x86/include/asm/fpu-internal.h
13460 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13461 ({ \
13462 int err; \
13463 asm volatile(ASM_STAC "\n" \
13464 - "1:" #insn "\n\t" \
13465 + "1:" \
13466 + __copyuser_seg \
13467 + #insn "\n\t" \
13468 "2: " ASM_CLAC "\n" \
13469 ".section .fixup,\"ax\"\n" \
13470 "3: movl $-1,%[err]\n" \
13471 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13472 "emms\n\t" /* clear stack tags */
13473 "fildl %P[addr]", /* set F?P to defined value */
13474 X86_FEATURE_FXSAVE_LEAK,
13475 - [addr] "m" (tsk->thread.fpu.has_fpu));
13476 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13477
13478 return fpu_restore_checking(&tsk->thread.fpu);
13479 }
13480 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13481 index be27ba1..8f13ff9 100644
13482 --- a/arch/x86/include/asm/futex.h
13483 +++ b/arch/x86/include/asm/futex.h
13484 @@ -12,6 +12,7 @@
13485 #include <asm/smap.h>
13486
13487 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13488 + typecheck(u32 __user *, uaddr); \
13489 asm volatile("\t" ASM_STAC "\n" \
13490 "1:\t" insn "\n" \
13491 "2:\t" ASM_CLAC "\n" \
13492 @@ -20,15 +21,16 @@
13493 "\tjmp\t2b\n" \
13494 "\t.previous\n" \
13495 _ASM_EXTABLE(1b, 3b) \
13496 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13497 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13498 : "i" (-EFAULT), "0" (oparg), "1" (0))
13499
13500 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13501 + typecheck(u32 __user *, uaddr); \
13502 asm volatile("\t" ASM_STAC "\n" \
13503 "1:\tmovl %2, %0\n" \
13504 "\tmovl\t%0, %3\n" \
13505 "\t" insn "\n" \
13506 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13507 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13508 "\tjnz\t1b\n" \
13509 "3:\t" ASM_CLAC "\n" \
13510 "\t.section .fixup,\"ax\"\n" \
13511 @@ -38,7 +40,7 @@
13512 _ASM_EXTABLE(1b, 4b) \
13513 _ASM_EXTABLE(2b, 4b) \
13514 : "=&a" (oldval), "=&r" (ret), \
13515 - "+m" (*uaddr), "=&r" (tem) \
13516 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13517 : "r" (oparg), "i" (-EFAULT), "1" (0))
13518
13519 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13520 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13521
13522 switch (op) {
13523 case FUTEX_OP_SET:
13524 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13525 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13526 break;
13527 case FUTEX_OP_ADD:
13528 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13529 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13530 uaddr, oparg);
13531 break;
13532 case FUTEX_OP_OR:
13533 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13534 return -EFAULT;
13535
13536 asm volatile("\t" ASM_STAC "\n"
13537 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13538 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13539 "2:\t" ASM_CLAC "\n"
13540 "\t.section .fixup, \"ax\"\n"
13541 "3:\tmov %3, %0\n"
13542 "\tjmp 2b\n"
13543 "\t.previous\n"
13544 _ASM_EXTABLE(1b, 3b)
13545 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13546 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13547 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13548 : "memory"
13549 );
13550 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13551 index 10a78c3..cc77143 100644
13552 --- a/arch/x86/include/asm/hw_irq.h
13553 +++ b/arch/x86/include/asm/hw_irq.h
13554 @@ -147,8 +147,8 @@ extern void setup_ioapic_dest(void);
13555 extern void enable_IO_APIC(void);
13556
13557 /* Statistics */
13558 -extern atomic_t irq_err_count;
13559 -extern atomic_t irq_mis_count;
13560 +extern atomic_unchecked_t irq_err_count;
13561 +extern atomic_unchecked_t irq_mis_count;
13562
13563 /* EISA */
13564 extern void eisa_set_level_irq(unsigned int irq);
13565 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13566 index a203659..9889f1c 100644
13567 --- a/arch/x86/include/asm/i8259.h
13568 +++ b/arch/x86/include/asm/i8259.h
13569 @@ -62,7 +62,7 @@ struct legacy_pic {
13570 void (*init)(int auto_eoi);
13571 int (*irq_pending)(unsigned int irq);
13572 void (*make_irq)(unsigned int irq);
13573 -};
13574 +} __do_const;
13575
13576 extern struct legacy_pic *legacy_pic;
13577 extern struct legacy_pic null_legacy_pic;
13578 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13579 index d8e8eef..1765f78 100644
13580 --- a/arch/x86/include/asm/io.h
13581 +++ b/arch/x86/include/asm/io.h
13582 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13583 "m" (*(volatile type __force *)addr) barrier); }
13584
13585 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13586 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13587 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13588 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13589 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13590
13591 build_mmio_read(__readb, "b", unsigned char, "=q", )
13592 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13593 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13594 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13595 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13596
13597 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13598 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13599 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13600 return ioremap_nocache(offset, size);
13601 }
13602
13603 -extern void iounmap(volatile void __iomem *addr);
13604 +extern void iounmap(const volatile void __iomem *addr);
13605
13606 extern void set_iounmap_nonlazy(void);
13607
13608 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13609
13610 #include <linux/vmalloc.h>
13611
13612 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13613 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13614 +{
13615 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13616 +}
13617 +
13618 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13619 +{
13620 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13621 +}
13622 +
13623 /*
13624 * Convert a virtual cached pointer to an uncached pointer
13625 */
13626 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13627 index bba3cf8..06bc8da 100644
13628 --- a/arch/x86/include/asm/irqflags.h
13629 +++ b/arch/x86/include/asm/irqflags.h
13630 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13631 sti; \
13632 sysexit
13633
13634 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13635 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13636 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13637 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13638 +
13639 #else
13640 #define INTERRUPT_RETURN iret
13641 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13642 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13643 index 5a6d287..f815789 100644
13644 --- a/arch/x86/include/asm/kprobes.h
13645 +++ b/arch/x86/include/asm/kprobes.h
13646 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13647 #define RELATIVEJUMP_SIZE 5
13648 #define RELATIVECALL_OPCODE 0xe8
13649 #define RELATIVE_ADDR_SIZE 4
13650 -#define MAX_STACK_SIZE 64
13651 -#define MIN_STACK_SIZE(ADDR) \
13652 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13653 - THREAD_SIZE - (unsigned long)(ADDR))) \
13654 - ? (MAX_STACK_SIZE) \
13655 - : (((unsigned long)current_thread_info()) + \
13656 - THREAD_SIZE - (unsigned long)(ADDR)))
13657 +#define MAX_STACK_SIZE 64UL
13658 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13659
13660 #define flush_insn_slot(p) do { } while (0)
13661
13662 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13663 index 2d89e39..baee879 100644
13664 --- a/arch/x86/include/asm/local.h
13665 +++ b/arch/x86/include/asm/local.h
13666 @@ -10,33 +10,97 @@ typedef struct {
13667 atomic_long_t a;
13668 } local_t;
13669
13670 +typedef struct {
13671 + atomic_long_unchecked_t a;
13672 +} local_unchecked_t;
13673 +
13674 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13675
13676 #define local_read(l) atomic_long_read(&(l)->a)
13677 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13678 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13679 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13680
13681 static inline void local_inc(local_t *l)
13682 {
13683 - asm volatile(_ASM_INC "%0"
13684 + asm volatile(_ASM_INC "%0\n"
13685 +
13686 +#ifdef CONFIG_PAX_REFCOUNT
13687 + "jno 0f\n"
13688 + _ASM_DEC "%0\n"
13689 + "int $4\n0:\n"
13690 + _ASM_EXTABLE(0b, 0b)
13691 +#endif
13692 +
13693 + : "+m" (l->a.counter));
13694 +}
13695 +
13696 +static inline void local_inc_unchecked(local_unchecked_t *l)
13697 +{
13698 + asm volatile(_ASM_INC "%0\n"
13699 : "+m" (l->a.counter));
13700 }
13701
13702 static inline void local_dec(local_t *l)
13703 {
13704 - asm volatile(_ASM_DEC "%0"
13705 + asm volatile(_ASM_DEC "%0\n"
13706 +
13707 +#ifdef CONFIG_PAX_REFCOUNT
13708 + "jno 0f\n"
13709 + _ASM_INC "%0\n"
13710 + "int $4\n0:\n"
13711 + _ASM_EXTABLE(0b, 0b)
13712 +#endif
13713 +
13714 + : "+m" (l->a.counter));
13715 +}
13716 +
13717 +static inline void local_dec_unchecked(local_unchecked_t *l)
13718 +{
13719 + asm volatile(_ASM_DEC "%0\n"
13720 : "+m" (l->a.counter));
13721 }
13722
13723 static inline void local_add(long i, local_t *l)
13724 {
13725 - asm volatile(_ASM_ADD "%1,%0"
13726 + asm volatile(_ASM_ADD "%1,%0\n"
13727 +
13728 +#ifdef CONFIG_PAX_REFCOUNT
13729 + "jno 0f\n"
13730 + _ASM_SUB "%1,%0\n"
13731 + "int $4\n0:\n"
13732 + _ASM_EXTABLE(0b, 0b)
13733 +#endif
13734 +
13735 + : "+m" (l->a.counter)
13736 + : "ir" (i));
13737 +}
13738 +
13739 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13740 +{
13741 + asm volatile(_ASM_ADD "%1,%0\n"
13742 : "+m" (l->a.counter)
13743 : "ir" (i));
13744 }
13745
13746 static inline void local_sub(long i, local_t *l)
13747 {
13748 - asm volatile(_ASM_SUB "%1,%0"
13749 + asm volatile(_ASM_SUB "%1,%0\n"
13750 +
13751 +#ifdef CONFIG_PAX_REFCOUNT
13752 + "jno 0f\n"
13753 + _ASM_ADD "%1,%0\n"
13754 + "int $4\n0:\n"
13755 + _ASM_EXTABLE(0b, 0b)
13756 +#endif
13757 +
13758 + : "+m" (l->a.counter)
13759 + : "ir" (i));
13760 +}
13761 +
13762 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13763 +{
13764 + asm volatile(_ASM_SUB "%1,%0\n"
13765 : "+m" (l->a.counter)
13766 : "ir" (i));
13767 }
13768 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13769 {
13770 unsigned char c;
13771
13772 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13773 + asm volatile(_ASM_SUB "%2,%0\n"
13774 +
13775 +#ifdef CONFIG_PAX_REFCOUNT
13776 + "jno 0f\n"
13777 + _ASM_ADD "%2,%0\n"
13778 + "int $4\n0:\n"
13779 + _ASM_EXTABLE(0b, 0b)
13780 +#endif
13781 +
13782 + "sete %1\n"
13783 : "+m" (l->a.counter), "=qm" (c)
13784 : "ir" (i) : "memory");
13785 return c;
13786 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13787 {
13788 unsigned char c;
13789
13790 - asm volatile(_ASM_DEC "%0; sete %1"
13791 + asm volatile(_ASM_DEC "%0\n"
13792 +
13793 +#ifdef CONFIG_PAX_REFCOUNT
13794 + "jno 0f\n"
13795 + _ASM_INC "%0\n"
13796 + "int $4\n0:\n"
13797 + _ASM_EXTABLE(0b, 0b)
13798 +#endif
13799 +
13800 + "sete %1\n"
13801 : "+m" (l->a.counter), "=qm" (c)
13802 : : "memory");
13803 return c != 0;
13804 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13805 {
13806 unsigned char c;
13807
13808 - asm volatile(_ASM_INC "%0; sete %1"
13809 + asm volatile(_ASM_INC "%0\n"
13810 +
13811 +#ifdef CONFIG_PAX_REFCOUNT
13812 + "jno 0f\n"
13813 + _ASM_DEC "%0\n"
13814 + "int $4\n0:\n"
13815 + _ASM_EXTABLE(0b, 0b)
13816 +#endif
13817 +
13818 + "sete %1\n"
13819 : "+m" (l->a.counter), "=qm" (c)
13820 : : "memory");
13821 return c != 0;
13822 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13823 {
13824 unsigned char c;
13825
13826 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13827 + asm volatile(_ASM_ADD "%2,%0\n"
13828 +
13829 +#ifdef CONFIG_PAX_REFCOUNT
13830 + "jno 0f\n"
13831 + _ASM_SUB "%2,%0\n"
13832 + "int $4\n0:\n"
13833 + _ASM_EXTABLE(0b, 0b)
13834 +#endif
13835 +
13836 + "sets %1\n"
13837 : "+m" (l->a.counter), "=qm" (c)
13838 : "ir" (i) : "memory");
13839 return c;
13840 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13841 static inline long local_add_return(long i, local_t *l)
13842 {
13843 long __i = i;
13844 + asm volatile(_ASM_XADD "%0, %1\n"
13845 +
13846 +#ifdef CONFIG_PAX_REFCOUNT
13847 + "jno 0f\n"
13848 + _ASM_MOV "%0,%1\n"
13849 + "int $4\n0:\n"
13850 + _ASM_EXTABLE(0b, 0b)
13851 +#endif
13852 +
13853 + : "+r" (i), "+m" (l->a.counter)
13854 + : : "memory");
13855 + return i + __i;
13856 +}
13857 +
13858 +/**
13859 + * local_add_return_unchecked - add and return
13860 + * @i: integer value to add
13861 + * @l: pointer to type local_unchecked_t
13862 + *
13863 + * Atomically adds @i to @l and returns @i + @l
13864 + */
13865 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13866 +{
13867 + long __i = i;
13868 asm volatile(_ASM_XADD "%0, %1;"
13869 : "+r" (i), "+m" (l->a.counter)
13870 : : "memory");
13871 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13872
13873 #define local_cmpxchg(l, o, n) \
13874 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13875 +#define local_cmpxchg_unchecked(l, o, n) \
13876 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13877 /* Always has a lock prefix */
13878 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13879
13880 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13881 new file mode 100644
13882 index 0000000..2bfd3ba
13883 --- /dev/null
13884 +++ b/arch/x86/include/asm/mman.h
13885 @@ -0,0 +1,15 @@
13886 +#ifndef _X86_MMAN_H
13887 +#define _X86_MMAN_H
13888 +
13889 +#include <uapi/asm/mman.h>
13890 +
13891 +#ifdef __KERNEL__
13892 +#ifndef __ASSEMBLY__
13893 +#ifdef CONFIG_X86_32
13894 +#define arch_mmap_check i386_mmap_check
13895 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13896 +#endif
13897 +#endif
13898 +#endif
13899 +
13900 +#endif /* X86_MMAN_H */
13901 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13902 index 5f55e69..e20bfb1 100644
13903 --- a/arch/x86/include/asm/mmu.h
13904 +++ b/arch/x86/include/asm/mmu.h
13905 @@ -9,7 +9,7 @@
13906 * we put the segment information here.
13907 */
13908 typedef struct {
13909 - void *ldt;
13910 + struct desc_struct *ldt;
13911 int size;
13912
13913 #ifdef CONFIG_X86_64
13914 @@ -18,7 +18,19 @@ typedef struct {
13915 #endif
13916
13917 struct mutex lock;
13918 - void *vdso;
13919 + unsigned long vdso;
13920 +
13921 +#ifdef CONFIG_X86_32
13922 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13923 + unsigned long user_cs_base;
13924 + unsigned long user_cs_limit;
13925 +
13926 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13927 + cpumask_t cpu_user_cs_mask;
13928 +#endif
13929 +
13930 +#endif
13931 +#endif
13932 } mm_context_t;
13933
13934 #ifdef CONFIG_SMP
13935 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13936 index cdbf367..adb37ac 100644
13937 --- a/arch/x86/include/asm/mmu_context.h
13938 +++ b/arch/x86/include/asm/mmu_context.h
13939 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13940
13941 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13942 {
13943 +
13944 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13945 + unsigned int i;
13946 + pgd_t *pgd;
13947 +
13948 + pax_open_kernel();
13949 + pgd = get_cpu_pgd(smp_processor_id());
13950 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13951 + set_pgd_batched(pgd+i, native_make_pgd(0));
13952 + pax_close_kernel();
13953 +#endif
13954 +
13955 #ifdef CONFIG_SMP
13956 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13957 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13958 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13959 struct task_struct *tsk)
13960 {
13961 unsigned cpu = smp_processor_id();
13962 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13963 + int tlbstate = TLBSTATE_OK;
13964 +#endif
13965
13966 if (likely(prev != next)) {
13967 #ifdef CONFIG_SMP
13968 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13969 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13970 +#endif
13971 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13972 this_cpu_write(cpu_tlbstate.active_mm, next);
13973 #endif
13974 cpumask_set_cpu(cpu, mm_cpumask(next));
13975
13976 /* Re-load page tables */
13977 +#ifdef CONFIG_PAX_PER_CPU_PGD
13978 + pax_open_kernel();
13979 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13980 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13981 + pax_close_kernel();
13982 + load_cr3(get_cpu_pgd(cpu));
13983 +#else
13984 load_cr3(next->pgd);
13985 +#endif
13986
13987 /* stop flush ipis for the previous mm */
13988 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13989 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13990 */
13991 if (unlikely(prev->context.ldt != next->context.ldt))
13992 load_LDT_nolock(&next->context);
13993 - }
13994 +
13995 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13996 + if (!(__supported_pte_mask & _PAGE_NX)) {
13997 + smp_mb__before_clear_bit();
13998 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13999 + smp_mb__after_clear_bit();
14000 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14001 + }
14002 +#endif
14003 +
14004 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14005 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
14006 + prev->context.user_cs_limit != next->context.user_cs_limit))
14007 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14008 #ifdef CONFIG_SMP
14009 + else if (unlikely(tlbstate != TLBSTATE_OK))
14010 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14011 +#endif
14012 +#endif
14013 +
14014 + }
14015 else {
14016 +
14017 +#ifdef CONFIG_PAX_PER_CPU_PGD
14018 + pax_open_kernel();
14019 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14020 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14021 + pax_close_kernel();
14022 + load_cr3(get_cpu_pgd(cpu));
14023 +#endif
14024 +
14025 +#ifdef CONFIG_SMP
14026 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14027 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14028
14029 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14030 * tlb flush IPI delivery. We must reload CR3
14031 * to make sure to use no freed page tables.
14032 */
14033 +
14034 +#ifndef CONFIG_PAX_PER_CPU_PGD
14035 load_cr3(next->pgd);
14036 +#endif
14037 +
14038 load_LDT_nolock(&next->context);
14039 +
14040 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14041 + if (!(__supported_pte_mask & _PAGE_NX))
14042 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14043 +#endif
14044 +
14045 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14046 +#ifdef CONFIG_PAX_PAGEEXEC
14047 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14048 +#endif
14049 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14050 +#endif
14051 +
14052 }
14053 +#endif
14054 }
14055 -#endif
14056 }
14057
14058 #define activate_mm(prev, next) \
14059 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14060 index e3b7819..b257c64 100644
14061 --- a/arch/x86/include/asm/module.h
14062 +++ b/arch/x86/include/asm/module.h
14063 @@ -5,6 +5,7 @@
14064
14065 #ifdef CONFIG_X86_64
14066 /* X86_64 does not define MODULE_PROC_FAMILY */
14067 +#define MODULE_PROC_FAMILY ""
14068 #elif defined CONFIG_M486
14069 #define MODULE_PROC_FAMILY "486 "
14070 #elif defined CONFIG_M586
14071 @@ -57,8 +58,20 @@
14072 #error unknown processor family
14073 #endif
14074
14075 -#ifdef CONFIG_X86_32
14076 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14077 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14078 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14079 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14080 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14081 +#else
14082 +#define MODULE_PAX_KERNEXEC ""
14083 #endif
14084
14085 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14086 +#define MODULE_PAX_UDEREF "UDEREF "
14087 +#else
14088 +#define MODULE_PAX_UDEREF ""
14089 +#endif
14090 +
14091 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14092 +
14093 #endif /* _ASM_X86_MODULE_H */
14094 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14095 index c0fa356..07a498a 100644
14096 --- a/arch/x86/include/asm/nmi.h
14097 +++ b/arch/x86/include/asm/nmi.h
14098 @@ -42,11 +42,11 @@ struct nmiaction {
14099 nmi_handler_t handler;
14100 unsigned long flags;
14101 const char *name;
14102 -};
14103 +} __do_const;
14104
14105 #define register_nmi_handler(t, fn, fg, n, init...) \
14106 ({ \
14107 - static struct nmiaction init fn##_na = { \
14108 + static const struct nmiaction init fn##_na = { \
14109 .handler = (fn), \
14110 .name = (n), \
14111 .flags = (fg), \
14112 @@ -54,7 +54,7 @@ struct nmiaction {
14113 __register_nmi_handler((t), &fn##_na); \
14114 })
14115
14116 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14117 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14118
14119 void unregister_nmi_handler(unsigned int, const char *);
14120
14121 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14122 index 0f1ddee..e2fc3d1 100644
14123 --- a/arch/x86/include/asm/page_64.h
14124 +++ b/arch/x86/include/asm/page_64.h
14125 @@ -7,9 +7,9 @@
14126
14127 /* duplicated to the one in bootmem.h */
14128 extern unsigned long max_pfn;
14129 -extern unsigned long phys_base;
14130 +extern const unsigned long phys_base;
14131
14132 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14133 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14134 {
14135 unsigned long y = x - __START_KERNEL_map;
14136
14137 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14138 index 7361e47..16dc226 100644
14139 --- a/arch/x86/include/asm/paravirt.h
14140 +++ b/arch/x86/include/asm/paravirt.h
14141 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14142 return (pmd_t) { ret };
14143 }
14144
14145 -static inline pmdval_t pmd_val(pmd_t pmd)
14146 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14147 {
14148 pmdval_t ret;
14149
14150 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14151 val);
14152 }
14153
14154 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14155 +{
14156 + pgdval_t val = native_pgd_val(pgd);
14157 +
14158 + if (sizeof(pgdval_t) > sizeof(long))
14159 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14160 + val, (u64)val >> 32);
14161 + else
14162 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14163 + val);
14164 +}
14165 +
14166 static inline void pgd_clear(pgd_t *pgdp)
14167 {
14168 set_pgd(pgdp, __pgd(0));
14169 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14170 pv_mmu_ops.set_fixmap(idx, phys, flags);
14171 }
14172
14173 +#ifdef CONFIG_PAX_KERNEXEC
14174 +static inline unsigned long pax_open_kernel(void)
14175 +{
14176 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14177 +}
14178 +
14179 +static inline unsigned long pax_close_kernel(void)
14180 +{
14181 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14182 +}
14183 +#else
14184 +static inline unsigned long pax_open_kernel(void) { return 0; }
14185 +static inline unsigned long pax_close_kernel(void) { return 0; }
14186 +#endif
14187 +
14188 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14189
14190 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14191 @@ -930,7 +957,7 @@ extern void default_banner(void);
14192
14193 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14194 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14195 -#define PARA_INDIRECT(addr) *%cs:addr
14196 +#define PARA_INDIRECT(addr) *%ss:addr
14197 #endif
14198
14199 #define INTERRUPT_RETURN \
14200 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
14201 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14202 CLBR_NONE, \
14203 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14204 +
14205 +#define GET_CR0_INTO_RDI \
14206 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14207 + mov %rax,%rdi
14208 +
14209 +#define SET_RDI_INTO_CR0 \
14210 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14211 +
14212 +#define GET_CR3_INTO_RDI \
14213 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14214 + mov %rax,%rdi
14215 +
14216 +#define SET_RDI_INTO_CR3 \
14217 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14218 +
14219 #endif /* CONFIG_X86_32 */
14220
14221 #endif /* __ASSEMBLY__ */
14222 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14223 index b3b0ec1..b1cd3eb 100644
14224 --- a/arch/x86/include/asm/paravirt_types.h
14225 +++ b/arch/x86/include/asm/paravirt_types.h
14226 @@ -84,7 +84,7 @@ struct pv_init_ops {
14227 */
14228 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14229 unsigned long addr, unsigned len);
14230 -};
14231 +} __no_const;
14232
14233
14234 struct pv_lazy_ops {
14235 @@ -98,7 +98,7 @@ struct pv_time_ops {
14236 unsigned long long (*sched_clock)(void);
14237 unsigned long long (*steal_clock)(int cpu);
14238 unsigned long (*get_tsc_khz)(void);
14239 -};
14240 +} __no_const;
14241
14242 struct pv_cpu_ops {
14243 /* hooks for various privileged instructions */
14244 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14245
14246 void (*start_context_switch)(struct task_struct *prev);
14247 void (*end_context_switch)(struct task_struct *next);
14248 -};
14249 +} __no_const;
14250
14251 struct pv_irq_ops {
14252 /*
14253 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14254 unsigned long start_eip,
14255 unsigned long start_esp);
14256 #endif
14257 -};
14258 +} __no_const;
14259
14260 struct pv_mmu_ops {
14261 unsigned long (*read_cr2)(void);
14262 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14263 struct paravirt_callee_save make_pud;
14264
14265 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14266 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14267 #endif /* PAGETABLE_LEVELS == 4 */
14268 #endif /* PAGETABLE_LEVELS >= 3 */
14269
14270 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14271 an mfn. We can tell which is which from the index. */
14272 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14273 phys_addr_t phys, pgprot_t flags);
14274 +
14275 +#ifdef CONFIG_PAX_KERNEXEC
14276 + unsigned long (*pax_open_kernel)(void);
14277 + unsigned long (*pax_close_kernel)(void);
14278 +#endif
14279 +
14280 };
14281
14282 struct arch_spinlock;
14283 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14284 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14285 int (*spin_trylock)(struct arch_spinlock *lock);
14286 void (*spin_unlock)(struct arch_spinlock *lock);
14287 -};
14288 +} __no_const;
14289
14290 /* This contains all the paravirt structures: we get a convenient
14291 * number for each function using the offset which we use to indicate
14292 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14293 index b4389a4..7024269 100644
14294 --- a/arch/x86/include/asm/pgalloc.h
14295 +++ b/arch/x86/include/asm/pgalloc.h
14296 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14297 pmd_t *pmd, pte_t *pte)
14298 {
14299 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14300 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14301 +}
14302 +
14303 +static inline void pmd_populate_user(struct mm_struct *mm,
14304 + pmd_t *pmd, pte_t *pte)
14305 +{
14306 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14307 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14308 }
14309
14310 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14311
14312 #ifdef CONFIG_X86_PAE
14313 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14314 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14315 +{
14316 + pud_populate(mm, pudp, pmd);
14317 +}
14318 #else /* !CONFIG_X86_PAE */
14319 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14320 {
14321 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14322 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14323 }
14324 +
14325 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14326 +{
14327 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14328 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14329 +}
14330 #endif /* CONFIG_X86_PAE */
14331
14332 #if PAGETABLE_LEVELS > 3
14333 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14334 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14335 }
14336
14337 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14338 +{
14339 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14340 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14341 +}
14342 +
14343 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14344 {
14345 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14346 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14347 index f2b489c..4f7e2e5 100644
14348 --- a/arch/x86/include/asm/pgtable-2level.h
14349 +++ b/arch/x86/include/asm/pgtable-2level.h
14350 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14351
14352 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14353 {
14354 + pax_open_kernel();
14355 *pmdp = pmd;
14356 + pax_close_kernel();
14357 }
14358
14359 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14360 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14361 index 4cc9f2b..5fd9226 100644
14362 --- a/arch/x86/include/asm/pgtable-3level.h
14363 +++ b/arch/x86/include/asm/pgtable-3level.h
14364 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14365
14366 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14367 {
14368 + pax_open_kernel();
14369 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14370 + pax_close_kernel();
14371 }
14372
14373 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14374 {
14375 + pax_open_kernel();
14376 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14377 + pax_close_kernel();
14378 }
14379
14380 /*
14381 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14382 index 1e67223..dd6e7ea 100644
14383 --- a/arch/x86/include/asm/pgtable.h
14384 +++ b/arch/x86/include/asm/pgtable.h
14385 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14386
14387 #ifndef __PAGETABLE_PUD_FOLDED
14388 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14389 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14390 #define pgd_clear(pgd) native_pgd_clear(pgd)
14391 #endif
14392
14393 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14394
14395 #define arch_end_context_switch(prev) do {} while(0)
14396
14397 +#define pax_open_kernel() native_pax_open_kernel()
14398 +#define pax_close_kernel() native_pax_close_kernel()
14399 #endif /* CONFIG_PARAVIRT */
14400
14401 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14402 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14403 +
14404 +#ifdef CONFIG_PAX_KERNEXEC
14405 +static inline unsigned long native_pax_open_kernel(void)
14406 +{
14407 + unsigned long cr0;
14408 +
14409 + preempt_disable();
14410 + barrier();
14411 + cr0 = read_cr0() ^ X86_CR0_WP;
14412 + BUG_ON(cr0 & X86_CR0_WP);
14413 + write_cr0(cr0);
14414 + return cr0 ^ X86_CR0_WP;
14415 +}
14416 +
14417 +static inline unsigned long native_pax_close_kernel(void)
14418 +{
14419 + unsigned long cr0;
14420 +
14421 + cr0 = read_cr0() ^ X86_CR0_WP;
14422 + BUG_ON(!(cr0 & X86_CR0_WP));
14423 + write_cr0(cr0);
14424 + barrier();
14425 + preempt_enable_no_resched();
14426 + return cr0 ^ X86_CR0_WP;
14427 +}
14428 +#else
14429 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14430 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14431 +#endif
14432 +
14433 /*
14434 * The following only work if pte_present() is true.
14435 * Undefined behaviour if not..
14436 */
14437 +static inline int pte_user(pte_t pte)
14438 +{
14439 + return pte_val(pte) & _PAGE_USER;
14440 +}
14441 +
14442 static inline int pte_dirty(pte_t pte)
14443 {
14444 return pte_flags(pte) & _PAGE_DIRTY;
14445 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14446 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14447 }
14448
14449 +static inline unsigned long pgd_pfn(pgd_t pgd)
14450 +{
14451 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14452 +}
14453 +
14454 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14455
14456 static inline int pmd_large(pmd_t pte)
14457 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14458 return pte_clear_flags(pte, _PAGE_RW);
14459 }
14460
14461 +static inline pte_t pte_mkread(pte_t pte)
14462 +{
14463 + return __pte(pte_val(pte) | _PAGE_USER);
14464 +}
14465 +
14466 static inline pte_t pte_mkexec(pte_t pte)
14467 {
14468 - return pte_clear_flags(pte, _PAGE_NX);
14469 +#ifdef CONFIG_X86_PAE
14470 + if (__supported_pte_mask & _PAGE_NX)
14471 + return pte_clear_flags(pte, _PAGE_NX);
14472 + else
14473 +#endif
14474 + return pte_set_flags(pte, _PAGE_USER);
14475 +}
14476 +
14477 +static inline pte_t pte_exprotect(pte_t pte)
14478 +{
14479 +#ifdef CONFIG_X86_PAE
14480 + if (__supported_pte_mask & _PAGE_NX)
14481 + return pte_set_flags(pte, _PAGE_NX);
14482 + else
14483 +#endif
14484 + return pte_clear_flags(pte, _PAGE_USER);
14485 }
14486
14487 static inline pte_t pte_mkdirty(pte_t pte)
14488 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14489 #endif
14490
14491 #ifndef __ASSEMBLY__
14492 +
14493 +#ifdef CONFIG_PAX_PER_CPU_PGD
14494 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14495 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14496 +{
14497 + return cpu_pgd[cpu];
14498 +}
14499 +#endif
14500 +
14501 #include <linux/mm_types.h>
14502 #include <linux/log2.h>
14503
14504 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14505 * Currently stuck as a macro due to indirect forward reference to
14506 * linux/mmzone.h's __section_mem_map_addr() definition:
14507 */
14508 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14509 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14510
14511 /* Find an entry in the second-level page table.. */
14512 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14513 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14514 * Currently stuck as a macro due to indirect forward reference to
14515 * linux/mmzone.h's __section_mem_map_addr() definition:
14516 */
14517 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14518 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14519
14520 /* to find an entry in a page-table-directory. */
14521 static inline unsigned long pud_index(unsigned long address)
14522 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14523
14524 static inline int pgd_bad(pgd_t pgd)
14525 {
14526 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14527 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14528 }
14529
14530 static inline int pgd_none(pgd_t pgd)
14531 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14532 * pgd_offset() returns a (pgd_t *)
14533 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14534 */
14535 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14536 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14537 +
14538 +#ifdef CONFIG_PAX_PER_CPU_PGD
14539 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14540 +#endif
14541 +
14542 /*
14543 * a shortcut which implies the use of the kernel's pgd, instead
14544 * of a process's
14545 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14546 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14547 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14548
14549 +#ifdef CONFIG_X86_32
14550 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14551 +#else
14552 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14553 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14554 +
14555 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14556 +#ifdef __ASSEMBLY__
14557 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14558 +#else
14559 +extern unsigned long pax_user_shadow_base;
14560 +#endif
14561 +#endif
14562 +
14563 +#endif
14564 +
14565 #ifndef __ASSEMBLY__
14566
14567 extern int direct_gbpages;
14568 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14569 * dst and src can be on the same page, but the range must not overlap,
14570 * and must not cross a page boundary.
14571 */
14572 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14573 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14574 {
14575 - memcpy(dst, src, count * sizeof(pgd_t));
14576 + pax_open_kernel();
14577 + while (count--)
14578 + *dst++ = *src++;
14579 + pax_close_kernel();
14580 }
14581
14582 +#ifdef CONFIG_PAX_PER_CPU_PGD
14583 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14584 +#endif
14585 +
14586 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14587 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14588 +#else
14589 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14590 +#endif
14591 +
14592 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14593 static inline int page_level_shift(enum pg_level level)
14594 {
14595 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14596 index 9ee3221..b979c6b 100644
14597 --- a/arch/x86/include/asm/pgtable_32.h
14598 +++ b/arch/x86/include/asm/pgtable_32.h
14599 @@ -25,9 +25,6 @@
14600 struct mm_struct;
14601 struct vm_area_struct;
14602
14603 -extern pgd_t swapper_pg_dir[1024];
14604 -extern pgd_t initial_page_table[1024];
14605 -
14606 static inline void pgtable_cache_init(void) { }
14607 static inline void check_pgt_cache(void) { }
14608 void paging_init(void);
14609 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14610 # include <asm/pgtable-2level.h>
14611 #endif
14612
14613 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14614 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14615 +#ifdef CONFIG_X86_PAE
14616 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14617 +#endif
14618 +
14619 #if defined(CONFIG_HIGHPTE)
14620 #define pte_offset_map(dir, address) \
14621 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14622 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14623 /* Clear a kernel PTE and flush it from the TLB */
14624 #define kpte_clear_flush(ptep, vaddr) \
14625 do { \
14626 + pax_open_kernel(); \
14627 pte_clear(&init_mm, (vaddr), (ptep)); \
14628 + pax_close_kernel(); \
14629 __flush_tlb_one((vaddr)); \
14630 } while (0)
14631
14632 #endif /* !__ASSEMBLY__ */
14633
14634 +#define HAVE_ARCH_UNMAPPED_AREA
14635 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14636 +
14637 /*
14638 * kern_addr_valid() is (1) for FLATMEM and (0) for
14639 * SPARSEMEM and DISCONTIGMEM
14640 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14641 index ed5903b..c7fe163 100644
14642 --- a/arch/x86/include/asm/pgtable_32_types.h
14643 +++ b/arch/x86/include/asm/pgtable_32_types.h
14644 @@ -8,7 +8,7 @@
14645 */
14646 #ifdef CONFIG_X86_PAE
14647 # include <asm/pgtable-3level_types.h>
14648 -# define PMD_SIZE (1UL << PMD_SHIFT)
14649 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14650 # define PMD_MASK (~(PMD_SIZE - 1))
14651 #else
14652 # include <asm/pgtable-2level_types.h>
14653 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14654 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14655 #endif
14656
14657 +#ifdef CONFIG_PAX_KERNEXEC
14658 +#ifndef __ASSEMBLY__
14659 +extern unsigned char MODULES_EXEC_VADDR[];
14660 +extern unsigned char MODULES_EXEC_END[];
14661 +#endif
14662 +#include <asm/boot.h>
14663 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14664 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14665 +#else
14666 +#define ktla_ktva(addr) (addr)
14667 +#define ktva_ktla(addr) (addr)
14668 +#endif
14669 +
14670 #define MODULES_VADDR VMALLOC_START
14671 #define MODULES_END VMALLOC_END
14672 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14673 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14674 index e22c1db..23a625a 100644
14675 --- a/arch/x86/include/asm/pgtable_64.h
14676 +++ b/arch/x86/include/asm/pgtable_64.h
14677 @@ -16,10 +16,14 @@
14678
14679 extern pud_t level3_kernel_pgt[512];
14680 extern pud_t level3_ident_pgt[512];
14681 +extern pud_t level3_vmalloc_start_pgt[512];
14682 +extern pud_t level3_vmalloc_end_pgt[512];
14683 +extern pud_t level3_vmemmap_pgt[512];
14684 +extern pud_t level2_vmemmap_pgt[512];
14685 extern pmd_t level2_kernel_pgt[512];
14686 extern pmd_t level2_fixmap_pgt[512];
14687 -extern pmd_t level2_ident_pgt[512];
14688 -extern pgd_t init_level4_pgt[];
14689 +extern pmd_t level2_ident_pgt[512*2];
14690 +extern pgd_t init_level4_pgt[512];
14691
14692 #define swapper_pg_dir init_level4_pgt
14693
14694 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14695
14696 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14697 {
14698 + pax_open_kernel();
14699 *pmdp = pmd;
14700 + pax_close_kernel();
14701 }
14702
14703 static inline void native_pmd_clear(pmd_t *pmd)
14704 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14705
14706 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14707 {
14708 + pax_open_kernel();
14709 *pudp = pud;
14710 + pax_close_kernel();
14711 }
14712
14713 static inline void native_pud_clear(pud_t *pud)
14714 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14715
14716 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14717 {
14718 + pax_open_kernel();
14719 + *pgdp = pgd;
14720 + pax_close_kernel();
14721 +}
14722 +
14723 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14724 +{
14725 *pgdp = pgd;
14726 }
14727
14728 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14729 index 2d88344..4679fc3 100644
14730 --- a/arch/x86/include/asm/pgtable_64_types.h
14731 +++ b/arch/x86/include/asm/pgtable_64_types.h
14732 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14733 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14734 #define MODULES_END _AC(0xffffffffff000000, UL)
14735 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14736 +#define MODULES_EXEC_VADDR MODULES_VADDR
14737 +#define MODULES_EXEC_END MODULES_END
14738 +
14739 +#define ktla_ktva(addr) (addr)
14740 +#define ktva_ktla(addr) (addr)
14741
14742 #define EARLY_DYNAMIC_PAGE_TABLES 64
14743
14744 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14745 index 567b5d0..bd91d64 100644
14746 --- a/arch/x86/include/asm/pgtable_types.h
14747 +++ b/arch/x86/include/asm/pgtable_types.h
14748 @@ -16,13 +16,12 @@
14749 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14750 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14751 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14752 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14753 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14754 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14755 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14756 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14757 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14758 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14759 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14760 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14761 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14762 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14763
14764 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14765 @@ -40,7 +39,6 @@
14766 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14767 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14768 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14769 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14770 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14771 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14772 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14773 @@ -57,8 +55,10 @@
14774
14775 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14776 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14777 -#else
14778 +#elif defined(CONFIG_KMEMCHECK)
14779 #define _PAGE_NX (_AT(pteval_t, 0))
14780 +#else
14781 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14782 #endif
14783
14784 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14785 @@ -116,6 +116,9 @@
14786 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14787 _PAGE_ACCESSED)
14788
14789 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14790 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14791 +
14792 #define __PAGE_KERNEL_EXEC \
14793 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14794 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14795 @@ -126,7 +129,7 @@
14796 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14797 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14798 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14799 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14800 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14801 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14802 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14803 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14804 @@ -188,8 +191,8 @@
14805 * bits are combined, this will alow user to access the high address mapped
14806 * VDSO in the presence of CONFIG_COMPAT_VDSO
14807 */
14808 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14809 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14810 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14811 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14812 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14813 #endif
14814
14815 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14816 {
14817 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14818 }
14819 +#endif
14820
14821 +#if PAGETABLE_LEVELS == 3
14822 +#include <asm-generic/pgtable-nopud.h>
14823 +#endif
14824 +
14825 +#if PAGETABLE_LEVELS == 2
14826 +#include <asm-generic/pgtable-nopmd.h>
14827 +#endif
14828 +
14829 +#ifndef __ASSEMBLY__
14830 #if PAGETABLE_LEVELS > 3
14831 typedef struct { pudval_t pud; } pud_t;
14832
14833 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14834 return pud.pud;
14835 }
14836 #else
14837 -#include <asm-generic/pgtable-nopud.h>
14838 -
14839 static inline pudval_t native_pud_val(pud_t pud)
14840 {
14841 return native_pgd_val(pud.pgd);
14842 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14843 return pmd.pmd;
14844 }
14845 #else
14846 -#include <asm-generic/pgtable-nopmd.h>
14847 -
14848 static inline pmdval_t native_pmd_val(pmd_t pmd)
14849 {
14850 return native_pgd_val(pmd.pud.pgd);
14851 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14852
14853 extern pteval_t __supported_pte_mask;
14854 extern void set_nx(void);
14855 -extern int nx_enabled;
14856
14857 #define pgprot_writecombine pgprot_writecombine
14858 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14859 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14860 index 3270116..8d99d82 100644
14861 --- a/arch/x86/include/asm/processor.h
14862 +++ b/arch/x86/include/asm/processor.h
14863 @@ -285,7 +285,7 @@ struct tss_struct {
14864
14865 } ____cacheline_aligned;
14866
14867 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14868 +extern struct tss_struct init_tss[NR_CPUS];
14869
14870 /*
14871 * Save the original ist values for checking stack pointers during debugging
14872 @@ -826,11 +826,18 @@ static inline void spin_lock_prefetch(const void *x)
14873 */
14874 #define TASK_SIZE PAGE_OFFSET
14875 #define TASK_SIZE_MAX TASK_SIZE
14876 +
14877 +#ifdef CONFIG_PAX_SEGMEXEC
14878 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14879 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14880 +#else
14881 #define STACK_TOP TASK_SIZE
14882 -#define STACK_TOP_MAX STACK_TOP
14883 +#endif
14884 +
14885 +#define STACK_TOP_MAX TASK_SIZE
14886
14887 #define INIT_THREAD { \
14888 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14889 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14890 .vm86_info = NULL, \
14891 .sysenter_cs = __KERNEL_CS, \
14892 .io_bitmap_ptr = NULL, \
14893 @@ -844,7 +851,7 @@ static inline void spin_lock_prefetch(const void *x)
14894 */
14895 #define INIT_TSS { \
14896 .x86_tss = { \
14897 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14898 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14899 .ss0 = __KERNEL_DS, \
14900 .ss1 = __KERNEL_CS, \
14901 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14902 @@ -855,11 +862,7 @@ static inline void spin_lock_prefetch(const void *x)
14903 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14904
14905 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14906 -#define KSTK_TOP(info) \
14907 -({ \
14908 - unsigned long *__ptr = (unsigned long *)(info); \
14909 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14910 -})
14911 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14912
14913 /*
14914 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14915 @@ -874,7 +877,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14916 #define task_pt_regs(task) \
14917 ({ \
14918 struct pt_regs *__regs__; \
14919 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14920 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14921 __regs__ - 1; \
14922 })
14923
14924 @@ -884,13 +887,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14925 /*
14926 * User space process size. 47bits minus one guard page.
14927 */
14928 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14929 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14930
14931 /* This decides where the kernel will search for a free chunk of vm
14932 * space during mmap's.
14933 */
14934 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14935 - 0xc0000000 : 0xFFFFe000)
14936 + 0xc0000000 : 0xFFFFf000)
14937
14938 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14939 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14940 @@ -901,11 +904,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14941 #define STACK_TOP_MAX TASK_SIZE_MAX
14942
14943 #define INIT_THREAD { \
14944 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14945 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14946 }
14947
14948 #define INIT_TSS { \
14949 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14950 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14951 }
14952
14953 /*
14954 @@ -933,6 +936,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14955 */
14956 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14957
14958 +#ifdef CONFIG_PAX_SEGMEXEC
14959 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14960 +#endif
14961 +
14962 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14963
14964 /* Get/set a process' ability to use the timestamp counter instruction */
14965 @@ -993,7 +1000,7 @@ extern bool cpu_has_amd_erratum(const int *);
14966 #define cpu_has_amd_erratum(x) (false)
14967 #endif /* CONFIG_CPU_SUP_AMD */
14968
14969 -extern unsigned long arch_align_stack(unsigned long sp);
14970 +#define arch_align_stack(x) ((x) & ~0xfUL)
14971 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14972
14973 void default_idle(void);
14974 @@ -1003,6 +1010,6 @@ bool xen_set_default_idle(void);
14975 #define xen_set_default_idle 0
14976 #endif
14977
14978 -void stop_this_cpu(void *dummy);
14979 +void stop_this_cpu(void *dummy) __noreturn;
14980
14981 #endif /* _ASM_X86_PROCESSOR_H */
14982 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14983 index 942a086..6c26446 100644
14984 --- a/arch/x86/include/asm/ptrace.h
14985 +++ b/arch/x86/include/asm/ptrace.h
14986 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14987 }
14988
14989 /*
14990 - * user_mode_vm(regs) determines whether a register set came from user mode.
14991 + * user_mode(regs) determines whether a register set came from user mode.
14992 * This is true if V8086 mode was enabled OR if the register set was from
14993 * protected mode with RPL-3 CS value. This tricky test checks that with
14994 * one comparison. Many places in the kernel can bypass this full check
14995 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14996 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14997 + * be used.
14998 */
14999 -static inline int user_mode(struct pt_regs *regs)
15000 +static inline int user_mode_novm(struct pt_regs *regs)
15001 {
15002 #ifdef CONFIG_X86_32
15003 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15004 #else
15005 - return !!(regs->cs & 3);
15006 + return !!(regs->cs & SEGMENT_RPL_MASK);
15007 #endif
15008 }
15009
15010 -static inline int user_mode_vm(struct pt_regs *regs)
15011 +static inline int user_mode(struct pt_regs *regs)
15012 {
15013 #ifdef CONFIG_X86_32
15014 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15015 USER_RPL;
15016 #else
15017 - return user_mode(regs);
15018 + return user_mode_novm(regs);
15019 #endif
15020 }
15021
15022 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15023 #ifdef CONFIG_X86_64
15024 static inline bool user_64bit_mode(struct pt_regs *regs)
15025 {
15026 + unsigned long cs = regs->cs & 0xffff;
15027 #ifndef CONFIG_PARAVIRT
15028 /*
15029 * On non-paravirt systems, this is the only long mode CPL 3
15030 * selector. We do not allow long mode selectors in the LDT.
15031 */
15032 - return regs->cs == __USER_CS;
15033 + return cs == __USER_CS;
15034 #else
15035 /* Headers are too twisted for this to go in paravirt.h. */
15036 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15037 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15038 #endif
15039 }
15040
15041 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15042 * Traps from the kernel do not save sp and ss.
15043 * Use the helper function to retrieve sp.
15044 */
15045 - if (offset == offsetof(struct pt_regs, sp) &&
15046 - regs->cs == __KERNEL_CS)
15047 - return kernel_stack_pointer(regs);
15048 + if (offset == offsetof(struct pt_regs, sp)) {
15049 + unsigned long cs = regs->cs & 0xffff;
15050 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15051 + return kernel_stack_pointer(regs);
15052 + }
15053 #endif
15054 return *(unsigned long *)((unsigned long)regs + offset);
15055 }
15056 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15057 index 9c6b890..5305f53 100644
15058 --- a/arch/x86/include/asm/realmode.h
15059 +++ b/arch/x86/include/asm/realmode.h
15060 @@ -22,16 +22,14 @@ struct real_mode_header {
15061 #endif
15062 /* APM/BIOS reboot */
15063 u32 machine_real_restart_asm;
15064 -#ifdef CONFIG_X86_64
15065 u32 machine_real_restart_seg;
15066 -#endif
15067 };
15068
15069 /* This must match data at trampoline_32/64.S */
15070 struct trampoline_header {
15071 #ifdef CONFIG_X86_32
15072 u32 start;
15073 - u16 gdt_pad;
15074 + u16 boot_cs;
15075 u16 gdt_limit;
15076 u32 gdt_base;
15077 #else
15078 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15079 index a82c4f1..ac45053 100644
15080 --- a/arch/x86/include/asm/reboot.h
15081 +++ b/arch/x86/include/asm/reboot.h
15082 @@ -6,13 +6,13 @@
15083 struct pt_regs;
15084
15085 struct machine_ops {
15086 - void (*restart)(char *cmd);
15087 - void (*halt)(void);
15088 - void (*power_off)(void);
15089 + void (* __noreturn restart)(char *cmd);
15090 + void (* __noreturn halt)(void);
15091 + void (* __noreturn power_off)(void);
15092 void (*shutdown)(void);
15093 void (*crash_shutdown)(struct pt_regs *);
15094 - void (*emergency_restart)(void);
15095 -};
15096 + void (* __noreturn emergency_restart)(void);
15097 +} __no_const;
15098
15099 extern struct machine_ops machine_ops;
15100
15101 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15102 index 2dbe4a7..ce1db00 100644
15103 --- a/arch/x86/include/asm/rwsem.h
15104 +++ b/arch/x86/include/asm/rwsem.h
15105 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15106 {
15107 asm volatile("# beginning down_read\n\t"
15108 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15109 +
15110 +#ifdef CONFIG_PAX_REFCOUNT
15111 + "jno 0f\n"
15112 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15113 + "int $4\n0:\n"
15114 + _ASM_EXTABLE(0b, 0b)
15115 +#endif
15116 +
15117 /* adds 0x00000001 */
15118 " jns 1f\n"
15119 " call call_rwsem_down_read_failed\n"
15120 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15121 "1:\n\t"
15122 " mov %1,%2\n\t"
15123 " add %3,%2\n\t"
15124 +
15125 +#ifdef CONFIG_PAX_REFCOUNT
15126 + "jno 0f\n"
15127 + "sub %3,%2\n"
15128 + "int $4\n0:\n"
15129 + _ASM_EXTABLE(0b, 0b)
15130 +#endif
15131 +
15132 " jle 2f\n\t"
15133 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15134 " jnz 1b\n\t"
15135 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15136 long tmp;
15137 asm volatile("# beginning down_write\n\t"
15138 LOCK_PREFIX " xadd %1,(%2)\n\t"
15139 +
15140 +#ifdef CONFIG_PAX_REFCOUNT
15141 + "jno 0f\n"
15142 + "mov %1,(%2)\n"
15143 + "int $4\n0:\n"
15144 + _ASM_EXTABLE(0b, 0b)
15145 +#endif
15146 +
15147 /* adds 0xffff0001, returns the old value */
15148 " test %1,%1\n\t"
15149 /* was the count 0 before? */
15150 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15151 long tmp;
15152 asm volatile("# beginning __up_read\n\t"
15153 LOCK_PREFIX " xadd %1,(%2)\n\t"
15154 +
15155 +#ifdef CONFIG_PAX_REFCOUNT
15156 + "jno 0f\n"
15157 + "mov %1,(%2)\n"
15158 + "int $4\n0:\n"
15159 + _ASM_EXTABLE(0b, 0b)
15160 +#endif
15161 +
15162 /* subtracts 1, returns the old value */
15163 " jns 1f\n\t"
15164 " call call_rwsem_wake\n" /* expects old value in %edx */
15165 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15166 long tmp;
15167 asm volatile("# beginning __up_write\n\t"
15168 LOCK_PREFIX " xadd %1,(%2)\n\t"
15169 +
15170 +#ifdef CONFIG_PAX_REFCOUNT
15171 + "jno 0f\n"
15172 + "mov %1,(%2)\n"
15173 + "int $4\n0:\n"
15174 + _ASM_EXTABLE(0b, 0b)
15175 +#endif
15176 +
15177 /* subtracts 0xffff0001, returns the old value */
15178 " jns 1f\n\t"
15179 " call call_rwsem_wake\n" /* expects old value in %edx */
15180 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15181 {
15182 asm volatile("# beginning __downgrade_write\n\t"
15183 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15184 +
15185 +#ifdef CONFIG_PAX_REFCOUNT
15186 + "jno 0f\n"
15187 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15188 + "int $4\n0:\n"
15189 + _ASM_EXTABLE(0b, 0b)
15190 +#endif
15191 +
15192 /*
15193 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15194 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15195 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15196 */
15197 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15198 {
15199 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15200 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15201 +
15202 +#ifdef CONFIG_PAX_REFCOUNT
15203 + "jno 0f\n"
15204 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15205 + "int $4\n0:\n"
15206 + _ASM_EXTABLE(0b, 0b)
15207 +#endif
15208 +
15209 : "+m" (sem->count)
15210 : "er" (delta));
15211 }
15212 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15213 */
15214 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15215 {
15216 - return delta + xadd(&sem->count, delta);
15217 + return delta + xadd_check_overflow(&sem->count, delta);
15218 }
15219
15220 #endif /* __KERNEL__ */
15221 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15222 index c48a950..c6d7468 100644
15223 --- a/arch/x86/include/asm/segment.h
15224 +++ b/arch/x86/include/asm/segment.h
15225 @@ -64,10 +64,15 @@
15226 * 26 - ESPFIX small SS
15227 * 27 - per-cpu [ offset to per-cpu data area ]
15228 * 28 - stack_canary-20 [ for stack protector ]
15229 - * 29 - unused
15230 - * 30 - unused
15231 + * 29 - PCI BIOS CS
15232 + * 30 - PCI BIOS DS
15233 * 31 - TSS for double fault handler
15234 */
15235 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15236 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15237 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15238 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15239 +
15240 #define GDT_ENTRY_TLS_MIN 6
15241 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15242
15243 @@ -79,6 +84,8 @@
15244
15245 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15246
15247 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15248 +
15249 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15250
15251 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15252 @@ -104,6 +111,12 @@
15253 #define __KERNEL_STACK_CANARY 0
15254 #endif
15255
15256 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15257 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15258 +
15259 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15260 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15261 +
15262 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15263
15264 /*
15265 @@ -141,7 +154,7 @@
15266 */
15267
15268 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15269 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15270 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15271
15272
15273 #else
15274 @@ -165,6 +178,8 @@
15275 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15276 #define __USER32_DS __USER_DS
15277
15278 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15279 +
15280 #define GDT_ENTRY_TSS 8 /* needs two entries */
15281 #define GDT_ENTRY_LDT 10 /* needs two entries */
15282 #define GDT_ENTRY_TLS_MIN 12
15283 @@ -185,6 +200,7 @@
15284 #endif
15285
15286 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15287 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15288 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15289 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15290 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15291 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15292 {
15293 unsigned long __limit;
15294 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15295 - return __limit + 1;
15296 + return __limit;
15297 }
15298
15299 #endif /* !__ASSEMBLY__ */
15300 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15301 index b073aae..39f9bdd 100644
15302 --- a/arch/x86/include/asm/smp.h
15303 +++ b/arch/x86/include/asm/smp.h
15304 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15305 /* cpus sharing the last level cache: */
15306 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15307 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15308 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15309 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15310
15311 static inline struct cpumask *cpu_sibling_mask(int cpu)
15312 {
15313 @@ -79,7 +79,7 @@ struct smp_ops {
15314
15315 void (*send_call_func_ipi)(const struct cpumask *mask);
15316 void (*send_call_func_single_ipi)(int cpu);
15317 -};
15318 +} __no_const;
15319
15320 /* Globals due to paravirt */
15321 extern void set_cpu_sibling_map(int cpu);
15322 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15323 extern int safe_smp_processor_id(void);
15324
15325 #elif defined(CONFIG_X86_64_SMP)
15326 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15327 -
15328 -#define stack_smp_processor_id() \
15329 -({ \
15330 - struct thread_info *ti; \
15331 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15332 - ti->cpu; \
15333 -})
15334 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15335 +#define stack_smp_processor_id() raw_smp_processor_id()
15336 #define safe_smp_processor_id() smp_processor_id()
15337
15338 #endif
15339 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15340 index 33692ea..350a534 100644
15341 --- a/arch/x86/include/asm/spinlock.h
15342 +++ b/arch/x86/include/asm/spinlock.h
15343 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15344 static inline void arch_read_lock(arch_rwlock_t *rw)
15345 {
15346 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15347 +
15348 +#ifdef CONFIG_PAX_REFCOUNT
15349 + "jno 0f\n"
15350 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15351 + "int $4\n0:\n"
15352 + _ASM_EXTABLE(0b, 0b)
15353 +#endif
15354 +
15355 "jns 1f\n"
15356 "call __read_lock_failed\n\t"
15357 "1:\n"
15358 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15359 static inline void arch_write_lock(arch_rwlock_t *rw)
15360 {
15361 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15362 +
15363 +#ifdef CONFIG_PAX_REFCOUNT
15364 + "jno 0f\n"
15365 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15366 + "int $4\n0:\n"
15367 + _ASM_EXTABLE(0b, 0b)
15368 +#endif
15369 +
15370 "jz 1f\n"
15371 "call __write_lock_failed\n\t"
15372 "1:\n"
15373 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15374
15375 static inline void arch_read_unlock(arch_rwlock_t *rw)
15376 {
15377 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15378 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15379 +
15380 +#ifdef CONFIG_PAX_REFCOUNT
15381 + "jno 0f\n"
15382 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15383 + "int $4\n0:\n"
15384 + _ASM_EXTABLE(0b, 0b)
15385 +#endif
15386 +
15387 :"+m" (rw->lock) : : "memory");
15388 }
15389
15390 static inline void arch_write_unlock(arch_rwlock_t *rw)
15391 {
15392 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15393 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15394 +
15395 +#ifdef CONFIG_PAX_REFCOUNT
15396 + "jno 0f\n"
15397 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15398 + "int $4\n0:\n"
15399 + _ASM_EXTABLE(0b, 0b)
15400 +#endif
15401 +
15402 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15403 }
15404
15405 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15406 index 6a99859..03cb807 100644
15407 --- a/arch/x86/include/asm/stackprotector.h
15408 +++ b/arch/x86/include/asm/stackprotector.h
15409 @@ -47,7 +47,7 @@
15410 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15411 */
15412 #define GDT_STACK_CANARY_INIT \
15413 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15414 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15415
15416 /*
15417 * Initialize the stackprotector canary value.
15418 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15419
15420 static inline void load_stack_canary_segment(void)
15421 {
15422 -#ifdef CONFIG_X86_32
15423 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15424 asm volatile ("mov %0, %%gs" : : "r" (0));
15425 #endif
15426 }
15427 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15428 index 70bbe39..4ae2bd4 100644
15429 --- a/arch/x86/include/asm/stacktrace.h
15430 +++ b/arch/x86/include/asm/stacktrace.h
15431 @@ -11,28 +11,20 @@
15432
15433 extern int kstack_depth_to_print;
15434
15435 -struct thread_info;
15436 +struct task_struct;
15437 struct stacktrace_ops;
15438
15439 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15440 - unsigned long *stack,
15441 - unsigned long bp,
15442 - const struct stacktrace_ops *ops,
15443 - void *data,
15444 - unsigned long *end,
15445 - int *graph);
15446 +typedef unsigned long walk_stack_t(struct task_struct *task,
15447 + void *stack_start,
15448 + unsigned long *stack,
15449 + unsigned long bp,
15450 + const struct stacktrace_ops *ops,
15451 + void *data,
15452 + unsigned long *end,
15453 + int *graph);
15454
15455 -extern unsigned long
15456 -print_context_stack(struct thread_info *tinfo,
15457 - unsigned long *stack, unsigned long bp,
15458 - const struct stacktrace_ops *ops, void *data,
15459 - unsigned long *end, int *graph);
15460 -
15461 -extern unsigned long
15462 -print_context_stack_bp(struct thread_info *tinfo,
15463 - unsigned long *stack, unsigned long bp,
15464 - const struct stacktrace_ops *ops, void *data,
15465 - unsigned long *end, int *graph);
15466 +extern walk_stack_t print_context_stack;
15467 +extern walk_stack_t print_context_stack_bp;
15468
15469 /* Generic stack tracer with callbacks */
15470
15471 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15472 void (*address)(void *data, unsigned long address, int reliable);
15473 /* On negative return stop dumping */
15474 int (*stack)(void *data, char *name);
15475 - walk_stack_t walk_stack;
15476 + walk_stack_t *walk_stack;
15477 };
15478
15479 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15480 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15481 index 4ec45b3..a4f0a8a 100644
15482 --- a/arch/x86/include/asm/switch_to.h
15483 +++ b/arch/x86/include/asm/switch_to.h
15484 @@ -108,7 +108,7 @@ do { \
15485 "call __switch_to\n\t" \
15486 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15487 __switch_canary \
15488 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15489 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15490 "movq %%rax,%%rdi\n\t" \
15491 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15492 "jnz ret_from_fork\n\t" \
15493 @@ -119,7 +119,7 @@ do { \
15494 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15495 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15496 [_tif_fork] "i" (_TIF_FORK), \
15497 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15498 + [thread_info] "m" (current_tinfo), \
15499 [current_task] "m" (current_task) \
15500 __switch_canary_iparam \
15501 : "memory", "cc" __EXTRA_CLOBBER)
15502 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15503 index 2cd056e..0224df8 100644
15504 --- a/arch/x86/include/asm/thread_info.h
15505 +++ b/arch/x86/include/asm/thread_info.h
15506 @@ -10,6 +10,7 @@
15507 #include <linux/compiler.h>
15508 #include <asm/page.h>
15509 #include <asm/types.h>
15510 +#include <asm/percpu.h>
15511
15512 /*
15513 * low level task data that entry.S needs immediate access to
15514 @@ -23,7 +24,6 @@ struct exec_domain;
15515 #include <linux/atomic.h>
15516
15517 struct thread_info {
15518 - struct task_struct *task; /* main task structure */
15519 struct exec_domain *exec_domain; /* execution domain */
15520 __u32 flags; /* low level flags */
15521 __u32 status; /* thread synchronous flags */
15522 @@ -33,19 +33,13 @@ struct thread_info {
15523 mm_segment_t addr_limit;
15524 struct restart_block restart_block;
15525 void __user *sysenter_return;
15526 -#ifdef CONFIG_X86_32
15527 - unsigned long previous_esp; /* ESP of the previous stack in
15528 - case of nested (IRQ) stacks
15529 - */
15530 - __u8 supervisor_stack[0];
15531 -#endif
15532 + unsigned long lowest_stack;
15533 unsigned int sig_on_uaccess_error:1;
15534 unsigned int uaccess_err:1; /* uaccess failed */
15535 };
15536
15537 -#define INIT_THREAD_INFO(tsk) \
15538 +#define INIT_THREAD_INFO \
15539 { \
15540 - .task = &tsk, \
15541 .exec_domain = &default_exec_domain, \
15542 .flags = 0, \
15543 .cpu = 0, \
15544 @@ -56,7 +50,7 @@ struct thread_info {
15545 }, \
15546 }
15547
15548 -#define init_thread_info (init_thread_union.thread_info)
15549 +#define init_thread_info (init_thread_union.stack)
15550 #define init_stack (init_thread_union.stack)
15551
15552 #else /* !__ASSEMBLY__ */
15553 @@ -97,6 +91,7 @@ struct thread_info {
15554 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15555 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15556 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15557 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15558
15559 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15560 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15561 @@ -121,17 +116,18 @@ struct thread_info {
15562 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15563 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15564 #define _TIF_X32 (1 << TIF_X32)
15565 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15566
15567 /* work to do in syscall_trace_enter() */
15568 #define _TIF_WORK_SYSCALL_ENTRY \
15569 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15570 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15571 - _TIF_NOHZ)
15572 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15573
15574 /* work to do in syscall_trace_leave() */
15575 #define _TIF_WORK_SYSCALL_EXIT \
15576 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15577 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15578 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15579
15580 /* work to do on interrupt/exception return */
15581 #define _TIF_WORK_MASK \
15582 @@ -142,7 +138,7 @@ struct thread_info {
15583 /* work to do on any return to user space */
15584 #define _TIF_ALLWORK_MASK \
15585 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15586 - _TIF_NOHZ)
15587 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15588
15589 /* Only used for 64 bit */
15590 #define _TIF_DO_NOTIFY_MASK \
15591 @@ -158,45 +154,40 @@ struct thread_info {
15592
15593 #define PREEMPT_ACTIVE 0x10000000
15594
15595 -#ifdef CONFIG_X86_32
15596 -
15597 -#define STACK_WARN (THREAD_SIZE/8)
15598 -/*
15599 - * macros/functions for gaining access to the thread information structure
15600 - *
15601 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15602 - */
15603 -#ifndef __ASSEMBLY__
15604 -
15605 -
15606 -/* how to get the current stack pointer from C */
15607 -register unsigned long current_stack_pointer asm("esp") __used;
15608 -
15609 -/* how to get the thread information struct from C */
15610 -static inline struct thread_info *current_thread_info(void)
15611 -{
15612 - return (struct thread_info *)
15613 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15614 -}
15615 -
15616 -#else /* !__ASSEMBLY__ */
15617 -
15618 +#ifdef __ASSEMBLY__
15619 /* how to get the thread information struct from ASM */
15620 #define GET_THREAD_INFO(reg) \
15621 - movl $-THREAD_SIZE, reg; \
15622 - andl %esp, reg
15623 + mov PER_CPU_VAR(current_tinfo), reg
15624
15625 /* use this one if reg already contains %esp */
15626 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15627 - andl $-THREAD_SIZE, reg
15628 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15629 +#else
15630 +/* how to get the thread information struct from C */
15631 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15632 +
15633 +static __always_inline struct thread_info *current_thread_info(void)
15634 +{
15635 + return this_cpu_read_stable(current_tinfo);
15636 +}
15637 +#endif
15638 +
15639 +#ifdef CONFIG_X86_32
15640 +
15641 +#define STACK_WARN (THREAD_SIZE/8)
15642 +/*
15643 + * macros/functions for gaining access to the thread information structure
15644 + *
15645 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15646 + */
15647 +#ifndef __ASSEMBLY__
15648 +
15649 +/* how to get the current stack pointer from C */
15650 +register unsigned long current_stack_pointer asm("esp") __used;
15651
15652 #endif
15653
15654 #else /* X86_32 */
15655
15656 -#include <asm/percpu.h>
15657 -#define KERNEL_STACK_OFFSET (5*8)
15658 -
15659 /*
15660 * macros/functions for gaining access to the thread information structure
15661 * preempt_count needs to be 1 initially, until the scheduler is functional.
15662 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15663 #ifndef __ASSEMBLY__
15664 DECLARE_PER_CPU(unsigned long, kernel_stack);
15665
15666 -static inline struct thread_info *current_thread_info(void)
15667 -{
15668 - struct thread_info *ti;
15669 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15670 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15671 - return ti;
15672 -}
15673 -
15674 -#else /* !__ASSEMBLY__ */
15675 -
15676 -/* how to get the thread information struct from ASM */
15677 -#define GET_THREAD_INFO(reg) \
15678 - movq PER_CPU_VAR(kernel_stack),reg ; \
15679 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15680 -
15681 -/*
15682 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15683 - * a certain register (to be used in assembler memory operands).
15684 - */
15685 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15686 -
15687 +/* how to get the current stack pointer from C */
15688 +register unsigned long current_stack_pointer asm("rsp") __used;
15689 #endif
15690
15691 #endif /* !X86_32 */
15692 @@ -285,5 +257,12 @@ static inline bool is_ia32_task(void)
15693 extern void arch_task_cache_init(void);
15694 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15695 extern void arch_release_task_struct(struct task_struct *tsk);
15696 +
15697 +#define __HAVE_THREAD_FUNCTIONS
15698 +#define task_thread_info(task) (&(task)->tinfo)
15699 +#define task_stack_page(task) ((task)->stack)
15700 +#define setup_thread_stack(p, org) do {} while (0)
15701 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15702 +
15703 #endif
15704 #endif /* _ASM_X86_THREAD_INFO_H */
15705 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15706 index 5ee2687..70d5895 100644
15707 --- a/arch/x86/include/asm/uaccess.h
15708 +++ b/arch/x86/include/asm/uaccess.h
15709 @@ -7,6 +7,7 @@
15710 #include <linux/compiler.h>
15711 #include <linux/thread_info.h>
15712 #include <linux/string.h>
15713 +#include <linux/sched.h>
15714 #include <asm/asm.h>
15715 #include <asm/page.h>
15716 #include <asm/smap.h>
15717 @@ -29,7 +30,12 @@
15718
15719 #define get_ds() (KERNEL_DS)
15720 #define get_fs() (current_thread_info()->addr_limit)
15721 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15722 +void __set_fs(mm_segment_t x);
15723 +void set_fs(mm_segment_t x);
15724 +#else
15725 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15726 +#endif
15727
15728 #define segment_eq(a, b) ((a).seg == (b).seg)
15729
15730 @@ -77,8 +83,33 @@
15731 * checks that the pointer is in the user space range - after calling
15732 * this function, memory access functions may still return -EFAULT.
15733 */
15734 -#define access_ok(type, addr, size) \
15735 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15736 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15737 +#define access_ok(type, addr, size) \
15738 +({ \
15739 + long __size = size; \
15740 + unsigned long __addr = (unsigned long)addr; \
15741 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15742 + unsigned long __end_ao = __addr + __size - 1; \
15743 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15744 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15745 + while(__addr_ao <= __end_ao) { \
15746 + char __c_ao; \
15747 + __addr_ao += PAGE_SIZE; \
15748 + if (__size > PAGE_SIZE) \
15749 + cond_resched(); \
15750 + if (__get_user(__c_ao, (char __user *)__addr)) \
15751 + break; \
15752 + if (type != VERIFY_WRITE) { \
15753 + __addr = __addr_ao; \
15754 + continue; \
15755 + } \
15756 + if (__put_user(__c_ao, (char __user *)__addr)) \
15757 + break; \
15758 + __addr = __addr_ao; \
15759 + } \
15760 + } \
15761 + __ret_ao; \
15762 +})
15763
15764 /*
15765 * The exception table consists of pairs of addresses relative to the
15766 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15767 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15768 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15769
15770 -
15771 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15772 +#define __copyuser_seg "gs;"
15773 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15774 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15775 +#else
15776 +#define __copyuser_seg
15777 +#define __COPYUSER_SET_ES
15778 +#define __COPYUSER_RESTORE_ES
15779 +#endif
15780
15781 #ifdef CONFIG_X86_32
15782 #define __put_user_asm_u64(x, addr, err, errret) \
15783 asm volatile(ASM_STAC "\n" \
15784 - "1: movl %%eax,0(%2)\n" \
15785 - "2: movl %%edx,4(%2)\n" \
15786 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15787 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15788 "3: " ASM_CLAC "\n" \
15789 ".section .fixup,\"ax\"\n" \
15790 "4: movl %3,%0\n" \
15791 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15792
15793 #define __put_user_asm_ex_u64(x, addr) \
15794 asm volatile(ASM_STAC "\n" \
15795 - "1: movl %%eax,0(%1)\n" \
15796 - "2: movl %%edx,4(%1)\n" \
15797 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15798 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15799 "3: " ASM_CLAC "\n" \
15800 _ASM_EXTABLE_EX(1b, 2b) \
15801 _ASM_EXTABLE_EX(2b, 3b) \
15802 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15803 __typeof__(*(ptr)) __pu_val; \
15804 __chk_user_ptr(ptr); \
15805 might_fault(); \
15806 - __pu_val = x; \
15807 + __pu_val = (x); \
15808 switch (sizeof(*(ptr))) { \
15809 case 1: \
15810 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15811 @@ -345,7 +384,7 @@ do { \
15812
15813 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15814 asm volatile(ASM_STAC "\n" \
15815 - "1: mov"itype" %2,%"rtype"1\n" \
15816 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15817 "2: " ASM_CLAC "\n" \
15818 ".section .fixup,\"ax\"\n" \
15819 "3: mov %3,%0\n" \
15820 @@ -353,7 +392,7 @@ do { \
15821 " jmp 2b\n" \
15822 ".previous\n" \
15823 _ASM_EXTABLE(1b, 3b) \
15824 - : "=r" (err), ltype(x) \
15825 + : "=r" (err), ltype (x) \
15826 : "m" (__m(addr)), "i" (errret), "0" (err))
15827
15828 #define __get_user_size_ex(x, ptr, size) \
15829 @@ -378,7 +417,7 @@ do { \
15830 } while (0)
15831
15832 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15833 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15834 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15835 "2:\n" \
15836 _ASM_EXTABLE_EX(1b, 2b) \
15837 : ltype(x) : "m" (__m(addr)))
15838 @@ -395,13 +434,24 @@ do { \
15839 int __gu_err; \
15840 unsigned long __gu_val; \
15841 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15842 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15843 + (x) = (__typeof__(*(ptr)))__gu_val; \
15844 __gu_err; \
15845 })
15846
15847 /* FIXME: this hack is definitely wrong -AK */
15848 struct __large_struct { unsigned long buf[100]; };
15849 -#define __m(x) (*(struct __large_struct __user *)(x))
15850 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15851 +#define ____m(x) \
15852 +({ \
15853 + unsigned long ____x = (unsigned long)(x); \
15854 + if (____x < pax_user_shadow_base) \
15855 + ____x += pax_user_shadow_base; \
15856 + (typeof(x))____x; \
15857 +})
15858 +#else
15859 +#define ____m(x) (x)
15860 +#endif
15861 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15862
15863 /*
15864 * Tell gcc we read from memory instead of writing: this is because
15865 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15866 */
15867 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15868 asm volatile(ASM_STAC "\n" \
15869 - "1: mov"itype" %"rtype"1,%2\n" \
15870 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15871 "2: " ASM_CLAC "\n" \
15872 ".section .fixup,\"ax\"\n" \
15873 "3: mov %3,%0\n" \
15874 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15875 ".previous\n" \
15876 _ASM_EXTABLE(1b, 3b) \
15877 : "=r"(err) \
15878 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15879 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15880
15881 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15882 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15883 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15884 "2:\n" \
15885 _ASM_EXTABLE_EX(1b, 2b) \
15886 : : ltype(x), "m" (__m(addr)))
15887 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15888 * On error, the variable @x is set to zero.
15889 */
15890
15891 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15892 +#define __get_user(x, ptr) get_user((x), (ptr))
15893 +#else
15894 #define __get_user(x, ptr) \
15895 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15896 +#endif
15897
15898 /**
15899 * __put_user: - Write a simple value into user space, with less checking.
15900 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15901 * Returns zero on success, or -EFAULT on error.
15902 */
15903
15904 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15905 +#define __put_user(x, ptr) put_user((x), (ptr))
15906 +#else
15907 #define __put_user(x, ptr) \
15908 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15909 +#endif
15910
15911 #define __get_user_unaligned __get_user
15912 #define __put_user_unaligned __put_user
15913 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15914 #define get_user_ex(x, ptr) do { \
15915 unsigned long __gue_val; \
15916 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15917 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15918 + (x) = (__typeof__(*(ptr)))__gue_val; \
15919 } while (0)
15920
15921 #define put_user_try uaccess_try
15922 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15923 extern __must_check long strlen_user(const char __user *str);
15924 extern __must_check long strnlen_user(const char __user *str, long n);
15925
15926 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15927 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15928 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15929 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15930
15931 /*
15932 * movsl can be slow when source and dest are not both 8-byte aligned
15933 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15934 index 7f760a9..04b1c65 100644
15935 --- a/arch/x86/include/asm/uaccess_32.h
15936 +++ b/arch/x86/include/asm/uaccess_32.h
15937 @@ -11,15 +11,15 @@
15938 #include <asm/page.h>
15939
15940 unsigned long __must_check __copy_to_user_ll
15941 - (void __user *to, const void *from, unsigned long n);
15942 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15943 unsigned long __must_check __copy_from_user_ll
15944 - (void *to, const void __user *from, unsigned long n);
15945 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15946 unsigned long __must_check __copy_from_user_ll_nozero
15947 - (void *to, const void __user *from, unsigned long n);
15948 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15949 unsigned long __must_check __copy_from_user_ll_nocache
15950 - (void *to, const void __user *from, unsigned long n);
15951 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15952 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15953 - (void *to, const void __user *from, unsigned long n);
15954 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15955
15956 /**
15957 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15958 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15959 static __always_inline unsigned long __must_check
15960 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15961 {
15962 + if ((long)n < 0)
15963 + return n;
15964 +
15965 + check_object_size(from, n, true);
15966 +
15967 if (__builtin_constant_p(n)) {
15968 unsigned long ret;
15969
15970 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15971 __copy_to_user(void __user *to, const void *from, unsigned long n)
15972 {
15973 might_fault();
15974 +
15975 return __copy_to_user_inatomic(to, from, n);
15976 }
15977
15978 static __always_inline unsigned long
15979 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15980 {
15981 + if ((long)n < 0)
15982 + return n;
15983 +
15984 /* Avoid zeroing the tail if the copy fails..
15985 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15986 * but as the zeroing behaviour is only significant when n is not
15987 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15988 __copy_from_user(void *to, const void __user *from, unsigned long n)
15989 {
15990 might_fault();
15991 +
15992 + if ((long)n < 0)
15993 + return n;
15994 +
15995 + check_object_size(to, n, false);
15996 +
15997 if (__builtin_constant_p(n)) {
15998 unsigned long ret;
15999
16000 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16001 const void __user *from, unsigned long n)
16002 {
16003 might_fault();
16004 +
16005 + if ((long)n < 0)
16006 + return n;
16007 +
16008 if (__builtin_constant_p(n)) {
16009 unsigned long ret;
16010
16011 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16012 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16013 unsigned long n)
16014 {
16015 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16016 + if ((long)n < 0)
16017 + return n;
16018 +
16019 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16020 }
16021
16022 -unsigned long __must_check copy_to_user(void __user *to,
16023 - const void *from, unsigned long n);
16024 -unsigned long __must_check _copy_from_user(void *to,
16025 - const void __user *from,
16026 - unsigned long n);
16027 -
16028 +extern void copy_to_user_overflow(void)
16029 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16030 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16031 +#else
16032 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16033 +#endif
16034 +;
16035
16036 extern void copy_from_user_overflow(void)
16037 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16038 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16039 #endif
16040 ;
16041
16042 -static inline unsigned long __must_check copy_from_user(void *to,
16043 - const void __user *from,
16044 - unsigned long n)
16045 +/**
16046 + * copy_to_user: - Copy a block of data into user space.
16047 + * @to: Destination address, in user space.
16048 + * @from: Source address, in kernel space.
16049 + * @n: Number of bytes to copy.
16050 + *
16051 + * Context: User context only. This function may sleep.
16052 + *
16053 + * Copy data from kernel space to user space.
16054 + *
16055 + * Returns number of bytes that could not be copied.
16056 + * On success, this will be zero.
16057 + */
16058 +static inline unsigned long __must_check
16059 +copy_to_user(void __user *to, const void *from, unsigned long n)
16060 {
16061 - int sz = __compiletime_object_size(to);
16062 + size_t sz = __compiletime_object_size(from);
16063
16064 - if (likely(sz == -1 || sz >= n))
16065 - n = _copy_from_user(to, from, n);
16066 - else
16067 + if (unlikely(sz != (size_t)-1 && sz < n))
16068 + copy_to_user_overflow();
16069 + else if (access_ok(VERIFY_WRITE, to, n))
16070 + n = __copy_to_user(to, from, n);
16071 + return n;
16072 +}
16073 +
16074 +/**
16075 + * copy_from_user: - Copy a block of data from user space.
16076 + * @to: Destination address, in kernel space.
16077 + * @from: Source address, in user space.
16078 + * @n: Number of bytes to copy.
16079 + *
16080 + * Context: User context only. This function may sleep.
16081 + *
16082 + * Copy data from user space to kernel space.
16083 + *
16084 + * Returns number of bytes that could not be copied.
16085 + * On success, this will be zero.
16086 + *
16087 + * If some data could not be copied, this function will pad the copied
16088 + * data to the requested size using zero bytes.
16089 + */
16090 +static inline unsigned long __must_check
16091 +copy_from_user(void *to, const void __user *from, unsigned long n)
16092 +{
16093 + size_t sz = __compiletime_object_size(to);
16094 +
16095 + check_object_size(to, n, false);
16096 +
16097 + if (unlikely(sz != (size_t)-1 && sz < n))
16098 copy_from_user_overflow();
16099 -
16100 + else if (access_ok(VERIFY_READ, from, n))
16101 + n = __copy_from_user(to, from, n);
16102 + else if ((long)n > 0)
16103 + memset(to, 0, n);
16104 return n;
16105 }
16106
16107 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16108 index 142810c..1f2a0a7 100644
16109 --- a/arch/x86/include/asm/uaccess_64.h
16110 +++ b/arch/x86/include/asm/uaccess_64.h
16111 @@ -10,6 +10,9 @@
16112 #include <asm/alternative.h>
16113 #include <asm/cpufeature.h>
16114 #include <asm/page.h>
16115 +#include <asm/pgtable.h>
16116 +
16117 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16118
16119 /*
16120 * Copy To/From Userspace
16121 @@ -17,13 +20,13 @@
16122
16123 /* Handles exceptions in both to and from, but doesn't do access_ok */
16124 __must_check unsigned long
16125 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16126 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16127 __must_check unsigned long
16128 -copy_user_generic_string(void *to, const void *from, unsigned len);
16129 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16130 __must_check unsigned long
16131 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16132 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16133
16134 -static __always_inline __must_check unsigned long
16135 +static __always_inline __must_check __size_overflow(3) unsigned long
16136 copy_user_generic(void *to, const void *from, unsigned len)
16137 {
16138 unsigned ret;
16139 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16140 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16141 "=d" (len)),
16142 "1" (to), "2" (from), "3" (len)
16143 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16144 + : "memory", "rcx", "r8", "r9", "r11");
16145 return ret;
16146 }
16147
16148 +static __always_inline __must_check unsigned long
16149 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16150 +static __always_inline __must_check unsigned long
16151 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16152 __must_check unsigned long
16153 -_copy_to_user(void __user *to, const void *from, unsigned len);
16154 -__must_check unsigned long
16155 -_copy_from_user(void *to, const void __user *from, unsigned len);
16156 -__must_check unsigned long
16157 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16158 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16159 +
16160 +extern void copy_to_user_overflow(void)
16161 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16162 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16163 +#else
16164 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16165 +#endif
16166 +;
16167 +
16168 +extern void copy_from_user_overflow(void)
16169 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16170 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16171 +#else
16172 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16173 +#endif
16174 +;
16175
16176 static inline unsigned long __must_check copy_from_user(void *to,
16177 const void __user *from,
16178 unsigned long n)
16179 {
16180 - int sz = __compiletime_object_size(to);
16181 -
16182 might_fault();
16183 - if (likely(sz == -1 || sz >= n))
16184 - n = _copy_from_user(to, from, n);
16185 -#ifdef CONFIG_DEBUG_VM
16186 - else
16187 - WARN(1, "Buffer overflow detected!\n");
16188 -#endif
16189 +
16190 + check_object_size(to, n, false);
16191 +
16192 + if (access_ok(VERIFY_READ, from, n))
16193 + n = __copy_from_user(to, from, n);
16194 + else if (n < INT_MAX)
16195 + memset(to, 0, n);
16196 return n;
16197 }
16198
16199 static __always_inline __must_check
16200 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16201 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16202 {
16203 might_fault();
16204
16205 - return _copy_to_user(dst, src, size);
16206 + if (access_ok(VERIFY_WRITE, dst, size))
16207 + size = __copy_to_user(dst, src, size);
16208 + return size;
16209 }
16210
16211 static __always_inline __must_check
16212 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16213 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16214 {
16215 - int ret = 0;
16216 + size_t sz = __compiletime_object_size(dst);
16217 + unsigned ret = 0;
16218
16219 might_fault();
16220 +
16221 + if (size > INT_MAX)
16222 + return size;
16223 +
16224 + check_object_size(dst, size, false);
16225 +
16226 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16227 + if (!__access_ok(VERIFY_READ, src, size))
16228 + return size;
16229 +#endif
16230 +
16231 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16232 + copy_from_user_overflow();
16233 + return size;
16234 + }
16235 +
16236 if (!__builtin_constant_p(size))
16237 - return copy_user_generic(dst, (__force void *)src, size);
16238 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16239 switch (size) {
16240 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16241 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16242 ret, "b", "b", "=q", 1);
16243 return ret;
16244 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16245 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16246 ret, "w", "w", "=r", 2);
16247 return ret;
16248 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16249 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16250 ret, "l", "k", "=r", 4);
16251 return ret;
16252 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16253 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16254 ret, "q", "", "=r", 8);
16255 return ret;
16256 case 10:
16257 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16258 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16259 ret, "q", "", "=r", 10);
16260 if (unlikely(ret))
16261 return ret;
16262 __get_user_asm(*(u16 *)(8 + (char *)dst),
16263 - (u16 __user *)(8 + (char __user *)src),
16264 + (const u16 __user *)(8 + (const char __user *)src),
16265 ret, "w", "w", "=r", 2);
16266 return ret;
16267 case 16:
16268 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16269 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16270 ret, "q", "", "=r", 16);
16271 if (unlikely(ret))
16272 return ret;
16273 __get_user_asm(*(u64 *)(8 + (char *)dst),
16274 - (u64 __user *)(8 + (char __user *)src),
16275 + (const u64 __user *)(8 + (const char __user *)src),
16276 ret, "q", "", "=r", 8);
16277 return ret;
16278 default:
16279 - return copy_user_generic(dst, (__force void *)src, size);
16280 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16281 }
16282 }
16283
16284 static __always_inline __must_check
16285 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16286 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16287 {
16288 - int ret = 0;
16289 + size_t sz = __compiletime_object_size(src);
16290 + unsigned ret = 0;
16291
16292 might_fault();
16293 +
16294 + if (size > INT_MAX)
16295 + return size;
16296 +
16297 + check_object_size(src, size, true);
16298 +
16299 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16300 + if (!__access_ok(VERIFY_WRITE, dst, size))
16301 + return size;
16302 +#endif
16303 +
16304 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16305 + copy_to_user_overflow();
16306 + return size;
16307 + }
16308 +
16309 if (!__builtin_constant_p(size))
16310 - return copy_user_generic((__force void *)dst, src, size);
16311 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16312 switch (size) {
16313 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16314 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16315 ret, "b", "b", "iq", 1);
16316 return ret;
16317 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16318 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16319 ret, "w", "w", "ir", 2);
16320 return ret;
16321 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16322 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16323 ret, "l", "k", "ir", 4);
16324 return ret;
16325 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16326 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16327 ret, "q", "", "er", 8);
16328 return ret;
16329 case 10:
16330 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16331 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16332 ret, "q", "", "er", 10);
16333 if (unlikely(ret))
16334 return ret;
16335 asm("":::"memory");
16336 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16337 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16338 ret, "w", "w", "ir", 2);
16339 return ret;
16340 case 16:
16341 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16342 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16343 ret, "q", "", "er", 16);
16344 if (unlikely(ret))
16345 return ret;
16346 asm("":::"memory");
16347 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16348 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16349 ret, "q", "", "er", 8);
16350 return ret;
16351 default:
16352 - return copy_user_generic((__force void *)dst, src, size);
16353 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16354 }
16355 }
16356
16357 static __always_inline __must_check
16358 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16359 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16360 {
16361 - int ret = 0;
16362 + unsigned ret = 0;
16363
16364 might_fault();
16365 +
16366 + if (size > INT_MAX)
16367 + return size;
16368 +
16369 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16370 + if (!__access_ok(VERIFY_READ, src, size))
16371 + return size;
16372 + if (!__access_ok(VERIFY_WRITE, dst, size))
16373 + return size;
16374 +#endif
16375 +
16376 if (!__builtin_constant_p(size))
16377 - return copy_user_generic((__force void *)dst,
16378 - (__force void *)src, size);
16379 + return copy_user_generic((__force_kernel void *)____m(dst),
16380 + (__force_kernel const void *)____m(src), size);
16381 switch (size) {
16382 case 1: {
16383 u8 tmp;
16384 - __get_user_asm(tmp, (u8 __user *)src,
16385 + __get_user_asm(tmp, (const u8 __user *)src,
16386 ret, "b", "b", "=q", 1);
16387 if (likely(!ret))
16388 __put_user_asm(tmp, (u8 __user *)dst,
16389 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16390 }
16391 case 2: {
16392 u16 tmp;
16393 - __get_user_asm(tmp, (u16 __user *)src,
16394 + __get_user_asm(tmp, (const u16 __user *)src,
16395 ret, "w", "w", "=r", 2);
16396 if (likely(!ret))
16397 __put_user_asm(tmp, (u16 __user *)dst,
16398 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16399
16400 case 4: {
16401 u32 tmp;
16402 - __get_user_asm(tmp, (u32 __user *)src,
16403 + __get_user_asm(tmp, (const u32 __user *)src,
16404 ret, "l", "k", "=r", 4);
16405 if (likely(!ret))
16406 __put_user_asm(tmp, (u32 __user *)dst,
16407 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16408 }
16409 case 8: {
16410 u64 tmp;
16411 - __get_user_asm(tmp, (u64 __user *)src,
16412 + __get_user_asm(tmp, (const u64 __user *)src,
16413 ret, "q", "", "=r", 8);
16414 if (likely(!ret))
16415 __put_user_asm(tmp, (u64 __user *)dst,
16416 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16417 return ret;
16418 }
16419 default:
16420 - return copy_user_generic((__force void *)dst,
16421 - (__force void *)src, size);
16422 + return copy_user_generic((__force_kernel void *)____m(dst),
16423 + (__force_kernel const void *)____m(src), size);
16424 }
16425 }
16426
16427 static __must_check __always_inline int
16428 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16429 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16430 {
16431 - return copy_user_generic(dst, (__force const void *)src, size);
16432 + if (size > INT_MAX)
16433 + return size;
16434 +
16435 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16436 + if (!__access_ok(VERIFY_READ, src, size))
16437 + return size;
16438 +#endif
16439 +
16440 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16441 }
16442
16443 -static __must_check __always_inline int
16444 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16445 +static __must_check __always_inline unsigned long
16446 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16447 {
16448 - return copy_user_generic((__force void *)dst, src, size);
16449 + if (size > INT_MAX)
16450 + return size;
16451 +
16452 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16453 + if (!__access_ok(VERIFY_WRITE, dst, size))
16454 + return size;
16455 +#endif
16456 +
16457 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16458 }
16459
16460 -extern long __copy_user_nocache(void *dst, const void __user *src,
16461 - unsigned size, int zerorest);
16462 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16463 + unsigned long size, int zerorest) __size_overflow(3);
16464
16465 -static inline int
16466 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16467 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16468 {
16469 might_sleep();
16470 +
16471 + if (size > INT_MAX)
16472 + return size;
16473 +
16474 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16475 + if (!__access_ok(VERIFY_READ, src, size))
16476 + return size;
16477 +#endif
16478 +
16479 return __copy_user_nocache(dst, src, size, 1);
16480 }
16481
16482 -static inline int
16483 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16484 - unsigned size)
16485 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16486 + unsigned long size)
16487 {
16488 + if (size > INT_MAX)
16489 + return size;
16490 +
16491 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16492 + if (!__access_ok(VERIFY_READ, src, size))
16493 + return size;
16494 +#endif
16495 +
16496 return __copy_user_nocache(dst, src, size, 0);
16497 }
16498
16499 -unsigned long
16500 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16501 +extern unsigned long
16502 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16503
16504 #endif /* _ASM_X86_UACCESS_64_H */
16505 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16506 index 5b238981..77fdd78 100644
16507 --- a/arch/x86/include/asm/word-at-a-time.h
16508 +++ b/arch/x86/include/asm/word-at-a-time.h
16509 @@ -11,7 +11,7 @@
16510 * and shift, for example.
16511 */
16512 struct word_at_a_time {
16513 - const unsigned long one_bits, high_bits;
16514 + unsigned long one_bits, high_bits;
16515 };
16516
16517 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16518 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16519 index d8d9922..bf6cecb 100644
16520 --- a/arch/x86/include/asm/x86_init.h
16521 +++ b/arch/x86/include/asm/x86_init.h
16522 @@ -129,7 +129,7 @@ struct x86_init_ops {
16523 struct x86_init_timers timers;
16524 struct x86_init_iommu iommu;
16525 struct x86_init_pci pci;
16526 -};
16527 +} __no_const;
16528
16529 /**
16530 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16531 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16532 void (*setup_percpu_clockev)(void);
16533 void (*early_percpu_clock_init)(void);
16534 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16535 -};
16536 +} __no_const;
16537
16538 /**
16539 * struct x86_platform_ops - platform specific runtime functions
16540 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16541 void (*save_sched_clock_state)(void);
16542 void (*restore_sched_clock_state)(void);
16543 void (*apic_post_init)(void);
16544 -};
16545 +} __no_const;
16546
16547 struct pci_dev;
16548 struct msi_msg;
16549 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16550 void (*teardown_msi_irqs)(struct pci_dev *dev);
16551 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16552 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16553 -};
16554 +} __no_const;
16555
16556 struct IO_APIC_route_entry;
16557 struct io_apic_irq_attr;
16558 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16559 unsigned int destination, int vector,
16560 struct io_apic_irq_attr *attr);
16561 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16562 -};
16563 +} __no_const;
16564
16565 extern struct x86_init_ops x86_init;
16566 extern struct x86_cpuinit_ops x86_cpuinit;
16567 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16568 index 0415cda..b43d877 100644
16569 --- a/arch/x86/include/asm/xsave.h
16570 +++ b/arch/x86/include/asm/xsave.h
16571 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16572 return -EFAULT;
16573
16574 __asm__ __volatile__(ASM_STAC "\n"
16575 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16576 + "1:"
16577 + __copyuser_seg
16578 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16579 "2: " ASM_CLAC "\n"
16580 ".section .fixup,\"ax\"\n"
16581 "3: movl $-1,%[err]\n"
16582 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16583 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16584 {
16585 int err;
16586 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16587 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16588 u32 lmask = mask;
16589 u32 hmask = mask >> 32;
16590
16591 __asm__ __volatile__(ASM_STAC "\n"
16592 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16593 + "1:"
16594 + __copyuser_seg
16595 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16596 "2: " ASM_CLAC "\n"
16597 ".section .fixup,\"ax\"\n"
16598 "3: movl $-1,%[err]\n"
16599 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16600 index bbae024..e1528f9 100644
16601 --- a/arch/x86/include/uapi/asm/e820.h
16602 +++ b/arch/x86/include/uapi/asm/e820.h
16603 @@ -63,7 +63,7 @@ struct e820map {
16604 #define ISA_START_ADDRESS 0xa0000
16605 #define ISA_END_ADDRESS 0x100000
16606
16607 -#define BIOS_BEGIN 0x000a0000
16608 +#define BIOS_BEGIN 0x000c0000
16609 #define BIOS_END 0x00100000
16610
16611 #define BIOS_ROM_BASE 0xffe00000
16612 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16613 index 7bd3bd3..5dac791 100644
16614 --- a/arch/x86/kernel/Makefile
16615 +++ b/arch/x86/kernel/Makefile
16616 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16617 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16618 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16619 obj-y += probe_roms.o
16620 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16621 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16622 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16623 obj-y += syscall_$(BITS).o
16624 obj-$(CONFIG_X86_64) += vsyscall_64.o
16625 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16626 index 230c8ea..f915130 100644
16627 --- a/arch/x86/kernel/acpi/boot.c
16628 +++ b/arch/x86/kernel/acpi/boot.c
16629 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16630 * If your system is blacklisted here, but you find that acpi=force
16631 * works for you, please contact linux-acpi@vger.kernel.org
16632 */
16633 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16634 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16635 /*
16636 * Boxes that need ACPI disabled
16637 */
16638 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16639 };
16640
16641 /* second table for DMI checks that should run after early-quirks */
16642 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16643 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16644 /*
16645 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16646 * which includes some code which overrides all temperature
16647 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16648 index 0532f5d..36afc0a 100644
16649 --- a/arch/x86/kernel/acpi/sleep.c
16650 +++ b/arch/x86/kernel/acpi/sleep.c
16651 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16652 #else /* CONFIG_64BIT */
16653 #ifdef CONFIG_SMP
16654 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16655 +
16656 + pax_open_kernel();
16657 early_gdt_descr.address =
16658 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16659 + pax_close_kernel();
16660 +
16661 initial_gs = per_cpu_offset(smp_processor_id());
16662 #endif
16663 initial_code = (unsigned long)wakeup_long64;
16664 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16665 index 13ab720..95d5442 100644
16666 --- a/arch/x86/kernel/acpi/wakeup_32.S
16667 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16668 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16669 # and restore the stack ... but you need gdt for this to work
16670 movl saved_context_esp, %esp
16671
16672 - movl %cs:saved_magic, %eax
16673 - cmpl $0x12345678, %eax
16674 + cmpl $0x12345678, saved_magic
16675 jne bogus_magic
16676
16677 # jump to place where we left off
16678 - movl saved_eip, %eax
16679 - jmp *%eax
16680 + jmp *(saved_eip)
16681
16682 bogus_magic:
16683 jmp bogus_magic
16684 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16685 index ef5ccca..bd83949 100644
16686 --- a/arch/x86/kernel/alternative.c
16687 +++ b/arch/x86/kernel/alternative.c
16688 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16689 */
16690 for (a = start; a < end; a++) {
16691 instr = (u8 *)&a->instr_offset + a->instr_offset;
16692 +
16693 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16694 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16695 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16696 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16697 +#endif
16698 +
16699 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16700 BUG_ON(a->replacementlen > a->instrlen);
16701 BUG_ON(a->instrlen > sizeof(insnbuf));
16702 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16703 for (poff = start; poff < end; poff++) {
16704 u8 *ptr = (u8 *)poff + *poff;
16705
16706 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16707 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16708 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16709 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16710 +#endif
16711 +
16712 if (!*poff || ptr < text || ptr >= text_end)
16713 continue;
16714 /* turn DS segment override prefix into lock prefix */
16715 - if (*ptr == 0x3e)
16716 + if (*ktla_ktva(ptr) == 0x3e)
16717 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16718 }
16719 mutex_unlock(&text_mutex);
16720 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16721 for (poff = start; poff < end; poff++) {
16722 u8 *ptr = (u8 *)poff + *poff;
16723
16724 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16725 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16726 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16727 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16728 +#endif
16729 +
16730 if (!*poff || ptr < text || ptr >= text_end)
16731 continue;
16732 /* turn lock prefix into DS segment override prefix */
16733 - if (*ptr == 0xf0)
16734 + if (*ktla_ktva(ptr) == 0xf0)
16735 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16736 }
16737 mutex_unlock(&text_mutex);
16738 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16739
16740 BUG_ON(p->len > MAX_PATCH_LEN);
16741 /* prep the buffer with the original instructions */
16742 - memcpy(insnbuf, p->instr, p->len);
16743 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16744 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16745 (unsigned long)p->instr, p->len);
16746
16747 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16748 if (!uniproc_patched || num_possible_cpus() == 1)
16749 free_init_pages("SMP alternatives",
16750 (unsigned long)__smp_locks,
16751 - (unsigned long)__smp_locks_end);
16752 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16753 #endif
16754
16755 apply_paravirt(__parainstructions, __parainstructions_end);
16756 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16757 * instructions. And on the local CPU you need to be protected again NMI or MCE
16758 * handlers seeing an inconsistent instruction while you patch.
16759 */
16760 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16761 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16762 size_t len)
16763 {
16764 unsigned long flags;
16765 local_irq_save(flags);
16766 - memcpy(addr, opcode, len);
16767 +
16768 + pax_open_kernel();
16769 + memcpy(ktla_ktva(addr), opcode, len);
16770 sync_core();
16771 + pax_close_kernel();
16772 +
16773 local_irq_restore(flags);
16774 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16775 that causes hangs on some VIA CPUs. */
16776 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16777 */
16778 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16779 {
16780 - unsigned long flags;
16781 - char *vaddr;
16782 + unsigned char *vaddr = ktla_ktva(addr);
16783 struct page *pages[2];
16784 - int i;
16785 + size_t i;
16786
16787 if (!core_kernel_text((unsigned long)addr)) {
16788 - pages[0] = vmalloc_to_page(addr);
16789 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16790 + pages[0] = vmalloc_to_page(vaddr);
16791 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16792 } else {
16793 - pages[0] = virt_to_page(addr);
16794 + pages[0] = virt_to_page(vaddr);
16795 WARN_ON(!PageReserved(pages[0]));
16796 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16797 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16798 }
16799 BUG_ON(!pages[0]);
16800 - local_irq_save(flags);
16801 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16802 - if (pages[1])
16803 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16804 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16805 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16806 - clear_fixmap(FIX_TEXT_POKE0);
16807 - if (pages[1])
16808 - clear_fixmap(FIX_TEXT_POKE1);
16809 - local_flush_tlb();
16810 - sync_core();
16811 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16812 - that causes hangs on some VIA CPUs. */
16813 + text_poke_early(addr, opcode, len);
16814 for (i = 0; i < len; i++)
16815 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16816 - local_irq_restore(flags);
16817 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16818 return addr;
16819 }
16820
16821 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16822 index 904611b..004dde6 100644
16823 --- a/arch/x86/kernel/apic/apic.c
16824 +++ b/arch/x86/kernel/apic/apic.c
16825 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16826 /*
16827 * Debug level, exported for io_apic.c
16828 */
16829 -unsigned int apic_verbosity;
16830 +int apic_verbosity;
16831
16832 int pic_mode;
16833
16834 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16835 apic_write(APIC_ESR, 0);
16836 v1 = apic_read(APIC_ESR);
16837 ack_APIC_irq();
16838 - atomic_inc(&irq_err_count);
16839 + atomic_inc_unchecked(&irq_err_count);
16840
16841 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16842 smp_processor_id(), v0 , v1);
16843 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16844 index 00c77cf..2dc6a2d 100644
16845 --- a/arch/x86/kernel/apic/apic_flat_64.c
16846 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16847 @@ -157,7 +157,7 @@ static int flat_probe(void)
16848 return 1;
16849 }
16850
16851 -static struct apic apic_flat = {
16852 +static struct apic apic_flat __read_only = {
16853 .name = "flat",
16854 .probe = flat_probe,
16855 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16856 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16857 return 0;
16858 }
16859
16860 -static struct apic apic_physflat = {
16861 +static struct apic apic_physflat __read_only = {
16862
16863 .name = "physical flat",
16864 .probe = physflat_probe,
16865 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16866 index e145f28..2752888 100644
16867 --- a/arch/x86/kernel/apic/apic_noop.c
16868 +++ b/arch/x86/kernel/apic/apic_noop.c
16869 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16870 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16871 }
16872
16873 -struct apic apic_noop = {
16874 +struct apic apic_noop __read_only = {
16875 .name = "noop",
16876 .probe = noop_probe,
16877 .acpi_madt_oem_check = NULL,
16878 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16879 index d50e364..543bee3 100644
16880 --- a/arch/x86/kernel/apic/bigsmp_32.c
16881 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16882 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16883 return dmi_bigsmp;
16884 }
16885
16886 -static struct apic apic_bigsmp = {
16887 +static struct apic apic_bigsmp __read_only = {
16888
16889 .name = "bigsmp",
16890 .probe = probe_bigsmp,
16891 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16892 index 0874799..a7a7892 100644
16893 --- a/arch/x86/kernel/apic/es7000_32.c
16894 +++ b/arch/x86/kernel/apic/es7000_32.c
16895 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16896 return ret && es7000_apic_is_cluster();
16897 }
16898
16899 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16900 -static struct apic __refdata apic_es7000_cluster = {
16901 +static struct apic apic_es7000_cluster __read_only = {
16902
16903 .name = "es7000",
16904 .probe = probe_es7000,
16905 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16906 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16907 };
16908
16909 -static struct apic __refdata apic_es7000 = {
16910 +static struct apic apic_es7000 __read_only = {
16911
16912 .name = "es7000",
16913 .probe = probe_es7000,
16914 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16915 index 9ed796c..e930fe4 100644
16916 --- a/arch/x86/kernel/apic/io_apic.c
16917 +++ b/arch/x86/kernel/apic/io_apic.c
16918 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16919 }
16920 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16921
16922 -void lock_vector_lock(void)
16923 +void lock_vector_lock(void) __acquires(vector_lock)
16924 {
16925 /* Used to the online set of cpus does not change
16926 * during assign_irq_vector.
16927 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16928 raw_spin_lock(&vector_lock);
16929 }
16930
16931 -void unlock_vector_lock(void)
16932 +void unlock_vector_lock(void) __releases(vector_lock)
16933 {
16934 raw_spin_unlock(&vector_lock);
16935 }
16936 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16937 ack_APIC_irq();
16938 }
16939
16940 -atomic_t irq_mis_count;
16941 +atomic_unchecked_t irq_mis_count;
16942
16943 #ifdef CONFIG_GENERIC_PENDING_IRQ
16944 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16945 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16946 * at the cpu.
16947 */
16948 if (!(v & (1 << (i & 0x1f)))) {
16949 - atomic_inc(&irq_mis_count);
16950 + atomic_inc_unchecked(&irq_mis_count);
16951
16952 eoi_ioapic_irq(irq, cfg);
16953 }
16954 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16955 index d661ee9..791fd33 100644
16956 --- a/arch/x86/kernel/apic/numaq_32.c
16957 +++ b/arch/x86/kernel/apic/numaq_32.c
16958 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16959 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16960 }
16961
16962 -/* Use __refdata to keep false positive warning calm. */
16963 -static struct apic __refdata apic_numaq = {
16964 +static struct apic apic_numaq __read_only = {
16965
16966 .name = "NUMAQ",
16967 .probe = probe_numaq,
16968 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16969 index eb35ef9..f184a21 100644
16970 --- a/arch/x86/kernel/apic/probe_32.c
16971 +++ b/arch/x86/kernel/apic/probe_32.c
16972 @@ -72,7 +72,7 @@ static int probe_default(void)
16973 return 1;
16974 }
16975
16976 -static struct apic apic_default = {
16977 +static struct apic apic_default __read_only = {
16978
16979 .name = "default",
16980 .probe = probe_default,
16981 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16982 index 77c95c0..434f8a4 100644
16983 --- a/arch/x86/kernel/apic/summit_32.c
16984 +++ b/arch/x86/kernel/apic/summit_32.c
16985 @@ -486,7 +486,7 @@ void setup_summit(void)
16986 }
16987 #endif
16988
16989 -static struct apic apic_summit = {
16990 +static struct apic apic_summit __read_only = {
16991
16992 .name = "summit",
16993 .probe = probe_summit,
16994 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16995 index c88baa4..757aee1 100644
16996 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16997 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16998 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16999 return notifier_from_errno(err);
17000 }
17001
17002 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17003 +static struct notifier_block x2apic_cpu_notifier = {
17004 .notifier_call = update_clusterinfo,
17005 };
17006
17007 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17008 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17009 }
17010
17011 -static struct apic apic_x2apic_cluster = {
17012 +static struct apic apic_x2apic_cluster __read_only = {
17013
17014 .name = "cluster x2apic",
17015 .probe = x2apic_cluster_probe,
17016 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17017 index 562a76d..a003c0f 100644
17018 --- a/arch/x86/kernel/apic/x2apic_phys.c
17019 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17020 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17021 return apic == &apic_x2apic_phys;
17022 }
17023
17024 -static struct apic apic_x2apic_phys = {
17025 +static struct apic apic_x2apic_phys __read_only = {
17026
17027 .name = "physical x2apic",
17028 .probe = x2apic_phys_probe,
17029 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17030 index 794f6eb..67e1db2 100644
17031 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17032 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17033 @@ -342,7 +342,7 @@ static int uv_probe(void)
17034 return apic == &apic_x2apic_uv_x;
17035 }
17036
17037 -static struct apic __refdata apic_x2apic_uv_x = {
17038 +static struct apic apic_x2apic_uv_x __read_only = {
17039
17040 .name = "UV large system",
17041 .probe = uv_probe,
17042 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17043 index 66b5faf..3442423 100644
17044 --- a/arch/x86/kernel/apm_32.c
17045 +++ b/arch/x86/kernel/apm_32.c
17046 @@ -434,7 +434,7 @@ static DEFINE_MUTEX(apm_mutex);
17047 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17048 * even though they are called in protected mode.
17049 */
17050 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17051 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17052 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17053
17054 static const char driver_version[] = "1.16ac"; /* no spaces */
17055 @@ -612,7 +612,10 @@ static long __apm_bios_call(void *_call)
17056 BUG_ON(cpu != 0);
17057 gdt = get_cpu_gdt_table(cpu);
17058 save_desc_40 = gdt[0x40 / 8];
17059 +
17060 + pax_open_kernel();
17061 gdt[0x40 / 8] = bad_bios_desc;
17062 + pax_close_kernel();
17063
17064 apm_irq_save(flags);
17065 APM_DO_SAVE_SEGS;
17066 @@ -621,7 +624,11 @@ static long __apm_bios_call(void *_call)
17067 &call->esi);
17068 APM_DO_RESTORE_SEGS;
17069 apm_irq_restore(flags);
17070 +
17071 + pax_open_kernel();
17072 gdt[0x40 / 8] = save_desc_40;
17073 + pax_close_kernel();
17074 +
17075 put_cpu();
17076
17077 return call->eax & 0xff;
17078 @@ -688,7 +695,10 @@ static long __apm_bios_call_simple(void *_call)
17079 BUG_ON(cpu != 0);
17080 gdt = get_cpu_gdt_table(cpu);
17081 save_desc_40 = gdt[0x40 / 8];
17082 +
17083 + pax_open_kernel();
17084 gdt[0x40 / 8] = bad_bios_desc;
17085 + pax_close_kernel();
17086
17087 apm_irq_save(flags);
17088 APM_DO_SAVE_SEGS;
17089 @@ -696,7 +706,11 @@ static long __apm_bios_call_simple(void *_call)
17090 &call->eax);
17091 APM_DO_RESTORE_SEGS;
17092 apm_irq_restore(flags);
17093 +
17094 + pax_open_kernel();
17095 gdt[0x40 / 8] = save_desc_40;
17096 + pax_close_kernel();
17097 +
17098 put_cpu();
17099 return error;
17100 }
17101 @@ -2363,12 +2377,15 @@ static int __init apm_init(void)
17102 * code to that CPU.
17103 */
17104 gdt = get_cpu_gdt_table(0);
17105 +
17106 + pax_open_kernel();
17107 set_desc_base(&gdt[APM_CS >> 3],
17108 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17109 set_desc_base(&gdt[APM_CS_16 >> 3],
17110 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17111 set_desc_base(&gdt[APM_DS >> 3],
17112 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17113 + pax_close_kernel();
17114
17115 proc_create("apm", 0, NULL, &apm_file_ops);
17116
17117 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17118 index 2861082..6d4718e 100644
17119 --- a/arch/x86/kernel/asm-offsets.c
17120 +++ b/arch/x86/kernel/asm-offsets.c
17121 @@ -33,6 +33,8 @@ void common(void) {
17122 OFFSET(TI_status, thread_info, status);
17123 OFFSET(TI_addr_limit, thread_info, addr_limit);
17124 OFFSET(TI_preempt_count, thread_info, preempt_count);
17125 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17126 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17127
17128 BLANK();
17129 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17130 @@ -53,8 +55,26 @@ void common(void) {
17131 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17132 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17133 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17134 +
17135 +#ifdef CONFIG_PAX_KERNEXEC
17136 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17137 #endif
17138
17139 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17140 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17141 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17142 +#ifdef CONFIG_X86_64
17143 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17144 +#endif
17145 +#endif
17146 +
17147 +#endif
17148 +
17149 + BLANK();
17150 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17151 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17152 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17153 +
17154 #ifdef CONFIG_XEN
17155 BLANK();
17156 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17157 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17158 index 1b4754f..fbb4227 100644
17159 --- a/arch/x86/kernel/asm-offsets_64.c
17160 +++ b/arch/x86/kernel/asm-offsets_64.c
17161 @@ -76,6 +76,7 @@ int main(void)
17162 BLANK();
17163 #undef ENTRY
17164
17165 + DEFINE(TSS_size, sizeof(struct tss_struct));
17166 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17167 BLANK();
17168
17169 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17170 index a0e067d..9c7db16 100644
17171 --- a/arch/x86/kernel/cpu/Makefile
17172 +++ b/arch/x86/kernel/cpu/Makefile
17173 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17174 CFLAGS_REMOVE_perf_event.o = -pg
17175 endif
17176
17177 -# Make sure load_percpu_segment has no stackprotector
17178 -nostackp := $(call cc-option, -fno-stack-protector)
17179 -CFLAGS_common.o := $(nostackp)
17180 -
17181 obj-y := intel_cacheinfo.o scattered.o topology.o
17182 obj-y += proc.o capflags.o powerflags.o common.o
17183 obj-y += vmware.o hypervisor.o mshyperv.o
17184 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17185 index fa96eb0..03efe73 100644
17186 --- a/arch/x86/kernel/cpu/amd.c
17187 +++ b/arch/x86/kernel/cpu/amd.c
17188 @@ -737,7 +737,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17189 unsigned int size)
17190 {
17191 /* AMD errata T13 (order #21922) */
17192 - if ((c->x86 == 6)) {
17193 + if (c->x86 == 6) {
17194 /* Duron Rev A0 */
17195 if (c->x86_model == 3 && c->x86_mask == 0)
17196 size = 64;
17197 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17198 index d814772..c615653 100644
17199 --- a/arch/x86/kernel/cpu/common.c
17200 +++ b/arch/x86/kernel/cpu/common.c
17201 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17202
17203 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17204
17205 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17206 -#ifdef CONFIG_X86_64
17207 - /*
17208 - * We need valid kernel segments for data and code in long mode too
17209 - * IRET will check the segment types kkeil 2000/10/28
17210 - * Also sysret mandates a special GDT layout
17211 - *
17212 - * TLS descriptors are currently at a different place compared to i386.
17213 - * Hopefully nobody expects them at a fixed place (Wine?)
17214 - */
17215 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17216 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17217 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17218 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17219 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17220 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17221 -#else
17222 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17223 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17224 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17225 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17226 - /*
17227 - * Segments used for calling PnP BIOS have byte granularity.
17228 - * They code segments and data segments have fixed 64k limits,
17229 - * the transfer segment sizes are set at run time.
17230 - */
17231 - /* 32-bit code */
17232 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17233 - /* 16-bit code */
17234 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17235 - /* 16-bit data */
17236 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17237 - /* 16-bit data */
17238 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17239 - /* 16-bit data */
17240 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17241 - /*
17242 - * The APM segments have byte granularity and their bases
17243 - * are set at run time. All have 64k limits.
17244 - */
17245 - /* 32-bit code */
17246 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17247 - /* 16-bit code */
17248 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17249 - /* data */
17250 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17251 -
17252 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17253 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17254 - GDT_STACK_CANARY_INIT
17255 -#endif
17256 -} };
17257 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17258 -
17259 static int __init x86_xsave_setup(char *s)
17260 {
17261 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17262 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17263 {
17264 struct desc_ptr gdt_descr;
17265
17266 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17267 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17268 gdt_descr.size = GDT_SIZE - 1;
17269 load_gdt(&gdt_descr);
17270 /* Reload the per-cpu base */
17271 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17272 /* Filter out anything that depends on CPUID levels we don't have */
17273 filter_cpuid_features(c, true);
17274
17275 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17276 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17277 +#endif
17278 +
17279 /* If the model name is still unset, do table lookup. */
17280 if (!c->x86_model_id[0]) {
17281 const char *p;
17282 @@ -1065,10 +1015,12 @@ static __init int setup_disablecpuid(char *arg)
17283 }
17284 __setup("clearcpuid=", setup_disablecpuid);
17285
17286 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17287 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17288 +
17289 #ifdef CONFIG_X86_64
17290 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17291 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17292 - (unsigned long) nmi_idt_table };
17293 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17294
17295 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17296 irq_stack_union) __aligned(PAGE_SIZE);
17297 @@ -1082,7 +1034,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17298 EXPORT_PER_CPU_SYMBOL(current_task);
17299
17300 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17301 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17302 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17303 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17304
17305 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17306 @@ -1227,7 +1179,7 @@ void __cpuinit cpu_init(void)
17307 load_ucode_ap();
17308
17309 cpu = stack_smp_processor_id();
17310 - t = &per_cpu(init_tss, cpu);
17311 + t = init_tss + cpu;
17312 oist = &per_cpu(orig_ist, cpu);
17313
17314 #ifdef CONFIG_NUMA
17315 @@ -1253,7 +1205,7 @@ void __cpuinit cpu_init(void)
17316 switch_to_new_gdt(cpu);
17317 loadsegment(fs, 0);
17318
17319 - load_idt((const struct desc_ptr *)&idt_descr);
17320 + load_idt(&idt_descr);
17321
17322 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17323 syscall_init();
17324 @@ -1262,7 +1214,6 @@ void __cpuinit cpu_init(void)
17325 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17326 barrier();
17327
17328 - x86_configure_nx();
17329 enable_x2apic();
17330
17331 /*
17332 @@ -1314,7 +1265,7 @@ void __cpuinit cpu_init(void)
17333 {
17334 int cpu = smp_processor_id();
17335 struct task_struct *curr = current;
17336 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17337 + struct tss_struct *t = init_tss + cpu;
17338 struct thread_struct *thread = &curr->thread;
17339
17340 show_ucode_info_early();
17341 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17342 index 1905ce9..a7ac587 100644
17343 --- a/arch/x86/kernel/cpu/intel.c
17344 +++ b/arch/x86/kernel/cpu/intel.c
17345 @@ -173,7 +173,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17346 * Update the IDT descriptor and reload the IDT so that
17347 * it uses the read-only mapped virtual address.
17348 */
17349 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17350 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17351 load_idt(&idt_descr);
17352 }
17353 #endif
17354 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17355 index 7c6f7d5..8cac382 100644
17356 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17357 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17358 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17359 };
17360
17361 #ifdef CONFIG_AMD_NB
17362 +static struct attribute *default_attrs_amd_nb[] = {
17363 + &type.attr,
17364 + &level.attr,
17365 + &coherency_line_size.attr,
17366 + &physical_line_partition.attr,
17367 + &ways_of_associativity.attr,
17368 + &number_of_sets.attr,
17369 + &size.attr,
17370 + &shared_cpu_map.attr,
17371 + &shared_cpu_list.attr,
17372 + NULL,
17373 + NULL,
17374 + NULL,
17375 + NULL
17376 +};
17377 +
17378 static struct attribute ** __cpuinit amd_l3_attrs(void)
17379 {
17380 static struct attribute **attrs;
17381 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17382
17383 n = ARRAY_SIZE(default_attrs);
17384
17385 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17386 - n += 2;
17387 -
17388 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17389 - n += 1;
17390 -
17391 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17392 - if (attrs == NULL)
17393 - return attrs = default_attrs;
17394 -
17395 - for (n = 0; default_attrs[n]; n++)
17396 - attrs[n] = default_attrs[n];
17397 + attrs = default_attrs_amd_nb;
17398
17399 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17400 attrs[n++] = &cache_disable_0.attr;
17401 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17402 .default_attrs = default_attrs,
17403 };
17404
17405 +#ifdef CONFIG_AMD_NB
17406 +static struct kobj_type ktype_cache_amd_nb = {
17407 + .sysfs_ops = &sysfs_ops,
17408 + .default_attrs = default_attrs_amd_nb,
17409 +};
17410 +#endif
17411 +
17412 static struct kobj_type ktype_percpu_entry = {
17413 .sysfs_ops = &sysfs_ops,
17414 };
17415 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17416 return retval;
17417 }
17418
17419 +#ifdef CONFIG_AMD_NB
17420 + amd_l3_attrs();
17421 +#endif
17422 +
17423 for (i = 0; i < num_cache_leaves; i++) {
17424 + struct kobj_type *ktype;
17425 +
17426 this_object = INDEX_KOBJECT_PTR(cpu, i);
17427 this_object->cpu = cpu;
17428 this_object->index = i;
17429
17430 this_leaf = CPUID4_INFO_IDX(cpu, i);
17431
17432 - ktype_cache.default_attrs = default_attrs;
17433 + ktype = &ktype_cache;
17434 #ifdef CONFIG_AMD_NB
17435 if (this_leaf->base.nb)
17436 - ktype_cache.default_attrs = amd_l3_attrs();
17437 + ktype = &ktype_cache_amd_nb;
17438 #endif
17439 retval = kobject_init_and_add(&(this_object->kobj),
17440 - &ktype_cache,
17441 + ktype,
17442 per_cpu(ici_cache_kobject, cpu),
17443 "index%1lu", i);
17444 if (unlikely(retval)) {
17445 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17446 return NOTIFY_OK;
17447 }
17448
17449 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17450 +static struct notifier_block cacheinfo_cpu_notifier = {
17451 .notifier_call = cacheinfo_cpu_callback,
17452 };
17453
17454 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17455 index 7bc1263..bff5686 100644
17456 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17457 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17458 @@ -45,6 +45,7 @@
17459 #include <asm/processor.h>
17460 #include <asm/mce.h>
17461 #include <asm/msr.h>
17462 +#include <asm/local.h>
17463
17464 #include "mce-internal.h"
17465
17466 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17467 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17468 m->cs, m->ip);
17469
17470 - if (m->cs == __KERNEL_CS)
17471 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17472 print_symbol("{%s}", m->ip);
17473 pr_cont("\n");
17474 }
17475 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17476
17477 #define PANIC_TIMEOUT 5 /* 5 seconds */
17478
17479 -static atomic_t mce_paniced;
17480 +static atomic_unchecked_t mce_paniced;
17481
17482 static int fake_panic;
17483 -static atomic_t mce_fake_paniced;
17484 +static atomic_unchecked_t mce_fake_paniced;
17485
17486 /* Panic in progress. Enable interrupts and wait for final IPI */
17487 static void wait_for_panic(void)
17488 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17489 /*
17490 * Make sure only one CPU runs in machine check panic
17491 */
17492 - if (atomic_inc_return(&mce_paniced) > 1)
17493 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17494 wait_for_panic();
17495 barrier();
17496
17497 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17498 console_verbose();
17499 } else {
17500 /* Don't log too much for fake panic */
17501 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17502 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17503 return;
17504 }
17505 /* First print corrected ones that are still unlogged */
17506 @@ -353,7 +354,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17507 if (!fake_panic) {
17508 if (panic_timeout == 0)
17509 panic_timeout = mca_cfg.panic_timeout;
17510 - panic(msg);
17511 + panic("%s", msg);
17512 } else
17513 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
17514 }
17515 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17516 * might have been modified by someone else.
17517 */
17518 rmb();
17519 - if (atomic_read(&mce_paniced))
17520 + if (atomic_read_unchecked(&mce_paniced))
17521 wait_for_panic();
17522 if (!mca_cfg.monarch_timeout)
17523 goto out;
17524 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17525 }
17526
17527 /* Call the installed machine check handler for this CPU setup. */
17528 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17529 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17530 unexpected_machine_check;
17531
17532 /*
17533 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17534 return;
17535 }
17536
17537 + pax_open_kernel();
17538 machine_check_vector = do_machine_check;
17539 + pax_close_kernel();
17540
17541 __mcheck_cpu_init_generic();
17542 __mcheck_cpu_init_vendor(c);
17543 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17544 */
17545
17546 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17547 -static int mce_chrdev_open_count; /* #times opened */
17548 +static local_t mce_chrdev_open_count; /* #times opened */
17549 static int mce_chrdev_open_exclu; /* already open exclusive? */
17550
17551 static int mce_chrdev_open(struct inode *inode, struct file *file)
17552 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17553 spin_lock(&mce_chrdev_state_lock);
17554
17555 if (mce_chrdev_open_exclu ||
17556 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17557 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17558 spin_unlock(&mce_chrdev_state_lock);
17559
17560 return -EBUSY;
17561 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17562
17563 if (file->f_flags & O_EXCL)
17564 mce_chrdev_open_exclu = 1;
17565 - mce_chrdev_open_count++;
17566 + local_inc(&mce_chrdev_open_count);
17567
17568 spin_unlock(&mce_chrdev_state_lock);
17569
17570 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17571 {
17572 spin_lock(&mce_chrdev_state_lock);
17573
17574 - mce_chrdev_open_count--;
17575 + local_dec(&mce_chrdev_open_count);
17576 mce_chrdev_open_exclu = 0;
17577
17578 spin_unlock(&mce_chrdev_state_lock);
17579 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17580 return NOTIFY_OK;
17581 }
17582
17583 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17584 +static struct notifier_block mce_cpu_notifier = {
17585 .notifier_call = mce_cpu_callback,
17586 };
17587
17588 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17589
17590 for (i = 0; i < mca_cfg.banks; i++) {
17591 struct mce_bank *b = &mce_banks[i];
17592 - struct device_attribute *a = &b->attr;
17593 + device_attribute_no_const *a = &b->attr;
17594
17595 sysfs_attr_init(&a->attr);
17596 a->attr.name = b->attrname;
17597 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17598 static void mce_reset(void)
17599 {
17600 cpu_missing = 0;
17601 - atomic_set(&mce_fake_paniced, 0);
17602 + atomic_set_unchecked(&mce_fake_paniced, 0);
17603 atomic_set(&mce_executing, 0);
17604 atomic_set(&mce_callin, 0);
17605 atomic_set(&global_nwo, 0);
17606 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17607 index 1c044b1..37a2a43 100644
17608 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17609 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17610 @@ -11,6 +11,7 @@
17611 #include <asm/processor.h>
17612 #include <asm/mce.h>
17613 #include <asm/msr.h>
17614 +#include <asm/pgtable.h>
17615
17616 /* By default disabled */
17617 int mce_p5_enabled __read_mostly;
17618 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17619 if (!cpu_has(c, X86_FEATURE_MCE))
17620 return;
17621
17622 + pax_open_kernel();
17623 machine_check_vector = pentium_machine_check;
17624 + pax_close_kernel();
17625 /* Make sure the vector pointer is visible before we enable MCEs: */
17626 wmb();
17627
17628 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17629 index 47a1870..8c019a7 100644
17630 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17631 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17632 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17633 return notifier_from_errno(err);
17634 }
17635
17636 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17637 +static struct notifier_block thermal_throttle_cpu_notifier =
17638 {
17639 .notifier_call = thermal_throttle_cpu_callback,
17640 };
17641 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17642 index e9a701a..35317d6 100644
17643 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17644 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17645 @@ -10,6 +10,7 @@
17646 #include <asm/processor.h>
17647 #include <asm/mce.h>
17648 #include <asm/msr.h>
17649 +#include <asm/pgtable.h>
17650
17651 /* Machine check handler for WinChip C6: */
17652 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17653 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17654 {
17655 u32 lo, hi;
17656
17657 + pax_open_kernel();
17658 machine_check_vector = winchip_machine_check;
17659 + pax_close_kernel();
17660 /* Make sure the vector pointer is visible before we enable MCEs: */
17661 wmb();
17662
17663 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17664 index 726bf96..81f0526 100644
17665 --- a/arch/x86/kernel/cpu/mtrr/main.c
17666 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17667 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17668 u64 size_or_mask, size_and_mask;
17669 static bool mtrr_aps_delayed_init;
17670
17671 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17672 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17673
17674 const struct mtrr_ops *mtrr_if;
17675
17676 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17677 index df5e41f..816c719 100644
17678 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17679 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17680 @@ -25,7 +25,7 @@ struct mtrr_ops {
17681 int (*validate_add_page)(unsigned long base, unsigned long size,
17682 unsigned int type);
17683 int (*have_wrcomb)(void);
17684 -};
17685 +} __do_const;
17686
17687 extern int generic_get_free_region(unsigned long base, unsigned long size,
17688 int replace_reg);
17689 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17690 index bf0f01a..9adfee1 100644
17691 --- a/arch/x86/kernel/cpu/perf_event.c
17692 +++ b/arch/x86/kernel/cpu/perf_event.c
17693 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17694 pr_info("no hardware sampling interrupt available.\n");
17695 }
17696
17697 -static struct attribute_group x86_pmu_format_group = {
17698 +static attribute_group_no_const x86_pmu_format_group = {
17699 .name = "format",
17700 .attrs = NULL,
17701 };
17702 @@ -1374,7 +1374,7 @@ static struct attribute *events_attr[] = {
17703 NULL,
17704 };
17705
17706 -static struct attribute_group x86_pmu_events_group = {
17707 +static attribute_group_no_const x86_pmu_events_group = {
17708 .name = "events",
17709 .attrs = events_attr,
17710 };
17711 @@ -1873,7 +1873,7 @@ static unsigned long get_segment_base(unsigned int segment)
17712 if (idx > GDT_ENTRIES)
17713 return 0;
17714
17715 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17716 + desc = get_cpu_gdt_table(smp_processor_id());
17717 }
17718
17719 return get_desc_base(desc + idx);
17720 @@ -1963,7 +1963,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17721 break;
17722
17723 perf_callchain_store(entry, frame.return_address);
17724 - fp = frame.next_frame;
17725 + fp = (const void __force_user *)frame.next_frame;
17726 }
17727 }
17728
17729 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17730 index 4a0a462..be3b204 100644
17731 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17732 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17733 @@ -1994,10 +1994,10 @@ __init int intel_pmu_init(void)
17734 * v2 and above have a perf capabilities MSR
17735 */
17736 if (version > 1) {
17737 - u64 capabilities;
17738 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17739
17740 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17741 - x86_pmu.intel_cap.capabilities = capabilities;
17742 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17743 + x86_pmu.intel_cap.capabilities = capabilities;
17744 }
17745
17746 intel_ds_init();
17747 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17748 index 3e091f0..d2dc8d6 100644
17749 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17750 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17751 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17752 static int __init uncore_type_init(struct intel_uncore_type *type)
17753 {
17754 struct intel_uncore_pmu *pmus;
17755 - struct attribute_group *attr_group;
17756 + attribute_group_no_const *attr_group;
17757 struct attribute **attrs;
17758 int i, j;
17759
17760 @@ -2826,7 +2826,7 @@ static int
17761 return NOTIFY_OK;
17762 }
17763
17764 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17765 +static struct notifier_block uncore_cpu_nb = {
17766 .notifier_call = uncore_cpu_notifier,
17767 /*
17768 * to migrate uncore events, our notifier should be executed
17769 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17770 index e68a455..975a932 100644
17771 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17772 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17773 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17774 struct uncore_event_desc {
17775 struct kobj_attribute attr;
17776 const char *config;
17777 -};
17778 +} __do_const;
17779
17780 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17781 { \
17782 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17783 index 1e4dbcf..b9a34c2 100644
17784 --- a/arch/x86/kernel/cpuid.c
17785 +++ b/arch/x86/kernel/cpuid.c
17786 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17787 return notifier_from_errno(err);
17788 }
17789
17790 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17791 +static struct notifier_block cpuid_class_cpu_notifier =
17792 {
17793 .notifier_call = cpuid_class_cpu_callback,
17794 };
17795 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17796 index 74467fe..18793d5 100644
17797 --- a/arch/x86/kernel/crash.c
17798 +++ b/arch/x86/kernel/crash.c
17799 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17800 {
17801 #ifdef CONFIG_X86_32
17802 struct pt_regs fixed_regs;
17803 -#endif
17804
17805 -#ifdef CONFIG_X86_32
17806 - if (!user_mode_vm(regs)) {
17807 + if (!user_mode(regs)) {
17808 crash_fixup_ss_esp(&fixed_regs, regs);
17809 regs = &fixed_regs;
17810 }
17811 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17812 index afa64ad..dce67dd 100644
17813 --- a/arch/x86/kernel/crash_dump_64.c
17814 +++ b/arch/x86/kernel/crash_dump_64.c
17815 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17816 return -ENOMEM;
17817
17818 if (userbuf) {
17819 - if (copy_to_user(buf, vaddr + offset, csize)) {
17820 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17821 iounmap(vaddr);
17822 return -EFAULT;
17823 }
17824 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17825 index 37250fe..bf2ec74 100644
17826 --- a/arch/x86/kernel/doublefault_32.c
17827 +++ b/arch/x86/kernel/doublefault_32.c
17828 @@ -11,7 +11,7 @@
17829
17830 #define DOUBLEFAULT_STACKSIZE (1024)
17831 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17832 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17833 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17834
17835 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17836
17837 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17838 unsigned long gdt, tss;
17839
17840 store_gdt(&gdt_desc);
17841 - gdt = gdt_desc.address;
17842 + gdt = (unsigned long)gdt_desc.address;
17843
17844 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17845
17846 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17847 /* 0x2 bit is always set */
17848 .flags = X86_EFLAGS_SF | 0x2,
17849 .sp = STACK_START,
17850 - .es = __USER_DS,
17851 + .es = __KERNEL_DS,
17852 .cs = __KERNEL_CS,
17853 .ss = __KERNEL_DS,
17854 - .ds = __USER_DS,
17855 + .ds = __KERNEL_DS,
17856 .fs = __KERNEL_PERCPU,
17857
17858 .__cr3 = __pa_nodebug(swapper_pg_dir),
17859 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17860 index c8797d5..c605e53 100644
17861 --- a/arch/x86/kernel/dumpstack.c
17862 +++ b/arch/x86/kernel/dumpstack.c
17863 @@ -2,6 +2,9 @@
17864 * Copyright (C) 1991, 1992 Linus Torvalds
17865 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17866 */
17867 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17868 +#define __INCLUDED_BY_HIDESYM 1
17869 +#endif
17870 #include <linux/kallsyms.h>
17871 #include <linux/kprobes.h>
17872 #include <linux/uaccess.h>
17873 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17874 static void
17875 print_ftrace_graph_addr(unsigned long addr, void *data,
17876 const struct stacktrace_ops *ops,
17877 - struct thread_info *tinfo, int *graph)
17878 + struct task_struct *task, int *graph)
17879 {
17880 - struct task_struct *task;
17881 unsigned long ret_addr;
17882 int index;
17883
17884 if (addr != (unsigned long)return_to_handler)
17885 return;
17886
17887 - task = tinfo->task;
17888 index = task->curr_ret_stack;
17889
17890 if (!task->ret_stack || index < *graph)
17891 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17892 static inline void
17893 print_ftrace_graph_addr(unsigned long addr, void *data,
17894 const struct stacktrace_ops *ops,
17895 - struct thread_info *tinfo, int *graph)
17896 + struct task_struct *task, int *graph)
17897 { }
17898 #endif
17899
17900 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17901 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17902 */
17903
17904 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17905 - void *p, unsigned int size, void *end)
17906 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17907 {
17908 - void *t = tinfo;
17909 if (end) {
17910 if (p < end && p >= (end-THREAD_SIZE))
17911 return 1;
17912 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17913 }
17914
17915 unsigned long
17916 -print_context_stack(struct thread_info *tinfo,
17917 +print_context_stack(struct task_struct *task, void *stack_start,
17918 unsigned long *stack, unsigned long bp,
17919 const struct stacktrace_ops *ops, void *data,
17920 unsigned long *end, int *graph)
17921 {
17922 struct stack_frame *frame = (struct stack_frame *)bp;
17923
17924 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17925 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17926 unsigned long addr;
17927
17928 addr = *stack;
17929 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17930 } else {
17931 ops->address(data, addr, 0);
17932 }
17933 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17934 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17935 }
17936 stack++;
17937 }
17938 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17939 EXPORT_SYMBOL_GPL(print_context_stack);
17940
17941 unsigned long
17942 -print_context_stack_bp(struct thread_info *tinfo,
17943 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17944 unsigned long *stack, unsigned long bp,
17945 const struct stacktrace_ops *ops, void *data,
17946 unsigned long *end, int *graph)
17947 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17948 struct stack_frame *frame = (struct stack_frame *)bp;
17949 unsigned long *ret_addr = &frame->return_address;
17950
17951 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17952 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17953 unsigned long addr = *ret_addr;
17954
17955 if (!__kernel_text_address(addr))
17956 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17957 ops->address(data, addr, 1);
17958 frame = frame->next_frame;
17959 ret_addr = &frame->return_address;
17960 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17961 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17962 }
17963
17964 return (unsigned long)frame;
17965 @@ -189,7 +188,7 @@ void dump_stack(void)
17966
17967 bp = stack_frame(current, NULL);
17968 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17969 - current->pid, current->comm, print_tainted(),
17970 + task_pid_nr(current), current->comm, print_tainted(),
17971 init_utsname()->release,
17972 (int)strcspn(init_utsname()->version, " "),
17973 init_utsname()->version);
17974 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17975 }
17976 EXPORT_SYMBOL_GPL(oops_begin);
17977
17978 +extern void gr_handle_kernel_exploit(void);
17979 +
17980 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17981 {
17982 if (regs && kexec_should_crash(current))
17983 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17984 panic("Fatal exception in interrupt");
17985 if (panic_on_oops)
17986 panic("Fatal exception");
17987 - do_exit(signr);
17988 +
17989 + gr_handle_kernel_exploit();
17990 +
17991 + do_group_exit(signr);
17992 }
17993
17994 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17995 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17996 print_modules();
17997 show_regs(regs);
17998 #ifdef CONFIG_X86_32
17999 - if (user_mode_vm(regs)) {
18000 + if (user_mode(regs)) {
18001 sp = regs->sp;
18002 ss = regs->ss & 0xffff;
18003 } else {
18004 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18005 unsigned long flags = oops_begin();
18006 int sig = SIGSEGV;
18007
18008 - if (!user_mode_vm(regs))
18009 + if (!user_mode(regs))
18010 report_bug(regs->ip, regs);
18011
18012 if (__die(str, regs, err))
18013 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18014 index 1038a41..db2c12b 100644
18015 --- a/arch/x86/kernel/dumpstack_32.c
18016 +++ b/arch/x86/kernel/dumpstack_32.c
18017 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18018 bp = stack_frame(task, regs);
18019
18020 for (;;) {
18021 - struct thread_info *context;
18022 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18023
18024 - context = (struct thread_info *)
18025 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18026 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18027 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18028
18029 - stack = (unsigned long *)context->previous_esp;
18030 - if (!stack)
18031 + if (stack_start == task_stack_page(task))
18032 break;
18033 + stack = *(unsigned long **)stack_start;
18034 if (ops->stack(data, "IRQ") < 0)
18035 break;
18036 touch_nmi_watchdog();
18037 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18038 {
18039 int i;
18040
18041 - __show_regs(regs, !user_mode_vm(regs));
18042 + __show_regs(regs, !user_mode(regs));
18043
18044 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18045 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18046 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18047 * When in-kernel, we also print out the stack and code at the
18048 * time of the fault..
18049 */
18050 - if (!user_mode_vm(regs)) {
18051 + if (!user_mode(regs)) {
18052 unsigned int code_prologue = code_bytes * 43 / 64;
18053 unsigned int code_len = code_bytes;
18054 unsigned char c;
18055 u8 *ip;
18056 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18057
18058 pr_emerg("Stack:\n");
18059 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18060
18061 pr_emerg("Code:");
18062
18063 - ip = (u8 *)regs->ip - code_prologue;
18064 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18065 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18066 /* try starting at IP */
18067 - ip = (u8 *)regs->ip;
18068 + ip = (u8 *)regs->ip + cs_base;
18069 code_len = code_len - code_prologue + 1;
18070 }
18071 for (i = 0; i < code_len; i++, ip++) {
18072 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18073 pr_cont(" Bad EIP value.");
18074 break;
18075 }
18076 - if (ip == (u8 *)regs->ip)
18077 + if (ip == (u8 *)regs->ip + cs_base)
18078 pr_cont(" <%02x>", c);
18079 else
18080 pr_cont(" %02x", c);
18081 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18082 {
18083 unsigned short ud2;
18084
18085 + ip = ktla_ktva(ip);
18086 if (ip < PAGE_OFFSET)
18087 return 0;
18088 if (probe_kernel_address((unsigned short *)ip, ud2))
18089 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18090
18091 return ud2 == 0x0b0f;
18092 }
18093 +
18094 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18095 +void pax_check_alloca(unsigned long size)
18096 +{
18097 + unsigned long sp = (unsigned long)&sp, stack_left;
18098 +
18099 + /* all kernel stacks are of the same size */
18100 + stack_left = sp & (THREAD_SIZE - 1);
18101 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18102 +}
18103 +EXPORT_SYMBOL(pax_check_alloca);
18104 +#endif
18105 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18106 index b653675..51cc8c0 100644
18107 --- a/arch/x86/kernel/dumpstack_64.c
18108 +++ b/arch/x86/kernel/dumpstack_64.c
18109 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18110 unsigned long *irq_stack_end =
18111 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18112 unsigned used = 0;
18113 - struct thread_info *tinfo;
18114 int graph = 0;
18115 unsigned long dummy;
18116 + void *stack_start;
18117
18118 if (!task)
18119 task = current;
18120 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18121 * current stack address. If the stacks consist of nested
18122 * exceptions
18123 */
18124 - tinfo = task_thread_info(task);
18125 for (;;) {
18126 char *id;
18127 unsigned long *estack_end;
18128 +
18129 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18130 &used, &id);
18131
18132 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18133 if (ops->stack(data, id) < 0)
18134 break;
18135
18136 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18137 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18138 data, estack_end, &graph);
18139 ops->stack(data, "<EOE>");
18140 /*
18141 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18142 * second-to-last pointer (index -2 to end) in the
18143 * exception stack:
18144 */
18145 + if ((u16)estack_end[-1] != __KERNEL_DS)
18146 + goto out;
18147 stack = (unsigned long *) estack_end[-2];
18148 continue;
18149 }
18150 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18151 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18152 if (ops->stack(data, "IRQ") < 0)
18153 break;
18154 - bp = ops->walk_stack(tinfo, stack, bp,
18155 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18156 ops, data, irq_stack_end, &graph);
18157 /*
18158 * We link to the next stack (which would be
18159 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18160 /*
18161 * This handles the process stack:
18162 */
18163 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18164 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18165 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18166 +out:
18167 put_cpu();
18168 }
18169 EXPORT_SYMBOL(dump_trace);
18170 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18171 {
18172 int i;
18173 unsigned long sp;
18174 - const int cpu = smp_processor_id();
18175 + const int cpu = raw_smp_processor_id();
18176 struct task_struct *cur = current;
18177
18178 sp = regs->sp;
18179 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18180
18181 return ud2 == 0x0b0f;
18182 }
18183 +
18184 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18185 +void pax_check_alloca(unsigned long size)
18186 +{
18187 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18188 + unsigned cpu, used;
18189 + char *id;
18190 +
18191 + /* check the process stack first */
18192 + stack_start = (unsigned long)task_stack_page(current);
18193 + stack_end = stack_start + THREAD_SIZE;
18194 + if (likely(stack_start <= sp && sp < stack_end)) {
18195 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18196 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18197 + return;
18198 + }
18199 +
18200 + cpu = get_cpu();
18201 +
18202 + /* check the irq stacks */
18203 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18204 + stack_start = stack_end - IRQ_STACK_SIZE;
18205 + if (stack_start <= sp && sp < stack_end) {
18206 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18207 + put_cpu();
18208 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18209 + return;
18210 + }
18211 +
18212 + /* check the exception stacks */
18213 + used = 0;
18214 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18215 + stack_start = stack_end - EXCEPTION_STKSZ;
18216 + if (stack_end && stack_start <= sp && sp < stack_end) {
18217 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18218 + put_cpu();
18219 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18220 + return;
18221 + }
18222 +
18223 + put_cpu();
18224 +
18225 + /* unknown stack */
18226 + BUG();
18227 +}
18228 +EXPORT_SYMBOL(pax_check_alloca);
18229 +#endif
18230 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
18231 index d32abea..74daf4f 100644
18232 --- a/arch/x86/kernel/e820.c
18233 +++ b/arch/x86/kernel/e820.c
18234 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
18235
18236 static void early_panic(char *msg)
18237 {
18238 - early_printk(msg);
18239 - panic(msg);
18240 + early_printk("%s", msg);
18241 + panic("%s", msg);
18242 }
18243
18244 static int userdef __initdata;
18245 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18246 index 9b9f18b..9fcaa04 100644
18247 --- a/arch/x86/kernel/early_printk.c
18248 +++ b/arch/x86/kernel/early_printk.c
18249 @@ -7,6 +7,7 @@
18250 #include <linux/pci_regs.h>
18251 #include <linux/pci_ids.h>
18252 #include <linux/errno.h>
18253 +#include <linux/sched.h>
18254 #include <asm/io.h>
18255 #include <asm/processor.h>
18256 #include <asm/fcntl.h>
18257 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18258 index 8f3e2de..934870f 100644
18259 --- a/arch/x86/kernel/entry_32.S
18260 +++ b/arch/x86/kernel/entry_32.S
18261 @@ -177,13 +177,153 @@
18262 /*CFI_REL_OFFSET gs, PT_GS*/
18263 .endm
18264 .macro SET_KERNEL_GS reg
18265 +
18266 +#ifdef CONFIG_CC_STACKPROTECTOR
18267 movl $(__KERNEL_STACK_CANARY), \reg
18268 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18269 + movl $(__USER_DS), \reg
18270 +#else
18271 + xorl \reg, \reg
18272 +#endif
18273 +
18274 movl \reg, %gs
18275 .endm
18276
18277 #endif /* CONFIG_X86_32_LAZY_GS */
18278
18279 -.macro SAVE_ALL
18280 +.macro pax_enter_kernel
18281 +#ifdef CONFIG_PAX_KERNEXEC
18282 + call pax_enter_kernel
18283 +#endif
18284 +.endm
18285 +
18286 +.macro pax_exit_kernel
18287 +#ifdef CONFIG_PAX_KERNEXEC
18288 + call pax_exit_kernel
18289 +#endif
18290 +.endm
18291 +
18292 +#ifdef CONFIG_PAX_KERNEXEC
18293 +ENTRY(pax_enter_kernel)
18294 +#ifdef CONFIG_PARAVIRT
18295 + pushl %eax
18296 + pushl %ecx
18297 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18298 + mov %eax, %esi
18299 +#else
18300 + mov %cr0, %esi
18301 +#endif
18302 + bts $16, %esi
18303 + jnc 1f
18304 + mov %cs, %esi
18305 + cmp $__KERNEL_CS, %esi
18306 + jz 3f
18307 + ljmp $__KERNEL_CS, $3f
18308 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18309 +2:
18310 +#ifdef CONFIG_PARAVIRT
18311 + mov %esi, %eax
18312 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18313 +#else
18314 + mov %esi, %cr0
18315 +#endif
18316 +3:
18317 +#ifdef CONFIG_PARAVIRT
18318 + popl %ecx
18319 + popl %eax
18320 +#endif
18321 + ret
18322 +ENDPROC(pax_enter_kernel)
18323 +
18324 +ENTRY(pax_exit_kernel)
18325 +#ifdef CONFIG_PARAVIRT
18326 + pushl %eax
18327 + pushl %ecx
18328 +#endif
18329 + mov %cs, %esi
18330 + cmp $__KERNEXEC_KERNEL_CS, %esi
18331 + jnz 2f
18332 +#ifdef CONFIG_PARAVIRT
18333 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18334 + mov %eax, %esi
18335 +#else
18336 + mov %cr0, %esi
18337 +#endif
18338 + btr $16, %esi
18339 + ljmp $__KERNEL_CS, $1f
18340 +1:
18341 +#ifdef CONFIG_PARAVIRT
18342 + mov %esi, %eax
18343 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18344 +#else
18345 + mov %esi, %cr0
18346 +#endif
18347 +2:
18348 +#ifdef CONFIG_PARAVIRT
18349 + popl %ecx
18350 + popl %eax
18351 +#endif
18352 + ret
18353 +ENDPROC(pax_exit_kernel)
18354 +#endif
18355 +
18356 +.macro pax_erase_kstack
18357 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18358 + call pax_erase_kstack
18359 +#endif
18360 +.endm
18361 +
18362 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18363 +/*
18364 + * ebp: thread_info
18365 + */
18366 +ENTRY(pax_erase_kstack)
18367 + pushl %edi
18368 + pushl %ecx
18369 + pushl %eax
18370 +
18371 + mov TI_lowest_stack(%ebp), %edi
18372 + mov $-0xBEEF, %eax
18373 + std
18374 +
18375 +1: mov %edi, %ecx
18376 + and $THREAD_SIZE_asm - 1, %ecx
18377 + shr $2, %ecx
18378 + repne scasl
18379 + jecxz 2f
18380 +
18381 + cmp $2*16, %ecx
18382 + jc 2f
18383 +
18384 + mov $2*16, %ecx
18385 + repe scasl
18386 + jecxz 2f
18387 + jne 1b
18388 +
18389 +2: cld
18390 + mov %esp, %ecx
18391 + sub %edi, %ecx
18392 +
18393 + cmp $THREAD_SIZE_asm, %ecx
18394 + jb 3f
18395 + ud2
18396 +3:
18397 +
18398 + shr $2, %ecx
18399 + rep stosl
18400 +
18401 + mov TI_task_thread_sp0(%ebp), %edi
18402 + sub $128, %edi
18403 + mov %edi, TI_lowest_stack(%ebp)
18404 +
18405 + popl %eax
18406 + popl %ecx
18407 + popl %edi
18408 + ret
18409 +ENDPROC(pax_erase_kstack)
18410 +#endif
18411 +
18412 +.macro __SAVE_ALL _DS
18413 cld
18414 PUSH_GS
18415 pushl_cfi %fs
18416 @@ -206,7 +346,7 @@
18417 CFI_REL_OFFSET ecx, 0
18418 pushl_cfi %ebx
18419 CFI_REL_OFFSET ebx, 0
18420 - movl $(__USER_DS), %edx
18421 + movl $\_DS, %edx
18422 movl %edx, %ds
18423 movl %edx, %es
18424 movl $(__KERNEL_PERCPU), %edx
18425 @@ -214,6 +354,15 @@
18426 SET_KERNEL_GS %edx
18427 .endm
18428
18429 +.macro SAVE_ALL
18430 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18431 + __SAVE_ALL __KERNEL_DS
18432 + pax_enter_kernel
18433 +#else
18434 + __SAVE_ALL __USER_DS
18435 +#endif
18436 +.endm
18437 +
18438 .macro RESTORE_INT_REGS
18439 popl_cfi %ebx
18440 CFI_RESTORE ebx
18441 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18442 popfl_cfi
18443 jmp syscall_exit
18444 CFI_ENDPROC
18445 -END(ret_from_fork)
18446 +ENDPROC(ret_from_fork)
18447
18448 ENTRY(ret_from_kernel_thread)
18449 CFI_STARTPROC
18450 @@ -344,7 +493,15 @@ ret_from_intr:
18451 andl $SEGMENT_RPL_MASK, %eax
18452 #endif
18453 cmpl $USER_RPL, %eax
18454 +
18455 +#ifdef CONFIG_PAX_KERNEXEC
18456 + jae resume_userspace
18457 +
18458 + pax_exit_kernel
18459 + jmp resume_kernel
18460 +#else
18461 jb resume_kernel # not returning to v8086 or userspace
18462 +#endif
18463
18464 ENTRY(resume_userspace)
18465 LOCKDEP_SYS_EXIT
18466 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18467 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18468 # int/exception return?
18469 jne work_pending
18470 - jmp restore_all
18471 -END(ret_from_exception)
18472 + jmp restore_all_pax
18473 +ENDPROC(ret_from_exception)
18474
18475 #ifdef CONFIG_PREEMPT
18476 ENTRY(resume_kernel)
18477 @@ -372,7 +529,7 @@ need_resched:
18478 jz restore_all
18479 call preempt_schedule_irq
18480 jmp need_resched
18481 -END(resume_kernel)
18482 +ENDPROC(resume_kernel)
18483 #endif
18484 CFI_ENDPROC
18485 /*
18486 @@ -406,30 +563,45 @@ sysenter_past_esp:
18487 /*CFI_REL_OFFSET cs, 0*/
18488 /*
18489 * Push current_thread_info()->sysenter_return to the stack.
18490 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18491 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18492 */
18493 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18494 + pushl_cfi $0
18495 CFI_REL_OFFSET eip, 0
18496
18497 pushl_cfi %eax
18498 SAVE_ALL
18499 + GET_THREAD_INFO(%ebp)
18500 + movl TI_sysenter_return(%ebp),%ebp
18501 + movl %ebp,PT_EIP(%esp)
18502 ENABLE_INTERRUPTS(CLBR_NONE)
18503
18504 /*
18505 * Load the potential sixth argument from user stack.
18506 * Careful about security.
18507 */
18508 + movl PT_OLDESP(%esp),%ebp
18509 +
18510 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18511 + mov PT_OLDSS(%esp),%ds
18512 +1: movl %ds:(%ebp),%ebp
18513 + push %ss
18514 + pop %ds
18515 +#else
18516 cmpl $__PAGE_OFFSET-3,%ebp
18517 jae syscall_fault
18518 ASM_STAC
18519 1: movl (%ebp),%ebp
18520 ASM_CLAC
18521 +#endif
18522 +
18523 movl %ebp,PT_EBP(%esp)
18524 _ASM_EXTABLE(1b,syscall_fault)
18525
18526 GET_THREAD_INFO(%ebp)
18527
18528 +#ifdef CONFIG_PAX_RANDKSTACK
18529 + pax_erase_kstack
18530 +#endif
18531 +
18532 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18533 jnz sysenter_audit
18534 sysenter_do_call:
18535 @@ -444,12 +616,24 @@ sysenter_do_call:
18536 testl $_TIF_ALLWORK_MASK, %ecx
18537 jne sysexit_audit
18538 sysenter_exit:
18539 +
18540 +#ifdef CONFIG_PAX_RANDKSTACK
18541 + pushl_cfi %eax
18542 + movl %esp, %eax
18543 + call pax_randomize_kstack
18544 + popl_cfi %eax
18545 +#endif
18546 +
18547 + pax_erase_kstack
18548 +
18549 /* if something modifies registers it must also disable sysexit */
18550 movl PT_EIP(%esp), %edx
18551 movl PT_OLDESP(%esp), %ecx
18552 xorl %ebp,%ebp
18553 TRACE_IRQS_ON
18554 1: mov PT_FS(%esp), %fs
18555 +2: mov PT_DS(%esp), %ds
18556 +3: mov PT_ES(%esp), %es
18557 PTGS_TO_GS
18558 ENABLE_INTERRUPTS_SYSEXIT
18559
18560 @@ -466,6 +650,9 @@ sysenter_audit:
18561 movl %eax,%edx /* 2nd arg: syscall number */
18562 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18563 call __audit_syscall_entry
18564 +
18565 + pax_erase_kstack
18566 +
18567 pushl_cfi %ebx
18568 movl PT_EAX(%esp),%eax /* reload syscall number */
18569 jmp sysenter_do_call
18570 @@ -491,10 +678,16 @@ sysexit_audit:
18571
18572 CFI_ENDPROC
18573 .pushsection .fixup,"ax"
18574 -2: movl $0,PT_FS(%esp)
18575 +4: movl $0,PT_FS(%esp)
18576 + jmp 1b
18577 +5: movl $0,PT_DS(%esp)
18578 + jmp 1b
18579 +6: movl $0,PT_ES(%esp)
18580 jmp 1b
18581 .popsection
18582 - _ASM_EXTABLE(1b,2b)
18583 + _ASM_EXTABLE(1b,4b)
18584 + _ASM_EXTABLE(2b,5b)
18585 + _ASM_EXTABLE(3b,6b)
18586 PTGS_TO_GS_EX
18587 ENDPROC(ia32_sysenter_target)
18588
18589 @@ -509,6 +702,11 @@ ENTRY(system_call)
18590 pushl_cfi %eax # save orig_eax
18591 SAVE_ALL
18592 GET_THREAD_INFO(%ebp)
18593 +
18594 +#ifdef CONFIG_PAX_RANDKSTACK
18595 + pax_erase_kstack
18596 +#endif
18597 +
18598 # system call tracing in operation / emulation
18599 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18600 jnz syscall_trace_entry
18601 @@ -527,6 +725,15 @@ syscall_exit:
18602 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18603 jne syscall_exit_work
18604
18605 +restore_all_pax:
18606 +
18607 +#ifdef CONFIG_PAX_RANDKSTACK
18608 + movl %esp, %eax
18609 + call pax_randomize_kstack
18610 +#endif
18611 +
18612 + pax_erase_kstack
18613 +
18614 restore_all:
18615 TRACE_IRQS_IRET
18616 restore_all_notrace:
18617 @@ -583,14 +790,34 @@ ldt_ss:
18618 * compensating for the offset by changing to the ESPFIX segment with
18619 * a base address that matches for the difference.
18620 */
18621 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18622 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18623 mov %esp, %edx /* load kernel esp */
18624 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18625 mov %dx, %ax /* eax: new kernel esp */
18626 sub %eax, %edx /* offset (low word is 0) */
18627 +#ifdef CONFIG_SMP
18628 + movl PER_CPU_VAR(cpu_number), %ebx
18629 + shll $PAGE_SHIFT_asm, %ebx
18630 + addl $cpu_gdt_table, %ebx
18631 +#else
18632 + movl $cpu_gdt_table, %ebx
18633 +#endif
18634 shr $16, %edx
18635 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18636 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18637 +
18638 +#ifdef CONFIG_PAX_KERNEXEC
18639 + mov %cr0, %esi
18640 + btr $16, %esi
18641 + mov %esi, %cr0
18642 +#endif
18643 +
18644 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18645 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18646 +
18647 +#ifdef CONFIG_PAX_KERNEXEC
18648 + bts $16, %esi
18649 + mov %esi, %cr0
18650 +#endif
18651 +
18652 pushl_cfi $__ESPFIX_SS
18653 pushl_cfi %eax /* new kernel esp */
18654 /* Disable interrupts, but do not irqtrace this section: we
18655 @@ -619,20 +846,18 @@ work_resched:
18656 movl TI_flags(%ebp), %ecx
18657 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18658 # than syscall tracing?
18659 - jz restore_all
18660 + jz restore_all_pax
18661 testb $_TIF_NEED_RESCHED, %cl
18662 jnz work_resched
18663
18664 work_notifysig: # deal with pending signals and
18665 # notify-resume requests
18666 + movl %esp, %eax
18667 #ifdef CONFIG_VM86
18668 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18669 - movl %esp, %eax
18670 jne work_notifysig_v86 # returning to kernel-space or
18671 # vm86-space
18672 1:
18673 -#else
18674 - movl %esp, %eax
18675 #endif
18676 TRACE_IRQS_ON
18677 ENABLE_INTERRUPTS(CLBR_NONE)
18678 @@ -653,7 +878,7 @@ work_notifysig_v86:
18679 movl %eax, %esp
18680 jmp 1b
18681 #endif
18682 -END(work_pending)
18683 +ENDPROC(work_pending)
18684
18685 # perform syscall exit tracing
18686 ALIGN
18687 @@ -661,11 +886,14 @@ syscall_trace_entry:
18688 movl $-ENOSYS,PT_EAX(%esp)
18689 movl %esp, %eax
18690 call syscall_trace_enter
18691 +
18692 + pax_erase_kstack
18693 +
18694 /* What it returned is what we'll actually use. */
18695 cmpl $(NR_syscalls), %eax
18696 jnae syscall_call
18697 jmp syscall_exit
18698 -END(syscall_trace_entry)
18699 +ENDPROC(syscall_trace_entry)
18700
18701 # perform syscall exit tracing
18702 ALIGN
18703 @@ -678,21 +906,25 @@ syscall_exit_work:
18704 movl %esp, %eax
18705 call syscall_trace_leave
18706 jmp resume_userspace
18707 -END(syscall_exit_work)
18708 +ENDPROC(syscall_exit_work)
18709 CFI_ENDPROC
18710
18711 RING0_INT_FRAME # can't unwind into user space anyway
18712 syscall_fault:
18713 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18714 + push %ss
18715 + pop %ds
18716 +#endif
18717 ASM_CLAC
18718 GET_THREAD_INFO(%ebp)
18719 movl $-EFAULT,PT_EAX(%esp)
18720 jmp resume_userspace
18721 -END(syscall_fault)
18722 +ENDPROC(syscall_fault)
18723
18724 syscall_badsys:
18725 movl $-ENOSYS,PT_EAX(%esp)
18726 jmp resume_userspace
18727 -END(syscall_badsys)
18728 +ENDPROC(syscall_badsys)
18729 CFI_ENDPROC
18730 /*
18731 * End of kprobes section
18732 @@ -708,8 +940,15 @@ END(syscall_badsys)
18733 * normal stack and adjusts ESP with the matching offset.
18734 */
18735 /* fixup the stack */
18736 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18737 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18738 +#ifdef CONFIG_SMP
18739 + movl PER_CPU_VAR(cpu_number), %ebx
18740 + shll $PAGE_SHIFT_asm, %ebx
18741 + addl $cpu_gdt_table, %ebx
18742 +#else
18743 + movl $cpu_gdt_table, %ebx
18744 +#endif
18745 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18746 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18747 shl $16, %eax
18748 addl %esp, %eax /* the adjusted stack pointer */
18749 pushl_cfi $__KERNEL_DS
18750 @@ -762,7 +1001,7 @@ vector=vector+1
18751 .endr
18752 2: jmp common_interrupt
18753 .endr
18754 -END(irq_entries_start)
18755 +ENDPROC(irq_entries_start)
18756
18757 .previous
18758 END(interrupt)
18759 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18760 pushl_cfi $do_coprocessor_error
18761 jmp error_code
18762 CFI_ENDPROC
18763 -END(coprocessor_error)
18764 +ENDPROC(coprocessor_error)
18765
18766 ENTRY(simd_coprocessor_error)
18767 RING0_INT_FRAME
18768 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18769 #endif
18770 jmp error_code
18771 CFI_ENDPROC
18772 -END(simd_coprocessor_error)
18773 +ENDPROC(simd_coprocessor_error)
18774
18775 ENTRY(device_not_available)
18776 RING0_INT_FRAME
18777 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18778 pushl_cfi $do_device_not_available
18779 jmp error_code
18780 CFI_ENDPROC
18781 -END(device_not_available)
18782 +ENDPROC(device_not_available)
18783
18784 #ifdef CONFIG_PARAVIRT
18785 ENTRY(native_iret)
18786 iret
18787 _ASM_EXTABLE(native_iret, iret_exc)
18788 -END(native_iret)
18789 +ENDPROC(native_iret)
18790
18791 ENTRY(native_irq_enable_sysexit)
18792 sti
18793 sysexit
18794 -END(native_irq_enable_sysexit)
18795 +ENDPROC(native_irq_enable_sysexit)
18796 #endif
18797
18798 ENTRY(overflow)
18799 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18800 pushl_cfi $do_overflow
18801 jmp error_code
18802 CFI_ENDPROC
18803 -END(overflow)
18804 +ENDPROC(overflow)
18805
18806 ENTRY(bounds)
18807 RING0_INT_FRAME
18808 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18809 pushl_cfi $do_bounds
18810 jmp error_code
18811 CFI_ENDPROC
18812 -END(bounds)
18813 +ENDPROC(bounds)
18814
18815 ENTRY(invalid_op)
18816 RING0_INT_FRAME
18817 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18818 pushl_cfi $do_invalid_op
18819 jmp error_code
18820 CFI_ENDPROC
18821 -END(invalid_op)
18822 +ENDPROC(invalid_op)
18823
18824 ENTRY(coprocessor_segment_overrun)
18825 RING0_INT_FRAME
18826 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18827 pushl_cfi $do_coprocessor_segment_overrun
18828 jmp error_code
18829 CFI_ENDPROC
18830 -END(coprocessor_segment_overrun)
18831 +ENDPROC(coprocessor_segment_overrun)
18832
18833 ENTRY(invalid_TSS)
18834 RING0_EC_FRAME
18835 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18836 pushl_cfi $do_invalid_TSS
18837 jmp error_code
18838 CFI_ENDPROC
18839 -END(invalid_TSS)
18840 +ENDPROC(invalid_TSS)
18841
18842 ENTRY(segment_not_present)
18843 RING0_EC_FRAME
18844 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18845 pushl_cfi $do_segment_not_present
18846 jmp error_code
18847 CFI_ENDPROC
18848 -END(segment_not_present)
18849 +ENDPROC(segment_not_present)
18850
18851 ENTRY(stack_segment)
18852 RING0_EC_FRAME
18853 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18854 pushl_cfi $do_stack_segment
18855 jmp error_code
18856 CFI_ENDPROC
18857 -END(stack_segment)
18858 +ENDPROC(stack_segment)
18859
18860 ENTRY(alignment_check)
18861 RING0_EC_FRAME
18862 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18863 pushl_cfi $do_alignment_check
18864 jmp error_code
18865 CFI_ENDPROC
18866 -END(alignment_check)
18867 +ENDPROC(alignment_check)
18868
18869 ENTRY(divide_error)
18870 RING0_INT_FRAME
18871 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18872 pushl_cfi $do_divide_error
18873 jmp error_code
18874 CFI_ENDPROC
18875 -END(divide_error)
18876 +ENDPROC(divide_error)
18877
18878 #ifdef CONFIG_X86_MCE
18879 ENTRY(machine_check)
18880 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18881 pushl_cfi machine_check_vector
18882 jmp error_code
18883 CFI_ENDPROC
18884 -END(machine_check)
18885 +ENDPROC(machine_check)
18886 #endif
18887
18888 ENTRY(spurious_interrupt_bug)
18889 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18890 pushl_cfi $do_spurious_interrupt_bug
18891 jmp error_code
18892 CFI_ENDPROC
18893 -END(spurious_interrupt_bug)
18894 +ENDPROC(spurious_interrupt_bug)
18895 /*
18896 * End of kprobes section
18897 */
18898 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18899
18900 ENTRY(mcount)
18901 ret
18902 -END(mcount)
18903 +ENDPROC(mcount)
18904
18905 ENTRY(ftrace_caller)
18906 cmpl $0, function_trace_stop
18907 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18908 .globl ftrace_stub
18909 ftrace_stub:
18910 ret
18911 -END(ftrace_caller)
18912 +ENDPROC(ftrace_caller)
18913
18914 ENTRY(ftrace_regs_caller)
18915 pushf /* push flags before compare (in cs location) */
18916 @@ -1197,7 +1436,7 @@ trace:
18917 popl %ecx
18918 popl %eax
18919 jmp ftrace_stub
18920 -END(mcount)
18921 +ENDPROC(mcount)
18922 #endif /* CONFIG_DYNAMIC_FTRACE */
18923 #endif /* CONFIG_FUNCTION_TRACER */
18924
18925 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18926 popl %ecx
18927 popl %eax
18928 ret
18929 -END(ftrace_graph_caller)
18930 +ENDPROC(ftrace_graph_caller)
18931
18932 .globl return_to_handler
18933 return_to_handler:
18934 @@ -1271,15 +1510,18 @@ error_code:
18935 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18936 REG_TO_PTGS %ecx
18937 SET_KERNEL_GS %ecx
18938 - movl $(__USER_DS), %ecx
18939 + movl $(__KERNEL_DS), %ecx
18940 movl %ecx, %ds
18941 movl %ecx, %es
18942 +
18943 + pax_enter_kernel
18944 +
18945 TRACE_IRQS_OFF
18946 movl %esp,%eax # pt_regs pointer
18947 call *%edi
18948 jmp ret_from_exception
18949 CFI_ENDPROC
18950 -END(page_fault)
18951 +ENDPROC(page_fault)
18952
18953 /*
18954 * Debug traps and NMI can happen at the one SYSENTER instruction
18955 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18956 call do_debug
18957 jmp ret_from_exception
18958 CFI_ENDPROC
18959 -END(debug)
18960 +ENDPROC(debug)
18961
18962 /*
18963 * NMI is doubly nasty. It can happen _while_ we're handling
18964 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18965 xorl %edx,%edx # zero error code
18966 movl %esp,%eax # pt_regs pointer
18967 call do_nmi
18968 +
18969 + pax_exit_kernel
18970 +
18971 jmp restore_all_notrace
18972 CFI_ENDPROC
18973
18974 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18975 FIXUP_ESPFIX_STACK # %eax == %esp
18976 xorl %edx,%edx # zero error code
18977 call do_nmi
18978 +
18979 + pax_exit_kernel
18980 +
18981 RESTORE_REGS
18982 lss 12+4(%esp), %esp # back to espfix stack
18983 CFI_ADJUST_CFA_OFFSET -24
18984 jmp irq_return
18985 CFI_ENDPROC
18986 -END(nmi)
18987 +ENDPROC(nmi)
18988
18989 ENTRY(int3)
18990 RING0_INT_FRAME
18991 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18992 call do_int3
18993 jmp ret_from_exception
18994 CFI_ENDPROC
18995 -END(int3)
18996 +ENDPROC(int3)
18997
18998 ENTRY(general_protection)
18999 RING0_EC_FRAME
19000 pushl_cfi $do_general_protection
19001 jmp error_code
19002 CFI_ENDPROC
19003 -END(general_protection)
19004 +ENDPROC(general_protection)
19005
19006 #ifdef CONFIG_KVM_GUEST
19007 ENTRY(async_page_fault)
19008 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
19009 pushl_cfi $do_async_page_fault
19010 jmp error_code
19011 CFI_ENDPROC
19012 -END(async_page_fault)
19013 +ENDPROC(async_page_fault)
19014 #endif
19015
19016 /*
19017 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19018 index c1d01e6..7f633850 100644
19019 --- a/arch/x86/kernel/entry_64.S
19020 +++ b/arch/x86/kernel/entry_64.S
19021 @@ -59,6 +59,8 @@
19022 #include <asm/context_tracking.h>
19023 #include <asm/smap.h>
19024 #include <linux/err.h>
19025 +#include <asm/pgtable.h>
19026 +#include <asm/alternative-asm.h>
19027
19028 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19029 #include <linux/elf-em.h>
19030 @@ -80,8 +82,9 @@
19031 #ifdef CONFIG_DYNAMIC_FTRACE
19032
19033 ENTRY(function_hook)
19034 + pax_force_retaddr
19035 retq
19036 -END(function_hook)
19037 +ENDPROC(function_hook)
19038
19039 /* skip is set if stack has been adjusted */
19040 .macro ftrace_caller_setup skip=0
19041 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19042 #endif
19043
19044 GLOBAL(ftrace_stub)
19045 + pax_force_retaddr
19046 retq
19047 -END(ftrace_caller)
19048 +ENDPROC(ftrace_caller)
19049
19050 ENTRY(ftrace_regs_caller)
19051 /* Save the current flags before compare (in SS location)*/
19052 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19053 popfq
19054 jmp ftrace_stub
19055
19056 -END(ftrace_regs_caller)
19057 +ENDPROC(ftrace_regs_caller)
19058
19059
19060 #else /* ! CONFIG_DYNAMIC_FTRACE */
19061 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19062 #endif
19063
19064 GLOBAL(ftrace_stub)
19065 + pax_force_retaddr
19066 retq
19067
19068 trace:
19069 @@ -225,12 +230,13 @@ trace:
19070 #endif
19071 subq $MCOUNT_INSN_SIZE, %rdi
19072
19073 + pax_force_fptr ftrace_trace_function
19074 call *ftrace_trace_function
19075
19076 MCOUNT_RESTORE_FRAME
19077
19078 jmp ftrace_stub
19079 -END(function_hook)
19080 +ENDPROC(function_hook)
19081 #endif /* CONFIG_DYNAMIC_FTRACE */
19082 #endif /* CONFIG_FUNCTION_TRACER */
19083
19084 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19085
19086 MCOUNT_RESTORE_FRAME
19087
19088 + pax_force_retaddr
19089 retq
19090 -END(ftrace_graph_caller)
19091 +ENDPROC(ftrace_graph_caller)
19092
19093 GLOBAL(return_to_handler)
19094 subq $24, %rsp
19095 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19096 movq 8(%rsp), %rdx
19097 movq (%rsp), %rax
19098 addq $24, %rsp
19099 + pax_force_fptr %rdi
19100 jmp *%rdi
19101 +ENDPROC(return_to_handler)
19102 #endif
19103
19104
19105 @@ -284,6 +293,309 @@ ENTRY(native_usergs_sysret64)
19106 ENDPROC(native_usergs_sysret64)
19107 #endif /* CONFIG_PARAVIRT */
19108
19109 + .macro ljmpq sel, off
19110 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19111 + .byte 0x48; ljmp *1234f(%rip)
19112 + .pushsection .rodata
19113 + .align 16
19114 + 1234: .quad \off; .word \sel
19115 + .popsection
19116 +#else
19117 + pushq $\sel
19118 + pushq $\off
19119 + lretq
19120 +#endif
19121 + .endm
19122 +
19123 + .macro pax_enter_kernel
19124 + pax_set_fptr_mask
19125 +#ifdef CONFIG_PAX_KERNEXEC
19126 + call pax_enter_kernel
19127 +#endif
19128 + .endm
19129 +
19130 + .macro pax_exit_kernel
19131 +#ifdef CONFIG_PAX_KERNEXEC
19132 + call pax_exit_kernel
19133 +#endif
19134 + .endm
19135 +
19136 +#ifdef CONFIG_PAX_KERNEXEC
19137 +ENTRY(pax_enter_kernel)
19138 + pushq %rdi
19139 +
19140 +#ifdef CONFIG_PARAVIRT
19141 + PV_SAVE_REGS(CLBR_RDI)
19142 +#endif
19143 +
19144 + GET_CR0_INTO_RDI
19145 + bts $16,%rdi
19146 + jnc 3f
19147 + mov %cs,%edi
19148 + cmp $__KERNEL_CS,%edi
19149 + jnz 2f
19150 +1:
19151 +
19152 +#ifdef CONFIG_PARAVIRT
19153 + PV_RESTORE_REGS(CLBR_RDI)
19154 +#endif
19155 +
19156 + popq %rdi
19157 + pax_force_retaddr
19158 + retq
19159 +
19160 +2: ljmpq __KERNEL_CS,1b
19161 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19162 +4: SET_RDI_INTO_CR0
19163 + jmp 1b
19164 +ENDPROC(pax_enter_kernel)
19165 +
19166 +ENTRY(pax_exit_kernel)
19167 + pushq %rdi
19168 +
19169 +#ifdef CONFIG_PARAVIRT
19170 + PV_SAVE_REGS(CLBR_RDI)
19171 +#endif
19172 +
19173 + mov %cs,%rdi
19174 + cmp $__KERNEXEC_KERNEL_CS,%edi
19175 + jz 2f
19176 + GET_CR0_INTO_RDI
19177 + bts $16,%rdi
19178 + jnc 4f
19179 +1:
19180 +
19181 +#ifdef CONFIG_PARAVIRT
19182 + PV_RESTORE_REGS(CLBR_RDI);
19183 +#endif
19184 +
19185 + popq %rdi
19186 + pax_force_retaddr
19187 + retq
19188 +
19189 +2: GET_CR0_INTO_RDI
19190 + btr $16,%rdi
19191 + jnc 4f
19192 + ljmpq __KERNEL_CS,3f
19193 +3: SET_RDI_INTO_CR0
19194 + jmp 1b
19195 +4: ud2
19196 + jmp 4b
19197 +ENDPROC(pax_exit_kernel)
19198 +#endif
19199 +
19200 + .macro pax_enter_kernel_user
19201 + pax_set_fptr_mask
19202 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19203 + call pax_enter_kernel_user
19204 +#endif
19205 + .endm
19206 +
19207 + .macro pax_exit_kernel_user
19208 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19209 + call pax_exit_kernel_user
19210 +#endif
19211 +#ifdef CONFIG_PAX_RANDKSTACK
19212 + pushq %rax
19213 + pushq %r11
19214 + call pax_randomize_kstack
19215 + popq %r11
19216 + popq %rax
19217 +#endif
19218 + .endm
19219 +
19220 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19221 +ENTRY(pax_enter_kernel_user)
19222 + pushq %rdi
19223 + pushq %rbx
19224 +
19225 +#ifdef CONFIG_PARAVIRT
19226 + PV_SAVE_REGS(CLBR_RDI)
19227 +#endif
19228 +
19229 + GET_CR3_INTO_RDI
19230 + mov %rdi,%rbx
19231 + add $__START_KERNEL_map,%rbx
19232 + sub phys_base(%rip),%rbx
19233 +
19234 +#ifdef CONFIG_PARAVIRT
19235 + cmpl $0, pv_info+PARAVIRT_enabled
19236 + jz 1f
19237 + pushq %rdi
19238 + i = 0
19239 + .rept USER_PGD_PTRS
19240 + mov i*8(%rbx),%rsi
19241 + mov $0,%sil
19242 + lea i*8(%rbx),%rdi
19243 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19244 + i = i + 1
19245 + .endr
19246 + popq %rdi
19247 + jmp 2f
19248 +1:
19249 +#endif
19250 +
19251 + i = 0
19252 + .rept USER_PGD_PTRS
19253 + movb $0,i*8(%rbx)
19254 + i = i + 1
19255 + .endr
19256 +
19257 +#ifdef CONFIG_PARAVIRT
19258 +2:
19259 +#endif
19260 + SET_RDI_INTO_CR3
19261 +
19262 +#ifdef CONFIG_PAX_KERNEXEC
19263 + GET_CR0_INTO_RDI
19264 + bts $16,%rdi
19265 + SET_RDI_INTO_CR0
19266 +#endif
19267 +
19268 +#ifdef CONFIG_PARAVIRT
19269 + PV_RESTORE_REGS(CLBR_RDI)
19270 +#endif
19271 +
19272 + popq %rbx
19273 + popq %rdi
19274 + pax_force_retaddr
19275 + retq
19276 +ENDPROC(pax_enter_kernel_user)
19277 +
19278 +ENTRY(pax_exit_kernel_user)
19279 + pushq %rdi
19280 + pushq %rbx
19281 +
19282 +#ifdef CONFIG_PARAVIRT
19283 + PV_SAVE_REGS(CLBR_RDI)
19284 +#endif
19285 +
19286 +#ifdef CONFIG_PAX_KERNEXEC
19287 + GET_CR0_INTO_RDI
19288 + btr $16,%rdi
19289 + jnc 3f
19290 + SET_RDI_INTO_CR0
19291 +#endif
19292 +
19293 + GET_CR3_INTO_RDI
19294 + mov %rdi,%rbx
19295 + add $__START_KERNEL_map,%rbx
19296 + sub phys_base(%rip),%rbx
19297 +
19298 +#ifdef CONFIG_PARAVIRT
19299 + cmpl $0, pv_info+PARAVIRT_enabled
19300 + jz 1f
19301 + i = 0
19302 + .rept USER_PGD_PTRS
19303 + mov i*8(%rbx),%rsi
19304 + mov $0x67,%sil
19305 + lea i*8(%rbx),%rdi
19306 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19307 + i = i + 1
19308 + .endr
19309 + jmp 2f
19310 +1:
19311 +#endif
19312 +
19313 + i = 0
19314 + .rept USER_PGD_PTRS
19315 + movb $0x67,i*8(%rbx)
19316 + i = i + 1
19317 + .endr
19318 +
19319 +#ifdef CONFIG_PARAVIRT
19320 +2: PV_RESTORE_REGS(CLBR_RDI)
19321 +#endif
19322 +
19323 + popq %rbx
19324 + popq %rdi
19325 + pax_force_retaddr
19326 + retq
19327 +3: ud2
19328 + jmp 3b
19329 +ENDPROC(pax_exit_kernel_user)
19330 +#endif
19331 +
19332 + .macro pax_enter_kernel_nmi
19333 + pax_set_fptr_mask
19334 +
19335 +#ifdef CONFIG_PAX_KERNEXEC
19336 + GET_CR0_INTO_RDI
19337 + bts $16,%rdi
19338 + jc 110f
19339 + SET_RDI_INTO_CR0
19340 + or $2,%ebx
19341 +110:
19342 +#endif
19343 + .endm
19344 +
19345 + .macro pax_exit_kernel_nmi
19346 +#ifdef CONFIG_PAX_KERNEXEC
19347 + btr $1,%ebx
19348 + jnc 110f
19349 + GET_CR0_INTO_RDI
19350 + btr $16,%rdi
19351 + SET_RDI_INTO_CR0
19352 +110:
19353 +#endif
19354 + .endm
19355 +
19356 +.macro pax_erase_kstack
19357 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19358 + call pax_erase_kstack
19359 +#endif
19360 +.endm
19361 +
19362 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19363 +ENTRY(pax_erase_kstack)
19364 + pushq %rdi
19365 + pushq %rcx
19366 + pushq %rax
19367 + pushq %r11
19368 +
19369 + GET_THREAD_INFO(%r11)
19370 + mov TI_lowest_stack(%r11), %rdi
19371 + mov $-0xBEEF, %rax
19372 + std
19373 +
19374 +1: mov %edi, %ecx
19375 + and $THREAD_SIZE_asm - 1, %ecx
19376 + shr $3, %ecx
19377 + repne scasq
19378 + jecxz 2f
19379 +
19380 + cmp $2*8, %ecx
19381 + jc 2f
19382 +
19383 + mov $2*8, %ecx
19384 + repe scasq
19385 + jecxz 2f
19386 + jne 1b
19387 +
19388 +2: cld
19389 + mov %esp, %ecx
19390 + sub %edi, %ecx
19391 +
19392 + cmp $THREAD_SIZE_asm, %rcx
19393 + jb 3f
19394 + ud2
19395 +3:
19396 +
19397 + shr $3, %ecx
19398 + rep stosq
19399 +
19400 + mov TI_task_thread_sp0(%r11), %rdi
19401 + sub $256, %rdi
19402 + mov %rdi, TI_lowest_stack(%r11)
19403 +
19404 + popq %r11
19405 + popq %rax
19406 + popq %rcx
19407 + popq %rdi
19408 + pax_force_retaddr
19409 + ret
19410 +ENDPROC(pax_erase_kstack)
19411 +#endif
19412
19413 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19414 #ifdef CONFIG_TRACE_IRQFLAGS
19415 @@ -375,8 +687,8 @@ ENDPROC(native_usergs_sysret64)
19416 .endm
19417
19418 .macro UNFAKE_STACK_FRAME
19419 - addq $8*6, %rsp
19420 - CFI_ADJUST_CFA_OFFSET -(6*8)
19421 + addq $8*6 + ARG_SKIP, %rsp
19422 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19423 .endm
19424
19425 /*
19426 @@ -463,7 +775,7 @@ ENDPROC(native_usergs_sysret64)
19427 movq %rsp, %rsi
19428
19429 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19430 - testl $3, CS-RBP(%rsi)
19431 + testb $3, CS-RBP(%rsi)
19432 je 1f
19433 SWAPGS
19434 /*
19435 @@ -498,9 +810,10 @@ ENTRY(save_rest)
19436 movq_cfi r15, R15+16
19437 movq %r11, 8(%rsp) /* return address */
19438 FIXUP_TOP_OF_STACK %r11, 16
19439 + pax_force_retaddr
19440 ret
19441 CFI_ENDPROC
19442 -END(save_rest)
19443 +ENDPROC(save_rest)
19444
19445 /* save complete stack frame */
19446 .pushsection .kprobes.text, "ax"
19447 @@ -529,9 +842,10 @@ ENTRY(save_paranoid)
19448 js 1f /* negative -> in kernel */
19449 SWAPGS
19450 xorl %ebx,%ebx
19451 -1: ret
19452 +1: pax_force_retaddr_bts
19453 + ret
19454 CFI_ENDPROC
19455 -END(save_paranoid)
19456 +ENDPROC(save_paranoid)
19457 .popsection
19458
19459 /*
19460 @@ -553,7 +867,7 @@ ENTRY(ret_from_fork)
19461
19462 RESTORE_REST
19463
19464 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19465 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19466 jz 1f
19467
19468 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19469 @@ -571,7 +885,7 @@ ENTRY(ret_from_fork)
19470 RESTORE_REST
19471 jmp int_ret_from_sys_call
19472 CFI_ENDPROC
19473 -END(ret_from_fork)
19474 +ENDPROC(ret_from_fork)
19475
19476 /*
19477 * System call entry. Up to 6 arguments in registers are supported.
19478 @@ -608,7 +922,7 @@ END(ret_from_fork)
19479 ENTRY(system_call)
19480 CFI_STARTPROC simple
19481 CFI_SIGNAL_FRAME
19482 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19483 + CFI_DEF_CFA rsp,0
19484 CFI_REGISTER rip,rcx
19485 /*CFI_REGISTER rflags,r11*/
19486 SWAPGS_UNSAFE_STACK
19487 @@ -621,16 +935,23 @@ GLOBAL(system_call_after_swapgs)
19488
19489 movq %rsp,PER_CPU_VAR(old_rsp)
19490 movq PER_CPU_VAR(kernel_stack),%rsp
19491 + SAVE_ARGS 8*6,0
19492 + pax_enter_kernel_user
19493 +
19494 +#ifdef CONFIG_PAX_RANDKSTACK
19495 + pax_erase_kstack
19496 +#endif
19497 +
19498 /*
19499 * No need to follow this irqs off/on section - it's straight
19500 * and short:
19501 */
19502 ENABLE_INTERRUPTS(CLBR_NONE)
19503 - SAVE_ARGS 8,0
19504 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19505 movq %rcx,RIP-ARGOFFSET(%rsp)
19506 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19507 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19508 + GET_THREAD_INFO(%rcx)
19509 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19510 jnz tracesys
19511 system_call_fastpath:
19512 #if __SYSCALL_MASK == ~0
19513 @@ -640,7 +961,7 @@ system_call_fastpath:
19514 cmpl $__NR_syscall_max,%eax
19515 #endif
19516 ja badsys
19517 - movq %r10,%rcx
19518 + movq R10-ARGOFFSET(%rsp),%rcx
19519 call *sys_call_table(,%rax,8) # XXX: rip relative
19520 movq %rax,RAX-ARGOFFSET(%rsp)
19521 /*
19522 @@ -654,10 +975,13 @@ sysret_check:
19523 LOCKDEP_SYS_EXIT
19524 DISABLE_INTERRUPTS(CLBR_NONE)
19525 TRACE_IRQS_OFF
19526 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19527 + GET_THREAD_INFO(%rcx)
19528 + movl TI_flags(%rcx),%edx
19529 andl %edi,%edx
19530 jnz sysret_careful
19531 CFI_REMEMBER_STATE
19532 + pax_exit_kernel_user
19533 + pax_erase_kstack
19534 /*
19535 * sysretq will re-enable interrupts:
19536 */
19537 @@ -709,14 +1033,18 @@ badsys:
19538 * jump back to the normal fast path.
19539 */
19540 auditsys:
19541 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19542 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19543 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19544 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19545 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19546 movq %rax,%rsi /* 2nd arg: syscall number */
19547 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19548 call __audit_syscall_entry
19549 +
19550 + pax_erase_kstack
19551 +
19552 LOAD_ARGS 0 /* reload call-clobbered registers */
19553 + pax_set_fptr_mask
19554 jmp system_call_fastpath
19555
19556 /*
19557 @@ -737,7 +1065,7 @@ sysret_audit:
19558 /* Do syscall tracing */
19559 tracesys:
19560 #ifdef CONFIG_AUDITSYSCALL
19561 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19562 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19563 jz auditsys
19564 #endif
19565 SAVE_REST
19566 @@ -745,12 +1073,16 @@ tracesys:
19567 FIXUP_TOP_OF_STACK %rdi
19568 movq %rsp,%rdi
19569 call syscall_trace_enter
19570 +
19571 + pax_erase_kstack
19572 +
19573 /*
19574 * Reload arg registers from stack in case ptrace changed them.
19575 * We don't reload %rax because syscall_trace_enter() returned
19576 * the value it wants us to use in the table lookup.
19577 */
19578 LOAD_ARGS ARGOFFSET, 1
19579 + pax_set_fptr_mask
19580 RESTORE_REST
19581 #if __SYSCALL_MASK == ~0
19582 cmpq $__NR_syscall_max,%rax
19583 @@ -759,7 +1091,7 @@ tracesys:
19584 cmpl $__NR_syscall_max,%eax
19585 #endif
19586 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19587 - movq %r10,%rcx /* fixup for C */
19588 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19589 call *sys_call_table(,%rax,8)
19590 movq %rax,RAX-ARGOFFSET(%rsp)
19591 /* Use IRET because user could have changed frame */
19592 @@ -780,7 +1112,9 @@ GLOBAL(int_with_check)
19593 andl %edi,%edx
19594 jnz int_careful
19595 andl $~TS_COMPAT,TI_status(%rcx)
19596 - jmp retint_swapgs
19597 + pax_exit_kernel_user
19598 + pax_erase_kstack
19599 + jmp retint_swapgs_pax
19600
19601 /* Either reschedule or signal or syscall exit tracking needed. */
19602 /* First do a reschedule test. */
19603 @@ -826,7 +1160,7 @@ int_restore_rest:
19604 TRACE_IRQS_OFF
19605 jmp int_with_check
19606 CFI_ENDPROC
19607 -END(system_call)
19608 +ENDPROC(system_call)
19609
19610 .macro FORK_LIKE func
19611 ENTRY(stub_\func)
19612 @@ -839,9 +1173,10 @@ ENTRY(stub_\func)
19613 DEFAULT_FRAME 0 8 /* offset 8: return address */
19614 call sys_\func
19615 RESTORE_TOP_OF_STACK %r11, 8
19616 + pax_force_retaddr
19617 ret $REST_SKIP /* pop extended registers */
19618 CFI_ENDPROC
19619 -END(stub_\func)
19620 +ENDPROC(stub_\func)
19621 .endm
19622
19623 .macro FIXED_FRAME label,func
19624 @@ -851,9 +1186,10 @@ ENTRY(\label)
19625 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19626 call \func
19627 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19628 + pax_force_retaddr
19629 ret
19630 CFI_ENDPROC
19631 -END(\label)
19632 +ENDPROC(\label)
19633 .endm
19634
19635 FORK_LIKE clone
19636 @@ -870,9 +1206,10 @@ ENTRY(ptregscall_common)
19637 movq_cfi_restore R12+8, r12
19638 movq_cfi_restore RBP+8, rbp
19639 movq_cfi_restore RBX+8, rbx
19640 + pax_force_retaddr
19641 ret $REST_SKIP /* pop extended registers */
19642 CFI_ENDPROC
19643 -END(ptregscall_common)
19644 +ENDPROC(ptregscall_common)
19645
19646 ENTRY(stub_execve)
19647 CFI_STARTPROC
19648 @@ -885,7 +1222,7 @@ ENTRY(stub_execve)
19649 RESTORE_REST
19650 jmp int_ret_from_sys_call
19651 CFI_ENDPROC
19652 -END(stub_execve)
19653 +ENDPROC(stub_execve)
19654
19655 /*
19656 * sigreturn is special because it needs to restore all registers on return.
19657 @@ -902,7 +1239,7 @@ ENTRY(stub_rt_sigreturn)
19658 RESTORE_REST
19659 jmp int_ret_from_sys_call
19660 CFI_ENDPROC
19661 -END(stub_rt_sigreturn)
19662 +ENDPROC(stub_rt_sigreturn)
19663
19664 #ifdef CONFIG_X86_X32_ABI
19665 ENTRY(stub_x32_rt_sigreturn)
19666 @@ -916,7 +1253,7 @@ ENTRY(stub_x32_rt_sigreturn)
19667 RESTORE_REST
19668 jmp int_ret_from_sys_call
19669 CFI_ENDPROC
19670 -END(stub_x32_rt_sigreturn)
19671 +ENDPROC(stub_x32_rt_sigreturn)
19672
19673 ENTRY(stub_x32_execve)
19674 CFI_STARTPROC
19675 @@ -930,7 +1267,7 @@ ENTRY(stub_x32_execve)
19676 RESTORE_REST
19677 jmp int_ret_from_sys_call
19678 CFI_ENDPROC
19679 -END(stub_x32_execve)
19680 +ENDPROC(stub_x32_execve)
19681
19682 #endif
19683
19684 @@ -967,7 +1304,7 @@ vector=vector+1
19685 2: jmp common_interrupt
19686 .endr
19687 CFI_ENDPROC
19688 -END(irq_entries_start)
19689 +ENDPROC(irq_entries_start)
19690
19691 .previous
19692 END(interrupt)
19693 @@ -987,6 +1324,16 @@ END(interrupt)
19694 subq $ORIG_RAX-RBP, %rsp
19695 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19696 SAVE_ARGS_IRQ
19697 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19698 + testb $3, CS(%rdi)
19699 + jnz 1f
19700 + pax_enter_kernel
19701 + jmp 2f
19702 +1: pax_enter_kernel_user
19703 +2:
19704 +#else
19705 + pax_enter_kernel
19706 +#endif
19707 call \func
19708 .endm
19709
19710 @@ -1019,7 +1366,7 @@ ret_from_intr:
19711
19712 exit_intr:
19713 GET_THREAD_INFO(%rcx)
19714 - testl $3,CS-ARGOFFSET(%rsp)
19715 + testb $3,CS-ARGOFFSET(%rsp)
19716 je retint_kernel
19717
19718 /* Interrupt came from user space */
19719 @@ -1041,12 +1388,16 @@ retint_swapgs: /* return to user-space */
19720 * The iretq could re-enable interrupts:
19721 */
19722 DISABLE_INTERRUPTS(CLBR_ANY)
19723 + pax_exit_kernel_user
19724 +retint_swapgs_pax:
19725 TRACE_IRQS_IRETQ
19726 SWAPGS
19727 jmp restore_args
19728
19729 retint_restore_args: /* return to kernel space */
19730 DISABLE_INTERRUPTS(CLBR_ANY)
19731 + pax_exit_kernel
19732 + pax_force_retaddr (RIP-ARGOFFSET)
19733 /*
19734 * The iretq could re-enable interrupts:
19735 */
19736 @@ -1129,7 +1480,7 @@ ENTRY(retint_kernel)
19737 #endif
19738
19739 CFI_ENDPROC
19740 -END(common_interrupt)
19741 +ENDPROC(common_interrupt)
19742 /*
19743 * End of kprobes section
19744 */
19745 @@ -1147,7 +1498,7 @@ ENTRY(\sym)
19746 interrupt \do_sym
19747 jmp ret_from_intr
19748 CFI_ENDPROC
19749 -END(\sym)
19750 +ENDPROC(\sym)
19751 .endm
19752
19753 #ifdef CONFIG_SMP
19754 @@ -1203,12 +1554,22 @@ ENTRY(\sym)
19755 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19756 call error_entry
19757 DEFAULT_FRAME 0
19758 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19759 + testb $3, CS(%rsp)
19760 + jnz 1f
19761 + pax_enter_kernel
19762 + jmp 2f
19763 +1: pax_enter_kernel_user
19764 +2:
19765 +#else
19766 + pax_enter_kernel
19767 +#endif
19768 movq %rsp,%rdi /* pt_regs pointer */
19769 xorl %esi,%esi /* no error code */
19770 call \do_sym
19771 jmp error_exit /* %ebx: no swapgs flag */
19772 CFI_ENDPROC
19773 -END(\sym)
19774 +ENDPROC(\sym)
19775 .endm
19776
19777 .macro paranoidzeroentry sym do_sym
19778 @@ -1221,15 +1582,25 @@ ENTRY(\sym)
19779 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19780 call save_paranoid
19781 TRACE_IRQS_OFF
19782 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19783 + testb $3, CS(%rsp)
19784 + jnz 1f
19785 + pax_enter_kernel
19786 + jmp 2f
19787 +1: pax_enter_kernel_user
19788 +2:
19789 +#else
19790 + pax_enter_kernel
19791 +#endif
19792 movq %rsp,%rdi /* pt_regs pointer */
19793 xorl %esi,%esi /* no error code */
19794 call \do_sym
19795 jmp paranoid_exit /* %ebx: no swapgs flag */
19796 CFI_ENDPROC
19797 -END(\sym)
19798 +ENDPROC(\sym)
19799 .endm
19800
19801 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19802 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19803 .macro paranoidzeroentry_ist sym do_sym ist
19804 ENTRY(\sym)
19805 INTR_FRAME
19806 @@ -1240,14 +1611,30 @@ ENTRY(\sym)
19807 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19808 call save_paranoid
19809 TRACE_IRQS_OFF_DEBUG
19810 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19811 + testb $3, CS(%rsp)
19812 + jnz 1f
19813 + pax_enter_kernel
19814 + jmp 2f
19815 +1: pax_enter_kernel_user
19816 +2:
19817 +#else
19818 + pax_enter_kernel
19819 +#endif
19820 movq %rsp,%rdi /* pt_regs pointer */
19821 xorl %esi,%esi /* no error code */
19822 +#ifdef CONFIG_SMP
19823 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19824 + lea init_tss(%r12), %r12
19825 +#else
19826 + lea init_tss(%rip), %r12
19827 +#endif
19828 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19829 call \do_sym
19830 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19831 jmp paranoid_exit /* %ebx: no swapgs flag */
19832 CFI_ENDPROC
19833 -END(\sym)
19834 +ENDPROC(\sym)
19835 .endm
19836
19837 .macro errorentry sym do_sym
19838 @@ -1259,13 +1646,23 @@ ENTRY(\sym)
19839 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19840 call error_entry
19841 DEFAULT_FRAME 0
19842 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19843 + testb $3, CS(%rsp)
19844 + jnz 1f
19845 + pax_enter_kernel
19846 + jmp 2f
19847 +1: pax_enter_kernel_user
19848 +2:
19849 +#else
19850 + pax_enter_kernel
19851 +#endif
19852 movq %rsp,%rdi /* pt_regs pointer */
19853 movq ORIG_RAX(%rsp),%rsi /* get error code */
19854 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19855 call \do_sym
19856 jmp error_exit /* %ebx: no swapgs flag */
19857 CFI_ENDPROC
19858 -END(\sym)
19859 +ENDPROC(\sym)
19860 .endm
19861
19862 /* error code is on the stack already */
19863 @@ -1279,13 +1676,23 @@ ENTRY(\sym)
19864 call save_paranoid
19865 DEFAULT_FRAME 0
19866 TRACE_IRQS_OFF
19867 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19868 + testb $3, CS(%rsp)
19869 + jnz 1f
19870 + pax_enter_kernel
19871 + jmp 2f
19872 +1: pax_enter_kernel_user
19873 +2:
19874 +#else
19875 + pax_enter_kernel
19876 +#endif
19877 movq %rsp,%rdi /* pt_regs pointer */
19878 movq ORIG_RAX(%rsp),%rsi /* get error code */
19879 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19880 call \do_sym
19881 jmp paranoid_exit /* %ebx: no swapgs flag */
19882 CFI_ENDPROC
19883 -END(\sym)
19884 +ENDPROC(\sym)
19885 .endm
19886
19887 zeroentry divide_error do_divide_error
19888 @@ -1315,9 +1722,10 @@ gs_change:
19889 2: mfence /* workaround */
19890 SWAPGS
19891 popfq_cfi
19892 + pax_force_retaddr
19893 ret
19894 CFI_ENDPROC
19895 -END(native_load_gs_index)
19896 +ENDPROC(native_load_gs_index)
19897
19898 _ASM_EXTABLE(gs_change,bad_gs)
19899 .section .fixup,"ax"
19900 @@ -1345,9 +1753,10 @@ ENTRY(call_softirq)
19901 CFI_DEF_CFA_REGISTER rsp
19902 CFI_ADJUST_CFA_OFFSET -8
19903 decl PER_CPU_VAR(irq_count)
19904 + pax_force_retaddr
19905 ret
19906 CFI_ENDPROC
19907 -END(call_softirq)
19908 +ENDPROC(call_softirq)
19909
19910 #ifdef CONFIG_XEN
19911 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19912 @@ -1385,7 +1794,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19913 decl PER_CPU_VAR(irq_count)
19914 jmp error_exit
19915 CFI_ENDPROC
19916 -END(xen_do_hypervisor_callback)
19917 +ENDPROC(xen_do_hypervisor_callback)
19918
19919 /*
19920 * Hypervisor uses this for application faults while it executes.
19921 @@ -1444,7 +1853,7 @@ ENTRY(xen_failsafe_callback)
19922 SAVE_ALL
19923 jmp error_exit
19924 CFI_ENDPROC
19925 -END(xen_failsafe_callback)
19926 +ENDPROC(xen_failsafe_callback)
19927
19928 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19929 xen_hvm_callback_vector xen_evtchn_do_upcall
19930 @@ -1498,16 +1907,31 @@ ENTRY(paranoid_exit)
19931 TRACE_IRQS_OFF_DEBUG
19932 testl %ebx,%ebx /* swapgs needed? */
19933 jnz paranoid_restore
19934 - testl $3,CS(%rsp)
19935 + testb $3,CS(%rsp)
19936 jnz paranoid_userspace
19937 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19938 + pax_exit_kernel
19939 + TRACE_IRQS_IRETQ 0
19940 + SWAPGS_UNSAFE_STACK
19941 + RESTORE_ALL 8
19942 + pax_force_retaddr_bts
19943 + jmp irq_return
19944 +#endif
19945 paranoid_swapgs:
19946 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19947 + pax_exit_kernel_user
19948 +#else
19949 + pax_exit_kernel
19950 +#endif
19951 TRACE_IRQS_IRETQ 0
19952 SWAPGS_UNSAFE_STACK
19953 RESTORE_ALL 8
19954 jmp irq_return
19955 paranoid_restore:
19956 + pax_exit_kernel
19957 TRACE_IRQS_IRETQ_DEBUG 0
19958 RESTORE_ALL 8
19959 + pax_force_retaddr_bts
19960 jmp irq_return
19961 paranoid_userspace:
19962 GET_THREAD_INFO(%rcx)
19963 @@ -1536,7 +1960,7 @@ paranoid_schedule:
19964 TRACE_IRQS_OFF
19965 jmp paranoid_userspace
19966 CFI_ENDPROC
19967 -END(paranoid_exit)
19968 +ENDPROC(paranoid_exit)
19969
19970 /*
19971 * Exception entry point. This expects an error code/orig_rax on the stack.
19972 @@ -1563,12 +1987,13 @@ ENTRY(error_entry)
19973 movq_cfi r14, R14+8
19974 movq_cfi r15, R15+8
19975 xorl %ebx,%ebx
19976 - testl $3,CS+8(%rsp)
19977 + testb $3,CS+8(%rsp)
19978 je error_kernelspace
19979 error_swapgs:
19980 SWAPGS
19981 error_sti:
19982 TRACE_IRQS_OFF
19983 + pax_force_retaddr_bts
19984 ret
19985
19986 /*
19987 @@ -1595,7 +2020,7 @@ bstep_iret:
19988 movq %rcx,RIP+8(%rsp)
19989 jmp error_swapgs
19990 CFI_ENDPROC
19991 -END(error_entry)
19992 +ENDPROC(error_entry)
19993
19994
19995 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19996 @@ -1615,7 +2040,7 @@ ENTRY(error_exit)
19997 jnz retint_careful
19998 jmp retint_swapgs
19999 CFI_ENDPROC
20000 -END(error_exit)
20001 +ENDPROC(error_exit)
20002
20003 /*
20004 * Test if a given stack is an NMI stack or not.
20005 @@ -1673,9 +2098,11 @@ ENTRY(nmi)
20006 * If %cs was not the kernel segment, then the NMI triggered in user
20007 * space, which means it is definitely not nested.
20008 */
20009 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20010 + je 1f
20011 cmpl $__KERNEL_CS, 16(%rsp)
20012 jne first_nmi
20013 -
20014 +1:
20015 /*
20016 * Check the special variable on the stack to see if NMIs are
20017 * executing.
20018 @@ -1709,8 +2136,7 @@ nested_nmi:
20019
20020 1:
20021 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
20022 - leaq -1*8(%rsp), %rdx
20023 - movq %rdx, %rsp
20024 + subq $8, %rsp
20025 CFI_ADJUST_CFA_OFFSET 1*8
20026 leaq -10*8(%rsp), %rdx
20027 pushq_cfi $__KERNEL_DS
20028 @@ -1728,6 +2154,7 @@ nested_nmi_out:
20029 CFI_RESTORE rdx
20030
20031 /* No need to check faults here */
20032 +# pax_force_retaddr_bts
20033 INTERRUPT_RETURN
20034
20035 CFI_RESTORE_STATE
20036 @@ -1844,6 +2271,8 @@ end_repeat_nmi:
20037 */
20038 movq %cr2, %r12
20039
20040 + pax_enter_kernel_nmi
20041 +
20042 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20043 movq %rsp,%rdi
20044 movq $-1,%rsi
20045 @@ -1856,26 +2285,31 @@ end_repeat_nmi:
20046 movq %r12, %cr2
20047 1:
20048
20049 - testl %ebx,%ebx /* swapgs needed? */
20050 + testl $1,%ebx /* swapgs needed? */
20051 jnz nmi_restore
20052 nmi_swapgs:
20053 SWAPGS_UNSAFE_STACK
20054 nmi_restore:
20055 + pax_exit_kernel_nmi
20056 /* Pop the extra iret frame at once */
20057 RESTORE_ALL 6*8
20058 + testb $3, 8(%rsp)
20059 + jnz 1f
20060 + pax_force_retaddr_bts
20061 +1:
20062
20063 /* Clear the NMI executing stack variable */
20064 movq $0, 5*8(%rsp)
20065 jmp irq_return
20066 CFI_ENDPROC
20067 -END(nmi)
20068 +ENDPROC(nmi)
20069
20070 ENTRY(ignore_sysret)
20071 CFI_STARTPROC
20072 mov $-ENOSYS,%eax
20073 sysret
20074 CFI_ENDPROC
20075 -END(ignore_sysret)
20076 +ENDPROC(ignore_sysret)
20077
20078 /*
20079 * End of kprobes section
20080 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20081 index 42a392a..fbbd930 100644
20082 --- a/arch/x86/kernel/ftrace.c
20083 +++ b/arch/x86/kernel/ftrace.c
20084 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20085 {
20086 unsigned char replaced[MCOUNT_INSN_SIZE];
20087
20088 + ip = ktla_ktva(ip);
20089 +
20090 /*
20091 * Note: Due to modules and __init, code can
20092 * disappear and change, we need to protect against faulting
20093 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20094 unsigned char old[MCOUNT_INSN_SIZE], *new;
20095 int ret;
20096
20097 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20098 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20099 new = ftrace_call_replace(ip, (unsigned long)func);
20100
20101 /* See comment above by declaration of modifying_ftrace_code */
20102 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20103 /* Also update the regs callback function */
20104 if (!ret) {
20105 ip = (unsigned long)(&ftrace_regs_call);
20106 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20107 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20108 new = ftrace_call_replace(ip, (unsigned long)func);
20109 ret = ftrace_modify_code(ip, old, new);
20110 }
20111 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20112 * kernel identity mapping to modify code.
20113 */
20114 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20115 - ip = (unsigned long)__va(__pa_symbol(ip));
20116 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20117
20118 return probe_kernel_write((void *)ip, val, size);
20119 }
20120 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20121 unsigned char replaced[MCOUNT_INSN_SIZE];
20122 unsigned char brk = BREAKPOINT_INSTRUCTION;
20123
20124 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20125 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20126 return -EFAULT;
20127
20128 /* Make sure it is what we expect it to be */
20129 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20130 return ret;
20131
20132 fail_update:
20133 - probe_kernel_write((void *)ip, &old_code[0], 1);
20134 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20135 goto out;
20136 }
20137
20138 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20139 {
20140 unsigned char code[MCOUNT_INSN_SIZE];
20141
20142 + ip = ktla_ktva(ip);
20143 +
20144 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20145 return -EFAULT;
20146
20147 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20148 index 8f3201d..aa860bf 100644
20149 --- a/arch/x86/kernel/head64.c
20150 +++ b/arch/x86/kernel/head64.c
20151 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20152 if (console_loglevel == 10)
20153 early_printk("Kernel alive\n");
20154
20155 - clear_page(init_level4_pgt);
20156 /* set init_level4_pgt kernel high mapping*/
20157 init_level4_pgt[511] = early_level4_pgt[511];
20158
20159 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20160 index 73afd11..d1670f5 100644
20161 --- a/arch/x86/kernel/head_32.S
20162 +++ b/arch/x86/kernel/head_32.S
20163 @@ -26,6 +26,12 @@
20164 /* Physical address */
20165 #define pa(X) ((X) - __PAGE_OFFSET)
20166
20167 +#ifdef CONFIG_PAX_KERNEXEC
20168 +#define ta(X) (X)
20169 +#else
20170 +#define ta(X) ((X) - __PAGE_OFFSET)
20171 +#endif
20172 +
20173 /*
20174 * References to members of the new_cpu_data structure.
20175 */
20176 @@ -55,11 +61,7 @@
20177 * and small than max_low_pfn, otherwise will waste some page table entries
20178 */
20179
20180 -#if PTRS_PER_PMD > 1
20181 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20182 -#else
20183 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20184 -#endif
20185 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20186
20187 /* Number of possible pages in the lowmem region */
20188 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20189 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20190 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20191
20192 /*
20193 + * Real beginning of normal "text" segment
20194 + */
20195 +ENTRY(stext)
20196 +ENTRY(_stext)
20197 +
20198 +/*
20199 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20200 * %esi points to the real-mode code as a 32-bit pointer.
20201 * CS and DS must be 4 GB flat segments, but we don't depend on
20202 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20203 * can.
20204 */
20205 __HEAD
20206 +
20207 +#ifdef CONFIG_PAX_KERNEXEC
20208 + jmp startup_32
20209 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20210 +.fill PAGE_SIZE-5,1,0xcc
20211 +#endif
20212 +
20213 ENTRY(startup_32)
20214 movl pa(stack_start),%ecx
20215
20216 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20217 2:
20218 leal -__PAGE_OFFSET(%ecx),%esp
20219
20220 +#ifdef CONFIG_SMP
20221 + movl $pa(cpu_gdt_table),%edi
20222 + movl $__per_cpu_load,%eax
20223 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20224 + rorl $16,%eax
20225 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20226 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20227 + movl $__per_cpu_end - 1,%eax
20228 + subl $__per_cpu_start,%eax
20229 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20230 +#endif
20231 +
20232 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20233 + movl $NR_CPUS,%ecx
20234 + movl $pa(cpu_gdt_table),%edi
20235 +1:
20236 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20237 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20238 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20239 + addl $PAGE_SIZE_asm,%edi
20240 + loop 1b
20241 +#endif
20242 +
20243 +#ifdef CONFIG_PAX_KERNEXEC
20244 + movl $pa(boot_gdt),%edi
20245 + movl $__LOAD_PHYSICAL_ADDR,%eax
20246 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20247 + rorl $16,%eax
20248 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20249 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20250 + rorl $16,%eax
20251 +
20252 + ljmp $(__BOOT_CS),$1f
20253 +1:
20254 +
20255 + movl $NR_CPUS,%ecx
20256 + movl $pa(cpu_gdt_table),%edi
20257 + addl $__PAGE_OFFSET,%eax
20258 +1:
20259 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20260 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20261 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20262 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20263 + rorl $16,%eax
20264 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20265 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20266 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20267 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20268 + rorl $16,%eax
20269 + addl $PAGE_SIZE_asm,%edi
20270 + loop 1b
20271 +#endif
20272 +
20273 /*
20274 * Clear BSS first so that there are no surprises...
20275 */
20276 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20277 movl %eax, pa(max_pfn_mapped)
20278
20279 /* Do early initialization of the fixmap area */
20280 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20281 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20282 +#ifdef CONFIG_COMPAT_VDSO
20283 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20284 +#else
20285 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20286 +#endif
20287 #else /* Not PAE */
20288
20289 page_pde_offset = (__PAGE_OFFSET >> 20);
20290 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20291 movl %eax, pa(max_pfn_mapped)
20292
20293 /* Do early initialization of the fixmap area */
20294 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20295 - movl %eax,pa(initial_page_table+0xffc)
20296 +#ifdef CONFIG_COMPAT_VDSO
20297 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20298 +#else
20299 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20300 +#endif
20301 #endif
20302
20303 #ifdef CONFIG_PARAVIRT
20304 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20305 cmpl $num_subarch_entries, %eax
20306 jae bad_subarch
20307
20308 - movl pa(subarch_entries)(,%eax,4), %eax
20309 - subl $__PAGE_OFFSET, %eax
20310 - jmp *%eax
20311 + jmp *pa(subarch_entries)(,%eax,4)
20312
20313 bad_subarch:
20314 WEAK(lguest_entry)
20315 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20316 __INITDATA
20317
20318 subarch_entries:
20319 - .long default_entry /* normal x86/PC */
20320 - .long lguest_entry /* lguest hypervisor */
20321 - .long xen_entry /* Xen hypervisor */
20322 - .long default_entry /* Moorestown MID */
20323 + .long ta(default_entry) /* normal x86/PC */
20324 + .long ta(lguest_entry) /* lguest hypervisor */
20325 + .long ta(xen_entry) /* Xen hypervisor */
20326 + .long ta(default_entry) /* Moorestown MID */
20327 num_subarch_entries = (. - subarch_entries) / 4
20328 .previous
20329 #else
20330 @@ -355,6 +427,7 @@ default_entry:
20331 movl pa(mmu_cr4_features),%eax
20332 movl %eax,%cr4
20333
20334 +#ifdef CONFIG_X86_PAE
20335 testb $X86_CR4_PAE, %al # check if PAE is enabled
20336 jz enable_paging
20337
20338 @@ -383,6 +456,9 @@ default_entry:
20339 /* Make changes effective */
20340 wrmsr
20341
20342 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20343 +#endif
20344 +
20345 enable_paging:
20346
20347 /*
20348 @@ -451,14 +527,20 @@ is486:
20349 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20350 movl %eax,%ss # after changing gdt.
20351
20352 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20353 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20354 movl %eax,%ds
20355 movl %eax,%es
20356
20357 movl $(__KERNEL_PERCPU), %eax
20358 movl %eax,%fs # set this cpu's percpu
20359
20360 +#ifdef CONFIG_CC_STACKPROTECTOR
20361 movl $(__KERNEL_STACK_CANARY),%eax
20362 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20363 + movl $(__USER_DS),%eax
20364 +#else
20365 + xorl %eax,%eax
20366 +#endif
20367 movl %eax,%gs
20368
20369 xorl %eax,%eax # Clear LDT
20370 @@ -534,8 +616,11 @@ setup_once:
20371 * relocation. Manually set base address in stack canary
20372 * segment descriptor.
20373 */
20374 - movl $gdt_page,%eax
20375 + movl $cpu_gdt_table,%eax
20376 movl $stack_canary,%ecx
20377 +#ifdef CONFIG_SMP
20378 + addl $__per_cpu_load,%ecx
20379 +#endif
20380 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20381 shrl $16, %ecx
20382 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20383 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20384 /* This is global to keep gas from relaxing the jumps */
20385 ENTRY(early_idt_handler)
20386 cld
20387 - cmpl $2,%ss:early_recursion_flag
20388 + cmpl $1,%ss:early_recursion_flag
20389 je hlt_loop
20390 incl %ss:early_recursion_flag
20391
20392 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20393 pushl (20+6*4)(%esp) /* trapno */
20394 pushl $fault_msg
20395 call printk
20396 -#endif
20397 call dump_stack
20398 +#endif
20399 hlt_loop:
20400 hlt
20401 jmp hlt_loop
20402 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20403 /* This is the default interrupt "handler" :-) */
20404 ALIGN
20405 ignore_int:
20406 - cld
20407 #ifdef CONFIG_PRINTK
20408 + cmpl $2,%ss:early_recursion_flag
20409 + je hlt_loop
20410 + incl %ss:early_recursion_flag
20411 + cld
20412 pushl %eax
20413 pushl %ecx
20414 pushl %edx
20415 @@ -634,9 +722,6 @@ ignore_int:
20416 movl $(__KERNEL_DS),%eax
20417 movl %eax,%ds
20418 movl %eax,%es
20419 - cmpl $2,early_recursion_flag
20420 - je hlt_loop
20421 - incl early_recursion_flag
20422 pushl 16(%esp)
20423 pushl 24(%esp)
20424 pushl 32(%esp)
20425 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20426 /*
20427 * BSS section
20428 */
20429 -__PAGE_ALIGNED_BSS
20430 - .align PAGE_SIZE
20431 #ifdef CONFIG_X86_PAE
20432 +.section .initial_pg_pmd,"a",@progbits
20433 initial_pg_pmd:
20434 .fill 1024*KPMDS,4,0
20435 #else
20436 +.section .initial_page_table,"a",@progbits
20437 ENTRY(initial_page_table)
20438 .fill 1024,4,0
20439 #endif
20440 +.section .initial_pg_fixmap,"a",@progbits
20441 initial_pg_fixmap:
20442 .fill 1024,4,0
20443 +.section .empty_zero_page,"a",@progbits
20444 ENTRY(empty_zero_page)
20445 .fill 4096,1,0
20446 +.section .swapper_pg_dir,"a",@progbits
20447 ENTRY(swapper_pg_dir)
20448 +#ifdef CONFIG_X86_PAE
20449 + .fill 4,8,0
20450 +#else
20451 .fill 1024,4,0
20452 +#endif
20453 +
20454 +/*
20455 + * The IDT has to be page-aligned to simplify the Pentium
20456 + * F0 0F bug workaround.. We have a special link segment
20457 + * for this.
20458 + */
20459 +.section .idt,"a",@progbits
20460 +ENTRY(idt_table)
20461 + .fill 256,8,0
20462
20463 /*
20464 * This starts the data section.
20465 */
20466 #ifdef CONFIG_X86_PAE
20467 -__PAGE_ALIGNED_DATA
20468 - /* Page-aligned for the benefit of paravirt? */
20469 - .align PAGE_SIZE
20470 +.section .initial_page_table,"a",@progbits
20471 ENTRY(initial_page_table)
20472 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20473 # if KPMDS == 3
20474 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20475 # error "Kernel PMDs should be 1, 2 or 3"
20476 # endif
20477 .align PAGE_SIZE /* needs to be page-sized too */
20478 +
20479 +#ifdef CONFIG_PAX_PER_CPU_PGD
20480 +ENTRY(cpu_pgd)
20481 + .rept NR_CPUS
20482 + .fill 4,8,0
20483 + .endr
20484 +#endif
20485 +
20486 #endif
20487
20488 .data
20489 .balign 4
20490 ENTRY(stack_start)
20491 - .long init_thread_union+THREAD_SIZE
20492 + .long init_thread_union+THREAD_SIZE-8
20493
20494 __INITRODATA
20495 int_msg:
20496 @@ -744,7 +851,7 @@ fault_msg:
20497 * segment size, and 32-bit linear address value:
20498 */
20499
20500 - .data
20501 +.section .rodata,"a",@progbits
20502 .globl boot_gdt_descr
20503 .globl idt_descr
20504
20505 @@ -753,7 +860,7 @@ fault_msg:
20506 .word 0 # 32 bit align gdt_desc.address
20507 boot_gdt_descr:
20508 .word __BOOT_DS+7
20509 - .long boot_gdt - __PAGE_OFFSET
20510 + .long pa(boot_gdt)
20511
20512 .word 0 # 32-bit align idt_desc.address
20513 idt_descr:
20514 @@ -764,7 +871,7 @@ idt_descr:
20515 .word 0 # 32 bit align gdt_desc.address
20516 ENTRY(early_gdt_descr)
20517 .word GDT_ENTRIES*8-1
20518 - .long gdt_page /* Overwritten for secondary CPUs */
20519 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20520
20521 /*
20522 * The boot_gdt must mirror the equivalent in setup.S and is
20523 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20524 .align L1_CACHE_BYTES
20525 ENTRY(boot_gdt)
20526 .fill GDT_ENTRY_BOOT_CS,8,0
20527 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20528 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20529 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20530 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20531 +
20532 + .align PAGE_SIZE_asm
20533 +ENTRY(cpu_gdt_table)
20534 + .rept NR_CPUS
20535 + .quad 0x0000000000000000 /* NULL descriptor */
20536 + .quad 0x0000000000000000 /* 0x0b reserved */
20537 + .quad 0x0000000000000000 /* 0x13 reserved */
20538 + .quad 0x0000000000000000 /* 0x1b reserved */
20539 +
20540 +#ifdef CONFIG_PAX_KERNEXEC
20541 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20542 +#else
20543 + .quad 0x0000000000000000 /* 0x20 unused */
20544 +#endif
20545 +
20546 + .quad 0x0000000000000000 /* 0x28 unused */
20547 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20548 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20549 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20550 + .quad 0x0000000000000000 /* 0x4b reserved */
20551 + .quad 0x0000000000000000 /* 0x53 reserved */
20552 + .quad 0x0000000000000000 /* 0x5b reserved */
20553 +
20554 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20555 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20556 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20557 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20558 +
20559 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20560 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20561 +
20562 + /*
20563 + * Segments used for calling PnP BIOS have byte granularity.
20564 + * The code segments and data segments have fixed 64k limits,
20565 + * the transfer segment sizes are set at run time.
20566 + */
20567 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20568 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20569 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20570 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20571 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20572 +
20573 + /*
20574 + * The APM segments have byte granularity and their bases
20575 + * are set at run time. All have 64k limits.
20576 + */
20577 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20578 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20579 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20580 +
20581 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20582 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20583 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20584 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20585 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20586 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20587 +
20588 + /* Be sure this is zeroed to avoid false validations in Xen */
20589 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20590 + .endr
20591 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20592 index 321d65e..7830f05 100644
20593 --- a/arch/x86/kernel/head_64.S
20594 +++ b/arch/x86/kernel/head_64.S
20595 @@ -20,6 +20,8 @@
20596 #include <asm/processor-flags.h>
20597 #include <asm/percpu.h>
20598 #include <asm/nops.h>
20599 +#include <asm/cpufeature.h>
20600 +#include <asm/alternative-asm.h>
20601
20602 #ifdef CONFIG_PARAVIRT
20603 #include <asm/asm-offsets.h>
20604 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20605 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20606 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20607 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20608 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20609 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20610 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20611 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20612 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20613 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20614
20615 .text
20616 __HEAD
20617 @@ -89,11 +97,15 @@ startup_64:
20618 * Fixup the physical addresses in the page table
20619 */
20620 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20621 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20622 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20623 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20624
20625 addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20626 addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20627
20628 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20629 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20630
20631 /*
20632 * Set up the identity mapping for the switchover. These
20633 @@ -177,8 +189,8 @@ ENTRY(secondary_startup_64)
20634 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20635 1:
20636
20637 - /* Enable PAE mode and PGE */
20638 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20639 + /* Enable PAE mode and PSE/PGE */
20640 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20641 movq %rcx, %cr4
20642
20643 /* Setup early boot stage 4 level pagetables. */
20644 @@ -199,10 +211,18 @@ ENTRY(secondary_startup_64)
20645 movl $MSR_EFER, %ecx
20646 rdmsr
20647 btsl $_EFER_SCE, %eax /* Enable System Call */
20648 - btl $20,%edi /* No Execute supported? */
20649 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20650 jnc 1f
20651 btsl $_EFER_NX, %eax
20652 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20653 + leaq init_level4_pgt(%rip), %rdi
20654 +#ifndef CONFIG_EFI
20655 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20656 +#endif
20657 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20658 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20659 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20660 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20661 1: wrmsr /* Make changes effective */
20662
20663 /* Setup cr0 */
20664 @@ -282,6 +302,7 @@ ENTRY(secondary_startup_64)
20665 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20666 * address given in m16:64.
20667 */
20668 + pax_set_fptr_mask
20669 movq initial_code(%rip),%rax
20670 pushq $0 # fake return address to stop unwinder
20671 pushq $__KERNEL_CS # set correct cs
20672 @@ -388,7 +409,7 @@ ENTRY(early_idt_handler)
20673 call dump_stack
20674 #ifdef CONFIG_KALLSYMS
20675 leaq early_idt_ripmsg(%rip),%rdi
20676 - movq 40(%rsp),%rsi # %rip again
20677 + movq 88(%rsp),%rsi # %rip again
20678 call __print_symbol
20679 #endif
20680 #endif /* EARLY_PRINTK */
20681 @@ -416,6 +437,7 @@ ENDPROC(early_idt_handler)
20682 early_recursion_flag:
20683 .long 0
20684
20685 + .section .rodata,"a",@progbits
20686 #ifdef CONFIG_EARLY_PRINTK
20687 early_idt_msg:
20688 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20689 @@ -445,27 +467,50 @@ NEXT_PAGE(early_dynamic_pgts)
20690
20691 .data
20692
20693 -#ifndef CONFIG_XEN
20694 NEXT_PAGE(init_level4_pgt)
20695 - .fill 512,8,0
20696 -#else
20697 -NEXT_PAGE(init_level4_pgt)
20698 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20699 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20700 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20701 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20702 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20703 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20704 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20705 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20706 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20707 .org init_level4_pgt + L4_START_KERNEL*8, 0
20708 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20709 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20710
20711 +#ifdef CONFIG_PAX_PER_CPU_PGD
20712 +NEXT_PAGE(cpu_pgd)
20713 + .rept NR_CPUS
20714 + .fill 512,8,0
20715 + .endr
20716 +#endif
20717 +
20718 NEXT_PAGE(level3_ident_pgt)
20719 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20720 +#ifdef CONFIG_XEN
20721 .fill 511, 8, 0
20722 +#else
20723 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20724 + .fill 510,8,0
20725 +#endif
20726 +
20727 +NEXT_PAGE(level3_vmalloc_start_pgt)
20728 + .fill 512,8,0
20729 +
20730 +NEXT_PAGE(level3_vmalloc_end_pgt)
20731 + .fill 512,8,0
20732 +
20733 +NEXT_PAGE(level3_vmemmap_pgt)
20734 + .fill L3_VMEMMAP_START,8,0
20735 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20736 +
20737 NEXT_PAGE(level2_ident_pgt)
20738 - /* Since I easily can, map the first 1G.
20739 + /* Since I easily can, map the first 2G.
20740 * Don't set NX because code runs from these pages.
20741 */
20742 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20743 -#endif
20744 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20745
20746 NEXT_PAGE(level3_kernel_pgt)
20747 .fill L3_START_KERNEL,8,0
20748 @@ -473,6 +518,9 @@ NEXT_PAGE(level3_kernel_pgt)
20749 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20750 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20751
20752 +NEXT_PAGE(level2_vmemmap_pgt)
20753 + .fill 512,8,0
20754 +
20755 NEXT_PAGE(level2_kernel_pgt)
20756 /*
20757 * 512 MB kernel mapping. We spend a full page on this pagetable
20758 @@ -488,39 +536,64 @@ NEXT_PAGE(level2_kernel_pgt)
20759 KERNEL_IMAGE_SIZE/PMD_SIZE)
20760
20761 NEXT_PAGE(level2_fixmap_pgt)
20762 - .fill 506,8,0
20763 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20764 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20765 - .fill 5,8,0
20766 + .fill 507,8,0
20767 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20768 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20769 + .fill 4,8,0
20770
20771 -NEXT_PAGE(level1_fixmap_pgt)
20772 +NEXT_PAGE(level1_vsyscall_pgt)
20773 .fill 512,8,0
20774
20775 #undef PMDS
20776
20777 - .data
20778 + .align PAGE_SIZE
20779 +ENTRY(cpu_gdt_table)
20780 + .rept NR_CPUS
20781 + .quad 0x0000000000000000 /* NULL descriptor */
20782 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20783 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20784 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20785 + .quad 0x00cffb000000ffff /* __USER32_CS */
20786 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20787 + .quad 0x00affb000000ffff /* __USER_CS */
20788 +
20789 +#ifdef CONFIG_PAX_KERNEXEC
20790 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20791 +#else
20792 + .quad 0x0 /* unused */
20793 +#endif
20794 +
20795 + .quad 0,0 /* TSS */
20796 + .quad 0,0 /* LDT */
20797 + .quad 0,0,0 /* three TLS descriptors */
20798 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20799 + /* asm/segment.h:GDT_ENTRIES must match this */
20800 +
20801 + /* zero the remaining page */
20802 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20803 + .endr
20804 +
20805 .align 16
20806 .globl early_gdt_descr
20807 early_gdt_descr:
20808 .word GDT_ENTRIES*8-1
20809 early_gdt_descr_base:
20810 - .quad INIT_PER_CPU_VAR(gdt_page)
20811 + .quad cpu_gdt_table
20812
20813 ENTRY(phys_base)
20814 /* This must match the first entry in level2_kernel_pgt */
20815 .quad 0x0000000000000000
20816
20817 #include "../../x86/xen/xen-head.S"
20818 -
20819 - .section .bss, "aw", @nobits
20820 +
20821 + .section .rodata,"a",@progbits
20822 .align L1_CACHE_BYTES
20823 ENTRY(idt_table)
20824 - .skip IDT_ENTRIES * 16
20825 + .fill 512,8,0
20826
20827 .align L1_CACHE_BYTES
20828 ENTRY(nmi_idt_table)
20829 - .skip IDT_ENTRIES * 16
20830 + .fill 512,8,0
20831
20832 - __PAGE_ALIGNED_BSS
20833 NEXT_PAGE(empty_zero_page)
20834 .skip PAGE_SIZE
20835 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20836 index 0fa6912..37fce70 100644
20837 --- a/arch/x86/kernel/i386_ksyms_32.c
20838 +++ b/arch/x86/kernel/i386_ksyms_32.c
20839 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20840 EXPORT_SYMBOL(cmpxchg8b_emu);
20841 #endif
20842
20843 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20844 +
20845 /* Networking helper routines. */
20846 EXPORT_SYMBOL(csum_partial_copy_generic);
20847 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20848 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20849
20850 EXPORT_SYMBOL(__get_user_1);
20851 EXPORT_SYMBOL(__get_user_2);
20852 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20853
20854 EXPORT_SYMBOL(csum_partial);
20855 EXPORT_SYMBOL(empty_zero_page);
20856 +
20857 +#ifdef CONFIG_PAX_KERNEXEC
20858 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20859 +#endif
20860 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20861 index cb33909..1163b40 100644
20862 --- a/arch/x86/kernel/i387.c
20863 +++ b/arch/x86/kernel/i387.c
20864 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20865 static inline bool interrupted_user_mode(void)
20866 {
20867 struct pt_regs *regs = get_irq_regs();
20868 - return regs && user_mode_vm(regs);
20869 + return regs && user_mode(regs);
20870 }
20871
20872 /*
20873 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20874 index 9a5c460..84868423 100644
20875 --- a/arch/x86/kernel/i8259.c
20876 +++ b/arch/x86/kernel/i8259.c
20877 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20878 static void make_8259A_irq(unsigned int irq)
20879 {
20880 disable_irq_nosync(irq);
20881 - io_apic_irqs &= ~(1<<irq);
20882 + io_apic_irqs &= ~(1UL<<irq);
20883 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20884 i8259A_chip.name);
20885 enable_irq(irq);
20886 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20887 "spurious 8259A interrupt: IRQ%d.\n", irq);
20888 spurious_irq_mask |= irqmask;
20889 }
20890 - atomic_inc(&irq_err_count);
20891 + atomic_inc_unchecked(&irq_err_count);
20892 /*
20893 * Theoretically we do not have to handle this IRQ,
20894 * but in Linux this does not cause problems and is
20895 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20896 /* (slave's support for AEOI in flat mode is to be investigated) */
20897 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20898
20899 + pax_open_kernel();
20900 if (auto_eoi)
20901 /*
20902 * In AEOI mode we just have to mask the interrupt
20903 * when acking.
20904 */
20905 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20906 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20907 else
20908 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20909 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20910 + pax_close_kernel();
20911
20912 udelay(100); /* wait for 8259A to initialize */
20913
20914 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20915 index a979b5b..1d6db75 100644
20916 --- a/arch/x86/kernel/io_delay.c
20917 +++ b/arch/x86/kernel/io_delay.c
20918 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20919 * Quirk table for systems that misbehave (lock up, etc.) if port
20920 * 0x80 is used:
20921 */
20922 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20923 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20924 {
20925 .callback = dmi_io_delay_0xed_port,
20926 .ident = "Compaq Presario V6000",
20927 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20928 index 4ddaf66..6292f4e 100644
20929 --- a/arch/x86/kernel/ioport.c
20930 +++ b/arch/x86/kernel/ioport.c
20931 @@ -6,6 +6,7 @@
20932 #include <linux/sched.h>
20933 #include <linux/kernel.h>
20934 #include <linux/capability.h>
20935 +#include <linux/security.h>
20936 #include <linux/errno.h>
20937 #include <linux/types.h>
20938 #include <linux/ioport.h>
20939 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20940
20941 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20942 return -EINVAL;
20943 +#ifdef CONFIG_GRKERNSEC_IO
20944 + if (turn_on && grsec_disable_privio) {
20945 + gr_handle_ioperm();
20946 + return -EPERM;
20947 + }
20948 +#endif
20949 if (turn_on && !capable(CAP_SYS_RAWIO))
20950 return -EPERM;
20951
20952 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20953 * because the ->io_bitmap_max value must match the bitmap
20954 * contents:
20955 */
20956 - tss = &per_cpu(init_tss, get_cpu());
20957 + tss = init_tss + get_cpu();
20958
20959 if (turn_on)
20960 bitmap_clear(t->io_bitmap_ptr, from, num);
20961 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20962 return -EINVAL;
20963 /* Trying to gain more privileges? */
20964 if (level > old) {
20965 +#ifdef CONFIG_GRKERNSEC_IO
20966 + if (grsec_disable_privio) {
20967 + gr_handle_iopl();
20968 + return -EPERM;
20969 + }
20970 +#endif
20971 if (!capable(CAP_SYS_RAWIO))
20972 return -EPERM;
20973 }
20974 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20975 index 84b7789..e65e8be 100644
20976 --- a/arch/x86/kernel/irq.c
20977 +++ b/arch/x86/kernel/irq.c
20978 @@ -18,7 +18,7 @@
20979 #include <asm/mce.h>
20980 #include <asm/hw_irq.h>
20981
20982 -atomic_t irq_err_count;
20983 +atomic_unchecked_t irq_err_count;
20984
20985 /* Function pointer for generic interrupt vector handling */
20986 void (*x86_platform_ipi_callback)(void) = NULL;
20987 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20988 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20989 seq_printf(p, " Machine check polls\n");
20990 #endif
20991 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20992 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20993 #if defined(CONFIG_X86_IO_APIC)
20994 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20995 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20996 #endif
20997 return 0;
20998 }
20999 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21000
21001 u64 arch_irq_stat(void)
21002 {
21003 - u64 sum = atomic_read(&irq_err_count);
21004 + u64 sum = atomic_read_unchecked(&irq_err_count);
21005 return sum;
21006 }
21007
21008 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21009 index 344faf8..355f60d 100644
21010 --- a/arch/x86/kernel/irq_32.c
21011 +++ b/arch/x86/kernel/irq_32.c
21012 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21013 __asm__ __volatile__("andl %%esp,%0" :
21014 "=r" (sp) : "0" (THREAD_SIZE - 1));
21015
21016 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21017 + return sp < STACK_WARN;
21018 }
21019
21020 static void print_stack_overflow(void)
21021 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21022 * per-CPU IRQ handling contexts (thread information and stack)
21023 */
21024 union irq_ctx {
21025 - struct thread_info tinfo;
21026 - u32 stack[THREAD_SIZE/sizeof(u32)];
21027 + unsigned long previous_esp;
21028 + u32 stack[THREAD_SIZE/sizeof(u32)];
21029 } __attribute__((aligned(THREAD_SIZE)));
21030
21031 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21032 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21033 static inline int
21034 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21035 {
21036 - union irq_ctx *curctx, *irqctx;
21037 + union irq_ctx *irqctx;
21038 u32 *isp, arg1, arg2;
21039
21040 - curctx = (union irq_ctx *) current_thread_info();
21041 irqctx = __this_cpu_read(hardirq_ctx);
21042
21043 /*
21044 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21045 * handler) we can't do that and just have to keep using the
21046 * current stack (which is the irq stack already after all)
21047 */
21048 - if (unlikely(curctx == irqctx))
21049 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21050 return 0;
21051
21052 /* build the stack frame on the IRQ stack */
21053 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21054 - irqctx->tinfo.task = curctx->tinfo.task;
21055 - irqctx->tinfo.previous_esp = current_stack_pointer;
21056 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21057 + irqctx->previous_esp = current_stack_pointer;
21058
21059 - /* Copy the preempt_count so that the [soft]irq checks work. */
21060 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21061 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21062 + __set_fs(MAKE_MM_SEG(0));
21063 +#endif
21064
21065 if (unlikely(overflow))
21066 call_on_stack(print_stack_overflow, isp);
21067 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21068 : "0" (irq), "1" (desc), "2" (isp),
21069 "D" (desc->handle_irq)
21070 : "memory", "cc", "ecx");
21071 +
21072 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21073 + __set_fs(current_thread_info()->addr_limit);
21074 +#endif
21075 +
21076 return 1;
21077 }
21078
21079 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21080 */
21081 void __cpuinit irq_ctx_init(int cpu)
21082 {
21083 - union irq_ctx *irqctx;
21084 -
21085 if (per_cpu(hardirq_ctx, cpu))
21086 return;
21087
21088 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21089 - THREADINFO_GFP,
21090 - THREAD_SIZE_ORDER));
21091 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21092 - irqctx->tinfo.cpu = cpu;
21093 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21094 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21095 -
21096 - per_cpu(hardirq_ctx, cpu) = irqctx;
21097 -
21098 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21099 - THREADINFO_GFP,
21100 - THREAD_SIZE_ORDER));
21101 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21102 - irqctx->tinfo.cpu = cpu;
21103 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21104 -
21105 - per_cpu(softirq_ctx, cpu) = irqctx;
21106 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21107 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21108 +
21109 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21110 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21111
21112 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21113 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21114 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21115 asmlinkage void do_softirq(void)
21116 {
21117 unsigned long flags;
21118 - struct thread_info *curctx;
21119 union irq_ctx *irqctx;
21120 u32 *isp;
21121
21122 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21123 local_irq_save(flags);
21124
21125 if (local_softirq_pending()) {
21126 - curctx = current_thread_info();
21127 irqctx = __this_cpu_read(softirq_ctx);
21128 - irqctx->tinfo.task = curctx->task;
21129 - irqctx->tinfo.previous_esp = current_stack_pointer;
21130 + irqctx->previous_esp = current_stack_pointer;
21131
21132 /* build the stack frame on the softirq stack */
21133 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21134 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21135 +
21136 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21137 + __set_fs(MAKE_MM_SEG(0));
21138 +#endif
21139
21140 call_on_stack(__do_softirq, isp);
21141 +
21142 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21143 + __set_fs(current_thread_info()->addr_limit);
21144 +#endif
21145 +
21146 /*
21147 * Shouldn't happen, we returned above if in_interrupt():
21148 */
21149 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21150 if (unlikely(!desc))
21151 return false;
21152
21153 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21154 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21155 if (unlikely(overflow))
21156 print_stack_overflow();
21157 desc->handle_irq(irq, desc);
21158 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21159 index d04d3ec..ea4b374 100644
21160 --- a/arch/x86/kernel/irq_64.c
21161 +++ b/arch/x86/kernel/irq_64.c
21162 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21163 u64 estack_top, estack_bottom;
21164 u64 curbase = (u64)task_stack_page(current);
21165
21166 - if (user_mode_vm(regs))
21167 + if (user_mode(regs))
21168 return;
21169
21170 if (regs->sp >= curbase + sizeof(struct thread_info) +
21171 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21172 index dc1404b..bbc43e7 100644
21173 --- a/arch/x86/kernel/kdebugfs.c
21174 +++ b/arch/x86/kernel/kdebugfs.c
21175 @@ -27,7 +27,7 @@ struct setup_data_node {
21176 u32 len;
21177 };
21178
21179 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21180 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21181 size_t count, loff_t *ppos)
21182 {
21183 struct setup_data_node *node = file->private_data;
21184 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21185 index 836f832..a8bda67 100644
21186 --- a/arch/x86/kernel/kgdb.c
21187 +++ b/arch/x86/kernel/kgdb.c
21188 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21189 #ifdef CONFIG_X86_32
21190 switch (regno) {
21191 case GDB_SS:
21192 - if (!user_mode_vm(regs))
21193 + if (!user_mode(regs))
21194 *(unsigned long *)mem = __KERNEL_DS;
21195 break;
21196 case GDB_SP:
21197 - if (!user_mode_vm(regs))
21198 + if (!user_mode(regs))
21199 *(unsigned long *)mem = kernel_stack_pointer(regs);
21200 break;
21201 case GDB_GS:
21202 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21203 bp->attr.bp_addr = breakinfo[breakno].addr;
21204 bp->attr.bp_len = breakinfo[breakno].len;
21205 bp->attr.bp_type = breakinfo[breakno].type;
21206 - info->address = breakinfo[breakno].addr;
21207 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21208 + info->address = ktla_ktva(breakinfo[breakno].addr);
21209 + else
21210 + info->address = breakinfo[breakno].addr;
21211 info->len = breakinfo[breakno].len;
21212 info->type = breakinfo[breakno].type;
21213 val = arch_install_hw_breakpoint(bp);
21214 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21215 case 'k':
21216 /* clear the trace bit */
21217 linux_regs->flags &= ~X86_EFLAGS_TF;
21218 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21219 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21220
21221 /* set the trace bit if we're stepping */
21222 if (remcomInBuffer[0] == 's') {
21223 linux_regs->flags |= X86_EFLAGS_TF;
21224 - atomic_set(&kgdb_cpu_doing_single_step,
21225 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21226 raw_smp_processor_id());
21227 }
21228
21229 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21230
21231 switch (cmd) {
21232 case DIE_DEBUG:
21233 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21234 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21235 if (user_mode(regs))
21236 return single_step_cont(regs, args);
21237 break;
21238 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21239 #endif /* CONFIG_DEBUG_RODATA */
21240
21241 bpt->type = BP_BREAKPOINT;
21242 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21243 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21244 BREAK_INSTR_SIZE);
21245 if (err)
21246 return err;
21247 - err = probe_kernel_write((char *)bpt->bpt_addr,
21248 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21249 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21250 #ifdef CONFIG_DEBUG_RODATA
21251 if (!err)
21252 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21253 return -EBUSY;
21254 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21255 BREAK_INSTR_SIZE);
21256 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21257 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21258 if (err)
21259 return err;
21260 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21261 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21262 if (mutex_is_locked(&text_mutex))
21263 goto knl_write;
21264 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21265 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21266 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21267 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21268 goto knl_write;
21269 return err;
21270 knl_write:
21271 #endif /* CONFIG_DEBUG_RODATA */
21272 - return probe_kernel_write((char *)bpt->bpt_addr,
21273 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21274 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21275 }
21276
21277 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21278 index 7bfe318..383d238 100644
21279 --- a/arch/x86/kernel/kprobes/core.c
21280 +++ b/arch/x86/kernel/kprobes/core.c
21281 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21282 s32 raddr;
21283 } __packed *insn;
21284
21285 - insn = (struct __arch_relative_insn *)from;
21286 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21287 +
21288 + pax_open_kernel();
21289 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21290 insn->op = op;
21291 + pax_close_kernel();
21292 }
21293
21294 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21295 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21296 kprobe_opcode_t opcode;
21297 kprobe_opcode_t *orig_opcodes = opcodes;
21298
21299 - if (search_exception_tables((unsigned long)opcodes))
21300 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21301 return 0; /* Page fault may occur on this address. */
21302
21303 retry:
21304 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21305 * for the first byte, we can recover the original instruction
21306 * from it and kp->opcode.
21307 */
21308 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21309 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21310 buf[0] = kp->opcode;
21311 - return (unsigned long)buf;
21312 + return ktva_ktla((unsigned long)buf);
21313 }
21314
21315 /*
21316 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21317 /* Another subsystem puts a breakpoint, failed to recover */
21318 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21319 return 0;
21320 + pax_open_kernel();
21321 memcpy(dest, insn.kaddr, insn.length);
21322 + pax_close_kernel();
21323
21324 #ifdef CONFIG_X86_64
21325 if (insn_rip_relative(&insn)) {
21326 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21327 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21328 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21329 disp = (u8 *) dest + insn_offset_displacement(&insn);
21330 + pax_open_kernel();
21331 *(s32 *) disp = (s32) newdisp;
21332 + pax_close_kernel();
21333 }
21334 #endif
21335 return insn.length;
21336 @@ -488,7 +495,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21337 * nor set current_kprobe, because it doesn't use single
21338 * stepping.
21339 */
21340 - regs->ip = (unsigned long)p->ainsn.insn;
21341 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21342 preempt_enable_no_resched();
21343 return;
21344 }
21345 @@ -505,9 +512,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21346 regs->flags &= ~X86_EFLAGS_IF;
21347 /* single step inline if the instruction is an int3 */
21348 if (p->opcode == BREAKPOINT_INSTRUCTION)
21349 - regs->ip = (unsigned long)p->addr;
21350 + regs->ip = ktla_ktva((unsigned long)p->addr);
21351 else
21352 - regs->ip = (unsigned long)p->ainsn.insn;
21353 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21354 }
21355
21356 /*
21357 @@ -586,7 +593,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21358 setup_singlestep(p, regs, kcb, 0);
21359 return 1;
21360 }
21361 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21362 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21363 /*
21364 * The breakpoint instruction was removed right
21365 * after we hit it. Another cpu has removed
21366 @@ -632,6 +639,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21367 " movq %rax, 152(%rsp)\n"
21368 RESTORE_REGS_STRING
21369 " popfq\n"
21370 +#ifdef KERNEXEC_PLUGIN
21371 + " btsq $63,(%rsp)\n"
21372 +#endif
21373 #else
21374 " pushf\n"
21375 SAVE_REGS_STRING
21376 @@ -769,7 +779,7 @@ static void __kprobes
21377 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21378 {
21379 unsigned long *tos = stack_addr(regs);
21380 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21381 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21382 unsigned long orig_ip = (unsigned long)p->addr;
21383 kprobe_opcode_t *insn = p->ainsn.insn;
21384
21385 @@ -951,7 +961,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21386 struct die_args *args = data;
21387 int ret = NOTIFY_DONE;
21388
21389 - if (args->regs && user_mode_vm(args->regs))
21390 + if (args->regs && user_mode(args->regs))
21391 return ret;
21392
21393 switch (val) {
21394 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21395 index 76dc6f0..66bdfc3 100644
21396 --- a/arch/x86/kernel/kprobes/opt.c
21397 +++ b/arch/x86/kernel/kprobes/opt.c
21398 @@ -79,6 +79,7 @@ found:
21399 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21400 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21401 {
21402 + pax_open_kernel();
21403 #ifdef CONFIG_X86_64
21404 *addr++ = 0x48;
21405 *addr++ = 0xbf;
21406 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21407 *addr++ = 0xb8;
21408 #endif
21409 *(unsigned long *)addr = val;
21410 + pax_close_kernel();
21411 }
21412
21413 static void __used __kprobes kprobes_optinsn_template_holder(void)
21414 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21415 * Verify if the address gap is in 2GB range, because this uses
21416 * a relative jump.
21417 */
21418 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21419 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21420 if (abs(rel) > 0x7fffffff)
21421 return -ERANGE;
21422
21423 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21424 op->optinsn.size = ret;
21425
21426 /* Copy arch-dep-instance from template */
21427 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21428 + pax_open_kernel();
21429 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21430 + pax_close_kernel();
21431
21432 /* Set probe information */
21433 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21434
21435 /* Set probe function call */
21436 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21437 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21438
21439 /* Set returning jmp instruction at the tail of out-of-line buffer */
21440 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21441 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21442 (u8 *)op->kp.addr + op->optinsn.size);
21443
21444 flush_icache_range((unsigned long) buf,
21445 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21446 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21447
21448 /* Backup instructions which will be replaced by jump address */
21449 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21450 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21451 RELATIVE_ADDR_SIZE);
21452
21453 insn_buf[0] = RELATIVEJUMP_OPCODE;
21454 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21455 /* This kprobe is really able to run optimized path. */
21456 op = container_of(p, struct optimized_kprobe, kp);
21457 /* Detour through copied instructions */
21458 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21459 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21460 if (!reenter)
21461 reset_current_kprobe();
21462 preempt_enable_no_resched();
21463 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21464 index b686a90..60d36fb 100644
21465 --- a/arch/x86/kernel/kvm.c
21466 +++ b/arch/x86/kernel/kvm.c
21467 @@ -453,7 +453,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21468 return NOTIFY_OK;
21469 }
21470
21471 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21472 +static struct notifier_block kvm_cpu_notifier = {
21473 .notifier_call = kvm_cpu_notify,
21474 };
21475 #endif
21476 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21477 index ebc9873..1b9724b 100644
21478 --- a/arch/x86/kernel/ldt.c
21479 +++ b/arch/x86/kernel/ldt.c
21480 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21481 if (reload) {
21482 #ifdef CONFIG_SMP
21483 preempt_disable();
21484 - load_LDT(pc);
21485 + load_LDT_nolock(pc);
21486 if (!cpumask_equal(mm_cpumask(current->mm),
21487 cpumask_of(smp_processor_id())))
21488 smp_call_function(flush_ldt, current->mm, 1);
21489 preempt_enable();
21490 #else
21491 - load_LDT(pc);
21492 + load_LDT_nolock(pc);
21493 #endif
21494 }
21495 if (oldsize) {
21496 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21497 return err;
21498
21499 for (i = 0; i < old->size; i++)
21500 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21501 + write_ldt_entry(new->ldt, i, old->ldt + i);
21502 return 0;
21503 }
21504
21505 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21506 retval = copy_ldt(&mm->context, &old_mm->context);
21507 mutex_unlock(&old_mm->context.lock);
21508 }
21509 +
21510 + if (tsk == current) {
21511 + mm->context.vdso = 0;
21512 +
21513 +#ifdef CONFIG_X86_32
21514 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21515 + mm->context.user_cs_base = 0UL;
21516 + mm->context.user_cs_limit = ~0UL;
21517 +
21518 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21519 + cpus_clear(mm->context.cpu_user_cs_mask);
21520 +#endif
21521 +
21522 +#endif
21523 +#endif
21524 +
21525 + }
21526 +
21527 return retval;
21528 }
21529
21530 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21531 }
21532 }
21533
21534 +#ifdef CONFIG_PAX_SEGMEXEC
21535 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21536 + error = -EINVAL;
21537 + goto out_unlock;
21538 + }
21539 +#endif
21540 +
21541 fill_ldt(&ldt, &ldt_info);
21542 if (oldmode)
21543 ldt.avl = 0;
21544 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21545 index 5b19e4d..6476a76 100644
21546 --- a/arch/x86/kernel/machine_kexec_32.c
21547 +++ b/arch/x86/kernel/machine_kexec_32.c
21548 @@ -26,7 +26,7 @@
21549 #include <asm/cacheflush.h>
21550 #include <asm/debugreg.h>
21551
21552 -static void set_idt(void *newidt, __u16 limit)
21553 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21554 {
21555 struct desc_ptr curidt;
21556
21557 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21558 }
21559
21560
21561 -static void set_gdt(void *newgdt, __u16 limit)
21562 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21563 {
21564 struct desc_ptr curgdt;
21565
21566 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21567 }
21568
21569 control_page = page_address(image->control_code_page);
21570 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21571 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21572
21573 relocate_kernel_ptr = control_page;
21574 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21575 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21576 index 22db92b..d546bec 100644
21577 --- a/arch/x86/kernel/microcode_core.c
21578 +++ b/arch/x86/kernel/microcode_core.c
21579 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21580 return NOTIFY_OK;
21581 }
21582
21583 -static struct notifier_block __refdata mc_cpu_notifier = {
21584 +static struct notifier_block mc_cpu_notifier = {
21585 .notifier_call = mc_cpu_callback,
21586 };
21587
21588 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21589 index 5fb2ceb..3ae90bb 100644
21590 --- a/arch/x86/kernel/microcode_intel.c
21591 +++ b/arch/x86/kernel/microcode_intel.c
21592 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21593
21594 static int get_ucode_user(void *to, const void *from, size_t n)
21595 {
21596 - return copy_from_user(to, from, n);
21597 + return copy_from_user(to, (const void __force_user *)from, n);
21598 }
21599
21600 static enum ucode_state
21601 request_microcode_user(int cpu, const void __user *buf, size_t size)
21602 {
21603 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21604 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21605 }
21606
21607 static void microcode_fini_cpu(int cpu)
21608 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21609 index 216a4d7..228255a 100644
21610 --- a/arch/x86/kernel/module.c
21611 +++ b/arch/x86/kernel/module.c
21612 @@ -43,15 +43,60 @@ do { \
21613 } while (0)
21614 #endif
21615
21616 -void *module_alloc(unsigned long size)
21617 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21618 {
21619 - if (PAGE_ALIGN(size) > MODULES_LEN)
21620 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21621 return NULL;
21622 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21623 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21624 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21625 -1, __builtin_return_address(0));
21626 }
21627
21628 +void *module_alloc(unsigned long size)
21629 +{
21630 +
21631 +#ifdef CONFIG_PAX_KERNEXEC
21632 + return __module_alloc(size, PAGE_KERNEL);
21633 +#else
21634 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21635 +#endif
21636 +
21637 +}
21638 +
21639 +#ifdef CONFIG_PAX_KERNEXEC
21640 +#ifdef CONFIG_X86_32
21641 +void *module_alloc_exec(unsigned long size)
21642 +{
21643 + struct vm_struct *area;
21644 +
21645 + if (size == 0)
21646 + return NULL;
21647 +
21648 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21649 + return area ? area->addr : NULL;
21650 +}
21651 +EXPORT_SYMBOL(module_alloc_exec);
21652 +
21653 +void module_free_exec(struct module *mod, void *module_region)
21654 +{
21655 + vunmap(module_region);
21656 +}
21657 +EXPORT_SYMBOL(module_free_exec);
21658 +#else
21659 +void module_free_exec(struct module *mod, void *module_region)
21660 +{
21661 + module_free(mod, module_region);
21662 +}
21663 +EXPORT_SYMBOL(module_free_exec);
21664 +
21665 +void *module_alloc_exec(unsigned long size)
21666 +{
21667 + return __module_alloc(size, PAGE_KERNEL_RX);
21668 +}
21669 +EXPORT_SYMBOL(module_alloc_exec);
21670 +#endif
21671 +#endif
21672 +
21673 #ifdef CONFIG_X86_32
21674 int apply_relocate(Elf32_Shdr *sechdrs,
21675 const char *strtab,
21676 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21677 unsigned int i;
21678 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21679 Elf32_Sym *sym;
21680 - uint32_t *location;
21681 + uint32_t *plocation, location;
21682
21683 DEBUGP("Applying relocate section %u to %u\n",
21684 relsec, sechdrs[relsec].sh_info);
21685 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21686 /* This is where to make the change */
21687 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21688 - + rel[i].r_offset;
21689 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21690 + location = (uint32_t)plocation;
21691 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21692 + plocation = ktla_ktva((void *)plocation);
21693 /* This is the symbol it is referring to. Note that all
21694 undefined symbols have been resolved. */
21695 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21696 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21697 switch (ELF32_R_TYPE(rel[i].r_info)) {
21698 case R_386_32:
21699 /* We add the value into the location given */
21700 - *location += sym->st_value;
21701 + pax_open_kernel();
21702 + *plocation += sym->st_value;
21703 + pax_close_kernel();
21704 break;
21705 case R_386_PC32:
21706 /* Add the value, subtract its position */
21707 - *location += sym->st_value - (uint32_t)location;
21708 + pax_open_kernel();
21709 + *plocation += sym->st_value - location;
21710 + pax_close_kernel();
21711 break;
21712 default:
21713 pr_err("%s: Unknown relocation: %u\n",
21714 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21715 case R_X86_64_NONE:
21716 break;
21717 case R_X86_64_64:
21718 + pax_open_kernel();
21719 *(u64 *)loc = val;
21720 + pax_close_kernel();
21721 break;
21722 case R_X86_64_32:
21723 + pax_open_kernel();
21724 *(u32 *)loc = val;
21725 + pax_close_kernel();
21726 if (val != *(u32 *)loc)
21727 goto overflow;
21728 break;
21729 case R_X86_64_32S:
21730 + pax_open_kernel();
21731 *(s32 *)loc = val;
21732 + pax_close_kernel();
21733 if ((s64)val != *(s32 *)loc)
21734 goto overflow;
21735 break;
21736 case R_X86_64_PC32:
21737 val -= (u64)loc;
21738 + pax_open_kernel();
21739 *(u32 *)loc = val;
21740 + pax_close_kernel();
21741 +
21742 #if 0
21743 if ((s64)val != *(s32 *)loc)
21744 goto overflow;
21745 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21746 index ce13049..e2e9c3c 100644
21747 --- a/arch/x86/kernel/msr.c
21748 +++ b/arch/x86/kernel/msr.c
21749 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21750 return notifier_from_errno(err);
21751 }
21752
21753 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21754 +static struct notifier_block msr_class_cpu_notifier = {
21755 .notifier_call = msr_class_cpu_callback,
21756 };
21757
21758 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21759 index 6030805..2d33f21 100644
21760 --- a/arch/x86/kernel/nmi.c
21761 +++ b/arch/x86/kernel/nmi.c
21762 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21763 return handled;
21764 }
21765
21766 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21767 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21768 {
21769 struct nmi_desc *desc = nmi_to_desc(type);
21770 unsigned long flags;
21771 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21772 * event confuses some handlers (kdump uses this flag)
21773 */
21774 if (action->flags & NMI_FLAG_FIRST)
21775 - list_add_rcu(&action->list, &desc->head);
21776 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21777 else
21778 - list_add_tail_rcu(&action->list, &desc->head);
21779 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21780
21781 spin_unlock_irqrestore(&desc->lock, flags);
21782 return 0;
21783 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21784 if (!strcmp(n->name, name)) {
21785 WARN(in_nmi(),
21786 "Trying to free NMI (%s) from NMI context!\n", n->name);
21787 - list_del_rcu(&n->list);
21788 + pax_list_del_rcu((struct list_head *)&n->list);
21789 break;
21790 }
21791 }
21792 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21793 dotraplinkage notrace __kprobes void
21794 do_nmi(struct pt_regs *regs, long error_code)
21795 {
21796 +
21797 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21798 + if (!user_mode(regs)) {
21799 + unsigned long cs = regs->cs & 0xFFFF;
21800 + unsigned long ip = ktva_ktla(regs->ip);
21801 +
21802 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21803 + regs->ip = ip;
21804 + }
21805 +#endif
21806 +
21807 nmi_nesting_preprocess(regs);
21808
21809 nmi_enter();
21810 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21811 index 6d9582e..f746287 100644
21812 --- a/arch/x86/kernel/nmi_selftest.c
21813 +++ b/arch/x86/kernel/nmi_selftest.c
21814 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21815 {
21816 /* trap all the unknown NMIs we may generate */
21817 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21818 - __initdata);
21819 + __initconst);
21820 }
21821
21822 static void __init cleanup_nmi_testsuite(void)
21823 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21824 unsigned long timeout;
21825
21826 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21827 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21828 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21829 nmi_fail = FAILURE;
21830 return;
21831 }
21832 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21833 index 676b8c7..870ba04 100644
21834 --- a/arch/x86/kernel/paravirt-spinlocks.c
21835 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21836 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21837 arch_spin_lock(lock);
21838 }
21839
21840 -struct pv_lock_ops pv_lock_ops = {
21841 +struct pv_lock_ops pv_lock_ops __read_only = {
21842 #ifdef CONFIG_SMP
21843 .spin_is_locked = __ticket_spin_is_locked,
21844 .spin_is_contended = __ticket_spin_is_contended,
21845 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21846 index 8bfb335..c1463c6 100644
21847 --- a/arch/x86/kernel/paravirt.c
21848 +++ b/arch/x86/kernel/paravirt.c
21849 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21850 {
21851 return x;
21852 }
21853 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21854 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21855 +#endif
21856
21857 void __init default_banner(void)
21858 {
21859 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21860 if (opfunc == NULL)
21861 /* If there's no function, patch it with a ud2a (BUG) */
21862 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21863 - else if (opfunc == _paravirt_nop)
21864 + else if (opfunc == (void *)_paravirt_nop)
21865 /* If the operation is a nop, then nop the callsite */
21866 ret = paravirt_patch_nop();
21867
21868 /* identity functions just return their single argument */
21869 - else if (opfunc == _paravirt_ident_32)
21870 + else if (opfunc == (void *)_paravirt_ident_32)
21871 ret = paravirt_patch_ident_32(insnbuf, len);
21872 - else if (opfunc == _paravirt_ident_64)
21873 + else if (opfunc == (void *)_paravirt_ident_64)
21874 ret = paravirt_patch_ident_64(insnbuf, len);
21875 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21876 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21877 + ret = paravirt_patch_ident_64(insnbuf, len);
21878 +#endif
21879
21880 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21881 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21882 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21883 if (insn_len > len || start == NULL)
21884 insn_len = len;
21885 else
21886 - memcpy(insnbuf, start, insn_len);
21887 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21888
21889 return insn_len;
21890 }
21891 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21892 return this_cpu_read(paravirt_lazy_mode);
21893 }
21894
21895 -struct pv_info pv_info = {
21896 +struct pv_info pv_info __read_only = {
21897 .name = "bare hardware",
21898 .paravirt_enabled = 0,
21899 .kernel_rpl = 0,
21900 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21901 #endif
21902 };
21903
21904 -struct pv_init_ops pv_init_ops = {
21905 +struct pv_init_ops pv_init_ops __read_only = {
21906 .patch = native_patch,
21907 };
21908
21909 -struct pv_time_ops pv_time_ops = {
21910 +struct pv_time_ops pv_time_ops __read_only = {
21911 .sched_clock = native_sched_clock,
21912 .steal_clock = native_steal_clock,
21913 };
21914
21915 -struct pv_irq_ops pv_irq_ops = {
21916 +struct pv_irq_ops pv_irq_ops __read_only = {
21917 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21918 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21919 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21920 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21921 #endif
21922 };
21923
21924 -struct pv_cpu_ops pv_cpu_ops = {
21925 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21926 .cpuid = native_cpuid,
21927 .get_debugreg = native_get_debugreg,
21928 .set_debugreg = native_set_debugreg,
21929 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21930 .end_context_switch = paravirt_nop,
21931 };
21932
21933 -struct pv_apic_ops pv_apic_ops = {
21934 +struct pv_apic_ops pv_apic_ops __read_only= {
21935 #ifdef CONFIG_X86_LOCAL_APIC
21936 .startup_ipi_hook = paravirt_nop,
21937 #endif
21938 };
21939
21940 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21941 +#ifdef CONFIG_X86_32
21942 +#ifdef CONFIG_X86_PAE
21943 +/* 64-bit pagetable entries */
21944 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21945 +#else
21946 /* 32-bit pagetable entries */
21947 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21948 +#endif
21949 #else
21950 /* 64-bit pagetable entries */
21951 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21952 #endif
21953
21954 -struct pv_mmu_ops pv_mmu_ops = {
21955 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21956
21957 .read_cr2 = native_read_cr2,
21958 .write_cr2 = native_write_cr2,
21959 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21960 .make_pud = PTE_IDENT,
21961
21962 .set_pgd = native_set_pgd,
21963 + .set_pgd_batched = native_set_pgd_batched,
21964 #endif
21965 #endif /* PAGETABLE_LEVELS >= 3 */
21966
21967 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21968 },
21969
21970 .set_fixmap = native_set_fixmap,
21971 +
21972 +#ifdef CONFIG_PAX_KERNEXEC
21973 + .pax_open_kernel = native_pax_open_kernel,
21974 + .pax_close_kernel = native_pax_close_kernel,
21975 +#endif
21976 +
21977 };
21978
21979 EXPORT_SYMBOL_GPL(pv_time_ops);
21980 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
21981 index 299d493..2ccb0ee 100644
21982 --- a/arch/x86/kernel/pci-calgary_64.c
21983 +++ b/arch/x86/kernel/pci-calgary_64.c
21984 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
21985 tce_space = be64_to_cpu(readq(target));
21986 tce_space = tce_space & TAR_SW_BITS;
21987
21988 - tce_space = tce_space & (~specified_table_size);
21989 + tce_space = tce_space & (~(unsigned long)specified_table_size);
21990 info->tce_space = (u64 *)__va(tce_space);
21991 }
21992 }
21993 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21994 index 35ccf75..7a15747 100644
21995 --- a/arch/x86/kernel/pci-iommu_table.c
21996 +++ b/arch/x86/kernel/pci-iommu_table.c
21997 @@ -2,7 +2,7 @@
21998 #include <asm/iommu_table.h>
21999 #include <linux/string.h>
22000 #include <linux/kallsyms.h>
22001 -
22002 +#include <linux/sched.h>
22003
22004 #define DEBUG 1
22005
22006 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22007 index 6c483ba..d10ce2f 100644
22008 --- a/arch/x86/kernel/pci-swiotlb.c
22009 +++ b/arch/x86/kernel/pci-swiotlb.c
22010 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22011 void *vaddr, dma_addr_t dma_addr,
22012 struct dma_attrs *attrs)
22013 {
22014 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22015 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22016 }
22017
22018 static struct dma_map_ops swiotlb_dma_ops = {
22019 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22020 index 14ae100..752a4f6 100644
22021 --- a/arch/x86/kernel/process.c
22022 +++ b/arch/x86/kernel/process.c
22023 @@ -36,7 +36,8 @@
22024 * section. Since TSS's are completely CPU-local, we want them
22025 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22026 */
22027 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22028 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22029 +EXPORT_SYMBOL(init_tss);
22030
22031 #ifdef CONFIG_X86_64
22032 static DEFINE_PER_CPU(unsigned char, is_idle);
22033 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22034 task_xstate_cachep =
22035 kmem_cache_create("task_xstate", xstate_size,
22036 __alignof__(union thread_xstate),
22037 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22038 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22039 }
22040
22041 /*
22042 @@ -105,7 +106,7 @@ void exit_thread(void)
22043 unsigned long *bp = t->io_bitmap_ptr;
22044
22045 if (bp) {
22046 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22047 + struct tss_struct *tss = init_tss + get_cpu();
22048
22049 t->io_bitmap_ptr = NULL;
22050 clear_thread_flag(TIF_IO_BITMAP);
22051 @@ -136,7 +137,7 @@ void show_regs_common(void)
22052 board = dmi_get_system_info(DMI_BOARD_NAME);
22053
22054 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22055 - current->pid, current->comm, print_tainted(),
22056 + task_pid_nr(current), current->comm, print_tainted(),
22057 init_utsname()->release,
22058 (int)strcspn(init_utsname()->version, " "),
22059 init_utsname()->version,
22060 @@ -149,6 +150,9 @@ void flush_thread(void)
22061 {
22062 struct task_struct *tsk = current;
22063
22064 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22065 + loadsegment(gs, 0);
22066 +#endif
22067 flush_ptrace_hw_breakpoint(tsk);
22068 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22069 drop_init_fpu(tsk);
22070 @@ -295,7 +299,7 @@ static void __exit_idle(void)
22071 void exit_idle(void)
22072 {
22073 /* idle loop has pid 0 */
22074 - if (current->pid)
22075 + if (task_pid_nr(current))
22076 return;
22077 __exit_idle();
22078 }
22079 @@ -398,7 +402,7 @@ bool xen_set_default_idle(void)
22080 return ret;
22081 }
22082 #endif
22083 -void stop_this_cpu(void *dummy)
22084 +__noreturn void stop_this_cpu(void *dummy)
22085 {
22086 local_irq_disable();
22087 /*
22088 @@ -544,16 +548,37 @@ static int __init idle_setup(char *str)
22089 }
22090 early_param("idle", idle_setup);
22091
22092 -unsigned long arch_align_stack(unsigned long sp)
22093 +#ifdef CONFIG_PAX_RANDKSTACK
22094 +void pax_randomize_kstack(struct pt_regs *regs)
22095 {
22096 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22097 - sp -= get_random_int() % 8192;
22098 - return sp & ~0xf;
22099 -}
22100 + struct thread_struct *thread = &current->thread;
22101 + unsigned long time;
22102
22103 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22104 -{
22105 - unsigned long range_end = mm->brk + 0x02000000;
22106 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22107 -}
22108 + if (!randomize_va_space)
22109 + return;
22110 +
22111 + if (v8086_mode(regs))
22112 + return;
22113
22114 + rdtscl(time);
22115 +
22116 + /* P4 seems to return a 0 LSB, ignore it */
22117 +#ifdef CONFIG_MPENTIUM4
22118 + time &= 0x3EUL;
22119 + time <<= 2;
22120 +#elif defined(CONFIG_X86_64)
22121 + time &= 0xFUL;
22122 + time <<= 4;
22123 +#else
22124 + time &= 0x1FUL;
22125 + time <<= 3;
22126 +#endif
22127 +
22128 + thread->sp0 ^= time;
22129 + load_sp0(init_tss + smp_processor_id(), thread);
22130 +
22131 +#ifdef CONFIG_X86_64
22132 + this_cpu_write(kernel_stack, thread->sp0);
22133 +#endif
22134 +}
22135 +#endif
22136 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22137 index b5a8905..d9cacac 100644
22138 --- a/arch/x86/kernel/process_32.c
22139 +++ b/arch/x86/kernel/process_32.c
22140 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22141 unsigned long thread_saved_pc(struct task_struct *tsk)
22142 {
22143 return ((unsigned long *)tsk->thread.sp)[3];
22144 +//XXX return tsk->thread.eip;
22145 }
22146
22147 void __show_regs(struct pt_regs *regs, int all)
22148 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22149 unsigned long sp;
22150 unsigned short ss, gs;
22151
22152 - if (user_mode_vm(regs)) {
22153 + if (user_mode(regs)) {
22154 sp = regs->sp;
22155 ss = regs->ss & 0xffff;
22156 - gs = get_user_gs(regs);
22157 } else {
22158 sp = kernel_stack_pointer(regs);
22159 savesegment(ss, ss);
22160 - savesegment(gs, gs);
22161 }
22162 + gs = get_user_gs(regs);
22163
22164 show_regs_common();
22165
22166 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22167 (u16)regs->cs, regs->ip, regs->flags,
22168 - smp_processor_id());
22169 + raw_smp_processor_id());
22170 print_symbol("EIP is at %s\n", regs->ip);
22171
22172 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22173 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22174 int copy_thread(unsigned long clone_flags, unsigned long sp,
22175 unsigned long arg, struct task_struct *p)
22176 {
22177 - struct pt_regs *childregs = task_pt_regs(p);
22178 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22179 struct task_struct *tsk;
22180 int err;
22181
22182 p->thread.sp = (unsigned long) childregs;
22183 p->thread.sp0 = (unsigned long) (childregs+1);
22184 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22185
22186 if (unlikely(p->flags & PF_KTHREAD)) {
22187 /* kernel thread */
22188 memset(childregs, 0, sizeof(struct pt_regs));
22189 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22190 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22191 - childregs->ds = __USER_DS;
22192 - childregs->es = __USER_DS;
22193 + savesegment(gs, childregs->gs);
22194 + childregs->ds = __KERNEL_DS;
22195 + childregs->es = __KERNEL_DS;
22196 childregs->fs = __KERNEL_PERCPU;
22197 childregs->bx = sp; /* function */
22198 childregs->bp = arg;
22199 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22200 struct thread_struct *prev = &prev_p->thread,
22201 *next = &next_p->thread;
22202 int cpu = smp_processor_id();
22203 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22204 + struct tss_struct *tss = init_tss + cpu;
22205 fpu_switch_t fpu;
22206
22207 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22208 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22209 */
22210 lazy_save_gs(prev->gs);
22211
22212 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22213 + __set_fs(task_thread_info(next_p)->addr_limit);
22214 +#endif
22215 +
22216 /*
22217 * Load the per-thread Thread-Local Storage descriptor.
22218 */
22219 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22220 */
22221 arch_end_context_switch(next_p);
22222
22223 + this_cpu_write(current_task, next_p);
22224 + this_cpu_write(current_tinfo, &next_p->tinfo);
22225 +
22226 /*
22227 * Restore %gs if needed (which is common)
22228 */
22229 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22230
22231 switch_fpu_finish(next_p, fpu);
22232
22233 - this_cpu_write(current_task, next_p);
22234 -
22235 return prev_p;
22236 }
22237
22238 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22239 } while (count++ < 16);
22240 return 0;
22241 }
22242 -
22243 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22244 index 0f49677..fcbf88c 100644
22245 --- a/arch/x86/kernel/process_64.c
22246 +++ b/arch/x86/kernel/process_64.c
22247 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22248 struct pt_regs *childregs;
22249 struct task_struct *me = current;
22250
22251 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22252 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22253 childregs = task_pt_regs(p);
22254 p->thread.sp = (unsigned long) childregs;
22255 p->thread.usersp = me->thread.usersp;
22256 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22257 set_tsk_thread_flag(p, TIF_FORK);
22258 p->fpu_counter = 0;
22259 p->thread.io_bitmap_ptr = NULL;
22260 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22261 struct thread_struct *prev = &prev_p->thread;
22262 struct thread_struct *next = &next_p->thread;
22263 int cpu = smp_processor_id();
22264 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22265 + struct tss_struct *tss = init_tss + cpu;
22266 unsigned fsindex, gsindex;
22267 fpu_switch_t fpu;
22268
22269 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22270 prev->usersp = this_cpu_read(old_rsp);
22271 this_cpu_write(old_rsp, next->usersp);
22272 this_cpu_write(current_task, next_p);
22273 + this_cpu_write(current_tinfo, &next_p->tinfo);
22274
22275 - this_cpu_write(kernel_stack,
22276 - (unsigned long)task_stack_page(next_p) +
22277 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22278 + this_cpu_write(kernel_stack, next->sp0);
22279
22280 /*
22281 * Now maybe reload the debug registers and handle I/O bitmaps
22282 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22283 if (!p || p == current || p->state == TASK_RUNNING)
22284 return 0;
22285 stack = (unsigned long)task_stack_page(p);
22286 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22287 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22288 return 0;
22289 fp = *(u64 *)(p->thread.sp);
22290 do {
22291 - if (fp < (unsigned long)stack ||
22292 - fp >= (unsigned long)stack+THREAD_SIZE)
22293 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22294 return 0;
22295 ip = *(u64 *)(fp+8);
22296 if (!in_sched_functions(ip))
22297 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22298 index 29a8120..a50b5ee 100644
22299 --- a/arch/x86/kernel/ptrace.c
22300 +++ b/arch/x86/kernel/ptrace.c
22301 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22302 {
22303 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22304 unsigned long sp = (unsigned long)&regs->sp;
22305 - struct thread_info *tinfo;
22306
22307 - if (context == (sp & ~(THREAD_SIZE - 1)))
22308 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22309 return sp;
22310
22311 - tinfo = (struct thread_info *)context;
22312 - if (tinfo->previous_esp)
22313 - return tinfo->previous_esp;
22314 + sp = *(unsigned long *)context;
22315 + if (sp)
22316 + return sp;
22317
22318 return (unsigned long)regs;
22319 }
22320 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22321 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22322 {
22323 int i;
22324 - int dr7 = 0;
22325 + unsigned long dr7 = 0;
22326 struct arch_hw_breakpoint *info;
22327
22328 for (i = 0; i < HBP_NUM; i++) {
22329 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22330 unsigned long addr, unsigned long data)
22331 {
22332 int ret;
22333 - unsigned long __user *datap = (unsigned long __user *)data;
22334 + unsigned long __user *datap = (__force unsigned long __user *)data;
22335
22336 switch (request) {
22337 /* read the word at location addr in the USER area. */
22338 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22339 if ((int) addr < 0)
22340 return -EIO;
22341 ret = do_get_thread_area(child, addr,
22342 - (struct user_desc __user *)data);
22343 + (__force struct user_desc __user *) data);
22344 break;
22345
22346 case PTRACE_SET_THREAD_AREA:
22347 if ((int) addr < 0)
22348 return -EIO;
22349 ret = do_set_thread_area(child, addr,
22350 - (struct user_desc __user *)data, 0);
22351 + (__force struct user_desc __user *) data, 0);
22352 break;
22353 #endif
22354
22355 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22356
22357 #ifdef CONFIG_X86_64
22358
22359 -static struct user_regset x86_64_regsets[] __read_mostly = {
22360 +static user_regset_no_const x86_64_regsets[] __read_only = {
22361 [REGSET_GENERAL] = {
22362 .core_note_type = NT_PRSTATUS,
22363 .n = sizeof(struct user_regs_struct) / sizeof(long),
22364 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22365 #endif /* CONFIG_X86_64 */
22366
22367 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22368 -static struct user_regset x86_32_regsets[] __read_mostly = {
22369 +static user_regset_no_const x86_32_regsets[] __read_only = {
22370 [REGSET_GENERAL] = {
22371 .core_note_type = NT_PRSTATUS,
22372 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22373 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22374 */
22375 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22376
22377 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22378 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22379 {
22380 #ifdef CONFIG_X86_64
22381 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22382 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22383 memset(info, 0, sizeof(*info));
22384 info->si_signo = SIGTRAP;
22385 info->si_code = si_code;
22386 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22387 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22388 }
22389
22390 void user_single_step_siginfo(struct task_struct *tsk,
22391 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22392 # define IS_IA32 0
22393 #endif
22394
22395 +#ifdef CONFIG_GRKERNSEC_SETXID
22396 +extern void gr_delayed_cred_worker(void);
22397 +#endif
22398 +
22399 /*
22400 * We must return the syscall number to actually look up in the table.
22401 * This can be -1L to skip running any syscall at all.
22402 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22403
22404 user_exit();
22405
22406 +#ifdef CONFIG_GRKERNSEC_SETXID
22407 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22408 + gr_delayed_cred_worker();
22409 +#endif
22410 +
22411 /*
22412 * If we stepped into a sysenter/syscall insn, it trapped in
22413 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22414 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22415 */
22416 user_exit();
22417
22418 +#ifdef CONFIG_GRKERNSEC_SETXID
22419 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22420 + gr_delayed_cred_worker();
22421 +#endif
22422 +
22423 audit_syscall_exit(regs);
22424
22425 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22426 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22427 index 2cb9470..ff1fd80 100644
22428 --- a/arch/x86/kernel/pvclock.c
22429 +++ b/arch/x86/kernel/pvclock.c
22430 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22431 return pv_tsc_khz;
22432 }
22433
22434 -static atomic64_t last_value = ATOMIC64_INIT(0);
22435 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22436
22437 void pvclock_resume(void)
22438 {
22439 - atomic64_set(&last_value, 0);
22440 + atomic64_set_unchecked(&last_value, 0);
22441 }
22442
22443 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22444 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22445 * updating at the same time, and one of them could be slightly behind,
22446 * making the assumption that last_value always go forward fail to hold.
22447 */
22448 - last = atomic64_read(&last_value);
22449 + last = atomic64_read_unchecked(&last_value);
22450 do {
22451 if (ret < last)
22452 return last;
22453 - last = atomic64_cmpxchg(&last_value, last, ret);
22454 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22455 } while (unlikely(last != ret));
22456
22457 return ret;
22458 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22459 index 76fa1e9..abf09ea 100644
22460 --- a/arch/x86/kernel/reboot.c
22461 +++ b/arch/x86/kernel/reboot.c
22462 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22463 EXPORT_SYMBOL(pm_power_off);
22464
22465 static const struct desc_ptr no_idt = {};
22466 -static int reboot_mode;
22467 +static unsigned short reboot_mode;
22468 enum reboot_type reboot_type = BOOT_ACPI;
22469 int reboot_force;
22470
22471 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22472
22473 void __noreturn machine_real_restart(unsigned int type)
22474 {
22475 +
22476 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22477 + struct desc_struct *gdt;
22478 +#endif
22479 +
22480 local_irq_disable();
22481
22482 /*
22483 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22484
22485 /* Jump to the identity-mapped low memory code */
22486 #ifdef CONFIG_X86_32
22487 - asm volatile("jmpl *%0" : :
22488 +
22489 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22490 + gdt = get_cpu_gdt_table(smp_processor_id());
22491 + pax_open_kernel();
22492 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22493 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22494 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22495 + loadsegment(ds, __KERNEL_DS);
22496 + loadsegment(es, __KERNEL_DS);
22497 + loadsegment(ss, __KERNEL_DS);
22498 +#endif
22499 +#ifdef CONFIG_PAX_KERNEXEC
22500 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22501 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22502 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22503 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22504 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22505 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22506 +#endif
22507 + pax_close_kernel();
22508 +#endif
22509 +
22510 + asm volatile("ljmpl *%0" : :
22511 "rm" (real_mode_header->machine_real_restart_asm),
22512 "a" (type));
22513 #else
22514 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22515 * try to force a triple fault and then cycle between hitting the keyboard
22516 * controller and doing that
22517 */
22518 -static void native_machine_emergency_restart(void)
22519 +static void __noreturn native_machine_emergency_restart(void)
22520 {
22521 int i;
22522 int attempt = 0;
22523 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22524 #endif
22525 }
22526
22527 -static void __machine_emergency_restart(int emergency)
22528 +static void __noreturn __machine_emergency_restart(int emergency)
22529 {
22530 reboot_emergency = emergency;
22531 machine_ops.emergency_restart();
22532 }
22533
22534 -static void native_machine_restart(char *__unused)
22535 +static void __noreturn native_machine_restart(char *__unused)
22536 {
22537 pr_notice("machine restart\n");
22538
22539 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22540 __machine_emergency_restart(0);
22541 }
22542
22543 -static void native_machine_halt(void)
22544 +static void __noreturn native_machine_halt(void)
22545 {
22546 /* Stop other cpus and apics */
22547 machine_shutdown();
22548 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22549 stop_this_cpu(NULL);
22550 }
22551
22552 -static void native_machine_power_off(void)
22553 +static void __noreturn native_machine_power_off(void)
22554 {
22555 if (pm_power_off) {
22556 if (!reboot_force)
22557 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22558 }
22559 /* A fallback in case there is no PM info available */
22560 tboot_shutdown(TB_SHUTDOWN_HALT);
22561 + unreachable();
22562 }
22563
22564 -struct machine_ops machine_ops = {
22565 +struct machine_ops machine_ops __read_only = {
22566 .power_off = native_machine_power_off,
22567 .shutdown = native_machine_shutdown,
22568 .emergency_restart = native_machine_emergency_restart,
22569 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22570 index f2bb9c9..bed145d7 100644
22571 --- a/arch/x86/kernel/relocate_kernel_64.S
22572 +++ b/arch/x86/kernel/relocate_kernel_64.S
22573 @@ -11,6 +11,7 @@
22574 #include <asm/kexec.h>
22575 #include <asm/processor-flags.h>
22576 #include <asm/pgtable_types.h>
22577 +#include <asm/alternative-asm.h>
22578
22579 /*
22580 * Must be relocatable PIC code callable as a C function
22581 @@ -167,6 +168,7 @@ identity_mapped:
22582 xorq %r14, %r14
22583 xorq %r15, %r15
22584
22585 + pax_force_retaddr 0, 1
22586 ret
22587
22588 1:
22589 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22590 index fae9134..8fcd87c 100644
22591 --- a/arch/x86/kernel/setup.c
22592 +++ b/arch/x86/kernel/setup.c
22593 @@ -111,6 +111,7 @@
22594 #include <asm/mce.h>
22595 #include <asm/alternative.h>
22596 #include <asm/prom.h>
22597 +#include <asm/boot.h>
22598
22599 /*
22600 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22601 @@ -447,7 +448,7 @@ static void __init parse_setup_data(void)
22602
22603 switch (data->type) {
22604 case SETUP_E820_EXT:
22605 - parse_e820_ext(data);
22606 + parse_e820_ext((struct setup_data __force_kernel *)data);
22607 break;
22608 case SETUP_DTB:
22609 add_dtb(pa_data);
22610 @@ -774,7 +775,7 @@ static void __init trim_bios_range(void)
22611 * area (640->1Mb) as ram even though it is not.
22612 * take them out.
22613 */
22614 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22615 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22616
22617 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22618 }
22619 @@ -782,7 +783,7 @@ static void __init trim_bios_range(void)
22620 /* called before trim_bios_range() to spare extra sanitize */
22621 static void __init e820_add_kernel_range(void)
22622 {
22623 - u64 start = __pa_symbol(_text);
22624 + u64 start = __pa_symbol(ktla_ktva(_text));
22625 u64 size = __pa_symbol(_end) - start;
22626
22627 /*
22628 @@ -844,8 +845,12 @@ static void __init trim_low_memory_range(void)
22629
22630 void __init setup_arch(char **cmdline_p)
22631 {
22632 +#ifdef CONFIG_X86_32
22633 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
22634 +#else
22635 memblock_reserve(__pa_symbol(_text),
22636 (unsigned long)__bss_stop - (unsigned long)_text);
22637 +#endif
22638
22639 early_reserve_initrd();
22640
22641 @@ -937,14 +942,14 @@ void __init setup_arch(char **cmdline_p)
22642
22643 if (!boot_params.hdr.root_flags)
22644 root_mountflags &= ~MS_RDONLY;
22645 - init_mm.start_code = (unsigned long) _text;
22646 - init_mm.end_code = (unsigned long) _etext;
22647 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22648 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22649 init_mm.end_data = (unsigned long) _edata;
22650 init_mm.brk = _brk_end;
22651
22652 - code_resource.start = __pa_symbol(_text);
22653 - code_resource.end = __pa_symbol(_etext)-1;
22654 - data_resource.start = __pa_symbol(_etext);
22655 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22656 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22657 + data_resource.start = __pa_symbol(_sdata);
22658 data_resource.end = __pa_symbol(_edata)-1;
22659 bss_resource.start = __pa_symbol(__bss_start);
22660 bss_resource.end = __pa_symbol(__bss_stop)-1;
22661 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22662 index 5cdff03..80fa283 100644
22663 --- a/arch/x86/kernel/setup_percpu.c
22664 +++ b/arch/x86/kernel/setup_percpu.c
22665 @@ -21,19 +21,17 @@
22666 #include <asm/cpu.h>
22667 #include <asm/stackprotector.h>
22668
22669 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22670 +#ifdef CONFIG_SMP
22671 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22672 EXPORT_PER_CPU_SYMBOL(cpu_number);
22673 +#endif
22674
22675 -#ifdef CONFIG_X86_64
22676 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22677 -#else
22678 -#define BOOT_PERCPU_OFFSET 0
22679 -#endif
22680
22681 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22682 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22683
22684 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22685 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22686 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22687 };
22688 EXPORT_SYMBOL(__per_cpu_offset);
22689 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22690 {
22691 #ifdef CONFIG_NEED_MULTIPLE_NODES
22692 pg_data_t *last = NULL;
22693 - unsigned int cpu;
22694 + int cpu;
22695
22696 for_each_possible_cpu(cpu) {
22697 int node = early_cpu_to_node(cpu);
22698 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22699 {
22700 #ifdef CONFIG_X86_32
22701 struct desc_struct gdt;
22702 + unsigned long base = per_cpu_offset(cpu);
22703
22704 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22705 - 0x2 | DESCTYPE_S, 0x8);
22706 - gdt.s = 1;
22707 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22708 + 0x83 | DESCTYPE_S, 0xC);
22709 write_gdt_entry(get_cpu_gdt_table(cpu),
22710 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22711 #endif
22712 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22713 /* alrighty, percpu areas up and running */
22714 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22715 for_each_possible_cpu(cpu) {
22716 +#ifdef CONFIG_CC_STACKPROTECTOR
22717 +#ifdef CONFIG_X86_32
22718 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22719 +#endif
22720 +#endif
22721 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22722 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22723 per_cpu(cpu_number, cpu) = cpu;
22724 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22725 */
22726 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22727 #endif
22728 +#ifdef CONFIG_CC_STACKPROTECTOR
22729 +#ifdef CONFIG_X86_32
22730 + if (!cpu)
22731 + per_cpu(stack_canary.canary, cpu) = canary;
22732 +#endif
22733 +#endif
22734 /*
22735 * Up to this point, the boot CPU has been using .init.data
22736 * area. Reload any changed state for the boot CPU.
22737 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22738 index 6956299..f20beae 100644
22739 --- a/arch/x86/kernel/signal.c
22740 +++ b/arch/x86/kernel/signal.c
22741 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22742 * Align the stack pointer according to the i386 ABI,
22743 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22744 */
22745 - sp = ((sp + 4) & -16ul) - 4;
22746 + sp = ((sp - 12) & -16ul) - 4;
22747 #else /* !CONFIG_X86_32 */
22748 sp = round_down(sp, 16) - 8;
22749 #endif
22750 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22751 }
22752
22753 if (current->mm->context.vdso)
22754 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22755 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22756 else
22757 - restorer = &frame->retcode;
22758 + restorer = (void __user *)&frame->retcode;
22759 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22760 restorer = ksig->ka.sa.sa_restorer;
22761
22762 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22763 * reasons and because gdb uses it as a signature to notice
22764 * signal handler stack frames.
22765 */
22766 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22767 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22768
22769 if (err)
22770 return -EFAULT;
22771 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22772 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22773
22774 /* Set up to return from userspace. */
22775 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22776 + if (current->mm->context.vdso)
22777 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22778 + else
22779 + restorer = (void __user *)&frame->retcode;
22780 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22781 restorer = ksig->ka.sa.sa_restorer;
22782 put_user_ex(restorer, &frame->pretcode);
22783 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22784 * reasons and because gdb uses it as a signature to notice
22785 * signal handler stack frames.
22786 */
22787 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22788 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22789 } put_user_catch(err);
22790
22791 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22792 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22793 {
22794 int usig = signr_convert(ksig->sig);
22795 sigset_t *set = sigmask_to_save();
22796 - compat_sigset_t *cset = (compat_sigset_t *) set;
22797 + sigset_t sigcopy;
22798 + compat_sigset_t *cset;
22799 +
22800 + sigcopy = *set;
22801 +
22802 + cset = (compat_sigset_t *) &sigcopy;
22803
22804 /* Set up the stack frame */
22805 if (is_ia32_frame()) {
22806 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22807 } else if (is_x32_frame()) {
22808 return x32_setup_rt_frame(ksig, cset, regs);
22809 } else {
22810 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22811 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22812 }
22813 }
22814
22815 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22816 index 48d2b7d..90d328a 100644
22817 --- a/arch/x86/kernel/smp.c
22818 +++ b/arch/x86/kernel/smp.c
22819 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22820
22821 __setup("nonmi_ipi", nonmi_ipi_setup);
22822
22823 -struct smp_ops smp_ops = {
22824 +struct smp_ops smp_ops __read_only = {
22825 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22826 .smp_prepare_cpus = native_smp_prepare_cpus,
22827 .smp_cpus_done = native_smp_cpus_done,
22828 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22829 index 9f190a2..90a0688 100644
22830 --- a/arch/x86/kernel/smpboot.c
22831 +++ b/arch/x86/kernel/smpboot.c
22832 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22833 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22834 (THREAD_SIZE + task_stack_page(idle))) - 1);
22835 per_cpu(current_task, cpu) = idle;
22836 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22837
22838 #ifdef CONFIG_X86_32
22839 /* Stack for startup_32 can be just as for start_secondary onwards */
22840 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22841 #else
22842 clear_tsk_thread_flag(idle, TIF_FORK);
22843 initial_gs = per_cpu_offset(cpu);
22844 - per_cpu(kernel_stack, cpu) =
22845 - (unsigned long)task_stack_page(idle) -
22846 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22847 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22848 #endif
22849 +
22850 + pax_open_kernel();
22851 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22852 + pax_close_kernel();
22853 +
22854 initial_code = (unsigned long)start_secondary;
22855 stack_start = idle->thread.sp;
22856
22857 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22858 /* the FPU context is blank, nobody can own it */
22859 __cpu_disable_lazy_restore(cpu);
22860
22861 +#ifdef CONFIG_PAX_PER_CPU_PGD
22862 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22863 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22864 + KERNEL_PGD_PTRS);
22865 +#endif
22866 +
22867 + /* the FPU context is blank, nobody can own it */
22868 + __cpu_disable_lazy_restore(cpu);
22869 +
22870 err = do_boot_cpu(apicid, cpu, tidle);
22871 if (err) {
22872 pr_debug("do_boot_cpu failed %d\n", err);
22873 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22874 index 9b4d51d..5d28b58 100644
22875 --- a/arch/x86/kernel/step.c
22876 +++ b/arch/x86/kernel/step.c
22877 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22878 struct desc_struct *desc;
22879 unsigned long base;
22880
22881 - seg &= ~7UL;
22882 + seg >>= 3;
22883
22884 mutex_lock(&child->mm->context.lock);
22885 - if (unlikely((seg >> 3) >= child->mm->context.size))
22886 + if (unlikely(seg >= child->mm->context.size))
22887 addr = -1L; /* bogus selector, access would fault */
22888 else {
22889 desc = child->mm->context.ldt + seg;
22890 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22891 addr += base;
22892 }
22893 mutex_unlock(&child->mm->context.lock);
22894 - }
22895 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22896 + addr = ktla_ktva(addr);
22897
22898 return addr;
22899 }
22900 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22901 unsigned char opcode[15];
22902 unsigned long addr = convert_ip_to_linear(child, regs);
22903
22904 + if (addr == -EINVAL)
22905 + return 0;
22906 +
22907 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22908 for (i = 0; i < copied; i++) {
22909 switch (opcode[i]) {
22910 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22911 new file mode 100644
22912 index 0000000..5877189
22913 --- /dev/null
22914 +++ b/arch/x86/kernel/sys_i386_32.c
22915 @@ -0,0 +1,189 @@
22916 +/*
22917 + * This file contains various random system calls that
22918 + * have a non-standard calling sequence on the Linux/i386
22919 + * platform.
22920 + */
22921 +
22922 +#include <linux/errno.h>
22923 +#include <linux/sched.h>
22924 +#include <linux/mm.h>
22925 +#include <linux/fs.h>
22926 +#include <linux/smp.h>
22927 +#include <linux/sem.h>
22928 +#include <linux/msg.h>
22929 +#include <linux/shm.h>
22930 +#include <linux/stat.h>
22931 +#include <linux/syscalls.h>
22932 +#include <linux/mman.h>
22933 +#include <linux/file.h>
22934 +#include <linux/utsname.h>
22935 +#include <linux/ipc.h>
22936 +#include <linux/elf.h>
22937 +
22938 +#include <linux/uaccess.h>
22939 +#include <linux/unistd.h>
22940 +
22941 +#include <asm/syscalls.h>
22942 +
22943 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22944 +{
22945 + unsigned long pax_task_size = TASK_SIZE;
22946 +
22947 +#ifdef CONFIG_PAX_SEGMEXEC
22948 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22949 + pax_task_size = SEGMEXEC_TASK_SIZE;
22950 +#endif
22951 +
22952 + if (flags & MAP_FIXED)
22953 + if (len > pax_task_size || addr > pax_task_size - len)
22954 + return -EINVAL;
22955 +
22956 + return 0;
22957 +}
22958 +
22959 +/*
22960 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
22961 + */
22962 +static unsigned long get_align_mask(void)
22963 +{
22964 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
22965 + return 0;
22966 +
22967 + if (!(current->flags & PF_RANDOMIZE))
22968 + return 0;
22969 +
22970 + return va_align.mask;
22971 +}
22972 +
22973 +unsigned long
22974 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22975 + unsigned long len, unsigned long pgoff, unsigned long flags)
22976 +{
22977 + struct mm_struct *mm = current->mm;
22978 + struct vm_area_struct *vma;
22979 + unsigned long pax_task_size = TASK_SIZE;
22980 + struct vm_unmapped_area_info info;
22981 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22982 +
22983 +#ifdef CONFIG_PAX_SEGMEXEC
22984 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22985 + pax_task_size = SEGMEXEC_TASK_SIZE;
22986 +#endif
22987 +
22988 + pax_task_size -= PAGE_SIZE;
22989 +
22990 + if (len > pax_task_size)
22991 + return -ENOMEM;
22992 +
22993 + if (flags & MAP_FIXED)
22994 + return addr;
22995 +
22996 +#ifdef CONFIG_PAX_RANDMMAP
22997 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22998 +#endif
22999 +
23000 + if (addr) {
23001 + addr = PAGE_ALIGN(addr);
23002 + if (pax_task_size - len >= addr) {
23003 + vma = find_vma(mm, addr);
23004 + if (check_heap_stack_gap(vma, addr, len, offset))
23005 + return addr;
23006 + }
23007 + }
23008 +
23009 + info.flags = 0;
23010 + info.length = len;
23011 + info.align_mask = filp ? get_align_mask() : 0;
23012 + info.align_offset = pgoff << PAGE_SHIFT;
23013 + info.threadstack_offset = offset;
23014 +
23015 +#ifdef CONFIG_PAX_PAGEEXEC
23016 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
23017 + info.low_limit = 0x00110000UL;
23018 + info.high_limit = mm->start_code;
23019 +
23020 +#ifdef CONFIG_PAX_RANDMMAP
23021 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23022 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
23023 +#endif
23024 +
23025 + if (info.low_limit < info.high_limit) {
23026 + addr = vm_unmapped_area(&info);
23027 + if (!IS_ERR_VALUE(addr))
23028 + return addr;
23029 + }
23030 + } else
23031 +#endif
23032 +
23033 + info.low_limit = mm->mmap_base;
23034 + info.high_limit = pax_task_size;
23035 +
23036 + return vm_unmapped_area(&info);
23037 +}
23038 +
23039 +unsigned long
23040 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23041 + const unsigned long len, const unsigned long pgoff,
23042 + const unsigned long flags)
23043 +{
23044 + struct vm_area_struct *vma;
23045 + struct mm_struct *mm = current->mm;
23046 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
23047 + struct vm_unmapped_area_info info;
23048 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23049 +
23050 +#ifdef CONFIG_PAX_SEGMEXEC
23051 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23052 + pax_task_size = SEGMEXEC_TASK_SIZE;
23053 +#endif
23054 +
23055 + pax_task_size -= PAGE_SIZE;
23056 +
23057 + /* requested length too big for entire address space */
23058 + if (len > pax_task_size)
23059 + return -ENOMEM;
23060 +
23061 + if (flags & MAP_FIXED)
23062 + return addr;
23063 +
23064 +#ifdef CONFIG_PAX_PAGEEXEC
23065 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23066 + goto bottomup;
23067 +#endif
23068 +
23069 +#ifdef CONFIG_PAX_RANDMMAP
23070 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23071 +#endif
23072 +
23073 + /* requesting a specific address */
23074 + if (addr) {
23075 + addr = PAGE_ALIGN(addr);
23076 + if (pax_task_size - len >= addr) {
23077 + vma = find_vma(mm, addr);
23078 + if (check_heap_stack_gap(vma, addr, len, offset))
23079 + return addr;
23080 + }
23081 + }
23082 +
23083 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
23084 + info.length = len;
23085 + info.low_limit = PAGE_SIZE;
23086 + info.high_limit = mm->mmap_base;
23087 + info.align_mask = filp ? get_align_mask() : 0;
23088 + info.align_offset = pgoff << PAGE_SHIFT;
23089 + info.threadstack_offset = offset;
23090 +
23091 + addr = vm_unmapped_area(&info);
23092 + if (!(addr & ~PAGE_MASK))
23093 + return addr;
23094 + VM_BUG_ON(addr != -ENOMEM);
23095 +
23096 +bottomup:
23097 + /*
23098 + * A failed mmap() very likely causes application failure,
23099 + * so fall back to the bottom-up function here. This scenario
23100 + * can happen with large stack limits and large mmap()
23101 + * allocations.
23102 + */
23103 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23104 +}
23105 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23106 index dbded5a..ace2781 100644
23107 --- a/arch/x86/kernel/sys_x86_64.c
23108 +++ b/arch/x86/kernel/sys_x86_64.c
23109 @@ -81,8 +81,8 @@ out:
23110 return error;
23111 }
23112
23113 -static void find_start_end(unsigned long flags, unsigned long *begin,
23114 - unsigned long *end)
23115 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23116 + unsigned long *begin, unsigned long *end)
23117 {
23118 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23119 unsigned long new_begin;
23120 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23121 *begin = new_begin;
23122 }
23123 } else {
23124 - *begin = TASK_UNMAPPED_BASE;
23125 + *begin = mm->mmap_base;
23126 *end = TASK_SIZE;
23127 }
23128 }
23129 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23130 struct vm_area_struct *vma;
23131 struct vm_unmapped_area_info info;
23132 unsigned long begin, end;
23133 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23134
23135 if (flags & MAP_FIXED)
23136 return addr;
23137
23138 - find_start_end(flags, &begin, &end);
23139 + find_start_end(mm, flags, &begin, &end);
23140
23141 if (len > end)
23142 return -ENOMEM;
23143
23144 +#ifdef CONFIG_PAX_RANDMMAP
23145 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23146 +#endif
23147 +
23148 if (addr) {
23149 addr = PAGE_ALIGN(addr);
23150 vma = find_vma(mm, addr);
23151 - if (end - len >= addr &&
23152 - (!vma || addr + len <= vma->vm_start))
23153 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23154 return addr;
23155 }
23156
23157 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23158 info.high_limit = end;
23159 info.align_mask = filp ? get_align_mask() : 0;
23160 info.align_offset = pgoff << PAGE_SHIFT;
23161 + info.threadstack_offset = offset;
23162 return vm_unmapped_area(&info);
23163 }
23164
23165 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23166 struct mm_struct *mm = current->mm;
23167 unsigned long addr = addr0;
23168 struct vm_unmapped_area_info info;
23169 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23170
23171 /* requested length too big for entire address space */
23172 if (len > TASK_SIZE)
23173 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23174 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23175 goto bottomup;
23176
23177 +#ifdef CONFIG_PAX_RANDMMAP
23178 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23179 +#endif
23180 +
23181 /* requesting a specific address */
23182 if (addr) {
23183 addr = PAGE_ALIGN(addr);
23184 vma = find_vma(mm, addr);
23185 - if (TASK_SIZE - len >= addr &&
23186 - (!vma || addr + len <= vma->vm_start))
23187 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23188 return addr;
23189 }
23190
23191 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23192 info.high_limit = mm->mmap_base;
23193 info.align_mask = filp ? get_align_mask() : 0;
23194 info.align_offset = pgoff << PAGE_SHIFT;
23195 + info.threadstack_offset = offset;
23196 addr = vm_unmapped_area(&info);
23197 if (!(addr & ~PAGE_MASK))
23198 return addr;
23199 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23200 index f84fe00..f41d9f1 100644
23201 --- a/arch/x86/kernel/tboot.c
23202 +++ b/arch/x86/kernel/tboot.c
23203 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23204
23205 void tboot_shutdown(u32 shutdown_type)
23206 {
23207 - void (*shutdown)(void);
23208 + void (* __noreturn shutdown)(void);
23209
23210 if (!tboot_enabled())
23211 return;
23212 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23213
23214 switch_to_tboot_pt();
23215
23216 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23217 + shutdown = (void *)tboot->shutdown_entry;
23218 shutdown();
23219
23220 /* should not reach here */
23221 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23222 return 0;
23223 }
23224
23225 -static atomic_t ap_wfs_count;
23226 +static atomic_unchecked_t ap_wfs_count;
23227
23228 static int tboot_wait_for_aps(int num_aps)
23229 {
23230 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23231 {
23232 switch (action) {
23233 case CPU_DYING:
23234 - atomic_inc(&ap_wfs_count);
23235 + atomic_inc_unchecked(&ap_wfs_count);
23236 if (num_online_cpus() == 1)
23237 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23238 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23239 return NOTIFY_BAD;
23240 break;
23241 }
23242 return NOTIFY_OK;
23243 }
23244
23245 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23246 +static struct notifier_block tboot_cpu_notifier =
23247 {
23248 .notifier_call = tboot_cpu_callback,
23249 };
23250 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23251
23252 tboot_create_trampoline();
23253
23254 - atomic_set(&ap_wfs_count, 0);
23255 + atomic_set_unchecked(&ap_wfs_count, 0);
23256 register_hotcpu_notifier(&tboot_cpu_notifier);
23257
23258 acpi_os_set_prepare_sleep(&tboot_sleep);
23259 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23260 index 24d3c91..d06b473 100644
23261 --- a/arch/x86/kernel/time.c
23262 +++ b/arch/x86/kernel/time.c
23263 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23264 {
23265 unsigned long pc = instruction_pointer(regs);
23266
23267 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23268 + if (!user_mode(regs) && in_lock_functions(pc)) {
23269 #ifdef CONFIG_FRAME_POINTER
23270 - return *(unsigned long *)(regs->bp + sizeof(long));
23271 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23272 #else
23273 unsigned long *sp =
23274 (unsigned long *)kernel_stack_pointer(regs);
23275 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23276 * or above a saved flags. Eflags has bits 22-31 zero,
23277 * kernel addresses don't.
23278 */
23279 +
23280 +#ifdef CONFIG_PAX_KERNEXEC
23281 + return ktla_ktva(sp[0]);
23282 +#else
23283 if (sp[0] >> 22)
23284 return sp[0];
23285 if (sp[1] >> 22)
23286 return sp[1];
23287 #endif
23288 +
23289 +#endif
23290 }
23291 return pc;
23292 }
23293 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23294 index 9d9d2f9..cad418a 100644
23295 --- a/arch/x86/kernel/tls.c
23296 +++ b/arch/x86/kernel/tls.c
23297 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23298 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23299 return -EINVAL;
23300
23301 +#ifdef CONFIG_PAX_SEGMEXEC
23302 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23303 + return -EINVAL;
23304 +#endif
23305 +
23306 set_tls_desc(p, idx, &info, 1);
23307
23308 return 0;
23309 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23310
23311 if (kbuf)
23312 info = kbuf;
23313 - else if (__copy_from_user(infobuf, ubuf, count))
23314 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23315 return -EFAULT;
23316 else
23317 info = infobuf;
23318 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23319 index 68bda7a..3ec7bb7 100644
23320 --- a/arch/x86/kernel/traps.c
23321 +++ b/arch/x86/kernel/traps.c
23322 @@ -68,12 +68,6 @@
23323 #include <asm/setup.h>
23324
23325 asmlinkage int system_call(void);
23326 -
23327 -/*
23328 - * The IDT has to be page-aligned to simplify the Pentium
23329 - * F0 0F bug workaround.
23330 - */
23331 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23332 #endif
23333
23334 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23335 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23336 }
23337
23338 static int __kprobes
23339 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23340 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23341 struct pt_regs *regs, long error_code)
23342 {
23343 #ifdef CONFIG_X86_32
23344 - if (regs->flags & X86_VM_MASK) {
23345 + if (v8086_mode(regs)) {
23346 /*
23347 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23348 * On nmi (interrupt 2), do_trap should not be called.
23349 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23350 return -1;
23351 }
23352 #endif
23353 - if (!user_mode(regs)) {
23354 + if (!user_mode_novm(regs)) {
23355 if (!fixup_exception(regs)) {
23356 tsk->thread.error_code = error_code;
23357 tsk->thread.trap_nr = trapnr;
23358 +
23359 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23360 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23361 + str = "PAX: suspicious stack segment fault";
23362 +#endif
23363 +
23364 die(str, regs, error_code);
23365 }
23366 +
23367 +#ifdef CONFIG_PAX_REFCOUNT
23368 + if (trapnr == 4)
23369 + pax_report_refcount_overflow(regs);
23370 +#endif
23371 +
23372 return 0;
23373 }
23374
23375 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23376 }
23377
23378 static void __kprobes
23379 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23380 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23381 long error_code, siginfo_t *info)
23382 {
23383 struct task_struct *tsk = current;
23384 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23385 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23386 printk_ratelimit()) {
23387 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23388 - tsk->comm, tsk->pid, str,
23389 + tsk->comm, task_pid_nr(tsk), str,
23390 regs->ip, regs->sp, error_code);
23391 print_vma_addr(" in ", regs->ip);
23392 pr_cont("\n");
23393 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23394 conditional_sti(regs);
23395
23396 #ifdef CONFIG_X86_32
23397 - if (regs->flags & X86_VM_MASK) {
23398 + if (v8086_mode(regs)) {
23399 local_irq_enable();
23400 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23401 goto exit;
23402 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23403 #endif
23404
23405 tsk = current;
23406 - if (!user_mode(regs)) {
23407 + if (!user_mode_novm(regs)) {
23408 if (fixup_exception(regs))
23409 goto exit;
23410
23411 tsk->thread.error_code = error_code;
23412 tsk->thread.trap_nr = X86_TRAP_GP;
23413 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23414 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23415 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23416 +
23417 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23418 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23419 + die("PAX: suspicious general protection fault", regs, error_code);
23420 + else
23421 +#endif
23422 +
23423 die("general protection fault", regs, error_code);
23424 + }
23425 goto exit;
23426 }
23427
23428 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23429 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23430 + struct mm_struct *mm = tsk->mm;
23431 + unsigned long limit;
23432 +
23433 + down_write(&mm->mmap_sem);
23434 + limit = mm->context.user_cs_limit;
23435 + if (limit < TASK_SIZE) {
23436 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23437 + up_write(&mm->mmap_sem);
23438 + return;
23439 + }
23440 + up_write(&mm->mmap_sem);
23441 + }
23442 +#endif
23443 +
23444 tsk->thread.error_code = error_code;
23445 tsk->thread.trap_nr = X86_TRAP_GP;
23446
23447 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23448 /* It's safe to allow irq's after DR6 has been saved */
23449 preempt_conditional_sti(regs);
23450
23451 - if (regs->flags & X86_VM_MASK) {
23452 + if (v8086_mode(regs)) {
23453 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23454 X86_TRAP_DB);
23455 preempt_conditional_cli(regs);
23456 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23457 * We already checked v86 mode above, so we can check for kernel mode
23458 * by just checking the CPL of CS.
23459 */
23460 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23461 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23462 tsk->thread.debugreg6 &= ~DR_STEP;
23463 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23464 regs->flags &= ~X86_EFLAGS_TF;
23465 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23466 return;
23467 conditional_sti(regs);
23468
23469 - if (!user_mode_vm(regs))
23470 + if (!user_mode(regs))
23471 {
23472 if (!fixup_exception(regs)) {
23473 task->thread.error_code = error_code;
23474 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23475 index 0ba4cfb..4596bec 100644
23476 --- a/arch/x86/kernel/uprobes.c
23477 +++ b/arch/x86/kernel/uprobes.c
23478 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23479 int ret = NOTIFY_DONE;
23480
23481 /* We are only interested in userspace traps */
23482 - if (regs && !user_mode_vm(regs))
23483 + if (regs && !user_mode(regs))
23484 return NOTIFY_DONE;
23485
23486 switch (val) {
23487 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23488 index b9242ba..50c5edd 100644
23489 --- a/arch/x86/kernel/verify_cpu.S
23490 +++ b/arch/x86/kernel/verify_cpu.S
23491 @@ -20,6 +20,7 @@
23492 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23493 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23494 * arch/x86/kernel/head_32.S: processor startup
23495 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23496 *
23497 * verify_cpu, returns the status of longmode and SSE in register %eax.
23498 * 0: Success 1: Failure
23499 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23500 index 3dbdd9c..888b14e 100644
23501 --- a/arch/x86/kernel/vm86_32.c
23502 +++ b/arch/x86/kernel/vm86_32.c
23503 @@ -44,6 +44,7 @@
23504 #include <linux/ptrace.h>
23505 #include <linux/audit.h>
23506 #include <linux/stddef.h>
23507 +#include <linux/grsecurity.h>
23508
23509 #include <asm/uaccess.h>
23510 #include <asm/io.h>
23511 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23512 do_exit(SIGSEGV);
23513 }
23514
23515 - tss = &per_cpu(init_tss, get_cpu());
23516 + tss = init_tss + get_cpu();
23517 current->thread.sp0 = current->thread.saved_sp0;
23518 current->thread.sysenter_cs = __KERNEL_CS;
23519 load_sp0(tss, &current->thread);
23520 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23521
23522 if (tsk->thread.saved_sp0)
23523 goto out;
23524 +
23525 +#ifdef CONFIG_GRKERNSEC_VM86
23526 + if (!capable(CAP_SYS_RAWIO)) {
23527 + gr_handle_vm86();
23528 + goto out;
23529 + }
23530 +#endif
23531 +
23532 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23533 offsetof(struct kernel_vm86_struct, vm86plus) -
23534 sizeof(info.regs));
23535 @@ -242,6 +251,14 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23536 int tmp, ret;
23537 struct vm86plus_struct __user *v86;
23538
23539 +#ifdef CONFIG_GRKERNSEC_VM86
23540 + if (!capable(CAP_SYS_RAWIO)) {
23541 + gr_handle_vm86();
23542 + ret = -EPERM;
23543 + goto out;
23544 + }
23545 +#endif
23546 +
23547 tsk = current;
23548 switch (cmd) {
23549 case VM86_REQUEST_IRQ:
23550 @@ -329,7 +346,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23551 tsk->thread.saved_fs = info->regs32->fs;
23552 tsk->thread.saved_gs = get_user_gs(info->regs32);
23553
23554 - tss = &per_cpu(init_tss, get_cpu());
23555 + tss = init_tss + get_cpu();
23556 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23557 if (cpu_has_sep)
23558 tsk->thread.sysenter_cs = 0;
23559 @@ -536,7 +553,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23560 goto cannot_handle;
23561 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23562 goto cannot_handle;
23563 - intr_ptr = (unsigned long __user *) (i << 2);
23564 + intr_ptr = (__force unsigned long __user *) (i << 2);
23565 if (get_user(segoffs, intr_ptr))
23566 goto cannot_handle;
23567 if ((segoffs >> 16) == BIOSSEG)
23568 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23569 index 22a1530..5efafbf 100644
23570 --- a/arch/x86/kernel/vmlinux.lds.S
23571 +++ b/arch/x86/kernel/vmlinux.lds.S
23572 @@ -26,6 +26,13 @@
23573 #include <asm/page_types.h>
23574 #include <asm/cache.h>
23575 #include <asm/boot.h>
23576 +#include <asm/segment.h>
23577 +
23578 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23579 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23580 +#else
23581 +#define __KERNEL_TEXT_OFFSET 0
23582 +#endif
23583
23584 #undef i386 /* in case the preprocessor is a 32bit one */
23585
23586 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23587
23588 PHDRS {
23589 text PT_LOAD FLAGS(5); /* R_E */
23590 +#ifdef CONFIG_X86_32
23591 + module PT_LOAD FLAGS(5); /* R_E */
23592 +#endif
23593 +#ifdef CONFIG_XEN
23594 + rodata PT_LOAD FLAGS(5); /* R_E */
23595 +#else
23596 + rodata PT_LOAD FLAGS(4); /* R__ */
23597 +#endif
23598 data PT_LOAD FLAGS(6); /* RW_ */
23599 -#ifdef CONFIG_X86_64
23600 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23601 #ifdef CONFIG_SMP
23602 percpu PT_LOAD FLAGS(6); /* RW_ */
23603 #endif
23604 + text.init PT_LOAD FLAGS(5); /* R_E */
23605 + text.exit PT_LOAD FLAGS(5); /* R_E */
23606 init PT_LOAD FLAGS(7); /* RWE */
23607 -#endif
23608 note PT_NOTE FLAGS(0); /* ___ */
23609 }
23610
23611 SECTIONS
23612 {
23613 #ifdef CONFIG_X86_32
23614 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23615 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23616 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23617 #else
23618 - . = __START_KERNEL;
23619 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23620 + . = __START_KERNEL;
23621 #endif
23622
23623 /* Text and read-only data */
23624 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23625 - _text = .;
23626 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23627 /* bootstrapping code */
23628 +#ifdef CONFIG_X86_32
23629 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23630 +#else
23631 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23632 +#endif
23633 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23634 + _text = .;
23635 HEAD_TEXT
23636 #ifdef CONFIG_X86_32
23637 . = ALIGN(PAGE_SIZE);
23638 @@ -108,13 +128,48 @@ SECTIONS
23639 IRQENTRY_TEXT
23640 *(.fixup)
23641 *(.gnu.warning)
23642 - /* End of text section */
23643 - _etext = .;
23644 } :text = 0x9090
23645
23646 - NOTES :text :note
23647 + . += __KERNEL_TEXT_OFFSET;
23648
23649 - EXCEPTION_TABLE(16) :text = 0x9090
23650 +#ifdef CONFIG_X86_32
23651 + . = ALIGN(PAGE_SIZE);
23652 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23653 +
23654 +#ifdef CONFIG_PAX_KERNEXEC
23655 + MODULES_EXEC_VADDR = .;
23656 + BYTE(0)
23657 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23658 + . = ALIGN(HPAGE_SIZE) - 1;
23659 + MODULES_EXEC_END = .;
23660 +#endif
23661 +
23662 + } :module
23663 +#endif
23664 +
23665 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23666 + /* End of text section */
23667 + BYTE(0)
23668 + _etext = . - __KERNEL_TEXT_OFFSET;
23669 + }
23670 +
23671 +#ifdef CONFIG_X86_32
23672 + . = ALIGN(PAGE_SIZE);
23673 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23674 + *(.idt)
23675 + . = ALIGN(PAGE_SIZE);
23676 + *(.empty_zero_page)
23677 + *(.initial_pg_fixmap)
23678 + *(.initial_pg_pmd)
23679 + *(.initial_page_table)
23680 + *(.swapper_pg_dir)
23681 + } :rodata
23682 +#endif
23683 +
23684 + . = ALIGN(PAGE_SIZE);
23685 + NOTES :rodata :note
23686 +
23687 + EXCEPTION_TABLE(16) :rodata
23688
23689 #if defined(CONFIG_DEBUG_RODATA)
23690 /* .text should occupy whole number of pages */
23691 @@ -126,16 +181,20 @@ SECTIONS
23692
23693 /* Data */
23694 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23695 +
23696 +#ifdef CONFIG_PAX_KERNEXEC
23697 + . = ALIGN(HPAGE_SIZE);
23698 +#else
23699 + . = ALIGN(PAGE_SIZE);
23700 +#endif
23701 +
23702 /* Start of data section */
23703 _sdata = .;
23704
23705 /* init_task */
23706 INIT_TASK_DATA(THREAD_SIZE)
23707
23708 -#ifdef CONFIG_X86_32
23709 - /* 32 bit has nosave before _edata */
23710 NOSAVE_DATA
23711 -#endif
23712
23713 PAGE_ALIGNED_DATA(PAGE_SIZE)
23714
23715 @@ -176,12 +235,19 @@ SECTIONS
23716 #endif /* CONFIG_X86_64 */
23717
23718 /* Init code and data - will be freed after init */
23719 - . = ALIGN(PAGE_SIZE);
23720 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23721 + BYTE(0)
23722 +
23723 +#ifdef CONFIG_PAX_KERNEXEC
23724 + . = ALIGN(HPAGE_SIZE);
23725 +#else
23726 + . = ALIGN(PAGE_SIZE);
23727 +#endif
23728 +
23729 __init_begin = .; /* paired with __init_end */
23730 - }
23731 + } :init.begin
23732
23733 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23734 +#ifdef CONFIG_SMP
23735 /*
23736 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23737 * output PHDR, so the next output section - .init.text - should
23738 @@ -190,12 +256,27 @@ SECTIONS
23739 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23740 #endif
23741
23742 - INIT_TEXT_SECTION(PAGE_SIZE)
23743 -#ifdef CONFIG_X86_64
23744 - :init
23745 -#endif
23746 + . = ALIGN(PAGE_SIZE);
23747 + init_begin = .;
23748 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23749 + VMLINUX_SYMBOL(_sinittext) = .;
23750 + INIT_TEXT
23751 + VMLINUX_SYMBOL(_einittext) = .;
23752 + . = ALIGN(PAGE_SIZE);
23753 + } :text.init
23754
23755 - INIT_DATA_SECTION(16)
23756 + /*
23757 + * .exit.text is discard at runtime, not link time, to deal with
23758 + * references from .altinstructions and .eh_frame
23759 + */
23760 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23761 + EXIT_TEXT
23762 + . = ALIGN(16);
23763 + } :text.exit
23764 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23765 +
23766 + . = ALIGN(PAGE_SIZE);
23767 + INIT_DATA_SECTION(16) :init
23768
23769 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23770 __x86_cpu_dev_start = .;
23771 @@ -257,19 +338,12 @@ SECTIONS
23772 }
23773
23774 . = ALIGN(8);
23775 - /*
23776 - * .exit.text is discard at runtime, not link time, to deal with
23777 - * references from .altinstructions and .eh_frame
23778 - */
23779 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23780 - EXIT_TEXT
23781 - }
23782
23783 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23784 EXIT_DATA
23785 }
23786
23787 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23788 +#ifndef CONFIG_SMP
23789 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23790 #endif
23791
23792 @@ -288,16 +362,10 @@ SECTIONS
23793 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23794 __smp_locks = .;
23795 *(.smp_locks)
23796 - . = ALIGN(PAGE_SIZE);
23797 __smp_locks_end = .;
23798 + . = ALIGN(PAGE_SIZE);
23799 }
23800
23801 -#ifdef CONFIG_X86_64
23802 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23803 - NOSAVE_DATA
23804 - }
23805 -#endif
23806 -
23807 /* BSS */
23808 . = ALIGN(PAGE_SIZE);
23809 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23810 @@ -313,6 +381,7 @@ SECTIONS
23811 __brk_base = .;
23812 . += 64 * 1024; /* 64k alignment slop space */
23813 *(.brk_reservation) /* areas brk users have reserved */
23814 + . = ALIGN(HPAGE_SIZE);
23815 __brk_limit = .;
23816 }
23817
23818 @@ -339,13 +408,12 @@ SECTIONS
23819 * for the boot processor.
23820 */
23821 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23822 -INIT_PER_CPU(gdt_page);
23823 INIT_PER_CPU(irq_stack_union);
23824
23825 /*
23826 * Build-time check on the image size:
23827 */
23828 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23829 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23830 "kernel image bigger than KERNEL_IMAGE_SIZE");
23831
23832 #ifdef CONFIG_SMP
23833 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23834 index 9a907a6..f83f921 100644
23835 --- a/arch/x86/kernel/vsyscall_64.c
23836 +++ b/arch/x86/kernel/vsyscall_64.c
23837 @@ -56,15 +56,13 @@
23838 DEFINE_VVAR(int, vgetcpu_mode);
23839 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23840
23841 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23842 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23843
23844 static int __init vsyscall_setup(char *str)
23845 {
23846 if (str) {
23847 if (!strcmp("emulate", str))
23848 vsyscall_mode = EMULATE;
23849 - else if (!strcmp("native", str))
23850 - vsyscall_mode = NATIVE;
23851 else if (!strcmp("none", str))
23852 vsyscall_mode = NONE;
23853 else
23854 @@ -323,8 +321,7 @@ do_ret:
23855 return true;
23856
23857 sigsegv:
23858 - force_sig(SIGSEGV, current);
23859 - return true;
23860 + do_group_exit(SIGKILL);
23861 }
23862
23863 /*
23864 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23865 extern char __vvar_page;
23866 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23867
23868 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23869 - vsyscall_mode == NATIVE
23870 - ? PAGE_KERNEL_VSYSCALL
23871 - : PAGE_KERNEL_VVAR);
23872 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23873 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23874 (unsigned long)VSYSCALL_START);
23875
23876 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23877 index b014d94..6d6ca7b 100644
23878 --- a/arch/x86/kernel/x8664_ksyms_64.c
23879 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23880 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23881 EXPORT_SYMBOL(copy_user_generic_unrolled);
23882 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23883 EXPORT_SYMBOL(__copy_user_nocache);
23884 -EXPORT_SYMBOL(_copy_from_user);
23885 -EXPORT_SYMBOL(_copy_to_user);
23886
23887 EXPORT_SYMBOL(copy_page);
23888 EXPORT_SYMBOL(clear_page);
23889 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23890 index 45a14db..075bb9b 100644
23891 --- a/arch/x86/kernel/x86_init.c
23892 +++ b/arch/x86/kernel/x86_init.c
23893 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23894 },
23895 };
23896
23897 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23898 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23899 .early_percpu_clock_init = x86_init_noop,
23900 .setup_percpu_clockev = setup_secondary_APIC_clock,
23901 };
23902 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23903 static void default_nmi_init(void) { };
23904 static int default_i8042_detect(void) { return 1; };
23905
23906 -struct x86_platform_ops x86_platform = {
23907 +struct x86_platform_ops x86_platform __read_only = {
23908 .calibrate_tsc = native_calibrate_tsc,
23909 .get_wallclock = mach_get_cmos_time,
23910 .set_wallclock = mach_set_rtc_mmss,
23911 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23912 };
23913
23914 EXPORT_SYMBOL_GPL(x86_platform);
23915 -struct x86_msi_ops x86_msi = {
23916 +struct x86_msi_ops x86_msi __read_only = {
23917 .setup_msi_irqs = native_setup_msi_irqs,
23918 .compose_msi_msg = native_compose_msi_msg,
23919 .teardown_msi_irq = native_teardown_msi_irq,
23920 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23921 .setup_hpet_msi = default_setup_hpet_msi,
23922 };
23923
23924 -struct x86_io_apic_ops x86_io_apic_ops = {
23925 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23926 .init = native_io_apic_init_mappings,
23927 .read = native_io_apic_read,
23928 .write = native_io_apic_write,
23929 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23930 index ada87a3..afea76d 100644
23931 --- a/arch/x86/kernel/xsave.c
23932 +++ b/arch/x86/kernel/xsave.c
23933 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23934 {
23935 int err;
23936
23937 + buf = (struct xsave_struct __user *)____m(buf);
23938 if (use_xsave())
23939 err = xsave_user(buf);
23940 else if (use_fxsr())
23941 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23942 */
23943 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23944 {
23945 + buf = (void __user *)____m(buf);
23946 if (use_xsave()) {
23947 if ((unsigned long)buf % 64 || fx_only) {
23948 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23949 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23950 index a20ecb5..d0e2194 100644
23951 --- a/arch/x86/kvm/cpuid.c
23952 +++ b/arch/x86/kvm/cpuid.c
23953 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23954 struct kvm_cpuid2 *cpuid,
23955 struct kvm_cpuid_entry2 __user *entries)
23956 {
23957 - int r;
23958 + int r, i;
23959
23960 r = -E2BIG;
23961 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23962 goto out;
23963 r = -EFAULT;
23964 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23965 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23966 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23967 goto out;
23968 + for (i = 0; i < cpuid->nent; ++i) {
23969 + struct kvm_cpuid_entry2 cpuid_entry;
23970 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23971 + goto out;
23972 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23973 + }
23974 vcpu->arch.cpuid_nent = cpuid->nent;
23975 kvm_apic_set_version(vcpu);
23976 kvm_x86_ops->cpuid_update(vcpu);
23977 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23978 struct kvm_cpuid2 *cpuid,
23979 struct kvm_cpuid_entry2 __user *entries)
23980 {
23981 - int r;
23982 + int r, i;
23983
23984 r = -E2BIG;
23985 if (cpuid->nent < vcpu->arch.cpuid_nent)
23986 goto out;
23987 r = -EFAULT;
23988 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23989 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23990 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23991 goto out;
23992 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23993 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23994 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23995 + goto out;
23996 + }
23997 return 0;
23998
23999 out:
24000 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24001 index 698eece..776b682 100644
24002 --- a/arch/x86/kvm/emulate.c
24003 +++ b/arch/x86/kvm/emulate.c
24004 @@ -328,6 +328,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24005
24006 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24007 do { \
24008 + unsigned long _tmp; \
24009 __asm__ __volatile__ ( \
24010 _PRE_EFLAGS("0", "4", "2") \
24011 _op _suffix " %"_x"3,%1; " \
24012 @@ -342,8 +343,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24013 /* Raw emulation: instruction has two explicit operands. */
24014 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24015 do { \
24016 - unsigned long _tmp; \
24017 - \
24018 switch ((ctxt)->dst.bytes) { \
24019 case 2: \
24020 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24021 @@ -359,7 +358,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24022
24023 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24024 do { \
24025 - unsigned long _tmp; \
24026 switch ((ctxt)->dst.bytes) { \
24027 case 1: \
24028 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24029 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24030 index f77df1c..6f20690 100644
24031 --- a/arch/x86/kvm/lapic.c
24032 +++ b/arch/x86/kvm/lapic.c
24033 @@ -55,7 +55,7 @@
24034 #define APIC_BUS_CYCLE_NS 1
24035
24036 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24037 -#define apic_debug(fmt, arg...)
24038 +#define apic_debug(fmt, arg...) do {} while (0)
24039
24040 #define APIC_LVT_NUM 6
24041 /* 14 is the version for Xeon and Pentium 8.4.8*/
24042 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24043 index 105dd5b..1b0ccc2 100644
24044 --- a/arch/x86/kvm/paging_tmpl.h
24045 +++ b/arch/x86/kvm/paging_tmpl.h
24046 @@ -208,7 +208,7 @@ retry_walk:
24047 if (unlikely(kvm_is_error_hva(host_addr)))
24048 goto error;
24049
24050 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24051 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24052 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24053 goto error;
24054 walker->ptep_user[walker->level - 1] = ptep_user;
24055 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24056 index e1b1ce2..f7b4b43 100644
24057 --- a/arch/x86/kvm/svm.c
24058 +++ b/arch/x86/kvm/svm.c
24059 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24060 int cpu = raw_smp_processor_id();
24061
24062 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24063 +
24064 + pax_open_kernel();
24065 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24066 + pax_close_kernel();
24067 +
24068 load_TR_desc();
24069 }
24070
24071 @@ -3901,6 +3905,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24072 #endif
24073 #endif
24074
24075 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24076 + __set_fs(current_thread_info()->addr_limit);
24077 +#endif
24078 +
24079 reload_tss(vcpu);
24080
24081 local_irq_disable();
24082 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24083 index 0af1807..06912bb 100644
24084 --- a/arch/x86/kvm/vmx.c
24085 +++ b/arch/x86/kvm/vmx.c
24086 @@ -1184,12 +1184,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24087 #endif
24088 }
24089
24090 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24091 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24092 {
24093 vmcs_writel(field, vmcs_readl(field) & ~mask);
24094 }
24095
24096 -static void vmcs_set_bits(unsigned long field, u32 mask)
24097 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24098 {
24099 vmcs_writel(field, vmcs_readl(field) | mask);
24100 }
24101 @@ -1390,7 +1390,11 @@ static void reload_tss(void)
24102 struct desc_struct *descs;
24103
24104 descs = (void *)gdt->address;
24105 +
24106 + pax_open_kernel();
24107 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24108 + pax_close_kernel();
24109 +
24110 load_TR_desc();
24111 }
24112
24113 @@ -1614,6 +1618,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24114 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24115 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24116
24117 +#ifdef CONFIG_PAX_PER_CPU_PGD
24118 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24119 +#endif
24120 +
24121 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24122 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24123 vmx->loaded_vmcs->cpu = cpu;
24124 @@ -2779,8 +2787,11 @@ static __init int hardware_setup(void)
24125 if (!cpu_has_vmx_flexpriority())
24126 flexpriority_enabled = 0;
24127
24128 - if (!cpu_has_vmx_tpr_shadow())
24129 - kvm_x86_ops->update_cr8_intercept = NULL;
24130 + if (!cpu_has_vmx_tpr_shadow()) {
24131 + pax_open_kernel();
24132 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24133 + pax_close_kernel();
24134 + }
24135
24136 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24137 kvm_disable_largepages();
24138 @@ -2792,10 +2803,12 @@ static __init int hardware_setup(void)
24139 !cpu_has_vmx_virtual_intr_delivery())
24140 enable_apicv_reg_vid = 0;
24141
24142 + pax_open_kernel();
24143 if (enable_apicv_reg_vid)
24144 - kvm_x86_ops->update_cr8_intercept = NULL;
24145 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24146 else
24147 - kvm_x86_ops->hwapic_irr_update = NULL;
24148 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24149 + pax_close_kernel();
24150
24151 if (nested)
24152 nested_vmx_setup_ctls_msrs();
24153 @@ -3883,7 +3896,10 @@ static void vmx_set_constant_host_state(void)
24154
24155 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24156 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24157 +
24158 +#ifndef CONFIG_PAX_PER_CPU_PGD
24159 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24160 +#endif
24161
24162 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24163 #ifdef CONFIG_X86_64
24164 @@ -3904,7 +3920,7 @@ static void vmx_set_constant_host_state(void)
24165 native_store_idt(&dt);
24166 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24167
24168 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24169 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24170
24171 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24172 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24173 @@ -6580,6 +6596,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24174 "jmp 2f \n\t"
24175 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24176 "2: "
24177 +
24178 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24179 + "ljmp %[cs],$3f\n\t"
24180 + "3: "
24181 +#endif
24182 +
24183 /* Save guest registers, load host registers, keep flags */
24184 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24185 "pop %0 \n\t"
24186 @@ -6632,6 +6654,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24187 #endif
24188 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24189 [wordsize]"i"(sizeof(ulong))
24190 +
24191 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24192 + ,[cs]"i"(__KERNEL_CS)
24193 +#endif
24194 +
24195 : "cc", "memory"
24196 #ifdef CONFIG_X86_64
24197 , "rax", "rbx", "rdi", "rsi"
24198 @@ -6645,7 +6672,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24199 if (debugctlmsr)
24200 update_debugctlmsr(debugctlmsr);
24201
24202 -#ifndef CONFIG_X86_64
24203 +#ifdef CONFIG_X86_32
24204 /*
24205 * The sysexit path does not restore ds/es, so we must set them to
24206 * a reasonable value ourselves.
24207 @@ -6654,8 +6681,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24208 * may be executed in interrupt context, which saves and restore segments
24209 * around it, nullifying its effect.
24210 */
24211 - loadsegment(ds, __USER_DS);
24212 - loadsegment(es, __USER_DS);
24213 + loadsegment(ds, __KERNEL_DS);
24214 + loadsegment(es, __KERNEL_DS);
24215 + loadsegment(ss, __KERNEL_DS);
24216 +
24217 +#ifdef CONFIG_PAX_KERNEXEC
24218 + loadsegment(fs, __KERNEL_PERCPU);
24219 +#endif
24220 +
24221 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24222 + __set_fs(current_thread_info()->addr_limit);
24223 +#endif
24224 +
24225 #endif
24226
24227 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24228 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24229 index e172132..c3d3e27 100644
24230 --- a/arch/x86/kvm/x86.c
24231 +++ b/arch/x86/kvm/x86.c
24232 @@ -1686,8 +1686,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24233 {
24234 struct kvm *kvm = vcpu->kvm;
24235 int lm = is_long_mode(vcpu);
24236 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24237 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24238 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24239 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24240 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24241 : kvm->arch.xen_hvm_config.blob_size_32;
24242 u32 page_num = data & ~PAGE_MASK;
24243 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24244 if (n < msr_list.nmsrs)
24245 goto out;
24246 r = -EFAULT;
24247 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24248 + goto out;
24249 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24250 num_msrs_to_save * sizeof(u32)))
24251 goto out;
24252 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24253 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24254 struct kvm_interrupt *irq)
24255 {
24256 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24257 + if (irq->irq >= KVM_NR_INTERRUPTS)
24258 return -EINVAL;
24259 if (irqchip_in_kernel(vcpu->kvm))
24260 return -ENXIO;
24261 @@ -5247,7 +5249,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24262 };
24263 #endif
24264
24265 -int kvm_arch_init(void *opaque)
24266 +int kvm_arch_init(const void *opaque)
24267 {
24268 int r;
24269 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24270 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24271 index 7114c63..a1018fc 100644
24272 --- a/arch/x86/lguest/boot.c
24273 +++ b/arch/x86/lguest/boot.c
24274 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24275 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24276 * Launcher to reboot us.
24277 */
24278 -static void lguest_restart(char *reason)
24279 +static __noreturn void lguest_restart(char *reason)
24280 {
24281 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24282 + BUG();
24283 }
24284
24285 /*G:050
24286 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24287 index 00933d5..3a64af9 100644
24288 --- a/arch/x86/lib/atomic64_386_32.S
24289 +++ b/arch/x86/lib/atomic64_386_32.S
24290 @@ -48,6 +48,10 @@ BEGIN(read)
24291 movl (v), %eax
24292 movl 4(v), %edx
24293 RET_ENDP
24294 +BEGIN(read_unchecked)
24295 + movl (v), %eax
24296 + movl 4(v), %edx
24297 +RET_ENDP
24298 #undef v
24299
24300 #define v %esi
24301 @@ -55,6 +59,10 @@ BEGIN(set)
24302 movl %ebx, (v)
24303 movl %ecx, 4(v)
24304 RET_ENDP
24305 +BEGIN(set_unchecked)
24306 + movl %ebx, (v)
24307 + movl %ecx, 4(v)
24308 +RET_ENDP
24309 #undef v
24310
24311 #define v %esi
24312 @@ -70,6 +78,20 @@ RET_ENDP
24313 BEGIN(add)
24314 addl %eax, (v)
24315 adcl %edx, 4(v)
24316 +
24317 +#ifdef CONFIG_PAX_REFCOUNT
24318 + jno 0f
24319 + subl %eax, (v)
24320 + sbbl %edx, 4(v)
24321 + int $4
24322 +0:
24323 + _ASM_EXTABLE(0b, 0b)
24324 +#endif
24325 +
24326 +RET_ENDP
24327 +BEGIN(add_unchecked)
24328 + addl %eax, (v)
24329 + adcl %edx, 4(v)
24330 RET_ENDP
24331 #undef v
24332
24333 @@ -77,6 +99,24 @@ RET_ENDP
24334 BEGIN(add_return)
24335 addl (v), %eax
24336 adcl 4(v), %edx
24337 +
24338 +#ifdef CONFIG_PAX_REFCOUNT
24339 + into
24340 +1234:
24341 + _ASM_EXTABLE(1234b, 2f)
24342 +#endif
24343 +
24344 + movl %eax, (v)
24345 + movl %edx, 4(v)
24346 +
24347 +#ifdef CONFIG_PAX_REFCOUNT
24348 +2:
24349 +#endif
24350 +
24351 +RET_ENDP
24352 +BEGIN(add_return_unchecked)
24353 + addl (v), %eax
24354 + adcl 4(v), %edx
24355 movl %eax, (v)
24356 movl %edx, 4(v)
24357 RET_ENDP
24358 @@ -86,6 +126,20 @@ RET_ENDP
24359 BEGIN(sub)
24360 subl %eax, (v)
24361 sbbl %edx, 4(v)
24362 +
24363 +#ifdef CONFIG_PAX_REFCOUNT
24364 + jno 0f
24365 + addl %eax, (v)
24366 + adcl %edx, 4(v)
24367 + int $4
24368 +0:
24369 + _ASM_EXTABLE(0b, 0b)
24370 +#endif
24371 +
24372 +RET_ENDP
24373 +BEGIN(sub_unchecked)
24374 + subl %eax, (v)
24375 + sbbl %edx, 4(v)
24376 RET_ENDP
24377 #undef v
24378
24379 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24380 sbbl $0, %edx
24381 addl (v), %eax
24382 adcl 4(v), %edx
24383 +
24384 +#ifdef CONFIG_PAX_REFCOUNT
24385 + into
24386 +1234:
24387 + _ASM_EXTABLE(1234b, 2f)
24388 +#endif
24389 +
24390 + movl %eax, (v)
24391 + movl %edx, 4(v)
24392 +
24393 +#ifdef CONFIG_PAX_REFCOUNT
24394 +2:
24395 +#endif
24396 +
24397 +RET_ENDP
24398 +BEGIN(sub_return_unchecked)
24399 + negl %edx
24400 + negl %eax
24401 + sbbl $0, %edx
24402 + addl (v), %eax
24403 + adcl 4(v), %edx
24404 movl %eax, (v)
24405 movl %edx, 4(v)
24406 RET_ENDP
24407 @@ -105,6 +180,20 @@ RET_ENDP
24408 BEGIN(inc)
24409 addl $1, (v)
24410 adcl $0, 4(v)
24411 +
24412 +#ifdef CONFIG_PAX_REFCOUNT
24413 + jno 0f
24414 + subl $1, (v)
24415 + sbbl $0, 4(v)
24416 + int $4
24417 +0:
24418 + _ASM_EXTABLE(0b, 0b)
24419 +#endif
24420 +
24421 +RET_ENDP
24422 +BEGIN(inc_unchecked)
24423 + addl $1, (v)
24424 + adcl $0, 4(v)
24425 RET_ENDP
24426 #undef v
24427
24428 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24429 movl 4(v), %edx
24430 addl $1, %eax
24431 adcl $0, %edx
24432 +
24433 +#ifdef CONFIG_PAX_REFCOUNT
24434 + into
24435 +1234:
24436 + _ASM_EXTABLE(1234b, 2f)
24437 +#endif
24438 +
24439 + movl %eax, (v)
24440 + movl %edx, 4(v)
24441 +
24442 +#ifdef CONFIG_PAX_REFCOUNT
24443 +2:
24444 +#endif
24445 +
24446 +RET_ENDP
24447 +BEGIN(inc_return_unchecked)
24448 + movl (v), %eax
24449 + movl 4(v), %edx
24450 + addl $1, %eax
24451 + adcl $0, %edx
24452 movl %eax, (v)
24453 movl %edx, 4(v)
24454 RET_ENDP
24455 @@ -123,6 +232,20 @@ RET_ENDP
24456 BEGIN(dec)
24457 subl $1, (v)
24458 sbbl $0, 4(v)
24459 +
24460 +#ifdef CONFIG_PAX_REFCOUNT
24461 + jno 0f
24462 + addl $1, (v)
24463 + adcl $0, 4(v)
24464 + int $4
24465 +0:
24466 + _ASM_EXTABLE(0b, 0b)
24467 +#endif
24468 +
24469 +RET_ENDP
24470 +BEGIN(dec_unchecked)
24471 + subl $1, (v)
24472 + sbbl $0, 4(v)
24473 RET_ENDP
24474 #undef v
24475
24476 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24477 movl 4(v), %edx
24478 subl $1, %eax
24479 sbbl $0, %edx
24480 +
24481 +#ifdef CONFIG_PAX_REFCOUNT
24482 + into
24483 +1234:
24484 + _ASM_EXTABLE(1234b, 2f)
24485 +#endif
24486 +
24487 + movl %eax, (v)
24488 + movl %edx, 4(v)
24489 +
24490 +#ifdef CONFIG_PAX_REFCOUNT
24491 +2:
24492 +#endif
24493 +
24494 +RET_ENDP
24495 +BEGIN(dec_return_unchecked)
24496 + movl (v), %eax
24497 + movl 4(v), %edx
24498 + subl $1, %eax
24499 + sbbl $0, %edx
24500 movl %eax, (v)
24501 movl %edx, 4(v)
24502 RET_ENDP
24503 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24504 adcl %edx, %edi
24505 addl (v), %eax
24506 adcl 4(v), %edx
24507 +
24508 +#ifdef CONFIG_PAX_REFCOUNT
24509 + into
24510 +1234:
24511 + _ASM_EXTABLE(1234b, 2f)
24512 +#endif
24513 +
24514 cmpl %eax, %ecx
24515 je 3f
24516 1:
24517 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24518 1:
24519 addl $1, %eax
24520 adcl $0, %edx
24521 +
24522 +#ifdef CONFIG_PAX_REFCOUNT
24523 + into
24524 +1234:
24525 + _ASM_EXTABLE(1234b, 2f)
24526 +#endif
24527 +
24528 movl %eax, (v)
24529 movl %edx, 4(v)
24530 movl $1, %eax
24531 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24532 movl 4(v), %edx
24533 subl $1, %eax
24534 sbbl $0, %edx
24535 +
24536 +#ifdef CONFIG_PAX_REFCOUNT
24537 + into
24538 +1234:
24539 + _ASM_EXTABLE(1234b, 1f)
24540 +#endif
24541 +
24542 js 1f
24543 movl %eax, (v)
24544 movl %edx, 4(v)
24545 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24546 index f5cc9eb..51fa319 100644
24547 --- a/arch/x86/lib/atomic64_cx8_32.S
24548 +++ b/arch/x86/lib/atomic64_cx8_32.S
24549 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24550 CFI_STARTPROC
24551
24552 read64 %ecx
24553 + pax_force_retaddr
24554 ret
24555 CFI_ENDPROC
24556 ENDPROC(atomic64_read_cx8)
24557
24558 +ENTRY(atomic64_read_unchecked_cx8)
24559 + CFI_STARTPROC
24560 +
24561 + read64 %ecx
24562 + pax_force_retaddr
24563 + ret
24564 + CFI_ENDPROC
24565 +ENDPROC(atomic64_read_unchecked_cx8)
24566 +
24567 ENTRY(atomic64_set_cx8)
24568 CFI_STARTPROC
24569
24570 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24571 cmpxchg8b (%esi)
24572 jne 1b
24573
24574 + pax_force_retaddr
24575 ret
24576 CFI_ENDPROC
24577 ENDPROC(atomic64_set_cx8)
24578
24579 +ENTRY(atomic64_set_unchecked_cx8)
24580 + CFI_STARTPROC
24581 +
24582 +1:
24583 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24584 + * are atomic on 586 and newer */
24585 + cmpxchg8b (%esi)
24586 + jne 1b
24587 +
24588 + pax_force_retaddr
24589 + ret
24590 + CFI_ENDPROC
24591 +ENDPROC(atomic64_set_unchecked_cx8)
24592 +
24593 ENTRY(atomic64_xchg_cx8)
24594 CFI_STARTPROC
24595
24596 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24597 cmpxchg8b (%esi)
24598 jne 1b
24599
24600 + pax_force_retaddr
24601 ret
24602 CFI_ENDPROC
24603 ENDPROC(atomic64_xchg_cx8)
24604
24605 -.macro addsub_return func ins insc
24606 -ENTRY(atomic64_\func\()_return_cx8)
24607 +.macro addsub_return func ins insc unchecked=""
24608 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24609 CFI_STARTPROC
24610 SAVE ebp
24611 SAVE ebx
24612 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24613 movl %edx, %ecx
24614 \ins\()l %esi, %ebx
24615 \insc\()l %edi, %ecx
24616 +
24617 +.ifb \unchecked
24618 +#ifdef CONFIG_PAX_REFCOUNT
24619 + into
24620 +2:
24621 + _ASM_EXTABLE(2b, 3f)
24622 +#endif
24623 +.endif
24624 +
24625 LOCK_PREFIX
24626 cmpxchg8b (%ebp)
24627 jne 1b
24628 -
24629 -10:
24630 movl %ebx, %eax
24631 movl %ecx, %edx
24632 +
24633 +.ifb \unchecked
24634 +#ifdef CONFIG_PAX_REFCOUNT
24635 +3:
24636 +#endif
24637 +.endif
24638 +
24639 RESTORE edi
24640 RESTORE esi
24641 RESTORE ebx
24642 RESTORE ebp
24643 + pax_force_retaddr
24644 ret
24645 CFI_ENDPROC
24646 -ENDPROC(atomic64_\func\()_return_cx8)
24647 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24648 .endm
24649
24650 addsub_return add add adc
24651 addsub_return sub sub sbb
24652 +addsub_return add add adc _unchecked
24653 +addsub_return sub sub sbb _unchecked
24654
24655 -.macro incdec_return func ins insc
24656 -ENTRY(atomic64_\func\()_return_cx8)
24657 +.macro incdec_return func ins insc unchecked=""
24658 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24659 CFI_STARTPROC
24660 SAVE ebx
24661
24662 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24663 movl %edx, %ecx
24664 \ins\()l $1, %ebx
24665 \insc\()l $0, %ecx
24666 +
24667 +.ifb \unchecked
24668 +#ifdef CONFIG_PAX_REFCOUNT
24669 + into
24670 +2:
24671 + _ASM_EXTABLE(2b, 3f)
24672 +#endif
24673 +.endif
24674 +
24675 LOCK_PREFIX
24676 cmpxchg8b (%esi)
24677 jne 1b
24678
24679 -10:
24680 movl %ebx, %eax
24681 movl %ecx, %edx
24682 +
24683 +.ifb \unchecked
24684 +#ifdef CONFIG_PAX_REFCOUNT
24685 +3:
24686 +#endif
24687 +.endif
24688 +
24689 RESTORE ebx
24690 + pax_force_retaddr
24691 ret
24692 CFI_ENDPROC
24693 -ENDPROC(atomic64_\func\()_return_cx8)
24694 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24695 .endm
24696
24697 incdec_return inc add adc
24698 incdec_return dec sub sbb
24699 +incdec_return inc add adc _unchecked
24700 +incdec_return dec sub sbb _unchecked
24701
24702 ENTRY(atomic64_dec_if_positive_cx8)
24703 CFI_STARTPROC
24704 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24705 movl %edx, %ecx
24706 subl $1, %ebx
24707 sbb $0, %ecx
24708 +
24709 +#ifdef CONFIG_PAX_REFCOUNT
24710 + into
24711 +1234:
24712 + _ASM_EXTABLE(1234b, 2f)
24713 +#endif
24714 +
24715 js 2f
24716 LOCK_PREFIX
24717 cmpxchg8b (%esi)
24718 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24719 movl %ebx, %eax
24720 movl %ecx, %edx
24721 RESTORE ebx
24722 + pax_force_retaddr
24723 ret
24724 CFI_ENDPROC
24725 ENDPROC(atomic64_dec_if_positive_cx8)
24726 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24727 movl %edx, %ecx
24728 addl %ebp, %ebx
24729 adcl %edi, %ecx
24730 +
24731 +#ifdef CONFIG_PAX_REFCOUNT
24732 + into
24733 +1234:
24734 + _ASM_EXTABLE(1234b, 3f)
24735 +#endif
24736 +
24737 LOCK_PREFIX
24738 cmpxchg8b (%esi)
24739 jne 1b
24740 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24741 CFI_ADJUST_CFA_OFFSET -8
24742 RESTORE ebx
24743 RESTORE ebp
24744 + pax_force_retaddr
24745 ret
24746 4:
24747 cmpl %edx, 4(%esp)
24748 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24749 xorl %ecx, %ecx
24750 addl $1, %ebx
24751 adcl %edx, %ecx
24752 +
24753 +#ifdef CONFIG_PAX_REFCOUNT
24754 + into
24755 +1234:
24756 + _ASM_EXTABLE(1234b, 3f)
24757 +#endif
24758 +
24759 LOCK_PREFIX
24760 cmpxchg8b (%esi)
24761 jne 1b
24762 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24763 movl $1, %eax
24764 3:
24765 RESTORE ebx
24766 + pax_force_retaddr
24767 ret
24768 CFI_ENDPROC
24769 ENDPROC(atomic64_inc_not_zero_cx8)
24770 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24771 index 2af5df3..62b1a5a 100644
24772 --- a/arch/x86/lib/checksum_32.S
24773 +++ b/arch/x86/lib/checksum_32.S
24774 @@ -29,7 +29,8 @@
24775 #include <asm/dwarf2.h>
24776 #include <asm/errno.h>
24777 #include <asm/asm.h>
24778 -
24779 +#include <asm/segment.h>
24780 +
24781 /*
24782 * computes a partial checksum, e.g. for TCP/UDP fragments
24783 */
24784 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24785
24786 #define ARGBASE 16
24787 #define FP 12
24788 -
24789 -ENTRY(csum_partial_copy_generic)
24790 +
24791 +ENTRY(csum_partial_copy_generic_to_user)
24792 CFI_STARTPROC
24793 +
24794 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24795 + pushl_cfi %gs
24796 + popl_cfi %es
24797 + jmp csum_partial_copy_generic
24798 +#endif
24799 +
24800 +ENTRY(csum_partial_copy_generic_from_user)
24801 +
24802 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24803 + pushl_cfi %gs
24804 + popl_cfi %ds
24805 +#endif
24806 +
24807 +ENTRY(csum_partial_copy_generic)
24808 subl $4,%esp
24809 CFI_ADJUST_CFA_OFFSET 4
24810 pushl_cfi %edi
24811 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24812 jmp 4f
24813 SRC(1: movw (%esi), %bx )
24814 addl $2, %esi
24815 -DST( movw %bx, (%edi) )
24816 +DST( movw %bx, %es:(%edi) )
24817 addl $2, %edi
24818 addw %bx, %ax
24819 adcl $0, %eax
24820 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24821 SRC(1: movl (%esi), %ebx )
24822 SRC( movl 4(%esi), %edx )
24823 adcl %ebx, %eax
24824 -DST( movl %ebx, (%edi) )
24825 +DST( movl %ebx, %es:(%edi) )
24826 adcl %edx, %eax
24827 -DST( movl %edx, 4(%edi) )
24828 +DST( movl %edx, %es:4(%edi) )
24829
24830 SRC( movl 8(%esi), %ebx )
24831 SRC( movl 12(%esi), %edx )
24832 adcl %ebx, %eax
24833 -DST( movl %ebx, 8(%edi) )
24834 +DST( movl %ebx, %es:8(%edi) )
24835 adcl %edx, %eax
24836 -DST( movl %edx, 12(%edi) )
24837 +DST( movl %edx, %es:12(%edi) )
24838
24839 SRC( movl 16(%esi), %ebx )
24840 SRC( movl 20(%esi), %edx )
24841 adcl %ebx, %eax
24842 -DST( movl %ebx, 16(%edi) )
24843 +DST( movl %ebx, %es:16(%edi) )
24844 adcl %edx, %eax
24845 -DST( movl %edx, 20(%edi) )
24846 +DST( movl %edx, %es:20(%edi) )
24847
24848 SRC( movl 24(%esi), %ebx )
24849 SRC( movl 28(%esi), %edx )
24850 adcl %ebx, %eax
24851 -DST( movl %ebx, 24(%edi) )
24852 +DST( movl %ebx, %es:24(%edi) )
24853 adcl %edx, %eax
24854 -DST( movl %edx, 28(%edi) )
24855 +DST( movl %edx, %es:28(%edi) )
24856
24857 lea 32(%esi), %esi
24858 lea 32(%edi), %edi
24859 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24860 shrl $2, %edx # This clears CF
24861 SRC(3: movl (%esi), %ebx )
24862 adcl %ebx, %eax
24863 -DST( movl %ebx, (%edi) )
24864 +DST( movl %ebx, %es:(%edi) )
24865 lea 4(%esi), %esi
24866 lea 4(%edi), %edi
24867 dec %edx
24868 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24869 jb 5f
24870 SRC( movw (%esi), %cx )
24871 leal 2(%esi), %esi
24872 -DST( movw %cx, (%edi) )
24873 +DST( movw %cx, %es:(%edi) )
24874 leal 2(%edi), %edi
24875 je 6f
24876 shll $16,%ecx
24877 SRC(5: movb (%esi), %cl )
24878 -DST( movb %cl, (%edi) )
24879 +DST( movb %cl, %es:(%edi) )
24880 6: addl %ecx, %eax
24881 adcl $0, %eax
24882 7:
24883 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24884
24885 6001:
24886 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24887 - movl $-EFAULT, (%ebx)
24888 + movl $-EFAULT, %ss:(%ebx)
24889
24890 # zero the complete destination - computing the rest
24891 # is too much work
24892 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24893
24894 6002:
24895 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24896 - movl $-EFAULT,(%ebx)
24897 + movl $-EFAULT,%ss:(%ebx)
24898 jmp 5000b
24899
24900 .previous
24901
24902 + pushl_cfi %ss
24903 + popl_cfi %ds
24904 + pushl_cfi %ss
24905 + popl_cfi %es
24906 popl_cfi %ebx
24907 CFI_RESTORE ebx
24908 popl_cfi %esi
24909 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24910 popl_cfi %ecx # equivalent to addl $4,%esp
24911 ret
24912 CFI_ENDPROC
24913 -ENDPROC(csum_partial_copy_generic)
24914 +ENDPROC(csum_partial_copy_generic_to_user)
24915
24916 #else
24917
24918 /* Version for PentiumII/PPro */
24919
24920 #define ROUND1(x) \
24921 + nop; nop; nop; \
24922 SRC(movl x(%esi), %ebx ) ; \
24923 addl %ebx, %eax ; \
24924 - DST(movl %ebx, x(%edi) ) ;
24925 + DST(movl %ebx, %es:x(%edi)) ;
24926
24927 #define ROUND(x) \
24928 + nop; nop; nop; \
24929 SRC(movl x(%esi), %ebx ) ; \
24930 adcl %ebx, %eax ; \
24931 - DST(movl %ebx, x(%edi) ) ;
24932 + DST(movl %ebx, %es:x(%edi)) ;
24933
24934 #define ARGBASE 12
24935 -
24936 -ENTRY(csum_partial_copy_generic)
24937 +
24938 +ENTRY(csum_partial_copy_generic_to_user)
24939 CFI_STARTPROC
24940 +
24941 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24942 + pushl_cfi %gs
24943 + popl_cfi %es
24944 + jmp csum_partial_copy_generic
24945 +#endif
24946 +
24947 +ENTRY(csum_partial_copy_generic_from_user)
24948 +
24949 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24950 + pushl_cfi %gs
24951 + popl_cfi %ds
24952 +#endif
24953 +
24954 +ENTRY(csum_partial_copy_generic)
24955 pushl_cfi %ebx
24956 CFI_REL_OFFSET ebx, 0
24957 pushl_cfi %edi
24958 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24959 subl %ebx, %edi
24960 lea -1(%esi),%edx
24961 andl $-32,%edx
24962 - lea 3f(%ebx,%ebx), %ebx
24963 + lea 3f(%ebx,%ebx,2), %ebx
24964 testl %esi, %esi
24965 jmp *%ebx
24966 1: addl $64,%esi
24967 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24968 jb 5f
24969 SRC( movw (%esi), %dx )
24970 leal 2(%esi), %esi
24971 -DST( movw %dx, (%edi) )
24972 +DST( movw %dx, %es:(%edi) )
24973 leal 2(%edi), %edi
24974 je 6f
24975 shll $16,%edx
24976 5:
24977 SRC( movb (%esi), %dl )
24978 -DST( movb %dl, (%edi) )
24979 +DST( movb %dl, %es:(%edi) )
24980 6: addl %edx, %eax
24981 adcl $0, %eax
24982 7:
24983 .section .fixup, "ax"
24984 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24985 - movl $-EFAULT, (%ebx)
24986 + movl $-EFAULT, %ss:(%ebx)
24987 # zero the complete destination (computing the rest is too much work)
24988 movl ARGBASE+8(%esp),%edi # dst
24989 movl ARGBASE+12(%esp),%ecx # len
24990 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24991 rep; stosb
24992 jmp 7b
24993 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24994 - movl $-EFAULT, (%ebx)
24995 + movl $-EFAULT, %ss:(%ebx)
24996 jmp 7b
24997 .previous
24998
24999 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25000 + pushl_cfi %ss
25001 + popl_cfi %ds
25002 + pushl_cfi %ss
25003 + popl_cfi %es
25004 +#endif
25005 +
25006 popl_cfi %esi
25007 CFI_RESTORE esi
25008 popl_cfi %edi
25009 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25010 CFI_RESTORE ebx
25011 ret
25012 CFI_ENDPROC
25013 -ENDPROC(csum_partial_copy_generic)
25014 +ENDPROC(csum_partial_copy_generic_to_user)
25015
25016 #undef ROUND
25017 #undef ROUND1
25018 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25019 index f2145cf..cea889d 100644
25020 --- a/arch/x86/lib/clear_page_64.S
25021 +++ b/arch/x86/lib/clear_page_64.S
25022 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25023 movl $4096/8,%ecx
25024 xorl %eax,%eax
25025 rep stosq
25026 + pax_force_retaddr
25027 ret
25028 CFI_ENDPROC
25029 ENDPROC(clear_page_c)
25030 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25031 movl $4096,%ecx
25032 xorl %eax,%eax
25033 rep stosb
25034 + pax_force_retaddr
25035 ret
25036 CFI_ENDPROC
25037 ENDPROC(clear_page_c_e)
25038 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25039 leaq 64(%rdi),%rdi
25040 jnz .Lloop
25041 nop
25042 + pax_force_retaddr
25043 ret
25044 CFI_ENDPROC
25045 .Lclear_page_end:
25046 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25047
25048 #include <asm/cpufeature.h>
25049
25050 - .section .altinstr_replacement,"ax"
25051 + .section .altinstr_replacement,"a"
25052 1: .byte 0xeb /* jmp <disp8> */
25053 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25054 2: .byte 0xeb /* jmp <disp8> */
25055 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25056 index 1e572c5..2a162cd 100644
25057 --- a/arch/x86/lib/cmpxchg16b_emu.S
25058 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25059 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25060
25061 popf
25062 mov $1, %al
25063 + pax_force_retaddr
25064 ret
25065
25066 not_same:
25067 popf
25068 xor %al,%al
25069 + pax_force_retaddr
25070 ret
25071
25072 CFI_ENDPROC
25073 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25074 index 176cca6..1166c50 100644
25075 --- a/arch/x86/lib/copy_page_64.S
25076 +++ b/arch/x86/lib/copy_page_64.S
25077 @@ -9,6 +9,7 @@ copy_page_rep:
25078 CFI_STARTPROC
25079 movl $4096/8, %ecx
25080 rep movsq
25081 + pax_force_retaddr
25082 ret
25083 CFI_ENDPROC
25084 ENDPROC(copy_page_rep)
25085 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25086
25087 ENTRY(copy_page)
25088 CFI_STARTPROC
25089 - subq $2*8, %rsp
25090 - CFI_ADJUST_CFA_OFFSET 2*8
25091 + subq $3*8, %rsp
25092 + CFI_ADJUST_CFA_OFFSET 3*8
25093 movq %rbx, (%rsp)
25094 CFI_REL_OFFSET rbx, 0
25095 movq %r12, 1*8(%rsp)
25096 CFI_REL_OFFSET r12, 1*8
25097 + movq %r13, 2*8(%rsp)
25098 + CFI_REL_OFFSET r13, 2*8
25099
25100 movl $(4096/64)-5, %ecx
25101 .p2align 4
25102 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25103 movq 0x8*2(%rsi), %rdx
25104 movq 0x8*3(%rsi), %r8
25105 movq 0x8*4(%rsi), %r9
25106 - movq 0x8*5(%rsi), %r10
25107 + movq 0x8*5(%rsi), %r13
25108 movq 0x8*6(%rsi), %r11
25109 movq 0x8*7(%rsi), %r12
25110
25111 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25112 movq %rdx, 0x8*2(%rdi)
25113 movq %r8, 0x8*3(%rdi)
25114 movq %r9, 0x8*4(%rdi)
25115 - movq %r10, 0x8*5(%rdi)
25116 + movq %r13, 0x8*5(%rdi)
25117 movq %r11, 0x8*6(%rdi)
25118 movq %r12, 0x8*7(%rdi)
25119
25120 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25121 movq 0x8*2(%rsi), %rdx
25122 movq 0x8*3(%rsi), %r8
25123 movq 0x8*4(%rsi), %r9
25124 - movq 0x8*5(%rsi), %r10
25125 + movq 0x8*5(%rsi), %r13
25126 movq 0x8*6(%rsi), %r11
25127 movq 0x8*7(%rsi), %r12
25128
25129 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25130 movq %rdx, 0x8*2(%rdi)
25131 movq %r8, 0x8*3(%rdi)
25132 movq %r9, 0x8*4(%rdi)
25133 - movq %r10, 0x8*5(%rdi)
25134 + movq %r13, 0x8*5(%rdi)
25135 movq %r11, 0x8*6(%rdi)
25136 movq %r12, 0x8*7(%rdi)
25137
25138 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25139 CFI_RESTORE rbx
25140 movq 1*8(%rsp), %r12
25141 CFI_RESTORE r12
25142 - addq $2*8, %rsp
25143 - CFI_ADJUST_CFA_OFFSET -2*8
25144 + movq 2*8(%rsp), %r13
25145 + CFI_RESTORE r13
25146 + addq $3*8, %rsp
25147 + CFI_ADJUST_CFA_OFFSET -3*8
25148 + pax_force_retaddr
25149 ret
25150 .Lcopy_page_end:
25151 CFI_ENDPROC
25152 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25153
25154 #include <asm/cpufeature.h>
25155
25156 - .section .altinstr_replacement,"ax"
25157 + .section .altinstr_replacement,"a"
25158 1: .byte 0xeb /* jmp <disp8> */
25159 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25160 2:
25161 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25162 index a30ca15..d25fab6 100644
25163 --- a/arch/x86/lib/copy_user_64.S
25164 +++ b/arch/x86/lib/copy_user_64.S
25165 @@ -18,6 +18,7 @@
25166 #include <asm/alternative-asm.h>
25167 #include <asm/asm.h>
25168 #include <asm/smap.h>
25169 +#include <asm/pgtable.h>
25170
25171 /*
25172 * By placing feature2 after feature1 in altinstructions section, we logically
25173 @@ -31,7 +32,7 @@
25174 .byte 0xe9 /* 32bit jump */
25175 .long \orig-1f /* by default jump to orig */
25176 1:
25177 - .section .altinstr_replacement,"ax"
25178 + .section .altinstr_replacement,"a"
25179 2: .byte 0xe9 /* near jump with 32bit immediate */
25180 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25181 3: .byte 0xe9 /* near jump with 32bit immediate */
25182 @@ -70,47 +71,20 @@
25183 #endif
25184 .endm
25185
25186 -/* Standard copy_to_user with segment limit checking */
25187 -ENTRY(_copy_to_user)
25188 - CFI_STARTPROC
25189 - GET_THREAD_INFO(%rax)
25190 - movq %rdi,%rcx
25191 - addq %rdx,%rcx
25192 - jc bad_to_user
25193 - cmpq TI_addr_limit(%rax),%rcx
25194 - ja bad_to_user
25195 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25196 - copy_user_generic_unrolled,copy_user_generic_string, \
25197 - copy_user_enhanced_fast_string
25198 - CFI_ENDPROC
25199 -ENDPROC(_copy_to_user)
25200 -
25201 -/* Standard copy_from_user with segment limit checking */
25202 -ENTRY(_copy_from_user)
25203 - CFI_STARTPROC
25204 - GET_THREAD_INFO(%rax)
25205 - movq %rsi,%rcx
25206 - addq %rdx,%rcx
25207 - jc bad_from_user
25208 - cmpq TI_addr_limit(%rax),%rcx
25209 - ja bad_from_user
25210 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25211 - copy_user_generic_unrolled,copy_user_generic_string, \
25212 - copy_user_enhanced_fast_string
25213 - CFI_ENDPROC
25214 -ENDPROC(_copy_from_user)
25215 -
25216 .section .fixup,"ax"
25217 /* must zero dest */
25218 ENTRY(bad_from_user)
25219 bad_from_user:
25220 CFI_STARTPROC
25221 + testl %edx,%edx
25222 + js bad_to_user
25223 movl %edx,%ecx
25224 xorl %eax,%eax
25225 rep
25226 stosb
25227 bad_to_user:
25228 movl %edx,%eax
25229 + pax_force_retaddr
25230 ret
25231 CFI_ENDPROC
25232 ENDPROC(bad_from_user)
25233 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25234 jz 17f
25235 1: movq (%rsi),%r8
25236 2: movq 1*8(%rsi),%r9
25237 -3: movq 2*8(%rsi),%r10
25238 +3: movq 2*8(%rsi),%rax
25239 4: movq 3*8(%rsi),%r11
25240 5: movq %r8,(%rdi)
25241 6: movq %r9,1*8(%rdi)
25242 -7: movq %r10,2*8(%rdi)
25243 +7: movq %rax,2*8(%rdi)
25244 8: movq %r11,3*8(%rdi)
25245 9: movq 4*8(%rsi),%r8
25246 10: movq 5*8(%rsi),%r9
25247 -11: movq 6*8(%rsi),%r10
25248 +11: movq 6*8(%rsi),%rax
25249 12: movq 7*8(%rsi),%r11
25250 13: movq %r8,4*8(%rdi)
25251 14: movq %r9,5*8(%rdi)
25252 -15: movq %r10,6*8(%rdi)
25253 +15: movq %rax,6*8(%rdi)
25254 16: movq %r11,7*8(%rdi)
25255 leaq 64(%rsi),%rsi
25256 leaq 64(%rdi),%rdi
25257 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25258 jnz 21b
25259 23: xor %eax,%eax
25260 ASM_CLAC
25261 + pax_force_retaddr
25262 ret
25263
25264 .section .fixup,"ax"
25265 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25266 movsb
25267 4: xorl %eax,%eax
25268 ASM_CLAC
25269 + pax_force_retaddr
25270 ret
25271
25272 .section .fixup,"ax"
25273 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25274 movsb
25275 2: xorl %eax,%eax
25276 ASM_CLAC
25277 + pax_force_retaddr
25278 ret
25279
25280 .section .fixup,"ax"
25281 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25282 index 6a4f43c..f08b4a2 100644
25283 --- a/arch/x86/lib/copy_user_nocache_64.S
25284 +++ b/arch/x86/lib/copy_user_nocache_64.S
25285 @@ -8,6 +8,7 @@
25286
25287 #include <linux/linkage.h>
25288 #include <asm/dwarf2.h>
25289 +#include <asm/alternative-asm.h>
25290
25291 #define FIX_ALIGNMENT 1
25292
25293 @@ -16,6 +17,7 @@
25294 #include <asm/thread_info.h>
25295 #include <asm/asm.h>
25296 #include <asm/smap.h>
25297 +#include <asm/pgtable.h>
25298
25299 .macro ALIGN_DESTINATION
25300 #ifdef FIX_ALIGNMENT
25301 @@ -49,6 +51,15 @@
25302 */
25303 ENTRY(__copy_user_nocache)
25304 CFI_STARTPROC
25305 +
25306 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25307 + mov pax_user_shadow_base,%rcx
25308 + cmp %rcx,%rsi
25309 + jae 1f
25310 + add %rcx,%rsi
25311 +1:
25312 +#endif
25313 +
25314 ASM_STAC
25315 cmpl $8,%edx
25316 jb 20f /* less then 8 bytes, go to byte copy loop */
25317 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25318 jz 17f
25319 1: movq (%rsi),%r8
25320 2: movq 1*8(%rsi),%r9
25321 -3: movq 2*8(%rsi),%r10
25322 +3: movq 2*8(%rsi),%rax
25323 4: movq 3*8(%rsi),%r11
25324 5: movnti %r8,(%rdi)
25325 6: movnti %r9,1*8(%rdi)
25326 -7: movnti %r10,2*8(%rdi)
25327 +7: movnti %rax,2*8(%rdi)
25328 8: movnti %r11,3*8(%rdi)
25329 9: movq 4*8(%rsi),%r8
25330 10: movq 5*8(%rsi),%r9
25331 -11: movq 6*8(%rsi),%r10
25332 +11: movq 6*8(%rsi),%rax
25333 12: movq 7*8(%rsi),%r11
25334 13: movnti %r8,4*8(%rdi)
25335 14: movnti %r9,5*8(%rdi)
25336 -15: movnti %r10,6*8(%rdi)
25337 +15: movnti %rax,6*8(%rdi)
25338 16: movnti %r11,7*8(%rdi)
25339 leaq 64(%rsi),%rsi
25340 leaq 64(%rdi),%rdi
25341 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25342 23: xorl %eax,%eax
25343 ASM_CLAC
25344 sfence
25345 + pax_force_retaddr
25346 ret
25347
25348 .section .fixup,"ax"
25349 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25350 index 2419d5f..953ee51 100644
25351 --- a/arch/x86/lib/csum-copy_64.S
25352 +++ b/arch/x86/lib/csum-copy_64.S
25353 @@ -9,6 +9,7 @@
25354 #include <asm/dwarf2.h>
25355 #include <asm/errno.h>
25356 #include <asm/asm.h>
25357 +#include <asm/alternative-asm.h>
25358
25359 /*
25360 * Checksum copy with exception handling.
25361 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25362 CFI_RESTORE rbp
25363 addq $7*8, %rsp
25364 CFI_ADJUST_CFA_OFFSET -7*8
25365 + pax_force_retaddr 0, 1
25366 ret
25367 CFI_RESTORE_STATE
25368
25369 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25370 index 25b7ae8..169fafc 100644
25371 --- a/arch/x86/lib/csum-wrappers_64.c
25372 +++ b/arch/x86/lib/csum-wrappers_64.c
25373 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25374 len -= 2;
25375 }
25376 }
25377 - isum = csum_partial_copy_generic((__force const void *)src,
25378 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25379 dst, len, isum, errp, NULL);
25380 if (unlikely(*errp))
25381 goto out_err;
25382 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25383 }
25384
25385 *errp = 0;
25386 - return csum_partial_copy_generic(src, (void __force *)dst,
25387 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25388 len, isum, NULL, errp);
25389 }
25390 EXPORT_SYMBOL(csum_partial_copy_to_user);
25391 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25392 index a451235..79fb5cf 100644
25393 --- a/arch/x86/lib/getuser.S
25394 +++ b/arch/x86/lib/getuser.S
25395 @@ -33,17 +33,40 @@
25396 #include <asm/thread_info.h>
25397 #include <asm/asm.h>
25398 #include <asm/smap.h>
25399 +#include <asm/segment.h>
25400 +#include <asm/pgtable.h>
25401 +#include <asm/alternative-asm.h>
25402 +
25403 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25404 +#define __copyuser_seg gs;
25405 +#else
25406 +#define __copyuser_seg
25407 +#endif
25408
25409 .text
25410 ENTRY(__get_user_1)
25411 CFI_STARTPROC
25412 +
25413 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25414 GET_THREAD_INFO(%_ASM_DX)
25415 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25416 jae bad_get_user
25417 ASM_STAC
25418 -1: movzbl (%_ASM_AX),%edx
25419 +
25420 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25421 + mov pax_user_shadow_base,%_ASM_DX
25422 + cmp %_ASM_DX,%_ASM_AX
25423 + jae 1234f
25424 + add %_ASM_DX,%_ASM_AX
25425 +1234:
25426 +#endif
25427 +
25428 +#endif
25429 +
25430 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25431 xor %eax,%eax
25432 ASM_CLAC
25433 + pax_force_retaddr
25434 ret
25435 CFI_ENDPROC
25436 ENDPROC(__get_user_1)
25437 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25438 ENTRY(__get_user_2)
25439 CFI_STARTPROC
25440 add $1,%_ASM_AX
25441 +
25442 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25443 jc bad_get_user
25444 GET_THREAD_INFO(%_ASM_DX)
25445 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25446 jae bad_get_user
25447 ASM_STAC
25448 -2: movzwl -1(%_ASM_AX),%edx
25449 +
25450 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25451 + mov pax_user_shadow_base,%_ASM_DX
25452 + cmp %_ASM_DX,%_ASM_AX
25453 + jae 1234f
25454 + add %_ASM_DX,%_ASM_AX
25455 +1234:
25456 +#endif
25457 +
25458 +#endif
25459 +
25460 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25461 xor %eax,%eax
25462 ASM_CLAC
25463 + pax_force_retaddr
25464 ret
25465 CFI_ENDPROC
25466 ENDPROC(__get_user_2)
25467 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25468 ENTRY(__get_user_4)
25469 CFI_STARTPROC
25470 add $3,%_ASM_AX
25471 +
25472 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25473 jc bad_get_user
25474 GET_THREAD_INFO(%_ASM_DX)
25475 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25476 jae bad_get_user
25477 ASM_STAC
25478 -3: movl -3(%_ASM_AX),%edx
25479 +
25480 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25481 + mov pax_user_shadow_base,%_ASM_DX
25482 + cmp %_ASM_DX,%_ASM_AX
25483 + jae 1234f
25484 + add %_ASM_DX,%_ASM_AX
25485 +1234:
25486 +#endif
25487 +
25488 +#endif
25489 +
25490 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25491 xor %eax,%eax
25492 ASM_CLAC
25493 + pax_force_retaddr
25494 ret
25495 CFI_ENDPROC
25496 ENDPROC(__get_user_4)
25497 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25498 GET_THREAD_INFO(%_ASM_DX)
25499 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25500 jae bad_get_user
25501 +
25502 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25503 + mov pax_user_shadow_base,%_ASM_DX
25504 + cmp %_ASM_DX,%_ASM_AX
25505 + jae 1234f
25506 + add %_ASM_DX,%_ASM_AX
25507 +1234:
25508 +#endif
25509 +
25510 ASM_STAC
25511 4: movq -7(%_ASM_AX),%rdx
25512 xor %eax,%eax
25513 ASM_CLAC
25514 + pax_force_retaddr
25515 ret
25516 #else
25517 add $7,%_ASM_AX
25518 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25519 5: movl -3(%_ASM_AX),%ecx
25520 xor %eax,%eax
25521 ASM_CLAC
25522 + pax_force_retaddr
25523 ret
25524 #endif
25525 CFI_ENDPROC
25526 @@ -113,6 +175,7 @@ bad_get_user:
25527 xor %edx,%edx
25528 mov $(-EFAULT),%_ASM_AX
25529 ASM_CLAC
25530 + pax_force_retaddr
25531 ret
25532 CFI_ENDPROC
25533 END(bad_get_user)
25534 @@ -124,6 +187,7 @@ bad_get_user_8:
25535 xor %ecx,%ecx
25536 mov $(-EFAULT),%_ASM_AX
25537 ASM_CLAC
25538 + pax_force_retaddr
25539 ret
25540 CFI_ENDPROC
25541 END(bad_get_user_8)
25542 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25543 index 54fcffe..7be149e 100644
25544 --- a/arch/x86/lib/insn.c
25545 +++ b/arch/x86/lib/insn.c
25546 @@ -20,8 +20,10 @@
25547
25548 #ifdef __KERNEL__
25549 #include <linux/string.h>
25550 +#include <asm/pgtable_types.h>
25551 #else
25552 #include <string.h>
25553 +#define ktla_ktva(addr) addr
25554 #endif
25555 #include <asm/inat.h>
25556 #include <asm/insn.h>
25557 @@ -53,8 +55,8 @@
25558 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25559 {
25560 memset(insn, 0, sizeof(*insn));
25561 - insn->kaddr = kaddr;
25562 - insn->next_byte = kaddr;
25563 + insn->kaddr = ktla_ktva(kaddr);
25564 + insn->next_byte = ktla_ktva(kaddr);
25565 insn->x86_64 = x86_64 ? 1 : 0;
25566 insn->opnd_bytes = 4;
25567 if (x86_64)
25568 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25569 index 05a95e7..326f2fa 100644
25570 --- a/arch/x86/lib/iomap_copy_64.S
25571 +++ b/arch/x86/lib/iomap_copy_64.S
25572 @@ -17,6 +17,7 @@
25573
25574 #include <linux/linkage.h>
25575 #include <asm/dwarf2.h>
25576 +#include <asm/alternative-asm.h>
25577
25578 /*
25579 * override generic version in lib/iomap_copy.c
25580 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25581 CFI_STARTPROC
25582 movl %edx,%ecx
25583 rep movsd
25584 + pax_force_retaddr
25585 ret
25586 CFI_ENDPROC
25587 ENDPROC(__iowrite32_copy)
25588 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25589 index 1c273be..da9cc0e 100644
25590 --- a/arch/x86/lib/memcpy_64.S
25591 +++ b/arch/x86/lib/memcpy_64.S
25592 @@ -33,6 +33,7 @@
25593 rep movsq
25594 movl %edx, %ecx
25595 rep movsb
25596 + pax_force_retaddr
25597 ret
25598 .Lmemcpy_e:
25599 .previous
25600 @@ -49,6 +50,7 @@
25601 movq %rdi, %rax
25602 movq %rdx, %rcx
25603 rep movsb
25604 + pax_force_retaddr
25605 ret
25606 .Lmemcpy_e_e:
25607 .previous
25608 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25609 */
25610 movq 0*8(%rsi), %r8
25611 movq 1*8(%rsi), %r9
25612 - movq 2*8(%rsi), %r10
25613 + movq 2*8(%rsi), %rcx
25614 movq 3*8(%rsi), %r11
25615 leaq 4*8(%rsi), %rsi
25616
25617 movq %r8, 0*8(%rdi)
25618 movq %r9, 1*8(%rdi)
25619 - movq %r10, 2*8(%rdi)
25620 + movq %rcx, 2*8(%rdi)
25621 movq %r11, 3*8(%rdi)
25622 leaq 4*8(%rdi), %rdi
25623 jae .Lcopy_forward_loop
25624 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25625 subq $0x20, %rdx
25626 movq -1*8(%rsi), %r8
25627 movq -2*8(%rsi), %r9
25628 - movq -3*8(%rsi), %r10
25629 + movq -3*8(%rsi), %rcx
25630 movq -4*8(%rsi), %r11
25631 leaq -4*8(%rsi), %rsi
25632 movq %r8, -1*8(%rdi)
25633 movq %r9, -2*8(%rdi)
25634 - movq %r10, -3*8(%rdi)
25635 + movq %rcx, -3*8(%rdi)
25636 movq %r11, -4*8(%rdi)
25637 leaq -4*8(%rdi), %rdi
25638 jae .Lcopy_backward_loop
25639 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25640 */
25641 movq 0*8(%rsi), %r8
25642 movq 1*8(%rsi), %r9
25643 - movq -2*8(%rsi, %rdx), %r10
25644 + movq -2*8(%rsi, %rdx), %rcx
25645 movq -1*8(%rsi, %rdx), %r11
25646 movq %r8, 0*8(%rdi)
25647 movq %r9, 1*8(%rdi)
25648 - movq %r10, -2*8(%rdi, %rdx)
25649 + movq %rcx, -2*8(%rdi, %rdx)
25650 movq %r11, -1*8(%rdi, %rdx)
25651 + pax_force_retaddr
25652 retq
25653 .p2align 4
25654 .Lless_16bytes:
25655 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25656 movq -1*8(%rsi, %rdx), %r9
25657 movq %r8, 0*8(%rdi)
25658 movq %r9, -1*8(%rdi, %rdx)
25659 + pax_force_retaddr
25660 retq
25661 .p2align 4
25662 .Lless_8bytes:
25663 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25664 movl -4(%rsi, %rdx), %r8d
25665 movl %ecx, (%rdi)
25666 movl %r8d, -4(%rdi, %rdx)
25667 + pax_force_retaddr
25668 retq
25669 .p2align 4
25670 .Lless_3bytes:
25671 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25672 movb %cl, (%rdi)
25673
25674 .Lend:
25675 + pax_force_retaddr
25676 retq
25677 CFI_ENDPROC
25678 ENDPROC(memcpy)
25679 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25680 index ee16461..c39c199 100644
25681 --- a/arch/x86/lib/memmove_64.S
25682 +++ b/arch/x86/lib/memmove_64.S
25683 @@ -61,13 +61,13 @@ ENTRY(memmove)
25684 5:
25685 sub $0x20, %rdx
25686 movq 0*8(%rsi), %r11
25687 - movq 1*8(%rsi), %r10
25688 + movq 1*8(%rsi), %rcx
25689 movq 2*8(%rsi), %r9
25690 movq 3*8(%rsi), %r8
25691 leaq 4*8(%rsi), %rsi
25692
25693 movq %r11, 0*8(%rdi)
25694 - movq %r10, 1*8(%rdi)
25695 + movq %rcx, 1*8(%rdi)
25696 movq %r9, 2*8(%rdi)
25697 movq %r8, 3*8(%rdi)
25698 leaq 4*8(%rdi), %rdi
25699 @@ -81,10 +81,10 @@ ENTRY(memmove)
25700 4:
25701 movq %rdx, %rcx
25702 movq -8(%rsi, %rdx), %r11
25703 - lea -8(%rdi, %rdx), %r10
25704 + lea -8(%rdi, %rdx), %r9
25705 shrq $3, %rcx
25706 rep movsq
25707 - movq %r11, (%r10)
25708 + movq %r11, (%r9)
25709 jmp 13f
25710 .Lmemmove_end_forward:
25711
25712 @@ -95,14 +95,14 @@ ENTRY(memmove)
25713 7:
25714 movq %rdx, %rcx
25715 movq (%rsi), %r11
25716 - movq %rdi, %r10
25717 + movq %rdi, %r9
25718 leaq -8(%rsi, %rdx), %rsi
25719 leaq -8(%rdi, %rdx), %rdi
25720 shrq $3, %rcx
25721 std
25722 rep movsq
25723 cld
25724 - movq %r11, (%r10)
25725 + movq %r11, (%r9)
25726 jmp 13f
25727
25728 /*
25729 @@ -127,13 +127,13 @@ ENTRY(memmove)
25730 8:
25731 subq $0x20, %rdx
25732 movq -1*8(%rsi), %r11
25733 - movq -2*8(%rsi), %r10
25734 + movq -2*8(%rsi), %rcx
25735 movq -3*8(%rsi), %r9
25736 movq -4*8(%rsi), %r8
25737 leaq -4*8(%rsi), %rsi
25738
25739 movq %r11, -1*8(%rdi)
25740 - movq %r10, -2*8(%rdi)
25741 + movq %rcx, -2*8(%rdi)
25742 movq %r9, -3*8(%rdi)
25743 movq %r8, -4*8(%rdi)
25744 leaq -4*8(%rdi), %rdi
25745 @@ -151,11 +151,11 @@ ENTRY(memmove)
25746 * Move data from 16 bytes to 31 bytes.
25747 */
25748 movq 0*8(%rsi), %r11
25749 - movq 1*8(%rsi), %r10
25750 + movq 1*8(%rsi), %rcx
25751 movq -2*8(%rsi, %rdx), %r9
25752 movq -1*8(%rsi, %rdx), %r8
25753 movq %r11, 0*8(%rdi)
25754 - movq %r10, 1*8(%rdi)
25755 + movq %rcx, 1*8(%rdi)
25756 movq %r9, -2*8(%rdi, %rdx)
25757 movq %r8, -1*8(%rdi, %rdx)
25758 jmp 13f
25759 @@ -167,9 +167,9 @@ ENTRY(memmove)
25760 * Move data from 8 bytes to 15 bytes.
25761 */
25762 movq 0*8(%rsi), %r11
25763 - movq -1*8(%rsi, %rdx), %r10
25764 + movq -1*8(%rsi, %rdx), %r9
25765 movq %r11, 0*8(%rdi)
25766 - movq %r10, -1*8(%rdi, %rdx)
25767 + movq %r9, -1*8(%rdi, %rdx)
25768 jmp 13f
25769 10:
25770 cmpq $4, %rdx
25771 @@ -178,9 +178,9 @@ ENTRY(memmove)
25772 * Move data from 4 bytes to 7 bytes.
25773 */
25774 movl (%rsi), %r11d
25775 - movl -4(%rsi, %rdx), %r10d
25776 + movl -4(%rsi, %rdx), %r9d
25777 movl %r11d, (%rdi)
25778 - movl %r10d, -4(%rdi, %rdx)
25779 + movl %r9d, -4(%rdi, %rdx)
25780 jmp 13f
25781 11:
25782 cmp $2, %rdx
25783 @@ -189,9 +189,9 @@ ENTRY(memmove)
25784 * Move data from 2 bytes to 3 bytes.
25785 */
25786 movw (%rsi), %r11w
25787 - movw -2(%rsi, %rdx), %r10w
25788 + movw -2(%rsi, %rdx), %r9w
25789 movw %r11w, (%rdi)
25790 - movw %r10w, -2(%rdi, %rdx)
25791 + movw %r9w, -2(%rdi, %rdx)
25792 jmp 13f
25793 12:
25794 cmp $1, %rdx
25795 @@ -202,6 +202,7 @@ ENTRY(memmove)
25796 movb (%rsi), %r11b
25797 movb %r11b, (%rdi)
25798 13:
25799 + pax_force_retaddr
25800 retq
25801 CFI_ENDPROC
25802
25803 @@ -210,6 +211,7 @@ ENTRY(memmove)
25804 /* Forward moving data. */
25805 movq %rdx, %rcx
25806 rep movsb
25807 + pax_force_retaddr
25808 retq
25809 .Lmemmove_end_forward_efs:
25810 .previous
25811 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25812 index 2dcb380..963660a 100644
25813 --- a/arch/x86/lib/memset_64.S
25814 +++ b/arch/x86/lib/memset_64.S
25815 @@ -30,6 +30,7 @@
25816 movl %edx,%ecx
25817 rep stosb
25818 movq %r9,%rax
25819 + pax_force_retaddr
25820 ret
25821 .Lmemset_e:
25822 .previous
25823 @@ -52,6 +53,7 @@
25824 movq %rdx,%rcx
25825 rep stosb
25826 movq %r9,%rax
25827 + pax_force_retaddr
25828 ret
25829 .Lmemset_e_e:
25830 .previous
25831 @@ -59,7 +61,7 @@
25832 ENTRY(memset)
25833 ENTRY(__memset)
25834 CFI_STARTPROC
25835 - movq %rdi,%r10
25836 + movq %rdi,%r11
25837
25838 /* expand byte value */
25839 movzbl %sil,%ecx
25840 @@ -117,7 +119,8 @@ ENTRY(__memset)
25841 jnz .Lloop_1
25842
25843 .Lende:
25844 - movq %r10,%rax
25845 + movq %r11,%rax
25846 + pax_force_retaddr
25847 ret
25848
25849 CFI_RESTORE_STATE
25850 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25851 index c9f2d9b..e7fd2c0 100644
25852 --- a/arch/x86/lib/mmx_32.c
25853 +++ b/arch/x86/lib/mmx_32.c
25854 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25855 {
25856 void *p;
25857 int i;
25858 + unsigned long cr0;
25859
25860 if (unlikely(in_interrupt()))
25861 return __memcpy(to, from, len);
25862 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25863 kernel_fpu_begin();
25864
25865 __asm__ __volatile__ (
25866 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25867 - " prefetch 64(%0)\n"
25868 - " prefetch 128(%0)\n"
25869 - " prefetch 192(%0)\n"
25870 - " prefetch 256(%0)\n"
25871 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25872 + " prefetch 64(%1)\n"
25873 + " prefetch 128(%1)\n"
25874 + " prefetch 192(%1)\n"
25875 + " prefetch 256(%1)\n"
25876 "2: \n"
25877 ".section .fixup, \"ax\"\n"
25878 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25879 + "3: \n"
25880 +
25881 +#ifdef CONFIG_PAX_KERNEXEC
25882 + " movl %%cr0, %0\n"
25883 + " movl %0, %%eax\n"
25884 + " andl $0xFFFEFFFF, %%eax\n"
25885 + " movl %%eax, %%cr0\n"
25886 +#endif
25887 +
25888 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25889 +
25890 +#ifdef CONFIG_PAX_KERNEXEC
25891 + " movl %0, %%cr0\n"
25892 +#endif
25893 +
25894 " jmp 2b\n"
25895 ".previous\n"
25896 _ASM_EXTABLE(1b, 3b)
25897 - : : "r" (from));
25898 + : "=&r" (cr0) : "r" (from) : "ax");
25899
25900 for ( ; i > 5; i--) {
25901 __asm__ __volatile__ (
25902 - "1: prefetch 320(%0)\n"
25903 - "2: movq (%0), %%mm0\n"
25904 - " movq 8(%0), %%mm1\n"
25905 - " movq 16(%0), %%mm2\n"
25906 - " movq 24(%0), %%mm3\n"
25907 - " movq %%mm0, (%1)\n"
25908 - " movq %%mm1, 8(%1)\n"
25909 - " movq %%mm2, 16(%1)\n"
25910 - " movq %%mm3, 24(%1)\n"
25911 - " movq 32(%0), %%mm0\n"
25912 - " movq 40(%0), %%mm1\n"
25913 - " movq 48(%0), %%mm2\n"
25914 - " movq 56(%0), %%mm3\n"
25915 - " movq %%mm0, 32(%1)\n"
25916 - " movq %%mm1, 40(%1)\n"
25917 - " movq %%mm2, 48(%1)\n"
25918 - " movq %%mm3, 56(%1)\n"
25919 + "1: prefetch 320(%1)\n"
25920 + "2: movq (%1), %%mm0\n"
25921 + " movq 8(%1), %%mm1\n"
25922 + " movq 16(%1), %%mm2\n"
25923 + " movq 24(%1), %%mm3\n"
25924 + " movq %%mm0, (%2)\n"
25925 + " movq %%mm1, 8(%2)\n"
25926 + " movq %%mm2, 16(%2)\n"
25927 + " movq %%mm3, 24(%2)\n"
25928 + " movq 32(%1), %%mm0\n"
25929 + " movq 40(%1), %%mm1\n"
25930 + " movq 48(%1), %%mm2\n"
25931 + " movq 56(%1), %%mm3\n"
25932 + " movq %%mm0, 32(%2)\n"
25933 + " movq %%mm1, 40(%2)\n"
25934 + " movq %%mm2, 48(%2)\n"
25935 + " movq %%mm3, 56(%2)\n"
25936 ".section .fixup, \"ax\"\n"
25937 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25938 + "3:\n"
25939 +
25940 +#ifdef CONFIG_PAX_KERNEXEC
25941 + " movl %%cr0, %0\n"
25942 + " movl %0, %%eax\n"
25943 + " andl $0xFFFEFFFF, %%eax\n"
25944 + " movl %%eax, %%cr0\n"
25945 +#endif
25946 +
25947 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25948 +
25949 +#ifdef CONFIG_PAX_KERNEXEC
25950 + " movl %0, %%cr0\n"
25951 +#endif
25952 +
25953 " jmp 2b\n"
25954 ".previous\n"
25955 _ASM_EXTABLE(1b, 3b)
25956 - : : "r" (from), "r" (to) : "memory");
25957 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25958
25959 from += 64;
25960 to += 64;
25961 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25962 static void fast_copy_page(void *to, void *from)
25963 {
25964 int i;
25965 + unsigned long cr0;
25966
25967 kernel_fpu_begin();
25968
25969 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25970 * but that is for later. -AV
25971 */
25972 __asm__ __volatile__(
25973 - "1: prefetch (%0)\n"
25974 - " prefetch 64(%0)\n"
25975 - " prefetch 128(%0)\n"
25976 - " prefetch 192(%0)\n"
25977 - " prefetch 256(%0)\n"
25978 + "1: prefetch (%1)\n"
25979 + " prefetch 64(%1)\n"
25980 + " prefetch 128(%1)\n"
25981 + " prefetch 192(%1)\n"
25982 + " prefetch 256(%1)\n"
25983 "2: \n"
25984 ".section .fixup, \"ax\"\n"
25985 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25986 + "3: \n"
25987 +
25988 +#ifdef CONFIG_PAX_KERNEXEC
25989 + " movl %%cr0, %0\n"
25990 + " movl %0, %%eax\n"
25991 + " andl $0xFFFEFFFF, %%eax\n"
25992 + " movl %%eax, %%cr0\n"
25993 +#endif
25994 +
25995 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25996 +
25997 +#ifdef CONFIG_PAX_KERNEXEC
25998 + " movl %0, %%cr0\n"
25999 +#endif
26000 +
26001 " jmp 2b\n"
26002 ".previous\n"
26003 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26004 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26005
26006 for (i = 0; i < (4096-320)/64; i++) {
26007 __asm__ __volatile__ (
26008 - "1: prefetch 320(%0)\n"
26009 - "2: movq (%0), %%mm0\n"
26010 - " movntq %%mm0, (%1)\n"
26011 - " movq 8(%0), %%mm1\n"
26012 - " movntq %%mm1, 8(%1)\n"
26013 - " movq 16(%0), %%mm2\n"
26014 - " movntq %%mm2, 16(%1)\n"
26015 - " movq 24(%0), %%mm3\n"
26016 - " movntq %%mm3, 24(%1)\n"
26017 - " movq 32(%0), %%mm4\n"
26018 - " movntq %%mm4, 32(%1)\n"
26019 - " movq 40(%0), %%mm5\n"
26020 - " movntq %%mm5, 40(%1)\n"
26021 - " movq 48(%0), %%mm6\n"
26022 - " movntq %%mm6, 48(%1)\n"
26023 - " movq 56(%0), %%mm7\n"
26024 - " movntq %%mm7, 56(%1)\n"
26025 + "1: prefetch 320(%1)\n"
26026 + "2: movq (%1), %%mm0\n"
26027 + " movntq %%mm0, (%2)\n"
26028 + " movq 8(%1), %%mm1\n"
26029 + " movntq %%mm1, 8(%2)\n"
26030 + " movq 16(%1), %%mm2\n"
26031 + " movntq %%mm2, 16(%2)\n"
26032 + " movq 24(%1), %%mm3\n"
26033 + " movntq %%mm3, 24(%2)\n"
26034 + " movq 32(%1), %%mm4\n"
26035 + " movntq %%mm4, 32(%2)\n"
26036 + " movq 40(%1), %%mm5\n"
26037 + " movntq %%mm5, 40(%2)\n"
26038 + " movq 48(%1), %%mm6\n"
26039 + " movntq %%mm6, 48(%2)\n"
26040 + " movq 56(%1), %%mm7\n"
26041 + " movntq %%mm7, 56(%2)\n"
26042 ".section .fixup, \"ax\"\n"
26043 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26044 + "3:\n"
26045 +
26046 +#ifdef CONFIG_PAX_KERNEXEC
26047 + " movl %%cr0, %0\n"
26048 + " movl %0, %%eax\n"
26049 + " andl $0xFFFEFFFF, %%eax\n"
26050 + " movl %%eax, %%cr0\n"
26051 +#endif
26052 +
26053 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26054 +
26055 +#ifdef CONFIG_PAX_KERNEXEC
26056 + " movl %0, %%cr0\n"
26057 +#endif
26058 +
26059 " jmp 2b\n"
26060 ".previous\n"
26061 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26062 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26063
26064 from += 64;
26065 to += 64;
26066 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26067 static void fast_copy_page(void *to, void *from)
26068 {
26069 int i;
26070 + unsigned long cr0;
26071
26072 kernel_fpu_begin();
26073
26074 __asm__ __volatile__ (
26075 - "1: prefetch (%0)\n"
26076 - " prefetch 64(%0)\n"
26077 - " prefetch 128(%0)\n"
26078 - " prefetch 192(%0)\n"
26079 - " prefetch 256(%0)\n"
26080 + "1: prefetch (%1)\n"
26081 + " prefetch 64(%1)\n"
26082 + " prefetch 128(%1)\n"
26083 + " prefetch 192(%1)\n"
26084 + " prefetch 256(%1)\n"
26085 "2: \n"
26086 ".section .fixup, \"ax\"\n"
26087 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26088 + "3: \n"
26089 +
26090 +#ifdef CONFIG_PAX_KERNEXEC
26091 + " movl %%cr0, %0\n"
26092 + " movl %0, %%eax\n"
26093 + " andl $0xFFFEFFFF, %%eax\n"
26094 + " movl %%eax, %%cr0\n"
26095 +#endif
26096 +
26097 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26098 +
26099 +#ifdef CONFIG_PAX_KERNEXEC
26100 + " movl %0, %%cr0\n"
26101 +#endif
26102 +
26103 " jmp 2b\n"
26104 ".previous\n"
26105 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26106 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26107
26108 for (i = 0; i < 4096/64; i++) {
26109 __asm__ __volatile__ (
26110 - "1: prefetch 320(%0)\n"
26111 - "2: movq (%0), %%mm0\n"
26112 - " movq 8(%0), %%mm1\n"
26113 - " movq 16(%0), %%mm2\n"
26114 - " movq 24(%0), %%mm3\n"
26115 - " movq %%mm0, (%1)\n"
26116 - " movq %%mm1, 8(%1)\n"
26117 - " movq %%mm2, 16(%1)\n"
26118 - " movq %%mm3, 24(%1)\n"
26119 - " movq 32(%0), %%mm0\n"
26120 - " movq 40(%0), %%mm1\n"
26121 - " movq 48(%0), %%mm2\n"
26122 - " movq 56(%0), %%mm3\n"
26123 - " movq %%mm0, 32(%1)\n"
26124 - " movq %%mm1, 40(%1)\n"
26125 - " movq %%mm2, 48(%1)\n"
26126 - " movq %%mm3, 56(%1)\n"
26127 + "1: prefetch 320(%1)\n"
26128 + "2: movq (%1), %%mm0\n"
26129 + " movq 8(%1), %%mm1\n"
26130 + " movq 16(%1), %%mm2\n"
26131 + " movq 24(%1), %%mm3\n"
26132 + " movq %%mm0, (%2)\n"
26133 + " movq %%mm1, 8(%2)\n"
26134 + " movq %%mm2, 16(%2)\n"
26135 + " movq %%mm3, 24(%2)\n"
26136 + " movq 32(%1), %%mm0\n"
26137 + " movq 40(%1), %%mm1\n"
26138 + " movq 48(%1), %%mm2\n"
26139 + " movq 56(%1), %%mm3\n"
26140 + " movq %%mm0, 32(%2)\n"
26141 + " movq %%mm1, 40(%2)\n"
26142 + " movq %%mm2, 48(%2)\n"
26143 + " movq %%mm3, 56(%2)\n"
26144 ".section .fixup, \"ax\"\n"
26145 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26146 + "3:\n"
26147 +
26148 +#ifdef CONFIG_PAX_KERNEXEC
26149 + " movl %%cr0, %0\n"
26150 + " movl %0, %%eax\n"
26151 + " andl $0xFFFEFFFF, %%eax\n"
26152 + " movl %%eax, %%cr0\n"
26153 +#endif
26154 +
26155 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26156 +
26157 +#ifdef CONFIG_PAX_KERNEXEC
26158 + " movl %0, %%cr0\n"
26159 +#endif
26160 +
26161 " jmp 2b\n"
26162 ".previous\n"
26163 _ASM_EXTABLE(1b, 3b)
26164 - : : "r" (from), "r" (to) : "memory");
26165 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26166
26167 from += 64;
26168 to += 64;
26169 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26170 index f6d13ee..aca5f0b 100644
26171 --- a/arch/x86/lib/msr-reg.S
26172 +++ b/arch/x86/lib/msr-reg.S
26173 @@ -3,6 +3,7 @@
26174 #include <asm/dwarf2.h>
26175 #include <asm/asm.h>
26176 #include <asm/msr.h>
26177 +#include <asm/alternative-asm.h>
26178
26179 #ifdef CONFIG_X86_64
26180 /*
26181 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26182 CFI_STARTPROC
26183 pushq_cfi %rbx
26184 pushq_cfi %rbp
26185 - movq %rdi, %r10 /* Save pointer */
26186 + movq %rdi, %r9 /* Save pointer */
26187 xorl %r11d, %r11d /* Return value */
26188 movl (%rdi), %eax
26189 movl 4(%rdi), %ecx
26190 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26191 movl 28(%rdi), %edi
26192 CFI_REMEMBER_STATE
26193 1: \op
26194 -2: movl %eax, (%r10)
26195 +2: movl %eax, (%r9)
26196 movl %r11d, %eax /* Return value */
26197 - movl %ecx, 4(%r10)
26198 - movl %edx, 8(%r10)
26199 - movl %ebx, 12(%r10)
26200 - movl %ebp, 20(%r10)
26201 - movl %esi, 24(%r10)
26202 - movl %edi, 28(%r10)
26203 + movl %ecx, 4(%r9)
26204 + movl %edx, 8(%r9)
26205 + movl %ebx, 12(%r9)
26206 + movl %ebp, 20(%r9)
26207 + movl %esi, 24(%r9)
26208 + movl %edi, 28(%r9)
26209 popq_cfi %rbp
26210 popq_cfi %rbx
26211 + pax_force_retaddr
26212 ret
26213 3:
26214 CFI_RESTORE_STATE
26215 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26216 index fc6ba17..d4d989d 100644
26217 --- a/arch/x86/lib/putuser.S
26218 +++ b/arch/x86/lib/putuser.S
26219 @@ -16,7 +16,9 @@
26220 #include <asm/errno.h>
26221 #include <asm/asm.h>
26222 #include <asm/smap.h>
26223 -
26224 +#include <asm/segment.h>
26225 +#include <asm/pgtable.h>
26226 +#include <asm/alternative-asm.h>
26227
26228 /*
26229 * __put_user_X
26230 @@ -30,57 +32,125 @@
26231 * as they get called from within inline assembly.
26232 */
26233
26234 -#define ENTER CFI_STARTPROC ; \
26235 - GET_THREAD_INFO(%_ASM_BX)
26236 -#define EXIT ASM_CLAC ; \
26237 - ret ; \
26238 +#define ENTER CFI_STARTPROC
26239 +#define EXIT ASM_CLAC ; \
26240 + pax_force_retaddr ; \
26241 + ret ; \
26242 CFI_ENDPROC
26243
26244 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26245 +#define _DEST %_ASM_CX,%_ASM_BX
26246 +#else
26247 +#define _DEST %_ASM_CX
26248 +#endif
26249 +
26250 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26251 +#define __copyuser_seg gs;
26252 +#else
26253 +#define __copyuser_seg
26254 +#endif
26255 +
26256 .text
26257 ENTRY(__put_user_1)
26258 ENTER
26259 +
26260 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26261 + GET_THREAD_INFO(%_ASM_BX)
26262 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26263 jae bad_put_user
26264 ASM_STAC
26265 -1: movb %al,(%_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 +1: __copyuser_seg movb %al,(_DEST)
26278 xor %eax,%eax
26279 EXIT
26280 ENDPROC(__put_user_1)
26281
26282 ENTRY(__put_user_2)
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 $1,%_ASM_BX
26289 cmp %_ASM_BX,%_ASM_CX
26290 jae bad_put_user
26291 ASM_STAC
26292 -2: movw %ax,(%_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 +2: __copyuser_seg movw %ax,(_DEST)
26305 xor %eax,%eax
26306 EXIT
26307 ENDPROC(__put_user_2)
26308
26309 ENTRY(__put_user_4)
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 $3,%_ASM_BX
26316 cmp %_ASM_BX,%_ASM_CX
26317 jae bad_put_user
26318 ASM_STAC
26319 -3: movl %eax,(%_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 +3: __copyuser_seg movl %eax,(_DEST)
26332 xor %eax,%eax
26333 EXIT
26334 ENDPROC(__put_user_4)
26335
26336 ENTRY(__put_user_8)
26337 ENTER
26338 +
26339 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26340 + GET_THREAD_INFO(%_ASM_BX)
26341 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26342 sub $7,%_ASM_BX
26343 cmp %_ASM_BX,%_ASM_CX
26344 jae bad_put_user
26345 ASM_STAC
26346 -4: mov %_ASM_AX,(%_ASM_CX)
26347 +
26348 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26349 + mov pax_user_shadow_base,%_ASM_BX
26350 + cmp %_ASM_BX,%_ASM_CX
26351 + jb 1234f
26352 + xor %ebx,%ebx
26353 +1234:
26354 +#endif
26355 +
26356 +#endif
26357 +
26358 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26359 #ifdef CONFIG_X86_32
26360 -5: movl %edx,4(%_ASM_CX)
26361 +5: __copyuser_seg movl %edx,4(_DEST)
26362 #endif
26363 xor %eax,%eax
26364 EXIT
26365 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26366 index 1cad221..de671ee 100644
26367 --- a/arch/x86/lib/rwlock.S
26368 +++ b/arch/x86/lib/rwlock.S
26369 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26370 FRAME
26371 0: LOCK_PREFIX
26372 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26373 +
26374 +#ifdef CONFIG_PAX_REFCOUNT
26375 + jno 1234f
26376 + LOCK_PREFIX
26377 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26378 + int $4
26379 +1234:
26380 + _ASM_EXTABLE(1234b, 1234b)
26381 +#endif
26382 +
26383 1: rep; nop
26384 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26385 jne 1b
26386 LOCK_PREFIX
26387 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26388 +
26389 +#ifdef CONFIG_PAX_REFCOUNT
26390 + jno 1234f
26391 + LOCK_PREFIX
26392 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26393 + int $4
26394 +1234:
26395 + _ASM_EXTABLE(1234b, 1234b)
26396 +#endif
26397 +
26398 jnz 0b
26399 ENDFRAME
26400 + pax_force_retaddr
26401 ret
26402 CFI_ENDPROC
26403 END(__write_lock_failed)
26404 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26405 FRAME
26406 0: LOCK_PREFIX
26407 READ_LOCK_SIZE(inc) (%__lock_ptr)
26408 +
26409 +#ifdef CONFIG_PAX_REFCOUNT
26410 + jno 1234f
26411 + LOCK_PREFIX
26412 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26413 + int $4
26414 +1234:
26415 + _ASM_EXTABLE(1234b, 1234b)
26416 +#endif
26417 +
26418 1: rep; nop
26419 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26420 js 1b
26421 LOCK_PREFIX
26422 READ_LOCK_SIZE(dec) (%__lock_ptr)
26423 +
26424 +#ifdef CONFIG_PAX_REFCOUNT
26425 + jno 1234f
26426 + LOCK_PREFIX
26427 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26428 + int $4
26429 +1234:
26430 + _ASM_EXTABLE(1234b, 1234b)
26431 +#endif
26432 +
26433 js 0b
26434 ENDFRAME
26435 + pax_force_retaddr
26436 ret
26437 CFI_ENDPROC
26438 END(__read_lock_failed)
26439 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26440 index 5dff5f0..cadebf4 100644
26441 --- a/arch/x86/lib/rwsem.S
26442 +++ b/arch/x86/lib/rwsem.S
26443 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26444 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26445 CFI_RESTORE __ASM_REG(dx)
26446 restore_common_regs
26447 + pax_force_retaddr
26448 ret
26449 CFI_ENDPROC
26450 ENDPROC(call_rwsem_down_read_failed)
26451 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26452 movq %rax,%rdi
26453 call rwsem_down_write_failed
26454 restore_common_regs
26455 + pax_force_retaddr
26456 ret
26457 CFI_ENDPROC
26458 ENDPROC(call_rwsem_down_write_failed)
26459 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26460 movq %rax,%rdi
26461 call rwsem_wake
26462 restore_common_regs
26463 -1: ret
26464 +1: pax_force_retaddr
26465 + ret
26466 CFI_ENDPROC
26467 ENDPROC(call_rwsem_wake)
26468
26469 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26470 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26471 CFI_RESTORE __ASM_REG(dx)
26472 restore_common_regs
26473 + pax_force_retaddr
26474 ret
26475 CFI_ENDPROC
26476 ENDPROC(call_rwsem_downgrade_wake)
26477 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26478 index a63efd6..ccecad8 100644
26479 --- a/arch/x86/lib/thunk_64.S
26480 +++ b/arch/x86/lib/thunk_64.S
26481 @@ -8,6 +8,7 @@
26482 #include <linux/linkage.h>
26483 #include <asm/dwarf2.h>
26484 #include <asm/calling.h>
26485 +#include <asm/alternative-asm.h>
26486
26487 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26488 .macro THUNK name, func, put_ret_addr_in_rdi=0
26489 @@ -41,5 +42,6 @@
26490 SAVE_ARGS
26491 restore:
26492 RESTORE_ARGS
26493 + pax_force_retaddr
26494 ret
26495 CFI_ENDPROC
26496 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26497 index f0312d7..9c39d63 100644
26498 --- a/arch/x86/lib/usercopy_32.c
26499 +++ b/arch/x86/lib/usercopy_32.c
26500 @@ -42,11 +42,13 @@ do { \
26501 int __d0; \
26502 might_fault(); \
26503 __asm__ __volatile__( \
26504 + __COPYUSER_SET_ES \
26505 ASM_STAC "\n" \
26506 "0: rep; stosl\n" \
26507 " movl %2,%0\n" \
26508 "1: rep; stosb\n" \
26509 "2: " ASM_CLAC "\n" \
26510 + __COPYUSER_RESTORE_ES \
26511 ".section .fixup,\"ax\"\n" \
26512 "3: lea 0(%2,%0,4),%0\n" \
26513 " jmp 2b\n" \
26514 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26515
26516 #ifdef CONFIG_X86_INTEL_USERCOPY
26517 static unsigned long
26518 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26519 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26520 {
26521 int d0, d1;
26522 __asm__ __volatile__(
26523 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26524 " .align 2,0x90\n"
26525 "3: movl 0(%4), %%eax\n"
26526 "4: movl 4(%4), %%edx\n"
26527 - "5: movl %%eax, 0(%3)\n"
26528 - "6: movl %%edx, 4(%3)\n"
26529 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26530 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26531 "7: movl 8(%4), %%eax\n"
26532 "8: movl 12(%4),%%edx\n"
26533 - "9: movl %%eax, 8(%3)\n"
26534 - "10: movl %%edx, 12(%3)\n"
26535 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26536 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26537 "11: movl 16(%4), %%eax\n"
26538 "12: movl 20(%4), %%edx\n"
26539 - "13: movl %%eax, 16(%3)\n"
26540 - "14: movl %%edx, 20(%3)\n"
26541 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26542 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26543 "15: movl 24(%4), %%eax\n"
26544 "16: movl 28(%4), %%edx\n"
26545 - "17: movl %%eax, 24(%3)\n"
26546 - "18: movl %%edx, 28(%3)\n"
26547 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26548 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26549 "19: movl 32(%4), %%eax\n"
26550 "20: movl 36(%4), %%edx\n"
26551 - "21: movl %%eax, 32(%3)\n"
26552 - "22: movl %%edx, 36(%3)\n"
26553 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26554 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26555 "23: movl 40(%4), %%eax\n"
26556 "24: movl 44(%4), %%edx\n"
26557 - "25: movl %%eax, 40(%3)\n"
26558 - "26: movl %%edx, 44(%3)\n"
26559 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26560 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26561 "27: movl 48(%4), %%eax\n"
26562 "28: movl 52(%4), %%edx\n"
26563 - "29: movl %%eax, 48(%3)\n"
26564 - "30: movl %%edx, 52(%3)\n"
26565 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26566 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26567 "31: movl 56(%4), %%eax\n"
26568 "32: movl 60(%4), %%edx\n"
26569 - "33: movl %%eax, 56(%3)\n"
26570 - "34: movl %%edx, 60(%3)\n"
26571 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26572 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26573 " addl $-64, %0\n"
26574 " addl $64, %4\n"
26575 " addl $64, %3\n"
26576 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26577 " shrl $2, %0\n"
26578 " andl $3, %%eax\n"
26579 " cld\n"
26580 + __COPYUSER_SET_ES
26581 "99: rep; movsl\n"
26582 "36: movl %%eax, %0\n"
26583 "37: rep; movsb\n"
26584 "100:\n"
26585 + __COPYUSER_RESTORE_ES
26586 ".section .fixup,\"ax\"\n"
26587 "101: lea 0(%%eax,%0,4),%0\n"
26588 " jmp 100b\n"
26589 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26590 }
26591
26592 static unsigned long
26593 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26594 +{
26595 + int d0, d1;
26596 + __asm__ __volatile__(
26597 + " .align 2,0x90\n"
26598 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26599 + " cmpl $67, %0\n"
26600 + " jbe 3f\n"
26601 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26602 + " .align 2,0x90\n"
26603 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26604 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26605 + "5: movl %%eax, 0(%3)\n"
26606 + "6: movl %%edx, 4(%3)\n"
26607 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26608 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26609 + "9: movl %%eax, 8(%3)\n"
26610 + "10: movl %%edx, 12(%3)\n"
26611 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26612 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26613 + "13: movl %%eax, 16(%3)\n"
26614 + "14: movl %%edx, 20(%3)\n"
26615 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26616 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26617 + "17: movl %%eax, 24(%3)\n"
26618 + "18: movl %%edx, 28(%3)\n"
26619 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26620 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26621 + "21: movl %%eax, 32(%3)\n"
26622 + "22: movl %%edx, 36(%3)\n"
26623 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26624 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26625 + "25: movl %%eax, 40(%3)\n"
26626 + "26: movl %%edx, 44(%3)\n"
26627 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26628 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26629 + "29: movl %%eax, 48(%3)\n"
26630 + "30: movl %%edx, 52(%3)\n"
26631 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26632 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26633 + "33: movl %%eax, 56(%3)\n"
26634 + "34: movl %%edx, 60(%3)\n"
26635 + " addl $-64, %0\n"
26636 + " addl $64, %4\n"
26637 + " addl $64, %3\n"
26638 + " cmpl $63, %0\n"
26639 + " ja 1b\n"
26640 + "35: movl %0, %%eax\n"
26641 + " shrl $2, %0\n"
26642 + " andl $3, %%eax\n"
26643 + " cld\n"
26644 + "99: rep; "__copyuser_seg" movsl\n"
26645 + "36: movl %%eax, %0\n"
26646 + "37: rep; "__copyuser_seg" movsb\n"
26647 + "100:\n"
26648 + ".section .fixup,\"ax\"\n"
26649 + "101: lea 0(%%eax,%0,4),%0\n"
26650 + " jmp 100b\n"
26651 + ".previous\n"
26652 + _ASM_EXTABLE(1b,100b)
26653 + _ASM_EXTABLE(2b,100b)
26654 + _ASM_EXTABLE(3b,100b)
26655 + _ASM_EXTABLE(4b,100b)
26656 + _ASM_EXTABLE(5b,100b)
26657 + _ASM_EXTABLE(6b,100b)
26658 + _ASM_EXTABLE(7b,100b)
26659 + _ASM_EXTABLE(8b,100b)
26660 + _ASM_EXTABLE(9b,100b)
26661 + _ASM_EXTABLE(10b,100b)
26662 + _ASM_EXTABLE(11b,100b)
26663 + _ASM_EXTABLE(12b,100b)
26664 + _ASM_EXTABLE(13b,100b)
26665 + _ASM_EXTABLE(14b,100b)
26666 + _ASM_EXTABLE(15b,100b)
26667 + _ASM_EXTABLE(16b,100b)
26668 + _ASM_EXTABLE(17b,100b)
26669 + _ASM_EXTABLE(18b,100b)
26670 + _ASM_EXTABLE(19b,100b)
26671 + _ASM_EXTABLE(20b,100b)
26672 + _ASM_EXTABLE(21b,100b)
26673 + _ASM_EXTABLE(22b,100b)
26674 + _ASM_EXTABLE(23b,100b)
26675 + _ASM_EXTABLE(24b,100b)
26676 + _ASM_EXTABLE(25b,100b)
26677 + _ASM_EXTABLE(26b,100b)
26678 + _ASM_EXTABLE(27b,100b)
26679 + _ASM_EXTABLE(28b,100b)
26680 + _ASM_EXTABLE(29b,100b)
26681 + _ASM_EXTABLE(30b,100b)
26682 + _ASM_EXTABLE(31b,100b)
26683 + _ASM_EXTABLE(32b,100b)
26684 + _ASM_EXTABLE(33b,100b)
26685 + _ASM_EXTABLE(34b,100b)
26686 + _ASM_EXTABLE(35b,100b)
26687 + _ASM_EXTABLE(36b,100b)
26688 + _ASM_EXTABLE(37b,100b)
26689 + _ASM_EXTABLE(99b,101b)
26690 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26691 + : "1"(to), "2"(from), "0"(size)
26692 + : "eax", "edx", "memory");
26693 + return size;
26694 +}
26695 +
26696 +static unsigned long __size_overflow(3)
26697 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26698 {
26699 int d0, d1;
26700 __asm__ __volatile__(
26701 " .align 2,0x90\n"
26702 - "0: movl 32(%4), %%eax\n"
26703 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26704 " cmpl $67, %0\n"
26705 " jbe 2f\n"
26706 - "1: movl 64(%4), %%eax\n"
26707 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26708 " .align 2,0x90\n"
26709 - "2: movl 0(%4), %%eax\n"
26710 - "21: movl 4(%4), %%edx\n"
26711 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26712 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26713 " movl %%eax, 0(%3)\n"
26714 " movl %%edx, 4(%3)\n"
26715 - "3: movl 8(%4), %%eax\n"
26716 - "31: movl 12(%4),%%edx\n"
26717 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26718 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26719 " movl %%eax, 8(%3)\n"
26720 " movl %%edx, 12(%3)\n"
26721 - "4: movl 16(%4), %%eax\n"
26722 - "41: movl 20(%4), %%edx\n"
26723 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26724 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26725 " movl %%eax, 16(%3)\n"
26726 " movl %%edx, 20(%3)\n"
26727 - "10: movl 24(%4), %%eax\n"
26728 - "51: movl 28(%4), %%edx\n"
26729 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26730 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26731 " movl %%eax, 24(%3)\n"
26732 " movl %%edx, 28(%3)\n"
26733 - "11: movl 32(%4), %%eax\n"
26734 - "61: movl 36(%4), %%edx\n"
26735 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26736 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26737 " movl %%eax, 32(%3)\n"
26738 " movl %%edx, 36(%3)\n"
26739 - "12: movl 40(%4), %%eax\n"
26740 - "71: movl 44(%4), %%edx\n"
26741 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26742 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26743 " movl %%eax, 40(%3)\n"
26744 " movl %%edx, 44(%3)\n"
26745 - "13: movl 48(%4), %%eax\n"
26746 - "81: movl 52(%4), %%edx\n"
26747 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26748 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26749 " movl %%eax, 48(%3)\n"
26750 " movl %%edx, 52(%3)\n"
26751 - "14: movl 56(%4), %%eax\n"
26752 - "91: movl 60(%4), %%edx\n"
26753 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26754 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26755 " movl %%eax, 56(%3)\n"
26756 " movl %%edx, 60(%3)\n"
26757 " addl $-64, %0\n"
26758 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26759 " shrl $2, %0\n"
26760 " andl $3, %%eax\n"
26761 " cld\n"
26762 - "6: rep; movsl\n"
26763 + "6: rep; "__copyuser_seg" movsl\n"
26764 " movl %%eax,%0\n"
26765 - "7: rep; movsb\n"
26766 + "7: rep; "__copyuser_seg" movsb\n"
26767 "8:\n"
26768 ".section .fixup,\"ax\"\n"
26769 "9: lea 0(%%eax,%0,4),%0\n"
26770 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26771 * hyoshiok@miraclelinux.com
26772 */
26773
26774 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26775 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26776 const void __user *from, unsigned long size)
26777 {
26778 int d0, d1;
26779
26780 __asm__ __volatile__(
26781 " .align 2,0x90\n"
26782 - "0: movl 32(%4), %%eax\n"
26783 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26784 " cmpl $67, %0\n"
26785 " jbe 2f\n"
26786 - "1: movl 64(%4), %%eax\n"
26787 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26788 " .align 2,0x90\n"
26789 - "2: movl 0(%4), %%eax\n"
26790 - "21: movl 4(%4), %%edx\n"
26791 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26792 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26793 " movnti %%eax, 0(%3)\n"
26794 " movnti %%edx, 4(%3)\n"
26795 - "3: movl 8(%4), %%eax\n"
26796 - "31: movl 12(%4),%%edx\n"
26797 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26798 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26799 " movnti %%eax, 8(%3)\n"
26800 " movnti %%edx, 12(%3)\n"
26801 - "4: movl 16(%4), %%eax\n"
26802 - "41: movl 20(%4), %%edx\n"
26803 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26804 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26805 " movnti %%eax, 16(%3)\n"
26806 " movnti %%edx, 20(%3)\n"
26807 - "10: movl 24(%4), %%eax\n"
26808 - "51: movl 28(%4), %%edx\n"
26809 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26810 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26811 " movnti %%eax, 24(%3)\n"
26812 " movnti %%edx, 28(%3)\n"
26813 - "11: movl 32(%4), %%eax\n"
26814 - "61: movl 36(%4), %%edx\n"
26815 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26816 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26817 " movnti %%eax, 32(%3)\n"
26818 " movnti %%edx, 36(%3)\n"
26819 - "12: movl 40(%4), %%eax\n"
26820 - "71: movl 44(%4), %%edx\n"
26821 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26822 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26823 " movnti %%eax, 40(%3)\n"
26824 " movnti %%edx, 44(%3)\n"
26825 - "13: movl 48(%4), %%eax\n"
26826 - "81: movl 52(%4), %%edx\n"
26827 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26828 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26829 " movnti %%eax, 48(%3)\n"
26830 " movnti %%edx, 52(%3)\n"
26831 - "14: movl 56(%4), %%eax\n"
26832 - "91: movl 60(%4), %%edx\n"
26833 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26834 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26835 " movnti %%eax, 56(%3)\n"
26836 " movnti %%edx, 60(%3)\n"
26837 " addl $-64, %0\n"
26838 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26839 " shrl $2, %0\n"
26840 " andl $3, %%eax\n"
26841 " cld\n"
26842 - "6: rep; movsl\n"
26843 + "6: rep; "__copyuser_seg" movsl\n"
26844 " movl %%eax,%0\n"
26845 - "7: rep; movsb\n"
26846 + "7: rep; "__copyuser_seg" movsb\n"
26847 "8:\n"
26848 ".section .fixup,\"ax\"\n"
26849 "9: lea 0(%%eax,%0,4),%0\n"
26850 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26851 return size;
26852 }
26853
26854 -static unsigned long __copy_user_intel_nocache(void *to,
26855 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26856 const void __user *from, unsigned long size)
26857 {
26858 int d0, d1;
26859
26860 __asm__ __volatile__(
26861 " .align 2,0x90\n"
26862 - "0: movl 32(%4), %%eax\n"
26863 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26864 " cmpl $67, %0\n"
26865 " jbe 2f\n"
26866 - "1: movl 64(%4), %%eax\n"
26867 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26868 " .align 2,0x90\n"
26869 - "2: movl 0(%4), %%eax\n"
26870 - "21: movl 4(%4), %%edx\n"
26871 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26872 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26873 " movnti %%eax, 0(%3)\n"
26874 " movnti %%edx, 4(%3)\n"
26875 - "3: movl 8(%4), %%eax\n"
26876 - "31: movl 12(%4),%%edx\n"
26877 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26878 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26879 " movnti %%eax, 8(%3)\n"
26880 " movnti %%edx, 12(%3)\n"
26881 - "4: movl 16(%4), %%eax\n"
26882 - "41: movl 20(%4), %%edx\n"
26883 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26884 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26885 " movnti %%eax, 16(%3)\n"
26886 " movnti %%edx, 20(%3)\n"
26887 - "10: movl 24(%4), %%eax\n"
26888 - "51: movl 28(%4), %%edx\n"
26889 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26890 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26891 " movnti %%eax, 24(%3)\n"
26892 " movnti %%edx, 28(%3)\n"
26893 - "11: movl 32(%4), %%eax\n"
26894 - "61: movl 36(%4), %%edx\n"
26895 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26896 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26897 " movnti %%eax, 32(%3)\n"
26898 " movnti %%edx, 36(%3)\n"
26899 - "12: movl 40(%4), %%eax\n"
26900 - "71: movl 44(%4), %%edx\n"
26901 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26902 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26903 " movnti %%eax, 40(%3)\n"
26904 " movnti %%edx, 44(%3)\n"
26905 - "13: movl 48(%4), %%eax\n"
26906 - "81: movl 52(%4), %%edx\n"
26907 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26908 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26909 " movnti %%eax, 48(%3)\n"
26910 " movnti %%edx, 52(%3)\n"
26911 - "14: movl 56(%4), %%eax\n"
26912 - "91: movl 60(%4), %%edx\n"
26913 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26914 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26915 " movnti %%eax, 56(%3)\n"
26916 " movnti %%edx, 60(%3)\n"
26917 " addl $-64, %0\n"
26918 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26919 " shrl $2, %0\n"
26920 " andl $3, %%eax\n"
26921 " cld\n"
26922 - "6: rep; movsl\n"
26923 + "6: rep; "__copyuser_seg" movsl\n"
26924 " movl %%eax,%0\n"
26925 - "7: rep; movsb\n"
26926 + "7: rep; "__copyuser_seg" movsb\n"
26927 "8:\n"
26928 ".section .fixup,\"ax\"\n"
26929 "9: lea 0(%%eax,%0,4),%0\n"
26930 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26931 */
26932 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26933 unsigned long size);
26934 -unsigned long __copy_user_intel(void __user *to, const void *from,
26935 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26936 + unsigned long size);
26937 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26938 unsigned long size);
26939 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26940 const void __user *from, unsigned long size);
26941 #endif /* CONFIG_X86_INTEL_USERCOPY */
26942
26943 /* Generic arbitrary sized copy. */
26944 -#define __copy_user(to, from, size) \
26945 +#define __copy_user(to, from, size, prefix, set, restore) \
26946 do { \
26947 int __d0, __d1, __d2; \
26948 __asm__ __volatile__( \
26949 + set \
26950 " cmp $7,%0\n" \
26951 " jbe 1f\n" \
26952 " movl %1,%0\n" \
26953 " negl %0\n" \
26954 " andl $7,%0\n" \
26955 " subl %0,%3\n" \
26956 - "4: rep; movsb\n" \
26957 + "4: rep; "prefix"movsb\n" \
26958 " movl %3,%0\n" \
26959 " shrl $2,%0\n" \
26960 " andl $3,%3\n" \
26961 " .align 2,0x90\n" \
26962 - "0: rep; movsl\n" \
26963 + "0: rep; "prefix"movsl\n" \
26964 " movl %3,%0\n" \
26965 - "1: rep; movsb\n" \
26966 + "1: rep; "prefix"movsb\n" \
26967 "2:\n" \
26968 + restore \
26969 ".section .fixup,\"ax\"\n" \
26970 "5: addl %3,%0\n" \
26971 " jmp 2b\n" \
26972 @@ -538,14 +650,14 @@ do { \
26973 " negl %0\n" \
26974 " andl $7,%0\n" \
26975 " subl %0,%3\n" \
26976 - "4: rep; movsb\n" \
26977 + "4: rep; "__copyuser_seg"movsb\n" \
26978 " movl %3,%0\n" \
26979 " shrl $2,%0\n" \
26980 " andl $3,%3\n" \
26981 " .align 2,0x90\n" \
26982 - "0: rep; movsl\n" \
26983 + "0: rep; "__copyuser_seg"movsl\n" \
26984 " movl %3,%0\n" \
26985 - "1: rep; movsb\n" \
26986 + "1: rep; "__copyuser_seg"movsb\n" \
26987 "2:\n" \
26988 ".section .fixup,\"ax\"\n" \
26989 "5: addl %3,%0\n" \
26990 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26991 {
26992 stac();
26993 if (movsl_is_ok(to, from, n))
26994 - __copy_user(to, from, n);
26995 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26996 else
26997 - n = __copy_user_intel(to, from, n);
26998 + n = __generic_copy_to_user_intel(to, from, n);
26999 clac();
27000 return n;
27001 }
27002 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27003 {
27004 stac();
27005 if (movsl_is_ok(to, from, n))
27006 - __copy_user(to, from, n);
27007 + __copy_user(to, from, n, __copyuser_seg, "", "");
27008 else
27009 - n = __copy_user_intel((void __user *)to,
27010 - (const void *)from, n);
27011 + n = __generic_copy_from_user_intel(to, from, n);
27012 clac();
27013 return n;
27014 }
27015 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27016 if (n > 64 && cpu_has_xmm2)
27017 n = __copy_user_intel_nocache(to, from, n);
27018 else
27019 - __copy_user(to, from, n);
27020 + __copy_user(to, from, n, __copyuser_seg, "", "");
27021 #else
27022 - __copy_user(to, from, n);
27023 + __copy_user(to, from, n, __copyuser_seg, "", "");
27024 #endif
27025 clac();
27026 return n;
27027 }
27028 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27029
27030 -/**
27031 - * copy_to_user: - Copy a block of data into user space.
27032 - * @to: Destination address, in user space.
27033 - * @from: Source address, in kernel space.
27034 - * @n: Number of bytes to copy.
27035 - *
27036 - * Context: User context only. This function may sleep.
27037 - *
27038 - * Copy data from kernel space to user space.
27039 - *
27040 - * Returns number of bytes that could not be copied.
27041 - * On success, this will be zero.
27042 - */
27043 -unsigned long
27044 -copy_to_user(void __user *to, const void *from, unsigned long n)
27045 -{
27046 - if (access_ok(VERIFY_WRITE, to, n))
27047 - n = __copy_to_user(to, from, n);
27048 - return n;
27049 -}
27050 -EXPORT_SYMBOL(copy_to_user);
27051 -
27052 -/**
27053 - * copy_from_user: - Copy a block of data from user space.
27054 - * @to: Destination address, in kernel space.
27055 - * @from: Source address, in user space.
27056 - * @n: Number of bytes to copy.
27057 - *
27058 - * Context: User context only. This function may sleep.
27059 - *
27060 - * Copy data from user space to kernel space.
27061 - *
27062 - * Returns number of bytes that could not be copied.
27063 - * On success, this will be zero.
27064 - *
27065 - * If some data could not be copied, this function will pad the copied
27066 - * data to the requested size using zero bytes.
27067 - */
27068 -unsigned long
27069 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27070 -{
27071 - if (access_ok(VERIFY_READ, from, n))
27072 - n = __copy_from_user(to, from, n);
27073 - else
27074 - memset(to, 0, n);
27075 - return n;
27076 -}
27077 -EXPORT_SYMBOL(_copy_from_user);
27078 -
27079 void copy_from_user_overflow(void)
27080 {
27081 WARN(1, "Buffer overflow detected!\n");
27082 }
27083 EXPORT_SYMBOL(copy_from_user_overflow);
27084 +
27085 +void copy_to_user_overflow(void)
27086 +{
27087 + WARN(1, "Buffer overflow detected!\n");
27088 +}
27089 +EXPORT_SYMBOL(copy_to_user_overflow);
27090 +
27091 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27092 +void __set_fs(mm_segment_t x)
27093 +{
27094 + switch (x.seg) {
27095 + case 0:
27096 + loadsegment(gs, 0);
27097 + break;
27098 + case TASK_SIZE_MAX:
27099 + loadsegment(gs, __USER_DS);
27100 + break;
27101 + case -1UL:
27102 + loadsegment(gs, __KERNEL_DS);
27103 + break;
27104 + default:
27105 + BUG();
27106 + }
27107 + return;
27108 +}
27109 +EXPORT_SYMBOL(__set_fs);
27110 +
27111 +void set_fs(mm_segment_t x)
27112 +{
27113 + current_thread_info()->addr_limit = x;
27114 + __set_fs(x);
27115 +}
27116 +EXPORT_SYMBOL(set_fs);
27117 +#endif
27118 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27119 index 906fea3..ee8a097 100644
27120 --- a/arch/x86/lib/usercopy_64.c
27121 +++ b/arch/x86/lib/usercopy_64.c
27122 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27123 _ASM_EXTABLE(0b,3b)
27124 _ASM_EXTABLE(1b,2b)
27125 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27126 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27127 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27128 [zero] "r" (0UL), [eight] "r" (8UL));
27129 clac();
27130 return size;
27131 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27132 }
27133 EXPORT_SYMBOL(clear_user);
27134
27135 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27136 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27137 {
27138 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27139 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27140 - }
27141 - return len;
27142 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27143 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27144 + return len;
27145 }
27146 EXPORT_SYMBOL(copy_in_user);
27147
27148 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27149 * it is not necessary to optimize tail handling.
27150 */
27151 unsigned long
27152 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27153 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27154 {
27155 char c;
27156 unsigned zero_len;
27157 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27158 clac();
27159 return len;
27160 }
27161 +
27162 +void copy_from_user_overflow(void)
27163 +{
27164 + WARN(1, "Buffer overflow detected!\n");
27165 +}
27166 +EXPORT_SYMBOL(copy_from_user_overflow);
27167 +
27168 +void copy_to_user_overflow(void)
27169 +{
27170 + WARN(1, "Buffer overflow detected!\n");
27171 +}
27172 +EXPORT_SYMBOL(copy_to_user_overflow);
27173 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27174 index 903ec1e..c4166b2 100644
27175 --- a/arch/x86/mm/extable.c
27176 +++ b/arch/x86/mm/extable.c
27177 @@ -6,12 +6,24 @@
27178 static inline unsigned long
27179 ex_insn_addr(const struct exception_table_entry *x)
27180 {
27181 - return (unsigned long)&x->insn + x->insn;
27182 + unsigned long reloc = 0;
27183 +
27184 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27185 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27186 +#endif
27187 +
27188 + return (unsigned long)&x->insn + x->insn + reloc;
27189 }
27190 static inline unsigned long
27191 ex_fixup_addr(const struct exception_table_entry *x)
27192 {
27193 - return (unsigned long)&x->fixup + x->fixup;
27194 + unsigned long reloc = 0;
27195 +
27196 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27197 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27198 +#endif
27199 +
27200 + return (unsigned long)&x->fixup + x->fixup + reloc;
27201 }
27202
27203 int fixup_exception(struct pt_regs *regs)
27204 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27205 unsigned long new_ip;
27206
27207 #ifdef CONFIG_PNPBIOS
27208 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27209 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27210 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27211 extern u32 pnp_bios_is_utter_crap;
27212 pnp_bios_is_utter_crap = 1;
27213 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27214 i += 4;
27215 p->fixup -= i;
27216 i += 4;
27217 +
27218 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27219 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27220 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27221 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27222 +#endif
27223 +
27224 }
27225 }
27226
27227 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27228 index 0e88336..2bb9777 100644
27229 --- a/arch/x86/mm/fault.c
27230 +++ b/arch/x86/mm/fault.c
27231 @@ -13,12 +13,19 @@
27232 #include <linux/perf_event.h> /* perf_sw_event */
27233 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27234 #include <linux/prefetch.h> /* prefetchw */
27235 +#include <linux/unistd.h>
27236 +#include <linux/compiler.h>
27237
27238 #include <asm/traps.h> /* dotraplinkage, ... */
27239 #include <asm/pgalloc.h> /* pgd_*(), ... */
27240 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27241 #include <asm/fixmap.h> /* VSYSCALL_START */
27242 #include <asm/context_tracking.h> /* exception_enter(), ... */
27243 +#include <asm/tlbflush.h>
27244 +
27245 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27246 +#include <asm/stacktrace.h>
27247 +#endif
27248
27249 /*
27250 * Page fault error code bits:
27251 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27252 int ret = 0;
27253
27254 /* kprobe_running() needs smp_processor_id() */
27255 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27256 + if (kprobes_built_in() && !user_mode(regs)) {
27257 preempt_disable();
27258 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27259 ret = 1;
27260 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27261 return !instr_lo || (instr_lo>>1) == 1;
27262 case 0x00:
27263 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27264 - if (probe_kernel_address(instr, opcode))
27265 + if (user_mode(regs)) {
27266 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27267 + return 0;
27268 + } else if (probe_kernel_address(instr, opcode))
27269 return 0;
27270
27271 *prefetch = (instr_lo == 0xF) &&
27272 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27273 while (instr < max_instr) {
27274 unsigned char opcode;
27275
27276 - if (probe_kernel_address(instr, opcode))
27277 + if (user_mode(regs)) {
27278 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27279 + break;
27280 + } else if (probe_kernel_address(instr, opcode))
27281 break;
27282
27283 instr++;
27284 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27285 force_sig_info(si_signo, &info, tsk);
27286 }
27287
27288 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27289 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27290 +#endif
27291 +
27292 +#ifdef CONFIG_PAX_EMUTRAMP
27293 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27294 +#endif
27295 +
27296 +#ifdef CONFIG_PAX_PAGEEXEC
27297 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27298 +{
27299 + pgd_t *pgd;
27300 + pud_t *pud;
27301 + pmd_t *pmd;
27302 +
27303 + pgd = pgd_offset(mm, address);
27304 + if (!pgd_present(*pgd))
27305 + return NULL;
27306 + pud = pud_offset(pgd, address);
27307 + if (!pud_present(*pud))
27308 + return NULL;
27309 + pmd = pmd_offset(pud, address);
27310 + if (!pmd_present(*pmd))
27311 + return NULL;
27312 + return pmd;
27313 +}
27314 +#endif
27315 +
27316 DEFINE_SPINLOCK(pgd_lock);
27317 LIST_HEAD(pgd_list);
27318
27319 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27320 for (address = VMALLOC_START & PMD_MASK;
27321 address >= TASK_SIZE && address < FIXADDR_TOP;
27322 address += PMD_SIZE) {
27323 +
27324 +#ifdef CONFIG_PAX_PER_CPU_PGD
27325 + unsigned long cpu;
27326 +#else
27327 struct page *page;
27328 +#endif
27329
27330 spin_lock(&pgd_lock);
27331 +
27332 +#ifdef CONFIG_PAX_PER_CPU_PGD
27333 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27334 + pgd_t *pgd = get_cpu_pgd(cpu);
27335 + pmd_t *ret;
27336 +#else
27337 list_for_each_entry(page, &pgd_list, lru) {
27338 + pgd_t *pgd;
27339 spinlock_t *pgt_lock;
27340 pmd_t *ret;
27341
27342 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27343 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27344
27345 spin_lock(pgt_lock);
27346 - ret = vmalloc_sync_one(page_address(page), address);
27347 + pgd = page_address(page);
27348 +#endif
27349 +
27350 + ret = vmalloc_sync_one(pgd, address);
27351 +
27352 +#ifndef CONFIG_PAX_PER_CPU_PGD
27353 spin_unlock(pgt_lock);
27354 +#endif
27355
27356 if (!ret)
27357 break;
27358 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27359 * an interrupt in the middle of a task switch..
27360 */
27361 pgd_paddr = read_cr3();
27362 +
27363 +#ifdef CONFIG_PAX_PER_CPU_PGD
27364 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27365 +#endif
27366 +
27367 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27368 if (!pmd_k)
27369 return -1;
27370 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27371 * happen within a race in page table update. In the later
27372 * case just flush:
27373 */
27374 +
27375 +#ifdef CONFIG_PAX_PER_CPU_PGD
27376 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27377 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27378 +#else
27379 pgd = pgd_offset(current->active_mm, address);
27380 +#endif
27381 +
27382 pgd_ref = pgd_offset_k(address);
27383 if (pgd_none(*pgd_ref))
27384 return -1;
27385 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27386 static int is_errata100(struct pt_regs *regs, unsigned long address)
27387 {
27388 #ifdef CONFIG_X86_64
27389 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27390 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27391 return 1;
27392 #endif
27393 return 0;
27394 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27395 }
27396
27397 static const char nx_warning[] = KERN_CRIT
27398 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27399 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27400
27401 static void
27402 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27403 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27404 if (!oops_may_print())
27405 return;
27406
27407 - if (error_code & PF_INSTR) {
27408 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27409 unsigned int level;
27410
27411 pte_t *pte = lookup_address(address, &level);
27412
27413 if (pte && pte_present(*pte) && !pte_exec(*pte))
27414 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27415 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27416 }
27417
27418 +#ifdef CONFIG_PAX_KERNEXEC
27419 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27420 + if (current->signal->curr_ip)
27421 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27422 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27423 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27424 + else
27425 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27426 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27427 + }
27428 +#endif
27429 +
27430 printk(KERN_ALERT "BUG: unable to handle kernel ");
27431 if (address < PAGE_SIZE)
27432 printk(KERN_CONT "NULL pointer dereference");
27433 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27434 return;
27435 }
27436 #endif
27437 +
27438 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27439 + if (pax_is_fetch_fault(regs, error_code, address)) {
27440 +
27441 +#ifdef CONFIG_PAX_EMUTRAMP
27442 + switch (pax_handle_fetch_fault(regs)) {
27443 + case 2:
27444 + return;
27445 + }
27446 +#endif
27447 +
27448 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27449 + do_group_exit(SIGKILL);
27450 + }
27451 +#endif
27452 +
27453 /* Kernel addresses are always protection faults: */
27454 if (address >= TASK_SIZE)
27455 error_code |= PF_PROT;
27456 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27457 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27458 printk(KERN_ERR
27459 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27460 - tsk->comm, tsk->pid, address);
27461 + tsk->comm, task_pid_nr(tsk), address);
27462 code = BUS_MCEERR_AR;
27463 }
27464 #endif
27465 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27466 return 1;
27467 }
27468
27469 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27470 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27471 +{
27472 + pte_t *pte;
27473 + pmd_t *pmd;
27474 + spinlock_t *ptl;
27475 + unsigned char pte_mask;
27476 +
27477 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27478 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27479 + return 0;
27480 +
27481 + /* PaX: it's our fault, let's handle it if we can */
27482 +
27483 + /* PaX: take a look at read faults before acquiring any locks */
27484 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27485 + /* instruction fetch attempt from a protected page in user mode */
27486 + up_read(&mm->mmap_sem);
27487 +
27488 +#ifdef CONFIG_PAX_EMUTRAMP
27489 + switch (pax_handle_fetch_fault(regs)) {
27490 + case 2:
27491 + return 1;
27492 + }
27493 +#endif
27494 +
27495 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27496 + do_group_exit(SIGKILL);
27497 + }
27498 +
27499 + pmd = pax_get_pmd(mm, address);
27500 + if (unlikely(!pmd))
27501 + return 0;
27502 +
27503 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27504 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27505 + pte_unmap_unlock(pte, ptl);
27506 + return 0;
27507 + }
27508 +
27509 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27510 + /* write attempt to a protected page in user mode */
27511 + pte_unmap_unlock(pte, ptl);
27512 + return 0;
27513 + }
27514 +
27515 +#ifdef CONFIG_SMP
27516 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27517 +#else
27518 + if (likely(address > get_limit(regs->cs)))
27519 +#endif
27520 + {
27521 + set_pte(pte, pte_mkread(*pte));
27522 + __flush_tlb_one(address);
27523 + pte_unmap_unlock(pte, ptl);
27524 + up_read(&mm->mmap_sem);
27525 + return 1;
27526 + }
27527 +
27528 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27529 +
27530 + /*
27531 + * PaX: fill DTLB with user rights and retry
27532 + */
27533 + __asm__ __volatile__ (
27534 + "orb %2,(%1)\n"
27535 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27536 +/*
27537 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27538 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27539 + * page fault when examined during a TLB load attempt. this is true not only
27540 + * for PTEs holding a non-present entry but also present entries that will
27541 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27542 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27543 + * for our target pages since their PTEs are simply not in the TLBs at all.
27544 +
27545 + * the best thing in omitting it is that we gain around 15-20% speed in the
27546 + * fast path of the page fault handler and can get rid of tracing since we
27547 + * can no longer flush unintended entries.
27548 + */
27549 + "invlpg (%0)\n"
27550 +#endif
27551 + __copyuser_seg"testb $0,(%0)\n"
27552 + "xorb %3,(%1)\n"
27553 + :
27554 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27555 + : "memory", "cc");
27556 + pte_unmap_unlock(pte, ptl);
27557 + up_read(&mm->mmap_sem);
27558 + return 1;
27559 +}
27560 +#endif
27561 +
27562 /*
27563 * Handle a spurious fault caused by a stale TLB entry.
27564 *
27565 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27566 static inline int
27567 access_error(unsigned long error_code, struct vm_area_struct *vma)
27568 {
27569 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27570 + return 1;
27571 +
27572 if (error_code & PF_WRITE) {
27573 /* write, present and write, not present: */
27574 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27575 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27576 if (error_code & PF_USER)
27577 return false;
27578
27579 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27580 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27581 return false;
27582
27583 return true;
27584 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27585 {
27586 struct vm_area_struct *vma;
27587 struct task_struct *tsk;
27588 - unsigned long address;
27589 struct mm_struct *mm;
27590 int fault;
27591 int write = error_code & PF_WRITE;
27592 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27593 (write ? FAULT_FLAG_WRITE : 0);
27594
27595 - tsk = current;
27596 - mm = tsk->mm;
27597 -
27598 /* Get the faulting address: */
27599 - address = read_cr2();
27600 + unsigned long address = read_cr2();
27601 +
27602 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27603 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27604 + if (!search_exception_tables(regs->ip)) {
27605 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27606 + bad_area_nosemaphore(regs, error_code, address);
27607 + return;
27608 + }
27609 + if (address < pax_user_shadow_base) {
27610 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27611 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27612 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27613 + } else
27614 + address -= pax_user_shadow_base;
27615 + }
27616 +#endif
27617 +
27618 + tsk = current;
27619 + mm = tsk->mm;
27620
27621 /*
27622 * Detect and handle instructions that would cause a page fault for
27623 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27624 * User-mode registers count as a user access even for any
27625 * potential system fault or CPU buglet:
27626 */
27627 - if (user_mode_vm(regs)) {
27628 + if (user_mode(regs)) {
27629 local_irq_enable();
27630 error_code |= PF_USER;
27631 } else {
27632 @@ -1142,6 +1352,11 @@ retry:
27633 might_sleep();
27634 }
27635
27636 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27637 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27638 + return;
27639 +#endif
27640 +
27641 vma = find_vma(mm, address);
27642 if (unlikely(!vma)) {
27643 bad_area(regs, error_code, address);
27644 @@ -1153,18 +1368,24 @@ retry:
27645 bad_area(regs, error_code, address);
27646 return;
27647 }
27648 - if (error_code & PF_USER) {
27649 - /*
27650 - * Accessing the stack below %sp is always a bug.
27651 - * The large cushion allows instructions like enter
27652 - * and pusha to work. ("enter $65535, $31" pushes
27653 - * 32 pointers and then decrements %sp by 65535.)
27654 - */
27655 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27656 - bad_area(regs, error_code, address);
27657 - return;
27658 - }
27659 + /*
27660 + * Accessing the stack below %sp is always a bug.
27661 + * The large cushion allows instructions like enter
27662 + * and pusha to work. ("enter $65535, $31" pushes
27663 + * 32 pointers and then decrements %sp by 65535.)
27664 + */
27665 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27666 + bad_area(regs, error_code, address);
27667 + return;
27668 }
27669 +
27670 +#ifdef CONFIG_PAX_SEGMEXEC
27671 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27672 + bad_area(regs, error_code, address);
27673 + return;
27674 + }
27675 +#endif
27676 +
27677 if (unlikely(expand_stack(vma, address))) {
27678 bad_area(regs, error_code, address);
27679 return;
27680 @@ -1228,3 +1449,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27681 __do_page_fault(regs, error_code);
27682 exception_exit(regs);
27683 }
27684 +
27685 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27686 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27687 +{
27688 + struct mm_struct *mm = current->mm;
27689 + unsigned long ip = regs->ip;
27690 +
27691 + if (v8086_mode(regs))
27692 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27693 +
27694 +#ifdef CONFIG_PAX_PAGEEXEC
27695 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27696 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27697 + return true;
27698 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27699 + return true;
27700 + return false;
27701 + }
27702 +#endif
27703 +
27704 +#ifdef CONFIG_PAX_SEGMEXEC
27705 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27706 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27707 + return true;
27708 + return false;
27709 + }
27710 +#endif
27711 +
27712 + return false;
27713 +}
27714 +#endif
27715 +
27716 +#ifdef CONFIG_PAX_EMUTRAMP
27717 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27718 +{
27719 + int err;
27720 +
27721 + do { /* PaX: libffi trampoline emulation */
27722 + unsigned char mov, jmp;
27723 + unsigned int addr1, addr2;
27724 +
27725 +#ifdef CONFIG_X86_64
27726 + if ((regs->ip + 9) >> 32)
27727 + break;
27728 +#endif
27729 +
27730 + err = get_user(mov, (unsigned char __user *)regs->ip);
27731 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27732 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27733 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27734 +
27735 + if (err)
27736 + break;
27737 +
27738 + if (mov == 0xB8 && jmp == 0xE9) {
27739 + regs->ax = addr1;
27740 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27741 + return 2;
27742 + }
27743 + } while (0);
27744 +
27745 + do { /* PaX: gcc trampoline emulation #1 */
27746 + unsigned char mov1, mov2;
27747 + unsigned short jmp;
27748 + unsigned int addr1, addr2;
27749 +
27750 +#ifdef CONFIG_X86_64
27751 + if ((regs->ip + 11) >> 32)
27752 + break;
27753 +#endif
27754 +
27755 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27756 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27757 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27758 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27759 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27760 +
27761 + if (err)
27762 + break;
27763 +
27764 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27765 + regs->cx = addr1;
27766 + regs->ax = addr2;
27767 + regs->ip = addr2;
27768 + return 2;
27769 + }
27770 + } while (0);
27771 +
27772 + do { /* PaX: gcc trampoline emulation #2 */
27773 + unsigned char mov, jmp;
27774 + unsigned int addr1, addr2;
27775 +
27776 +#ifdef CONFIG_X86_64
27777 + if ((regs->ip + 9) >> 32)
27778 + break;
27779 +#endif
27780 +
27781 + err = get_user(mov, (unsigned char __user *)regs->ip);
27782 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27783 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27784 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27785 +
27786 + if (err)
27787 + break;
27788 +
27789 + if (mov == 0xB9 && jmp == 0xE9) {
27790 + regs->cx = addr1;
27791 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27792 + return 2;
27793 + }
27794 + } while (0);
27795 +
27796 + return 1; /* PaX in action */
27797 +}
27798 +
27799 +#ifdef CONFIG_X86_64
27800 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27801 +{
27802 + int err;
27803 +
27804 + do { /* PaX: libffi trampoline emulation */
27805 + unsigned short mov1, mov2, jmp1;
27806 + unsigned char stcclc, jmp2;
27807 + unsigned long addr1, addr2;
27808 +
27809 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27810 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27811 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27812 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27813 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27814 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27815 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27816 +
27817 + if (err)
27818 + break;
27819 +
27820 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27821 + regs->r11 = addr1;
27822 + regs->r10 = addr2;
27823 + if (stcclc == 0xF8)
27824 + regs->flags &= ~X86_EFLAGS_CF;
27825 + else
27826 + regs->flags |= X86_EFLAGS_CF;
27827 + regs->ip = addr1;
27828 + return 2;
27829 + }
27830 + } while (0);
27831 +
27832 + do { /* PaX: gcc trampoline emulation #1 */
27833 + unsigned short mov1, mov2, jmp1;
27834 + unsigned char jmp2;
27835 + unsigned int addr1;
27836 + unsigned long addr2;
27837 +
27838 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27839 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27840 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27841 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27842 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27843 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27844 +
27845 + if (err)
27846 + break;
27847 +
27848 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27849 + regs->r11 = addr1;
27850 + regs->r10 = addr2;
27851 + regs->ip = addr1;
27852 + return 2;
27853 + }
27854 + } while (0);
27855 +
27856 + do { /* PaX: gcc trampoline emulation #2 */
27857 + unsigned short mov1, mov2, jmp1;
27858 + unsigned char jmp2;
27859 + unsigned long addr1, addr2;
27860 +
27861 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27862 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27863 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27864 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27865 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27866 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27867 +
27868 + if (err)
27869 + break;
27870 +
27871 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27872 + regs->r11 = addr1;
27873 + regs->r10 = addr2;
27874 + regs->ip = addr1;
27875 + return 2;
27876 + }
27877 + } while (0);
27878 +
27879 + return 1; /* PaX in action */
27880 +}
27881 +#endif
27882 +
27883 +/*
27884 + * PaX: decide what to do with offenders (regs->ip = fault address)
27885 + *
27886 + * returns 1 when task should be killed
27887 + * 2 when gcc trampoline was detected
27888 + */
27889 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27890 +{
27891 + if (v8086_mode(regs))
27892 + return 1;
27893 +
27894 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27895 + return 1;
27896 +
27897 +#ifdef CONFIG_X86_32
27898 + return pax_handle_fetch_fault_32(regs);
27899 +#else
27900 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27901 + return pax_handle_fetch_fault_32(regs);
27902 + else
27903 + return pax_handle_fetch_fault_64(regs);
27904 +#endif
27905 +}
27906 +#endif
27907 +
27908 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27909 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27910 +{
27911 + long i;
27912 +
27913 + printk(KERN_ERR "PAX: bytes at PC: ");
27914 + for (i = 0; i < 20; i++) {
27915 + unsigned char c;
27916 + if (get_user(c, (unsigned char __force_user *)pc+i))
27917 + printk(KERN_CONT "?? ");
27918 + else
27919 + printk(KERN_CONT "%02x ", c);
27920 + }
27921 + printk("\n");
27922 +
27923 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27924 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27925 + unsigned long c;
27926 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27927 +#ifdef CONFIG_X86_32
27928 + printk(KERN_CONT "???????? ");
27929 +#else
27930 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27931 + printk(KERN_CONT "???????? ???????? ");
27932 + else
27933 + printk(KERN_CONT "???????????????? ");
27934 +#endif
27935 + } else {
27936 +#ifdef CONFIG_X86_64
27937 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27938 + printk(KERN_CONT "%08x ", (unsigned int)c);
27939 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27940 + } else
27941 +#endif
27942 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27943 + }
27944 + }
27945 + printk("\n");
27946 +}
27947 +#endif
27948 +
27949 +/**
27950 + * probe_kernel_write(): safely attempt to write to a location
27951 + * @dst: address to write to
27952 + * @src: pointer to the data that shall be written
27953 + * @size: size of the data chunk
27954 + *
27955 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27956 + * happens, handle that and return -EFAULT.
27957 + */
27958 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27959 +{
27960 + long ret;
27961 + mm_segment_t old_fs = get_fs();
27962 +
27963 + set_fs(KERNEL_DS);
27964 + pagefault_disable();
27965 + pax_open_kernel();
27966 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27967 + pax_close_kernel();
27968 + pagefault_enable();
27969 + set_fs(old_fs);
27970 +
27971 + return ret ? -EFAULT : 0;
27972 +}
27973 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27974 index dd74e46..7d26398 100644
27975 --- a/arch/x86/mm/gup.c
27976 +++ b/arch/x86/mm/gup.c
27977 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27978 addr = start;
27979 len = (unsigned long) nr_pages << PAGE_SHIFT;
27980 end = start + len;
27981 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27982 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27983 (void __user *)start, len)))
27984 return 0;
27985
27986 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27987 index 6f31ee5..8ee4164 100644
27988 --- a/arch/x86/mm/highmem_32.c
27989 +++ b/arch/x86/mm/highmem_32.c
27990 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27991 idx = type + KM_TYPE_NR*smp_processor_id();
27992 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27993 BUG_ON(!pte_none(*(kmap_pte-idx)));
27994 +
27995 + pax_open_kernel();
27996 set_pte(kmap_pte-idx, mk_pte(page, prot));
27997 + pax_close_kernel();
27998 +
27999 arch_flush_lazy_mmu_mode();
28000
28001 return (void *)vaddr;
28002 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28003 index ae1aa71..d9bea75 100644
28004 --- a/arch/x86/mm/hugetlbpage.c
28005 +++ b/arch/x86/mm/hugetlbpage.c
28006 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
28007 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
28008 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28009 unsigned long addr, unsigned long len,
28010 - unsigned long pgoff, unsigned long flags)
28011 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28012 {
28013 struct hstate *h = hstate_file(file);
28014 struct vm_unmapped_area_info info;
28015 -
28016 +
28017 info.flags = 0;
28018 info.length = len;
28019 info.low_limit = TASK_UNMAPPED_BASE;
28020 +
28021 +#ifdef CONFIG_PAX_RANDMMAP
28022 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28023 + info.low_limit += current->mm->delta_mmap;
28024 +#endif
28025 +
28026 info.high_limit = TASK_SIZE;
28027 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28028 info.align_offset = 0;
28029 + info.threadstack_offset = offset;
28030 return vm_unmapped_area(&info);
28031 }
28032
28033 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28034 unsigned long addr0, unsigned long len,
28035 - unsigned long pgoff, unsigned long flags)
28036 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28037 {
28038 struct hstate *h = hstate_file(file);
28039 struct vm_unmapped_area_info info;
28040 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28041 info.high_limit = current->mm->mmap_base;
28042 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28043 info.align_offset = 0;
28044 + info.threadstack_offset = offset;
28045 addr = vm_unmapped_area(&info);
28046
28047 /*
28048 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28049 VM_BUG_ON(addr != -ENOMEM);
28050 info.flags = 0;
28051 info.low_limit = TASK_UNMAPPED_BASE;
28052 +
28053 +#ifdef CONFIG_PAX_RANDMMAP
28054 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28055 + info.low_limit += current->mm->delta_mmap;
28056 +#endif
28057 +
28058 info.high_limit = TASK_SIZE;
28059 addr = vm_unmapped_area(&info);
28060 }
28061 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28062 struct hstate *h = hstate_file(file);
28063 struct mm_struct *mm = current->mm;
28064 struct vm_area_struct *vma;
28065 + unsigned long pax_task_size = TASK_SIZE;
28066 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28067
28068 if (len & ~huge_page_mask(h))
28069 return -EINVAL;
28070 - if (len > TASK_SIZE)
28071 +
28072 +#ifdef CONFIG_PAX_SEGMEXEC
28073 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28074 + pax_task_size = SEGMEXEC_TASK_SIZE;
28075 +#endif
28076 +
28077 + pax_task_size -= PAGE_SIZE;
28078 +
28079 + if (len > pax_task_size)
28080 return -ENOMEM;
28081
28082 if (flags & MAP_FIXED) {
28083 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28084 return addr;
28085 }
28086
28087 +#ifdef CONFIG_PAX_RANDMMAP
28088 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28089 +#endif
28090 +
28091 if (addr) {
28092 addr = ALIGN(addr, huge_page_size(h));
28093 vma = find_vma(mm, addr);
28094 - if (TASK_SIZE - len >= addr &&
28095 - (!vma || addr + len <= vma->vm_start))
28096 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28097 return addr;
28098 }
28099 if (mm->get_unmapped_area == arch_get_unmapped_area)
28100 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28101 - pgoff, flags);
28102 + pgoff, flags, offset);
28103 else
28104 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28105 - pgoff, flags);
28106 + pgoff, flags, offset);
28107 }
28108
28109 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28110 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28111 index 0c13708..689fe7f 100644
28112 --- a/arch/x86/mm/init.c
28113 +++ b/arch/x86/mm/init.c
28114 @@ -4,6 +4,7 @@
28115 #include <linux/swap.h>
28116 #include <linux/memblock.h>
28117 #include <linux/bootmem.h> /* for max_low_pfn */
28118 +#include <linux/tboot.h>
28119
28120 #include <asm/cacheflush.h>
28121 #include <asm/e820.h>
28122 @@ -17,6 +18,8 @@
28123 #include <asm/proto.h>
28124 #include <asm/dma.h> /* for MAX_DMA_PFN */
28125 #include <asm/microcode.h>
28126 +#include <asm/desc.h>
28127 +#include <asm/bios_ebda.h>
28128
28129 #include "mm_internal.h"
28130
28131 @@ -464,10 +467,40 @@ void __init init_mem_mapping(void)
28132 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28133 * mmio resources as well as potential bios/acpi data regions.
28134 */
28135 +
28136 +#ifdef CONFIG_GRKERNSEC_KMEM
28137 +static unsigned int ebda_start __read_only;
28138 +static unsigned int ebda_end __read_only;
28139 +#endif
28140 +
28141 int devmem_is_allowed(unsigned long pagenr)
28142 {
28143 - if (pagenr < 256)
28144 +#ifdef CONFIG_GRKERNSEC_KMEM
28145 + /* allow BDA */
28146 + if (!pagenr)
28147 return 1;
28148 + /* allow EBDA */
28149 + if (pagenr >= ebda_start && pagenr < ebda_end)
28150 + return 1;
28151 + /* if tboot is in use, allow access to its hardcoded serial log range */
28152 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28153 + return 1;
28154 +#else
28155 + if (!pagenr)
28156 + return 1;
28157 +#ifdef CONFIG_VM86
28158 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28159 + return 1;
28160 +#endif
28161 +#endif
28162 +
28163 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28164 + return 1;
28165 +#ifdef CONFIG_GRKERNSEC_KMEM
28166 + /* throw out everything else below 1MB */
28167 + if (pagenr <= 256)
28168 + return 0;
28169 +#endif
28170 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28171 return 0;
28172 if (!page_is_ram(pagenr))
28173 @@ -524,8 +557,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28174 #endif
28175 }
28176
28177 +#ifdef CONFIG_GRKERNSEC_KMEM
28178 +static inline void gr_init_ebda(void)
28179 +{
28180 + unsigned int ebda_addr;
28181 + unsigned int ebda_size = 0;
28182 +
28183 + ebda_addr = get_bios_ebda();
28184 + if (ebda_addr) {
28185 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28186 + ebda_size <<= 10;
28187 + }
28188 + if (ebda_addr && ebda_size) {
28189 + ebda_start = ebda_addr >> PAGE_SHIFT;
28190 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28191 + } else {
28192 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28193 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28194 + }
28195 +}
28196 +#else
28197 +static inline void gr_init_ebda(void) { }
28198 +#endif
28199 +
28200 void free_initmem(void)
28201 {
28202 +#ifdef CONFIG_PAX_KERNEXEC
28203 +#ifdef CONFIG_X86_32
28204 + /* PaX: limit KERNEL_CS to actual size */
28205 + unsigned long addr, limit;
28206 + struct desc_struct d;
28207 + int cpu;
28208 +#else
28209 + pgd_t *pgd;
28210 + pud_t *pud;
28211 + pmd_t *pmd;
28212 + unsigned long addr, end;
28213 +#endif
28214 +#endif
28215 +
28216 + gr_init_ebda();
28217 +
28218 +#ifdef CONFIG_PAX_KERNEXEC
28219 +#ifdef CONFIG_X86_32
28220 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28221 + limit = (limit - 1UL) >> PAGE_SHIFT;
28222 +
28223 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28224 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28225 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28226 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28227 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28228 + }
28229 +
28230 + /* PaX: make KERNEL_CS read-only */
28231 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28232 + if (!paravirt_enabled())
28233 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28234 +/*
28235 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28236 + pgd = pgd_offset_k(addr);
28237 + pud = pud_offset(pgd, addr);
28238 + pmd = pmd_offset(pud, addr);
28239 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28240 + }
28241 +*/
28242 +#ifdef CONFIG_X86_PAE
28243 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28244 +/*
28245 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28246 + pgd = pgd_offset_k(addr);
28247 + pud = pud_offset(pgd, addr);
28248 + pmd = pmd_offset(pud, addr);
28249 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28250 + }
28251 +*/
28252 +#endif
28253 +
28254 +#ifdef CONFIG_MODULES
28255 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28256 +#endif
28257 +
28258 +#else
28259 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28260 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28261 + pgd = pgd_offset_k(addr);
28262 + pud = pud_offset(pgd, addr);
28263 + pmd = pmd_offset(pud, addr);
28264 + if (!pmd_present(*pmd))
28265 + continue;
28266 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28267 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28268 + else
28269 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28270 + }
28271 +
28272 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28273 + end = addr + KERNEL_IMAGE_SIZE;
28274 + for (; addr < end; addr += PMD_SIZE) {
28275 + pgd = pgd_offset_k(addr);
28276 + pud = pud_offset(pgd, addr);
28277 + pmd = pmd_offset(pud, addr);
28278 + if (!pmd_present(*pmd))
28279 + continue;
28280 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28281 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28282 + }
28283 +#endif
28284 +
28285 + flush_tlb_all();
28286 +#endif
28287 +
28288 free_init_pages("unused kernel memory",
28289 (unsigned long)(&__init_begin),
28290 (unsigned long)(&__init_end));
28291 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28292 index 2d19001..6a1046c 100644
28293 --- a/arch/x86/mm/init_32.c
28294 +++ b/arch/x86/mm/init_32.c
28295 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28296 bool __read_mostly __vmalloc_start_set = false;
28297
28298 /*
28299 - * Creates a middle page table and puts a pointer to it in the
28300 - * given global directory entry. This only returns the gd entry
28301 - * in non-PAE compilation mode, since the middle layer is folded.
28302 - */
28303 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28304 -{
28305 - pud_t *pud;
28306 - pmd_t *pmd_table;
28307 -
28308 -#ifdef CONFIG_X86_PAE
28309 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28310 - pmd_table = (pmd_t *)alloc_low_page();
28311 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28312 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28313 - pud = pud_offset(pgd, 0);
28314 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28315 -
28316 - return pmd_table;
28317 - }
28318 -#endif
28319 - pud = pud_offset(pgd, 0);
28320 - pmd_table = pmd_offset(pud, 0);
28321 -
28322 - return pmd_table;
28323 -}
28324 -
28325 -/*
28326 * Create a page table and place a pointer to it in a middle page
28327 * directory entry:
28328 */
28329 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28330 pte_t *page_table = (pte_t *)alloc_low_page();
28331
28332 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28333 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28334 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28335 +#else
28336 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28337 +#endif
28338 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28339 }
28340
28341 return pte_offset_kernel(pmd, 0);
28342 }
28343
28344 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28345 +{
28346 + pud_t *pud;
28347 + pmd_t *pmd_table;
28348 +
28349 + pud = pud_offset(pgd, 0);
28350 + pmd_table = pmd_offset(pud, 0);
28351 +
28352 + return pmd_table;
28353 +}
28354 +
28355 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28356 {
28357 int pgd_idx = pgd_index(vaddr);
28358 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28359 int pgd_idx, pmd_idx;
28360 unsigned long vaddr;
28361 pgd_t *pgd;
28362 + pud_t *pud;
28363 pmd_t *pmd;
28364 pte_t *pte = NULL;
28365 unsigned long count = page_table_range_init_count(start, end);
28366 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28367 pgd = pgd_base + pgd_idx;
28368
28369 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28370 - pmd = one_md_table_init(pgd);
28371 - pmd = pmd + pmd_index(vaddr);
28372 + pud = pud_offset(pgd, vaddr);
28373 + pmd = pmd_offset(pud, vaddr);
28374 +
28375 +#ifdef CONFIG_X86_PAE
28376 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28377 +#endif
28378 +
28379 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28380 pmd++, pmd_idx++) {
28381 pte = page_table_kmap_check(one_page_table_init(pmd),
28382 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28383 }
28384 }
28385
28386 -static inline int is_kernel_text(unsigned long addr)
28387 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28388 {
28389 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28390 - return 1;
28391 - return 0;
28392 + if ((start > ktla_ktva((unsigned long)_etext) ||
28393 + end <= ktla_ktva((unsigned long)_stext)) &&
28394 + (start > ktla_ktva((unsigned long)_einittext) ||
28395 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28396 +
28397 +#ifdef CONFIG_ACPI_SLEEP
28398 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28399 +#endif
28400 +
28401 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28402 + return 0;
28403 + return 1;
28404 }
28405
28406 /*
28407 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28408 unsigned long last_map_addr = end;
28409 unsigned long start_pfn, end_pfn;
28410 pgd_t *pgd_base = swapper_pg_dir;
28411 - int pgd_idx, pmd_idx, pte_ofs;
28412 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28413 unsigned long pfn;
28414 pgd_t *pgd;
28415 + pud_t *pud;
28416 pmd_t *pmd;
28417 pte_t *pte;
28418 unsigned pages_2m, pages_4k;
28419 @@ -291,8 +295,13 @@ repeat:
28420 pfn = start_pfn;
28421 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28422 pgd = pgd_base + pgd_idx;
28423 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28424 - pmd = one_md_table_init(pgd);
28425 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28426 + pud = pud_offset(pgd, 0);
28427 + pmd = pmd_offset(pud, 0);
28428 +
28429 +#ifdef CONFIG_X86_PAE
28430 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28431 +#endif
28432
28433 if (pfn >= end_pfn)
28434 continue;
28435 @@ -304,14 +313,13 @@ repeat:
28436 #endif
28437 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28438 pmd++, pmd_idx++) {
28439 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28440 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28441
28442 /*
28443 * Map with big pages if possible, otherwise
28444 * create normal page tables:
28445 */
28446 if (use_pse) {
28447 - unsigned int addr2;
28448 pgprot_t prot = PAGE_KERNEL_LARGE;
28449 /*
28450 * first pass will use the same initial
28451 @@ -322,11 +330,7 @@ repeat:
28452 _PAGE_PSE);
28453
28454 pfn &= PMD_MASK >> PAGE_SHIFT;
28455 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28456 - PAGE_OFFSET + PAGE_SIZE-1;
28457 -
28458 - if (is_kernel_text(addr) ||
28459 - is_kernel_text(addr2))
28460 + if (is_kernel_text(address, address + PMD_SIZE))
28461 prot = PAGE_KERNEL_LARGE_EXEC;
28462
28463 pages_2m++;
28464 @@ -343,7 +347,7 @@ repeat:
28465 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28466 pte += pte_ofs;
28467 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28468 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28469 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28470 pgprot_t prot = PAGE_KERNEL;
28471 /*
28472 * first pass will use the same initial
28473 @@ -351,7 +355,7 @@ repeat:
28474 */
28475 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28476
28477 - if (is_kernel_text(addr))
28478 + if (is_kernel_text(address, address + PAGE_SIZE))
28479 prot = PAGE_KERNEL_EXEC;
28480
28481 pages_4k++;
28482 @@ -482,7 +486,7 @@ void __init native_pagetable_init(void)
28483
28484 pud = pud_offset(pgd, va);
28485 pmd = pmd_offset(pud, va);
28486 - if (!pmd_present(*pmd))
28487 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28488 break;
28489
28490 /* should not be large page here */
28491 @@ -540,12 +544,10 @@ void __init early_ioremap_page_table_range_init(void)
28492
28493 static void __init pagetable_init(void)
28494 {
28495 - pgd_t *pgd_base = swapper_pg_dir;
28496 -
28497 - permanent_kmaps_init(pgd_base);
28498 + permanent_kmaps_init(swapper_pg_dir);
28499 }
28500
28501 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28502 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28503 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28504
28505 /* user-defined highmem size */
28506 @@ -752,6 +754,12 @@ void __init mem_init(void)
28507
28508 pci_iommu_alloc();
28509
28510 +#ifdef CONFIG_PAX_PER_CPU_PGD
28511 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28512 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28513 + KERNEL_PGD_PTRS);
28514 +#endif
28515 +
28516 #ifdef CONFIG_FLATMEM
28517 BUG_ON(!mem_map);
28518 #endif
28519 @@ -780,7 +788,7 @@ void __init mem_init(void)
28520 after_bootmem = 1;
28521
28522 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28523 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28524 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28525 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28526
28527 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28528 @@ -821,10 +829,10 @@ void __init mem_init(void)
28529 ((unsigned long)&__init_end -
28530 (unsigned long)&__init_begin) >> 10,
28531
28532 - (unsigned long)&_etext, (unsigned long)&_edata,
28533 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28534 + (unsigned long)&_sdata, (unsigned long)&_edata,
28535 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28536
28537 - (unsigned long)&_text, (unsigned long)&_etext,
28538 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28539 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28540
28541 /*
28542 @@ -914,6 +922,7 @@ void set_kernel_text_rw(void)
28543 if (!kernel_set_to_readonly)
28544 return;
28545
28546 + start = ktla_ktva(start);
28547 pr_debug("Set kernel text: %lx - %lx for read write\n",
28548 start, start+size);
28549
28550 @@ -928,6 +937,7 @@ void set_kernel_text_ro(void)
28551 if (!kernel_set_to_readonly)
28552 return;
28553
28554 + start = ktla_ktva(start);
28555 pr_debug("Set kernel text: %lx - %lx for read only\n",
28556 start, start+size);
28557
28558 @@ -956,6 +966,7 @@ void mark_rodata_ro(void)
28559 unsigned long start = PFN_ALIGN(_text);
28560 unsigned long size = PFN_ALIGN(_etext) - start;
28561
28562 + start = ktla_ktva(start);
28563 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28564 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28565 size >> 10);
28566 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28567 index 474e28f..647dd12 100644
28568 --- a/arch/x86/mm/init_64.c
28569 +++ b/arch/x86/mm/init_64.c
28570 @@ -150,7 +150,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28571 * around without checking the pgd every time.
28572 */
28573
28574 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28575 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28576 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28577
28578 int force_personality32;
28579 @@ -183,12 +183,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28580
28581 for (address = start; address <= end; address += PGDIR_SIZE) {
28582 const pgd_t *pgd_ref = pgd_offset_k(address);
28583 +
28584 +#ifdef CONFIG_PAX_PER_CPU_PGD
28585 + unsigned long cpu;
28586 +#else
28587 struct page *page;
28588 +#endif
28589
28590 if (pgd_none(*pgd_ref))
28591 continue;
28592
28593 spin_lock(&pgd_lock);
28594 +
28595 +#ifdef CONFIG_PAX_PER_CPU_PGD
28596 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28597 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28598 +#else
28599 list_for_each_entry(page, &pgd_list, lru) {
28600 pgd_t *pgd;
28601 spinlock_t *pgt_lock;
28602 @@ -197,6 +207,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28603 /* the pgt_lock only for Xen */
28604 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28605 spin_lock(pgt_lock);
28606 +#endif
28607
28608 if (pgd_none(*pgd))
28609 set_pgd(pgd, *pgd_ref);
28610 @@ -204,7 +215,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28611 BUG_ON(pgd_page_vaddr(*pgd)
28612 != pgd_page_vaddr(*pgd_ref));
28613
28614 +#ifndef CONFIG_PAX_PER_CPU_PGD
28615 spin_unlock(pgt_lock);
28616 +#endif
28617 +
28618 }
28619 spin_unlock(&pgd_lock);
28620 }
28621 @@ -237,7 +251,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28622 {
28623 if (pgd_none(*pgd)) {
28624 pud_t *pud = (pud_t *)spp_getpage();
28625 - pgd_populate(&init_mm, pgd, pud);
28626 + pgd_populate_kernel(&init_mm, pgd, pud);
28627 if (pud != pud_offset(pgd, 0))
28628 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28629 pud, pud_offset(pgd, 0));
28630 @@ -249,7 +263,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28631 {
28632 if (pud_none(*pud)) {
28633 pmd_t *pmd = (pmd_t *) spp_getpage();
28634 - pud_populate(&init_mm, pud, pmd);
28635 + pud_populate_kernel(&init_mm, pud, pmd);
28636 if (pmd != pmd_offset(pud, 0))
28637 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28638 pmd, pmd_offset(pud, 0));
28639 @@ -278,7 +292,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28640 pmd = fill_pmd(pud, vaddr);
28641 pte = fill_pte(pmd, vaddr);
28642
28643 + pax_open_kernel();
28644 set_pte(pte, new_pte);
28645 + pax_close_kernel();
28646
28647 /*
28648 * It's enough to flush this one mapping.
28649 @@ -337,14 +353,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28650 pgd = pgd_offset_k((unsigned long)__va(phys));
28651 if (pgd_none(*pgd)) {
28652 pud = (pud_t *) spp_getpage();
28653 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28654 - _PAGE_USER));
28655 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28656 }
28657 pud = pud_offset(pgd, (unsigned long)__va(phys));
28658 if (pud_none(*pud)) {
28659 pmd = (pmd_t *) spp_getpage();
28660 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28661 - _PAGE_USER));
28662 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28663 }
28664 pmd = pmd_offset(pud, phys);
28665 BUG_ON(!pmd_none(*pmd));
28666 @@ -585,7 +599,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28667 prot);
28668
28669 spin_lock(&init_mm.page_table_lock);
28670 - pud_populate(&init_mm, pud, pmd);
28671 + pud_populate_kernel(&init_mm, pud, pmd);
28672 spin_unlock(&init_mm.page_table_lock);
28673 }
28674 __flush_tlb_all();
28675 @@ -626,7 +640,7 @@ kernel_physical_mapping_init(unsigned long start,
28676 page_size_mask);
28677
28678 spin_lock(&init_mm.page_table_lock);
28679 - pgd_populate(&init_mm, pgd, pud);
28680 + pgd_populate_kernel(&init_mm, pgd, pud);
28681 spin_unlock(&init_mm.page_table_lock);
28682 pgd_changed = true;
28683 }
28684 @@ -1065,6 +1079,12 @@ void __init mem_init(void)
28685
28686 pci_iommu_alloc();
28687
28688 +#ifdef CONFIG_PAX_PER_CPU_PGD
28689 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28690 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28691 + KERNEL_PGD_PTRS);
28692 +#endif
28693 +
28694 /* clear_bss() already clear the empty_zero_page */
28695
28696 reservedpages = 0;
28697 @@ -1224,8 +1244,8 @@ int kern_addr_valid(unsigned long addr)
28698 static struct vm_area_struct gate_vma = {
28699 .vm_start = VSYSCALL_START,
28700 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28701 - .vm_page_prot = PAGE_READONLY_EXEC,
28702 - .vm_flags = VM_READ | VM_EXEC
28703 + .vm_page_prot = PAGE_READONLY,
28704 + .vm_flags = VM_READ
28705 };
28706
28707 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28708 @@ -1259,7 +1279,7 @@ int in_gate_area_no_mm(unsigned long addr)
28709
28710 const char *arch_vma_name(struct vm_area_struct *vma)
28711 {
28712 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28713 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28714 return "[vdso]";
28715 if (vma == &gate_vma)
28716 return "[vsyscall]";
28717 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28718 index 7b179b4..6bd17777 100644
28719 --- a/arch/x86/mm/iomap_32.c
28720 +++ b/arch/x86/mm/iomap_32.c
28721 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28722 type = kmap_atomic_idx_push();
28723 idx = type + KM_TYPE_NR * smp_processor_id();
28724 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28725 +
28726 + pax_open_kernel();
28727 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28728 + pax_close_kernel();
28729 +
28730 arch_flush_lazy_mmu_mode();
28731
28732 return (void *)vaddr;
28733 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28734 index 78fe3f1..73b95e2 100644
28735 --- a/arch/x86/mm/ioremap.c
28736 +++ b/arch/x86/mm/ioremap.c
28737 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28738 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28739 int is_ram = page_is_ram(pfn);
28740
28741 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28742 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28743 return NULL;
28744 WARN_ON_ONCE(is_ram);
28745 }
28746 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28747 *
28748 * Caller must ensure there is only one unmapping for the same pointer.
28749 */
28750 -void iounmap(volatile void __iomem *addr)
28751 +void iounmap(const volatile void __iomem *addr)
28752 {
28753 struct vm_struct *p, *o;
28754
28755 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28756
28757 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28758 if (page_is_ram(start >> PAGE_SHIFT))
28759 +#ifdef CONFIG_HIGHMEM
28760 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28761 +#endif
28762 return __va(phys);
28763
28764 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28765 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28766 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28767 {
28768 if (page_is_ram(phys >> PAGE_SHIFT))
28769 +#ifdef CONFIG_HIGHMEM
28770 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28771 +#endif
28772 return;
28773
28774 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28775 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
28776 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28777
28778 static __initdata int after_paging_init;
28779 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28780 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28781
28782 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28783 {
28784 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
28785 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28786
28787 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28788 - memset(bm_pte, 0, sizeof(bm_pte));
28789 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28790 + pmd_populate_user(&init_mm, pmd, bm_pte);
28791
28792 /*
28793 * The boot-ioremap range spans multiple pmds, for which
28794 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28795 index d87dd6d..bf3fa66 100644
28796 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28797 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28798 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28799 * memory (e.g. tracked pages)? For now, we need this to avoid
28800 * invoking kmemcheck for PnP BIOS calls.
28801 */
28802 - if (regs->flags & X86_VM_MASK)
28803 + if (v8086_mode(regs))
28804 return false;
28805 - if (regs->cs != __KERNEL_CS)
28806 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28807 return false;
28808
28809 pte = kmemcheck_pte_lookup(address);
28810 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28811 index 845df68..1d8d29f 100644
28812 --- a/arch/x86/mm/mmap.c
28813 +++ b/arch/x86/mm/mmap.c
28814 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28815 * Leave an at least ~128 MB hole with possible stack randomization.
28816 */
28817 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28818 -#define MAX_GAP (TASK_SIZE/6*5)
28819 +#define MAX_GAP (pax_task_size/6*5)
28820
28821 static int mmap_is_legacy(void)
28822 {
28823 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28824 return rnd << PAGE_SHIFT;
28825 }
28826
28827 -static unsigned long mmap_base(void)
28828 +static unsigned long mmap_base(struct mm_struct *mm)
28829 {
28830 unsigned long gap = rlimit(RLIMIT_STACK);
28831 + unsigned long pax_task_size = TASK_SIZE;
28832 +
28833 +#ifdef CONFIG_PAX_SEGMEXEC
28834 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28835 + pax_task_size = SEGMEXEC_TASK_SIZE;
28836 +#endif
28837
28838 if (gap < MIN_GAP)
28839 gap = MIN_GAP;
28840 else if (gap > MAX_GAP)
28841 gap = MAX_GAP;
28842
28843 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28844 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28845 }
28846
28847 /*
28848 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28849 * does, but not when emulating X86_32
28850 */
28851 -static unsigned long mmap_legacy_base(void)
28852 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28853 {
28854 - if (mmap_is_ia32())
28855 + if (mmap_is_ia32()) {
28856 +
28857 +#ifdef CONFIG_PAX_SEGMEXEC
28858 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28859 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28860 + else
28861 +#endif
28862 +
28863 return TASK_UNMAPPED_BASE;
28864 - else
28865 + } else
28866 return TASK_UNMAPPED_BASE + mmap_rnd();
28867 }
28868
28869 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28870 void arch_pick_mmap_layout(struct mm_struct *mm)
28871 {
28872 if (mmap_is_legacy()) {
28873 - mm->mmap_base = mmap_legacy_base();
28874 + mm->mmap_base = mmap_legacy_base(mm);
28875 +
28876 +#ifdef CONFIG_PAX_RANDMMAP
28877 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28878 + mm->mmap_base += mm->delta_mmap;
28879 +#endif
28880 +
28881 mm->get_unmapped_area = arch_get_unmapped_area;
28882 mm->unmap_area = arch_unmap_area;
28883 } else {
28884 - mm->mmap_base = mmap_base();
28885 + mm->mmap_base = mmap_base(mm);
28886 +
28887 +#ifdef CONFIG_PAX_RANDMMAP
28888 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28889 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28890 +#endif
28891 +
28892 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28893 mm->unmap_area = arch_unmap_area_topdown;
28894 }
28895 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28896 index dc0b727..f612039 100644
28897 --- a/arch/x86/mm/mmio-mod.c
28898 +++ b/arch/x86/mm/mmio-mod.c
28899 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28900 break;
28901 default:
28902 {
28903 - unsigned char *ip = (unsigned char *)instptr;
28904 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28905 my_trace->opcode = MMIO_UNKNOWN_OP;
28906 my_trace->width = 0;
28907 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28908 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28909 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28910 void __iomem *addr)
28911 {
28912 - static atomic_t next_id;
28913 + static atomic_unchecked_t next_id;
28914 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28915 /* These are page-unaligned. */
28916 struct mmiotrace_map map = {
28917 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28918 .private = trace
28919 },
28920 .phys = offset,
28921 - .id = atomic_inc_return(&next_id)
28922 + .id = atomic_inc_return_unchecked(&next_id)
28923 };
28924 map.map_id = trace->id;
28925
28926 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28927 ioremap_trace_core(offset, size, addr);
28928 }
28929
28930 -static void iounmap_trace_core(volatile void __iomem *addr)
28931 +static void iounmap_trace_core(const volatile void __iomem *addr)
28932 {
28933 struct mmiotrace_map map = {
28934 .phys = 0,
28935 @@ -328,7 +328,7 @@ not_enabled:
28936 }
28937 }
28938
28939 -void mmiotrace_iounmap(volatile void __iomem *addr)
28940 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28941 {
28942 might_sleep();
28943 if (is_enabled()) /* recheck and proper locking in *_core() */
28944 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28945 index 72fe01e..f1a8daa 100644
28946 --- a/arch/x86/mm/numa.c
28947 +++ b/arch/x86/mm/numa.c
28948 @@ -477,7 +477,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28949 return true;
28950 }
28951
28952 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28953 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28954 {
28955 unsigned long uninitialized_var(pfn_align);
28956 int i, nid;
28957 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28958 index 0e38951..4ca8458 100644
28959 --- a/arch/x86/mm/pageattr-test.c
28960 +++ b/arch/x86/mm/pageattr-test.c
28961 @@ -36,7 +36,7 @@ enum {
28962
28963 static int pte_testbit(pte_t pte)
28964 {
28965 - return pte_flags(pte) & _PAGE_UNUSED1;
28966 + return pte_flags(pte) & _PAGE_CPA_TEST;
28967 }
28968
28969 struct split_state {
28970 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28971 index fb4e73e..43f7238 100644
28972 --- a/arch/x86/mm/pageattr.c
28973 +++ b/arch/x86/mm/pageattr.c
28974 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28975 */
28976 #ifdef CONFIG_PCI_BIOS
28977 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28978 - pgprot_val(forbidden) |= _PAGE_NX;
28979 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28980 #endif
28981
28982 /*
28983 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28984 * Does not cover __inittext since that is gone later on. On
28985 * 64bit we do not enforce !NX on the low mapping
28986 */
28987 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28988 - pgprot_val(forbidden) |= _PAGE_NX;
28989 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28990 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28991
28992 +#ifdef CONFIG_DEBUG_RODATA
28993 /*
28994 * The .rodata section needs to be read-only. Using the pfn
28995 * catches all aliases.
28996 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28997 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28998 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28999 pgprot_val(forbidden) |= _PAGE_RW;
29000 +#endif
29001
29002 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29003 /*
29004 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29005 }
29006 #endif
29007
29008 +#ifdef CONFIG_PAX_KERNEXEC
29009 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29010 + pgprot_val(forbidden) |= _PAGE_RW;
29011 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29012 + }
29013 +#endif
29014 +
29015 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29016
29017 return prot;
29018 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
29019 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29020 {
29021 /* change init_mm */
29022 + pax_open_kernel();
29023 set_pte_atomic(kpte, pte);
29024 +
29025 #ifdef CONFIG_X86_32
29026 if (!SHARED_KERNEL_PMD) {
29027 +
29028 +#ifdef CONFIG_PAX_PER_CPU_PGD
29029 + unsigned long cpu;
29030 +#else
29031 struct page *page;
29032 +#endif
29033
29034 +#ifdef CONFIG_PAX_PER_CPU_PGD
29035 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29036 + pgd_t *pgd = get_cpu_pgd(cpu);
29037 +#else
29038 list_for_each_entry(page, &pgd_list, lru) {
29039 - pgd_t *pgd;
29040 + pgd_t *pgd = (pgd_t *)page_address(page);
29041 +#endif
29042 +
29043 pud_t *pud;
29044 pmd_t *pmd;
29045
29046 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29047 + pgd += pgd_index(address);
29048 pud = pud_offset(pgd, address);
29049 pmd = pmd_offset(pud, address);
29050 set_pte_atomic((pte_t *)pmd, pte);
29051 }
29052 }
29053 #endif
29054 + pax_close_kernel();
29055 }
29056
29057 static int
29058 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29059 index 6574388..87e9bef 100644
29060 --- a/arch/x86/mm/pat.c
29061 +++ b/arch/x86/mm/pat.c
29062 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29063
29064 if (!entry) {
29065 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29066 - current->comm, current->pid, start, end - 1);
29067 + current->comm, task_pid_nr(current), start, end - 1);
29068 return -EINVAL;
29069 }
29070
29071 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29072
29073 while (cursor < to) {
29074 if (!devmem_is_allowed(pfn)) {
29075 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29076 - current->comm, from, to - 1);
29077 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29078 + current->comm, from, to - 1, cursor);
29079 return 0;
29080 }
29081 cursor += PAGE_SIZE;
29082 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29083 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29084 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29085 "for [mem %#010Lx-%#010Lx]\n",
29086 - current->comm, current->pid,
29087 + current->comm, task_pid_nr(current),
29088 cattr_name(flags),
29089 base, (unsigned long long)(base + size-1));
29090 return -EINVAL;
29091 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29092 flags = lookup_memtype(paddr);
29093 if (want_flags != flags) {
29094 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29095 - current->comm, current->pid,
29096 + current->comm, task_pid_nr(current),
29097 cattr_name(want_flags),
29098 (unsigned long long)paddr,
29099 (unsigned long long)(paddr + size - 1),
29100 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29101 free_memtype(paddr, paddr + size);
29102 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29103 " for [mem %#010Lx-%#010Lx], got %s\n",
29104 - current->comm, current->pid,
29105 + current->comm, task_pid_nr(current),
29106 cattr_name(want_flags),
29107 (unsigned long long)paddr,
29108 (unsigned long long)(paddr + size - 1),
29109 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29110 index 9f0614d..92ae64a 100644
29111 --- a/arch/x86/mm/pf_in.c
29112 +++ b/arch/x86/mm/pf_in.c
29113 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29114 int i;
29115 enum reason_type rv = OTHERS;
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
29122 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(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
29131 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29132 struct prefix_bits prf;
29133 int i;
29134
29135 - p = (unsigned char *)ins_addr;
29136 + p = (unsigned char *)ktla_ktva(ins_addr);
29137 p += skip_prefix(p, &prf);
29138 p += get_opcode(p, &opcode);
29139
29140 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29141 struct prefix_bits prf;
29142 int i;
29143
29144 - p = (unsigned char *)ins_addr;
29145 + p = (unsigned char *)ktla_ktva(ins_addr);
29146 p += skip_prefix(p, &prf);
29147 p += get_opcode(p, &opcode);
29148 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29149 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29150 struct prefix_bits prf;
29151 int i;
29152
29153 - p = (unsigned char *)ins_addr;
29154 + p = (unsigned char *)ktla_ktva(ins_addr);
29155 p += skip_prefix(p, &prf);
29156 p += get_opcode(p, &opcode);
29157 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29158 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29159 index 17fda6a..489c74a 100644
29160 --- a/arch/x86/mm/pgtable.c
29161 +++ b/arch/x86/mm/pgtable.c
29162 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29163 list_del(&page->lru);
29164 }
29165
29166 -#define UNSHARED_PTRS_PER_PGD \
29167 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29168 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29169 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29170
29171 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29172 +{
29173 + unsigned int count = USER_PGD_PTRS;
29174
29175 + while (count--)
29176 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29177 +}
29178 +#endif
29179 +
29180 +#ifdef CONFIG_PAX_PER_CPU_PGD
29181 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29182 +{
29183 + unsigned int count = USER_PGD_PTRS;
29184 +
29185 + while (count--) {
29186 + pgd_t pgd;
29187 +
29188 +#ifdef CONFIG_X86_64
29189 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29190 +#else
29191 + pgd = *src++;
29192 +#endif
29193 +
29194 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29195 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29196 +#endif
29197 +
29198 + *dst++ = pgd;
29199 + }
29200 +
29201 +}
29202 +#endif
29203 +
29204 +#ifdef CONFIG_X86_64
29205 +#define pxd_t pud_t
29206 +#define pyd_t pgd_t
29207 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29208 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29209 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29210 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29211 +#define PYD_SIZE PGDIR_SIZE
29212 +#else
29213 +#define pxd_t pmd_t
29214 +#define pyd_t pud_t
29215 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29216 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29217 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29218 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29219 +#define PYD_SIZE PUD_SIZE
29220 +#endif
29221 +
29222 +#ifdef CONFIG_PAX_PER_CPU_PGD
29223 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29224 +static inline void pgd_dtor(pgd_t *pgd) {}
29225 +#else
29226 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29227 {
29228 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29229 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29230 pgd_list_del(pgd);
29231 spin_unlock(&pgd_lock);
29232 }
29233 +#endif
29234
29235 /*
29236 * List of all pgd's needed for non-PAE so it can invalidate entries
29237 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29238 * -- nyc
29239 */
29240
29241 -#ifdef CONFIG_X86_PAE
29242 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29243 /*
29244 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29245 * updating the top-level pagetable entries to guarantee the
29246 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29247 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29248 * and initialize the kernel pmds here.
29249 */
29250 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29251 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29252
29253 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29254 {
29255 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29256 */
29257 flush_tlb_mm(mm);
29258 }
29259 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29260 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29261 #else /* !CONFIG_X86_PAE */
29262
29263 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29264 -#define PREALLOCATED_PMDS 0
29265 +#define PREALLOCATED_PXDS 0
29266
29267 #endif /* CONFIG_X86_PAE */
29268
29269 -static void free_pmds(pmd_t *pmds[])
29270 +static void free_pxds(pxd_t *pxds[])
29271 {
29272 int i;
29273
29274 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29275 - if (pmds[i])
29276 - free_page((unsigned long)pmds[i]);
29277 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29278 + if (pxds[i])
29279 + free_page((unsigned long)pxds[i]);
29280 }
29281
29282 -static int preallocate_pmds(pmd_t *pmds[])
29283 +static int preallocate_pxds(pxd_t *pxds[])
29284 {
29285 int i;
29286 bool failed = false;
29287
29288 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29289 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29290 - if (pmd == NULL)
29291 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29292 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29293 + if (pxd == NULL)
29294 failed = true;
29295 - pmds[i] = pmd;
29296 + pxds[i] = pxd;
29297 }
29298
29299 if (failed) {
29300 - free_pmds(pmds);
29301 + free_pxds(pxds);
29302 return -ENOMEM;
29303 }
29304
29305 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29306 * preallocate which never got a corresponding vma will need to be
29307 * freed manually.
29308 */
29309 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29310 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29311 {
29312 int i;
29313
29314 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29315 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29316 pgd_t pgd = pgdp[i];
29317
29318 if (pgd_val(pgd) != 0) {
29319 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29320 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29321
29322 - pgdp[i] = native_make_pgd(0);
29323 + set_pgd(pgdp + i, native_make_pgd(0));
29324
29325 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29326 - pmd_free(mm, pmd);
29327 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29328 + pxd_free(mm, pxd);
29329 }
29330 }
29331 }
29332
29333 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29334 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29335 {
29336 - pud_t *pud;
29337 + pyd_t *pyd;
29338 unsigned long addr;
29339 int i;
29340
29341 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29342 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29343 return;
29344
29345 - pud = pud_offset(pgd, 0);
29346 +#ifdef CONFIG_X86_64
29347 + pyd = pyd_offset(mm, 0L);
29348 +#else
29349 + pyd = pyd_offset(pgd, 0L);
29350 +#endif
29351
29352 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29353 - i++, pud++, addr += PUD_SIZE) {
29354 - pmd_t *pmd = pmds[i];
29355 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29356 + i++, pyd++, addr += PYD_SIZE) {
29357 + pxd_t *pxd = pxds[i];
29358
29359 if (i >= KERNEL_PGD_BOUNDARY)
29360 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29361 - sizeof(pmd_t) * PTRS_PER_PMD);
29362 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29363 + sizeof(pxd_t) * PTRS_PER_PMD);
29364
29365 - pud_populate(mm, pud, pmd);
29366 + pyd_populate(mm, pyd, pxd);
29367 }
29368 }
29369
29370 pgd_t *pgd_alloc(struct mm_struct *mm)
29371 {
29372 pgd_t *pgd;
29373 - pmd_t *pmds[PREALLOCATED_PMDS];
29374 + pxd_t *pxds[PREALLOCATED_PXDS];
29375
29376 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29377
29378 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29379
29380 mm->pgd = pgd;
29381
29382 - if (preallocate_pmds(pmds) != 0)
29383 + if (preallocate_pxds(pxds) != 0)
29384 goto out_free_pgd;
29385
29386 if (paravirt_pgd_alloc(mm) != 0)
29387 - goto out_free_pmds;
29388 + goto out_free_pxds;
29389
29390 /*
29391 * Make sure that pre-populating the pmds is atomic with
29392 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29393 spin_lock(&pgd_lock);
29394
29395 pgd_ctor(mm, pgd);
29396 - pgd_prepopulate_pmd(mm, pgd, pmds);
29397 + pgd_prepopulate_pxd(mm, pgd, pxds);
29398
29399 spin_unlock(&pgd_lock);
29400
29401 return pgd;
29402
29403 -out_free_pmds:
29404 - free_pmds(pmds);
29405 +out_free_pxds:
29406 + free_pxds(pxds);
29407 out_free_pgd:
29408 free_page((unsigned long)pgd);
29409 out:
29410 @@ -302,7 +363,7 @@ out:
29411
29412 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29413 {
29414 - pgd_mop_up_pmds(mm, pgd);
29415 + pgd_mop_up_pxds(mm, pgd);
29416 pgd_dtor(pgd);
29417 paravirt_pgd_free(mm, pgd);
29418 free_page((unsigned long)pgd);
29419 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29420 index a69bcb8..19068ab 100644
29421 --- a/arch/x86/mm/pgtable_32.c
29422 +++ b/arch/x86/mm/pgtable_32.c
29423 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29424 return;
29425 }
29426 pte = pte_offset_kernel(pmd, vaddr);
29427 +
29428 + pax_open_kernel();
29429 if (pte_val(pteval))
29430 set_pte_at(&init_mm, vaddr, pte, pteval);
29431 else
29432 pte_clear(&init_mm, vaddr, pte);
29433 + pax_close_kernel();
29434
29435 /*
29436 * It's enough to flush this one mapping.
29437 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29438 index e666cbb..61788c45 100644
29439 --- a/arch/x86/mm/physaddr.c
29440 +++ b/arch/x86/mm/physaddr.c
29441 @@ -10,7 +10,7 @@
29442 #ifdef CONFIG_X86_64
29443
29444 #ifdef CONFIG_DEBUG_VIRTUAL
29445 -unsigned long __phys_addr(unsigned long x)
29446 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29447 {
29448 unsigned long y = x - __START_KERNEL_map;
29449
29450 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29451 #else
29452
29453 #ifdef CONFIG_DEBUG_VIRTUAL
29454 -unsigned long __phys_addr(unsigned long x)
29455 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29456 {
29457 unsigned long phys_addr = x - PAGE_OFFSET;
29458 /* VMALLOC_* aren't constants */
29459 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29460 index 410531d..0f16030 100644
29461 --- a/arch/x86/mm/setup_nx.c
29462 +++ b/arch/x86/mm/setup_nx.c
29463 @@ -5,8 +5,10 @@
29464 #include <asm/pgtable.h>
29465 #include <asm/proto.h>
29466
29467 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29468 static int disable_nx __cpuinitdata;
29469
29470 +#ifndef CONFIG_PAX_PAGEEXEC
29471 /*
29472 * noexec = on|off
29473 *
29474 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29475 return 0;
29476 }
29477 early_param("noexec", noexec_setup);
29478 +#endif
29479 +
29480 +#endif
29481
29482 void __cpuinit x86_configure_nx(void)
29483 {
29484 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29485 if (cpu_has_nx && !disable_nx)
29486 __supported_pte_mask |= _PAGE_NX;
29487 else
29488 +#endif
29489 __supported_pte_mask &= ~_PAGE_NX;
29490 }
29491
29492 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29493 index 282375f..e03a98f 100644
29494 --- a/arch/x86/mm/tlb.c
29495 +++ b/arch/x86/mm/tlb.c
29496 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29497 BUG();
29498 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29499 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29500 +
29501 +#ifndef CONFIG_PAX_PER_CPU_PGD
29502 load_cr3(swapper_pg_dir);
29503 +#endif
29504 +
29505 }
29506 }
29507 EXPORT_SYMBOL_GPL(leave_mm);
29508 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29509 index 877b9a1..a8ecf42 100644
29510 --- a/arch/x86/net/bpf_jit.S
29511 +++ b/arch/x86/net/bpf_jit.S
29512 @@ -9,6 +9,7 @@
29513 */
29514 #include <linux/linkage.h>
29515 #include <asm/dwarf2.h>
29516 +#include <asm/alternative-asm.h>
29517
29518 /*
29519 * Calling convention :
29520 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29521 jle bpf_slow_path_word
29522 mov (SKBDATA,%rsi),%eax
29523 bswap %eax /* ntohl() */
29524 + pax_force_retaddr
29525 ret
29526
29527 sk_load_half:
29528 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29529 jle bpf_slow_path_half
29530 movzwl (SKBDATA,%rsi),%eax
29531 rol $8,%ax # ntohs()
29532 + pax_force_retaddr
29533 ret
29534
29535 sk_load_byte:
29536 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29537 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29538 jle bpf_slow_path_byte
29539 movzbl (SKBDATA,%rsi),%eax
29540 + pax_force_retaddr
29541 ret
29542
29543 /**
29544 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29545 movzbl (SKBDATA,%rsi),%ebx
29546 and $15,%bl
29547 shl $2,%bl
29548 + pax_force_retaddr
29549 ret
29550
29551 /* rsi contains offset and can be scratched */
29552 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29553 js bpf_error
29554 mov -12(%rbp),%eax
29555 bswap %eax
29556 + pax_force_retaddr
29557 ret
29558
29559 bpf_slow_path_half:
29560 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29561 mov -12(%rbp),%ax
29562 rol $8,%ax
29563 movzwl %ax,%eax
29564 + pax_force_retaddr
29565 ret
29566
29567 bpf_slow_path_byte:
29568 bpf_slow_path_common(1)
29569 js bpf_error
29570 movzbl -12(%rbp),%eax
29571 + pax_force_retaddr
29572 ret
29573
29574 bpf_slow_path_byte_msh:
29575 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29576 and $15,%al
29577 shl $2,%al
29578 xchg %eax,%ebx
29579 + pax_force_retaddr
29580 ret
29581
29582 #define sk_negative_common(SIZE) \
29583 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29584 sk_negative_common(4)
29585 mov (%rax), %eax
29586 bswap %eax
29587 + pax_force_retaddr
29588 ret
29589
29590 bpf_slow_path_half_neg:
29591 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29592 mov (%rax),%ax
29593 rol $8,%ax
29594 movzwl %ax,%eax
29595 + pax_force_retaddr
29596 ret
29597
29598 bpf_slow_path_byte_neg:
29599 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29600 .globl sk_load_byte_negative_offset
29601 sk_negative_common(1)
29602 movzbl (%rax), %eax
29603 + pax_force_retaddr
29604 ret
29605
29606 bpf_slow_path_byte_msh_neg:
29607 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29608 and $15,%al
29609 shl $2,%al
29610 xchg %eax,%ebx
29611 + pax_force_retaddr
29612 ret
29613
29614 bpf_error:
29615 @@ -197,4 +210,5 @@ bpf_error:
29616 xor %eax,%eax
29617 mov -8(%rbp),%rbx
29618 leaveq
29619 + pax_force_retaddr
29620 ret
29621 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29622 index 3cbe4538..003d011 100644
29623 --- a/arch/x86/net/bpf_jit_comp.c
29624 +++ b/arch/x86/net/bpf_jit_comp.c
29625 @@ -12,6 +12,7 @@
29626 #include <linux/netdevice.h>
29627 #include <linux/filter.h>
29628 #include <linux/if_vlan.h>
29629 +#include <linux/random.h>
29630
29631 /*
29632 * Conventions :
29633 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29634 return ptr + len;
29635 }
29636
29637 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29638 +#define MAX_INSTR_CODE_SIZE 96
29639 +#else
29640 +#define MAX_INSTR_CODE_SIZE 64
29641 +#endif
29642 +
29643 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29644
29645 #define EMIT1(b1) EMIT(b1, 1)
29646 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29647 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29648 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29649 +
29650 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29651 +/* original constant will appear in ecx */
29652 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29653 +do { \
29654 + /* mov ecx, randkey */ \
29655 + EMIT1(0xb9); \
29656 + EMIT(_key, 4); \
29657 + /* xor ecx, randkey ^ off */ \
29658 + EMIT2(0x81, 0xf1); \
29659 + EMIT((_key) ^ (_off), 4); \
29660 +} while (0)
29661 +
29662 +#define EMIT1_off32(b1, _off) \
29663 +do { \
29664 + switch (b1) { \
29665 + case 0x05: /* add eax, imm32 */ \
29666 + case 0x2d: /* sub eax, imm32 */ \
29667 + case 0x25: /* and eax, imm32 */ \
29668 + case 0x0d: /* or eax, imm32 */ \
29669 + case 0xb8: /* mov eax, imm32 */ \
29670 + case 0x35: /* xor eax, imm32 */ \
29671 + case 0x3d: /* cmp eax, imm32 */ \
29672 + case 0xa9: /* test eax, imm32 */ \
29673 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29674 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29675 + break; \
29676 + case 0xbb: /* mov ebx, imm32 */ \
29677 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29678 + /* mov ebx, ecx */ \
29679 + EMIT2(0x89, 0xcb); \
29680 + break; \
29681 + case 0xbe: /* mov esi, imm32 */ \
29682 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29683 + /* mov esi, ecx */ \
29684 + EMIT2(0x89, 0xce); \
29685 + break; \
29686 + case 0xe8: /* call rel imm32, always to known funcs */ \
29687 + EMIT1(b1); \
29688 + EMIT(_off, 4); \
29689 + break; \
29690 + case 0xe9: /* jmp rel imm32 */ \
29691 + EMIT1(b1); \
29692 + EMIT(_off, 4); \
29693 + /* prevent fall-through, we're not called if off = 0 */ \
29694 + EMIT(0xcccccccc, 4); \
29695 + EMIT(0xcccccccc, 4); \
29696 + break; \
29697 + default: \
29698 + BUILD_BUG(); \
29699 + } \
29700 +} while (0)
29701 +
29702 +#define EMIT2_off32(b1, b2, _off) \
29703 +do { \
29704 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29705 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29706 + EMIT(randkey, 4); \
29707 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29708 + EMIT((_off) - randkey, 4); \
29709 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29710 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29711 + /* imul eax, ecx */ \
29712 + EMIT3(0x0f, 0xaf, 0xc1); \
29713 + } else { \
29714 + BUILD_BUG(); \
29715 + } \
29716 +} while (0)
29717 +#else
29718 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29719 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29720 +#endif
29721
29722 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29723 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29724 @@ -90,6 +168,24 @@ do { \
29725 #define X86_JBE 0x76
29726 #define X86_JA 0x77
29727
29728 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29729 +#define APPEND_FLOW_VERIFY() \
29730 +do { \
29731 + /* mov ecx, randkey */ \
29732 + EMIT1(0xb9); \
29733 + EMIT(randkey, 4); \
29734 + /* cmp ecx, randkey */ \
29735 + EMIT2(0x81, 0xf9); \
29736 + EMIT(randkey, 4); \
29737 + /* jz after 8 int 3s */ \
29738 + EMIT2(0x74, 0x08); \
29739 + EMIT(0xcccccccc, 4); \
29740 + EMIT(0xcccccccc, 4); \
29741 +} while (0)
29742 +#else
29743 +#define APPEND_FLOW_VERIFY() do { } while (0)
29744 +#endif
29745 +
29746 #define EMIT_COND_JMP(op, offset) \
29747 do { \
29748 if (is_near(offset)) \
29749 @@ -97,6 +193,7 @@ do { \
29750 else { \
29751 EMIT2(0x0f, op + 0x10); \
29752 EMIT(offset, 4); /* jxx .+off32 */ \
29753 + APPEND_FLOW_VERIFY(); \
29754 } \
29755 } while (0)
29756
29757 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29758 set_fs(old_fs);
29759 }
29760
29761 +struct bpf_jit_work {
29762 + struct work_struct work;
29763 + void *image;
29764 +};
29765 +
29766 #define CHOOSE_LOAD_FUNC(K, func) \
29767 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29768
29769 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29770
29771 void bpf_jit_compile(struct sk_filter *fp)
29772 {
29773 - u8 temp[64];
29774 + u8 temp[MAX_INSTR_CODE_SIZE];
29775 u8 *prog;
29776 unsigned int proglen, oldproglen = 0;
29777 int ilen, i;
29778 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29779 unsigned int *addrs;
29780 const struct sock_filter *filter = fp->insns;
29781 int flen = fp->len;
29782 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29783 + unsigned int randkey;
29784 +#endif
29785
29786 if (!bpf_jit_enable)
29787 return;
29788 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29789 if (addrs == NULL)
29790 return;
29791
29792 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29793 + if (!fp->work)
29794 + goto out;
29795 +
29796 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29797 + randkey = get_random_int();
29798 +#endif
29799 +
29800 /* Before first pass, make a rough estimation of addrs[]
29801 - * each bpf instruction is translated to less than 64 bytes
29802 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29803 */
29804 for (proglen = 0, i = 0; i < flen; i++) {
29805 - proglen += 64;
29806 + proglen += MAX_INSTR_CODE_SIZE;
29807 addrs[i] = proglen;
29808 }
29809 cleanup_addr = proglen; /* epilogue address */
29810 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29811 case BPF_S_ALU_MUL_K: /* A *= K */
29812 if (is_imm8(K))
29813 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29814 - else {
29815 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29816 - EMIT(K, 4);
29817 - }
29818 + else
29819 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29820 break;
29821 case BPF_S_ALU_DIV_X: /* A /= X; */
29822 seen |= SEEN_XREG;
29823 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29824 break;
29825 case BPF_S_ALU_MOD_K: /* A %= K; */
29826 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29827 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29828 + DILUTE_CONST_SEQUENCE(K, randkey);
29829 +#else
29830 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29831 +#endif
29832 EMIT2(0xf7, 0xf1); /* div %ecx */
29833 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29834 break;
29835 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29836 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29837 + DILUTE_CONST_SEQUENCE(K, randkey);
29838 + // imul rax, rcx
29839 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29840 +#else
29841 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29842 EMIT(K, 4);
29843 +#endif
29844 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29845 break;
29846 case BPF_S_ALU_AND_X:
29847 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29848 if (is_imm8(K)) {
29849 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29850 } else {
29851 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29852 - EMIT(K, 4);
29853 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29854 }
29855 } else {
29856 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29857 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29858 break;
29859 default:
29860 /* hmm, too complex filter, give up with jit compiler */
29861 - goto out;
29862 + goto error;
29863 }
29864 ilen = prog - temp;
29865 if (image) {
29866 if (unlikely(proglen + ilen > oldproglen)) {
29867 pr_err("bpb_jit_compile fatal error\n");
29868 - kfree(addrs);
29869 - module_free(NULL, image);
29870 - return;
29871 + module_free_exec(NULL, image);
29872 + goto error;
29873 }
29874 + pax_open_kernel();
29875 memcpy(image + proglen, temp, ilen);
29876 + pax_close_kernel();
29877 }
29878 proglen += ilen;
29879 addrs[i] = proglen;
29880 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29881 break;
29882 }
29883 if (proglen == oldproglen) {
29884 - image = module_alloc(max_t(unsigned int,
29885 - proglen,
29886 - sizeof(struct work_struct)));
29887 + image = module_alloc_exec(proglen);
29888 if (!image)
29889 - goto out;
29890 + goto error;
29891 }
29892 oldproglen = proglen;
29893 }
29894 @@ -737,7 +856,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29895 bpf_flush_icache(image, image + proglen);
29896
29897 fp->bpf_func = (void *)image;
29898 - }
29899 + } else
29900 +error:
29901 + kfree(fp->work);
29902 +
29903 out:
29904 kfree(addrs);
29905 return;
29906 @@ -745,18 +867,20 @@ out:
29907
29908 static void jit_free_defer(struct work_struct *arg)
29909 {
29910 - module_free(NULL, arg);
29911 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29912 + kfree(arg);
29913 }
29914
29915 /* run from softirq, we must use a work_struct to call
29916 - * module_free() from process context
29917 + * module_free_exec() from process context
29918 */
29919 void bpf_jit_free(struct sk_filter *fp)
29920 {
29921 if (fp->bpf_func != sk_run_filter) {
29922 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29923 + struct work_struct *work = &fp->work->work;
29924
29925 INIT_WORK(work, jit_free_defer);
29926 + fp->work->image = fp->bpf_func;
29927 schedule_work(work);
29928 }
29929 }
29930 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29931 index d6aa6e8..266395a 100644
29932 --- a/arch/x86/oprofile/backtrace.c
29933 +++ b/arch/x86/oprofile/backtrace.c
29934 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29935 struct stack_frame_ia32 *fp;
29936 unsigned long bytes;
29937
29938 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29939 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29940 if (bytes != sizeof(bufhead))
29941 return NULL;
29942
29943 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29944 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29945
29946 oprofile_add_trace(bufhead[0].return_address);
29947
29948 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29949 struct stack_frame bufhead[2];
29950 unsigned long bytes;
29951
29952 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29953 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29954 if (bytes != sizeof(bufhead))
29955 return NULL;
29956
29957 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29958 {
29959 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29960
29961 - if (!user_mode_vm(regs)) {
29962 + if (!user_mode(regs)) {
29963 unsigned long stack = kernel_stack_pointer(regs);
29964 if (depth)
29965 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29966 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29967 index 48768df..ba9143c 100644
29968 --- a/arch/x86/oprofile/nmi_int.c
29969 +++ b/arch/x86/oprofile/nmi_int.c
29970 @@ -23,6 +23,7 @@
29971 #include <asm/nmi.h>
29972 #include <asm/msr.h>
29973 #include <asm/apic.h>
29974 +#include <asm/pgtable.h>
29975
29976 #include "op_counter.h"
29977 #include "op_x86_model.h"
29978 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29979 if (ret)
29980 return ret;
29981
29982 - if (!model->num_virt_counters)
29983 - model->num_virt_counters = model->num_counters;
29984 + if (!model->num_virt_counters) {
29985 + pax_open_kernel();
29986 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29987 + pax_close_kernel();
29988 + }
29989
29990 mux_init(ops);
29991
29992 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29993 index b2b9443..be58856 100644
29994 --- a/arch/x86/oprofile/op_model_amd.c
29995 +++ b/arch/x86/oprofile/op_model_amd.c
29996 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29997 num_counters = AMD64_NUM_COUNTERS;
29998 }
29999
30000 - op_amd_spec.num_counters = num_counters;
30001 - op_amd_spec.num_controls = num_counters;
30002 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30003 + pax_open_kernel();
30004 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30005 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30006 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30007 + pax_close_kernel();
30008
30009 return 0;
30010 }
30011 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30012 index d90528e..0127e2b 100644
30013 --- a/arch/x86/oprofile/op_model_ppro.c
30014 +++ b/arch/x86/oprofile/op_model_ppro.c
30015 @@ -19,6 +19,7 @@
30016 #include <asm/msr.h>
30017 #include <asm/apic.h>
30018 #include <asm/nmi.h>
30019 +#include <asm/pgtable.h>
30020
30021 #include "op_x86_model.h"
30022 #include "op_counter.h"
30023 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30024
30025 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30026
30027 - op_arch_perfmon_spec.num_counters = num_counters;
30028 - op_arch_perfmon_spec.num_controls = num_counters;
30029 + pax_open_kernel();
30030 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30031 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30032 + pax_close_kernel();
30033 }
30034
30035 static int arch_perfmon_init(struct oprofile_operations *ignore)
30036 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30037 index 71e8a67..6a313bb 100644
30038 --- a/arch/x86/oprofile/op_x86_model.h
30039 +++ b/arch/x86/oprofile/op_x86_model.h
30040 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30041 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30042 struct op_msrs const * const msrs);
30043 #endif
30044 -};
30045 +} __do_const;
30046
30047 struct op_counter_config;
30048
30049 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30050 index e9e6ed5..e47ae67 100644
30051 --- a/arch/x86/pci/amd_bus.c
30052 +++ b/arch/x86/pci/amd_bus.c
30053 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30054 return NOTIFY_OK;
30055 }
30056
30057 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30058 +static struct notifier_block amd_cpu_notifier = {
30059 .notifier_call = amd_cpu_notify,
30060 };
30061
30062 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30063 index 372e9b8..e775a6c 100644
30064 --- a/arch/x86/pci/irq.c
30065 +++ b/arch/x86/pci/irq.c
30066 @@ -50,7 +50,7 @@ struct irq_router {
30067 struct irq_router_handler {
30068 u16 vendor;
30069 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30070 -};
30071 +} __do_const;
30072
30073 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30074 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30075 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30076 return 0;
30077 }
30078
30079 -static __initdata struct irq_router_handler pirq_routers[] = {
30080 +static __initconst const struct irq_router_handler pirq_routers[] = {
30081 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30082 { PCI_VENDOR_ID_AL, ali_router_probe },
30083 { PCI_VENDOR_ID_ITE, ite_router_probe },
30084 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30085 static void __init pirq_find_router(struct irq_router *r)
30086 {
30087 struct irq_routing_table *rt = pirq_table;
30088 - struct irq_router_handler *h;
30089 + const struct irq_router_handler *h;
30090
30091 #ifdef CONFIG_PCI_BIOS
30092 if (!rt->signature) {
30093 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30094 return 0;
30095 }
30096
30097 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30098 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30099 {
30100 .callback = fix_broken_hp_bios_irq9,
30101 .ident = "HP Pavilion N5400 Series Laptop",
30102 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30103 index 6eb18c4..20d83de 100644
30104 --- a/arch/x86/pci/mrst.c
30105 +++ b/arch/x86/pci/mrst.c
30106 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30107 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30108 pci_mmcfg_late_init();
30109 pcibios_enable_irq = mrst_pci_irq_enable;
30110 - pci_root_ops = pci_mrst_ops;
30111 + pax_open_kernel();
30112 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30113 + pax_close_kernel();
30114 pci_soc_mode = 1;
30115 /* Continue with standard init */
30116 return 1;
30117 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30118 index c77b24a..c979855 100644
30119 --- a/arch/x86/pci/pcbios.c
30120 +++ b/arch/x86/pci/pcbios.c
30121 @@ -79,7 +79,7 @@ union bios32 {
30122 static struct {
30123 unsigned long address;
30124 unsigned short segment;
30125 -} bios32_indirect = { 0, __KERNEL_CS };
30126 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30127
30128 /*
30129 * Returns the entry point for the given service, NULL on error
30130 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30131 unsigned long length; /* %ecx */
30132 unsigned long entry; /* %edx */
30133 unsigned long flags;
30134 + struct desc_struct d, *gdt;
30135
30136 local_irq_save(flags);
30137 - __asm__("lcall *(%%edi); cld"
30138 +
30139 + gdt = get_cpu_gdt_table(smp_processor_id());
30140 +
30141 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30142 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30143 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30144 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30145 +
30146 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30147 : "=a" (return_code),
30148 "=b" (address),
30149 "=c" (length),
30150 "=d" (entry)
30151 : "0" (service),
30152 "1" (0),
30153 - "D" (&bios32_indirect));
30154 + "D" (&bios32_indirect),
30155 + "r"(__PCIBIOS_DS)
30156 + : "memory");
30157 +
30158 + pax_open_kernel();
30159 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30160 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30161 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30162 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30163 + pax_close_kernel();
30164 +
30165 local_irq_restore(flags);
30166
30167 switch (return_code) {
30168 - case 0:
30169 - return address + entry;
30170 - case 0x80: /* Not present */
30171 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30172 - return 0;
30173 - default: /* Shouldn't happen */
30174 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30175 - service, return_code);
30176 + case 0: {
30177 + int cpu;
30178 + unsigned char flags;
30179 +
30180 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30181 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30182 + printk(KERN_WARNING "bios32_service: not valid\n");
30183 return 0;
30184 + }
30185 + address = address + PAGE_OFFSET;
30186 + length += 16UL; /* some BIOSs underreport this... */
30187 + flags = 4;
30188 + if (length >= 64*1024*1024) {
30189 + length >>= PAGE_SHIFT;
30190 + flags |= 8;
30191 + }
30192 +
30193 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30194 + gdt = get_cpu_gdt_table(cpu);
30195 + pack_descriptor(&d, address, length, 0x9b, flags);
30196 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30197 + pack_descriptor(&d, address, length, 0x93, flags);
30198 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30199 + }
30200 + return entry;
30201 + }
30202 + case 0x80: /* Not present */
30203 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30204 + return 0;
30205 + default: /* Shouldn't happen */
30206 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30207 + service, return_code);
30208 + return 0;
30209 }
30210 }
30211
30212 static struct {
30213 unsigned long address;
30214 unsigned short segment;
30215 -} pci_indirect = { 0, __KERNEL_CS };
30216 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30217
30218 -static int pci_bios_present;
30219 +static int pci_bios_present __read_only;
30220
30221 static int check_pcibios(void)
30222 {
30223 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30224 unsigned long flags, pcibios_entry;
30225
30226 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30227 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30228 + pci_indirect.address = pcibios_entry;
30229
30230 local_irq_save(flags);
30231 - __asm__(
30232 - "lcall *(%%edi); cld\n\t"
30233 + __asm__("movw %w6, %%ds\n\t"
30234 + "lcall *%%ss:(%%edi); cld\n\t"
30235 + "push %%ss\n\t"
30236 + "pop %%ds\n\t"
30237 "jc 1f\n\t"
30238 "xor %%ah, %%ah\n"
30239 "1:"
30240 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30241 "=b" (ebx),
30242 "=c" (ecx)
30243 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30244 - "D" (&pci_indirect)
30245 + "D" (&pci_indirect),
30246 + "r" (__PCIBIOS_DS)
30247 : "memory");
30248 local_irq_restore(flags);
30249
30250 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30251
30252 switch (len) {
30253 case 1:
30254 - __asm__("lcall *(%%esi); cld\n\t"
30255 + __asm__("movw %w6, %%ds\n\t"
30256 + "lcall *%%ss:(%%esi); cld\n\t"
30257 + "push %%ss\n\t"
30258 + "pop %%ds\n\t"
30259 "jc 1f\n\t"
30260 "xor %%ah, %%ah\n"
30261 "1:"
30262 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30263 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30264 "b" (bx),
30265 "D" ((long)reg),
30266 - "S" (&pci_indirect));
30267 + "S" (&pci_indirect),
30268 + "r" (__PCIBIOS_DS));
30269 /*
30270 * Zero-extend the result beyond 8 bits, do not trust the
30271 * BIOS having done it:
30272 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30273 *value &= 0xff;
30274 break;
30275 case 2:
30276 - __asm__("lcall *(%%esi); cld\n\t"
30277 + __asm__("movw %w6, %%ds\n\t"
30278 + "lcall *%%ss:(%%esi); cld\n\t"
30279 + "push %%ss\n\t"
30280 + "pop %%ds\n\t"
30281 "jc 1f\n\t"
30282 "xor %%ah, %%ah\n"
30283 "1:"
30284 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30285 : "1" (PCIBIOS_READ_CONFIG_WORD),
30286 "b" (bx),
30287 "D" ((long)reg),
30288 - "S" (&pci_indirect));
30289 + "S" (&pci_indirect),
30290 + "r" (__PCIBIOS_DS));
30291 /*
30292 * Zero-extend the result beyond 16 bits, do not trust the
30293 * BIOS having done it:
30294 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30295 *value &= 0xffff;
30296 break;
30297 case 4:
30298 - __asm__("lcall *(%%esi); cld\n\t"
30299 + __asm__("movw %w6, %%ds\n\t"
30300 + "lcall *%%ss:(%%esi); cld\n\t"
30301 + "push %%ss\n\t"
30302 + "pop %%ds\n\t"
30303 "jc 1f\n\t"
30304 "xor %%ah, %%ah\n"
30305 "1:"
30306 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30307 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30308 "b" (bx),
30309 "D" ((long)reg),
30310 - "S" (&pci_indirect));
30311 + "S" (&pci_indirect),
30312 + "r" (__PCIBIOS_DS));
30313 break;
30314 }
30315
30316 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30317
30318 switch (len) {
30319 case 1:
30320 - __asm__("lcall *(%%esi); cld\n\t"
30321 + __asm__("movw %w6, %%ds\n\t"
30322 + "lcall *%%ss:(%%esi); cld\n\t"
30323 + "push %%ss\n\t"
30324 + "pop %%ds\n\t"
30325 "jc 1f\n\t"
30326 "xor %%ah, %%ah\n"
30327 "1:"
30328 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30329 "c" (value),
30330 "b" (bx),
30331 "D" ((long)reg),
30332 - "S" (&pci_indirect));
30333 + "S" (&pci_indirect),
30334 + "r" (__PCIBIOS_DS));
30335 break;
30336 case 2:
30337 - __asm__("lcall *(%%esi); cld\n\t"
30338 + __asm__("movw %w6, %%ds\n\t"
30339 + "lcall *%%ss:(%%esi); cld\n\t"
30340 + "push %%ss\n\t"
30341 + "pop %%ds\n\t"
30342 "jc 1f\n\t"
30343 "xor %%ah, %%ah\n"
30344 "1:"
30345 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30346 "c" (value),
30347 "b" (bx),
30348 "D" ((long)reg),
30349 - "S" (&pci_indirect));
30350 + "S" (&pci_indirect),
30351 + "r" (__PCIBIOS_DS));
30352 break;
30353 case 4:
30354 - __asm__("lcall *(%%esi); cld\n\t"
30355 + __asm__("movw %w6, %%ds\n\t"
30356 + "lcall *%%ss:(%%esi); cld\n\t"
30357 + "push %%ss\n\t"
30358 + "pop %%ds\n\t"
30359 "jc 1f\n\t"
30360 "xor %%ah, %%ah\n"
30361 "1:"
30362 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30363 "c" (value),
30364 "b" (bx),
30365 "D" ((long)reg),
30366 - "S" (&pci_indirect));
30367 + "S" (&pci_indirect),
30368 + "r" (__PCIBIOS_DS));
30369 break;
30370 }
30371
30372 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30373
30374 DBG("PCI: Fetching IRQ routing table... ");
30375 __asm__("push %%es\n\t"
30376 + "movw %w8, %%ds\n\t"
30377 "push %%ds\n\t"
30378 "pop %%es\n\t"
30379 - "lcall *(%%esi); cld\n\t"
30380 + "lcall *%%ss:(%%esi); cld\n\t"
30381 "pop %%es\n\t"
30382 + "push %%ss\n\t"
30383 + "pop %%ds\n"
30384 "jc 1f\n\t"
30385 "xor %%ah, %%ah\n"
30386 "1:"
30387 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30388 "1" (0),
30389 "D" ((long) &opt),
30390 "S" (&pci_indirect),
30391 - "m" (opt)
30392 + "m" (opt),
30393 + "r" (__PCIBIOS_DS)
30394 : "memory");
30395 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30396 if (ret & 0xff00)
30397 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30398 {
30399 int ret;
30400
30401 - __asm__("lcall *(%%esi); cld\n\t"
30402 + __asm__("movw %w5, %%ds\n\t"
30403 + "lcall *%%ss:(%%esi); cld\n\t"
30404 + "push %%ss\n\t"
30405 + "pop %%ds\n"
30406 "jc 1f\n\t"
30407 "xor %%ah, %%ah\n"
30408 "1:"
30409 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30410 : "0" (PCIBIOS_SET_PCI_HW_INT),
30411 "b" ((dev->bus->number << 8) | dev->devfn),
30412 "c" ((irq << 8) | (pin + 10)),
30413 - "S" (&pci_indirect));
30414 + "S" (&pci_indirect),
30415 + "r" (__PCIBIOS_DS));
30416 return !(ret & 0xff00);
30417 }
30418 EXPORT_SYMBOL(pcibios_set_irq_routing);
30419 diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
30420 index 90f3a52..714e825 100644
30421 --- a/arch/x86/platform/efi/efi.c
30422 +++ b/arch/x86/platform/efi/efi.c
30423 @@ -1059,7 +1059,10 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
30424 * that by attempting to use more space than is available.
30425 */
30426 unsigned long dummy_size = remaining_size + 1024;
30427 - void *dummy = kmalloc(dummy_size, GFP_ATOMIC);
30428 + void *dummy = kzalloc(dummy_size, GFP_ATOMIC);
30429 +
30430 + if (!dummy)
30431 + return EFI_OUT_OF_RESOURCES;
30432
30433 status = efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID,
30434 EFI_VARIABLE_NON_VOLATILE |
30435 @@ -1079,6 +1082,8 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
30436 0, dummy);
30437 }
30438
30439 + kfree(dummy);
30440 +
30441 /*
30442 * The runtime code may now have triggered a garbage collection
30443 * run, so check the variable info again
30444 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30445 index 40e4469..1ab536e 100644
30446 --- a/arch/x86/platform/efi/efi_32.c
30447 +++ b/arch/x86/platform/efi/efi_32.c
30448 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30449 {
30450 struct desc_ptr gdt_descr;
30451
30452 +#ifdef CONFIG_PAX_KERNEXEC
30453 + struct desc_struct d;
30454 +#endif
30455 +
30456 local_irq_save(efi_rt_eflags);
30457
30458 load_cr3(initial_page_table);
30459 __flush_tlb_all();
30460
30461 +#ifdef CONFIG_PAX_KERNEXEC
30462 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30463 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30464 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30465 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30466 +#endif
30467 +
30468 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30469 gdt_descr.size = GDT_SIZE - 1;
30470 load_gdt(&gdt_descr);
30471 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30472 {
30473 struct desc_ptr gdt_descr;
30474
30475 +#ifdef CONFIG_PAX_KERNEXEC
30476 + struct desc_struct d;
30477 +
30478 + memset(&d, 0, sizeof d);
30479 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30480 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30481 +#endif
30482 +
30483 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30484 gdt_descr.size = GDT_SIZE - 1;
30485 load_gdt(&gdt_descr);
30486 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30487 index fbe66e6..eae5e38 100644
30488 --- a/arch/x86/platform/efi/efi_stub_32.S
30489 +++ b/arch/x86/platform/efi/efi_stub_32.S
30490 @@ -6,7 +6,9 @@
30491 */
30492
30493 #include <linux/linkage.h>
30494 +#include <linux/init.h>
30495 #include <asm/page_types.h>
30496 +#include <asm/segment.h>
30497
30498 /*
30499 * efi_call_phys(void *, ...) is a function with variable parameters.
30500 @@ -20,7 +22,7 @@
30501 * service functions will comply with gcc calling convention, too.
30502 */
30503
30504 -.text
30505 +__INIT
30506 ENTRY(efi_call_phys)
30507 /*
30508 * 0. The function can only be called in Linux kernel. So CS has been
30509 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30510 * The mapping of lower virtual memory has been created in prelog and
30511 * epilog.
30512 */
30513 - movl $1f, %edx
30514 - subl $__PAGE_OFFSET, %edx
30515 - jmp *%edx
30516 +#ifdef CONFIG_PAX_KERNEXEC
30517 + movl $(__KERNEXEC_EFI_DS), %edx
30518 + mov %edx, %ds
30519 + mov %edx, %es
30520 + mov %edx, %ss
30521 + addl $2f,(1f)
30522 + ljmp *(1f)
30523 +
30524 +__INITDATA
30525 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30526 +.previous
30527 +
30528 +2:
30529 + subl $2b,(1b)
30530 +#else
30531 + jmp 1f-__PAGE_OFFSET
30532 1:
30533 +#endif
30534
30535 /*
30536 * 2. Now on the top of stack is the return
30537 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30538 * parameter 2, ..., param n. To make things easy, we save the return
30539 * address of efi_call_phys in a global variable.
30540 */
30541 - popl %edx
30542 - movl %edx, saved_return_addr
30543 - /* get the function pointer into ECX*/
30544 - popl %ecx
30545 - movl %ecx, efi_rt_function_ptr
30546 - movl $2f, %edx
30547 - subl $__PAGE_OFFSET, %edx
30548 - pushl %edx
30549 + popl (saved_return_addr)
30550 + popl (efi_rt_function_ptr)
30551
30552 /*
30553 * 3. Clear PG bit in %CR0.
30554 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30555 /*
30556 * 5. Call the physical function.
30557 */
30558 - jmp *%ecx
30559 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30560
30561 -2:
30562 /*
30563 * 6. After EFI runtime service returns, control will return to
30564 * following instruction. We'd better readjust stack pointer first.
30565 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30566 movl %cr0, %edx
30567 orl $0x80000000, %edx
30568 movl %edx, %cr0
30569 - jmp 1f
30570 -1:
30571 +
30572 /*
30573 * 8. Now restore the virtual mode from flat mode by
30574 * adding EIP with PAGE_OFFSET.
30575 */
30576 - movl $1f, %edx
30577 - jmp *%edx
30578 +#ifdef CONFIG_PAX_KERNEXEC
30579 + movl $(__KERNEL_DS), %edx
30580 + mov %edx, %ds
30581 + mov %edx, %es
30582 + mov %edx, %ss
30583 + ljmp $(__KERNEL_CS),$1f
30584 +#else
30585 + jmp 1f+__PAGE_OFFSET
30586 +#endif
30587 1:
30588
30589 /*
30590 * 9. Balance the stack. And because EAX contain the return value,
30591 * we'd better not clobber it.
30592 */
30593 - leal efi_rt_function_ptr, %edx
30594 - movl (%edx), %ecx
30595 - pushl %ecx
30596 + pushl (efi_rt_function_ptr)
30597
30598 /*
30599 - * 10. Push the saved return address onto the stack and return.
30600 + * 10. Return to the saved return address.
30601 */
30602 - leal saved_return_addr, %edx
30603 - movl (%edx), %ecx
30604 - pushl %ecx
30605 - ret
30606 + jmpl *(saved_return_addr)
30607 ENDPROC(efi_call_phys)
30608 .previous
30609
30610 -.data
30611 +__INITDATA
30612 saved_return_addr:
30613 .long 0
30614 efi_rt_function_ptr:
30615 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30616 index 4c07cca..2c8427d 100644
30617 --- a/arch/x86/platform/efi/efi_stub_64.S
30618 +++ b/arch/x86/platform/efi/efi_stub_64.S
30619 @@ -7,6 +7,7 @@
30620 */
30621
30622 #include <linux/linkage.h>
30623 +#include <asm/alternative-asm.h>
30624
30625 #define SAVE_XMM \
30626 mov %rsp, %rax; \
30627 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30628 call *%rdi
30629 addq $32, %rsp
30630 RESTORE_XMM
30631 + pax_force_retaddr 0, 1
30632 ret
30633 ENDPROC(efi_call0)
30634
30635 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30636 call *%rdi
30637 addq $32, %rsp
30638 RESTORE_XMM
30639 + pax_force_retaddr 0, 1
30640 ret
30641 ENDPROC(efi_call1)
30642
30643 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30644 call *%rdi
30645 addq $32, %rsp
30646 RESTORE_XMM
30647 + pax_force_retaddr 0, 1
30648 ret
30649 ENDPROC(efi_call2)
30650
30651 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30652 call *%rdi
30653 addq $32, %rsp
30654 RESTORE_XMM
30655 + pax_force_retaddr 0, 1
30656 ret
30657 ENDPROC(efi_call3)
30658
30659 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30660 call *%rdi
30661 addq $32, %rsp
30662 RESTORE_XMM
30663 + pax_force_retaddr 0, 1
30664 ret
30665 ENDPROC(efi_call4)
30666
30667 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30668 call *%rdi
30669 addq $48, %rsp
30670 RESTORE_XMM
30671 + pax_force_retaddr 0, 1
30672 ret
30673 ENDPROC(efi_call5)
30674
30675 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30676 call *%rdi
30677 addq $48, %rsp
30678 RESTORE_XMM
30679 + pax_force_retaddr 0, 1
30680 ret
30681 ENDPROC(efi_call6)
30682 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30683 index e31bcd8..f12dc46 100644
30684 --- a/arch/x86/platform/mrst/mrst.c
30685 +++ b/arch/x86/platform/mrst/mrst.c
30686 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30687 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30688 int sfi_mrtc_num;
30689
30690 -static void mrst_power_off(void)
30691 +static __noreturn void mrst_power_off(void)
30692 {
30693 + BUG();
30694 }
30695
30696 -static void mrst_reboot(void)
30697 +static __noreturn void mrst_reboot(void)
30698 {
30699 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30700 + BUG();
30701 }
30702
30703 /* parse all the mtimer info to a static mtimer array */
30704 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30705 index d6ee929..3637cb5 100644
30706 --- a/arch/x86/platform/olpc/olpc_dt.c
30707 +++ b/arch/x86/platform/olpc/olpc_dt.c
30708 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30709 return res;
30710 }
30711
30712 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30713 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30714 .nextprop = olpc_dt_nextprop,
30715 .getproplen = olpc_dt_getproplen,
30716 .getproperty = olpc_dt_getproperty,
30717 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30718 index 3c68768..07e82b8 100644
30719 --- a/arch/x86/power/cpu.c
30720 +++ b/arch/x86/power/cpu.c
30721 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30722 static void fix_processor_context(void)
30723 {
30724 int cpu = smp_processor_id();
30725 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30726 + struct tss_struct *t = init_tss + cpu;
30727
30728 set_tss_desc(cpu, t); /*
30729 * This just modifies memory; should not be
30730 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30731 */
30732
30733 #ifdef CONFIG_X86_64
30734 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30735 -
30736 syscall_init(); /* This sets MSR_*STAR and related */
30737 #endif
30738 load_TR_desc(); /* This does ltr */
30739 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30740 index a44f457..9140171 100644
30741 --- a/arch/x86/realmode/init.c
30742 +++ b/arch/x86/realmode/init.c
30743 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30744 __va(real_mode_header->trampoline_header);
30745
30746 #ifdef CONFIG_X86_32
30747 - trampoline_header->start = __pa_symbol(startup_32_smp);
30748 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30749 +
30750 +#ifdef CONFIG_PAX_KERNEXEC
30751 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30752 +#endif
30753 +
30754 + trampoline_header->boot_cs = __BOOT_CS;
30755 trampoline_header->gdt_limit = __BOOT_DS + 7;
30756 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30757 #else
30758 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30759 *trampoline_cr4_features = read_cr4();
30760
30761 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30762 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30763 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30764 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30765 #endif
30766 }
30767 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30768 index 8869287..d577672 100644
30769 --- a/arch/x86/realmode/rm/Makefile
30770 +++ b/arch/x86/realmode/rm/Makefile
30771 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30772 $(call cc-option, -fno-unit-at-a-time)) \
30773 $(call cc-option, -fno-stack-protector) \
30774 $(call cc-option, -mpreferred-stack-boundary=2)
30775 +ifdef CONSTIFY_PLUGIN
30776 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30777 +endif
30778 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30779 GCOV_PROFILE := n
30780 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30781 index a28221d..93c40f1 100644
30782 --- a/arch/x86/realmode/rm/header.S
30783 +++ b/arch/x86/realmode/rm/header.S
30784 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30785 #endif
30786 /* APM/BIOS reboot */
30787 .long pa_machine_real_restart_asm
30788 -#ifdef CONFIG_X86_64
30789 +#ifdef CONFIG_X86_32
30790 + .long __KERNEL_CS
30791 +#else
30792 .long __KERNEL32_CS
30793 #endif
30794 END(real_mode_header)
30795 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30796 index c1b2791..f9e31c7 100644
30797 --- a/arch/x86/realmode/rm/trampoline_32.S
30798 +++ b/arch/x86/realmode/rm/trampoline_32.S
30799 @@ -25,6 +25,12 @@
30800 #include <asm/page_types.h>
30801 #include "realmode.h"
30802
30803 +#ifdef CONFIG_PAX_KERNEXEC
30804 +#define ta(X) (X)
30805 +#else
30806 +#define ta(X) (pa_ ## X)
30807 +#endif
30808 +
30809 .text
30810 .code16
30811
30812 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30813
30814 cli # We should be safe anyway
30815
30816 - movl tr_start, %eax # where we need to go
30817 -
30818 movl $0xA5A5A5A5, trampoline_status
30819 # write marker for master knows we're running
30820
30821 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30822 movw $1, %dx # protected mode (PE) bit
30823 lmsw %dx # into protected mode
30824
30825 - ljmpl $__BOOT_CS, $pa_startup_32
30826 + ljmpl *(trampoline_header)
30827
30828 .section ".text32","ax"
30829 .code32
30830 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30831 .balign 8
30832 GLOBAL(trampoline_header)
30833 tr_start: .space 4
30834 - tr_gdt_pad: .space 2
30835 + tr_boot_cs: .space 2
30836 tr_gdt: .space 6
30837 END(trampoline_header)
30838
30839 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30840 index bb360dc..3e5945f 100644
30841 --- a/arch/x86/realmode/rm/trampoline_64.S
30842 +++ b/arch/x86/realmode/rm/trampoline_64.S
30843 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30844 wrmsr
30845
30846 # Enable paging and in turn activate Long Mode
30847 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30848 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30849 movl %eax, %cr0
30850
30851 /*
30852 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30853 index 79d67bd..c7e1b90 100644
30854 --- a/arch/x86/tools/relocs.c
30855 +++ b/arch/x86/tools/relocs.c
30856 @@ -12,10 +12,13 @@
30857 #include <regex.h>
30858 #include <tools/le_byteshift.h>
30859
30860 +#include "../../../include/generated/autoconf.h"
30861 +
30862 static void die(char *fmt, ...);
30863
30864 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30865 static Elf32_Ehdr ehdr;
30866 +static Elf32_Phdr *phdr;
30867 static unsigned long reloc_count, reloc_idx;
30868 static unsigned long *relocs;
30869 static unsigned long reloc16_count, reloc16_idx;
30870 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30871 }
30872 }
30873
30874 +static void read_phdrs(FILE *fp)
30875 +{
30876 + unsigned int i;
30877 +
30878 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30879 + if (!phdr) {
30880 + die("Unable to allocate %d program headers\n",
30881 + ehdr.e_phnum);
30882 + }
30883 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30884 + die("Seek to %d failed: %s\n",
30885 + ehdr.e_phoff, strerror(errno));
30886 + }
30887 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30888 + die("Cannot read ELF program headers: %s\n",
30889 + strerror(errno));
30890 + }
30891 + for(i = 0; i < ehdr.e_phnum; i++) {
30892 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30893 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30894 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30895 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30896 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30897 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30898 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30899 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30900 + }
30901 +
30902 +}
30903 +
30904 static void read_shdrs(FILE *fp)
30905 {
30906 - int i;
30907 + unsigned int i;
30908 Elf32_Shdr shdr;
30909
30910 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30911 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30912
30913 static void read_strtabs(FILE *fp)
30914 {
30915 - int i;
30916 + unsigned int i;
30917 for (i = 0; i < ehdr.e_shnum; i++) {
30918 struct section *sec = &secs[i];
30919 if (sec->shdr.sh_type != SHT_STRTAB) {
30920 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30921
30922 static void read_symtabs(FILE *fp)
30923 {
30924 - int i,j;
30925 + unsigned int i,j;
30926 for (i = 0; i < ehdr.e_shnum; i++) {
30927 struct section *sec = &secs[i];
30928 if (sec->shdr.sh_type != SHT_SYMTAB) {
30929 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30930 }
30931
30932
30933 -static void read_relocs(FILE *fp)
30934 +static void read_relocs(FILE *fp, int use_real_mode)
30935 {
30936 - int i,j;
30937 + unsigned int i,j;
30938 + uint32_t base;
30939 +
30940 for (i = 0; i < ehdr.e_shnum; i++) {
30941 struct section *sec = &secs[i];
30942 if (sec->shdr.sh_type != SHT_REL) {
30943 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30944 die("Cannot read symbol table: %s\n",
30945 strerror(errno));
30946 }
30947 + base = 0;
30948 +
30949 +#ifdef CONFIG_X86_32
30950 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30951 + if (phdr[j].p_type != PT_LOAD )
30952 + continue;
30953 + 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)
30954 + continue;
30955 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30956 + break;
30957 + }
30958 +#endif
30959 +
30960 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30961 Elf32_Rel *rel = &sec->reltab[j];
30962 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30963 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30964 rel->r_info = elf32_to_cpu(rel->r_info);
30965 }
30966 }
30967 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30968
30969 static void print_absolute_symbols(void)
30970 {
30971 - int i;
30972 + unsigned int i;
30973 printf("Absolute symbols\n");
30974 printf(" Num: Value Size Type Bind Visibility Name\n");
30975 for (i = 0; i < ehdr.e_shnum; i++) {
30976 struct section *sec = &secs[i];
30977 char *sym_strtab;
30978 - int j;
30979 + unsigned int j;
30980
30981 if (sec->shdr.sh_type != SHT_SYMTAB) {
30982 continue;
30983 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30984
30985 static void print_absolute_relocs(void)
30986 {
30987 - int i, printed = 0;
30988 + unsigned int i, printed = 0;
30989
30990 for (i = 0; i < ehdr.e_shnum; i++) {
30991 struct section *sec = &secs[i];
30992 struct section *sec_applies, *sec_symtab;
30993 char *sym_strtab;
30994 Elf32_Sym *sh_symtab;
30995 - int j;
30996 + unsigned int j;
30997 if (sec->shdr.sh_type != SHT_REL) {
30998 continue;
30999 }
31000 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
31001 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31002 int use_real_mode)
31003 {
31004 - int i;
31005 + unsigned int i;
31006 /* Walk through the relocations */
31007 for (i = 0; i < ehdr.e_shnum; i++) {
31008 char *sym_strtab;
31009 Elf32_Sym *sh_symtab;
31010 struct section *sec_applies, *sec_symtab;
31011 - int j;
31012 + unsigned int j;
31013 struct section *sec = &secs[i];
31014
31015 if (sec->shdr.sh_type != SHT_REL) {
31016 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31017 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
31018 r_type = ELF32_R_TYPE(rel->r_info);
31019
31020 + if (!use_real_mode) {
31021 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31022 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31023 + continue;
31024 +
31025 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
31026 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31027 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31028 + continue;
31029 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31030 + continue;
31031 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31032 + continue;
31033 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31034 + continue;
31035 +#endif
31036 + }
31037 +
31038 shn_abs = sym->st_shndx == SHN_ABS;
31039
31040 switch (r_type) {
31041 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
31042
31043 static void emit_relocs(int as_text, int use_real_mode)
31044 {
31045 - int i;
31046 + unsigned int i;
31047 /* Count how many relocations I have and allocate space for them. */
31048 reloc_count = 0;
31049 walk_relocs(count_reloc, use_real_mode);
31050 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
31051 fname, strerror(errno));
31052 }
31053 read_ehdr(fp);
31054 + read_phdrs(fp);
31055 read_shdrs(fp);
31056 read_strtabs(fp);
31057 read_symtabs(fp);
31058 - read_relocs(fp);
31059 + read_relocs(fp, use_real_mode);
31060 if (show_absolute_syms) {
31061 print_absolute_symbols();
31062 goto out;
31063 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31064 index fd14be1..e3c79c0 100644
31065 --- a/arch/x86/vdso/Makefile
31066 +++ b/arch/x86/vdso/Makefile
31067 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31068 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31069 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31070
31071 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31072 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31073 GCOV_PROFILE := n
31074
31075 #
31076 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31077 index 0faad64..39ef157 100644
31078 --- a/arch/x86/vdso/vdso32-setup.c
31079 +++ b/arch/x86/vdso/vdso32-setup.c
31080 @@ -25,6 +25,7 @@
31081 #include <asm/tlbflush.h>
31082 #include <asm/vdso.h>
31083 #include <asm/proto.h>
31084 +#include <asm/mman.h>
31085
31086 enum {
31087 VDSO_DISABLED = 0,
31088 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31089 void enable_sep_cpu(void)
31090 {
31091 int cpu = get_cpu();
31092 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31093 + struct tss_struct *tss = init_tss + cpu;
31094
31095 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31096 put_cpu();
31097 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31098 gate_vma.vm_start = FIXADDR_USER_START;
31099 gate_vma.vm_end = FIXADDR_USER_END;
31100 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31101 - gate_vma.vm_page_prot = __P101;
31102 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31103
31104 return 0;
31105 }
31106 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31107 if (compat)
31108 addr = VDSO_HIGH_BASE;
31109 else {
31110 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31111 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31112 if (IS_ERR_VALUE(addr)) {
31113 ret = addr;
31114 goto up_fail;
31115 }
31116 }
31117
31118 - current->mm->context.vdso = (void *)addr;
31119 + current->mm->context.vdso = addr;
31120
31121 if (compat_uses_vma || !compat) {
31122 /*
31123 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31124 }
31125
31126 current_thread_info()->sysenter_return =
31127 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31128 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31129
31130 up_fail:
31131 if (ret)
31132 - current->mm->context.vdso = NULL;
31133 + current->mm->context.vdso = 0;
31134
31135 up_write(&mm->mmap_sem);
31136
31137 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31138
31139 const char *arch_vma_name(struct vm_area_struct *vma)
31140 {
31141 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31142 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31143 return "[vdso]";
31144 +
31145 +#ifdef CONFIG_PAX_SEGMEXEC
31146 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31147 + return "[vdso]";
31148 +#endif
31149 +
31150 return NULL;
31151 }
31152
31153 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31154 * Check to see if the corresponding task was created in compat vdso
31155 * mode.
31156 */
31157 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31158 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31159 return &gate_vma;
31160 return NULL;
31161 }
31162 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31163 index 431e875..cbb23f3 100644
31164 --- a/arch/x86/vdso/vma.c
31165 +++ b/arch/x86/vdso/vma.c
31166 @@ -16,8 +16,6 @@
31167 #include <asm/vdso.h>
31168 #include <asm/page.h>
31169
31170 -unsigned int __read_mostly vdso_enabled = 1;
31171 -
31172 extern char vdso_start[], vdso_end[];
31173 extern unsigned short vdso_sync_cpuid;
31174
31175 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31176 * unaligned here as a result of stack start randomization.
31177 */
31178 addr = PAGE_ALIGN(addr);
31179 - addr = align_vdso_addr(addr);
31180
31181 return addr;
31182 }
31183 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31184 unsigned size)
31185 {
31186 struct mm_struct *mm = current->mm;
31187 - unsigned long addr;
31188 + unsigned long addr = 0;
31189 int ret;
31190
31191 - if (!vdso_enabled)
31192 - return 0;
31193 -
31194 down_write(&mm->mmap_sem);
31195 +
31196 +#ifdef CONFIG_PAX_RANDMMAP
31197 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31198 +#endif
31199 +
31200 addr = vdso_addr(mm->start_stack, size);
31201 + addr = align_vdso_addr(addr);
31202 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31203 if (IS_ERR_VALUE(addr)) {
31204 ret = addr;
31205 goto up_fail;
31206 }
31207
31208 - current->mm->context.vdso = (void *)addr;
31209 + mm->context.vdso = addr;
31210
31211 ret = install_special_mapping(mm, addr, size,
31212 VM_READ|VM_EXEC|
31213 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31214 pages);
31215 - if (ret) {
31216 - current->mm->context.vdso = NULL;
31217 - goto up_fail;
31218 - }
31219 + if (ret)
31220 + mm->context.vdso = 0;
31221
31222 up_fail:
31223 up_write(&mm->mmap_sem);
31224 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31225 vdsox32_size);
31226 }
31227 #endif
31228 -
31229 -static __init int vdso_setup(char *s)
31230 -{
31231 - vdso_enabled = simple_strtoul(s, NULL, 0);
31232 - return 0;
31233 -}
31234 -__setup("vdso=", vdso_setup);
31235 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31236 index cf95e19..17e9f50 100644
31237 --- a/arch/x86/xen/enlighten.c
31238 +++ b/arch/x86/xen/enlighten.c
31239 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31240
31241 struct shared_info xen_dummy_shared_info;
31242
31243 -void *xen_initial_gdt;
31244 -
31245 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31246 __read_mostly int xen_have_vector_callback;
31247 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31248 @@ -511,8 +509,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31249 {
31250 unsigned long va = dtr->address;
31251 unsigned int size = dtr->size + 1;
31252 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31253 - unsigned long frames[pages];
31254 + unsigned long frames[65536 / PAGE_SIZE];
31255 int f;
31256
31257 /*
31258 @@ -560,8 +557,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31259 {
31260 unsigned long va = dtr->address;
31261 unsigned int size = dtr->size + 1;
31262 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31263 - unsigned long frames[pages];
31264 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31265 int f;
31266
31267 /*
31268 @@ -569,7 +565,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31269 * 8-byte entries, or 16 4k pages..
31270 */
31271
31272 - BUG_ON(size > 65536);
31273 + BUG_ON(size > GDT_SIZE);
31274 BUG_ON(va & ~PAGE_MASK);
31275
31276 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31277 @@ -954,7 +950,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31278 return 0;
31279 }
31280
31281 -static void set_xen_basic_apic_ops(void)
31282 +static void __init set_xen_basic_apic_ops(void)
31283 {
31284 apic->read = xen_apic_read;
31285 apic->write = xen_apic_write;
31286 @@ -1260,30 +1256,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31287 #endif
31288 };
31289
31290 -static void xen_reboot(int reason)
31291 +static __noreturn void xen_reboot(int reason)
31292 {
31293 struct sched_shutdown r = { .reason = reason };
31294
31295 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31296 - BUG();
31297 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31298 + BUG();
31299 }
31300
31301 -static void xen_restart(char *msg)
31302 +static __noreturn void xen_restart(char *msg)
31303 {
31304 xen_reboot(SHUTDOWN_reboot);
31305 }
31306
31307 -static void xen_emergency_restart(void)
31308 +static __noreturn void xen_emergency_restart(void)
31309 {
31310 xen_reboot(SHUTDOWN_reboot);
31311 }
31312
31313 -static void xen_machine_halt(void)
31314 +static __noreturn void xen_machine_halt(void)
31315 {
31316 xen_reboot(SHUTDOWN_poweroff);
31317 }
31318
31319 -static void xen_machine_power_off(void)
31320 +static __noreturn void xen_machine_power_off(void)
31321 {
31322 if (pm_power_off)
31323 pm_power_off();
31324 @@ -1385,7 +1381,17 @@ asmlinkage void __init xen_start_kernel(void)
31325 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31326
31327 /* Work out if we support NX */
31328 - x86_configure_nx();
31329 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31330 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31331 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31332 + unsigned l, h;
31333 +
31334 + __supported_pte_mask |= _PAGE_NX;
31335 + rdmsr(MSR_EFER, l, h);
31336 + l |= EFER_NX;
31337 + wrmsr(MSR_EFER, l, h);
31338 + }
31339 +#endif
31340
31341 xen_setup_features();
31342
31343 @@ -1416,13 +1422,6 @@ asmlinkage void __init xen_start_kernel(void)
31344
31345 machine_ops = xen_machine_ops;
31346
31347 - /*
31348 - * The only reliable way to retain the initial address of the
31349 - * percpu gdt_page is to remember it here, so we can go and
31350 - * mark it RW later, when the initial percpu area is freed.
31351 - */
31352 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31353 -
31354 xen_smp_init();
31355
31356 #ifdef CONFIG_ACPI_NUMA
31357 @@ -1616,7 +1615,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31358 return NOTIFY_OK;
31359 }
31360
31361 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31362 +static struct notifier_block xen_hvm_cpu_notifier = {
31363 .notifier_call = xen_hvm_cpu_notify,
31364 };
31365
31366 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31367 index e006c18..b9a7d6c 100644
31368 --- a/arch/x86/xen/mmu.c
31369 +++ b/arch/x86/xen/mmu.c
31370 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31371 /* L3_k[510] -> level2_kernel_pgt
31372 * L3_i[511] -> level2_fixmap_pgt */
31373 convert_pfn_mfn(level3_kernel_pgt);
31374 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31375 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31376 + convert_pfn_mfn(level3_vmemmap_pgt);
31377
31378 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31379 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31380 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31381 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31382 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31383 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31384 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31385 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31386 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31387 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31388 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31389 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31390 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31391 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31392
31393 @@ -2110,6 +2117,7 @@ static void __init xen_post_allocator_init(void)
31394 pv_mmu_ops.set_pud = xen_set_pud;
31395 #if PAGETABLE_LEVELS == 4
31396 pv_mmu_ops.set_pgd = xen_set_pgd;
31397 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31398 #endif
31399
31400 /* This will work as long as patching hasn't happened yet
31401 @@ -2188,6 +2196,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31402 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31403 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31404 .set_pgd = xen_set_pgd_hyper,
31405 + .set_pgd_batched = xen_set_pgd_hyper,
31406
31407 .alloc_pud = xen_alloc_pmd_init,
31408 .release_pud = xen_release_pmd_init,
31409 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31410 index 96c4e85..284fded 100644
31411 --- a/arch/x86/xen/smp.c
31412 +++ b/arch/x86/xen/smp.c
31413 @@ -230,11 +230,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31414 {
31415 BUG_ON(smp_processor_id() != 0);
31416 native_smp_prepare_boot_cpu();
31417 -
31418 - /* We've switched to the "real" per-cpu gdt, so make sure the
31419 - old memory can be recycled */
31420 - make_lowmem_page_readwrite(xen_initial_gdt);
31421 -
31422 xen_filter_cpu_maps();
31423 xen_setup_vcpu_info_placement();
31424 }
31425 @@ -304,7 +299,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31426 ctxt->user_regs.ss = __KERNEL_DS;
31427 #ifdef CONFIG_X86_32
31428 ctxt->user_regs.fs = __KERNEL_PERCPU;
31429 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31430 + savesegment(gs, ctxt->user_regs.gs);
31431 #else
31432 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31433 #endif
31434 @@ -314,8 +309,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31435
31436 {
31437 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31438 - ctxt->user_regs.ds = __USER_DS;
31439 - ctxt->user_regs.es = __USER_DS;
31440 + ctxt->user_regs.ds = __KERNEL_DS;
31441 + ctxt->user_regs.es = __KERNEL_DS;
31442
31443 xen_copy_trap_info(ctxt->trap_ctxt);
31444
31445 @@ -360,13 +355,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31446 int rc;
31447
31448 per_cpu(current_task, cpu) = idle;
31449 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31450 #ifdef CONFIG_X86_32
31451 irq_ctx_init(cpu);
31452 #else
31453 clear_tsk_thread_flag(idle, TIF_FORK);
31454 - per_cpu(kernel_stack, cpu) =
31455 - (unsigned long)task_stack_page(idle) -
31456 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31457 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31458 #endif
31459 xen_setup_runstate_info(cpu);
31460 xen_setup_timer(cpu);
31461 @@ -642,7 +636,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31462
31463 void __init xen_smp_init(void)
31464 {
31465 - smp_ops = xen_smp_ops;
31466 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31467 xen_fill_possible_map();
31468 xen_init_spinlocks();
31469 }
31470 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31471 index 33ca6e4..0ded929 100644
31472 --- a/arch/x86/xen/xen-asm_32.S
31473 +++ b/arch/x86/xen/xen-asm_32.S
31474 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31475 ESP_OFFSET=4 # bytes pushed onto stack
31476
31477 /*
31478 - * Store vcpu_info pointer for easy access. Do it this way to
31479 - * avoid having to reload %fs
31480 + * Store vcpu_info pointer for easy access.
31481 */
31482 #ifdef CONFIG_SMP
31483 - GET_THREAD_INFO(%eax)
31484 - movl %ss:TI_cpu(%eax), %eax
31485 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31486 - mov %ss:xen_vcpu(%eax), %eax
31487 + push %fs
31488 + mov $(__KERNEL_PERCPU), %eax
31489 + mov %eax, %fs
31490 + mov PER_CPU_VAR(xen_vcpu), %eax
31491 + pop %fs
31492 #else
31493 movl %ss:xen_vcpu, %eax
31494 #endif
31495 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31496 index 7faed58..ba4427c 100644
31497 --- a/arch/x86/xen/xen-head.S
31498 +++ b/arch/x86/xen/xen-head.S
31499 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31500 #ifdef CONFIG_X86_32
31501 mov %esi,xen_start_info
31502 mov $init_thread_union+THREAD_SIZE,%esp
31503 +#ifdef CONFIG_SMP
31504 + movl $cpu_gdt_table,%edi
31505 + movl $__per_cpu_load,%eax
31506 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31507 + rorl $16,%eax
31508 + movb %al,__KERNEL_PERCPU + 4(%edi)
31509 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31510 + movl $__per_cpu_end - 1,%eax
31511 + subl $__per_cpu_start,%eax
31512 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31513 +#endif
31514 #else
31515 mov %rsi,xen_start_info
31516 mov $init_thread_union+THREAD_SIZE,%rsp
31517 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31518 index a95b417..b6dbd0b 100644
31519 --- a/arch/x86/xen/xen-ops.h
31520 +++ b/arch/x86/xen/xen-ops.h
31521 @@ -10,8 +10,6 @@
31522 extern const char xen_hypervisor_callback[];
31523 extern const char xen_failsafe_callback[];
31524
31525 -extern void *xen_initial_gdt;
31526 -
31527 struct trap_info;
31528 void xen_copy_trap_info(struct trap_info *traps);
31529
31530 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31531 index 525bd3d..ef888b1 100644
31532 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31533 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31534 @@ -119,9 +119,9 @@
31535 ----------------------------------------------------------------------*/
31536
31537 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31538 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31539 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31540 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31541 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31542
31543 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31544 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31545 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31546 index 2f33760..835e50a 100644
31547 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31548 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31549 @@ -11,6 +11,7 @@
31550 #ifndef _XTENSA_CORE_H
31551 #define _XTENSA_CORE_H
31552
31553 +#include <linux/const.h>
31554
31555 /****************************************************************************
31556 Parameters Useful for Any Code, USER or PRIVILEGED
31557 @@ -112,9 +113,9 @@
31558 ----------------------------------------------------------------------*/
31559
31560 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31561 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31562 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31563 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31564 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31565
31566 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31567 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31568 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31569 index af00795..2bb8105 100644
31570 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31571 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31572 @@ -11,6 +11,7 @@
31573 #ifndef _XTENSA_CORE_CONFIGURATION_H
31574 #define _XTENSA_CORE_CONFIGURATION_H
31575
31576 +#include <linux/const.h>
31577
31578 /****************************************************************************
31579 Parameters Useful for Any Code, USER or PRIVILEGED
31580 @@ -118,9 +119,9 @@
31581 ----------------------------------------------------------------------*/
31582
31583 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31584 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31585 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31586 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31587 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31588
31589 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31590 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31591 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31592 index 58916af..eb9dbcf6 100644
31593 --- a/block/blk-iopoll.c
31594 +++ b/block/blk-iopoll.c
31595 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31596 }
31597 EXPORT_SYMBOL(blk_iopoll_complete);
31598
31599 -static void blk_iopoll_softirq(struct softirq_action *h)
31600 +static void blk_iopoll_softirq(void)
31601 {
31602 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31603 int rearm = 0, budget = blk_iopoll_budget;
31604 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31605 return NOTIFY_OK;
31606 }
31607
31608 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31609 +static struct notifier_block blk_iopoll_cpu_notifier = {
31610 .notifier_call = blk_iopoll_cpu_notify,
31611 };
31612
31613 diff --git a/block/blk-map.c b/block/blk-map.c
31614 index 623e1cd..ca1e109 100644
31615 --- a/block/blk-map.c
31616 +++ b/block/blk-map.c
31617 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31618 if (!len || !kbuf)
31619 return -EINVAL;
31620
31621 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31622 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31623 if (do_copy)
31624 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31625 else
31626 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31627 index 467c8de..f3628c5 100644
31628 --- a/block/blk-softirq.c
31629 +++ b/block/blk-softirq.c
31630 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31631 * Softirq action handler - move entries to local list and loop over them
31632 * while passing them to the queue registered handler.
31633 */
31634 -static void blk_done_softirq(struct softirq_action *h)
31635 +static void blk_done_softirq(void)
31636 {
31637 struct list_head *cpu_list, local_list;
31638
31639 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31640 return NOTIFY_OK;
31641 }
31642
31643 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31644 +static struct notifier_block blk_cpu_notifier = {
31645 .notifier_call = blk_cpu_notify,
31646 };
31647
31648 diff --git a/block/bsg.c b/block/bsg.c
31649 index 420a5a9..23834aa 100644
31650 --- a/block/bsg.c
31651 +++ b/block/bsg.c
31652 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31653 struct sg_io_v4 *hdr, struct bsg_device *bd,
31654 fmode_t has_write_perm)
31655 {
31656 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31657 + unsigned char *cmdptr;
31658 +
31659 if (hdr->request_len > BLK_MAX_CDB) {
31660 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31661 if (!rq->cmd)
31662 return -ENOMEM;
31663 - }
31664 + cmdptr = rq->cmd;
31665 + } else
31666 + cmdptr = tmpcmd;
31667
31668 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31669 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31670 hdr->request_len))
31671 return -EFAULT;
31672
31673 + if (cmdptr != rq->cmd)
31674 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31675 +
31676 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31677 if (blk_verify_command(rq->cmd, has_write_perm))
31678 return -EPERM;
31679 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31680 index 7c668c8..db3521c 100644
31681 --- a/block/compat_ioctl.c
31682 +++ b/block/compat_ioctl.c
31683 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31684 err |= __get_user(f->spec1, &uf->spec1);
31685 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31686 err |= __get_user(name, &uf->name);
31687 - f->name = compat_ptr(name);
31688 + f->name = (void __force_kernel *)compat_ptr(name);
31689 if (err) {
31690 err = -EFAULT;
31691 goto out;
31692 diff --git a/block/genhd.c b/block/genhd.c
31693 index 3c001fb..d15a9e8 100644
31694 --- a/block/genhd.c
31695 +++ b/block/genhd.c
31696 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
31697
31698 /*
31699 * Register device numbers dev..(dev+range-1)
31700 - * range must be nonzero
31701 + * Noop if @range is zero.
31702 * The hash chain is sorted on range, so that subranges can override.
31703 */
31704 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
31705 struct kobject *(*probe)(dev_t, int *, void *),
31706 int (*lock)(dev_t, void *), void *data)
31707 {
31708 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
31709 + if (range)
31710 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
31711 }
31712
31713 EXPORT_SYMBOL(blk_register_region);
31714
31715 +/* undo blk_register_region(), noop if @range is zero */
31716 void blk_unregister_region(dev_t devt, unsigned long range)
31717 {
31718 - kobj_unmap(bdev_map, devt, range);
31719 + if (range)
31720 + kobj_unmap(bdev_map, devt, range);
31721 }
31722
31723 EXPORT_SYMBOL(blk_unregister_region);
31724 @@ -512,7 +515,7 @@ static void register_disk(struct gendisk *disk)
31725
31726 ddev->parent = disk->driverfs_dev;
31727
31728 - dev_set_name(ddev, disk->disk_name);
31729 + dev_set_name(ddev, "%s", disk->disk_name);
31730
31731 /* delay uevents, until we scanned partition table */
31732 dev_set_uevent_suppress(ddev, 1);
31733 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31734 index ff5804e..a88acad 100644
31735 --- a/block/partitions/efi.c
31736 +++ b/block/partitions/efi.c
31737 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31738 if (!gpt)
31739 return NULL;
31740
31741 + if (!le32_to_cpu(gpt->num_partition_entries))
31742 + return NULL;
31743 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31744 + if (!pte)
31745 + return NULL;
31746 +
31747 count = le32_to_cpu(gpt->num_partition_entries) *
31748 le32_to_cpu(gpt->sizeof_partition_entry);
31749 - if (!count)
31750 - return NULL;
31751 - pte = kzalloc(count, GFP_KERNEL);
31752 - if (!pte)
31753 - return NULL;
31754 -
31755 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31756 (u8 *) pte,
31757 count) < count) {
31758 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31759 index 9a87daa..fb17486 100644
31760 --- a/block/scsi_ioctl.c
31761 +++ b/block/scsi_ioctl.c
31762 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31763 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31764 struct sg_io_hdr *hdr, fmode_t mode)
31765 {
31766 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31767 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31768 + unsigned char *cmdptr;
31769 +
31770 + if (rq->cmd != rq->__cmd)
31771 + cmdptr = rq->cmd;
31772 + else
31773 + cmdptr = tmpcmd;
31774 +
31775 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31776 return -EFAULT;
31777 +
31778 + if (cmdptr != rq->cmd)
31779 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31780 +
31781 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31782 return -EPERM;
31783
31784 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31785 int err;
31786 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31787 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31788 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31789 + unsigned char *cmdptr;
31790
31791 if (!sic)
31792 return -EINVAL;
31793 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31794 */
31795 err = -EFAULT;
31796 rq->cmd_len = cmdlen;
31797 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31798 +
31799 + if (rq->cmd != rq->__cmd)
31800 + cmdptr = rq->cmd;
31801 + else
31802 + cmdptr = tmpcmd;
31803 +
31804 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31805 goto error;
31806
31807 + if (rq->cmd != cmdptr)
31808 + memcpy(rq->cmd, cmdptr, cmdlen);
31809 +
31810 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31811 goto error;
31812
31813 diff --git a/crypto/algapi.c b/crypto/algapi.c
31814 index 6149a6e..55ed50d 100644
31815 --- a/crypto/algapi.c
31816 +++ b/crypto/algapi.c
31817 @@ -495,7 +495,7 @@ static struct crypto_template *__crypto_lookup_template(const char *name)
31818
31819 struct crypto_template *crypto_lookup_template(const char *name)
31820 {
31821 - return try_then_request_module(__crypto_lookup_template(name), name);
31822 + return try_then_request_module(__crypto_lookup_template(name), "%s", name);
31823 }
31824 EXPORT_SYMBOL_GPL(crypto_lookup_template);
31825
31826 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31827 index 7bdd61b..afec999 100644
31828 --- a/crypto/cryptd.c
31829 +++ b/crypto/cryptd.c
31830 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31831
31832 struct cryptd_blkcipher_request_ctx {
31833 crypto_completion_t complete;
31834 -};
31835 +} __no_const;
31836
31837 struct cryptd_hash_ctx {
31838 struct crypto_shash *child;
31839 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31840
31841 struct cryptd_aead_request_ctx {
31842 crypto_completion_t complete;
31843 -};
31844 +} __no_const;
31845
31846 static void cryptd_queue_worker(struct work_struct *work);
31847
31848 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
31849 index b2c99dc..476c9fb 100644
31850 --- a/crypto/pcrypt.c
31851 +++ b/crypto/pcrypt.c
31852 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
31853 int ret;
31854
31855 pinst->kobj.kset = pcrypt_kset;
31856 - ret = kobject_add(&pinst->kobj, NULL, name);
31857 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
31858 if (!ret)
31859 kobject_uevent(&pinst->kobj, KOBJ_ADD);
31860
31861 @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
31862
31863 get_online_cpus();
31864
31865 - pcrypt->wq = alloc_workqueue(name,
31866 - WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
31867 + pcrypt->wq = alloc_workqueue("%s",
31868 + WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1, name);
31869 if (!pcrypt->wq)
31870 goto err;
31871
31872 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31873 index f220d64..d359ad6 100644
31874 --- a/drivers/acpi/apei/apei-internal.h
31875 +++ b/drivers/acpi/apei/apei-internal.h
31876 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31877 struct apei_exec_ins_type {
31878 u32 flags;
31879 apei_exec_ins_func_t run;
31880 -};
31881 +} __do_const;
31882
31883 struct apei_exec_context {
31884 u32 ip;
31885 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31886 index fefc2ca..12a535d 100644
31887 --- a/drivers/acpi/apei/cper.c
31888 +++ b/drivers/acpi/apei/cper.c
31889 @@ -39,12 +39,12 @@
31890 */
31891 u64 cper_next_record_id(void)
31892 {
31893 - static atomic64_t seq;
31894 + static atomic64_unchecked_t seq;
31895
31896 - if (!atomic64_read(&seq))
31897 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31898 + if (!atomic64_read_unchecked(&seq))
31899 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31900
31901 - return atomic64_inc_return(&seq);
31902 + return atomic64_inc_return_unchecked(&seq);
31903 }
31904 EXPORT_SYMBOL_GPL(cper_next_record_id);
31905
31906 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31907 index be60399..778b33e8 100644
31908 --- a/drivers/acpi/bgrt.c
31909 +++ b/drivers/acpi/bgrt.c
31910 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31911 return -ENODEV;
31912
31913 sysfs_bin_attr_init(&image_attr);
31914 - image_attr.private = bgrt_image;
31915 - image_attr.size = bgrt_image_size;
31916 + pax_open_kernel();
31917 + *(void **)&image_attr.private = bgrt_image;
31918 + *(size_t *)&image_attr.size = bgrt_image_size;
31919 + pax_close_kernel();
31920
31921 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31922 if (!bgrt_kobj)
31923 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31924 index cb96296..b81293b 100644
31925 --- a/drivers/acpi/blacklist.c
31926 +++ b/drivers/acpi/blacklist.c
31927 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31928 u32 is_critical_error;
31929 };
31930
31931 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31932 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31933
31934 /*
31935 * POLICY: If *anything* doesn't work, put it on the blacklist.
31936 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31937 return 0;
31938 }
31939
31940 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31941 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31942 {
31943 .callback = dmi_disable_osi_vista,
31944 .ident = "Fujitsu Siemens",
31945 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31946 index 7586544..636a2f0 100644
31947 --- a/drivers/acpi/ec_sys.c
31948 +++ b/drivers/acpi/ec_sys.c
31949 @@ -12,6 +12,7 @@
31950 #include <linux/acpi.h>
31951 #include <linux/debugfs.h>
31952 #include <linux/module.h>
31953 +#include <linux/uaccess.h>
31954 #include "internal.h"
31955
31956 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31957 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31958 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31959 */
31960 unsigned int size = EC_SPACE_SIZE;
31961 - u8 *data = (u8 *) buf;
31962 + u8 data;
31963 loff_t init_off = *off;
31964 int err = 0;
31965
31966 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31967 size = count;
31968
31969 while (size) {
31970 - err = ec_read(*off, &data[*off - init_off]);
31971 + err = ec_read(*off, &data);
31972 if (err)
31973 return err;
31974 + if (put_user(data, &buf[*off - init_off]))
31975 + return -EFAULT;
31976 *off += 1;
31977 size--;
31978 }
31979 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31980
31981 unsigned int size = count;
31982 loff_t init_off = *off;
31983 - u8 *data = (u8 *) buf;
31984 int err = 0;
31985
31986 if (*off >= EC_SPACE_SIZE)
31987 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31988 }
31989
31990 while (size) {
31991 - u8 byte_write = data[*off - init_off];
31992 + u8 byte_write;
31993 + if (get_user(byte_write, &buf[*off - init_off]))
31994 + return -EFAULT;
31995 err = ec_write(*off, byte_write);
31996 if (err)
31997 return err;
31998 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31999 index ee255c6..747c68b 100644
32000 --- a/drivers/acpi/processor_idle.c
32001 +++ b/drivers/acpi/processor_idle.c
32002 @@ -986,7 +986,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32003 {
32004 int i, count = CPUIDLE_DRIVER_STATE_START;
32005 struct acpi_processor_cx *cx;
32006 - struct cpuidle_state *state;
32007 + cpuidle_state_no_const *state;
32008 struct cpuidle_driver *drv = &acpi_idle_driver;
32009
32010 if (!pr->flags.power_setup_done)
32011 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32012 index 41c0504..f8c0836 100644
32013 --- a/drivers/acpi/sysfs.c
32014 +++ b/drivers/acpi/sysfs.c
32015 @@ -420,11 +420,11 @@ static u32 num_counters;
32016 static struct attribute **all_attrs;
32017 static u32 acpi_gpe_count;
32018
32019 -static struct attribute_group interrupt_stats_attr_group = {
32020 +static attribute_group_no_const interrupt_stats_attr_group = {
32021 .name = "interrupts",
32022 };
32023
32024 -static struct kobj_attribute *counter_attrs;
32025 +static kobj_attribute_no_const *counter_attrs;
32026
32027 static void delete_gpe_attr_array(void)
32028 {
32029 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32030 index 34c8216..f56c828 100644
32031 --- a/drivers/ata/libahci.c
32032 +++ b/drivers/ata/libahci.c
32033 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32034 }
32035 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32036
32037 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32038 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32039 struct ata_taskfile *tf, int is_cmd, u16 flags,
32040 unsigned long timeout_msec)
32041 {
32042 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32043 index cf15aee..e0b7078 100644
32044 --- a/drivers/ata/libata-core.c
32045 +++ b/drivers/ata/libata-core.c
32046 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32047 struct ata_port *ap;
32048 unsigned int tag;
32049
32050 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32051 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32052 ap = qc->ap;
32053
32054 qc->flags = 0;
32055 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32056 struct ata_port *ap;
32057 struct ata_link *link;
32058
32059 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32060 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32061 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32062 ap = qc->ap;
32063 link = qc->dev->link;
32064 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32065 return;
32066
32067 spin_lock(&lock);
32068 + pax_open_kernel();
32069
32070 for (cur = ops->inherits; cur; cur = cur->inherits) {
32071 void **inherit = (void **)cur;
32072 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32073 if (IS_ERR(*pp))
32074 *pp = NULL;
32075
32076 - ops->inherits = NULL;
32077 + *(struct ata_port_operations **)&ops->inherits = NULL;
32078
32079 + pax_close_kernel();
32080 spin_unlock(&lock);
32081 }
32082
32083 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32084 index 405022d..fb70e53 100644
32085 --- a/drivers/ata/pata_arasan_cf.c
32086 +++ b/drivers/ata/pata_arasan_cf.c
32087 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32088 /* Handle platform specific quirks */
32089 if (pdata->quirk) {
32090 if (pdata->quirk & CF_BROKEN_PIO) {
32091 - ap->ops->set_piomode = NULL;
32092 + pax_open_kernel();
32093 + *(void **)&ap->ops->set_piomode = NULL;
32094 + pax_close_kernel();
32095 ap->pio_mask = 0;
32096 }
32097 if (pdata->quirk & CF_BROKEN_MWDMA)
32098 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32099 index f9b983a..887b9d8 100644
32100 --- a/drivers/atm/adummy.c
32101 +++ b/drivers/atm/adummy.c
32102 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32103 vcc->pop(vcc, skb);
32104 else
32105 dev_kfree_skb_any(skb);
32106 - atomic_inc(&vcc->stats->tx);
32107 + atomic_inc_unchecked(&vcc->stats->tx);
32108
32109 return 0;
32110 }
32111 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32112 index 77a7480d..05cde58 100644
32113 --- a/drivers/atm/ambassador.c
32114 +++ b/drivers/atm/ambassador.c
32115 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32116 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32117
32118 // VC layer stats
32119 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32120 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32121
32122 // free the descriptor
32123 kfree (tx_descr);
32124 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32125 dump_skb ("<<<", vc, skb);
32126
32127 // VC layer stats
32128 - atomic_inc(&atm_vcc->stats->rx);
32129 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32130 __net_timestamp(skb);
32131 // end of our responsibility
32132 atm_vcc->push (atm_vcc, skb);
32133 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32134 } else {
32135 PRINTK (KERN_INFO, "dropped over-size frame");
32136 // should we count this?
32137 - atomic_inc(&atm_vcc->stats->rx_drop);
32138 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32139 }
32140
32141 } else {
32142 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32143 }
32144
32145 if (check_area (skb->data, skb->len)) {
32146 - atomic_inc(&atm_vcc->stats->tx_err);
32147 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32148 return -ENOMEM; // ?
32149 }
32150
32151 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32152 index 0e3f8f9..765a7a5 100644
32153 --- a/drivers/atm/atmtcp.c
32154 +++ b/drivers/atm/atmtcp.c
32155 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32156 if (vcc->pop) vcc->pop(vcc,skb);
32157 else dev_kfree_skb(skb);
32158 if (dev_data) return 0;
32159 - atomic_inc(&vcc->stats->tx_err);
32160 + atomic_inc_unchecked(&vcc->stats->tx_err);
32161 return -ENOLINK;
32162 }
32163 size = skb->len+sizeof(struct atmtcp_hdr);
32164 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32165 if (!new_skb) {
32166 if (vcc->pop) vcc->pop(vcc,skb);
32167 else dev_kfree_skb(skb);
32168 - atomic_inc(&vcc->stats->tx_err);
32169 + atomic_inc_unchecked(&vcc->stats->tx_err);
32170 return -ENOBUFS;
32171 }
32172 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32173 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32174 if (vcc->pop) vcc->pop(vcc,skb);
32175 else dev_kfree_skb(skb);
32176 out_vcc->push(out_vcc,new_skb);
32177 - atomic_inc(&vcc->stats->tx);
32178 - atomic_inc(&out_vcc->stats->rx);
32179 + atomic_inc_unchecked(&vcc->stats->tx);
32180 + atomic_inc_unchecked(&out_vcc->stats->rx);
32181 return 0;
32182 }
32183
32184 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32185 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32186 read_unlock(&vcc_sklist_lock);
32187 if (!out_vcc) {
32188 - atomic_inc(&vcc->stats->tx_err);
32189 + atomic_inc_unchecked(&vcc->stats->tx_err);
32190 goto done;
32191 }
32192 skb_pull(skb,sizeof(struct atmtcp_hdr));
32193 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32194 __net_timestamp(new_skb);
32195 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32196 out_vcc->push(out_vcc,new_skb);
32197 - atomic_inc(&vcc->stats->tx);
32198 - atomic_inc(&out_vcc->stats->rx);
32199 + atomic_inc_unchecked(&vcc->stats->tx);
32200 + atomic_inc_unchecked(&out_vcc->stats->rx);
32201 done:
32202 if (vcc->pop) vcc->pop(vcc,skb);
32203 else dev_kfree_skb(skb);
32204 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32205 index b1955ba..b179940 100644
32206 --- a/drivers/atm/eni.c
32207 +++ b/drivers/atm/eni.c
32208 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32209 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32210 vcc->dev->number);
32211 length = 0;
32212 - atomic_inc(&vcc->stats->rx_err);
32213 + atomic_inc_unchecked(&vcc->stats->rx_err);
32214 }
32215 else {
32216 length = ATM_CELL_SIZE-1; /* no HEC */
32217 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32218 size);
32219 }
32220 eff = length = 0;
32221 - atomic_inc(&vcc->stats->rx_err);
32222 + atomic_inc_unchecked(&vcc->stats->rx_err);
32223 }
32224 else {
32225 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32226 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32227 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32228 vcc->dev->number,vcc->vci,length,size << 2,descr);
32229 length = eff = 0;
32230 - atomic_inc(&vcc->stats->rx_err);
32231 + atomic_inc_unchecked(&vcc->stats->rx_err);
32232 }
32233 }
32234 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32235 @@ -767,7 +767,7 @@ rx_dequeued++;
32236 vcc->push(vcc,skb);
32237 pushed++;
32238 }
32239 - atomic_inc(&vcc->stats->rx);
32240 + atomic_inc_unchecked(&vcc->stats->rx);
32241 }
32242 wake_up(&eni_dev->rx_wait);
32243 }
32244 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32245 PCI_DMA_TODEVICE);
32246 if (vcc->pop) vcc->pop(vcc,skb);
32247 else dev_kfree_skb_irq(skb);
32248 - atomic_inc(&vcc->stats->tx);
32249 + atomic_inc_unchecked(&vcc->stats->tx);
32250 wake_up(&eni_dev->tx_wait);
32251 dma_complete++;
32252 }
32253 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32254 index b41c948..a002b17 100644
32255 --- a/drivers/atm/firestream.c
32256 +++ b/drivers/atm/firestream.c
32257 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32258 }
32259 }
32260
32261 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32262 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32263
32264 fs_dprintk (FS_DEBUG_TXMEM, "i");
32265 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32266 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32267 #endif
32268 skb_put (skb, qe->p1 & 0xffff);
32269 ATM_SKB(skb)->vcc = atm_vcc;
32270 - atomic_inc(&atm_vcc->stats->rx);
32271 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32272 __net_timestamp(skb);
32273 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32274 atm_vcc->push (atm_vcc, skb);
32275 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32276 kfree (pe);
32277 }
32278 if (atm_vcc)
32279 - atomic_inc(&atm_vcc->stats->rx_drop);
32280 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32281 break;
32282 case 0x1f: /* Reassembly abort: no buffers. */
32283 /* Silently increment error counter. */
32284 if (atm_vcc)
32285 - atomic_inc(&atm_vcc->stats->rx_drop);
32286 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32287 break;
32288 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32289 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32290 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32291 index 204814e..cede831 100644
32292 --- a/drivers/atm/fore200e.c
32293 +++ b/drivers/atm/fore200e.c
32294 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32295 #endif
32296 /* check error condition */
32297 if (*entry->status & STATUS_ERROR)
32298 - atomic_inc(&vcc->stats->tx_err);
32299 + atomic_inc_unchecked(&vcc->stats->tx_err);
32300 else
32301 - atomic_inc(&vcc->stats->tx);
32302 + atomic_inc_unchecked(&vcc->stats->tx);
32303 }
32304 }
32305
32306 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32307 if (skb == NULL) {
32308 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32309
32310 - atomic_inc(&vcc->stats->rx_drop);
32311 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32312 return -ENOMEM;
32313 }
32314
32315 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32316
32317 dev_kfree_skb_any(skb);
32318
32319 - atomic_inc(&vcc->stats->rx_drop);
32320 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32321 return -ENOMEM;
32322 }
32323
32324 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32325
32326 vcc->push(vcc, skb);
32327 - atomic_inc(&vcc->stats->rx);
32328 + atomic_inc_unchecked(&vcc->stats->rx);
32329
32330 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32331
32332 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32333 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32334 fore200e->atm_dev->number,
32335 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32336 - atomic_inc(&vcc->stats->rx_err);
32337 + atomic_inc_unchecked(&vcc->stats->rx_err);
32338 }
32339 }
32340
32341 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32342 goto retry_here;
32343 }
32344
32345 - atomic_inc(&vcc->stats->tx_err);
32346 + atomic_inc_unchecked(&vcc->stats->tx_err);
32347
32348 fore200e->tx_sat++;
32349 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32350 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32351 index d689126..e78e412 100644
32352 --- a/drivers/atm/he.c
32353 +++ b/drivers/atm/he.c
32354 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32355
32356 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32357 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32358 - atomic_inc(&vcc->stats->rx_drop);
32359 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32360 goto return_host_buffers;
32361 }
32362
32363 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32364 RBRQ_LEN_ERR(he_dev->rbrq_head)
32365 ? "LEN_ERR" : "",
32366 vcc->vpi, vcc->vci);
32367 - atomic_inc(&vcc->stats->rx_err);
32368 + atomic_inc_unchecked(&vcc->stats->rx_err);
32369 goto return_host_buffers;
32370 }
32371
32372 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32373 vcc->push(vcc, skb);
32374 spin_lock(&he_dev->global_lock);
32375
32376 - atomic_inc(&vcc->stats->rx);
32377 + atomic_inc_unchecked(&vcc->stats->rx);
32378
32379 return_host_buffers:
32380 ++pdus_assembled;
32381 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32382 tpd->vcc->pop(tpd->vcc, tpd->skb);
32383 else
32384 dev_kfree_skb_any(tpd->skb);
32385 - atomic_inc(&tpd->vcc->stats->tx_err);
32386 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32387 }
32388 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32389 return;
32390 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32391 vcc->pop(vcc, skb);
32392 else
32393 dev_kfree_skb_any(skb);
32394 - atomic_inc(&vcc->stats->tx_err);
32395 + atomic_inc_unchecked(&vcc->stats->tx_err);
32396 return -EINVAL;
32397 }
32398
32399 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32400 vcc->pop(vcc, skb);
32401 else
32402 dev_kfree_skb_any(skb);
32403 - atomic_inc(&vcc->stats->tx_err);
32404 + atomic_inc_unchecked(&vcc->stats->tx_err);
32405 return -EINVAL;
32406 }
32407 #endif
32408 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32409 vcc->pop(vcc, skb);
32410 else
32411 dev_kfree_skb_any(skb);
32412 - atomic_inc(&vcc->stats->tx_err);
32413 + atomic_inc_unchecked(&vcc->stats->tx_err);
32414 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32415 return -ENOMEM;
32416 }
32417 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32418 vcc->pop(vcc, skb);
32419 else
32420 dev_kfree_skb_any(skb);
32421 - atomic_inc(&vcc->stats->tx_err);
32422 + atomic_inc_unchecked(&vcc->stats->tx_err);
32423 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32424 return -ENOMEM;
32425 }
32426 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32427 __enqueue_tpd(he_dev, tpd, cid);
32428 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32429
32430 - atomic_inc(&vcc->stats->tx);
32431 + atomic_inc_unchecked(&vcc->stats->tx);
32432
32433 return 0;
32434 }
32435 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32436 index 1dc0519..1aadaf7 100644
32437 --- a/drivers/atm/horizon.c
32438 +++ b/drivers/atm/horizon.c
32439 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32440 {
32441 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32442 // VC layer stats
32443 - atomic_inc(&vcc->stats->rx);
32444 + atomic_inc_unchecked(&vcc->stats->rx);
32445 __net_timestamp(skb);
32446 // end of our responsibility
32447 vcc->push (vcc, skb);
32448 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32449 dev->tx_iovec = NULL;
32450
32451 // VC layer stats
32452 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32453 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32454
32455 // free the skb
32456 hrz_kfree_skb (skb);
32457 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32458 index 272f009..a18ba55 100644
32459 --- a/drivers/atm/idt77252.c
32460 +++ b/drivers/atm/idt77252.c
32461 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32462 else
32463 dev_kfree_skb(skb);
32464
32465 - atomic_inc(&vcc->stats->tx);
32466 + atomic_inc_unchecked(&vcc->stats->tx);
32467 }
32468
32469 atomic_dec(&scq->used);
32470 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32471 if ((sb = dev_alloc_skb(64)) == NULL) {
32472 printk("%s: Can't allocate buffers for aal0.\n",
32473 card->name);
32474 - atomic_add(i, &vcc->stats->rx_drop);
32475 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32476 break;
32477 }
32478 if (!atm_charge(vcc, sb->truesize)) {
32479 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32480 card->name);
32481 - atomic_add(i - 1, &vcc->stats->rx_drop);
32482 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32483 dev_kfree_skb(sb);
32484 break;
32485 }
32486 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32487 ATM_SKB(sb)->vcc = vcc;
32488 __net_timestamp(sb);
32489 vcc->push(vcc, sb);
32490 - atomic_inc(&vcc->stats->rx);
32491 + atomic_inc_unchecked(&vcc->stats->rx);
32492
32493 cell += ATM_CELL_PAYLOAD;
32494 }
32495 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32496 "(CDC: %08x)\n",
32497 card->name, len, rpp->len, readl(SAR_REG_CDC));
32498 recycle_rx_pool_skb(card, rpp);
32499 - atomic_inc(&vcc->stats->rx_err);
32500 + atomic_inc_unchecked(&vcc->stats->rx_err);
32501 return;
32502 }
32503 if (stat & SAR_RSQE_CRC) {
32504 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32505 recycle_rx_pool_skb(card, rpp);
32506 - atomic_inc(&vcc->stats->rx_err);
32507 + atomic_inc_unchecked(&vcc->stats->rx_err);
32508 return;
32509 }
32510 if (skb_queue_len(&rpp->queue) > 1) {
32511 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32512 RXPRINTK("%s: Can't alloc RX skb.\n",
32513 card->name);
32514 recycle_rx_pool_skb(card, rpp);
32515 - atomic_inc(&vcc->stats->rx_err);
32516 + atomic_inc_unchecked(&vcc->stats->rx_err);
32517 return;
32518 }
32519 if (!atm_charge(vcc, skb->truesize)) {
32520 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32521 __net_timestamp(skb);
32522
32523 vcc->push(vcc, skb);
32524 - atomic_inc(&vcc->stats->rx);
32525 + atomic_inc_unchecked(&vcc->stats->rx);
32526
32527 return;
32528 }
32529 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32530 __net_timestamp(skb);
32531
32532 vcc->push(vcc, skb);
32533 - atomic_inc(&vcc->stats->rx);
32534 + atomic_inc_unchecked(&vcc->stats->rx);
32535
32536 if (skb->truesize > SAR_FB_SIZE_3)
32537 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32538 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32539 if (vcc->qos.aal != ATM_AAL0) {
32540 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32541 card->name, vpi, vci);
32542 - atomic_inc(&vcc->stats->rx_drop);
32543 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32544 goto drop;
32545 }
32546
32547 if ((sb = dev_alloc_skb(64)) == NULL) {
32548 printk("%s: Can't allocate buffers for AAL0.\n",
32549 card->name);
32550 - atomic_inc(&vcc->stats->rx_err);
32551 + atomic_inc_unchecked(&vcc->stats->rx_err);
32552 goto drop;
32553 }
32554
32555 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32556 ATM_SKB(sb)->vcc = vcc;
32557 __net_timestamp(sb);
32558 vcc->push(vcc, sb);
32559 - atomic_inc(&vcc->stats->rx);
32560 + atomic_inc_unchecked(&vcc->stats->rx);
32561
32562 drop:
32563 skb_pull(queue, 64);
32564 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32565
32566 if (vc == NULL) {
32567 printk("%s: NULL connection in send().\n", card->name);
32568 - atomic_inc(&vcc->stats->tx_err);
32569 + atomic_inc_unchecked(&vcc->stats->tx_err);
32570 dev_kfree_skb(skb);
32571 return -EINVAL;
32572 }
32573 if (!test_bit(VCF_TX, &vc->flags)) {
32574 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32575 - atomic_inc(&vcc->stats->tx_err);
32576 + atomic_inc_unchecked(&vcc->stats->tx_err);
32577 dev_kfree_skb(skb);
32578 return -EINVAL;
32579 }
32580 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32581 break;
32582 default:
32583 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32584 - atomic_inc(&vcc->stats->tx_err);
32585 + atomic_inc_unchecked(&vcc->stats->tx_err);
32586 dev_kfree_skb(skb);
32587 return -EINVAL;
32588 }
32589
32590 if (skb_shinfo(skb)->nr_frags != 0) {
32591 printk("%s: No scatter-gather yet.\n", card->name);
32592 - atomic_inc(&vcc->stats->tx_err);
32593 + atomic_inc_unchecked(&vcc->stats->tx_err);
32594 dev_kfree_skb(skb);
32595 return -EINVAL;
32596 }
32597 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32598
32599 err = queue_skb(card, vc, skb, oam);
32600 if (err) {
32601 - atomic_inc(&vcc->stats->tx_err);
32602 + atomic_inc_unchecked(&vcc->stats->tx_err);
32603 dev_kfree_skb(skb);
32604 return err;
32605 }
32606 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32607 skb = dev_alloc_skb(64);
32608 if (!skb) {
32609 printk("%s: Out of memory in send_oam().\n", card->name);
32610 - atomic_inc(&vcc->stats->tx_err);
32611 + atomic_inc_unchecked(&vcc->stats->tx_err);
32612 return -ENOMEM;
32613 }
32614 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32615 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32616 index 4217f29..88f547a 100644
32617 --- a/drivers/atm/iphase.c
32618 +++ b/drivers/atm/iphase.c
32619 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32620 status = (u_short) (buf_desc_ptr->desc_mode);
32621 if (status & (RX_CER | RX_PTE | RX_OFL))
32622 {
32623 - atomic_inc(&vcc->stats->rx_err);
32624 + atomic_inc_unchecked(&vcc->stats->rx_err);
32625 IF_ERR(printk("IA: bad packet, dropping it");)
32626 if (status & RX_CER) {
32627 IF_ERR(printk(" cause: packet CRC error\n");)
32628 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32629 len = dma_addr - buf_addr;
32630 if (len > iadev->rx_buf_sz) {
32631 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32632 - atomic_inc(&vcc->stats->rx_err);
32633 + atomic_inc_unchecked(&vcc->stats->rx_err);
32634 goto out_free_desc;
32635 }
32636
32637 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32638 ia_vcc = INPH_IA_VCC(vcc);
32639 if (ia_vcc == NULL)
32640 {
32641 - atomic_inc(&vcc->stats->rx_err);
32642 + atomic_inc_unchecked(&vcc->stats->rx_err);
32643 atm_return(vcc, skb->truesize);
32644 dev_kfree_skb_any(skb);
32645 goto INCR_DLE;
32646 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32647 if ((length > iadev->rx_buf_sz) || (length >
32648 (skb->len - sizeof(struct cpcs_trailer))))
32649 {
32650 - atomic_inc(&vcc->stats->rx_err);
32651 + atomic_inc_unchecked(&vcc->stats->rx_err);
32652 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32653 length, skb->len);)
32654 atm_return(vcc, skb->truesize);
32655 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32656
32657 IF_RX(printk("rx_dle_intr: skb push");)
32658 vcc->push(vcc,skb);
32659 - atomic_inc(&vcc->stats->rx);
32660 + atomic_inc_unchecked(&vcc->stats->rx);
32661 iadev->rx_pkt_cnt++;
32662 }
32663 INCR_DLE:
32664 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32665 {
32666 struct k_sonet_stats *stats;
32667 stats = &PRIV(_ia_dev[board])->sonet_stats;
32668 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32669 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32670 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32671 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32672 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32673 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32674 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32675 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32676 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32677 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32678 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32679 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32680 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32681 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32682 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32683 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32684 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32685 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32686 }
32687 ia_cmds.status = 0;
32688 break;
32689 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32690 if ((desc == 0) || (desc > iadev->num_tx_desc))
32691 {
32692 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32693 - atomic_inc(&vcc->stats->tx);
32694 + atomic_inc_unchecked(&vcc->stats->tx);
32695 if (vcc->pop)
32696 vcc->pop(vcc, skb);
32697 else
32698 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32699 ATM_DESC(skb) = vcc->vci;
32700 skb_queue_tail(&iadev->tx_dma_q, skb);
32701
32702 - atomic_inc(&vcc->stats->tx);
32703 + atomic_inc_unchecked(&vcc->stats->tx);
32704 iadev->tx_pkt_cnt++;
32705 /* Increment transaction counter */
32706 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32707
32708 #if 0
32709 /* add flow control logic */
32710 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32711 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32712 if (iavcc->vc_desc_cnt > 10) {
32713 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32714 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32715 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32716 index fa7d701..1e404c7 100644
32717 --- a/drivers/atm/lanai.c
32718 +++ b/drivers/atm/lanai.c
32719 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32720 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32721 lanai_endtx(lanai, lvcc);
32722 lanai_free_skb(lvcc->tx.atmvcc, skb);
32723 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32724 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32725 }
32726
32727 /* Try to fill the buffer - don't call unless there is backlog */
32728 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32729 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32730 __net_timestamp(skb);
32731 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32732 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32733 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32734 out:
32735 lvcc->rx.buf.ptr = end;
32736 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32737 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32738 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32739 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32740 lanai->stats.service_rxnotaal5++;
32741 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32742 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32743 return 0;
32744 }
32745 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32746 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32747 int bytes;
32748 read_unlock(&vcc_sklist_lock);
32749 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32750 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32751 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32752 lvcc->stats.x.aal5.service_trash++;
32753 bytes = (SERVICE_GET_END(s) * 16) -
32754 (((unsigned long) lvcc->rx.buf.ptr) -
32755 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32756 }
32757 if (s & SERVICE_STREAM) {
32758 read_unlock(&vcc_sklist_lock);
32759 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32760 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32761 lvcc->stats.x.aal5.service_stream++;
32762 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32763 "PDU on VCI %d!\n", lanai->number, vci);
32764 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32765 return 0;
32766 }
32767 DPRINTK("got rx crc error on vci %d\n", vci);
32768 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32769 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32770 lvcc->stats.x.aal5.service_rxcrc++;
32771 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32772 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32773 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32774 index 6587dc2..149833d 100644
32775 --- a/drivers/atm/nicstar.c
32776 +++ b/drivers/atm/nicstar.c
32777 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32778 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32779 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32780 card->index);
32781 - atomic_inc(&vcc->stats->tx_err);
32782 + atomic_inc_unchecked(&vcc->stats->tx_err);
32783 dev_kfree_skb_any(skb);
32784 return -EINVAL;
32785 }
32786 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32787 if (!vc->tx) {
32788 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32789 card->index);
32790 - atomic_inc(&vcc->stats->tx_err);
32791 + atomic_inc_unchecked(&vcc->stats->tx_err);
32792 dev_kfree_skb_any(skb);
32793 return -EINVAL;
32794 }
32795 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32796 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32797 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32798 card->index);
32799 - atomic_inc(&vcc->stats->tx_err);
32800 + atomic_inc_unchecked(&vcc->stats->tx_err);
32801 dev_kfree_skb_any(skb);
32802 return -EINVAL;
32803 }
32804
32805 if (skb_shinfo(skb)->nr_frags != 0) {
32806 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32807 - atomic_inc(&vcc->stats->tx_err);
32808 + atomic_inc_unchecked(&vcc->stats->tx_err);
32809 dev_kfree_skb_any(skb);
32810 return -EINVAL;
32811 }
32812 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32813 }
32814
32815 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32816 - atomic_inc(&vcc->stats->tx_err);
32817 + atomic_inc_unchecked(&vcc->stats->tx_err);
32818 dev_kfree_skb_any(skb);
32819 return -EIO;
32820 }
32821 - atomic_inc(&vcc->stats->tx);
32822 + atomic_inc_unchecked(&vcc->stats->tx);
32823
32824 return 0;
32825 }
32826 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32827 printk
32828 ("nicstar%d: Can't allocate buffers for aal0.\n",
32829 card->index);
32830 - atomic_add(i, &vcc->stats->rx_drop);
32831 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32832 break;
32833 }
32834 if (!atm_charge(vcc, sb->truesize)) {
32835 RXPRINTK
32836 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32837 card->index);
32838 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32839 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32840 dev_kfree_skb_any(sb);
32841 break;
32842 }
32843 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32844 ATM_SKB(sb)->vcc = vcc;
32845 __net_timestamp(sb);
32846 vcc->push(vcc, sb);
32847 - atomic_inc(&vcc->stats->rx);
32848 + atomic_inc_unchecked(&vcc->stats->rx);
32849 cell += ATM_CELL_PAYLOAD;
32850 }
32851
32852 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32853 if (iovb == NULL) {
32854 printk("nicstar%d: Out of iovec buffers.\n",
32855 card->index);
32856 - atomic_inc(&vcc->stats->rx_drop);
32857 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32858 recycle_rx_buf(card, skb);
32859 return;
32860 }
32861 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32862 small or large buffer itself. */
32863 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32864 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32865 - atomic_inc(&vcc->stats->rx_err);
32866 + atomic_inc_unchecked(&vcc->stats->rx_err);
32867 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32868 NS_MAX_IOVECS);
32869 NS_PRV_IOVCNT(iovb) = 0;
32870 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32871 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32872 card->index);
32873 which_list(card, skb);
32874 - atomic_inc(&vcc->stats->rx_err);
32875 + atomic_inc_unchecked(&vcc->stats->rx_err);
32876 recycle_rx_buf(card, skb);
32877 vc->rx_iov = NULL;
32878 recycle_iov_buf(card, iovb);
32879 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32880 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32881 card->index);
32882 which_list(card, skb);
32883 - atomic_inc(&vcc->stats->rx_err);
32884 + atomic_inc_unchecked(&vcc->stats->rx_err);
32885 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32886 NS_PRV_IOVCNT(iovb));
32887 vc->rx_iov = NULL;
32888 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32889 printk(" - PDU size mismatch.\n");
32890 else
32891 printk(".\n");
32892 - atomic_inc(&vcc->stats->rx_err);
32893 + atomic_inc_unchecked(&vcc->stats->rx_err);
32894 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32895 NS_PRV_IOVCNT(iovb));
32896 vc->rx_iov = NULL;
32897 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32898 /* skb points to a small buffer */
32899 if (!atm_charge(vcc, skb->truesize)) {
32900 push_rxbufs(card, skb);
32901 - atomic_inc(&vcc->stats->rx_drop);
32902 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32903 } else {
32904 skb_put(skb, len);
32905 dequeue_sm_buf(card, skb);
32906 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32907 ATM_SKB(skb)->vcc = vcc;
32908 __net_timestamp(skb);
32909 vcc->push(vcc, skb);
32910 - atomic_inc(&vcc->stats->rx);
32911 + atomic_inc_unchecked(&vcc->stats->rx);
32912 }
32913 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32914 struct sk_buff *sb;
32915 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32916 if (len <= NS_SMBUFSIZE) {
32917 if (!atm_charge(vcc, sb->truesize)) {
32918 push_rxbufs(card, sb);
32919 - atomic_inc(&vcc->stats->rx_drop);
32920 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32921 } else {
32922 skb_put(sb, len);
32923 dequeue_sm_buf(card, sb);
32924 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32925 ATM_SKB(sb)->vcc = vcc;
32926 __net_timestamp(sb);
32927 vcc->push(vcc, sb);
32928 - atomic_inc(&vcc->stats->rx);
32929 + atomic_inc_unchecked(&vcc->stats->rx);
32930 }
32931
32932 push_rxbufs(card, skb);
32933 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32934
32935 if (!atm_charge(vcc, skb->truesize)) {
32936 push_rxbufs(card, skb);
32937 - atomic_inc(&vcc->stats->rx_drop);
32938 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32939 } else {
32940 dequeue_lg_buf(card, skb);
32941 #ifdef NS_USE_DESTRUCTORS
32942 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32943 ATM_SKB(skb)->vcc = vcc;
32944 __net_timestamp(skb);
32945 vcc->push(vcc, skb);
32946 - atomic_inc(&vcc->stats->rx);
32947 + atomic_inc_unchecked(&vcc->stats->rx);
32948 }
32949
32950 push_rxbufs(card, sb);
32951 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32952 printk
32953 ("nicstar%d: Out of huge buffers.\n",
32954 card->index);
32955 - atomic_inc(&vcc->stats->rx_drop);
32956 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32957 recycle_iovec_rx_bufs(card,
32958 (struct iovec *)
32959 iovb->data,
32960 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32961 card->hbpool.count++;
32962 } else
32963 dev_kfree_skb_any(hb);
32964 - atomic_inc(&vcc->stats->rx_drop);
32965 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32966 } else {
32967 /* Copy the small buffer to the huge buffer */
32968 sb = (struct sk_buff *)iov->iov_base;
32969 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32970 #endif /* NS_USE_DESTRUCTORS */
32971 __net_timestamp(hb);
32972 vcc->push(vcc, hb);
32973 - atomic_inc(&vcc->stats->rx);
32974 + atomic_inc_unchecked(&vcc->stats->rx);
32975 }
32976 }
32977
32978 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32979 index 32784d1..4a8434a 100644
32980 --- a/drivers/atm/solos-pci.c
32981 +++ b/drivers/atm/solos-pci.c
32982 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32983 }
32984 atm_charge(vcc, skb->truesize);
32985 vcc->push(vcc, skb);
32986 - atomic_inc(&vcc->stats->rx);
32987 + atomic_inc_unchecked(&vcc->stats->rx);
32988 break;
32989
32990 case PKT_STATUS:
32991 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32992 vcc = SKB_CB(oldskb)->vcc;
32993
32994 if (vcc) {
32995 - atomic_inc(&vcc->stats->tx);
32996 + atomic_inc_unchecked(&vcc->stats->tx);
32997 solos_pop(vcc, oldskb);
32998 } else {
32999 dev_kfree_skb_irq(oldskb);
33000 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33001 index 0215934..ce9f5b1 100644
33002 --- a/drivers/atm/suni.c
33003 +++ b/drivers/atm/suni.c
33004 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33005
33006
33007 #define ADD_LIMITED(s,v) \
33008 - atomic_add((v),&stats->s); \
33009 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33010 + atomic_add_unchecked((v),&stats->s); \
33011 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33012
33013
33014 static void suni_hz(unsigned long from_timer)
33015 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33016 index 5120a96..e2572bd 100644
33017 --- a/drivers/atm/uPD98402.c
33018 +++ b/drivers/atm/uPD98402.c
33019 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33020 struct sonet_stats tmp;
33021 int error = 0;
33022
33023 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33024 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33025 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33026 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33027 if (zero && !error) {
33028 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33029
33030
33031 #define ADD_LIMITED(s,v) \
33032 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33033 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33034 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33035 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33036 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33037 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33038
33039
33040 static void stat_event(struct atm_dev *dev)
33041 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33042 if (reason & uPD98402_INT_PFM) stat_event(dev);
33043 if (reason & uPD98402_INT_PCO) {
33044 (void) GET(PCOCR); /* clear interrupt cause */
33045 - atomic_add(GET(HECCT),
33046 + atomic_add_unchecked(GET(HECCT),
33047 &PRIV(dev)->sonet_stats.uncorr_hcs);
33048 }
33049 if ((reason & uPD98402_INT_RFO) &&
33050 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33051 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33052 uPD98402_INT_LOS),PIMR); /* enable them */
33053 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33054 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33055 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33056 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33057 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33058 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33059 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33060 return 0;
33061 }
33062
33063 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33064 index 969c3c2..9b72956 100644
33065 --- a/drivers/atm/zatm.c
33066 +++ b/drivers/atm/zatm.c
33067 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33068 }
33069 if (!size) {
33070 dev_kfree_skb_irq(skb);
33071 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33072 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33073 continue;
33074 }
33075 if (!atm_charge(vcc,skb->truesize)) {
33076 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33077 skb->len = size;
33078 ATM_SKB(skb)->vcc = vcc;
33079 vcc->push(vcc,skb);
33080 - atomic_inc(&vcc->stats->rx);
33081 + atomic_inc_unchecked(&vcc->stats->rx);
33082 }
33083 zout(pos & 0xffff,MTA(mbx));
33084 #if 0 /* probably a stupid idea */
33085 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33086 skb_queue_head(&zatm_vcc->backlog,skb);
33087 break;
33088 }
33089 - atomic_inc(&vcc->stats->tx);
33090 + atomic_inc_unchecked(&vcc->stats->tx);
33091 wake_up(&zatm_vcc->tx_wait);
33092 }
33093
33094 diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
33095 index d78b204..ecc1929 100644
33096 --- a/drivers/base/attribute_container.c
33097 +++ b/drivers/base/attribute_container.c
33098 @@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
33099 ic->classdev.parent = get_device(dev);
33100 ic->classdev.class = cont->class;
33101 cont->class->dev_release = attribute_container_release;
33102 - dev_set_name(&ic->classdev, dev_name(dev));
33103 + dev_set_name(&ic->classdev, "%s", dev_name(dev));
33104 if (fn)
33105 fn(cont, dev, &ic->classdev);
33106 else
33107 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33108 index 519865b..e540db3 100644
33109 --- a/drivers/base/bus.c
33110 +++ b/drivers/base/bus.c
33111 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33112 return -EINVAL;
33113
33114 mutex_lock(&subsys->p->mutex);
33115 - list_add_tail(&sif->node, &subsys->p->interfaces);
33116 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33117 if (sif->add_dev) {
33118 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33119 while ((dev = subsys_dev_iter_next(&iter)))
33120 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33121 subsys = sif->subsys;
33122
33123 mutex_lock(&subsys->p->mutex);
33124 - list_del_init(&sif->node);
33125 + pax_list_del_init((struct list_head *)&sif->node);
33126 if (sif->remove_dev) {
33127 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33128 while ((dev = subsys_dev_iter_next(&iter)))
33129 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33130 index 01fc5b0..917801f 100644
33131 --- a/drivers/base/devtmpfs.c
33132 +++ b/drivers/base/devtmpfs.c
33133 @@ -348,7 +348,7 @@ int devtmpfs_mount(const char *mntdir)
33134 if (!thread)
33135 return 0;
33136
33137 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33138 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33139 if (err)
33140 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33141 else
33142 @@ -373,11 +373,11 @@ static int devtmpfsd(void *p)
33143 *err = sys_unshare(CLONE_NEWNS);
33144 if (*err)
33145 goto out;
33146 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
33147 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
33148 if (*err)
33149 goto out;
33150 - sys_chdir("/.."); /* will traverse into overmounted root */
33151 - sys_chroot(".");
33152 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
33153 + sys_chroot((char __force_user *)".");
33154 complete(&setup_done);
33155 while (1) {
33156 spin_lock(&req_lock);
33157 diff --git a/drivers/base/node.c b/drivers/base/node.c
33158 index fac124a..66bd4ab 100644
33159 --- a/drivers/base/node.c
33160 +++ b/drivers/base/node.c
33161 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33162 struct node_attr {
33163 struct device_attribute attr;
33164 enum node_states state;
33165 -};
33166 +} __do_const;
33167
33168 static ssize_t show_node_state(struct device *dev,
33169 struct device_attribute *attr, char *buf)
33170 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33171 index 9a6b05a..2fc8fb9 100644
33172 --- a/drivers/base/power/domain.c
33173 +++ b/drivers/base/power/domain.c
33174 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33175 {
33176 struct cpuidle_driver *cpuidle_drv;
33177 struct gpd_cpu_data *cpu_data;
33178 - struct cpuidle_state *idle_state;
33179 + cpuidle_state_no_const *idle_state;
33180 int ret = 0;
33181
33182 if (IS_ERR_OR_NULL(genpd) || state < 0)
33183 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33184 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33185 {
33186 struct gpd_cpu_data *cpu_data;
33187 - struct cpuidle_state *idle_state;
33188 + cpuidle_state_no_const *idle_state;
33189 int ret = 0;
33190
33191 if (IS_ERR_OR_NULL(genpd))
33192 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
33193 index a53ebd2..8f73eeb 100644
33194 --- a/drivers/base/power/sysfs.c
33195 +++ b/drivers/base/power/sysfs.c
33196 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
33197 return -EIO;
33198 }
33199 }
33200 - return sprintf(buf, p);
33201 + return sprintf(buf, "%s", p);
33202 }
33203
33204 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
33205 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33206 index 79715e7..df06b3b 100644
33207 --- a/drivers/base/power/wakeup.c
33208 +++ b/drivers/base/power/wakeup.c
33209 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33210 * They need to be modified together atomically, so it's better to use one
33211 * atomic variable to hold them both.
33212 */
33213 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33214 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33215
33216 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33217 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33218
33219 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33220 {
33221 - unsigned int comb = atomic_read(&combined_event_count);
33222 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33223
33224 *cnt = (comb >> IN_PROGRESS_BITS);
33225 *inpr = comb & MAX_IN_PROGRESS;
33226 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33227 ws->start_prevent_time = ws->last_time;
33228
33229 /* Increment the counter of events in progress. */
33230 - cec = atomic_inc_return(&combined_event_count);
33231 + cec = atomic_inc_return_unchecked(&combined_event_count);
33232
33233 trace_wakeup_source_activate(ws->name, cec);
33234 }
33235 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33236 * Increment the counter of registered wakeup events and decrement the
33237 * couter of wakeup events in progress simultaneously.
33238 */
33239 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33240 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33241 trace_wakeup_source_deactivate(ws->name, cec);
33242
33243 split_counters(&cnt, &inpr);
33244 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33245 index e8d11b6..7b1b36f 100644
33246 --- a/drivers/base/syscore.c
33247 +++ b/drivers/base/syscore.c
33248 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33249 void register_syscore_ops(struct syscore_ops *ops)
33250 {
33251 mutex_lock(&syscore_ops_lock);
33252 - list_add_tail(&ops->node, &syscore_ops_list);
33253 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33254 mutex_unlock(&syscore_ops_lock);
33255 }
33256 EXPORT_SYMBOL_GPL(register_syscore_ops);
33257 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33258 void unregister_syscore_ops(struct syscore_ops *ops)
33259 {
33260 mutex_lock(&syscore_ops_lock);
33261 - list_del(&ops->node);
33262 + pax_list_del((struct list_head *)&ops->node);
33263 mutex_unlock(&syscore_ops_lock);
33264 }
33265 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33266 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33267 index dadea48..a1f3835 100644
33268 --- a/drivers/block/cciss.c
33269 +++ b/drivers/block/cciss.c
33270 @@ -1184,6 +1184,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33271 int err;
33272 u32 cp;
33273
33274 + memset(&arg64, 0, sizeof(arg64));
33275 +
33276 err = 0;
33277 err |=
33278 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33279 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33280 while (!list_empty(&h->reqQ)) {
33281 c = list_entry(h->reqQ.next, CommandList_struct, list);
33282 /* can't do anything if fifo is full */
33283 - if ((h->access.fifo_full(h))) {
33284 + if ((h->access->fifo_full(h))) {
33285 dev_warn(&h->pdev->dev, "fifo full\n");
33286 break;
33287 }
33288 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33289 h->Qdepth--;
33290
33291 /* Tell the controller execute command */
33292 - h->access.submit_command(h, c);
33293 + h->access->submit_command(h, c);
33294
33295 /* Put job onto the completed Q */
33296 addQ(&h->cmpQ, c);
33297 @@ -3441,17 +3443,17 @@ startio:
33298
33299 static inline unsigned long get_next_completion(ctlr_info_t *h)
33300 {
33301 - return h->access.command_completed(h);
33302 + return h->access->command_completed(h);
33303 }
33304
33305 static inline int interrupt_pending(ctlr_info_t *h)
33306 {
33307 - return h->access.intr_pending(h);
33308 + return h->access->intr_pending(h);
33309 }
33310
33311 static inline long interrupt_not_for_us(ctlr_info_t *h)
33312 {
33313 - return ((h->access.intr_pending(h) == 0) ||
33314 + return ((h->access->intr_pending(h) == 0) ||
33315 (h->interrupts_enabled == 0));
33316 }
33317
33318 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33319 u32 a;
33320
33321 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33322 - return h->access.command_completed(h);
33323 + return h->access->command_completed(h);
33324
33325 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33326 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33327 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33328 trans_support & CFGTBL_Trans_use_short_tags);
33329
33330 /* Change the access methods to the performant access methods */
33331 - h->access = SA5_performant_access;
33332 + h->access = &SA5_performant_access;
33333 h->transMethod = CFGTBL_Trans_Performant;
33334
33335 return;
33336 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33337 if (prod_index < 0)
33338 return -ENODEV;
33339 h->product_name = products[prod_index].product_name;
33340 - h->access = *(products[prod_index].access);
33341 + h->access = products[prod_index].access;
33342
33343 if (cciss_board_disabled(h)) {
33344 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33345 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33346 }
33347
33348 /* make sure the board interrupts are off */
33349 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33350 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33351 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33352 if (rc)
33353 goto clean2;
33354 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33355 * fake ones to scoop up any residual completions.
33356 */
33357 spin_lock_irqsave(&h->lock, flags);
33358 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33359 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33360 spin_unlock_irqrestore(&h->lock, flags);
33361 free_irq(h->intr[h->intr_mode], h);
33362 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33363 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33364 dev_info(&h->pdev->dev, "Board READY.\n");
33365 dev_info(&h->pdev->dev,
33366 "Waiting for stale completions to drain.\n");
33367 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33368 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33369 msleep(10000);
33370 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33371 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33372
33373 rc = controller_reset_failed(h->cfgtable);
33374 if (rc)
33375 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33376 cciss_scsi_setup(h);
33377
33378 /* Turn the interrupts on so we can service requests */
33379 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33380 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33381
33382 /* Get the firmware version */
33383 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33384 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33385 kfree(flush_buf);
33386 if (return_code != IO_OK)
33387 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33388 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33389 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33390 free_irq(h->intr[h->intr_mode], h);
33391 }
33392
33393 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33394 index 7fda30e..eb5dfe0 100644
33395 --- a/drivers/block/cciss.h
33396 +++ b/drivers/block/cciss.h
33397 @@ -101,7 +101,7 @@ struct ctlr_info
33398 /* information about each logical volume */
33399 drive_info_struct *drv[CISS_MAX_LUN];
33400
33401 - struct access_method access;
33402 + struct access_method *access;
33403
33404 /* queue and queue Info */
33405 struct list_head reqQ;
33406 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33407 index 3f08713..87d4b4a 100644
33408 --- a/drivers/block/cpqarray.c
33409 +++ b/drivers/block/cpqarray.c
33410 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33411 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33412 goto Enomem4;
33413 }
33414 - hba[i]->access.set_intr_mask(hba[i], 0);
33415 + hba[i]->access->set_intr_mask(hba[i], 0);
33416 if (request_irq(hba[i]->intr, do_ida_intr,
33417 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33418 {
33419 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33420 add_timer(&hba[i]->timer);
33421
33422 /* Enable IRQ now that spinlock and rate limit timer are set up */
33423 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33424 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33425
33426 for(j=0; j<NWD; j++) {
33427 struct gendisk *disk = ida_gendisk[i][j];
33428 @@ -694,7 +694,7 @@ DBGINFO(
33429 for(i=0; i<NR_PRODUCTS; i++) {
33430 if (board_id == products[i].board_id) {
33431 c->product_name = products[i].product_name;
33432 - c->access = *(products[i].access);
33433 + c->access = products[i].access;
33434 break;
33435 }
33436 }
33437 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33438 hba[ctlr]->intr = intr;
33439 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33440 hba[ctlr]->product_name = products[j].product_name;
33441 - hba[ctlr]->access = *(products[j].access);
33442 + hba[ctlr]->access = products[j].access;
33443 hba[ctlr]->ctlr = ctlr;
33444 hba[ctlr]->board_id = board_id;
33445 hba[ctlr]->pci_dev = NULL; /* not PCI */
33446 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33447
33448 while((c = h->reqQ) != NULL) {
33449 /* Can't do anything if we're busy */
33450 - if (h->access.fifo_full(h) == 0)
33451 + if (h->access->fifo_full(h) == 0)
33452 return;
33453
33454 /* Get the first entry from the request Q */
33455 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33456 h->Qdepth--;
33457
33458 /* Tell the controller to do our bidding */
33459 - h->access.submit_command(h, c);
33460 + h->access->submit_command(h, c);
33461
33462 /* Get onto the completion Q */
33463 addQ(&h->cmpQ, c);
33464 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33465 unsigned long flags;
33466 __u32 a,a1;
33467
33468 - istat = h->access.intr_pending(h);
33469 + istat = h->access->intr_pending(h);
33470 /* Is this interrupt for us? */
33471 if (istat == 0)
33472 return IRQ_NONE;
33473 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33474 */
33475 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33476 if (istat & FIFO_NOT_EMPTY) {
33477 - while((a = h->access.command_completed(h))) {
33478 + while((a = h->access->command_completed(h))) {
33479 a1 = a; a &= ~3;
33480 if ((c = h->cmpQ) == NULL)
33481 {
33482 @@ -1195,6 +1195,7 @@ out_passthru:
33483 ida_pci_info_struct pciinfo;
33484
33485 if (!arg) return -EINVAL;
33486 + memset(&pciinfo, 0, sizeof(pciinfo));
33487 pciinfo.bus = host->pci_dev->bus->number;
33488 pciinfo.dev_fn = host->pci_dev->devfn;
33489 pciinfo.board_id = host->board_id;
33490 @@ -1449,11 +1450,11 @@ static int sendcmd(
33491 /*
33492 * Disable interrupt
33493 */
33494 - info_p->access.set_intr_mask(info_p, 0);
33495 + info_p->access->set_intr_mask(info_p, 0);
33496 /* Make sure there is room in the command FIFO */
33497 /* Actually it should be completely empty at this time. */
33498 for (i = 200000; i > 0; i--) {
33499 - temp = info_p->access.fifo_full(info_p);
33500 + temp = info_p->access->fifo_full(info_p);
33501 if (temp != 0) {
33502 break;
33503 }
33504 @@ -1466,7 +1467,7 @@ DBG(
33505 /*
33506 * Send the cmd
33507 */
33508 - info_p->access.submit_command(info_p, c);
33509 + info_p->access->submit_command(info_p, c);
33510 complete = pollcomplete(ctlr);
33511
33512 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33513 @@ -1549,9 +1550,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33514 * we check the new geometry. Then turn interrupts back on when
33515 * we're done.
33516 */
33517 - host->access.set_intr_mask(host, 0);
33518 + host->access->set_intr_mask(host, 0);
33519 getgeometry(ctlr);
33520 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33521 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33522
33523 for(i=0; i<NWD; i++) {
33524 struct gendisk *disk = ida_gendisk[ctlr][i];
33525 @@ -1591,7 +1592,7 @@ static int pollcomplete(int ctlr)
33526 /* Wait (up to 2 seconds) for a command to complete */
33527
33528 for (i = 200000; i > 0; i--) {
33529 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33530 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33531 if (done == 0) {
33532 udelay(10); /* a short fixed delay */
33533 } else
33534 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33535 index be73e9d..7fbf140 100644
33536 --- a/drivers/block/cpqarray.h
33537 +++ b/drivers/block/cpqarray.h
33538 @@ -99,7 +99,7 @@ struct ctlr_info {
33539 drv_info_t drv[NWD];
33540 struct proc_dir_entry *proc;
33541
33542 - struct access_method access;
33543 + struct access_method *access;
33544
33545 cmdlist_t *reqQ;
33546 cmdlist_t *cmpQ;
33547 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33548 index 6b51afa..17e1191 100644
33549 --- a/drivers/block/drbd/drbd_int.h
33550 +++ b/drivers/block/drbd/drbd_int.h
33551 @@ -582,7 +582,7 @@ struct drbd_epoch {
33552 struct drbd_tconn *tconn;
33553 struct list_head list;
33554 unsigned int barrier_nr;
33555 - atomic_t epoch_size; /* increased on every request added. */
33556 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33557 atomic_t active; /* increased on every req. added, and dec on every finished. */
33558 unsigned long flags;
33559 };
33560 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33561 int al_tr_cycle;
33562 int al_tr_pos; /* position of the next transaction in the journal */
33563 wait_queue_head_t seq_wait;
33564 - atomic_t packet_seq;
33565 + atomic_unchecked_t packet_seq;
33566 unsigned int peer_seq;
33567 spinlock_t peer_seq_lock;
33568 unsigned int minor;
33569 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33570 char __user *uoptval;
33571 int err;
33572
33573 - uoptval = (char __user __force *)optval;
33574 + uoptval = (char __force_user *)optval;
33575
33576 set_fs(KERNEL_DS);
33577 if (level == SOL_SOCKET)
33578 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33579 index 54d03d4..332f311 100644
33580 --- a/drivers/block/drbd/drbd_main.c
33581 +++ b/drivers/block/drbd/drbd_main.c
33582 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33583 p->sector = sector;
33584 p->block_id = block_id;
33585 p->blksize = blksize;
33586 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33587 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33588 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33589 }
33590
33591 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33592 return -EIO;
33593 p->sector = cpu_to_be64(req->i.sector);
33594 p->block_id = (unsigned long)req;
33595 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33596 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33597 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33598 if (mdev->state.conn >= C_SYNC_SOURCE &&
33599 mdev->state.conn <= C_PAUSED_SYNC_T)
33600 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33601 {
33602 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33603
33604 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33605 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33606 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33607 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33608 kfree(tconn->current_epoch);
33609
33610 idr_destroy(&tconn->volumes);
33611 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33612 index 2f5fffd..b22a1ae 100644
33613 --- a/drivers/block/drbd/drbd_receiver.c
33614 +++ b/drivers/block/drbd/drbd_receiver.c
33615 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33616 {
33617 int err;
33618
33619 - atomic_set(&mdev->packet_seq, 0);
33620 + atomic_set_unchecked(&mdev->packet_seq, 0);
33621 mdev->peer_seq = 0;
33622
33623 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33624 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33625 do {
33626 next_epoch = NULL;
33627
33628 - epoch_size = atomic_read(&epoch->epoch_size);
33629 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33630
33631 switch (ev & ~EV_CLEANUP) {
33632 case EV_PUT:
33633 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33634 rv = FE_DESTROYED;
33635 } else {
33636 epoch->flags = 0;
33637 - atomic_set(&epoch->epoch_size, 0);
33638 + atomic_set_unchecked(&epoch->epoch_size, 0);
33639 /* atomic_set(&epoch->active, 0); is already zero */
33640 if (rv == FE_STILL_LIVE)
33641 rv = FE_RECYCLED;
33642 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33643 conn_wait_active_ee_empty(tconn);
33644 drbd_flush(tconn);
33645
33646 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33647 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33648 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33649 if (epoch)
33650 break;
33651 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33652 }
33653
33654 epoch->flags = 0;
33655 - atomic_set(&epoch->epoch_size, 0);
33656 + atomic_set_unchecked(&epoch->epoch_size, 0);
33657 atomic_set(&epoch->active, 0);
33658
33659 spin_lock(&tconn->epoch_lock);
33660 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33661 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33662 list_add(&epoch->list, &tconn->current_epoch->list);
33663 tconn->current_epoch = epoch;
33664 tconn->epochs++;
33665 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33666
33667 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33668 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33669 - atomic_inc(&tconn->current_epoch->epoch_size);
33670 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33671 err2 = drbd_drain_block(mdev, pi->size);
33672 if (!err)
33673 err = err2;
33674 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33675
33676 spin_lock(&tconn->epoch_lock);
33677 peer_req->epoch = tconn->current_epoch;
33678 - atomic_inc(&peer_req->epoch->epoch_size);
33679 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33680 atomic_inc(&peer_req->epoch->active);
33681 spin_unlock(&tconn->epoch_lock);
33682
33683 @@ -4345,7 +4345,7 @@ struct data_cmd {
33684 int expect_payload;
33685 size_t pkt_size;
33686 int (*fn)(struct drbd_tconn *, struct packet_info *);
33687 -};
33688 +} __do_const;
33689
33690 static struct data_cmd drbd_cmd_handler[] = {
33691 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33692 @@ -4465,7 +4465,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33693 if (!list_empty(&tconn->current_epoch->list))
33694 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33695 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33696 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33697 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33698 tconn->send.seen_any_write_yet = false;
33699
33700 conn_info(tconn, "Connection closed\n");
33701 @@ -5221,7 +5221,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33702 struct asender_cmd {
33703 size_t pkt_size;
33704 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33705 -};
33706 +} __do_const;
33707
33708 static struct asender_cmd asender_tbl[] = {
33709 [P_PING] = { 0, got_Ping },
33710 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33711 index dfe7583..83768bb 100644
33712 --- a/drivers/block/loop.c
33713 +++ b/drivers/block/loop.c
33714 @@ -231,7 +231,7 @@ static int __do_lo_send_write(struct file *file,
33715 mm_segment_t old_fs = get_fs();
33716
33717 set_fs(get_ds());
33718 - bw = file->f_op->write(file, buf, len, &pos);
33719 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33720 set_fs(old_fs);
33721 if (likely(bw == len))
33722 return 0;
33723 diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
33724 index 7fecc78..84d217c 100644
33725 --- a/drivers/block/nbd.c
33726 +++ b/drivers/block/nbd.c
33727 @@ -714,7 +714,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
33728 else
33729 blk_queue_flush(nbd->disk->queue, 0);
33730
33731 - thread = kthread_create(nbd_thread, nbd, nbd->disk->disk_name);
33732 + thread = kthread_create(nbd_thread, nbd, "%s", nbd->disk->disk_name);
33733 if (IS_ERR(thread)) {
33734 mutex_lock(&nbd->tx_lock);
33735 return PTR_ERR(thread);
33736 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33737 index 2e7de7a..ed86dc0 100644
33738 --- a/drivers/block/pktcdvd.c
33739 +++ b/drivers/block/pktcdvd.c
33740 @@ -83,7 +83,7 @@
33741
33742 #define MAX_SPEED 0xffff
33743
33744 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33745 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33746
33747 static DEFINE_MUTEX(pktcdvd_mutex);
33748 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33749 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33750 index d620b44..d7538c2 100644
33751 --- a/drivers/cdrom/cdrom.c
33752 +++ b/drivers/cdrom/cdrom.c
33753 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33754 ENSURE(reset, CDC_RESET);
33755 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33756 cdi->mc_flags = 0;
33757 - cdo->n_minors = 0;
33758 cdi->options = CDO_USE_FFLAGS;
33759
33760 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33761 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33762 else
33763 cdi->cdda_method = CDDA_OLD;
33764
33765 - if (!cdo->generic_packet)
33766 - cdo->generic_packet = cdrom_dummy_generic_packet;
33767 + if (!cdo->generic_packet) {
33768 + pax_open_kernel();
33769 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33770 + pax_close_kernel();
33771 + }
33772
33773 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33774 mutex_lock(&cdrom_mutex);
33775 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33776 if (cdi->exit)
33777 cdi->exit(cdi);
33778
33779 - cdi->ops->n_minors--;
33780 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33781 }
33782
33783 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
33784 */
33785 nr = nframes;
33786 do {
33787 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33788 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33789 if (cgc.buffer)
33790 break;
33791
33792 @@ -2882,7 +2883,7 @@ static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi,
33793 if (lba < 0)
33794 return -EINVAL;
33795
33796 - cgc->buffer = kmalloc(blocksize, GFP_KERNEL);
33797 + cgc->buffer = kzalloc(blocksize, GFP_KERNEL);
33798 if (cgc->buffer == NULL)
33799 return -ENOMEM;
33800
33801 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
33802 struct cdrom_device_info *cdi;
33803 int ret;
33804
33805 - ret = scnprintf(info + *pos, max_size - *pos, header);
33806 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
33807 if (!ret)
33808 return 1;
33809
33810 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33811 index d59cdcb..11afddf 100644
33812 --- a/drivers/cdrom/gdrom.c
33813 +++ b/drivers/cdrom/gdrom.c
33814 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33815 .audio_ioctl = gdrom_audio_ioctl,
33816 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33817 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33818 - .n_minors = 1,
33819 };
33820
33821 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33822 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33823 index 3bb6fa3..34013fb 100644
33824 --- a/drivers/char/Kconfig
33825 +++ b/drivers/char/Kconfig
33826 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33827
33828 config DEVKMEM
33829 bool "/dev/kmem virtual device support"
33830 - default y
33831 + default n
33832 + depends on !GRKERNSEC_KMEM
33833 help
33834 Say Y here if you want to support the /dev/kmem device. The
33835 /dev/kmem device is rarely used, but can be used for certain
33836 @@ -582,6 +583,7 @@ config DEVPORT
33837 bool
33838 depends on !M68K
33839 depends on ISA || PCI
33840 + depends on !GRKERNSEC_KMEM
33841 default y
33842
33843 source "drivers/s390/char/Kconfig"
33844 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33845 index a48e05b..6bac831 100644
33846 --- a/drivers/char/agp/compat_ioctl.c
33847 +++ b/drivers/char/agp/compat_ioctl.c
33848 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33849 return -ENOMEM;
33850 }
33851
33852 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33853 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33854 sizeof(*usegment) * ureserve.seg_count)) {
33855 kfree(usegment);
33856 kfree(ksegment);
33857 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33858 index 2e04433..771f2cc 100644
33859 --- a/drivers/char/agp/frontend.c
33860 +++ b/drivers/char/agp/frontend.c
33861 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33862 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33863 return -EFAULT;
33864
33865 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33866 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33867 return -EFAULT;
33868
33869 client = agp_find_client_by_pid(reserve.pid);
33870 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33871 if (segment == NULL)
33872 return -ENOMEM;
33873
33874 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33875 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33876 sizeof(struct agp_segment) * reserve.seg_count)) {
33877 kfree(segment);
33878 return -EFAULT;
33879 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33880 index 21cb980..f15107c 100644
33881 --- a/drivers/char/genrtc.c
33882 +++ b/drivers/char/genrtc.c
33883 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33884 switch (cmd) {
33885
33886 case RTC_PLL_GET:
33887 + memset(&pll, 0, sizeof(pll));
33888 if (get_rtc_pll(&pll))
33889 return -EINVAL;
33890 else
33891 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33892 index d784650..e8bfd69 100644
33893 --- a/drivers/char/hpet.c
33894 +++ b/drivers/char/hpet.c
33895 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33896 }
33897
33898 static int
33899 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33900 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33901 struct hpet_info *info)
33902 {
33903 struct hpet_timer __iomem *timer;
33904 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
33905 index 86fe45c..c0ea948 100644
33906 --- a/drivers/char/hw_random/intel-rng.c
33907 +++ b/drivers/char/hw_random/intel-rng.c
33908 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
33909
33910 if (no_fwh_detect)
33911 return -ENODEV;
33912 - printk(warning);
33913 + printk("%s", warning);
33914 return -EBUSY;
33915 }
33916
33917 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33918 index 053201b0..8335cce 100644
33919 --- a/drivers/char/ipmi/ipmi_msghandler.c
33920 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33921 @@ -420,7 +420,7 @@ struct ipmi_smi {
33922 struct proc_dir_entry *proc_dir;
33923 char proc_dir_name[10];
33924
33925 - atomic_t stats[IPMI_NUM_STATS];
33926 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33927
33928 /*
33929 * run_to_completion duplicate of smb_info, smi_info
33930 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33931
33932
33933 #define ipmi_inc_stat(intf, stat) \
33934 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33935 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33936 #define ipmi_get_stat(intf, stat) \
33937 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33938 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33939
33940 static int is_lan_addr(struct ipmi_addr *addr)
33941 {
33942 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33943 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33944 init_waitqueue_head(&intf->waitq);
33945 for (i = 0; i < IPMI_NUM_STATS; i++)
33946 - atomic_set(&intf->stats[i], 0);
33947 + atomic_set_unchecked(&intf->stats[i], 0);
33948
33949 intf->proc_dir = NULL;
33950
33951 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33952 index 0ac9b45..6179fb5 100644
33953 --- a/drivers/char/ipmi/ipmi_si_intf.c
33954 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33955 @@ -275,7 +275,7 @@ struct smi_info {
33956 unsigned char slave_addr;
33957
33958 /* Counters and things for the proc filesystem. */
33959 - atomic_t stats[SI_NUM_STATS];
33960 + atomic_unchecked_t stats[SI_NUM_STATS];
33961
33962 struct task_struct *thread;
33963
33964 @@ -284,9 +284,9 @@ struct smi_info {
33965 };
33966
33967 #define smi_inc_stat(smi, stat) \
33968 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33969 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33970 #define smi_get_stat(smi, stat) \
33971 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33972 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33973
33974 #define SI_MAX_PARMS 4
33975
33976 @@ -3254,7 +3254,7 @@ static int try_smi_init(struct smi_info *new_smi)
33977 atomic_set(&new_smi->req_events, 0);
33978 new_smi->run_to_completion = 0;
33979 for (i = 0; i < SI_NUM_STATS; i++)
33980 - atomic_set(&new_smi->stats[i], 0);
33981 + atomic_set_unchecked(&new_smi->stats[i], 0);
33982
33983 new_smi->interrupt_disabled = 1;
33984 atomic_set(&new_smi->stop_operation, 0);
33985 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33986 index 2c644af..4b7aede 100644
33987 --- a/drivers/char/mem.c
33988 +++ b/drivers/char/mem.c
33989 @@ -18,6 +18,7 @@
33990 #include <linux/raw.h>
33991 #include <linux/tty.h>
33992 #include <linux/capability.h>
33993 +#include <linux/security.h>
33994 #include <linux/ptrace.h>
33995 #include <linux/device.h>
33996 #include <linux/highmem.h>
33997 @@ -37,6 +38,10 @@
33998
33999 #define DEVPORT_MINOR 4
34000
34001 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34002 +extern const struct file_operations grsec_fops;
34003 +#endif
34004 +
34005 static inline unsigned long size_inside_page(unsigned long start,
34006 unsigned long size)
34007 {
34008 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34009
34010 while (cursor < to) {
34011 if (!devmem_is_allowed(pfn)) {
34012 +#ifdef CONFIG_GRKERNSEC_KMEM
34013 + gr_handle_mem_readwrite(from, to);
34014 +#else
34015 printk(KERN_INFO
34016 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34017 current->comm, from, to);
34018 +#endif
34019 return 0;
34020 }
34021 cursor += PAGE_SIZE;
34022 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34023 }
34024 return 1;
34025 }
34026 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34027 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34028 +{
34029 + return 0;
34030 +}
34031 #else
34032 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34033 {
34034 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34035
34036 while (count > 0) {
34037 unsigned long remaining;
34038 + char *temp;
34039
34040 sz = size_inside_page(p, count);
34041
34042 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34043 if (!ptr)
34044 return -EFAULT;
34045
34046 - remaining = copy_to_user(buf, ptr, sz);
34047 +#ifdef CONFIG_PAX_USERCOPY
34048 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34049 + if (!temp) {
34050 + unxlate_dev_mem_ptr(p, ptr);
34051 + return -ENOMEM;
34052 + }
34053 + memcpy(temp, ptr, sz);
34054 +#else
34055 + temp = ptr;
34056 +#endif
34057 +
34058 + remaining = copy_to_user(buf, temp, sz);
34059 +
34060 +#ifdef CONFIG_PAX_USERCOPY
34061 + kfree(temp);
34062 +#endif
34063 +
34064 unxlate_dev_mem_ptr(p, ptr);
34065 if (remaining)
34066 return -EFAULT;
34067 @@ -378,7 +409,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
34068 else
34069 csize = count;
34070
34071 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
34072 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
34073 if (rc < 0)
34074 return rc;
34075 buf += csize;
34076 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34077 size_t count, loff_t *ppos)
34078 {
34079 unsigned long p = *ppos;
34080 - ssize_t low_count, read, sz;
34081 + ssize_t low_count, read, sz, err = 0;
34082 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34083 - int err = 0;
34084
34085 read = 0;
34086 if (p < (unsigned long) high_memory) {
34087 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34088 }
34089 #endif
34090 while (low_count > 0) {
34091 + char *temp;
34092 +
34093 sz = size_inside_page(p, low_count);
34094
34095 /*
34096 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34097 */
34098 kbuf = xlate_dev_kmem_ptr((char *)p);
34099
34100 - if (copy_to_user(buf, kbuf, sz))
34101 +#ifdef CONFIG_PAX_USERCOPY
34102 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34103 + if (!temp)
34104 + return -ENOMEM;
34105 + memcpy(temp, kbuf, sz);
34106 +#else
34107 + temp = kbuf;
34108 +#endif
34109 +
34110 + err = copy_to_user(buf, temp, sz);
34111 +
34112 +#ifdef CONFIG_PAX_USERCOPY
34113 + kfree(temp);
34114 +#endif
34115 +
34116 + if (err)
34117 return -EFAULT;
34118 buf += sz;
34119 p += sz;
34120 @@ -833,6 +880,9 @@ static const struct memdev {
34121 #ifdef CONFIG_CRASH_DUMP
34122 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34123 #endif
34124 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34125 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34126 +#endif
34127 };
34128
34129 static int memory_open(struct inode *inode, struct file *filp)
34130 @@ -904,7 +954,7 @@ static int __init chr_dev_init(void)
34131 continue;
34132
34133 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
34134 - NULL, devlist[minor].name);
34135 + NULL, "%s", devlist[minor].name);
34136 }
34137
34138 return tty_init();
34139 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
34140 index c689697..04e6d6a2 100644
34141 --- a/drivers/char/mwave/tp3780i.c
34142 +++ b/drivers/char/mwave/tp3780i.c
34143 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
34144 PRINTK_2(TRACE_TP3780I,
34145 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
34146
34147 + memset(pAbilities, 0, sizeof(*pAbilities));
34148 /* fill out standard constant fields */
34149 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
34150 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
34151 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34152 index 9df78e2..01ba9ae 100644
34153 --- a/drivers/char/nvram.c
34154 +++ b/drivers/char/nvram.c
34155 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34156
34157 spin_unlock_irq(&rtc_lock);
34158
34159 - if (copy_to_user(buf, contents, tmp - contents))
34160 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34161 return -EFAULT;
34162
34163 *ppos = i;
34164 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34165 index 5c5cc00..ac9edb7 100644
34166 --- a/drivers/char/pcmcia/synclink_cs.c
34167 +++ b/drivers/char/pcmcia/synclink_cs.c
34168 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34169
34170 if (debug_level >= DEBUG_LEVEL_INFO)
34171 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34172 - __FILE__, __LINE__, info->device_name, port->count);
34173 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
34174
34175 - WARN_ON(!port->count);
34176 + WARN_ON(!atomic_read(&port->count));
34177
34178 if (tty_port_close_start(port, tty, filp) == 0)
34179 goto cleanup;
34180 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34181 cleanup:
34182 if (debug_level >= DEBUG_LEVEL_INFO)
34183 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
34184 - tty->driver->name, port->count);
34185 + tty->driver->name, atomic_read(&port->count));
34186 }
34187
34188 /* Wait until the transmitter is empty.
34189 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34190
34191 if (debug_level >= DEBUG_LEVEL_INFO)
34192 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34193 - __FILE__, __LINE__, tty->driver->name, port->count);
34194 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
34195
34196 /* If port is closing, signal caller to try again */
34197 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34198 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34199 goto cleanup;
34200 }
34201 spin_lock(&port->lock);
34202 - port->count++;
34203 + atomic_inc(&port->count);
34204 spin_unlock(&port->lock);
34205 spin_unlock_irqrestore(&info->netlock, flags);
34206
34207 - if (port->count == 1) {
34208 + if (atomic_read(&port->count) == 1) {
34209 /* 1st open on this device, init hardware */
34210 retval = startup(info, tty);
34211 if (retval < 0)
34212 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34213 unsigned short new_crctype;
34214
34215 /* return error if TTY interface open */
34216 - if (info->port.count)
34217 + if (atomic_read(&info->port.count))
34218 return -EBUSY;
34219
34220 switch (encoding)
34221 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
34222
34223 /* arbitrate between network and tty opens */
34224 spin_lock_irqsave(&info->netlock, flags);
34225 - if (info->port.count != 0 || info->netcount != 0) {
34226 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34227 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34228 spin_unlock_irqrestore(&info->netlock, flags);
34229 return -EBUSY;
34230 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34231 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
34232
34233 /* return error if TTY interface open */
34234 - if (info->port.count)
34235 + if (atomic_read(&info->port.count))
34236 return -EBUSY;
34237
34238 if (cmd != SIOCWANDEV)
34239 diff --git a/drivers/char/random.c b/drivers/char/random.c
34240 index eccd7cc..98038d5 100644
34241 --- a/drivers/char/random.c
34242 +++ b/drivers/char/random.c
34243 @@ -272,8 +272,13 @@
34244 /*
34245 * Configuration information
34246 */
34247 +#ifdef CONFIG_GRKERNSEC_RANDNET
34248 +#define INPUT_POOL_WORDS 512
34249 +#define OUTPUT_POOL_WORDS 128
34250 +#else
34251 #define INPUT_POOL_WORDS 128
34252 #define OUTPUT_POOL_WORDS 32
34253 +#endif
34254 #define SEC_XFER_SIZE 512
34255 #define EXTRACT_SIZE 10
34256
34257 @@ -313,10 +318,17 @@ static struct poolinfo {
34258 int poolwords;
34259 int tap1, tap2, tap3, tap4, tap5;
34260 } poolinfo_table[] = {
34261 +#ifdef CONFIG_GRKERNSEC_RANDNET
34262 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34263 + { 512, 411, 308, 208, 104, 1 },
34264 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34265 + { 128, 103, 76, 51, 25, 1 },
34266 +#else
34267 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34268 { 128, 103, 76, 51, 25, 1 },
34269 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34270 { 32, 26, 20, 14, 7, 1 },
34271 +#endif
34272 #if 0
34273 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34274 { 2048, 1638, 1231, 819, 411, 1 },
34275 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34276 input_rotate += i ? 7 : 14;
34277 }
34278
34279 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34280 - ACCESS_ONCE(r->add_ptr) = i;
34281 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34282 + ACCESS_ONCE_RW(r->add_ptr) = i;
34283 smp_wmb();
34284
34285 if (out)
34286 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34287
34288 extract_buf(r, tmp);
34289 i = min_t(int, nbytes, EXTRACT_SIZE);
34290 - if (copy_to_user(buf, tmp, i)) {
34291 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34292 ret = -EFAULT;
34293 break;
34294 }
34295 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34296 #include <linux/sysctl.h>
34297
34298 static int min_read_thresh = 8, min_write_thresh;
34299 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34300 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34301 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34302 static char sysctl_bootid[16];
34303
34304 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
34305 static int proc_do_uuid(ctl_table *table, int write,
34306 void __user *buffer, size_t *lenp, loff_t *ppos)
34307 {
34308 - ctl_table fake_table;
34309 + ctl_table_no_const fake_table;
34310 unsigned char buf[64], tmp_uuid[16], *uuid;
34311
34312 uuid = table->data;
34313 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34314 index bf2349db..5456d53 100644
34315 --- a/drivers/char/sonypi.c
34316 +++ b/drivers/char/sonypi.c
34317 @@ -54,6 +54,7 @@
34318
34319 #include <asm/uaccess.h>
34320 #include <asm/io.h>
34321 +#include <asm/local.h>
34322
34323 #include <linux/sonypi.h>
34324
34325 @@ -490,7 +491,7 @@ static struct sonypi_device {
34326 spinlock_t fifo_lock;
34327 wait_queue_head_t fifo_proc_list;
34328 struct fasync_struct *fifo_async;
34329 - int open_count;
34330 + local_t open_count;
34331 int model;
34332 struct input_dev *input_jog_dev;
34333 struct input_dev *input_key_dev;
34334 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34335 static int sonypi_misc_release(struct inode *inode, struct file *file)
34336 {
34337 mutex_lock(&sonypi_device.lock);
34338 - sonypi_device.open_count--;
34339 + local_dec(&sonypi_device.open_count);
34340 mutex_unlock(&sonypi_device.lock);
34341 return 0;
34342 }
34343 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34344 {
34345 mutex_lock(&sonypi_device.lock);
34346 /* Flush input queue on first open */
34347 - if (!sonypi_device.open_count)
34348 + if (!local_read(&sonypi_device.open_count))
34349 kfifo_reset(&sonypi_device.fifo);
34350 - sonypi_device.open_count++;
34351 + local_inc(&sonypi_device.open_count);
34352 mutex_unlock(&sonypi_device.lock);
34353
34354 return 0;
34355 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34356 index 64420b3..5c40b56 100644
34357 --- a/drivers/char/tpm/tpm_acpi.c
34358 +++ b/drivers/char/tpm/tpm_acpi.c
34359 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34360 virt = acpi_os_map_memory(start, len);
34361 if (!virt) {
34362 kfree(log->bios_event_log);
34363 + log->bios_event_log = NULL;
34364 printk("%s: ERROR - Unable to map memory\n", __func__);
34365 return -EIO;
34366 }
34367
34368 - memcpy_fromio(log->bios_event_log, virt, len);
34369 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34370
34371 acpi_os_unmap_memory(virt, len);
34372 return 0;
34373 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34374 index 84ddc55..1d32f1e 100644
34375 --- a/drivers/char/tpm/tpm_eventlog.c
34376 +++ b/drivers/char/tpm/tpm_eventlog.c
34377 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34378 event = addr;
34379
34380 if ((event->event_type == 0 && event->event_size == 0) ||
34381 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34382 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34383 return NULL;
34384
34385 return addr;
34386 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34387 return NULL;
34388
34389 if ((event->event_type == 0 && event->event_size == 0) ||
34390 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34391 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34392 return NULL;
34393
34394 (*pos)++;
34395 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34396 int i;
34397
34398 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34399 - seq_putc(m, data[i]);
34400 + if (!seq_putc(m, data[i]))
34401 + return -EFAULT;
34402
34403 return 0;
34404 }
34405 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34406 index ce5f3fc..e2d3e55 100644
34407 --- a/drivers/char/virtio_console.c
34408 +++ b/drivers/char/virtio_console.c
34409 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34410 if (to_user) {
34411 ssize_t ret;
34412
34413 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34414 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34415 if (ret)
34416 return -EFAULT;
34417 } else {
34418 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34419 if (!port_has_data(port) && !port->host_connected)
34420 return 0;
34421
34422 - return fill_readbuf(port, ubuf, count, true);
34423 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34424 }
34425
34426 static int wait_port_writable(struct port *port, bool nonblock)
34427 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34428 index d7ad425..3e3f81f 100644
34429 --- a/drivers/clocksource/arm_arch_timer.c
34430 +++ b/drivers/clocksource/arm_arch_timer.c
34431 @@ -262,7 +262,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34432 return NOTIFY_OK;
34433 }
34434
34435 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34436 +static struct notifier_block arch_timer_cpu_nb = {
34437 .notifier_call = arch_timer_cpu_notify,
34438 };
34439
34440 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34441 index ade7513..069445f 100644
34442 --- a/drivers/clocksource/metag_generic.c
34443 +++ b/drivers/clocksource/metag_generic.c
34444 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34445 return NOTIFY_OK;
34446 }
34447
34448 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34449 +static struct notifier_block arch_timer_cpu_nb = {
34450 .notifier_call = arch_timer_cpu_notify,
34451 };
34452
34453 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34454 index bb5939b..d9accb7 100644
34455 --- a/drivers/cpufreq/acpi-cpufreq.c
34456 +++ b/drivers/cpufreq/acpi-cpufreq.c
34457 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34458 return sprintf(buf, "%u\n", boost_enabled);
34459 }
34460
34461 -static struct global_attr global_boost = __ATTR(boost, 0644,
34462 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34463 show_global_boost,
34464 store_global_boost);
34465
34466 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34467 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34468 per_cpu(acfreq_data, cpu) = data;
34469
34470 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34471 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34472 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34473 + pax_open_kernel();
34474 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34475 + pax_close_kernel();
34476 + }
34477
34478 result = acpi_processor_register_performance(data->acpi_data, cpu);
34479 if (result)
34480 @@ -839,7 +842,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34481 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34482 break;
34483 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34484 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34485 + pax_open_kernel();
34486 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34487 + pax_close_kernel();
34488 policy->cur = get_cur_freq_on_cpu(cpu);
34489 break;
34490 default:
34491 @@ -850,8 +855,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34492 acpi_processor_notify_smm(THIS_MODULE);
34493
34494 /* Check for APERF/MPERF support in hardware */
34495 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34496 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34497 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34498 + pax_open_kernel();
34499 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34500 + pax_close_kernel();
34501 + }
34502
34503 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34504 for (i = 0; i < perf->state_count; i++)
34505 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34506 index b02824d..51e44aa 100644
34507 --- a/drivers/cpufreq/cpufreq.c
34508 +++ b/drivers/cpufreq/cpufreq.c
34509 @@ -1813,7 +1813,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34510 return NOTIFY_OK;
34511 }
34512
34513 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34514 +static struct notifier_block cpufreq_cpu_notifier = {
34515 .notifier_call = cpufreq_cpu_callback,
34516 };
34517
34518 @@ -1845,8 +1845,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34519
34520 pr_debug("trying to register driver %s\n", driver_data->name);
34521
34522 - if (driver_data->setpolicy)
34523 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34524 + if (driver_data->setpolicy) {
34525 + pax_open_kernel();
34526 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34527 + pax_close_kernel();
34528 + }
34529
34530 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34531 if (cpufreq_driver) {
34532 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34533 index 5a76086..0f4d394 100644
34534 --- a/drivers/cpufreq/cpufreq_governor.c
34535 +++ b/drivers/cpufreq/cpufreq_governor.c
34536 @@ -201,8 +201,8 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34537 {
34538 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34539 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34540 - struct cs_ops *cs_ops = NULL;
34541 - struct od_ops *od_ops = NULL;
34542 + const struct cs_ops *cs_ops = NULL;
34543 + const struct od_ops *od_ops = NULL;
34544 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
34545 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
34546 struct cpu_dbs_common_info *cpu_cdbs;
34547 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34548 index cc4bd2f..ad142bc 100644
34549 --- a/drivers/cpufreq/cpufreq_governor.h
34550 +++ b/drivers/cpufreq/cpufreq_governor.h
34551 @@ -142,7 +142,7 @@ struct dbs_data {
34552 void (*gov_check_cpu)(int cpu, unsigned int load);
34553
34554 /* Governor specific ops, see below */
34555 - void *gov_ops;
34556 + const void *gov_ops;
34557 };
34558
34559 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34560 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34561 index bfd6273..e39dd63 100644
34562 --- a/drivers/cpufreq/cpufreq_stats.c
34563 +++ b/drivers/cpufreq/cpufreq_stats.c
34564 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34565 }
34566
34567 /* priority=1 so this will get called before cpufreq_remove_dev */
34568 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34569 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34570 .notifier_call = cpufreq_stat_cpu_callback,
34571 .priority = 1,
34572 };
34573 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34574 index 827629c9..0bc6a03 100644
34575 --- a/drivers/cpufreq/p4-clockmod.c
34576 +++ b/drivers/cpufreq/p4-clockmod.c
34577 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34578 case 0x0F: /* Core Duo */
34579 case 0x16: /* Celeron Core */
34580 case 0x1C: /* Atom */
34581 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34582 + pax_open_kernel();
34583 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34584 + pax_close_kernel();
34585 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34586 case 0x0D: /* Pentium M (Dothan) */
34587 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34588 + pax_open_kernel();
34589 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34590 + pax_close_kernel();
34591 /* fall through */
34592 case 0x09: /* Pentium M (Banias) */
34593 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34594 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34595
34596 /* on P-4s, the TSC runs with constant frequency independent whether
34597 * throttling is active or not. */
34598 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34599 + pax_open_kernel();
34600 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34601 + pax_close_kernel();
34602
34603 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34604 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34605 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34606 index 3a953d5..f5993f6 100644
34607 --- a/drivers/cpufreq/speedstep-centrino.c
34608 +++ b/drivers/cpufreq/speedstep-centrino.c
34609 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34610 !cpu_has(cpu, X86_FEATURE_EST))
34611 return -ENODEV;
34612
34613 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34614 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34615 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34616 + pax_open_kernel();
34617 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34618 + pax_close_kernel();
34619 + }
34620
34621 if (policy->cpu != 0)
34622 return -ENODEV;
34623 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34624 index eba6929..0f53baf 100644
34625 --- a/drivers/cpuidle/cpuidle.c
34626 +++ b/drivers/cpuidle/cpuidle.c
34627 @@ -277,7 +277,7 @@ static int poll_idle(struct cpuidle_device *dev,
34628
34629 static void poll_idle_init(struct cpuidle_driver *drv)
34630 {
34631 - struct cpuidle_state *state = &drv->states[0];
34632 + cpuidle_state_no_const *state = &drv->states[0];
34633
34634 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34635 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34636 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34637 index ea2f8e7..70ac501 100644
34638 --- a/drivers/cpuidle/governor.c
34639 +++ b/drivers/cpuidle/governor.c
34640 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34641 mutex_lock(&cpuidle_lock);
34642 if (__cpuidle_find_governor(gov->name) == NULL) {
34643 ret = 0;
34644 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34645 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34646 if (!cpuidle_curr_governor ||
34647 cpuidle_curr_governor->rating < gov->rating)
34648 cpuidle_switch_governor(gov);
34649 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34650 new_gov = cpuidle_replace_governor(gov->rating);
34651 cpuidle_switch_governor(new_gov);
34652 }
34653 - list_del(&gov->governor_list);
34654 + pax_list_del((struct list_head *)&gov->governor_list);
34655 mutex_unlock(&cpuidle_lock);
34656 }
34657
34658 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34659 index 428754a..8bdf9cc 100644
34660 --- a/drivers/cpuidle/sysfs.c
34661 +++ b/drivers/cpuidle/sysfs.c
34662 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34663 NULL
34664 };
34665
34666 -static struct attribute_group cpuidle_attr_group = {
34667 +static attribute_group_no_const cpuidle_attr_group = {
34668 .attrs = cpuidle_default_attrs,
34669 .name = "cpuidle",
34670 };
34671 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34672 index 3b36797..db0b0c0 100644
34673 --- a/drivers/devfreq/devfreq.c
34674 +++ b/drivers/devfreq/devfreq.c
34675 @@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
34676 GFP_KERNEL);
34677 devfreq->last_stat_updated = jiffies;
34678
34679 - dev_set_name(&devfreq->dev, dev_name(dev));
34680 + dev_set_name(&devfreq->dev, "%s", dev_name(dev));
34681 err = device_register(&devfreq->dev);
34682 if (err) {
34683 put_device(&devfreq->dev);
34684 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34685 goto err_out;
34686 }
34687
34688 - list_add(&governor->node, &devfreq_governor_list);
34689 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34690
34691 list_for_each_entry(devfreq, &devfreq_list, node) {
34692 int ret = 0;
34693 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34694 }
34695 }
34696
34697 - list_del(&governor->node);
34698 + pax_list_del((struct list_head *)&governor->node);
34699 err_out:
34700 mutex_unlock(&devfreq_list_lock);
34701
34702 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34703 index b70709b..1d8d02a 100644
34704 --- a/drivers/dma/sh/shdma.c
34705 +++ b/drivers/dma/sh/shdma.c
34706 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34707 return ret;
34708 }
34709
34710 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34711 +static struct notifier_block sh_dmae_nmi_notifier = {
34712 .notifier_call = sh_dmae_nmi_handler,
34713
34714 /* Run before NMI debug handler and KGDB */
34715 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34716 index 769d92e..a3dcc1e 100644
34717 --- a/drivers/edac/edac_mc_sysfs.c
34718 +++ b/drivers/edac/edac_mc_sysfs.c
34719 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34720 struct dev_ch_attribute {
34721 struct device_attribute attr;
34722 int channel;
34723 -};
34724 +} __do_const;
34725
34726 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34727 struct dev_ch_attribute dev_attr_legacy_##_name = \
34728 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34729 }
34730
34731 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34732 + pax_open_kernel();
34733 if (mci->get_sdram_scrub_rate) {
34734 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34735 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34736 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34737 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34738 }
34739 if (mci->set_sdram_scrub_rate) {
34740 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34741 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34742 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34743 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34744 }
34745 + pax_close_kernel();
34746 err = device_create_file(&mci->dev,
34747 &dev_attr_sdram_scrub_rate);
34748 if (err) {
34749 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34750 index e8658e4..22746d6 100644
34751 --- a/drivers/edac/edac_pci_sysfs.c
34752 +++ b/drivers/edac/edac_pci_sysfs.c
34753 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34754 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34755 static int edac_pci_poll_msec = 1000; /* one second workq period */
34756
34757 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34758 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34759 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34760 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34761
34762 static struct kobject *edac_pci_top_main_kobj;
34763 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34764 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34765 void *value;
34766 ssize_t(*show) (void *, char *);
34767 ssize_t(*store) (void *, const char *, size_t);
34768 -};
34769 +} __do_const;
34770
34771 /* Set of show/store abstract level functions for PCI Parity object */
34772 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34773 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34774 edac_printk(KERN_CRIT, EDAC_PCI,
34775 "Signaled System Error on %s\n",
34776 pci_name(dev));
34777 - atomic_inc(&pci_nonparity_count);
34778 + atomic_inc_unchecked(&pci_nonparity_count);
34779 }
34780
34781 if (status & (PCI_STATUS_PARITY)) {
34782 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34783 "Master Data Parity Error on %s\n",
34784 pci_name(dev));
34785
34786 - atomic_inc(&pci_parity_count);
34787 + atomic_inc_unchecked(&pci_parity_count);
34788 }
34789
34790 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34791 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34792 "Detected Parity Error on %s\n",
34793 pci_name(dev));
34794
34795 - atomic_inc(&pci_parity_count);
34796 + atomic_inc_unchecked(&pci_parity_count);
34797 }
34798 }
34799
34800 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34801 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34802 "Signaled System Error on %s\n",
34803 pci_name(dev));
34804 - atomic_inc(&pci_nonparity_count);
34805 + atomic_inc_unchecked(&pci_nonparity_count);
34806 }
34807
34808 if (status & (PCI_STATUS_PARITY)) {
34809 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34810 "Master Data Parity Error on "
34811 "%s\n", pci_name(dev));
34812
34813 - atomic_inc(&pci_parity_count);
34814 + atomic_inc_unchecked(&pci_parity_count);
34815 }
34816
34817 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34818 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34819 "Detected Parity Error on %s\n",
34820 pci_name(dev));
34821
34822 - atomic_inc(&pci_parity_count);
34823 + atomic_inc_unchecked(&pci_parity_count);
34824 }
34825 }
34826 }
34827 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34828 if (!check_pci_errors)
34829 return;
34830
34831 - before_count = atomic_read(&pci_parity_count);
34832 + before_count = atomic_read_unchecked(&pci_parity_count);
34833
34834 /* scan all PCI devices looking for a Parity Error on devices and
34835 * bridges.
34836 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34837 /* Only if operator has selected panic on PCI Error */
34838 if (edac_pci_get_panic_on_pe()) {
34839 /* If the count is different 'after' from 'before' */
34840 - if (before_count != atomic_read(&pci_parity_count))
34841 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34842 panic("EDAC: PCI Parity Error");
34843 }
34844 }
34845 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34846 index 51b7e3a..aa8a3e8 100644
34847 --- a/drivers/edac/mce_amd.h
34848 +++ b/drivers/edac/mce_amd.h
34849 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
34850 bool (*mc0_mce)(u16, u8);
34851 bool (*mc1_mce)(u16, u8);
34852 bool (*mc2_mce)(u16, u8);
34853 -};
34854 +} __no_const;
34855
34856 void amd_report_gart_errors(bool);
34857 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34858 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34859 index 57ea7f4..789e3c3 100644
34860 --- a/drivers/firewire/core-card.c
34861 +++ b/drivers/firewire/core-card.c
34862 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34863
34864 void fw_core_remove_card(struct fw_card *card)
34865 {
34866 - struct fw_card_driver dummy_driver = dummy_driver_template;
34867 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34868
34869 card->driver->update_phy_reg(card, 4,
34870 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34871 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34872 index 27ac423..13573e8 100644
34873 --- a/drivers/firewire/core-cdev.c
34874 +++ b/drivers/firewire/core-cdev.c
34875 @@ -1366,8 +1366,7 @@ static int init_iso_resource(struct client *client,
34876 int ret;
34877
34878 if ((request->channels == 0 && request->bandwidth == 0) ||
34879 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34880 - request->bandwidth < 0)
34881 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34882 return -EINVAL;
34883
34884 r = kmalloc(sizeof(*r), GFP_KERNEL);
34885 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34886 index 03ce7d9..b70f5da 100644
34887 --- a/drivers/firewire/core-device.c
34888 +++ b/drivers/firewire/core-device.c
34889 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34890 struct config_rom_attribute {
34891 struct device_attribute attr;
34892 u32 key;
34893 -};
34894 +} __do_const;
34895
34896 static ssize_t show_immediate(struct device *dev,
34897 struct device_attribute *dattr, char *buf)
34898 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34899 index 28a94c7..58da63a 100644
34900 --- a/drivers/firewire/core-transaction.c
34901 +++ b/drivers/firewire/core-transaction.c
34902 @@ -38,6 +38,7 @@
34903 #include <linux/timer.h>
34904 #include <linux/types.h>
34905 #include <linux/workqueue.h>
34906 +#include <linux/sched.h>
34907
34908 #include <asm/byteorder.h>
34909
34910 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34911 index 515a42c..5ecf3ba 100644
34912 --- a/drivers/firewire/core.h
34913 +++ b/drivers/firewire/core.h
34914 @@ -111,6 +111,7 @@ struct fw_card_driver {
34915
34916 int (*stop_iso)(struct fw_iso_context *ctx);
34917 };
34918 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34919
34920 void fw_card_initialize(struct fw_card *card,
34921 const struct fw_card_driver *driver, struct device *device);
34922 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34923 index 94a58a0..f5eba42 100644
34924 --- a/drivers/firmware/dmi-id.c
34925 +++ b/drivers/firmware/dmi-id.c
34926 @@ -16,7 +16,7 @@
34927 struct dmi_device_attribute{
34928 struct device_attribute dev_attr;
34929 int field;
34930 -};
34931 +} __do_const;
34932 #define to_dmi_dev_attr(_dev_attr) \
34933 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34934
34935 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34936 index 4cd392d..4b629e1 100644
34937 --- a/drivers/firmware/dmi_scan.c
34938 +++ b/drivers/firmware/dmi_scan.c
34939 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34940 }
34941 }
34942 else {
34943 - /*
34944 - * no iounmap() for that ioremap(); it would be a no-op, but
34945 - * it's so early in setup that sucker gets confused into doing
34946 - * what it shouldn't if we actually call it.
34947 - */
34948 p = dmi_ioremap(0xF0000, 0x10000);
34949 if (p == NULL)
34950 goto error;
34951 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34952 if (buf == NULL)
34953 return -1;
34954
34955 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34956 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34957
34958 iounmap(buf);
34959 return 0;
34960 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34961 index f4baa11..7970c3a 100644
34962 --- a/drivers/firmware/efivars.c
34963 +++ b/drivers/firmware/efivars.c
34964 @@ -139,7 +139,7 @@ struct efivar_attribute {
34965 };
34966
34967 static struct efivars __efivars;
34968 -static struct efivar_operations ops;
34969 +static efivar_operations_no_const ops __read_only;
34970
34971 #define PSTORE_EFI_ATTRIBUTES \
34972 (EFI_VARIABLE_NON_VOLATILE | \
34973 @@ -1844,7 +1844,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34974 static int
34975 create_efivars_bin_attributes(struct efivars *efivars)
34976 {
34977 - struct bin_attribute *attr;
34978 + bin_attribute_no_const *attr;
34979 int error;
34980
34981 /* new_var */
34982 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34983 index 2a90ba6..07f3733 100644
34984 --- a/drivers/firmware/google/memconsole.c
34985 +++ b/drivers/firmware/google/memconsole.c
34986 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34987 if (!found_memconsole())
34988 return -ENODEV;
34989
34990 - memconsole_bin_attr.size = memconsole_length;
34991 + pax_open_kernel();
34992 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34993 + pax_close_kernel();
34994
34995 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34996
34997 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34998 index de3c317..b7cd029 100644
34999 --- a/drivers/gpio/gpio-ich.c
35000 +++ b/drivers/gpio/gpio-ich.c
35001 @@ -69,7 +69,7 @@ struct ichx_desc {
35002 /* Some chipsets have quirks, let these use their own request/get */
35003 int (*request)(struct gpio_chip *chip, unsigned offset);
35004 int (*get)(struct gpio_chip *chip, unsigned offset);
35005 -};
35006 +} __do_const;
35007
35008 static struct {
35009 spinlock_t lock;
35010 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35011 index 9902732..64b62dd 100644
35012 --- a/drivers/gpio/gpio-vr41xx.c
35013 +++ b/drivers/gpio/gpio-vr41xx.c
35014 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35015 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35016 maskl, pendl, maskh, pendh);
35017
35018 - atomic_inc(&irq_err_count);
35019 + atomic_inc_unchecked(&irq_err_count);
35020
35021 return -EINVAL;
35022 }
35023 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35024 index 7b2d378..cc947ea 100644
35025 --- a/drivers/gpu/drm/drm_crtc_helper.c
35026 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35027 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35028 struct drm_crtc *tmp;
35029 int crtc_mask = 1;
35030
35031 - WARN(!crtc, "checking null crtc?\n");
35032 + BUG_ON(!crtc);
35033
35034 dev = crtc->dev;
35035
35036 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35037 index 25f91cd..a376f55 100644
35038 --- a/drivers/gpu/drm/drm_drv.c
35039 +++ b/drivers/gpu/drm/drm_drv.c
35040 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
35041 /**
35042 * Copy and IOCTL return string to user space
35043 */
35044 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35045 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35046 {
35047 int len;
35048
35049 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
35050 struct drm_file *file_priv = filp->private_data;
35051 struct drm_device *dev;
35052 struct drm_ioctl_desc *ioctl;
35053 - drm_ioctl_t *func;
35054 + drm_ioctl_no_const_t func;
35055 unsigned int nr = DRM_IOCTL_NR(cmd);
35056 int retcode = -EINVAL;
35057 char stack_kdata[128];
35058 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
35059 return -ENODEV;
35060
35061 atomic_inc(&dev->ioctl_count);
35062 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35063 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35064 ++file_priv->ioctl_count;
35065
35066 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
35067 diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c
35068 index 48c52f7..0cfb60f 100644
35069 --- a/drivers/gpu/drm/drm_encoder_slave.c
35070 +++ b/drivers/gpu/drm/drm_encoder_slave.c
35071 @@ -54,16 +54,12 @@ int drm_i2c_encoder_init(struct drm_device *dev,
35072 struct i2c_adapter *adap,
35073 const struct i2c_board_info *info)
35074 {
35075 - char modalias[sizeof(I2C_MODULE_PREFIX)
35076 - + I2C_NAME_SIZE];
35077 struct module *module = NULL;
35078 struct i2c_client *client;
35079 struct drm_i2c_encoder_driver *encoder_drv;
35080 int err = 0;
35081
35082 - snprintf(modalias, sizeof(modalias),
35083 - "%s%s", I2C_MODULE_PREFIX, info->type);
35084 - request_module(modalias);
35085 + request_module("%s%s", I2C_MODULE_PREFIX, info->type);
35086
35087 client = i2c_new_device(adap, info);
35088 if (!client) {
35089 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35090 index 429e07d..e681a2c 100644
35091 --- a/drivers/gpu/drm/drm_fops.c
35092 +++ b/drivers/gpu/drm/drm_fops.c
35093 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35094 }
35095
35096 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35097 - atomic_set(&dev->counts[i], 0);
35098 + atomic_set_unchecked(&dev->counts[i], 0);
35099
35100 dev->sigdata.lock = NULL;
35101
35102 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35103 if (drm_device_is_unplugged(dev))
35104 return -ENODEV;
35105
35106 - if (!dev->open_count++)
35107 + if (local_inc_return(&dev->open_count) == 1)
35108 need_setup = 1;
35109 mutex_lock(&dev->struct_mutex);
35110 old_imapping = inode->i_mapping;
35111 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35112 retcode = drm_open_helper(inode, filp, dev);
35113 if (retcode)
35114 goto err_undo;
35115 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35116 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35117 if (need_setup) {
35118 retcode = drm_setup(dev);
35119 if (retcode)
35120 @@ -166,7 +166,7 @@ err_undo:
35121 iput(container_of(dev->dev_mapping, struct inode, i_data));
35122 dev->dev_mapping = old_mapping;
35123 mutex_unlock(&dev->struct_mutex);
35124 - dev->open_count--;
35125 + local_dec(&dev->open_count);
35126 return retcode;
35127 }
35128 EXPORT_SYMBOL(drm_open);
35129 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
35130
35131 mutex_lock(&drm_global_mutex);
35132
35133 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35134 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35135
35136 if (dev->driver->preclose)
35137 dev->driver->preclose(dev, file_priv);
35138 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
35139 * Begin inline drm_release
35140 */
35141
35142 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35143 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35144 task_pid_nr(current),
35145 (long)old_encode_dev(file_priv->minor->device),
35146 - dev->open_count);
35147 + local_read(&dev->open_count));
35148
35149 /* Release any auth tokens that might point to this file_priv,
35150 (do that under the drm_global_mutex) */
35151 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
35152 * End inline drm_release
35153 */
35154
35155 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35156 - if (!--dev->open_count) {
35157 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35158 + if (local_dec_and_test(&dev->open_count)) {
35159 if (atomic_read(&dev->ioctl_count)) {
35160 DRM_ERROR("Device busy: %d\n",
35161 atomic_read(&dev->ioctl_count));
35162 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35163 index f731116..629842c 100644
35164 --- a/drivers/gpu/drm/drm_global.c
35165 +++ b/drivers/gpu/drm/drm_global.c
35166 @@ -36,7 +36,7 @@
35167 struct drm_global_item {
35168 struct mutex mutex;
35169 void *object;
35170 - int refcount;
35171 + atomic_t refcount;
35172 };
35173
35174 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35175 @@ -49,7 +49,7 @@ void drm_global_init(void)
35176 struct drm_global_item *item = &glob[i];
35177 mutex_init(&item->mutex);
35178 item->object = NULL;
35179 - item->refcount = 0;
35180 + atomic_set(&item->refcount, 0);
35181 }
35182 }
35183
35184 @@ -59,7 +59,7 @@ void drm_global_release(void)
35185 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35186 struct drm_global_item *item = &glob[i];
35187 BUG_ON(item->object != NULL);
35188 - BUG_ON(item->refcount != 0);
35189 + BUG_ON(atomic_read(&item->refcount) != 0);
35190 }
35191 }
35192
35193 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35194 void *object;
35195
35196 mutex_lock(&item->mutex);
35197 - if (item->refcount == 0) {
35198 + if (atomic_read(&item->refcount) == 0) {
35199 item->object = kzalloc(ref->size, GFP_KERNEL);
35200 if (unlikely(item->object == NULL)) {
35201 ret = -ENOMEM;
35202 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35203 goto out_err;
35204
35205 }
35206 - ++item->refcount;
35207 + atomic_inc(&item->refcount);
35208 ref->object = item->object;
35209 object = item->object;
35210 mutex_unlock(&item->mutex);
35211 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35212 struct drm_global_item *item = &glob[ref->global_type];
35213
35214 mutex_lock(&item->mutex);
35215 - BUG_ON(item->refcount == 0);
35216 + BUG_ON(atomic_read(&item->refcount) == 0);
35217 BUG_ON(ref->object != item->object);
35218 - if (--item->refcount == 0) {
35219 + if (atomic_dec_and_test(&item->refcount)) {
35220 ref->release(ref);
35221 item->object = NULL;
35222 }
35223 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35224 index d4b20ce..77a8d41 100644
35225 --- a/drivers/gpu/drm/drm_info.c
35226 +++ b/drivers/gpu/drm/drm_info.c
35227 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35228 struct drm_local_map *map;
35229 struct drm_map_list *r_list;
35230
35231 - /* Hardcoded from _DRM_FRAME_BUFFER,
35232 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35233 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35234 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35235 + static const char * const types[] = {
35236 + [_DRM_FRAME_BUFFER] = "FB",
35237 + [_DRM_REGISTERS] = "REG",
35238 + [_DRM_SHM] = "SHM",
35239 + [_DRM_AGP] = "AGP",
35240 + [_DRM_SCATTER_GATHER] = "SG",
35241 + [_DRM_CONSISTENT] = "PCI",
35242 + [_DRM_GEM] = "GEM" };
35243 const char *type;
35244 int i;
35245
35246 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35247 map = r_list->map;
35248 if (!map)
35249 continue;
35250 - if (map->type < 0 || map->type > 5)
35251 + if (map->type >= ARRAY_SIZE(types))
35252 type = "??";
35253 else
35254 type = types[map->type];
35255 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35256 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35257 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35258 vma->vm_flags & VM_IO ? 'i' : '-',
35259 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35260 + 0);
35261 +#else
35262 vma->vm_pgoff);
35263 +#endif
35264
35265 #if defined(__i386__)
35266 pgprot = pgprot_val(vma->vm_page_prot);
35267 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35268 index 2f4c434..dd12cd2 100644
35269 --- a/drivers/gpu/drm/drm_ioc32.c
35270 +++ b/drivers/gpu/drm/drm_ioc32.c
35271 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35272 request = compat_alloc_user_space(nbytes);
35273 if (!access_ok(VERIFY_WRITE, request, nbytes))
35274 return -EFAULT;
35275 - list = (struct drm_buf_desc *) (request + 1);
35276 + list = (struct drm_buf_desc __user *) (request + 1);
35277
35278 if (__put_user(count, &request->count)
35279 || __put_user(list, &request->list))
35280 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35281 request = compat_alloc_user_space(nbytes);
35282 if (!access_ok(VERIFY_WRITE, request, nbytes))
35283 return -EFAULT;
35284 - list = (struct drm_buf_pub *) (request + 1);
35285 + list = (struct drm_buf_pub __user *) (request + 1);
35286
35287 if (__put_user(count, &request->count)
35288 || __put_user(list, &request->list))
35289 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35290 return 0;
35291 }
35292
35293 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35294 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35295 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35296 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35297 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35298 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35299 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35300 {
35301 unsigned int nr = DRM_IOCTL_NR(cmd);
35302 - drm_ioctl_compat_t *fn;
35303 int ret;
35304
35305 /* Assume that ioctls without an explicit compat routine will just
35306 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35307 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35308 return drm_ioctl(filp, cmd, arg);
35309
35310 - fn = drm_compat_ioctls[nr];
35311 -
35312 - if (fn != NULL)
35313 - ret = (*fn) (filp, cmd, arg);
35314 + if (drm_compat_ioctls[nr] != NULL)
35315 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35316 else
35317 ret = drm_ioctl(filp, cmd, arg);
35318
35319 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35320 index e77bd8b..1571b85 100644
35321 --- a/drivers/gpu/drm/drm_ioctl.c
35322 +++ b/drivers/gpu/drm/drm_ioctl.c
35323 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35324 stats->data[i].value =
35325 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35326 else
35327 - stats->data[i].value = atomic_read(&dev->counts[i]);
35328 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35329 stats->data[i].type = dev->types[i];
35330 }
35331
35332 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35333 index d752c96..fe08455 100644
35334 --- a/drivers/gpu/drm/drm_lock.c
35335 +++ b/drivers/gpu/drm/drm_lock.c
35336 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35337 if (drm_lock_take(&master->lock, lock->context)) {
35338 master->lock.file_priv = file_priv;
35339 master->lock.lock_time = jiffies;
35340 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35341 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35342 break; /* Got lock */
35343 }
35344
35345 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35346 return -EINVAL;
35347 }
35348
35349 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35350 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35351
35352 if (drm_lock_free(&master->lock, lock->context)) {
35353 /* FIXME: Should really bail out here. */
35354 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35355 index 7d30802..42c6cbb 100644
35356 --- a/drivers/gpu/drm/drm_stub.c
35357 +++ b/drivers/gpu/drm/drm_stub.c
35358 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35359
35360 drm_device_set_unplugged(dev);
35361
35362 - if (dev->open_count == 0) {
35363 + if (local_read(&dev->open_count) == 0) {
35364 drm_put_dev(dev);
35365 }
35366 mutex_unlock(&drm_global_mutex);
35367 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
35368 index 0229665..f61329c 100644
35369 --- a/drivers/gpu/drm/drm_sysfs.c
35370 +++ b/drivers/gpu/drm/drm_sysfs.c
35371 @@ -499,7 +499,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
35372 int drm_sysfs_device_add(struct drm_minor *minor)
35373 {
35374 int err;
35375 - char *minor_str;
35376 + const char *minor_str;
35377
35378 minor->kdev.parent = minor->dev->dev;
35379
35380 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35381 index 004ecdf..db1f6e0 100644
35382 --- a/drivers/gpu/drm/i810/i810_dma.c
35383 +++ b/drivers/gpu/drm/i810/i810_dma.c
35384 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35385 dma->buflist[vertex->idx],
35386 vertex->discard, vertex->used);
35387
35388 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35389 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35390 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35391 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35392 sarea_priv->last_enqueue = dev_priv->counter - 1;
35393 sarea_priv->last_dispatch = (int)hw_status[5];
35394
35395 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35396 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35397 mc->last_render);
35398
35399 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35400 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35401 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35402 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35403 sarea_priv->last_enqueue = dev_priv->counter - 1;
35404 sarea_priv->last_dispatch = (int)hw_status[5];
35405
35406 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35407 index 6e0acad..93c8289 100644
35408 --- a/drivers/gpu/drm/i810/i810_drv.h
35409 +++ b/drivers/gpu/drm/i810/i810_drv.h
35410 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35411 int page_flipping;
35412
35413 wait_queue_head_t irq_queue;
35414 - atomic_t irq_received;
35415 - atomic_t irq_emitted;
35416 + atomic_unchecked_t irq_received;
35417 + atomic_unchecked_t irq_emitted;
35418
35419 int front_offset;
35420 } drm_i810_private_t;
35421 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35422 index 7299ea4..5314487 100644
35423 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35424 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35425 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35426 I915_READ(GTIMR));
35427 }
35428 seq_printf(m, "Interrupts received: %d\n",
35429 - atomic_read(&dev_priv->irq_received));
35430 + atomic_read_unchecked(&dev_priv->irq_received));
35431 for_each_ring(ring, dev_priv, i) {
35432 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35433 seq_printf(m,
35434 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35435 index 4fa6beb..f930fec 100644
35436 --- a/drivers/gpu/drm/i915/i915_dma.c
35437 +++ b/drivers/gpu/drm/i915/i915_dma.c
35438 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35439 bool can_switch;
35440
35441 spin_lock(&dev->count_lock);
35442 - can_switch = (dev->open_count == 0);
35443 + can_switch = (local_read(&dev->open_count) == 0);
35444 spin_unlock(&dev->count_lock);
35445 return can_switch;
35446 }
35447 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35448 index ef99b1c..09ce7fb 100644
35449 --- a/drivers/gpu/drm/i915/i915_drv.h
35450 +++ b/drivers/gpu/drm/i915/i915_drv.h
35451 @@ -893,7 +893,7 @@ typedef struct drm_i915_private {
35452 drm_dma_handle_t *status_page_dmah;
35453 struct resource mch_res;
35454
35455 - atomic_t irq_received;
35456 + atomic_unchecked_t irq_received;
35457
35458 /* protects the irq masks */
35459 spinlock_t irq_lock;
35460 @@ -1775,7 +1775,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35461 struct drm_i915_private *dev_priv, unsigned port);
35462 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35463 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35464 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35465 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35466 {
35467 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35468 }
35469 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35470 index 9a48e1a..f0cbc3e 100644
35471 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35472 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35473 @@ -729,9 +729,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35474
35475 static int
35476 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35477 - int count)
35478 + unsigned int count)
35479 {
35480 - int i;
35481 + unsigned int i;
35482 int relocs_total = 0;
35483 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35484
35485 @@ -1195,7 +1195,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35486 return -ENOMEM;
35487 }
35488 ret = copy_from_user(exec2_list,
35489 - (struct drm_i915_relocation_entry __user *)
35490 + (struct drm_i915_gem_exec_object2 __user *)
35491 (uintptr_t) args->buffers_ptr,
35492 sizeof(*exec2_list) * args->buffer_count);
35493 if (ret != 0) {
35494 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35495 index 3c59584..500f2e9 100644
35496 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35497 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35498 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35499 (unsigned long)request);
35500 }
35501
35502 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35503 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35504 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35505 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35506 [DRM_I915_GETPARAM] = compat_i915_getparam,
35507 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35508 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35509 {
35510 unsigned int nr = DRM_IOCTL_NR(cmd);
35511 - drm_ioctl_compat_t *fn = NULL;
35512 int ret;
35513
35514 if (nr < DRM_COMMAND_BASE)
35515 return drm_compat_ioctl(filp, cmd, arg);
35516
35517 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35518 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35519 -
35520 - if (fn != NULL)
35521 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35522 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35523 ret = (*fn) (filp, cmd, arg);
35524 - else
35525 + } else
35526 ret = drm_ioctl(filp, cmd, arg);
35527
35528 return ret;
35529 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35530 index 3c7bb04..182e049 100644
35531 --- a/drivers/gpu/drm/i915/i915_irq.c
35532 +++ b/drivers/gpu/drm/i915/i915_irq.c
35533 @@ -549,7 +549,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35534 int pipe;
35535 u32 pipe_stats[I915_MAX_PIPES];
35536
35537 - atomic_inc(&dev_priv->irq_received);
35538 + atomic_inc_unchecked(&dev_priv->irq_received);
35539
35540 while (true) {
35541 iir = I915_READ(VLV_IIR);
35542 @@ -705,7 +705,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35543 irqreturn_t ret = IRQ_NONE;
35544 int i;
35545
35546 - atomic_inc(&dev_priv->irq_received);
35547 + atomic_inc_unchecked(&dev_priv->irq_received);
35548
35549 /* disable master interrupt before clearing iir */
35550 de_ier = I915_READ(DEIER);
35551 @@ -791,7 +791,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35552 int ret = IRQ_NONE;
35553 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35554
35555 - atomic_inc(&dev_priv->irq_received);
35556 + atomic_inc_unchecked(&dev_priv->irq_received);
35557
35558 /* disable master interrupt before clearing iir */
35559 de_ier = I915_READ(DEIER);
35560 @@ -1886,7 +1886,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35561 {
35562 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35563
35564 - atomic_set(&dev_priv->irq_received, 0);
35565 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35566
35567 I915_WRITE(HWSTAM, 0xeffe);
35568
35569 @@ -1912,7 +1912,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35570 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35571 int pipe;
35572
35573 - atomic_set(&dev_priv->irq_received, 0);
35574 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35575
35576 /* VLV magic */
35577 I915_WRITE(VLV_IMR, 0);
35578 @@ -2208,7 +2208,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35579 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35580 int pipe;
35581
35582 - atomic_set(&dev_priv->irq_received, 0);
35583 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35584
35585 for_each_pipe(pipe)
35586 I915_WRITE(PIPESTAT(pipe), 0);
35587 @@ -2259,7 +2259,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35588 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35589 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35590
35591 - atomic_inc(&dev_priv->irq_received);
35592 + atomic_inc_unchecked(&dev_priv->irq_received);
35593
35594 iir = I915_READ16(IIR);
35595 if (iir == 0)
35596 @@ -2344,7 +2344,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35597 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35598 int pipe;
35599
35600 - atomic_set(&dev_priv->irq_received, 0);
35601 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35602
35603 if (I915_HAS_HOTPLUG(dev)) {
35604 I915_WRITE(PORT_HOTPLUG_EN, 0);
35605 @@ -2448,7 +2448,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35606 };
35607 int pipe, ret = IRQ_NONE;
35608
35609 - atomic_inc(&dev_priv->irq_received);
35610 + atomic_inc_unchecked(&dev_priv->irq_received);
35611
35612 iir = I915_READ(IIR);
35613 do {
35614 @@ -2574,7 +2574,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35615 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35616 int pipe;
35617
35618 - atomic_set(&dev_priv->irq_received, 0);
35619 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35620
35621 I915_WRITE(PORT_HOTPLUG_EN, 0);
35622 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35623 @@ -2690,7 +2690,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35624 int irq_received;
35625 int ret = IRQ_NONE, pipe;
35626
35627 - atomic_inc(&dev_priv->irq_received);
35628 + atomic_inc_unchecked(&dev_priv->irq_received);
35629
35630 iir = I915_READ(IIR);
35631
35632 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35633 index 2ab65b4..acbd821 100644
35634 --- a/drivers/gpu/drm/i915/intel_display.c
35635 +++ b/drivers/gpu/drm/i915/intel_display.c
35636 @@ -8742,13 +8742,13 @@ struct intel_quirk {
35637 int subsystem_vendor;
35638 int subsystem_device;
35639 void (*hook)(struct drm_device *dev);
35640 -};
35641 +} __do_const;
35642
35643 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35644 struct intel_dmi_quirk {
35645 void (*hook)(struct drm_device *dev);
35646 const struct dmi_system_id (*dmi_id_list)[];
35647 -};
35648 +} __do_const;
35649
35650 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35651 {
35652 @@ -8756,18 +8756,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35653 return 1;
35654 }
35655
35656 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35657 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35658 {
35659 - .dmi_id_list = &(const struct dmi_system_id[]) {
35660 - {
35661 - .callback = intel_dmi_reverse_brightness,
35662 - .ident = "NCR Corporation",
35663 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35664 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35665 - },
35666 - },
35667 - { } /* terminating entry */
35668 + .callback = intel_dmi_reverse_brightness,
35669 + .ident = "NCR Corporation",
35670 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35671 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35672 },
35673 + },
35674 + { } /* terminating entry */
35675 +};
35676 +
35677 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35678 + {
35679 + .dmi_id_list = &intel_dmi_quirks_table,
35680 .hook = quirk_invert_brightness,
35681 },
35682 };
35683 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35684 index 54558a0..2d97005 100644
35685 --- a/drivers/gpu/drm/mga/mga_drv.h
35686 +++ b/drivers/gpu/drm/mga/mga_drv.h
35687 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35688 u32 clear_cmd;
35689 u32 maccess;
35690
35691 - atomic_t vbl_received; /**< Number of vblanks received. */
35692 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35693 wait_queue_head_t fence_queue;
35694 - atomic_t last_fence_retired;
35695 + atomic_unchecked_t last_fence_retired;
35696 u32 next_fence_to_post;
35697
35698 unsigned int fb_cpp;
35699 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35700 index 709e90d..89a1c0d 100644
35701 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35702 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35703 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35704 return 0;
35705 }
35706
35707 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35708 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35709 [DRM_MGA_INIT] = compat_mga_init,
35710 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35711 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35712 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35713 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35714 {
35715 unsigned int nr = DRM_IOCTL_NR(cmd);
35716 - drm_ioctl_compat_t *fn = NULL;
35717 int ret;
35718
35719 if (nr < DRM_COMMAND_BASE)
35720 return drm_compat_ioctl(filp, cmd, arg);
35721
35722 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35723 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35724 -
35725 - if (fn != NULL)
35726 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35727 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35728 ret = (*fn) (filp, cmd, arg);
35729 - else
35730 + } else
35731 ret = drm_ioctl(filp, cmd, arg);
35732
35733 return ret;
35734 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35735 index 598c281..60d590e 100644
35736 --- a/drivers/gpu/drm/mga/mga_irq.c
35737 +++ b/drivers/gpu/drm/mga/mga_irq.c
35738 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35739 if (crtc != 0)
35740 return 0;
35741
35742 - return atomic_read(&dev_priv->vbl_received);
35743 + return atomic_read_unchecked(&dev_priv->vbl_received);
35744 }
35745
35746
35747 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35748 /* VBLANK interrupt */
35749 if (status & MGA_VLINEPEN) {
35750 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35751 - atomic_inc(&dev_priv->vbl_received);
35752 + atomic_inc_unchecked(&dev_priv->vbl_received);
35753 drm_handle_vblank(dev, 0);
35754 handled = 1;
35755 }
35756 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35757 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35758 MGA_WRITE(MGA_PRIMEND, prim_end);
35759
35760 - atomic_inc(&dev_priv->last_fence_retired);
35761 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35762 DRM_WAKEUP(&dev_priv->fence_queue);
35763 handled = 1;
35764 }
35765 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35766 * using fences.
35767 */
35768 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35769 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35770 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35771 - *sequence) <= (1 << 23)));
35772
35773 *sequence = cur_fence;
35774 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35775 index 50a6dd0..ea66ed8 100644
35776 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35777 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35778 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35779 struct bit_table {
35780 const char id;
35781 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35782 -};
35783 +} __no_const;
35784
35785 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35786
35787 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35788 index 9c39baf..30a22be 100644
35789 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35790 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35791 @@ -81,7 +81,7 @@ struct nouveau_drm {
35792 struct drm_global_reference mem_global_ref;
35793 struct ttm_bo_global_ref bo_global_ref;
35794 struct ttm_bo_device bdev;
35795 - atomic_t validate_sequence;
35796 + atomic_unchecked_t validate_sequence;
35797 int (*move)(struct nouveau_channel *,
35798 struct ttm_buffer_object *,
35799 struct ttm_mem_reg *, struct ttm_mem_reg *);
35800 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35801 index b4b4d0c..b7edc15 100644
35802 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35803 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35804 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35805 int ret, i;
35806 struct nouveau_bo *res_bo = NULL;
35807
35808 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35809 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35810 retry:
35811 if (++trycnt > 100000) {
35812 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35813 @@ -359,7 +359,7 @@ retry:
35814 if (ret) {
35815 validate_fini(op, NULL);
35816 if (unlikely(ret == -EAGAIN)) {
35817 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35818 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35819 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35820 sequence);
35821 if (!ret)
35822 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35823 index 08214bc..9208577 100644
35824 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35825 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35826 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35827 unsigned long arg)
35828 {
35829 unsigned int nr = DRM_IOCTL_NR(cmd);
35830 - drm_ioctl_compat_t *fn = NULL;
35831 + drm_ioctl_compat_t fn = NULL;
35832 int ret;
35833
35834 if (nr < DRM_COMMAND_BASE)
35835 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35836 index 25d3495..d81aaf6 100644
35837 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35838 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35839 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35840 bool can_switch;
35841
35842 spin_lock(&dev->count_lock);
35843 - can_switch = (dev->open_count == 0);
35844 + can_switch = (local_read(&dev->open_count) == 0);
35845 spin_unlock(&dev->count_lock);
35846 return can_switch;
35847 }
35848 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35849 index d4660cf..70dbe65 100644
35850 --- a/drivers/gpu/drm/r128/r128_cce.c
35851 +++ b/drivers/gpu/drm/r128/r128_cce.c
35852 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35853
35854 /* GH: Simple idle check.
35855 */
35856 - atomic_set(&dev_priv->idle_count, 0);
35857 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35858
35859 /* We don't support anything other than bus-mastering ring mode,
35860 * but the ring can be in either AGP or PCI space for the ring
35861 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35862 index 930c71b..499aded 100644
35863 --- a/drivers/gpu/drm/r128/r128_drv.h
35864 +++ b/drivers/gpu/drm/r128/r128_drv.h
35865 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35866 int is_pci;
35867 unsigned long cce_buffers_offset;
35868
35869 - atomic_t idle_count;
35870 + atomic_unchecked_t idle_count;
35871
35872 int page_flipping;
35873 int current_page;
35874 u32 crtc_offset;
35875 u32 crtc_offset_cntl;
35876
35877 - atomic_t vbl_received;
35878 + atomic_unchecked_t vbl_received;
35879
35880 u32 color_fmt;
35881 unsigned int front_offset;
35882 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35883 index a954c54..9cc595c 100644
35884 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35885 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35886 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35887 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35888 }
35889
35890 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35891 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35892 [DRM_R128_INIT] = compat_r128_init,
35893 [DRM_R128_DEPTH] = compat_r128_depth,
35894 [DRM_R128_STIPPLE] = compat_r128_stipple,
35895 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35896 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35897 {
35898 unsigned int nr = DRM_IOCTL_NR(cmd);
35899 - drm_ioctl_compat_t *fn = NULL;
35900 int ret;
35901
35902 if (nr < DRM_COMMAND_BASE)
35903 return drm_compat_ioctl(filp, cmd, arg);
35904
35905 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35906 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35907 -
35908 - if (fn != NULL)
35909 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35910 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35911 ret = (*fn) (filp, cmd, arg);
35912 - else
35913 + } else
35914 ret = drm_ioctl(filp, cmd, arg);
35915
35916 return ret;
35917 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35918 index 2ea4f09..d391371 100644
35919 --- a/drivers/gpu/drm/r128/r128_irq.c
35920 +++ b/drivers/gpu/drm/r128/r128_irq.c
35921 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35922 if (crtc != 0)
35923 return 0;
35924
35925 - return atomic_read(&dev_priv->vbl_received);
35926 + return atomic_read_unchecked(&dev_priv->vbl_received);
35927 }
35928
35929 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35930 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35931 /* VBLANK interrupt */
35932 if (status & R128_CRTC_VBLANK_INT) {
35933 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35934 - atomic_inc(&dev_priv->vbl_received);
35935 + atomic_inc_unchecked(&dev_priv->vbl_received);
35936 drm_handle_vblank(dev, 0);
35937 return IRQ_HANDLED;
35938 }
35939 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35940 index 19bb7e6..de7e2a2 100644
35941 --- a/drivers/gpu/drm/r128/r128_state.c
35942 +++ b/drivers/gpu/drm/r128/r128_state.c
35943 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35944
35945 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35946 {
35947 - if (atomic_read(&dev_priv->idle_count) == 0)
35948 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35949 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35950 else
35951 - atomic_set(&dev_priv->idle_count, 0);
35952 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35953 }
35954
35955 #endif
35956 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35957 index 5a82b6b..9e69c73 100644
35958 --- a/drivers/gpu/drm/radeon/mkregtable.c
35959 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35960 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35961 regex_t mask_rex;
35962 regmatch_t match[4];
35963 char buf[1024];
35964 - size_t end;
35965 + long end;
35966 int len;
35967 int done = 0;
35968 int r;
35969 unsigned o;
35970 struct offset *offset;
35971 char last_reg_s[10];
35972 - int last_reg;
35973 + unsigned long last_reg;
35974
35975 if (regcomp
35976 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35977 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35978 index 5073665..31d15a6 100644
35979 --- a/drivers/gpu/drm/radeon/radeon_device.c
35980 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35981 @@ -976,7 +976,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35982 bool can_switch;
35983
35984 spin_lock(&dev->count_lock);
35985 - can_switch = (dev->open_count == 0);
35986 + can_switch = (local_read(&dev->open_count) == 0);
35987 spin_unlock(&dev->count_lock);
35988 return can_switch;
35989 }
35990 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35991 index b369d42..8dd04eb 100644
35992 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35993 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35994 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
35995
35996 /* SW interrupt */
35997 wait_queue_head_t swi_queue;
35998 - atomic_t swi_emitted;
35999 + atomic_unchecked_t swi_emitted;
36000 int vblank_crtc;
36001 uint32_t irq_enable_reg;
36002 uint32_t r500_disp_irq_reg;
36003 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36004 index c180df8..5fd8186 100644
36005 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36006 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36007 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36008 request = compat_alloc_user_space(sizeof(*request));
36009 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36010 || __put_user(req32.param, &request->param)
36011 - || __put_user((void __user *)(unsigned long)req32.value,
36012 + || __put_user((unsigned long)req32.value,
36013 &request->value))
36014 return -EFAULT;
36015
36016 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36017 #define compat_radeon_cp_setparam NULL
36018 #endif /* X86_64 || IA64 */
36019
36020 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36021 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36022 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36023 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36024 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36025 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36026 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36027 {
36028 unsigned int nr = DRM_IOCTL_NR(cmd);
36029 - drm_ioctl_compat_t *fn = NULL;
36030 int ret;
36031
36032 if (nr < DRM_COMMAND_BASE)
36033 return drm_compat_ioctl(filp, cmd, arg);
36034
36035 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36036 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36037 -
36038 - if (fn != NULL)
36039 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36040 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36041 ret = (*fn) (filp, cmd, arg);
36042 - else
36043 + } else
36044 ret = drm_ioctl(filp, cmd, arg);
36045
36046 return ret;
36047 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36048 index 8d68e97..9dcfed8 100644
36049 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36050 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36051 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36052 unsigned int ret;
36053 RING_LOCALS;
36054
36055 - atomic_inc(&dev_priv->swi_emitted);
36056 - ret = atomic_read(&dev_priv->swi_emitted);
36057 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36058 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36059
36060 BEGIN_RING(4);
36061 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36062 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36063 drm_radeon_private_t *dev_priv =
36064 (drm_radeon_private_t *) dev->dev_private;
36065
36066 - atomic_set(&dev_priv->swi_emitted, 0);
36067 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36068 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36069
36070 dev->max_vblank_count = 0x001fffff;
36071 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36072 index 4d20910..6726b6d 100644
36073 --- a/drivers/gpu/drm/radeon/radeon_state.c
36074 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36075 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36076 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36077 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36078
36079 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36080 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36081 sarea_priv->nbox * sizeof(depth_boxes[0])))
36082 return -EFAULT;
36083
36084 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36085 {
36086 drm_radeon_private_t *dev_priv = dev->dev_private;
36087 drm_radeon_getparam_t *param = data;
36088 - int value;
36089 + int value = 0;
36090
36091 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36092
36093 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36094 index 6c0ce89..66f6d65 100644
36095 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36096 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36097 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36098 man->size = size >> PAGE_SHIFT;
36099 }
36100
36101 -static struct vm_operations_struct radeon_ttm_vm_ops;
36102 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36103 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36104
36105 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36106 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36107 }
36108 if (unlikely(ttm_vm_ops == NULL)) {
36109 ttm_vm_ops = vma->vm_ops;
36110 + pax_open_kernel();
36111 radeon_ttm_vm_ops = *ttm_vm_ops;
36112 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36113 + pax_close_kernel();
36114 }
36115 vma->vm_ops = &radeon_ttm_vm_ops;
36116 return 0;
36117 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36118 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36119 else
36120 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36121 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36122 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36123 - radeon_mem_types_list[i].driver_features = 0;
36124 + pax_open_kernel();
36125 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36126 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36127 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36128 if (i == 0)
36129 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36130 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36131 else
36132 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36133 -
36134 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36135 + pax_close_kernel();
36136 }
36137 /* Add ttm page pool to debugfs */
36138 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36139 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36140 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36141 - radeon_mem_types_list[i].driver_features = 0;
36142 - radeon_mem_types_list[i++].data = NULL;
36143 + pax_open_kernel();
36144 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36145 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36146 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36147 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36148 + pax_close_kernel();
36149 #ifdef CONFIG_SWIOTLB
36150 if (swiotlb_nr_tbl()) {
36151 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36152 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36153 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36154 - radeon_mem_types_list[i].driver_features = 0;
36155 - radeon_mem_types_list[i++].data = NULL;
36156 + pax_open_kernel();
36157 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36158 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36159 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36160 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36161 + pax_close_kernel();
36162 }
36163 #endif
36164 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36165 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36166 index fad6633..4ff94de 100644
36167 --- a/drivers/gpu/drm/radeon/rs690.c
36168 +++ b/drivers/gpu/drm/radeon/rs690.c
36169 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36170 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36171 rdev->pm.sideport_bandwidth.full)
36172 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36173 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36174 + read_delay_latency.full = dfixed_const(800 * 1000);
36175 read_delay_latency.full = dfixed_div(read_delay_latency,
36176 rdev->pm.igp_sideport_mclk);
36177 + a.full = dfixed_const(370);
36178 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36179 } else {
36180 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36181 rdev->pm.k8_bandwidth.full)
36182 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
36183 index dbc2def..0a9f710 100644
36184 --- a/drivers/gpu/drm/ttm/ttm_memory.c
36185 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
36186 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
36187 zone->glob = glob;
36188 glob->zone_kernel = zone;
36189 ret = kobject_init_and_add(
36190 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36191 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36192 if (unlikely(ret != 0)) {
36193 kobject_put(&zone->kobj);
36194 return ret;
36195 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
36196 zone->glob = glob;
36197 glob->zone_dma32 = zone;
36198 ret = kobject_init_and_add(
36199 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36200 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36201 if (unlikely(ret != 0)) {
36202 kobject_put(&zone->kobj);
36203 return ret;
36204 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36205 index bd2a3b4..122d9ad 100644
36206 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36207 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36208 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36209 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36210 struct shrink_control *sc)
36211 {
36212 - static atomic_t start_pool = ATOMIC_INIT(0);
36213 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36214 unsigned i;
36215 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36216 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36217 struct ttm_page_pool *pool;
36218 int shrink_pages = sc->nr_to_scan;
36219
36220 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36221 index 9f4be3d..cbc9fcc 100644
36222 --- a/drivers/gpu/drm/udl/udl_fb.c
36223 +++ b/drivers/gpu/drm/udl/udl_fb.c
36224 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36225 fb_deferred_io_cleanup(info);
36226 kfree(info->fbdefio);
36227 info->fbdefio = NULL;
36228 - info->fbops->fb_mmap = udl_fb_mmap;
36229 }
36230
36231 pr_warn("released /dev/fb%d user=%d count=%d\n",
36232 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36233 index 893a650..6190d3b 100644
36234 --- a/drivers/gpu/drm/via/via_drv.h
36235 +++ b/drivers/gpu/drm/via/via_drv.h
36236 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36237 typedef uint32_t maskarray_t[5];
36238
36239 typedef struct drm_via_irq {
36240 - atomic_t irq_received;
36241 + atomic_unchecked_t irq_received;
36242 uint32_t pending_mask;
36243 uint32_t enable_mask;
36244 wait_queue_head_t irq_queue;
36245 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36246 struct timeval last_vblank;
36247 int last_vblank_valid;
36248 unsigned usec_per_vblank;
36249 - atomic_t vbl_received;
36250 + atomic_unchecked_t vbl_received;
36251 drm_via_state_t hc_state;
36252 char pci_buf[VIA_PCI_BUF_SIZE];
36253 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36254 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36255 index ac98964..5dbf512 100644
36256 --- a/drivers/gpu/drm/via/via_irq.c
36257 +++ b/drivers/gpu/drm/via/via_irq.c
36258 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36259 if (crtc != 0)
36260 return 0;
36261
36262 - return atomic_read(&dev_priv->vbl_received);
36263 + return atomic_read_unchecked(&dev_priv->vbl_received);
36264 }
36265
36266 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36267 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36268
36269 status = VIA_READ(VIA_REG_INTERRUPT);
36270 if (status & VIA_IRQ_VBLANK_PENDING) {
36271 - atomic_inc(&dev_priv->vbl_received);
36272 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36273 + atomic_inc_unchecked(&dev_priv->vbl_received);
36274 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36275 do_gettimeofday(&cur_vblank);
36276 if (dev_priv->last_vblank_valid) {
36277 dev_priv->usec_per_vblank =
36278 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36279 dev_priv->last_vblank = cur_vblank;
36280 dev_priv->last_vblank_valid = 1;
36281 }
36282 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36283 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36284 DRM_DEBUG("US per vblank is: %u\n",
36285 dev_priv->usec_per_vblank);
36286 }
36287 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36288
36289 for (i = 0; i < dev_priv->num_irqs; ++i) {
36290 if (status & cur_irq->pending_mask) {
36291 - atomic_inc(&cur_irq->irq_received);
36292 + atomic_inc_unchecked(&cur_irq->irq_received);
36293 DRM_WAKEUP(&cur_irq->irq_queue);
36294 handled = 1;
36295 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36296 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36297 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36298 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36299 masks[irq][4]));
36300 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36301 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36302 } else {
36303 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36304 (((cur_irq_sequence =
36305 - atomic_read(&cur_irq->irq_received)) -
36306 + atomic_read_unchecked(&cur_irq->irq_received)) -
36307 *sequence) <= (1 << 23)));
36308 }
36309 *sequence = cur_irq_sequence;
36310 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36311 }
36312
36313 for (i = 0; i < dev_priv->num_irqs; ++i) {
36314 - atomic_set(&cur_irq->irq_received, 0);
36315 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36316 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36317 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36318 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36319 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36320 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36321 case VIA_IRQ_RELATIVE:
36322 irqwait->request.sequence +=
36323 - atomic_read(&cur_irq->irq_received);
36324 + atomic_read_unchecked(&cur_irq->irq_received);
36325 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36326 case VIA_IRQ_ABSOLUTE:
36327 break;
36328 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36329 index 13aeda7..4a952d1 100644
36330 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36331 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36332 @@ -290,7 +290,7 @@ struct vmw_private {
36333 * Fencing and IRQs.
36334 */
36335
36336 - atomic_t marker_seq;
36337 + atomic_unchecked_t marker_seq;
36338 wait_queue_head_t fence_queue;
36339 wait_queue_head_t fifo_queue;
36340 int fence_queue_waiters; /* Protected by hw_mutex */
36341 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36342 index 3eb1486..0a47ee9 100644
36343 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36344 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36345 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36346 (unsigned int) min,
36347 (unsigned int) fifo->capabilities);
36348
36349 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36350 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36351 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36352 vmw_marker_queue_init(&fifo->marker_queue);
36353 return vmw_fifo_send_fence(dev_priv, &dummy);
36354 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36355 if (reserveable)
36356 iowrite32(bytes, fifo_mem +
36357 SVGA_FIFO_RESERVED);
36358 - return fifo_mem + (next_cmd >> 2);
36359 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36360 } else {
36361 need_bounce = true;
36362 }
36363 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36364
36365 fm = vmw_fifo_reserve(dev_priv, bytes);
36366 if (unlikely(fm == NULL)) {
36367 - *seqno = atomic_read(&dev_priv->marker_seq);
36368 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36369 ret = -ENOMEM;
36370 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36371 false, 3*HZ);
36372 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36373 }
36374
36375 do {
36376 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36377 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36378 } while (*seqno == 0);
36379
36380 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36381 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36382 index c509d40..3b640c3 100644
36383 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36384 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36385 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36386 int ret;
36387
36388 num_clips = arg->num_clips;
36389 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36390 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36391
36392 if (unlikely(num_clips == 0))
36393 return 0;
36394 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36395 int ret;
36396
36397 num_clips = arg->num_clips;
36398 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36399 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36400
36401 if (unlikely(num_clips == 0))
36402 return 0;
36403 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36404 index 4640adb..e1384ed 100644
36405 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36406 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36407 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36408 * emitted. Then the fence is stale and signaled.
36409 */
36410
36411 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36412 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36413 > VMW_FENCE_WRAP);
36414
36415 return ret;
36416 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36417
36418 if (fifo_idle)
36419 down_read(&fifo_state->rwsem);
36420 - signal_seq = atomic_read(&dev_priv->marker_seq);
36421 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36422 ret = 0;
36423
36424 for (;;) {
36425 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36426 index 8a8725c2..afed796 100644
36427 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36428 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36429 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36430 while (!vmw_lag_lt(queue, us)) {
36431 spin_lock(&queue->lock);
36432 if (list_empty(&queue->head))
36433 - seqno = atomic_read(&dev_priv->marker_seq);
36434 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36435 else {
36436 marker = list_first_entry(&queue->head,
36437 struct vmw_marker, head);
36438 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36439 index e6dbf09..3dd2540 100644
36440 --- a/drivers/hid/hid-core.c
36441 +++ b/drivers/hid/hid-core.c
36442 @@ -2268,7 +2268,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36443
36444 int hid_add_device(struct hid_device *hdev)
36445 {
36446 - static atomic_t id = ATOMIC_INIT(0);
36447 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36448 int ret;
36449
36450 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36451 @@ -2302,7 +2302,7 @@ int hid_add_device(struct hid_device *hdev)
36452 /* XXX hack, any other cleaner solution after the driver core
36453 * is converted to allow more than 20 bytes as the device name? */
36454 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36455 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36456 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36457
36458 hid_debug_register(hdev, dev_name(&hdev->dev));
36459 ret = device_add(&hdev->dev);
36460 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36461 index 90124ff..3761764 100644
36462 --- a/drivers/hid/hid-wiimote-debug.c
36463 +++ b/drivers/hid/hid-wiimote-debug.c
36464 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36465 else if (size == 0)
36466 return -EIO;
36467
36468 - if (copy_to_user(u, buf, size))
36469 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36470 return -EFAULT;
36471
36472 *off += size;
36473 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36474 index 0b122f8..b1d8160 100644
36475 --- a/drivers/hv/channel.c
36476 +++ b/drivers/hv/channel.c
36477 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36478 int ret = 0;
36479 int t;
36480
36481 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36482 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36483 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36484 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36485
36486 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36487 if (ret)
36488 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36489 index 7311589..861e9ef 100644
36490 --- a/drivers/hv/hv.c
36491 +++ b/drivers/hv/hv.c
36492 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36493 u64 output_address = (output) ? virt_to_phys(output) : 0;
36494 u32 output_address_hi = output_address >> 32;
36495 u32 output_address_lo = output_address & 0xFFFFFFFF;
36496 - void *hypercall_page = hv_context.hypercall_page;
36497 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36498
36499 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36500 "=a"(hv_status_lo) : "d" (control_hi),
36501 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36502 index 12f2f9e..679603c 100644
36503 --- a/drivers/hv/hyperv_vmbus.h
36504 +++ b/drivers/hv/hyperv_vmbus.h
36505 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36506 struct vmbus_connection {
36507 enum vmbus_connect_state conn_state;
36508
36509 - atomic_t next_gpadl_handle;
36510 + atomic_unchecked_t next_gpadl_handle;
36511
36512 /*
36513 * Represents channel interrupts. Each bit position represents a
36514 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36515 index bf421e0..ce2c897 100644
36516 --- a/drivers/hv/vmbus_drv.c
36517 +++ b/drivers/hv/vmbus_drv.c
36518 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36519 {
36520 int ret = 0;
36521
36522 - static atomic_t device_num = ATOMIC_INIT(0);
36523 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36524
36525 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36526 - atomic_inc_return(&device_num));
36527 + atomic_inc_return_unchecked(&device_num));
36528
36529 child_device_obj->device.bus = &hv_bus;
36530 child_device_obj->device.parent = &hv_acpi_dev->dev;
36531 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36532 index 6351aba..dc4aaf4 100644
36533 --- a/drivers/hwmon/acpi_power_meter.c
36534 +++ b/drivers/hwmon/acpi_power_meter.c
36535 @@ -117,7 +117,7 @@ struct sensor_template {
36536 struct device_attribute *devattr,
36537 const char *buf, size_t count);
36538 int index;
36539 -};
36540 +} __do_const;
36541
36542 /* Averaging interval */
36543 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36544 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36545 struct sensor_template *attrs)
36546 {
36547 struct device *dev = &resource->acpi_dev->dev;
36548 - struct sensor_device_attribute *sensors =
36549 + sensor_device_attribute_no_const *sensors =
36550 &resource->sensors[resource->num_sensors];
36551 int res = 0;
36552
36553 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36554 index b41baff..4953e4d 100644
36555 --- a/drivers/hwmon/applesmc.c
36556 +++ b/drivers/hwmon/applesmc.c
36557 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36558 {
36559 struct applesmc_node_group *grp;
36560 struct applesmc_dev_attr *node;
36561 - struct attribute *attr;
36562 + attribute_no_const *attr;
36563 int ret, i;
36564
36565 for (grp = groups; grp->format; grp++) {
36566 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36567 index b25c643..a13460d 100644
36568 --- a/drivers/hwmon/asus_atk0110.c
36569 +++ b/drivers/hwmon/asus_atk0110.c
36570 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36571 struct atk_sensor_data {
36572 struct list_head list;
36573 struct atk_data *data;
36574 - struct device_attribute label_attr;
36575 - struct device_attribute input_attr;
36576 - struct device_attribute limit1_attr;
36577 - struct device_attribute limit2_attr;
36578 + device_attribute_no_const label_attr;
36579 + device_attribute_no_const input_attr;
36580 + device_attribute_no_const limit1_attr;
36581 + device_attribute_no_const limit2_attr;
36582 char label_attr_name[ATTR_NAME_SIZE];
36583 char input_attr_name[ATTR_NAME_SIZE];
36584 char limit1_attr_name[ATTR_NAME_SIZE];
36585 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36586 static struct device_attribute atk_name_attr =
36587 __ATTR(name, 0444, atk_name_show, NULL);
36588
36589 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36590 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36591 sysfs_show_func show)
36592 {
36593 sysfs_attr_init(&attr->attr);
36594 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36595 index 3f1e297..a6cafb5 100644
36596 --- a/drivers/hwmon/coretemp.c
36597 +++ b/drivers/hwmon/coretemp.c
36598 @@ -791,7 +791,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36599 return NOTIFY_OK;
36600 }
36601
36602 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36603 +static struct notifier_block coretemp_cpu_notifier = {
36604 .notifier_call = coretemp_cpu_callback,
36605 };
36606
36607 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36608 index a14f634..2916ee2 100644
36609 --- a/drivers/hwmon/ibmaem.c
36610 +++ b/drivers/hwmon/ibmaem.c
36611 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36612 struct aem_rw_sensor_template *rw)
36613 {
36614 struct device *dev = &data->pdev->dev;
36615 - struct sensor_device_attribute *sensors = data->sensors;
36616 + sensor_device_attribute_no_const *sensors = data->sensors;
36617 int err;
36618
36619 /* Set up read-only sensors */
36620 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36621 index 9add6092..ee7ba3f 100644
36622 --- a/drivers/hwmon/pmbus/pmbus_core.c
36623 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36624 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36625 return 0;
36626 }
36627
36628 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36629 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36630 const char *name,
36631 umode_t mode,
36632 ssize_t (*show)(struct device *dev,
36633 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36634 dev_attr->store = store;
36635 }
36636
36637 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36638 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36639 const char *name,
36640 umode_t mode,
36641 ssize_t (*show)(struct device *dev,
36642 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36643 u16 reg, u8 mask)
36644 {
36645 struct pmbus_boolean *boolean;
36646 - struct sensor_device_attribute *a;
36647 + sensor_device_attribute_no_const *a;
36648
36649 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36650 if (!boolean)
36651 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36652 bool update, bool readonly)
36653 {
36654 struct pmbus_sensor *sensor;
36655 - struct device_attribute *a;
36656 + device_attribute_no_const *a;
36657
36658 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36659 if (!sensor)
36660 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36661 const char *lstring, int index)
36662 {
36663 struct pmbus_label *label;
36664 - struct device_attribute *a;
36665 + device_attribute_no_const *a;
36666
36667 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36668 if (!label)
36669 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36670 index 2507f90..1645765 100644
36671 --- a/drivers/hwmon/sht15.c
36672 +++ b/drivers/hwmon/sht15.c
36673 @@ -169,7 +169,7 @@ struct sht15_data {
36674 int supply_uv;
36675 bool supply_uv_valid;
36676 struct work_struct update_supply_work;
36677 - atomic_t interrupt_handled;
36678 + atomic_unchecked_t interrupt_handled;
36679 };
36680
36681 /**
36682 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36683 ret = gpio_direction_input(data->pdata->gpio_data);
36684 if (ret)
36685 return ret;
36686 - atomic_set(&data->interrupt_handled, 0);
36687 + atomic_set_unchecked(&data->interrupt_handled, 0);
36688
36689 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36690 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36691 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36692 /* Only relevant if the interrupt hasn't occurred. */
36693 - if (!atomic_read(&data->interrupt_handled))
36694 + if (!atomic_read_unchecked(&data->interrupt_handled))
36695 schedule_work(&data->read_work);
36696 }
36697 ret = wait_event_timeout(data->wait_queue,
36698 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36699
36700 /* First disable the interrupt */
36701 disable_irq_nosync(irq);
36702 - atomic_inc(&data->interrupt_handled);
36703 + atomic_inc_unchecked(&data->interrupt_handled);
36704 /* Then schedule a reading work struct */
36705 if (data->state != SHT15_READING_NOTHING)
36706 schedule_work(&data->read_work);
36707 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36708 * If not, then start the interrupt again - care here as could
36709 * have gone low in meantime so verify it hasn't!
36710 */
36711 - atomic_set(&data->interrupt_handled, 0);
36712 + atomic_set_unchecked(&data->interrupt_handled, 0);
36713 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36714 /* If still not occurred or another handler was scheduled */
36715 if (gpio_get_value(data->pdata->gpio_data)
36716 - || atomic_read(&data->interrupt_handled))
36717 + || atomic_read_unchecked(&data->interrupt_handled))
36718 return;
36719 }
36720
36721 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36722 index 76f157b..9c0db1b 100644
36723 --- a/drivers/hwmon/via-cputemp.c
36724 +++ b/drivers/hwmon/via-cputemp.c
36725 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36726 return NOTIFY_OK;
36727 }
36728
36729 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36730 +static struct notifier_block via_cputemp_cpu_notifier = {
36731 .notifier_call = via_cputemp_cpu_callback,
36732 };
36733
36734 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36735 index 378fcb5..5e91fa8 100644
36736 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36737 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36738 @@ -43,7 +43,7 @@
36739 extern struct i2c_adapter amd756_smbus;
36740
36741 static struct i2c_adapter *s4882_adapter;
36742 -static struct i2c_algorithm *s4882_algo;
36743 +static i2c_algorithm_no_const *s4882_algo;
36744
36745 /* Wrapper access functions for multiplexed SMBus */
36746 static DEFINE_MUTEX(amd756_lock);
36747 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36748 index 29015eb..af2d8e9 100644
36749 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36750 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36751 @@ -41,7 +41,7 @@
36752 extern struct i2c_adapter *nforce2_smbus;
36753
36754 static struct i2c_adapter *s4985_adapter;
36755 -static struct i2c_algorithm *s4985_algo;
36756 +static i2c_algorithm_no_const *s4985_algo;
36757
36758 /* Wrapper access functions for multiplexed SMBus */
36759 static DEFINE_MUTEX(nforce2_lock);
36760 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
36761 index c3ccdea..5b3dc1a 100644
36762 --- a/drivers/i2c/i2c-dev.c
36763 +++ b/drivers/i2c/i2c-dev.c
36764 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
36765 break;
36766 }
36767
36768 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
36769 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
36770 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
36771 if (IS_ERR(rdwr_pa[i].buf)) {
36772 res = PTR_ERR(rdwr_pa[i].buf);
36773 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36774 index 8126824..55a2798 100644
36775 --- a/drivers/ide/ide-cd.c
36776 +++ b/drivers/ide/ide-cd.c
36777 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36778 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36779 if ((unsigned long)buf & alignment
36780 || blk_rq_bytes(rq) & q->dma_pad_mask
36781 - || object_is_on_stack(buf))
36782 + || object_starts_on_stack(buf))
36783 drive->dma = 0;
36784 }
36785 }
36786 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36787 index 8848f16..f8e6dd8 100644
36788 --- a/drivers/iio/industrialio-core.c
36789 +++ b/drivers/iio/industrialio-core.c
36790 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36791 }
36792
36793 static
36794 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36795 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36796 const char *postfix,
36797 struct iio_chan_spec const *chan,
36798 ssize_t (*readfunc)(struct device *dev,
36799 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36800 index 784b97c..c9ceadf 100644
36801 --- a/drivers/infiniband/core/cm.c
36802 +++ b/drivers/infiniband/core/cm.c
36803 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36804
36805 struct cm_counter_group {
36806 struct kobject obj;
36807 - atomic_long_t counter[CM_ATTR_COUNT];
36808 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36809 };
36810
36811 struct cm_counter_attribute {
36812 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36813 struct ib_mad_send_buf *msg = NULL;
36814 int ret;
36815
36816 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36817 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36818 counter[CM_REQ_COUNTER]);
36819
36820 /* Quick state check to discard duplicate REQs. */
36821 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36822 if (!cm_id_priv)
36823 return;
36824
36825 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36826 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36827 counter[CM_REP_COUNTER]);
36828 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36829 if (ret)
36830 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
36831 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36832 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36833 spin_unlock_irq(&cm_id_priv->lock);
36834 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36835 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36836 counter[CM_RTU_COUNTER]);
36837 goto out;
36838 }
36839 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
36840 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36841 dreq_msg->local_comm_id);
36842 if (!cm_id_priv) {
36843 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36844 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36845 counter[CM_DREQ_COUNTER]);
36846 cm_issue_drep(work->port, work->mad_recv_wc);
36847 return -EINVAL;
36848 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
36849 case IB_CM_MRA_REP_RCVD:
36850 break;
36851 case IB_CM_TIMEWAIT:
36852 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36853 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36854 counter[CM_DREQ_COUNTER]);
36855 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36856 goto unlock;
36857 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
36858 cm_free_msg(msg);
36859 goto deref;
36860 case IB_CM_DREQ_RCVD:
36861 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36862 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36863 counter[CM_DREQ_COUNTER]);
36864 goto unlock;
36865 default:
36866 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
36867 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36868 cm_id_priv->msg, timeout)) {
36869 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36870 - atomic_long_inc(&work->port->
36871 + atomic_long_inc_unchecked(&work->port->
36872 counter_group[CM_RECV_DUPLICATES].
36873 counter[CM_MRA_COUNTER]);
36874 goto out;
36875 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
36876 break;
36877 case IB_CM_MRA_REQ_RCVD:
36878 case IB_CM_MRA_REP_RCVD:
36879 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36880 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36881 counter[CM_MRA_COUNTER]);
36882 /* fall through */
36883 default:
36884 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
36885 case IB_CM_LAP_IDLE:
36886 break;
36887 case IB_CM_MRA_LAP_SENT:
36888 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36889 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36890 counter[CM_LAP_COUNTER]);
36891 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36892 goto unlock;
36893 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
36894 cm_free_msg(msg);
36895 goto deref;
36896 case IB_CM_LAP_RCVD:
36897 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36898 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36899 counter[CM_LAP_COUNTER]);
36900 goto unlock;
36901 default:
36902 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36903 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36904 if (cur_cm_id_priv) {
36905 spin_unlock_irq(&cm.lock);
36906 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36907 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36908 counter[CM_SIDR_REQ_COUNTER]);
36909 goto out; /* Duplicate message. */
36910 }
36911 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36912 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36913 msg->retries = 1;
36914
36915 - atomic_long_add(1 + msg->retries,
36916 + atomic_long_add_unchecked(1 + msg->retries,
36917 &port->counter_group[CM_XMIT].counter[attr_index]);
36918 if (msg->retries)
36919 - atomic_long_add(msg->retries,
36920 + atomic_long_add_unchecked(msg->retries,
36921 &port->counter_group[CM_XMIT_RETRIES].
36922 counter[attr_index]);
36923
36924 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36925 }
36926
36927 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36928 - atomic_long_inc(&port->counter_group[CM_RECV].
36929 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36930 counter[attr_id - CM_ATTR_ID_OFFSET]);
36931
36932 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36933 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36934 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36935
36936 return sprintf(buf, "%ld\n",
36937 - atomic_long_read(&group->counter[cm_attr->index]));
36938 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36939 }
36940
36941 static const struct sysfs_ops cm_counter_ops = {
36942 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36943 index 9f5ad7c..588cd84 100644
36944 --- a/drivers/infiniband/core/fmr_pool.c
36945 +++ b/drivers/infiniband/core/fmr_pool.c
36946 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36947
36948 struct task_struct *thread;
36949
36950 - atomic_t req_ser;
36951 - atomic_t flush_ser;
36952 + atomic_unchecked_t req_ser;
36953 + atomic_unchecked_t flush_ser;
36954
36955 wait_queue_head_t force_wait;
36956 };
36957 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36958 struct ib_fmr_pool *pool = pool_ptr;
36959
36960 do {
36961 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36962 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36963 ib_fmr_batch_release(pool);
36964
36965 - atomic_inc(&pool->flush_ser);
36966 + atomic_inc_unchecked(&pool->flush_ser);
36967 wake_up_interruptible(&pool->force_wait);
36968
36969 if (pool->flush_function)
36970 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36971 }
36972
36973 set_current_state(TASK_INTERRUPTIBLE);
36974 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36975 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36976 !kthread_should_stop())
36977 schedule();
36978 __set_current_state(TASK_RUNNING);
36979 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36980 pool->dirty_watermark = params->dirty_watermark;
36981 pool->dirty_len = 0;
36982 spin_lock_init(&pool->pool_lock);
36983 - atomic_set(&pool->req_ser, 0);
36984 - atomic_set(&pool->flush_ser, 0);
36985 + atomic_set_unchecked(&pool->req_ser, 0);
36986 + atomic_set_unchecked(&pool->flush_ser, 0);
36987 init_waitqueue_head(&pool->force_wait);
36988
36989 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36990 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36991 }
36992 spin_unlock_irq(&pool->pool_lock);
36993
36994 - serial = atomic_inc_return(&pool->req_ser);
36995 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36996 wake_up_process(pool->thread);
36997
36998 if (wait_event_interruptible(pool->force_wait,
36999 - atomic_read(&pool->flush_ser) - serial >= 0))
37000 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37001 return -EINTR;
37002
37003 return 0;
37004 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37005 } else {
37006 list_add_tail(&fmr->list, &pool->dirty_list);
37007 if (++pool->dirty_len >= pool->dirty_watermark) {
37008 - atomic_inc(&pool->req_ser);
37009 + atomic_inc_unchecked(&pool->req_ser);
37010 wake_up_process(pool->thread);
37011 }
37012 }
37013 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37014 index 903a92d..9262548 100644
37015 --- a/drivers/infiniband/hw/cxgb4/mem.c
37016 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37017 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37018 int err;
37019 struct fw_ri_tpte tpt;
37020 u32 stag_idx;
37021 - static atomic_t key;
37022 + static atomic_unchecked_t key;
37023
37024 if (c4iw_fatal_error(rdev))
37025 return -EIO;
37026 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37027 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37028 rdev->stats.stag.max = rdev->stats.stag.cur;
37029 mutex_unlock(&rdev->stats.lock);
37030 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37031 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37032 }
37033 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37034 __func__, stag_state, type, pdid, stag_idx);
37035 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37036 index 79b3dbc..96e5fcc 100644
37037 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37038 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37039 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37040 struct ib_atomic_eth *ateth;
37041 struct ipath_ack_entry *e;
37042 u64 vaddr;
37043 - atomic64_t *maddr;
37044 + atomic64_unchecked_t *maddr;
37045 u64 sdata;
37046 u32 rkey;
37047 u8 next;
37048 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37049 IB_ACCESS_REMOTE_ATOMIC)))
37050 goto nack_acc_unlck;
37051 /* Perform atomic OP and save result. */
37052 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37053 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37054 sdata = be64_to_cpu(ateth->swap_data);
37055 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37056 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37057 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37058 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37059 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37060 be64_to_cpu(ateth->compare_data),
37061 sdata);
37062 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37063 index 1f95bba..9530f87 100644
37064 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37065 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37066 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37067 unsigned long flags;
37068 struct ib_wc wc;
37069 u64 sdata;
37070 - atomic64_t *maddr;
37071 + atomic64_unchecked_t *maddr;
37072 enum ib_wc_status send_status;
37073
37074 /*
37075 @@ -382,11 +382,11 @@ again:
37076 IB_ACCESS_REMOTE_ATOMIC)))
37077 goto acc_err;
37078 /* Perform atomic OP and save result. */
37079 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37080 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37081 sdata = wqe->wr.wr.atomic.compare_add;
37082 *(u64 *) sqp->s_sge.sge.vaddr =
37083 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37084 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37085 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37086 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37087 sdata, wqe->wr.wr.atomic.swap);
37088 goto send_comp;
37089 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37090 index 9d3e5c1..d9afe4a 100644
37091 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37092 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37093 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37094 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37095 }
37096
37097 -int mthca_QUERY_FW(struct mthca_dev *dev)
37098 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37099 {
37100 struct mthca_mailbox *mailbox;
37101 u32 *outbox;
37102 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37103 index ed9a989..e0c5871 100644
37104 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37105 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37106 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37107 return key;
37108 }
37109
37110 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37111 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37112 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37113 {
37114 struct mthca_mailbox *mailbox;
37115 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37116 index 4291410..d2ab1fb 100644
37117 --- a/drivers/infiniband/hw/nes/nes.c
37118 +++ b/drivers/infiniband/hw/nes/nes.c
37119 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37120 LIST_HEAD(nes_adapter_list);
37121 static LIST_HEAD(nes_dev_list);
37122
37123 -atomic_t qps_destroyed;
37124 +atomic_unchecked_t qps_destroyed;
37125
37126 static unsigned int ee_flsh_adapter;
37127 static unsigned int sysfs_nonidx_addr;
37128 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37129 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37130 struct nes_adapter *nesadapter = nesdev->nesadapter;
37131
37132 - atomic_inc(&qps_destroyed);
37133 + atomic_inc_unchecked(&qps_destroyed);
37134
37135 /* Free the control structures */
37136
37137 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37138 index 33cc589..3bd6538 100644
37139 --- a/drivers/infiniband/hw/nes/nes.h
37140 +++ b/drivers/infiniband/hw/nes/nes.h
37141 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37142 extern unsigned int wqm_quanta;
37143 extern struct list_head nes_adapter_list;
37144
37145 -extern atomic_t cm_connects;
37146 -extern atomic_t cm_accepts;
37147 -extern atomic_t cm_disconnects;
37148 -extern atomic_t cm_closes;
37149 -extern atomic_t cm_connecteds;
37150 -extern atomic_t cm_connect_reqs;
37151 -extern atomic_t cm_rejects;
37152 -extern atomic_t mod_qp_timouts;
37153 -extern atomic_t qps_created;
37154 -extern atomic_t qps_destroyed;
37155 -extern atomic_t sw_qps_destroyed;
37156 +extern atomic_unchecked_t cm_connects;
37157 +extern atomic_unchecked_t cm_accepts;
37158 +extern atomic_unchecked_t cm_disconnects;
37159 +extern atomic_unchecked_t cm_closes;
37160 +extern atomic_unchecked_t cm_connecteds;
37161 +extern atomic_unchecked_t cm_connect_reqs;
37162 +extern atomic_unchecked_t cm_rejects;
37163 +extern atomic_unchecked_t mod_qp_timouts;
37164 +extern atomic_unchecked_t qps_created;
37165 +extern atomic_unchecked_t qps_destroyed;
37166 +extern atomic_unchecked_t sw_qps_destroyed;
37167 extern u32 mh_detected;
37168 extern u32 mh_pauses_sent;
37169 extern u32 cm_packets_sent;
37170 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37171 extern u32 cm_packets_received;
37172 extern u32 cm_packets_dropped;
37173 extern u32 cm_packets_retrans;
37174 -extern atomic_t cm_listens_created;
37175 -extern atomic_t cm_listens_destroyed;
37176 +extern atomic_unchecked_t cm_listens_created;
37177 +extern atomic_unchecked_t cm_listens_destroyed;
37178 extern u32 cm_backlog_drops;
37179 -extern atomic_t cm_loopbacks;
37180 -extern atomic_t cm_nodes_created;
37181 -extern atomic_t cm_nodes_destroyed;
37182 -extern atomic_t cm_accel_dropped_pkts;
37183 -extern atomic_t cm_resets_recvd;
37184 -extern atomic_t pau_qps_created;
37185 -extern atomic_t pau_qps_destroyed;
37186 +extern atomic_unchecked_t cm_loopbacks;
37187 +extern atomic_unchecked_t cm_nodes_created;
37188 +extern atomic_unchecked_t cm_nodes_destroyed;
37189 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37190 +extern atomic_unchecked_t cm_resets_recvd;
37191 +extern atomic_unchecked_t pau_qps_created;
37192 +extern atomic_unchecked_t pau_qps_destroyed;
37193
37194 extern u32 int_mod_timer_init;
37195 extern u32 int_mod_cq_depth_256;
37196 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37197 index 24b9f1a..00fd004 100644
37198 --- a/drivers/infiniband/hw/nes/nes_cm.c
37199 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37200 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37201 u32 cm_packets_retrans;
37202 u32 cm_packets_created;
37203 u32 cm_packets_received;
37204 -atomic_t cm_listens_created;
37205 -atomic_t cm_listens_destroyed;
37206 +atomic_unchecked_t cm_listens_created;
37207 +atomic_unchecked_t cm_listens_destroyed;
37208 u32 cm_backlog_drops;
37209 -atomic_t cm_loopbacks;
37210 -atomic_t cm_nodes_created;
37211 -atomic_t cm_nodes_destroyed;
37212 -atomic_t cm_accel_dropped_pkts;
37213 -atomic_t cm_resets_recvd;
37214 +atomic_unchecked_t cm_loopbacks;
37215 +atomic_unchecked_t cm_nodes_created;
37216 +atomic_unchecked_t cm_nodes_destroyed;
37217 +atomic_unchecked_t cm_accel_dropped_pkts;
37218 +atomic_unchecked_t cm_resets_recvd;
37219
37220 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37221 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37222 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37223
37224 static struct nes_cm_core *g_cm_core;
37225
37226 -atomic_t cm_connects;
37227 -atomic_t cm_accepts;
37228 -atomic_t cm_disconnects;
37229 -atomic_t cm_closes;
37230 -atomic_t cm_connecteds;
37231 -atomic_t cm_connect_reqs;
37232 -atomic_t cm_rejects;
37233 +atomic_unchecked_t cm_connects;
37234 +atomic_unchecked_t cm_accepts;
37235 +atomic_unchecked_t cm_disconnects;
37236 +atomic_unchecked_t cm_closes;
37237 +atomic_unchecked_t cm_connecteds;
37238 +atomic_unchecked_t cm_connect_reqs;
37239 +atomic_unchecked_t cm_rejects;
37240
37241 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37242 {
37243 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37244 kfree(listener);
37245 listener = NULL;
37246 ret = 0;
37247 - atomic_inc(&cm_listens_destroyed);
37248 + atomic_inc_unchecked(&cm_listens_destroyed);
37249 } else {
37250 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37251 }
37252 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37253 cm_node->rem_mac);
37254
37255 add_hte_node(cm_core, cm_node);
37256 - atomic_inc(&cm_nodes_created);
37257 + atomic_inc_unchecked(&cm_nodes_created);
37258
37259 return cm_node;
37260 }
37261 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37262 }
37263
37264 atomic_dec(&cm_core->node_cnt);
37265 - atomic_inc(&cm_nodes_destroyed);
37266 + atomic_inc_unchecked(&cm_nodes_destroyed);
37267 nesqp = cm_node->nesqp;
37268 if (nesqp) {
37269 nesqp->cm_node = NULL;
37270 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37271
37272 static void drop_packet(struct sk_buff *skb)
37273 {
37274 - atomic_inc(&cm_accel_dropped_pkts);
37275 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37276 dev_kfree_skb_any(skb);
37277 }
37278
37279 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37280 {
37281
37282 int reset = 0; /* whether to send reset in case of err.. */
37283 - atomic_inc(&cm_resets_recvd);
37284 + atomic_inc_unchecked(&cm_resets_recvd);
37285 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37286 " refcnt=%d\n", cm_node, cm_node->state,
37287 atomic_read(&cm_node->ref_count));
37288 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37289 rem_ref_cm_node(cm_node->cm_core, cm_node);
37290 return NULL;
37291 }
37292 - atomic_inc(&cm_loopbacks);
37293 + atomic_inc_unchecked(&cm_loopbacks);
37294 loopbackremotenode->loopbackpartner = cm_node;
37295 loopbackremotenode->tcp_cntxt.rcv_wscale =
37296 NES_CM_DEFAULT_RCV_WND_SCALE;
37297 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37298 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37299 else {
37300 rem_ref_cm_node(cm_core, cm_node);
37301 - atomic_inc(&cm_accel_dropped_pkts);
37302 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37303 dev_kfree_skb_any(skb);
37304 }
37305 break;
37306 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37307
37308 if ((cm_id) && (cm_id->event_handler)) {
37309 if (issue_disconn) {
37310 - atomic_inc(&cm_disconnects);
37311 + atomic_inc_unchecked(&cm_disconnects);
37312 cm_event.event = IW_CM_EVENT_DISCONNECT;
37313 cm_event.status = disconn_status;
37314 cm_event.local_addr = cm_id->local_addr;
37315 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37316 }
37317
37318 if (issue_close) {
37319 - atomic_inc(&cm_closes);
37320 + atomic_inc_unchecked(&cm_closes);
37321 nes_disconnect(nesqp, 1);
37322
37323 cm_id->provider_data = nesqp;
37324 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37325
37326 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37327 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37328 - atomic_inc(&cm_accepts);
37329 + atomic_inc_unchecked(&cm_accepts);
37330
37331 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37332 netdev_refcnt_read(nesvnic->netdev));
37333 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37334 struct nes_cm_core *cm_core;
37335 u8 *start_buff;
37336
37337 - atomic_inc(&cm_rejects);
37338 + atomic_inc_unchecked(&cm_rejects);
37339 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37340 loopback = cm_node->loopbackpartner;
37341 cm_core = cm_node->cm_core;
37342 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37343 ntohl(cm_id->local_addr.sin_addr.s_addr),
37344 ntohs(cm_id->local_addr.sin_port));
37345
37346 - atomic_inc(&cm_connects);
37347 + atomic_inc_unchecked(&cm_connects);
37348 nesqp->active_conn = 1;
37349
37350 /* cache the cm_id in the qp */
37351 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37352 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37353 return err;
37354 }
37355 - atomic_inc(&cm_listens_created);
37356 + atomic_inc_unchecked(&cm_listens_created);
37357 }
37358
37359 cm_id->add_ref(cm_id);
37360 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37361
37362 if (nesqp->destroyed)
37363 return;
37364 - atomic_inc(&cm_connecteds);
37365 + atomic_inc_unchecked(&cm_connecteds);
37366 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37367 " local port 0x%04X. jiffies = %lu.\n",
37368 nesqp->hwqp.qp_id,
37369 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37370
37371 cm_id->add_ref(cm_id);
37372 ret = cm_id->event_handler(cm_id, &cm_event);
37373 - atomic_inc(&cm_closes);
37374 + atomic_inc_unchecked(&cm_closes);
37375 cm_event.event = IW_CM_EVENT_CLOSE;
37376 cm_event.status = 0;
37377 cm_event.provider_data = cm_id->provider_data;
37378 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37379 return;
37380 cm_id = cm_node->cm_id;
37381
37382 - atomic_inc(&cm_connect_reqs);
37383 + atomic_inc_unchecked(&cm_connect_reqs);
37384 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37385 cm_node, cm_id, jiffies);
37386
37387 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37388 return;
37389 cm_id = cm_node->cm_id;
37390
37391 - atomic_inc(&cm_connect_reqs);
37392 + atomic_inc_unchecked(&cm_connect_reqs);
37393 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37394 cm_node, cm_id, jiffies);
37395
37396 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37397 index 4166452..fc952c3 100644
37398 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37399 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37400 @@ -40,8 +40,8 @@
37401 #include "nes.h"
37402 #include "nes_mgt.h"
37403
37404 -atomic_t pau_qps_created;
37405 -atomic_t pau_qps_destroyed;
37406 +atomic_unchecked_t pau_qps_created;
37407 +atomic_unchecked_t pau_qps_destroyed;
37408
37409 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37410 {
37411 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37412 {
37413 struct sk_buff *skb;
37414 unsigned long flags;
37415 - atomic_inc(&pau_qps_destroyed);
37416 + atomic_inc_unchecked(&pau_qps_destroyed);
37417
37418 /* Free packets that have not yet been forwarded */
37419 /* Lock is acquired by skb_dequeue when removing the skb */
37420 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37421 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37422 skb_queue_head_init(&nesqp->pau_list);
37423 spin_lock_init(&nesqp->pau_lock);
37424 - atomic_inc(&pau_qps_created);
37425 + atomic_inc_unchecked(&pau_qps_created);
37426 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37427 }
37428
37429 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37430 index 85cf4d1..05d8e71 100644
37431 --- a/drivers/infiniband/hw/nes/nes_nic.c
37432 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37433 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37434 target_stat_values[++index] = mh_detected;
37435 target_stat_values[++index] = mh_pauses_sent;
37436 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37437 - target_stat_values[++index] = atomic_read(&cm_connects);
37438 - target_stat_values[++index] = atomic_read(&cm_accepts);
37439 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37440 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37441 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37442 - target_stat_values[++index] = atomic_read(&cm_rejects);
37443 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37444 - target_stat_values[++index] = atomic_read(&qps_created);
37445 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37446 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37447 - target_stat_values[++index] = atomic_read(&cm_closes);
37448 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37449 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37450 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37451 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37452 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37453 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37454 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37455 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37456 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37457 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37458 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37459 target_stat_values[++index] = cm_packets_sent;
37460 target_stat_values[++index] = cm_packets_bounced;
37461 target_stat_values[++index] = cm_packets_created;
37462 target_stat_values[++index] = cm_packets_received;
37463 target_stat_values[++index] = cm_packets_dropped;
37464 target_stat_values[++index] = cm_packets_retrans;
37465 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37466 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37467 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37468 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37469 target_stat_values[++index] = cm_backlog_drops;
37470 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37471 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37472 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37473 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37474 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37475 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37476 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37477 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37478 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37479 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37480 target_stat_values[++index] = nesadapter->free_4kpbl;
37481 target_stat_values[++index] = nesadapter->free_256pbl;
37482 target_stat_values[++index] = int_mod_timer_init;
37483 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37484 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37485 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37486 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37487 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37488 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37489 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37490 }
37491
37492 /**
37493 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37494 index 8f67fe2..8960859 100644
37495 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37496 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37497 @@ -46,9 +46,9 @@
37498
37499 #include <rdma/ib_umem.h>
37500
37501 -atomic_t mod_qp_timouts;
37502 -atomic_t qps_created;
37503 -atomic_t sw_qps_destroyed;
37504 +atomic_unchecked_t mod_qp_timouts;
37505 +atomic_unchecked_t qps_created;
37506 +atomic_unchecked_t sw_qps_destroyed;
37507
37508 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37509
37510 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37511 if (init_attr->create_flags)
37512 return ERR_PTR(-EINVAL);
37513
37514 - atomic_inc(&qps_created);
37515 + atomic_inc_unchecked(&qps_created);
37516 switch (init_attr->qp_type) {
37517 case IB_QPT_RC:
37518 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37519 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37520 struct iw_cm_event cm_event;
37521 int ret = 0;
37522
37523 - atomic_inc(&sw_qps_destroyed);
37524 + atomic_inc_unchecked(&sw_qps_destroyed);
37525 nesqp->destroyed = 1;
37526
37527 /* Blow away the connection if it exists. */
37528 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37529 index 4d11575..3e890e5 100644
37530 --- a/drivers/infiniband/hw/qib/qib.h
37531 +++ b/drivers/infiniband/hw/qib/qib.h
37532 @@ -51,6 +51,7 @@
37533 #include <linux/completion.h>
37534 #include <linux/kref.h>
37535 #include <linux/sched.h>
37536 +#include <linux/slab.h>
37537
37538 #include "qib_common.h"
37539 #include "qib_verbs.h"
37540 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37541 index da739d9..da1c7f4 100644
37542 --- a/drivers/input/gameport/gameport.c
37543 +++ b/drivers/input/gameport/gameport.c
37544 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37545 */
37546 static void gameport_init_port(struct gameport *gameport)
37547 {
37548 - static atomic_t gameport_no = ATOMIC_INIT(0);
37549 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37550
37551 __module_get(THIS_MODULE);
37552
37553 mutex_init(&gameport->drv_mutex);
37554 device_initialize(&gameport->dev);
37555 dev_set_name(&gameport->dev, "gameport%lu",
37556 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37557 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37558 gameport->dev.bus = &gameport_bus;
37559 gameport->dev.release = gameport_release_port;
37560 if (gameport->parent)
37561 diff --git a/drivers/input/input.c b/drivers/input/input.c
37562 index c044699..174d71a 100644
37563 --- a/drivers/input/input.c
37564 +++ b/drivers/input/input.c
37565 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37566 */
37567 int input_register_device(struct input_dev *dev)
37568 {
37569 - static atomic_t input_no = ATOMIC_INIT(0);
37570 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37571 struct input_devres *devres = NULL;
37572 struct input_handler *handler;
37573 unsigned int packet_size;
37574 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37575 dev->setkeycode = input_default_setkeycode;
37576
37577 dev_set_name(&dev->dev, "input%ld",
37578 - (unsigned long) atomic_inc_return(&input_no) - 1);
37579 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37580
37581 error = device_add(&dev->dev);
37582 if (error)
37583 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37584 index 04c69af..5f92d00 100644
37585 --- a/drivers/input/joystick/sidewinder.c
37586 +++ b/drivers/input/joystick/sidewinder.c
37587 @@ -30,6 +30,7 @@
37588 #include <linux/kernel.h>
37589 #include <linux/module.h>
37590 #include <linux/slab.h>
37591 +#include <linux/sched.h>
37592 #include <linux/init.h>
37593 #include <linux/input.h>
37594 #include <linux/gameport.h>
37595 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37596 index d6cbfe9..6225402 100644
37597 --- a/drivers/input/joystick/xpad.c
37598 +++ b/drivers/input/joystick/xpad.c
37599 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37600
37601 static int xpad_led_probe(struct usb_xpad *xpad)
37602 {
37603 - static atomic_t led_seq = ATOMIC_INIT(0);
37604 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37605 long led_no;
37606 struct xpad_led *led;
37607 struct led_classdev *led_cdev;
37608 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37609 if (!led)
37610 return -ENOMEM;
37611
37612 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37613 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37614
37615 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37616 led->xpad = xpad;
37617 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37618 index 2f0b39d..7370f13 100644
37619 --- a/drivers/input/mouse/psmouse.h
37620 +++ b/drivers/input/mouse/psmouse.h
37621 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37622 ssize_t (*set)(struct psmouse *psmouse, void *data,
37623 const char *buf, size_t count);
37624 bool protect;
37625 -};
37626 +} __do_const;
37627 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37628
37629 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37630 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37631 index 4c842c3..590b0bf 100644
37632 --- a/drivers/input/mousedev.c
37633 +++ b/drivers/input/mousedev.c
37634 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37635
37636 spin_unlock_irq(&client->packet_lock);
37637
37638 - if (copy_to_user(buffer, data, count))
37639 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37640 return -EFAULT;
37641
37642 return count;
37643 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37644 index 25fc597..558bf3b3 100644
37645 --- a/drivers/input/serio/serio.c
37646 +++ b/drivers/input/serio/serio.c
37647 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37648 */
37649 static void serio_init_port(struct serio *serio)
37650 {
37651 - static atomic_t serio_no = ATOMIC_INIT(0);
37652 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37653
37654 __module_get(THIS_MODULE);
37655
37656 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37657 mutex_init(&serio->drv_mutex);
37658 device_initialize(&serio->dev);
37659 dev_set_name(&serio->dev, "serio%ld",
37660 - (long)atomic_inc_return(&serio_no) - 1);
37661 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37662 serio->dev.bus = &serio_bus;
37663 serio->dev.release = serio_release_port;
37664 serio->dev.groups = serio_device_attr_groups;
37665 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37666 index b972d43..8943713 100644
37667 --- a/drivers/iommu/iommu.c
37668 +++ b/drivers/iommu/iommu.c
37669 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37670 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37671 {
37672 bus_register_notifier(bus, &iommu_bus_nb);
37673 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37674 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37675 }
37676
37677 /**
37678 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37679 index 7c11ff3..a2a0457 100644
37680 --- a/drivers/iommu/irq_remapping.c
37681 +++ b/drivers/iommu/irq_remapping.c
37682 @@ -348,7 +348,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
37683 void panic_if_irq_remap(const char *msg)
37684 {
37685 if (irq_remapping_enabled)
37686 - panic(msg);
37687 + panic("%s", msg);
37688 }
37689
37690 static void ir_ack_apic_edge(struct irq_data *data)
37691 @@ -369,10 +369,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37692
37693 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37694 {
37695 - chip->irq_print_chip = ir_print_prefix;
37696 - chip->irq_ack = ir_ack_apic_edge;
37697 - chip->irq_eoi = ir_ack_apic_level;
37698 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37699 + pax_open_kernel();
37700 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37701 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37702 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37703 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37704 + pax_close_kernel();
37705 }
37706
37707 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37708 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37709 index fc6aebf..762c5f5 100644
37710 --- a/drivers/irqchip/irq-gic.c
37711 +++ b/drivers/irqchip/irq-gic.c
37712 @@ -83,7 +83,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37713 * Supported arch specific GIC irq extension.
37714 * Default make them NULL.
37715 */
37716 -struct irq_chip gic_arch_extn = {
37717 +irq_chip_no_const gic_arch_extn = {
37718 .irq_eoi = NULL,
37719 .irq_mask = NULL,
37720 .irq_unmask = NULL,
37721 @@ -332,7 +332,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37722 chained_irq_exit(chip, desc);
37723 }
37724
37725 -static struct irq_chip gic_chip = {
37726 +static irq_chip_no_const gic_chip __read_only = {
37727 .name = "GIC",
37728 .irq_mask = gic_mask_irq,
37729 .irq_unmask = gic_unmask_irq,
37730 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37731 index 89562a8..218999b 100644
37732 --- a/drivers/isdn/capi/capi.c
37733 +++ b/drivers/isdn/capi/capi.c
37734 @@ -81,8 +81,8 @@ struct capiminor {
37735
37736 struct capi20_appl *ap;
37737 u32 ncci;
37738 - atomic_t datahandle;
37739 - atomic_t msgid;
37740 + atomic_unchecked_t datahandle;
37741 + atomic_unchecked_t msgid;
37742
37743 struct tty_port port;
37744 int ttyinstop;
37745 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37746 capimsg_setu16(s, 2, mp->ap->applid);
37747 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37748 capimsg_setu8 (s, 5, CAPI_RESP);
37749 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37750 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37751 capimsg_setu32(s, 8, mp->ncci);
37752 capimsg_setu16(s, 12, datahandle);
37753 }
37754 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37755 mp->outbytes -= len;
37756 spin_unlock_bh(&mp->outlock);
37757
37758 - datahandle = atomic_inc_return(&mp->datahandle);
37759 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37760 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37761 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37762 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37763 capimsg_setu16(skb->data, 2, mp->ap->applid);
37764 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37765 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37766 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37767 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37768 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37769 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37770 capimsg_setu16(skb->data, 16, len); /* Data length */
37771 diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
37772 index 9b1b274..c123709 100644
37773 --- a/drivers/isdn/capi/kcapi.c
37774 +++ b/drivers/isdn/capi/kcapi.c
37775 @@ -93,7 +93,7 @@ capi_ctr_put(struct capi_ctr *ctr)
37776
37777 static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr)
37778 {
37779 - if (contr - 1 >= CAPI_MAXCONTR)
37780 + if (contr < 1 || contr - 1 >= CAPI_MAXCONTR)
37781 return NULL;
37782
37783 return capi_controller[contr - 1];
37784 @@ -103,7 +103,7 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)
37785 {
37786 lockdep_assert_held(&capi_controller_lock);
37787
37788 - if (applid - 1 >= CAPI_MAXAPPL)
37789 + if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)
37790 return NULL;
37791
37792 return capi_applications[applid - 1];
37793 @@ -111,7 +111,7 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)
37794
37795 static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid)
37796 {
37797 - if (applid - 1 >= CAPI_MAXAPPL)
37798 + if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)
37799 return NULL;
37800
37801 return rcu_dereference(capi_applications[applid - 1]);
37802 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37803 index e2b5396..c5486dc 100644
37804 --- a/drivers/isdn/gigaset/interface.c
37805 +++ b/drivers/isdn/gigaset/interface.c
37806 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37807 }
37808 tty->driver_data = cs;
37809
37810 - ++cs->port.count;
37811 + atomic_inc(&cs->port.count);
37812
37813 - if (cs->port.count == 1) {
37814 + if (atomic_read(&cs->port.count) == 1) {
37815 tty_port_tty_set(&cs->port, tty);
37816 cs->port.low_latency = 1;
37817 }
37818 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37819
37820 if (!cs->connected)
37821 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37822 - else if (!cs->port.count)
37823 + else if (!atomic_read(&cs->port.count))
37824 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37825 - else if (!--cs->port.count)
37826 + else if (!atomic_dec_return(&cs->port.count))
37827 tty_port_tty_set(&cs->port, NULL);
37828
37829 mutex_unlock(&cs->mutex);
37830 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37831 index 821f7ac..28d4030 100644
37832 --- a/drivers/isdn/hardware/avm/b1.c
37833 +++ b/drivers/isdn/hardware/avm/b1.c
37834 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37835 }
37836 if (left) {
37837 if (t4file->user) {
37838 - if (copy_from_user(buf, dp, left))
37839 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37840 return -EFAULT;
37841 } else {
37842 memcpy(buf, dp, left);
37843 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37844 }
37845 if (left) {
37846 if (config->user) {
37847 - if (copy_from_user(buf, dp, left))
37848 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37849 return -EFAULT;
37850 } else {
37851 memcpy(buf, dp, left);
37852 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37853 index ebaebdf..acd4405 100644
37854 --- a/drivers/isdn/i4l/isdn_tty.c
37855 +++ b/drivers/isdn/i4l/isdn_tty.c
37856 @@ -1511,9 +1511,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37857
37858 #ifdef ISDN_DEBUG_MODEM_OPEN
37859 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37860 - port->count);
37861 + atomic_read(&port->count));
37862 #endif
37863 - port->count++;
37864 + atomic_inc(&port->count);
37865 port->tty = tty;
37866 /*
37867 * Start up serial port
37868 @@ -1557,7 +1557,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37869 #endif
37870 return;
37871 }
37872 - if ((tty->count == 1) && (port->count != 1)) {
37873 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37874 /*
37875 * Uh, oh. tty->count is 1, which means that the tty
37876 * structure will be freed. Info->count should always
37877 @@ -1566,15 +1566,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37878 * serial port won't be shutdown.
37879 */
37880 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37881 - "info->count is %d\n", port->count);
37882 - port->count = 1;
37883 + "info->count is %d\n", atomic_read(&port->count));
37884 + atomic_set(&port->count, 1);
37885 }
37886 - if (--port->count < 0) {
37887 + if (atomic_dec_return(&port->count) < 0) {
37888 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37889 - info->line, port->count);
37890 - port->count = 0;
37891 + info->line, atomic_read(&port->count));
37892 + atomic_set(&port->count, 0);
37893 }
37894 - if (port->count) {
37895 + if (atomic_read(&port->count)) {
37896 #ifdef ISDN_DEBUG_MODEM_OPEN
37897 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37898 #endif
37899 @@ -1628,7 +1628,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37900 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37901 return;
37902 isdn_tty_shutdown(info);
37903 - port->count = 0;
37904 + atomic_set(&port->count, 0);
37905 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37906 port->tty = NULL;
37907 wake_up_interruptible(&port->open_wait);
37908 @@ -1973,7 +1973,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37909 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37910 modem_info *info = &dev->mdm.info[i];
37911
37912 - if (info->port.count == 0)
37913 + if (atomic_read(&info->port.count) == 0)
37914 continue;
37915 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37916 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37917 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37918 index e74df7c..03a03ba 100644
37919 --- a/drivers/isdn/icn/icn.c
37920 +++ b/drivers/isdn/icn/icn.c
37921 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37922 if (count > len)
37923 count = len;
37924 if (user) {
37925 - if (copy_from_user(msg, buf, count))
37926 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37927 return -EFAULT;
37928 } else
37929 memcpy(msg, buf, count);
37930 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37931 index 6a8405d..0bd1c7e 100644
37932 --- a/drivers/leds/leds-clevo-mail.c
37933 +++ b/drivers/leds/leds-clevo-mail.c
37934 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37935 * detected as working, but in reality it is not) as low as
37936 * possible.
37937 */
37938 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37939 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37940 {
37941 .callback = clevo_mail_led_dmi_callback,
37942 .ident = "Clevo D410J",
37943 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37944 index 64e204e..c6bf189 100644
37945 --- a/drivers/leds/leds-ss4200.c
37946 +++ b/drivers/leds/leds-ss4200.c
37947 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37948 * detected as working, but in reality it is not) as low as
37949 * possible.
37950 */
37951 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37952 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37953 {
37954 .callback = ss4200_led_dmi_callback,
37955 .ident = "Intel SS4200-E",
37956 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37957 index a5ebc00..3de3364 100644
37958 --- a/drivers/lguest/core.c
37959 +++ b/drivers/lguest/core.c
37960 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37961 * it's worked so far. The end address needs +1 because __get_vm_area
37962 * allocates an extra guard page, so we need space for that.
37963 */
37964 +
37965 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37966 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37967 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37968 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37969 +#else
37970 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37971 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37972 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37973 +#endif
37974 +
37975 if (!switcher_vma) {
37976 err = -ENOMEM;
37977 printk("lguest: could not map switcher pages high\n");
37978 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37979 * Now the Switcher is mapped at the right address, we can't fail!
37980 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37981 */
37982 - memcpy(switcher_vma->addr, start_switcher_text,
37983 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37984 end_switcher_text - start_switcher_text);
37985
37986 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37987 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37988 index 3b62be16..e33134a 100644
37989 --- a/drivers/lguest/page_tables.c
37990 +++ b/drivers/lguest/page_tables.c
37991 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37992 /*:*/
37993
37994 #ifdef CONFIG_X86_PAE
37995 -static void release_pmd(pmd_t *spmd)
37996 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37997 {
37998 /* If the entry's not present, there's nothing to release. */
37999 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
38000 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
38001 index 4af12e1..0e89afe 100644
38002 --- a/drivers/lguest/x86/core.c
38003 +++ b/drivers/lguest/x86/core.c
38004 @@ -59,7 +59,7 @@ static struct {
38005 /* Offset from where switcher.S was compiled to where we've copied it */
38006 static unsigned long switcher_offset(void)
38007 {
38008 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
38009 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
38010 }
38011
38012 /* This cpu's struct lguest_pages. */
38013 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
38014 * These copies are pretty cheap, so we do them unconditionally: */
38015 /* Save the current Host top-level page directory.
38016 */
38017 +
38018 +#ifdef CONFIG_PAX_PER_CPU_PGD
38019 + pages->state.host_cr3 = read_cr3();
38020 +#else
38021 pages->state.host_cr3 = __pa(current->mm->pgd);
38022 +#endif
38023 +
38024 /*
38025 * Set up the Guest's page tables to see this CPU's pages (and no
38026 * other CPU's pages).
38027 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
38028 * compiled-in switcher code and the high-mapped copy we just made.
38029 */
38030 for (i = 0; i < IDT_ENTRIES; i++)
38031 - default_idt_entries[i] += switcher_offset();
38032 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
38033
38034 /*
38035 * Set up the Switcher's per-cpu areas.
38036 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
38037 * it will be undisturbed when we switch. To change %cs and jump we
38038 * need this structure to feed to Intel's "lcall" instruction.
38039 */
38040 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
38041 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
38042 lguest_entry.segment = LGUEST_CS;
38043
38044 /*
38045 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
38046 index 40634b0..4f5855e 100644
38047 --- a/drivers/lguest/x86/switcher_32.S
38048 +++ b/drivers/lguest/x86/switcher_32.S
38049 @@ -87,6 +87,7 @@
38050 #include <asm/page.h>
38051 #include <asm/segment.h>
38052 #include <asm/lguest.h>
38053 +#include <asm/processor-flags.h>
38054
38055 // We mark the start of the code to copy
38056 // It's placed in .text tho it's never run here
38057 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38058 // Changes type when we load it: damn Intel!
38059 // For after we switch over our page tables
38060 // That entry will be read-only: we'd crash.
38061 +
38062 +#ifdef CONFIG_PAX_KERNEXEC
38063 + mov %cr0, %edx
38064 + xor $X86_CR0_WP, %edx
38065 + mov %edx, %cr0
38066 +#endif
38067 +
38068 movl $(GDT_ENTRY_TSS*8), %edx
38069 ltr %dx
38070
38071 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38072 // Let's clear it again for our return.
38073 // The GDT descriptor of the Host
38074 // Points to the table after two "size" bytes
38075 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38076 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38077 // Clear "used" from type field (byte 5, bit 2)
38078 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38079 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38080 +
38081 +#ifdef CONFIG_PAX_KERNEXEC
38082 + mov %cr0, %eax
38083 + xor $X86_CR0_WP, %eax
38084 + mov %eax, %cr0
38085 +#endif
38086
38087 // Once our page table's switched, the Guest is live!
38088 // The Host fades as we run this final step.
38089 @@ -295,13 +309,12 @@ deliver_to_host:
38090 // I consulted gcc, and it gave
38091 // These instructions, which I gladly credit:
38092 leal (%edx,%ebx,8), %eax
38093 - movzwl (%eax),%edx
38094 - movl 4(%eax), %eax
38095 - xorw %ax, %ax
38096 - orl %eax, %edx
38097 + movl 4(%eax), %edx
38098 + movw (%eax), %dx
38099 // Now the address of the handler's in %edx
38100 // We call it now: its "iret" drops us home.
38101 - jmp *%edx
38102 + ljmp $__KERNEL_CS, $1f
38103 +1: jmp *%edx
38104
38105 // Every interrupt can come to us here
38106 // But we must truly tell each apart.
38107 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38108 index 4fd9d6a..834fa03 100644
38109 --- a/drivers/md/bitmap.c
38110 +++ b/drivers/md/bitmap.c
38111 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38112 chunk_kb ? "KB" : "B");
38113 if (bitmap->storage.file) {
38114 seq_printf(seq, ", file: ");
38115 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38116 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38117 }
38118
38119 seq_printf(seq, "\n");
38120 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38121 index aa04f02..2a1309e 100644
38122 --- a/drivers/md/dm-ioctl.c
38123 +++ b/drivers/md/dm-ioctl.c
38124 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38125 cmd == DM_LIST_VERSIONS_CMD)
38126 return 0;
38127
38128 - if ((cmd == DM_DEV_CREATE_CMD)) {
38129 + if (cmd == DM_DEV_CREATE_CMD) {
38130 if (!*param->name) {
38131 DMWARN("name not supplied when creating device");
38132 return -EINVAL;
38133 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38134 index d053098..05cc375 100644
38135 --- a/drivers/md/dm-raid1.c
38136 +++ b/drivers/md/dm-raid1.c
38137 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38138
38139 struct mirror {
38140 struct mirror_set *ms;
38141 - atomic_t error_count;
38142 + atomic_unchecked_t error_count;
38143 unsigned long error_type;
38144 struct dm_dev *dev;
38145 sector_t offset;
38146 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38147 struct mirror *m;
38148
38149 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38150 - if (!atomic_read(&m->error_count))
38151 + if (!atomic_read_unchecked(&m->error_count))
38152 return m;
38153
38154 return NULL;
38155 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38156 * simple way to tell if a device has encountered
38157 * errors.
38158 */
38159 - atomic_inc(&m->error_count);
38160 + atomic_inc_unchecked(&m->error_count);
38161
38162 if (test_and_set_bit(error_type, &m->error_type))
38163 return;
38164 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38165 struct mirror *m = get_default_mirror(ms);
38166
38167 do {
38168 - if (likely(!atomic_read(&m->error_count)))
38169 + if (likely(!atomic_read_unchecked(&m->error_count)))
38170 return m;
38171
38172 if (m-- == ms->mirror)
38173 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
38174 {
38175 struct mirror *default_mirror = get_default_mirror(m->ms);
38176
38177 - return !atomic_read(&default_mirror->error_count);
38178 + return !atomic_read_unchecked(&default_mirror->error_count);
38179 }
38180
38181 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38182 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38183 */
38184 if (likely(region_in_sync(ms, region, 1)))
38185 m = choose_mirror(ms, bio->bi_sector);
38186 - else if (m && atomic_read(&m->error_count))
38187 + else if (m && atomic_read_unchecked(&m->error_count))
38188 m = NULL;
38189
38190 if (likely(m))
38191 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38192 }
38193
38194 ms->mirror[mirror].ms = ms;
38195 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38196 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38197 ms->mirror[mirror].error_type = 0;
38198 ms->mirror[mirror].offset = offset;
38199
38200 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
38201 */
38202 static char device_status_char(struct mirror *m)
38203 {
38204 - if (!atomic_read(&(m->error_count)))
38205 + if (!atomic_read_unchecked(&(m->error_count)))
38206 return 'A';
38207
38208 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38209 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38210 index 7b8b2b9..9c7d145 100644
38211 --- a/drivers/md/dm-stripe.c
38212 +++ b/drivers/md/dm-stripe.c
38213 @@ -20,7 +20,7 @@ struct stripe {
38214 struct dm_dev *dev;
38215 sector_t physical_start;
38216
38217 - atomic_t error_count;
38218 + atomic_unchecked_t error_count;
38219 };
38220
38221 struct stripe_c {
38222 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38223 kfree(sc);
38224 return r;
38225 }
38226 - atomic_set(&(sc->stripe[i].error_count), 0);
38227 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38228 }
38229
38230 ti->private = sc;
38231 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38232 DMEMIT("%d ", sc->stripes);
38233 for (i = 0; i < sc->stripes; i++) {
38234 DMEMIT("%s ", sc->stripe[i].dev->name);
38235 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38236 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38237 'D' : 'A';
38238 }
38239 buffer[i] = '\0';
38240 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38241 */
38242 for (i = 0; i < sc->stripes; i++)
38243 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38244 - atomic_inc(&(sc->stripe[i].error_count));
38245 - if (atomic_read(&(sc->stripe[i].error_count)) <
38246 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38247 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38248 DM_IO_ERROR_THRESHOLD)
38249 schedule_work(&sc->trigger_event);
38250 }
38251 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38252 index 1ff252a..ee384c1 100644
38253 --- a/drivers/md/dm-table.c
38254 +++ b/drivers/md/dm-table.c
38255 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38256 if (!dev_size)
38257 return 0;
38258
38259 - if ((start >= dev_size) || (start + len > dev_size)) {
38260 + if ((start >= dev_size) || (len > dev_size - start)) {
38261 DMWARN("%s: %s too small for target: "
38262 "start=%llu, len=%llu, dev_size=%llu",
38263 dm_device_name(ti->table->md), bdevname(bdev, b),
38264 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38265 index 00cee02..b89a29d 100644
38266 --- a/drivers/md/dm-thin-metadata.c
38267 +++ b/drivers/md/dm-thin-metadata.c
38268 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38269 {
38270 pmd->info.tm = pmd->tm;
38271 pmd->info.levels = 2;
38272 - pmd->info.value_type.context = pmd->data_sm;
38273 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38274 pmd->info.value_type.size = sizeof(__le64);
38275 pmd->info.value_type.inc = data_block_inc;
38276 pmd->info.value_type.dec = data_block_dec;
38277 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38278
38279 pmd->bl_info.tm = pmd->tm;
38280 pmd->bl_info.levels = 1;
38281 - pmd->bl_info.value_type.context = pmd->data_sm;
38282 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38283 pmd->bl_info.value_type.size = sizeof(__le64);
38284 pmd->bl_info.value_type.inc = data_block_inc;
38285 pmd->bl_info.value_type.dec = data_block_dec;
38286 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38287 index 9a0bdad..4df9543 100644
38288 --- a/drivers/md/dm.c
38289 +++ b/drivers/md/dm.c
38290 @@ -169,9 +169,9 @@ struct mapped_device {
38291 /*
38292 * Event handling.
38293 */
38294 - atomic_t event_nr;
38295 + atomic_unchecked_t event_nr;
38296 wait_queue_head_t eventq;
38297 - atomic_t uevent_seq;
38298 + atomic_unchecked_t uevent_seq;
38299 struct list_head uevent_list;
38300 spinlock_t uevent_lock; /* Protect access to uevent_list */
38301
38302 @@ -1879,8 +1879,8 @@ static struct mapped_device *alloc_dev(int minor)
38303 rwlock_init(&md->map_lock);
38304 atomic_set(&md->holders, 1);
38305 atomic_set(&md->open_count, 0);
38306 - atomic_set(&md->event_nr, 0);
38307 - atomic_set(&md->uevent_seq, 0);
38308 + atomic_set_unchecked(&md->event_nr, 0);
38309 + atomic_set_unchecked(&md->uevent_seq, 0);
38310 INIT_LIST_HEAD(&md->uevent_list);
38311 spin_lock_init(&md->uevent_lock);
38312
38313 @@ -2028,7 +2028,7 @@ static void event_callback(void *context)
38314
38315 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38316
38317 - atomic_inc(&md->event_nr);
38318 + atomic_inc_unchecked(&md->event_nr);
38319 wake_up(&md->eventq);
38320 }
38321
38322 @@ -2685,18 +2685,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38323
38324 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38325 {
38326 - return atomic_add_return(1, &md->uevent_seq);
38327 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38328 }
38329
38330 uint32_t dm_get_event_nr(struct mapped_device *md)
38331 {
38332 - return atomic_read(&md->event_nr);
38333 + return atomic_read_unchecked(&md->event_nr);
38334 }
38335
38336 int dm_wait_event(struct mapped_device *md, int event_nr)
38337 {
38338 return wait_event_interruptible(md->eventq,
38339 - (event_nr != atomic_read(&md->event_nr)));
38340 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38341 }
38342
38343 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38344 diff --git a/drivers/md/md.c b/drivers/md/md.c
38345 index a4a93b9..4747b63 100644
38346 --- a/drivers/md/md.c
38347 +++ b/drivers/md/md.c
38348 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38349 * start build, activate spare
38350 */
38351 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38352 -static atomic_t md_event_count;
38353 +static atomic_unchecked_t md_event_count;
38354 void md_new_event(struct mddev *mddev)
38355 {
38356 - atomic_inc(&md_event_count);
38357 + atomic_inc_unchecked(&md_event_count);
38358 wake_up(&md_event_waiters);
38359 }
38360 EXPORT_SYMBOL_GPL(md_new_event);
38361 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38362 */
38363 static void md_new_event_inintr(struct mddev *mddev)
38364 {
38365 - atomic_inc(&md_event_count);
38366 + atomic_inc_unchecked(&md_event_count);
38367 wake_up(&md_event_waiters);
38368 }
38369
38370 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38371 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38372 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38373 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38374 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38375 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38376
38377 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38378 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38379 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38380 else
38381 sb->resync_offset = cpu_to_le64(0);
38382
38383 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38384 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38385
38386 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38387 sb->size = cpu_to_le64(mddev->dev_sectors);
38388 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38389 static ssize_t
38390 errors_show(struct md_rdev *rdev, char *page)
38391 {
38392 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38393 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38394 }
38395
38396 static ssize_t
38397 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38398 char *e;
38399 unsigned long n = simple_strtoul(buf, &e, 10);
38400 if (*buf && (*e == 0 || *e == '\n')) {
38401 - atomic_set(&rdev->corrected_errors, n);
38402 + atomic_set_unchecked(&rdev->corrected_errors, n);
38403 return len;
38404 }
38405 return -EINVAL;
38406 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38407 rdev->sb_loaded = 0;
38408 rdev->bb_page = NULL;
38409 atomic_set(&rdev->nr_pending, 0);
38410 - atomic_set(&rdev->read_errors, 0);
38411 - atomic_set(&rdev->corrected_errors, 0);
38412 + atomic_set_unchecked(&rdev->read_errors, 0);
38413 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38414
38415 INIT_LIST_HEAD(&rdev->same_set);
38416 init_waitqueue_head(&rdev->blocked_wait);
38417 @@ -6994,7 +6994,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38418
38419 spin_unlock(&pers_lock);
38420 seq_printf(seq, "\n");
38421 - seq->poll_event = atomic_read(&md_event_count);
38422 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38423 return 0;
38424 }
38425 if (v == (void*)2) {
38426 @@ -7097,7 +7097,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38427 return error;
38428
38429 seq = file->private_data;
38430 - seq->poll_event = atomic_read(&md_event_count);
38431 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38432 return error;
38433 }
38434
38435 @@ -7111,7 +7111,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38436 /* always allow read */
38437 mask = POLLIN | POLLRDNORM;
38438
38439 - if (seq->poll_event != atomic_read(&md_event_count))
38440 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38441 mask |= POLLERR | POLLPRI;
38442 return mask;
38443 }
38444 @@ -7155,7 +7155,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38445 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38446 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38447 (int)part_stat_read(&disk->part0, sectors[1]) -
38448 - atomic_read(&disk->sync_io);
38449 + atomic_read_unchecked(&disk->sync_io);
38450 /* sync IO will cause sync_io to increase before the disk_stats
38451 * as sync_io is counted when a request starts, and
38452 * disk_stats is counted when it completes.
38453 diff --git a/drivers/md/md.h b/drivers/md/md.h
38454 index d90fb1a..4174a2b 100644
38455 --- a/drivers/md/md.h
38456 +++ b/drivers/md/md.h
38457 @@ -94,13 +94,13 @@ struct md_rdev {
38458 * only maintained for arrays that
38459 * support hot removal
38460 */
38461 - atomic_t read_errors; /* number of consecutive read errors that
38462 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38463 * we have tried to ignore.
38464 */
38465 struct timespec last_read_error; /* monotonic time since our
38466 * last read error
38467 */
38468 - atomic_t corrected_errors; /* number of corrected read errors,
38469 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38470 * for reporting to userspace and storing
38471 * in superblock.
38472 */
38473 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38474
38475 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38476 {
38477 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38478 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38479 }
38480
38481 struct md_personality
38482 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38483 index 1cbfc6b..56e1dbb 100644
38484 --- a/drivers/md/persistent-data/dm-space-map.h
38485 +++ b/drivers/md/persistent-data/dm-space-map.h
38486 @@ -60,6 +60,7 @@ struct dm_space_map {
38487 int (*root_size)(struct dm_space_map *sm, size_t *result);
38488 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38489 };
38490 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38491
38492 /*----------------------------------------------------------------*/
38493
38494 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38495 index 7116798..c81390c 100644
38496 --- a/drivers/md/raid1.c
38497 +++ b/drivers/md/raid1.c
38498 @@ -1836,7 +1836,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38499 if (r1_sync_page_io(rdev, sect, s,
38500 bio->bi_io_vec[idx].bv_page,
38501 READ) != 0)
38502 - atomic_add(s, &rdev->corrected_errors);
38503 + atomic_add_unchecked(s, &rdev->corrected_errors);
38504 }
38505 sectors -= s;
38506 sect += s;
38507 @@ -2058,7 +2058,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38508 test_bit(In_sync, &rdev->flags)) {
38509 if (r1_sync_page_io(rdev, sect, s,
38510 conf->tmppage, READ)) {
38511 - atomic_add(s, &rdev->corrected_errors);
38512 + atomic_add_unchecked(s, &rdev->corrected_errors);
38513 printk(KERN_INFO
38514 "md/raid1:%s: read error corrected "
38515 "(%d sectors at %llu on %s)\n",
38516 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38517 index e4ea992..d234520 100644
38518 --- a/drivers/md/raid10.c
38519 +++ b/drivers/md/raid10.c
38520 @@ -1942,7 +1942,7 @@ static void end_sync_read(struct bio *bio, int error)
38521 /* The write handler will notice the lack of
38522 * R10BIO_Uptodate and record any errors etc
38523 */
38524 - atomic_add(r10_bio->sectors,
38525 + atomic_add_unchecked(r10_bio->sectors,
38526 &conf->mirrors[d].rdev->corrected_errors);
38527
38528 /* for reconstruct, we always reschedule after a read.
38529 @@ -2291,7 +2291,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38530 {
38531 struct timespec cur_time_mon;
38532 unsigned long hours_since_last;
38533 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38534 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38535
38536 ktime_get_ts(&cur_time_mon);
38537
38538 @@ -2313,9 +2313,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38539 * overflowing the shift of read_errors by hours_since_last.
38540 */
38541 if (hours_since_last >= 8 * sizeof(read_errors))
38542 - atomic_set(&rdev->read_errors, 0);
38543 + atomic_set_unchecked(&rdev->read_errors, 0);
38544 else
38545 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38546 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38547 }
38548
38549 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38550 @@ -2369,8 +2369,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38551 return;
38552
38553 check_decay_read_errors(mddev, rdev);
38554 - atomic_inc(&rdev->read_errors);
38555 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38556 + atomic_inc_unchecked(&rdev->read_errors);
38557 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38558 char b[BDEVNAME_SIZE];
38559 bdevname(rdev->bdev, b);
38560
38561 @@ -2378,7 +2378,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38562 "md/raid10:%s: %s: Raid device exceeded "
38563 "read_error threshold [cur %d:max %d]\n",
38564 mdname(mddev), b,
38565 - atomic_read(&rdev->read_errors), max_read_errors);
38566 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38567 printk(KERN_NOTICE
38568 "md/raid10:%s: %s: Failing raid device\n",
38569 mdname(mddev), b);
38570 @@ -2533,7 +2533,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38571 sect +
38572 choose_data_offset(r10_bio, rdev)),
38573 bdevname(rdev->bdev, b));
38574 - atomic_add(s, &rdev->corrected_errors);
38575 + atomic_add_unchecked(s, &rdev->corrected_errors);
38576 }
38577
38578 rdev_dec_pending(rdev, mddev);
38579 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38580 index 251ab64..ed23a18 100644
38581 --- a/drivers/md/raid5.c
38582 +++ b/drivers/md/raid5.c
38583 @@ -1763,21 +1763,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38584 mdname(conf->mddev), STRIPE_SECTORS,
38585 (unsigned long long)s,
38586 bdevname(rdev->bdev, b));
38587 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38588 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38589 clear_bit(R5_ReadError, &sh->dev[i].flags);
38590 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38591 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38592 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38593
38594 - if (atomic_read(&rdev->read_errors))
38595 - atomic_set(&rdev->read_errors, 0);
38596 + if (atomic_read_unchecked(&rdev->read_errors))
38597 + atomic_set_unchecked(&rdev->read_errors, 0);
38598 } else {
38599 const char *bdn = bdevname(rdev->bdev, b);
38600 int retry = 0;
38601 int set_bad = 0;
38602
38603 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38604 - atomic_inc(&rdev->read_errors);
38605 + atomic_inc_unchecked(&rdev->read_errors);
38606 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38607 printk_ratelimited(
38608 KERN_WARNING
38609 @@ -1805,7 +1805,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38610 mdname(conf->mddev),
38611 (unsigned long long)s,
38612 bdn);
38613 - } else if (atomic_read(&rdev->read_errors)
38614 + } else if (atomic_read_unchecked(&rdev->read_errors)
38615 > conf->max_nr_stripes)
38616 printk(KERN_WARNING
38617 "md/raid:%s: Too many read errors, failing device %s.\n",
38618 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38619 index 401ef64..836e563 100644
38620 --- a/drivers/media/dvb-core/dvbdev.c
38621 +++ b/drivers/media/dvb-core/dvbdev.c
38622 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38623 const struct dvb_device *template, void *priv, int type)
38624 {
38625 struct dvb_device *dvbdev;
38626 - struct file_operations *dvbdevfops;
38627 + file_operations_no_const *dvbdevfops;
38628 struct device *clsdev;
38629 int minor;
38630 int id;
38631 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38632 index 9b6c3bb..baeb5c7 100644
38633 --- a/drivers/media/dvb-frontends/dib3000.h
38634 +++ b/drivers/media/dvb-frontends/dib3000.h
38635 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38636 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38637 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38638 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38639 -};
38640 +} __no_const;
38641
38642 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38643 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38644 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38645 index bc78354..42c9459 100644
38646 --- a/drivers/media/pci/cx88/cx88-video.c
38647 +++ b/drivers/media/pci/cx88/cx88-video.c
38648 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38649
38650 /* ------------------------------------------------------------------ */
38651
38652 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38653 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38654 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38655 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38656 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38657 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38658
38659 module_param_array(video_nr, int, NULL, 0444);
38660 module_param_array(vbi_nr, int, NULL, 0444);
38661 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38662 index 96c4a17..1305a79 100644
38663 --- a/drivers/media/platform/omap/omap_vout.c
38664 +++ b/drivers/media/platform/omap/omap_vout.c
38665 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38666 OMAP_VIDEO2,
38667 };
38668
38669 -static struct videobuf_queue_ops video_vbq_ops;
38670 /* Variables configurable through module params*/
38671 static u32 video1_numbuffers = 3;
38672 static u32 video2_numbuffers = 3;
38673 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38674 {
38675 struct videobuf_queue *q;
38676 struct omap_vout_device *vout = NULL;
38677 + static struct videobuf_queue_ops video_vbq_ops = {
38678 + .buf_setup = omap_vout_buffer_setup,
38679 + .buf_prepare = omap_vout_buffer_prepare,
38680 + .buf_release = omap_vout_buffer_release,
38681 + .buf_queue = omap_vout_buffer_queue,
38682 + };
38683
38684 vout = video_drvdata(file);
38685 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38686 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38687 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38688
38689 q = &vout->vbq;
38690 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38691 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38692 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38693 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38694 spin_lock_init(&vout->vbq_lock);
38695
38696 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38697 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38698 index 04e6490..2df65bf 100644
38699 --- a/drivers/media/platform/s5p-tv/mixer.h
38700 +++ b/drivers/media/platform/s5p-tv/mixer.h
38701 @@ -156,7 +156,7 @@ struct mxr_layer {
38702 /** layer index (unique identifier) */
38703 int idx;
38704 /** callbacks for layer methods */
38705 - struct mxr_layer_ops ops;
38706 + struct mxr_layer_ops *ops;
38707 /** format array */
38708 const struct mxr_format **fmt_array;
38709 /** size of format array */
38710 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38711 index b93a21f..2535195 100644
38712 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38713 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38714 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38715 {
38716 struct mxr_layer *layer;
38717 int ret;
38718 - struct mxr_layer_ops ops = {
38719 + static struct mxr_layer_ops ops = {
38720 .release = mxr_graph_layer_release,
38721 .buffer_set = mxr_graph_buffer_set,
38722 .stream_set = mxr_graph_stream_set,
38723 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38724 index b713403..53cb5ad 100644
38725 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38726 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38727 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38728 layer->update_buf = next;
38729 }
38730
38731 - layer->ops.buffer_set(layer, layer->update_buf);
38732 + layer->ops->buffer_set(layer, layer->update_buf);
38733
38734 if (done && done != layer->shadow_buf)
38735 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38736 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38737 index 82142a2..6de47e8 100644
38738 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38739 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38740 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38741 layer->geo.src.height = layer->geo.src.full_height;
38742
38743 mxr_geometry_dump(mdev, &layer->geo);
38744 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38745 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38746 mxr_geometry_dump(mdev, &layer->geo);
38747 }
38748
38749 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38750 layer->geo.dst.full_width = mbus_fmt.width;
38751 layer->geo.dst.full_height = mbus_fmt.height;
38752 layer->geo.dst.field = mbus_fmt.field;
38753 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38754 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38755
38756 mxr_geometry_dump(mdev, &layer->geo);
38757 }
38758 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38759 /* set source size to highest accepted value */
38760 geo->src.full_width = max(geo->dst.full_width, pix->width);
38761 geo->src.full_height = max(geo->dst.full_height, pix->height);
38762 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38763 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38764 mxr_geometry_dump(mdev, &layer->geo);
38765 /* set cropping to total visible screen */
38766 geo->src.width = pix->width;
38767 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38768 geo->src.x_offset = 0;
38769 geo->src.y_offset = 0;
38770 /* assure consistency of geometry */
38771 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38772 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38773 mxr_geometry_dump(mdev, &layer->geo);
38774 /* set full size to lowest possible value */
38775 geo->src.full_width = 0;
38776 geo->src.full_height = 0;
38777 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38778 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38779 mxr_geometry_dump(mdev, &layer->geo);
38780
38781 /* returning results */
38782 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38783 target->width = s->r.width;
38784 target->height = s->r.height;
38785
38786 - layer->ops.fix_geometry(layer, stage, s->flags);
38787 + layer->ops->fix_geometry(layer, stage, s->flags);
38788
38789 /* retrieve update selection rectangle */
38790 res.left = target->x_offset;
38791 @@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38792 mxr_output_get(mdev);
38793
38794 mxr_layer_update_output(layer);
38795 - layer->ops.format_set(layer);
38796 + layer->ops->format_set(layer);
38797 /* enabling layer in hardware */
38798 spin_lock_irqsave(&layer->enq_slock, flags);
38799 layer->state = MXR_LAYER_STREAMING;
38800 spin_unlock_irqrestore(&layer->enq_slock, flags);
38801
38802 - layer->ops.stream_set(layer, MXR_ENABLE);
38803 + layer->ops->stream_set(layer, MXR_ENABLE);
38804 mxr_streamer_get(mdev);
38805
38806 return 0;
38807 @@ -1014,7 +1014,7 @@ static int stop_streaming(struct vb2_queue *vq)
38808 spin_unlock_irqrestore(&layer->enq_slock, flags);
38809
38810 /* disabling layer in hardware */
38811 - layer->ops.stream_set(layer, MXR_DISABLE);
38812 + layer->ops->stream_set(layer, MXR_DISABLE);
38813 /* remove one streamer */
38814 mxr_streamer_put(mdev);
38815 /* allow changes in output configuration */
38816 @@ -1053,8 +1053,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38817
38818 void mxr_layer_release(struct mxr_layer *layer)
38819 {
38820 - if (layer->ops.release)
38821 - layer->ops.release(layer);
38822 + if (layer->ops->release)
38823 + layer->ops->release(layer);
38824 }
38825
38826 void mxr_base_layer_release(struct mxr_layer *layer)
38827 @@ -1080,7 +1080,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38828
38829 layer->mdev = mdev;
38830 layer->idx = idx;
38831 - layer->ops = *ops;
38832 + layer->ops = ops;
38833
38834 spin_lock_init(&layer->enq_slock);
38835 INIT_LIST_HEAD(&layer->enq_list);
38836 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38837 index 3d13a63..da31bf1 100644
38838 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38839 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38840 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38841 {
38842 struct mxr_layer *layer;
38843 int ret;
38844 - struct mxr_layer_ops ops = {
38845 + static struct mxr_layer_ops ops = {
38846 .release = mxr_vp_layer_release,
38847 .buffer_set = mxr_vp_buffer_set,
38848 .stream_set = mxr_vp_stream_set,
38849 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38850 index 643d80a..56bb96b 100644
38851 --- a/drivers/media/radio/radio-cadet.c
38852 +++ b/drivers/media/radio/radio-cadet.c
38853 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38854 unsigned char readbuf[RDS_BUFFER];
38855 int i = 0;
38856
38857 + if (count > RDS_BUFFER)
38858 + return -EFAULT;
38859 mutex_lock(&dev->lock);
38860 if (dev->rdsstat == 0)
38861 cadet_start_rds(dev);
38862 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38863 while (i < count && dev->rdsin != dev->rdsout)
38864 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38865
38866 - if (i && copy_to_user(data, readbuf, i))
38867 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38868 i = -EFAULT;
38869 unlock:
38870 mutex_unlock(&dev->lock);
38871 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38872 index 3940bb0..fb3952a 100644
38873 --- a/drivers/media/usb/dvb-usb/cxusb.c
38874 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38875 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38876
38877 struct dib0700_adapter_state {
38878 int (*set_param_save) (struct dvb_frontend *);
38879 -};
38880 +} __no_const;
38881
38882 static int dib7070_set_param_override(struct dvb_frontend *fe)
38883 {
38884 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38885 index 9578a67..31aa652 100644
38886 --- a/drivers/media/usb/dvb-usb/dw2102.c
38887 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38888 @@ -115,7 +115,7 @@ struct su3000_state {
38889
38890 struct s6x0_state {
38891 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38892 -};
38893 +} __no_const;
38894
38895 /* debug */
38896 static int dvb_usb_dw2102_debug;
38897 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38898 index 7157af3..139e91a 100644
38899 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38900 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38901 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
38902 __u32 reserved;
38903 };
38904
38905 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38906 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38907 enum v4l2_memory memory)
38908 {
38909 void __user *up_pln;
38910 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38911 return 0;
38912 }
38913
38914 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38915 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38916 enum v4l2_memory memory)
38917 {
38918 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
38919 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
38920 put_user(kp->start_block, &up->start_block) ||
38921 put_user(kp->blocks, &up->blocks) ||
38922 put_user(tmp, &up->edid) ||
38923 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
38924 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
38925 return -EFAULT;
38926 return 0;
38927 }
38928 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38929 index aa6e7c7..cb5de87 100644
38930 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38931 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38932 @@ -236,7 +236,7 @@ static void v4l_print_format(const void *arg, bool write_only)
38933 const struct v4l2_vbi_format *vbi;
38934 const struct v4l2_sliced_vbi_format *sliced;
38935 const struct v4l2_window *win;
38936 - const struct v4l2_clip *clip;
38937 + const struct v4l2_clip __user *pclip;
38938 unsigned i;
38939
38940 pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
38941 @@ -284,12 +284,16 @@ static void v4l_print_format(const void *arg, bool write_only)
38942 win->w.left, win->w.top,
38943 prt_names(win->field, v4l2_field_names),
38944 win->chromakey, win->bitmap, win->global_alpha);
38945 - clip = win->clips;
38946 + pclip = win->clips;
38947 for (i = 0; i < win->clipcount; i++) {
38948 + struct v4l2_clip clip;
38949 +
38950 + if (copy_from_user(&clip, pclip, sizeof clip))
38951 + break;
38952 printk(KERN_DEBUG "clip %u: wxh=%dx%d, x,y=%d,%d\n",
38953 - i, clip->c.width, clip->c.height,
38954 - clip->c.left, clip->c.top);
38955 - clip = clip->next;
38956 + i, clip.c.width, clip.c.height,
38957 + clip.c.left, clip.c.top);
38958 + pclip = clip.next;
38959 }
38960 break;
38961 case V4L2_BUF_TYPE_VBI_CAPTURE:
38962 @@ -1923,7 +1927,8 @@ struct v4l2_ioctl_info {
38963 struct file *file, void *fh, void *p);
38964 } u;
38965 void (*debug)(const void *arg, bool write_only);
38966 -};
38967 +} __do_const;
38968 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38969
38970 /* This control needs a priority check */
38971 #define INFO_FL_PRIO (1 << 0)
38972 @@ -2108,7 +2113,7 @@ static long __video_do_ioctl(struct file *file,
38973 struct video_device *vfd = video_devdata(file);
38974 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38975 bool write_only = false;
38976 - struct v4l2_ioctl_info default_info;
38977 + v4l2_ioctl_info_no_const default_info;
38978 const struct v4l2_ioctl_info *info;
38979 void *fh = file->private_data;
38980 struct v4l2_fh *vfh = NULL;
38981 @@ -2193,7 +2198,7 @@ done:
38982 }
38983
38984 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38985 - void * __user *user_ptr, void ***kernel_ptr)
38986 + void __user **user_ptr, void ***kernel_ptr)
38987 {
38988 int ret = 0;
38989
38990 @@ -2209,7 +2214,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38991 ret = -EINVAL;
38992 break;
38993 }
38994 - *user_ptr = (void __user *)buf->m.planes;
38995 + *user_ptr = (void __force_user *)buf->m.planes;
38996 *kernel_ptr = (void *)&buf->m.planes;
38997 *array_size = sizeof(struct v4l2_plane) * buf->length;
38998 ret = 1;
38999 @@ -2244,7 +2249,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39000 ret = -EINVAL;
39001 break;
39002 }
39003 - *user_ptr = (void __user *)ctrls->controls;
39004 + *user_ptr = (void __force_user *)ctrls->controls;
39005 *kernel_ptr = (void *)&ctrls->controls;
39006 *array_size = sizeof(struct v4l2_ext_control)
39007 * ctrls->count;
39008 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
39009 index fb69baa..3aeea2e 100644
39010 --- a/drivers/message/fusion/mptbase.c
39011 +++ b/drivers/message/fusion/mptbase.c
39012 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39013 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
39014 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
39015
39016 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39017 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
39018 +#else
39019 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
39020 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
39021 +#endif
39022 +
39023 /*
39024 * Rounding UP to nearest 4-kB boundary here...
39025 */
39026 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39027 ioc->facts.GlobalCredits);
39028
39029 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
39030 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39031 + NULL, NULL);
39032 +#else
39033 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
39034 +#endif
39035 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
39036 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
39037 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
39038 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
39039 index fa43c39..daeb158 100644
39040 --- a/drivers/message/fusion/mptsas.c
39041 +++ b/drivers/message/fusion/mptsas.c
39042 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
39043 return 0;
39044 }
39045
39046 +static inline void
39047 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39048 +{
39049 + if (phy_info->port_details) {
39050 + phy_info->port_details->rphy = rphy;
39051 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39052 + ioc->name, rphy));
39053 + }
39054 +
39055 + if (rphy) {
39056 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39057 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39058 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39059 + ioc->name, rphy, rphy->dev.release));
39060 + }
39061 +}
39062 +
39063 /* no mutex */
39064 static void
39065 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
39066 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
39067 return NULL;
39068 }
39069
39070 -static inline void
39071 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39072 -{
39073 - if (phy_info->port_details) {
39074 - phy_info->port_details->rphy = rphy;
39075 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39076 - ioc->name, rphy));
39077 - }
39078 -
39079 - if (rphy) {
39080 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39081 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39082 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39083 - ioc->name, rphy, rphy->dev.release));
39084 - }
39085 -}
39086 -
39087 static inline struct sas_port *
39088 mptsas_get_port(struct mptsas_phyinfo *phy_info)
39089 {
39090 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
39091 index 164afa7..b6b2e74 100644
39092 --- a/drivers/message/fusion/mptscsih.c
39093 +++ b/drivers/message/fusion/mptscsih.c
39094 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
39095
39096 h = shost_priv(SChost);
39097
39098 - if (h) {
39099 - if (h->info_kbuf == NULL)
39100 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39101 - return h->info_kbuf;
39102 - h->info_kbuf[0] = '\0';
39103 + if (!h)
39104 + return NULL;
39105
39106 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39107 - h->info_kbuf[size-1] = '\0';
39108 - }
39109 + if (h->info_kbuf == NULL)
39110 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39111 + return h->info_kbuf;
39112 + h->info_kbuf[0] = '\0';
39113 +
39114 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39115 + h->info_kbuf[size-1] = '\0';
39116
39117 return h->info_kbuf;
39118 }
39119 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39120 index 8001aa6..b137580 100644
39121 --- a/drivers/message/i2o/i2o_proc.c
39122 +++ b/drivers/message/i2o/i2o_proc.c
39123 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39124 "Array Controller Device"
39125 };
39126
39127 -static char *chtostr(char *tmp, u8 *chars, int n)
39128 -{
39129 - tmp[0] = 0;
39130 - return strncat(tmp, (char *)chars, n);
39131 -}
39132 -
39133 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39134 char *group)
39135 {
39136 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39137 } *result;
39138
39139 i2o_exec_execute_ddm_table ddm_table;
39140 - char tmp[28 + 1];
39141
39142 result = kmalloc(sizeof(*result), GFP_KERNEL);
39143 if (!result)
39144 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39145
39146 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39147 seq_printf(seq, "%-#8x", ddm_table.module_id);
39148 - seq_printf(seq, "%-29s",
39149 - chtostr(tmp, ddm_table.module_name_version, 28));
39150 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39151 seq_printf(seq, "%9d ", ddm_table.data_size);
39152 seq_printf(seq, "%8d", ddm_table.code_size);
39153
39154 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39155
39156 i2o_driver_result_table *result;
39157 i2o_driver_store_table *dst;
39158 - char tmp[28 + 1];
39159
39160 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39161 if (result == NULL)
39162 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39163
39164 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39165 seq_printf(seq, "%-#8x", dst->module_id);
39166 - seq_printf(seq, "%-29s",
39167 - chtostr(tmp, dst->module_name_version, 28));
39168 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39169 + seq_printf(seq, "%-.28s", dst->module_name_version);
39170 + seq_printf(seq, "%-.8s", dst->date);
39171 seq_printf(seq, "%8d ", dst->module_size);
39172 seq_printf(seq, "%8d ", dst->mpb_size);
39173 seq_printf(seq, "0x%04x", dst->module_flags);
39174 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39175 // == (allow) 512d bytes (max)
39176 static u16 *work16 = (u16 *) work32;
39177 int token;
39178 - char tmp[16 + 1];
39179
39180 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39181
39182 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39183 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39184 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39185 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39186 - seq_printf(seq, "Vendor info : %s\n",
39187 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39188 - seq_printf(seq, "Product info : %s\n",
39189 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39190 - seq_printf(seq, "Description : %s\n",
39191 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39192 - seq_printf(seq, "Product rev. : %s\n",
39193 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39194 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39195 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39196 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39197 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39198
39199 seq_printf(seq, "Serial number : ");
39200 print_serial_number(seq, (u8 *) (work32 + 16),
39201 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39202 u8 pad[256]; // allow up to 256 byte (max) serial number
39203 } result;
39204
39205 - char tmp[24 + 1];
39206 -
39207 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39208
39209 if (token < 0) {
39210 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39211 }
39212
39213 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39214 - seq_printf(seq, "Module name : %s\n",
39215 - chtostr(tmp, result.module_name, 24));
39216 - seq_printf(seq, "Module revision : %s\n",
39217 - chtostr(tmp, result.module_rev, 8));
39218 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39219 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39220
39221 seq_printf(seq, "Serial number : ");
39222 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39223 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39224 u8 instance_number[4];
39225 } result;
39226
39227 - char tmp[64 + 1];
39228 -
39229 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39230
39231 if (token < 0) {
39232 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39233 return 0;
39234 }
39235
39236 - seq_printf(seq, "Device name : %s\n",
39237 - chtostr(tmp, result.device_name, 64));
39238 - seq_printf(seq, "Service name : %s\n",
39239 - chtostr(tmp, result.service_name, 64));
39240 - seq_printf(seq, "Physical name : %s\n",
39241 - chtostr(tmp, result.physical_location, 64));
39242 - seq_printf(seq, "Instance number : %s\n",
39243 - chtostr(tmp, result.instance_number, 4));
39244 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39245 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39246 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39247 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39248
39249 return 0;
39250 }
39251 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39252 index a8c08f3..155fe3d 100644
39253 --- a/drivers/message/i2o/iop.c
39254 +++ b/drivers/message/i2o/iop.c
39255 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39256
39257 spin_lock_irqsave(&c->context_list_lock, flags);
39258
39259 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39260 - atomic_inc(&c->context_list_counter);
39261 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39262 + atomic_inc_unchecked(&c->context_list_counter);
39263
39264 - entry->context = atomic_read(&c->context_list_counter);
39265 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39266
39267 list_add(&entry->list, &c->context_list);
39268
39269 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39270
39271 #if BITS_PER_LONG == 64
39272 spin_lock_init(&c->context_list_lock);
39273 - atomic_set(&c->context_list_counter, 0);
39274 + atomic_set_unchecked(&c->context_list_counter, 0);
39275 INIT_LIST_HEAD(&c->context_list);
39276 #endif
39277
39278 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39279 index 45ece11..8efa218 100644
39280 --- a/drivers/mfd/janz-cmodio.c
39281 +++ b/drivers/mfd/janz-cmodio.c
39282 @@ -13,6 +13,7 @@
39283
39284 #include <linux/kernel.h>
39285 #include <linux/module.h>
39286 +#include <linux/slab.h>
39287 #include <linux/init.h>
39288 #include <linux/pci.h>
39289 #include <linux/interrupt.h>
39290 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39291 index a5f9888..1c0ed56 100644
39292 --- a/drivers/mfd/twl4030-irq.c
39293 +++ b/drivers/mfd/twl4030-irq.c
39294 @@ -35,6 +35,7 @@
39295 #include <linux/of.h>
39296 #include <linux/irqdomain.h>
39297 #include <linux/i2c/twl.h>
39298 +#include <asm/pgtable.h>
39299
39300 #include "twl-core.h"
39301
39302 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39303 * Install an irq handler for each of the SIH modules;
39304 * clone dummy irq_chip since PIH can't *do* anything
39305 */
39306 - twl4030_irq_chip = dummy_irq_chip;
39307 - twl4030_irq_chip.name = "twl4030";
39308 + pax_open_kernel();
39309 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39310 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39311
39312 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39313 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39314 + pax_close_kernel();
39315
39316 for (i = irq_base; i < irq_end; i++) {
39317 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39318 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39319 index 277a8db..0e0b754 100644
39320 --- a/drivers/mfd/twl6030-irq.c
39321 +++ b/drivers/mfd/twl6030-irq.c
39322 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39323 * install an irq handler for each of the modules;
39324 * clone dummy irq_chip since PIH can't *do* anything
39325 */
39326 - twl6030_irq_chip = dummy_irq_chip;
39327 - twl6030_irq_chip.name = "twl6030";
39328 - twl6030_irq_chip.irq_set_type = NULL;
39329 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39330 + pax_open_kernel();
39331 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39332 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39333 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39334 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39335 + pax_close_kernel();
39336
39337 for (i = irq_base; i < irq_end; i++) {
39338 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39339 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39340 index f32550a..e3e52a2 100644
39341 --- a/drivers/misc/c2port/core.c
39342 +++ b/drivers/misc/c2port/core.c
39343 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39344 mutex_init(&c2dev->mutex);
39345
39346 /* Create binary file */
39347 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39348 + pax_open_kernel();
39349 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39350 + pax_close_kernel();
39351 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39352 if (unlikely(ret))
39353 goto error_device_create_bin_file;
39354 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39355 index 36f5d52..32311c3 100644
39356 --- a/drivers/misc/kgdbts.c
39357 +++ b/drivers/misc/kgdbts.c
39358 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39359 char before[BREAK_INSTR_SIZE];
39360 char after[BREAK_INSTR_SIZE];
39361
39362 - probe_kernel_read(before, (char *)kgdbts_break_test,
39363 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39364 BREAK_INSTR_SIZE);
39365 init_simple_test();
39366 ts.tst = plant_and_detach_test;
39367 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39368 /* Activate test with initial breakpoint */
39369 if (!is_early)
39370 kgdb_breakpoint();
39371 - probe_kernel_read(after, (char *)kgdbts_break_test,
39372 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39373 BREAK_INSTR_SIZE);
39374 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39375 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39376 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39377 index 4a87e5c..76bdf5c 100644
39378 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39379 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39380 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39381 * the lid is closed. This leads to interrupts as soon as a little move
39382 * is done.
39383 */
39384 - atomic_inc(&lis3->count);
39385 + atomic_inc_unchecked(&lis3->count);
39386
39387 wake_up_interruptible(&lis3->misc_wait);
39388 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39389 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39390 if (lis3->pm_dev)
39391 pm_runtime_get_sync(lis3->pm_dev);
39392
39393 - atomic_set(&lis3->count, 0);
39394 + atomic_set_unchecked(&lis3->count, 0);
39395 return 0;
39396 }
39397
39398 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39399 add_wait_queue(&lis3->misc_wait, &wait);
39400 while (true) {
39401 set_current_state(TASK_INTERRUPTIBLE);
39402 - data = atomic_xchg(&lis3->count, 0);
39403 + data = atomic_xchg_unchecked(&lis3->count, 0);
39404 if (data)
39405 break;
39406
39407 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39408 struct lis3lv02d, miscdev);
39409
39410 poll_wait(file, &lis3->misc_wait, wait);
39411 - if (atomic_read(&lis3->count))
39412 + if (atomic_read_unchecked(&lis3->count))
39413 return POLLIN | POLLRDNORM;
39414 return 0;
39415 }
39416 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39417 index c439c82..1f20f57 100644
39418 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39419 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39420 @@ -297,7 +297,7 @@ struct lis3lv02d {
39421 struct input_polled_dev *idev; /* input device */
39422 struct platform_device *pdev; /* platform device */
39423 struct regulator_bulk_data regulators[2];
39424 - atomic_t count; /* interrupt count after last read */
39425 + atomic_unchecked_t count; /* interrupt count after last read */
39426 union axis_conversion ac; /* hw -> logical axis */
39427 int mapped_btns[3];
39428
39429 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39430 index 2f30bad..c4c13d0 100644
39431 --- a/drivers/misc/sgi-gru/gruhandles.c
39432 +++ b/drivers/misc/sgi-gru/gruhandles.c
39433 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39434 unsigned long nsec;
39435
39436 nsec = CLKS2NSEC(clks);
39437 - atomic_long_inc(&mcs_op_statistics[op].count);
39438 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39439 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39440 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39441 if (mcs_op_statistics[op].max < nsec)
39442 mcs_op_statistics[op].max = nsec;
39443 }
39444 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39445 index 950dbe9..eeef0f8 100644
39446 --- a/drivers/misc/sgi-gru/gruprocfs.c
39447 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39448 @@ -32,9 +32,9 @@
39449
39450 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39451
39452 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39453 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39454 {
39455 - unsigned long val = atomic_long_read(v);
39456 + unsigned long val = atomic_long_read_unchecked(v);
39457
39458 seq_printf(s, "%16lu %s\n", val, id);
39459 }
39460 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39461
39462 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39463 for (op = 0; op < mcsop_last; op++) {
39464 - count = atomic_long_read(&mcs_op_statistics[op].count);
39465 - total = atomic_long_read(&mcs_op_statistics[op].total);
39466 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39467 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39468 max = mcs_op_statistics[op].max;
39469 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39470 count ? total / count : 0, max);
39471 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39472 index 5c3ce24..4915ccb 100644
39473 --- a/drivers/misc/sgi-gru/grutables.h
39474 +++ b/drivers/misc/sgi-gru/grutables.h
39475 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39476 * GRU statistics.
39477 */
39478 struct gru_stats_s {
39479 - atomic_long_t vdata_alloc;
39480 - atomic_long_t vdata_free;
39481 - atomic_long_t gts_alloc;
39482 - atomic_long_t gts_free;
39483 - atomic_long_t gms_alloc;
39484 - atomic_long_t gms_free;
39485 - atomic_long_t gts_double_allocate;
39486 - atomic_long_t assign_context;
39487 - atomic_long_t assign_context_failed;
39488 - atomic_long_t free_context;
39489 - atomic_long_t load_user_context;
39490 - atomic_long_t load_kernel_context;
39491 - atomic_long_t lock_kernel_context;
39492 - atomic_long_t unlock_kernel_context;
39493 - atomic_long_t steal_user_context;
39494 - atomic_long_t steal_kernel_context;
39495 - atomic_long_t steal_context_failed;
39496 - atomic_long_t nopfn;
39497 - atomic_long_t asid_new;
39498 - atomic_long_t asid_next;
39499 - atomic_long_t asid_wrap;
39500 - atomic_long_t asid_reuse;
39501 - atomic_long_t intr;
39502 - atomic_long_t intr_cbr;
39503 - atomic_long_t intr_tfh;
39504 - atomic_long_t intr_spurious;
39505 - atomic_long_t intr_mm_lock_failed;
39506 - atomic_long_t call_os;
39507 - atomic_long_t call_os_wait_queue;
39508 - atomic_long_t user_flush_tlb;
39509 - atomic_long_t user_unload_context;
39510 - atomic_long_t user_exception;
39511 - atomic_long_t set_context_option;
39512 - atomic_long_t check_context_retarget_intr;
39513 - atomic_long_t check_context_unload;
39514 - atomic_long_t tlb_dropin;
39515 - atomic_long_t tlb_preload_page;
39516 - atomic_long_t tlb_dropin_fail_no_asid;
39517 - atomic_long_t tlb_dropin_fail_upm;
39518 - atomic_long_t tlb_dropin_fail_invalid;
39519 - atomic_long_t tlb_dropin_fail_range_active;
39520 - atomic_long_t tlb_dropin_fail_idle;
39521 - atomic_long_t tlb_dropin_fail_fmm;
39522 - atomic_long_t tlb_dropin_fail_no_exception;
39523 - atomic_long_t tfh_stale_on_fault;
39524 - atomic_long_t mmu_invalidate_range;
39525 - atomic_long_t mmu_invalidate_page;
39526 - atomic_long_t flush_tlb;
39527 - atomic_long_t flush_tlb_gru;
39528 - atomic_long_t flush_tlb_gru_tgh;
39529 - atomic_long_t flush_tlb_gru_zero_asid;
39530 + atomic_long_unchecked_t vdata_alloc;
39531 + atomic_long_unchecked_t vdata_free;
39532 + atomic_long_unchecked_t gts_alloc;
39533 + atomic_long_unchecked_t gts_free;
39534 + atomic_long_unchecked_t gms_alloc;
39535 + atomic_long_unchecked_t gms_free;
39536 + atomic_long_unchecked_t gts_double_allocate;
39537 + atomic_long_unchecked_t assign_context;
39538 + atomic_long_unchecked_t assign_context_failed;
39539 + atomic_long_unchecked_t free_context;
39540 + atomic_long_unchecked_t load_user_context;
39541 + atomic_long_unchecked_t load_kernel_context;
39542 + atomic_long_unchecked_t lock_kernel_context;
39543 + atomic_long_unchecked_t unlock_kernel_context;
39544 + atomic_long_unchecked_t steal_user_context;
39545 + atomic_long_unchecked_t steal_kernel_context;
39546 + atomic_long_unchecked_t steal_context_failed;
39547 + atomic_long_unchecked_t nopfn;
39548 + atomic_long_unchecked_t asid_new;
39549 + atomic_long_unchecked_t asid_next;
39550 + atomic_long_unchecked_t asid_wrap;
39551 + atomic_long_unchecked_t asid_reuse;
39552 + atomic_long_unchecked_t intr;
39553 + atomic_long_unchecked_t intr_cbr;
39554 + atomic_long_unchecked_t intr_tfh;
39555 + atomic_long_unchecked_t intr_spurious;
39556 + atomic_long_unchecked_t intr_mm_lock_failed;
39557 + atomic_long_unchecked_t call_os;
39558 + atomic_long_unchecked_t call_os_wait_queue;
39559 + atomic_long_unchecked_t user_flush_tlb;
39560 + atomic_long_unchecked_t user_unload_context;
39561 + atomic_long_unchecked_t user_exception;
39562 + atomic_long_unchecked_t set_context_option;
39563 + atomic_long_unchecked_t check_context_retarget_intr;
39564 + atomic_long_unchecked_t check_context_unload;
39565 + atomic_long_unchecked_t tlb_dropin;
39566 + atomic_long_unchecked_t tlb_preload_page;
39567 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39568 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39569 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39570 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39571 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39572 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39573 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39574 + atomic_long_unchecked_t tfh_stale_on_fault;
39575 + atomic_long_unchecked_t mmu_invalidate_range;
39576 + atomic_long_unchecked_t mmu_invalidate_page;
39577 + atomic_long_unchecked_t flush_tlb;
39578 + atomic_long_unchecked_t flush_tlb_gru;
39579 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39580 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39581
39582 - atomic_long_t copy_gpa;
39583 - atomic_long_t read_gpa;
39584 + atomic_long_unchecked_t copy_gpa;
39585 + atomic_long_unchecked_t read_gpa;
39586
39587 - atomic_long_t mesq_receive;
39588 - atomic_long_t mesq_receive_none;
39589 - atomic_long_t mesq_send;
39590 - atomic_long_t mesq_send_failed;
39591 - atomic_long_t mesq_noop;
39592 - atomic_long_t mesq_send_unexpected_error;
39593 - atomic_long_t mesq_send_lb_overflow;
39594 - atomic_long_t mesq_send_qlimit_reached;
39595 - atomic_long_t mesq_send_amo_nacked;
39596 - atomic_long_t mesq_send_put_nacked;
39597 - atomic_long_t mesq_page_overflow;
39598 - atomic_long_t mesq_qf_locked;
39599 - atomic_long_t mesq_qf_noop_not_full;
39600 - atomic_long_t mesq_qf_switch_head_failed;
39601 - atomic_long_t mesq_qf_unexpected_error;
39602 - atomic_long_t mesq_noop_unexpected_error;
39603 - atomic_long_t mesq_noop_lb_overflow;
39604 - atomic_long_t mesq_noop_qlimit_reached;
39605 - atomic_long_t mesq_noop_amo_nacked;
39606 - atomic_long_t mesq_noop_put_nacked;
39607 - atomic_long_t mesq_noop_page_overflow;
39608 + atomic_long_unchecked_t mesq_receive;
39609 + atomic_long_unchecked_t mesq_receive_none;
39610 + atomic_long_unchecked_t mesq_send;
39611 + atomic_long_unchecked_t mesq_send_failed;
39612 + atomic_long_unchecked_t mesq_noop;
39613 + atomic_long_unchecked_t mesq_send_unexpected_error;
39614 + atomic_long_unchecked_t mesq_send_lb_overflow;
39615 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39616 + atomic_long_unchecked_t mesq_send_amo_nacked;
39617 + atomic_long_unchecked_t mesq_send_put_nacked;
39618 + atomic_long_unchecked_t mesq_page_overflow;
39619 + atomic_long_unchecked_t mesq_qf_locked;
39620 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39621 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39622 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39623 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39624 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39625 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39626 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39627 + atomic_long_unchecked_t mesq_noop_put_nacked;
39628 + atomic_long_unchecked_t mesq_noop_page_overflow;
39629
39630 };
39631
39632 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39633 tghop_invalidate, mcsop_last};
39634
39635 struct mcs_op_statistic {
39636 - atomic_long_t count;
39637 - atomic_long_t total;
39638 + atomic_long_unchecked_t count;
39639 + atomic_long_unchecked_t total;
39640 unsigned long max;
39641 };
39642
39643 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39644
39645 #define STAT(id) do { \
39646 if (gru_options & OPT_STATS) \
39647 - atomic_long_inc(&gru_stats.id); \
39648 + atomic_long_inc_unchecked(&gru_stats.id); \
39649 } while (0)
39650
39651 #ifdef CONFIG_SGI_GRU_DEBUG
39652 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39653 index c862cd4..0d176fe 100644
39654 --- a/drivers/misc/sgi-xp/xp.h
39655 +++ b/drivers/misc/sgi-xp/xp.h
39656 @@ -288,7 +288,7 @@ struct xpc_interface {
39657 xpc_notify_func, void *);
39658 void (*received) (short, int, void *);
39659 enum xp_retval (*partid_to_nasids) (short, void *);
39660 -};
39661 +} __no_const;
39662
39663 extern struct xpc_interface xpc_interface;
39664
39665 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39666 index b94d5f7..7f494c5 100644
39667 --- a/drivers/misc/sgi-xp/xpc.h
39668 +++ b/drivers/misc/sgi-xp/xpc.h
39669 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39670 void (*received_payload) (struct xpc_channel *, void *);
39671 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39672 };
39673 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39674
39675 /* struct xpc_partition act_state values (for XPC HB) */
39676
39677 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39678 /* found in xpc_main.c */
39679 extern struct device *xpc_part;
39680 extern struct device *xpc_chan;
39681 -extern struct xpc_arch_operations xpc_arch_ops;
39682 +extern xpc_arch_operations_no_const xpc_arch_ops;
39683 extern int xpc_disengage_timelimit;
39684 extern int xpc_disengage_timedout;
39685 extern int xpc_activate_IRQ_rcvd;
39686 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39687 index d971817..33bdca5 100644
39688 --- a/drivers/misc/sgi-xp/xpc_main.c
39689 +++ b/drivers/misc/sgi-xp/xpc_main.c
39690 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39691 .notifier_call = xpc_system_die,
39692 };
39693
39694 -struct xpc_arch_operations xpc_arch_ops;
39695 +xpc_arch_operations_no_const xpc_arch_ops;
39696
39697 /*
39698 * Timer function to enforce the timelimit on the partition disengage.
39699 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39700
39701 if (((die_args->trapnr == X86_TRAP_MF) ||
39702 (die_args->trapnr == X86_TRAP_XF)) &&
39703 - !user_mode_vm(die_args->regs))
39704 + !user_mode(die_args->regs))
39705 xpc_die_deactivate();
39706
39707 break;
39708 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39709 index 49f04bc..65660c2 100644
39710 --- a/drivers/mmc/core/mmc_ops.c
39711 +++ b/drivers/mmc/core/mmc_ops.c
39712 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39713 void *data_buf;
39714 int is_on_stack;
39715
39716 - is_on_stack = object_is_on_stack(buf);
39717 + is_on_stack = object_starts_on_stack(buf);
39718 if (is_on_stack) {
39719 /*
39720 * dma onto stack is unsafe/nonportable, but callers to this
39721 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39722 index 53b8fd9..615b462 100644
39723 --- a/drivers/mmc/host/dw_mmc.h
39724 +++ b/drivers/mmc/host/dw_mmc.h
39725 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39726 int (*parse_dt)(struct dw_mci *host);
39727 int (*setup_bus)(struct dw_mci *host,
39728 struct device_node *slot_np, u8 bus_width);
39729 -};
39730 +} __do_const;
39731 #endif /* _DW_MMC_H_ */
39732 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39733 index 7363efe..681558e 100644
39734 --- a/drivers/mmc/host/sdhci-s3c.c
39735 +++ b/drivers/mmc/host/sdhci-s3c.c
39736 @@ -720,9 +720,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39737 * we can use overriding functions instead of default.
39738 */
39739 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39740 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39741 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39742 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39743 + pax_open_kernel();
39744 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39745 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39746 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39747 + pax_close_kernel();
39748 }
39749
39750 /* It supports additional host capabilities if needed */
39751 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39752 index a4eb8b5..8c0628f 100644
39753 --- a/drivers/mtd/devices/doc2000.c
39754 +++ b/drivers/mtd/devices/doc2000.c
39755 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39756
39757 /* The ECC will not be calculated correctly if less than 512 is written */
39758 /* DBB-
39759 - if (len != 0x200 && eccbuf)
39760 + if (len != 0x200)
39761 printk(KERN_WARNING
39762 "ECC needs a full sector write (adr: %lx size %lx)\n",
39763 (long) to, (long) len);
39764 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39765 index 0c8bb6b..6f35deb 100644
39766 --- a/drivers/mtd/nand/denali.c
39767 +++ b/drivers/mtd/nand/denali.c
39768 @@ -24,6 +24,7 @@
39769 #include <linux/slab.h>
39770 #include <linux/mtd/mtd.h>
39771 #include <linux/module.h>
39772 +#include <linux/slab.h>
39773
39774 #include "denali.h"
39775
39776 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39777 index 51b9d6a..52af9a7 100644
39778 --- a/drivers/mtd/nftlmount.c
39779 +++ b/drivers/mtd/nftlmount.c
39780 @@ -24,6 +24,7 @@
39781 #include <asm/errno.h>
39782 #include <linux/delay.h>
39783 #include <linux/slab.h>
39784 +#include <linux/sched.h>
39785 #include <linux/mtd/mtd.h>
39786 #include <linux/mtd/nand.h>
39787 #include <linux/mtd/nftl.h>
39788 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39789 index 8dd6ba5..419cc1d 100644
39790 --- a/drivers/mtd/sm_ftl.c
39791 +++ b/drivers/mtd/sm_ftl.c
39792 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39793 #define SM_CIS_VENDOR_OFFSET 0x59
39794 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39795 {
39796 - struct attribute_group *attr_group;
39797 + attribute_group_no_const *attr_group;
39798 struct attribute **attributes;
39799 struct sm_sysfs_attribute *vendor_attribute;
39800
39801 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39802 index dbbea0e..3f4a0b1 100644
39803 --- a/drivers/net/bonding/bond_main.c
39804 +++ b/drivers/net/bonding/bond_main.c
39805 @@ -4822,7 +4822,7 @@ static unsigned int bond_get_num_tx_queues(void)
39806 return tx_queues;
39807 }
39808
39809 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39810 +static struct rtnl_link_ops bond_link_ops = {
39811 .kind = "bond",
39812 .priv_size = sizeof(struct bonding),
39813 .setup = bond_setup,
39814 @@ -4947,8 +4947,8 @@ static void __exit bonding_exit(void)
39815
39816 bond_destroy_debugfs();
39817
39818 - rtnl_link_unregister(&bond_link_ops);
39819 unregister_pernet_subsys(&bond_net_ops);
39820 + rtnl_link_unregister(&bond_link_ops);
39821
39822 #ifdef CONFIG_NET_POLL_CONTROLLER
39823 /*
39824 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39825 index e1d2643..7f4133b 100644
39826 --- a/drivers/net/ethernet/8390/ax88796.c
39827 +++ b/drivers/net/ethernet/8390/ax88796.c
39828 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39829 if (ax->plat->reg_offsets)
39830 ei_local->reg_offset = ax->plat->reg_offsets;
39831 else {
39832 + resource_size_t _mem_size = mem_size;
39833 + do_div(_mem_size, 0x18);
39834 ei_local->reg_offset = ax->reg_offsets;
39835 for (ret = 0; ret < 0x18; ret++)
39836 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39837 + ax->reg_offsets[ret] = _mem_size * ret;
39838 }
39839
39840 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39841 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39842 index aee7671..3ca2651 100644
39843 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39844 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39845 @@ -1093,7 +1093,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39846 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39847 {
39848 /* RX_MODE controlling object */
39849 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39850 + bnx2x_init_rx_mode_obj(bp);
39851
39852 /* multicast configuration controlling object */
39853 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39854 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39855 index 7306416..5fb7fb5 100644
39856 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39857 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39858 @@ -2381,15 +2381,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39859 return rc;
39860 }
39861
39862 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39863 - struct bnx2x_rx_mode_obj *o)
39864 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39865 {
39866 if (CHIP_IS_E1x(bp)) {
39867 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39868 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39869 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39870 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39871 } else {
39872 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39873 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39874 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39875 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39876 }
39877 }
39878
39879 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39880 index ff90760..08d8aed 100644
39881 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39882 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39883 @@ -1306,8 +1306,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39884
39885 /********************* RX MODE ****************/
39886
39887 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39888 - struct bnx2x_rx_mode_obj *o);
39889 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39890
39891 /**
39892 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39893 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39894 index 25309bf..fcfd54c 100644
39895 --- a/drivers/net/ethernet/broadcom/tg3.h
39896 +++ b/drivers/net/ethernet/broadcom/tg3.h
39897 @@ -147,6 +147,7 @@
39898 #define CHIPREV_ID_5750_A0 0x4000
39899 #define CHIPREV_ID_5750_A1 0x4001
39900 #define CHIPREV_ID_5750_A3 0x4003
39901 +#define CHIPREV_ID_5750_C1 0x4201
39902 #define CHIPREV_ID_5750_C2 0x4202
39903 #define CHIPREV_ID_5752_A0_HW 0x5000
39904 #define CHIPREV_ID_5752_A0 0x6000
39905 diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
39906 index 6e8bc9d..94d957d 100644
39907 --- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
39908 +++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
39909 @@ -244,7 +244,7 @@ bnad_debugfs_lseek(struct file *file, loff_t offset, int orig)
39910 file->f_pos += offset;
39911 break;
39912 case 2:
39913 - file->f_pos = debug->buffer_len - offset;
39914 + file->f_pos = debug->buffer_len + offset;
39915 break;
39916 default:
39917 return -EINVAL;
39918 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39919 index 8cffcdf..aadf043 100644
39920 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39921 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39922 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39923 */
39924 struct l2t_skb_cb {
39925 arp_failure_handler_func arp_failure_handler;
39926 -};
39927 +} __no_const;
39928
39929 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39930
39931 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39932 index 4c83003..2a2a5b9 100644
39933 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39934 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39935 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39936 for (i=0; i<ETH_ALEN; i++) {
39937 tmp.addr[i] = dev->dev_addr[i];
39938 }
39939 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39940 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39941 break;
39942
39943 case DE4X5_SET_HWADDR: /* Set the hardware address */
39944 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39945 spin_lock_irqsave(&lp->lock, flags);
39946 memcpy(&statbuf, &lp->pktStats, ioc->len);
39947 spin_unlock_irqrestore(&lp->lock, flags);
39948 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39949 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39950 return -EFAULT;
39951 break;
39952 }
39953 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39954 index 2886c9b..db71673 100644
39955 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39956 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39957 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39958
39959 if (wrapped)
39960 newacc += 65536;
39961 - ACCESS_ONCE(*acc) = newacc;
39962 + ACCESS_ONCE_RW(*acc) = newacc;
39963 }
39964
39965 void be_parse_stats(struct be_adapter *adapter)
39966 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39967 index 7c361d1..57e3ff1 100644
39968 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39969 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39970 @@ -31,6 +31,8 @@
39971 #include <linux/netdevice.h>
39972 #include <linux/phy.h>
39973 #include <linux/platform_device.h>
39974 +#include <linux/interrupt.h>
39975 +#include <linux/irqreturn.h>
39976 #include <net/ip.h>
39977
39978 #include "ftgmac100.h"
39979 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39980 index b5ea8fb..bd25e9a 100644
39981 --- a/drivers/net/ethernet/faraday/ftmac100.c
39982 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39983 @@ -31,6 +31,8 @@
39984 #include <linux/module.h>
39985 #include <linux/netdevice.h>
39986 #include <linux/platform_device.h>
39987 +#include <linux/interrupt.h>
39988 +#include <linux/irqreturn.h>
39989
39990 #include "ftmac100.h"
39991
39992 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39993 index 331987d..3be1135 100644
39994 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39995 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39996 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39997 }
39998
39999 /* update the base incval used to calculate frequency adjustment */
40000 - ACCESS_ONCE(adapter->base_incval) = incval;
40001 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40002 smp_mb();
40003
40004 /* need lock to prevent incorrect read while modifying cyclecounter */
40005 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40006 index fbe5363..266b4e3 100644
40007 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40008 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40009 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40010 struct __vxge_hw_fifo *fifo;
40011 struct vxge_hw_fifo_config *config;
40012 u32 txdl_size, txdl_per_memblock;
40013 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40014 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40015 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40016 + };
40017 +
40018 struct __vxge_hw_virtualpath *vpath;
40019
40020 if ((vp == NULL) || (attr == NULL)) {
40021 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40022 goto exit;
40023 }
40024
40025 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40026 -
40027 fifo->mempool =
40028 __vxge_hw_mempool_create(vpath->hldev,
40029 fifo->config->memblock_size,
40030 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40031 index 5c033f2..7bbb0d8 100644
40032 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40033 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40034 @@ -1894,7 +1894,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
40035 op_mode = QLCRDX(ahw, QLC_83XX_DRV_OP_MODE);
40036
40037 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
40038 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40039 + pax_open_kernel();
40040 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40041 + pax_close_kernel();
40042 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40043 } else {
40044 return -EIO;
40045 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40046 index b0c3de9..fc5857e 100644
40047 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40048 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40049 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
40050 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
40051 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
40052 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40053 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40054 + pax_open_kernel();
40055 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40056 + pax_close_kernel();
40057 } else if (priv_level == QLCNIC_PRIV_FUNC) {
40058 ahw->op_mode = QLCNIC_PRIV_FUNC;
40059 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
40060 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40061 + pax_open_kernel();
40062 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40063 + pax_close_kernel();
40064 } else if (priv_level == QLCNIC_MGMT_FUNC) {
40065 ahw->op_mode = QLCNIC_MGMT_FUNC;
40066 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40067 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40068 + pax_open_kernel();
40069 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40070 + pax_close_kernel();
40071 } else {
40072 return -EIO;
40073 }
40074 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40075 index 15ba8c4..3f56838 100644
40076 --- a/drivers/net/ethernet/realtek/r8169.c
40077 +++ b/drivers/net/ethernet/realtek/r8169.c
40078 @@ -740,22 +740,22 @@ struct rtl8169_private {
40079 struct mdio_ops {
40080 void (*write)(struct rtl8169_private *, int, int);
40081 int (*read)(struct rtl8169_private *, int);
40082 - } mdio_ops;
40083 + } __no_const mdio_ops;
40084
40085 struct pll_power_ops {
40086 void (*down)(struct rtl8169_private *);
40087 void (*up)(struct rtl8169_private *);
40088 - } pll_power_ops;
40089 + } __no_const pll_power_ops;
40090
40091 struct jumbo_ops {
40092 void (*enable)(struct rtl8169_private *);
40093 void (*disable)(struct rtl8169_private *);
40094 - } jumbo_ops;
40095 + } __no_const jumbo_ops;
40096
40097 struct csi_ops {
40098 void (*write)(struct rtl8169_private *, int, int);
40099 u32 (*read)(struct rtl8169_private *, int);
40100 - } csi_ops;
40101 + } __no_const csi_ops;
40102
40103 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40104 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40105 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40106 index 3f93624..cf01144 100644
40107 --- a/drivers/net/ethernet/sfc/ptp.c
40108 +++ b/drivers/net/ethernet/sfc/ptp.c
40109 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40110 (u32)((u64)ptp->start.dma_addr >> 32));
40111
40112 /* Clear flag that signals MC ready */
40113 - ACCESS_ONCE(*start) = 0;
40114 + ACCESS_ONCE_RW(*start) = 0;
40115 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40116 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40117
40118 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40119 index 50617c5..b13724c 100644
40120 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40121 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40122 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40123
40124 writel(value, ioaddr + MMC_CNTRL);
40125
40126 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40127 - MMC_CNTRL, value);
40128 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40129 +// MMC_CNTRL, value);
40130 }
40131
40132 /* To mask all all interrupts.*/
40133 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40134 index e6fe0d8..2b7d752 100644
40135 --- a/drivers/net/hyperv/hyperv_net.h
40136 +++ b/drivers/net/hyperv/hyperv_net.h
40137 @@ -101,7 +101,7 @@ struct rndis_device {
40138
40139 enum rndis_device_state state;
40140 bool link_state;
40141 - atomic_t new_req_id;
40142 + atomic_unchecked_t new_req_id;
40143
40144 spinlock_t request_lock;
40145 struct list_head req_list;
40146 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40147 index 0775f0a..d4fb316 100644
40148 --- a/drivers/net/hyperv/rndis_filter.c
40149 +++ b/drivers/net/hyperv/rndis_filter.c
40150 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40151 * template
40152 */
40153 set = &rndis_msg->msg.set_req;
40154 - set->req_id = atomic_inc_return(&dev->new_req_id);
40155 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40156
40157 /* Add to the request list */
40158 spin_lock_irqsave(&dev->request_lock, flags);
40159 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40160
40161 /* Setup the rndis set */
40162 halt = &request->request_msg.msg.halt_req;
40163 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40164 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40165
40166 /* Ignore return since this msg is optional. */
40167 rndis_filter_send_request(dev, request);
40168 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40169 index 8f1c256..a2991d1 100644
40170 --- a/drivers/net/ieee802154/fakehard.c
40171 +++ b/drivers/net/ieee802154/fakehard.c
40172 @@ -385,7 +385,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40173 phy->transmit_power = 0xbf;
40174
40175 dev->netdev_ops = &fake_ops;
40176 - dev->ml_priv = &fake_mlme;
40177 + dev->ml_priv = (void *)&fake_mlme;
40178
40179 priv = netdev_priv(dev);
40180 priv->phy = phy;
40181 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40182 index 011062e..ada88e9 100644
40183 --- a/drivers/net/macvlan.c
40184 +++ b/drivers/net/macvlan.c
40185 @@ -892,13 +892,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40186 int macvlan_link_register(struct rtnl_link_ops *ops)
40187 {
40188 /* common fields */
40189 - ops->priv_size = sizeof(struct macvlan_dev);
40190 - ops->validate = macvlan_validate;
40191 - ops->maxtype = IFLA_MACVLAN_MAX;
40192 - ops->policy = macvlan_policy;
40193 - ops->changelink = macvlan_changelink;
40194 - ops->get_size = macvlan_get_size;
40195 - ops->fill_info = macvlan_fill_info;
40196 + pax_open_kernel();
40197 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40198 + *(void **)&ops->validate = macvlan_validate;
40199 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40200 + *(const void **)&ops->policy = macvlan_policy;
40201 + *(void **)&ops->changelink = macvlan_changelink;
40202 + *(void **)&ops->get_size = macvlan_get_size;
40203 + *(void **)&ops->fill_info = macvlan_fill_info;
40204 + pax_close_kernel();
40205
40206 return rtnl_link_register(ops);
40207 };
40208 @@ -954,7 +956,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40209 return NOTIFY_DONE;
40210 }
40211
40212 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40213 +static struct notifier_block macvlan_notifier_block = {
40214 .notifier_call = macvlan_device_event,
40215 };
40216
40217 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40218 index a449439..1e468fe 100644
40219 --- a/drivers/net/macvtap.c
40220 +++ b/drivers/net/macvtap.c
40221 @@ -1090,7 +1090,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40222 return NOTIFY_DONE;
40223 }
40224
40225 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40226 +static struct notifier_block macvtap_notifier_block = {
40227 .notifier_call = macvtap_device_event,
40228 };
40229
40230 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40231 index daec9b0..6428fcb 100644
40232 --- a/drivers/net/phy/mdio-bitbang.c
40233 +++ b/drivers/net/phy/mdio-bitbang.c
40234 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40235 struct mdiobb_ctrl *ctrl = bus->priv;
40236
40237 module_put(ctrl->ops->owner);
40238 + mdiobus_unregister(bus);
40239 mdiobus_free(bus);
40240 }
40241 EXPORT_SYMBOL(free_mdio_bitbang);
40242 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40243 index 72ff14b..11d442d 100644
40244 --- a/drivers/net/ppp/ppp_generic.c
40245 +++ b/drivers/net/ppp/ppp_generic.c
40246 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40247 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40248 struct ppp_stats stats;
40249 struct ppp_comp_stats cstats;
40250 - char *vers;
40251
40252 switch (cmd) {
40253 case SIOCGPPPSTATS:
40254 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40255 break;
40256
40257 case SIOCGPPPVER:
40258 - vers = PPP_VERSION;
40259 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40260 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40261 break;
40262 err = 0;
40263 break;
40264 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
40265 index 1252d9c..80e660b 100644
40266 --- a/drivers/net/slip/slhc.c
40267 +++ b/drivers/net/slip/slhc.c
40268 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
40269 register struct tcphdr *thp;
40270 register struct iphdr *ip;
40271 register struct cstate *cs;
40272 - int len, hdrlen;
40273 + long len, hdrlen;
40274 unsigned char *cp = icp;
40275
40276 /* We've got a compressed packet; read the change byte */
40277 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40278 index bf34192..fba3500 100644
40279 --- a/drivers/net/team/team.c
40280 +++ b/drivers/net/team/team.c
40281 @@ -2668,7 +2668,7 @@ static int team_device_event(struct notifier_block *unused,
40282 return NOTIFY_DONE;
40283 }
40284
40285 -static struct notifier_block team_notifier_block __read_mostly = {
40286 +static struct notifier_block team_notifier_block = {
40287 .notifier_call = team_device_event,
40288 };
40289
40290 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40291 index 755fa9e..631fdce 100644
40292 --- a/drivers/net/tun.c
40293 +++ b/drivers/net/tun.c
40294 @@ -1841,7 +1841,7 @@ unlock:
40295 }
40296
40297 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40298 - unsigned long arg, int ifreq_len)
40299 + unsigned long arg, size_t ifreq_len)
40300 {
40301 struct tun_file *tfile = file->private_data;
40302 struct tun_struct *tun;
40303 @@ -1853,6 +1853,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40304 int vnet_hdr_sz;
40305 int ret;
40306
40307 + if (ifreq_len > sizeof ifr)
40308 + return -EFAULT;
40309 +
40310 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40311 if (copy_from_user(&ifr, argp, ifreq_len))
40312 return -EFAULT;
40313 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40314 index e2dd324..be92fcf 100644
40315 --- a/drivers/net/usb/hso.c
40316 +++ b/drivers/net/usb/hso.c
40317 @@ -71,7 +71,7 @@
40318 #include <asm/byteorder.h>
40319 #include <linux/serial_core.h>
40320 #include <linux/serial.h>
40321 -
40322 +#include <asm/local.h>
40323
40324 #define MOD_AUTHOR "Option Wireless"
40325 #define MOD_DESCRIPTION "USB High Speed Option driver"
40326 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40327 struct urb *urb;
40328
40329 urb = serial->rx_urb[0];
40330 - if (serial->port.count > 0) {
40331 + if (atomic_read(&serial->port.count) > 0) {
40332 count = put_rxbuf_data(urb, serial);
40333 if (count == -1)
40334 return;
40335 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40336 DUMP1(urb->transfer_buffer, urb->actual_length);
40337
40338 /* Anyone listening? */
40339 - if (serial->port.count == 0)
40340 + if (atomic_read(&serial->port.count) == 0)
40341 return;
40342
40343 if (status == 0) {
40344 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40345 tty_port_tty_set(&serial->port, tty);
40346
40347 /* check for port already opened, if not set the termios */
40348 - serial->port.count++;
40349 - if (serial->port.count == 1) {
40350 + if (atomic_inc_return(&serial->port.count) == 1) {
40351 serial->rx_state = RX_IDLE;
40352 /* Force default termio settings */
40353 _hso_serial_set_termios(tty, NULL);
40354 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40355 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40356 if (result) {
40357 hso_stop_serial_device(serial->parent);
40358 - serial->port.count--;
40359 + atomic_dec(&serial->port.count);
40360 kref_put(&serial->parent->ref, hso_serial_ref_free);
40361 }
40362 } else {
40363 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40364
40365 /* reset the rts and dtr */
40366 /* do the actual close */
40367 - serial->port.count--;
40368 + atomic_dec(&serial->port.count);
40369
40370 - if (serial->port.count <= 0) {
40371 - serial->port.count = 0;
40372 + if (atomic_read(&serial->port.count) <= 0) {
40373 + atomic_set(&serial->port.count, 0);
40374 tty_port_tty_set(&serial->port, NULL);
40375 if (!usb_gone)
40376 hso_stop_serial_device(serial->parent);
40377 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40378
40379 /* the actual setup */
40380 spin_lock_irqsave(&serial->serial_lock, flags);
40381 - if (serial->port.count)
40382 + if (atomic_read(&serial->port.count))
40383 _hso_serial_set_termios(tty, old);
40384 else
40385 tty->termios = *old;
40386 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40387 D1("Pending read interrupt on port %d\n", i);
40388 spin_lock(&serial->serial_lock);
40389 if (serial->rx_state == RX_IDLE &&
40390 - serial->port.count > 0) {
40391 + atomic_read(&serial->port.count) > 0) {
40392 /* Setup and send a ctrl req read on
40393 * port i */
40394 if (!serial->rx_urb_filled[0]) {
40395 @@ -3066,7 +3065,7 @@ static int hso_resume(struct usb_interface *iface)
40396 /* Start all serial ports */
40397 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40398 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40399 - if (dev2ser(serial_table[i])->port.count) {
40400 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40401 result =
40402 hso_start_serial_device(serial_table[i], GFP_NOIO);
40403 hso_kick_transmit(dev2ser(serial_table[i]));
40404 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40405 index 7cee7a3..1eb9f3b 100644
40406 --- a/drivers/net/vxlan.c
40407 +++ b/drivers/net/vxlan.c
40408 @@ -1443,7 +1443,7 @@ nla_put_failure:
40409 return -EMSGSIZE;
40410 }
40411
40412 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40413 +static struct rtnl_link_ops vxlan_link_ops = {
40414 .kind = "vxlan",
40415 .maxtype = IFLA_VXLAN_MAX,
40416 .policy = vxlan_policy,
40417 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40418 index 5ac5f7a..5f82012 100644
40419 --- a/drivers/net/wireless/at76c50x-usb.c
40420 +++ b/drivers/net/wireless/at76c50x-usb.c
40421 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40422 }
40423
40424 /* Convert timeout from the DFU status to jiffies */
40425 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40426 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40427 {
40428 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40429 | (s->poll_timeout[1] << 8)
40430 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40431 index 8d78253..bebbb68 100644
40432 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40433 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40434 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40435 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40436 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40437
40438 - ACCESS_ONCE(ads->ds_link) = i->link;
40439 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40440 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40441 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40442
40443 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40444 ctl6 = SM(i->keytype, AR_EncrType);
40445 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40446
40447 if ((i->is_first || i->is_last) &&
40448 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40449 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40450 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40451 | set11nTries(i->rates, 1)
40452 | set11nTries(i->rates, 2)
40453 | set11nTries(i->rates, 3)
40454 | (i->dur_update ? AR_DurUpdateEna : 0)
40455 | SM(0, AR_BurstDur);
40456
40457 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40458 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40459 | set11nRate(i->rates, 1)
40460 | set11nRate(i->rates, 2)
40461 | set11nRate(i->rates, 3);
40462 } else {
40463 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40464 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40465 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40466 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40467 }
40468
40469 if (!i->is_first) {
40470 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40471 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40472 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40473 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40474 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40475 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40476 return;
40477 }
40478
40479 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40480 break;
40481 }
40482
40483 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40484 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40485 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40486 | SM(i->txpower, AR_XmitPower)
40487 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40488 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40489 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40490 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40491
40492 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40493 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40494 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40495 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40496
40497 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40498 return;
40499
40500 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40501 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40502 | set11nPktDurRTSCTS(i->rates, 1);
40503
40504 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40505 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40506 | set11nPktDurRTSCTS(i->rates, 3);
40507
40508 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40509 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40510 | set11nRateFlags(i->rates, 1)
40511 | set11nRateFlags(i->rates, 2)
40512 | set11nRateFlags(i->rates, 3)
40513 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40514 index 301bf72..3f5654f 100644
40515 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40516 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40517 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40518 (i->qcu << AR_TxQcuNum_S) | desc_len;
40519
40520 checksum += val;
40521 - ACCESS_ONCE(ads->info) = val;
40522 + ACCESS_ONCE_RW(ads->info) = val;
40523
40524 checksum += i->link;
40525 - ACCESS_ONCE(ads->link) = i->link;
40526 + ACCESS_ONCE_RW(ads->link) = i->link;
40527
40528 checksum += i->buf_addr[0];
40529 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40530 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40531 checksum += i->buf_addr[1];
40532 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40533 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40534 checksum += i->buf_addr[2];
40535 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40536 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40537 checksum += i->buf_addr[3];
40538 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40539 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40540
40541 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40542 - ACCESS_ONCE(ads->ctl3) = val;
40543 + ACCESS_ONCE_RW(ads->ctl3) = val;
40544 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40545 - ACCESS_ONCE(ads->ctl5) = val;
40546 + ACCESS_ONCE_RW(ads->ctl5) = val;
40547 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40548 - ACCESS_ONCE(ads->ctl7) = val;
40549 + ACCESS_ONCE_RW(ads->ctl7) = val;
40550 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40551 - ACCESS_ONCE(ads->ctl9) = val;
40552 + ACCESS_ONCE_RW(ads->ctl9) = val;
40553
40554 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40555 - ACCESS_ONCE(ads->ctl10) = checksum;
40556 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40557
40558 if (i->is_first || i->is_last) {
40559 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40560 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40561 | set11nTries(i->rates, 1)
40562 | set11nTries(i->rates, 2)
40563 | set11nTries(i->rates, 3)
40564 | (i->dur_update ? AR_DurUpdateEna : 0)
40565 | SM(0, AR_BurstDur);
40566
40567 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40568 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40569 | set11nRate(i->rates, 1)
40570 | set11nRate(i->rates, 2)
40571 | set11nRate(i->rates, 3);
40572 } else {
40573 - ACCESS_ONCE(ads->ctl13) = 0;
40574 - ACCESS_ONCE(ads->ctl14) = 0;
40575 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40576 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40577 }
40578
40579 ads->ctl20 = 0;
40580 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40581
40582 ctl17 = SM(i->keytype, AR_EncrType);
40583 if (!i->is_first) {
40584 - ACCESS_ONCE(ads->ctl11) = 0;
40585 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40586 - ACCESS_ONCE(ads->ctl15) = 0;
40587 - ACCESS_ONCE(ads->ctl16) = 0;
40588 - ACCESS_ONCE(ads->ctl17) = ctl17;
40589 - ACCESS_ONCE(ads->ctl18) = 0;
40590 - ACCESS_ONCE(ads->ctl19) = 0;
40591 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40592 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40593 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40594 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40595 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40596 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40597 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40598 return;
40599 }
40600
40601 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40602 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40603 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40604 | SM(i->txpower, AR_XmitPower)
40605 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40606 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40607 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40608 ctl12 |= SM(val, AR_PAPRDChainMask);
40609
40610 - ACCESS_ONCE(ads->ctl12) = ctl12;
40611 - ACCESS_ONCE(ads->ctl17) = ctl17;
40612 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40613 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40614
40615 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40616 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40617 | set11nPktDurRTSCTS(i->rates, 1);
40618
40619 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40620 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40621 | set11nPktDurRTSCTS(i->rates, 3);
40622
40623 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40624 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40625 | set11nRateFlags(i->rates, 1)
40626 | set11nRateFlags(i->rates, 2)
40627 | set11nRateFlags(i->rates, 3)
40628 | SM(i->rtscts_rate, AR_RTSCTSRate);
40629
40630 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40631 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40632 }
40633
40634 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40635 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40636 index 784e81c..349e01e 100644
40637 --- a/drivers/net/wireless/ath/ath9k/hw.h
40638 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40639 @@ -653,7 +653,7 @@ struct ath_hw_private_ops {
40640
40641 /* ANI */
40642 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40643 -};
40644 +} __no_const;
40645
40646 /**
40647 * struct ath_spec_scan - parameters for Atheros spectral scan
40648 @@ -722,7 +722,7 @@ struct ath_hw_ops {
40649 struct ath_spec_scan *param);
40650 void (*spectral_scan_trigger)(struct ath_hw *ah);
40651 void (*spectral_scan_wait)(struct ath_hw *ah);
40652 -};
40653 +} __no_const;
40654
40655 struct ath_nf_limits {
40656 s16 max;
40657 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40658 index c353b5f..62aaca2 100644
40659 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40660 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40661 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40662 */
40663 if (il3945_mod_params.disable_hw_scan) {
40664 D_INFO("Disabling hw_scan\n");
40665 - il3945_mac_ops.hw_scan = NULL;
40666 + pax_open_kernel();
40667 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40668 + pax_close_kernel();
40669 }
40670
40671 D_INFO("*** LOAD DRIVER ***\n");
40672 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40673 index 81d4071..f2071ea 100644
40674 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40675 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40676 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40677 {
40678 struct iwl_priv *priv = file->private_data;
40679 char buf[64];
40680 - int buf_size;
40681 + size_t buf_size;
40682 u32 offset, len;
40683
40684 memset(buf, 0, sizeof(buf));
40685 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40686 struct iwl_priv *priv = file->private_data;
40687
40688 char buf[8];
40689 - int buf_size;
40690 + size_t buf_size;
40691 u32 reset_flag;
40692
40693 memset(buf, 0, sizeof(buf));
40694 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40695 {
40696 struct iwl_priv *priv = file->private_data;
40697 char buf[8];
40698 - int buf_size;
40699 + size_t buf_size;
40700 int ht40;
40701
40702 memset(buf, 0, sizeof(buf));
40703 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40704 {
40705 struct iwl_priv *priv = file->private_data;
40706 char buf[8];
40707 - int buf_size;
40708 + size_t buf_size;
40709 int value;
40710
40711 memset(buf, 0, sizeof(buf));
40712 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40713 {
40714 struct iwl_priv *priv = file->private_data;
40715 char buf[8];
40716 - int buf_size;
40717 + size_t buf_size;
40718 int clear;
40719
40720 memset(buf, 0, sizeof(buf));
40721 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40722 {
40723 struct iwl_priv *priv = file->private_data;
40724 char buf[8];
40725 - int buf_size;
40726 + size_t buf_size;
40727 int trace;
40728
40729 memset(buf, 0, sizeof(buf));
40730 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40731 {
40732 struct iwl_priv *priv = file->private_data;
40733 char buf[8];
40734 - int buf_size;
40735 + size_t buf_size;
40736 int missed;
40737
40738 memset(buf, 0, sizeof(buf));
40739 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40740
40741 struct iwl_priv *priv = file->private_data;
40742 char buf[8];
40743 - int buf_size;
40744 + size_t buf_size;
40745 int plcp;
40746
40747 memset(buf, 0, sizeof(buf));
40748 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40749
40750 struct iwl_priv *priv = file->private_data;
40751 char buf[8];
40752 - int buf_size;
40753 + size_t buf_size;
40754 int flush;
40755
40756 memset(buf, 0, sizeof(buf));
40757 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40758
40759 struct iwl_priv *priv = file->private_data;
40760 char buf[8];
40761 - int buf_size;
40762 + size_t buf_size;
40763 int rts;
40764
40765 if (!priv->cfg->ht_params)
40766 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40767 {
40768 struct iwl_priv *priv = file->private_data;
40769 char buf[8];
40770 - int buf_size;
40771 + size_t buf_size;
40772
40773 memset(buf, 0, sizeof(buf));
40774 buf_size = min(count, sizeof(buf) - 1);
40775 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40776 struct iwl_priv *priv = file->private_data;
40777 u32 event_log_flag;
40778 char buf[8];
40779 - int buf_size;
40780 + size_t buf_size;
40781
40782 /* check that the interface is up */
40783 if (!iwl_is_ready(priv))
40784 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40785 struct iwl_priv *priv = file->private_data;
40786 char buf[8];
40787 u32 calib_disabled;
40788 - int buf_size;
40789 + size_t buf_size;
40790
40791 memset(buf, 0, sizeof(buf));
40792 buf_size = min(count, sizeof(buf) - 1);
40793 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40794 index 12c4f31..484d948 100644
40795 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40796 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40797 @@ -1328,7 +1328,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40798 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40799
40800 char buf[8];
40801 - int buf_size;
40802 + size_t buf_size;
40803 u32 reset_flag;
40804
40805 memset(buf, 0, sizeof(buf));
40806 @@ -1349,7 +1349,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40807 {
40808 struct iwl_trans *trans = file->private_data;
40809 char buf[8];
40810 - int buf_size;
40811 + size_t buf_size;
40812 int csr;
40813
40814 memset(buf, 0, sizeof(buf));
40815 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40816 index 2b49f48..14fc244 100644
40817 --- a/drivers/net/wireless/mac80211_hwsim.c
40818 +++ b/drivers/net/wireless/mac80211_hwsim.c
40819 @@ -2143,25 +2143,19 @@ static int __init init_mac80211_hwsim(void)
40820
40821 if (channels > 1) {
40822 hwsim_if_comb.num_different_channels = channels;
40823 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40824 - mac80211_hwsim_ops.cancel_hw_scan =
40825 - mac80211_hwsim_cancel_hw_scan;
40826 - mac80211_hwsim_ops.sw_scan_start = NULL;
40827 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40828 - mac80211_hwsim_ops.remain_on_channel =
40829 - mac80211_hwsim_roc;
40830 - mac80211_hwsim_ops.cancel_remain_on_channel =
40831 - mac80211_hwsim_croc;
40832 - mac80211_hwsim_ops.add_chanctx =
40833 - mac80211_hwsim_add_chanctx;
40834 - mac80211_hwsim_ops.remove_chanctx =
40835 - mac80211_hwsim_remove_chanctx;
40836 - mac80211_hwsim_ops.change_chanctx =
40837 - mac80211_hwsim_change_chanctx;
40838 - mac80211_hwsim_ops.assign_vif_chanctx =
40839 - mac80211_hwsim_assign_vif_chanctx;
40840 - mac80211_hwsim_ops.unassign_vif_chanctx =
40841 - mac80211_hwsim_unassign_vif_chanctx;
40842 + pax_open_kernel();
40843 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40844 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40845 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40846 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40847 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40848 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40849 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40850 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40851 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40852 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40853 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40854 + pax_close_kernel();
40855 }
40856
40857 spin_lock_init(&hwsim_radio_lock);
40858 diff --git a/drivers/net/wireless/mwifiex/debugfs.c b/drivers/net/wireless/mwifiex/debugfs.c
40859 index 753b568..a5f9875 100644
40860 --- a/drivers/net/wireless/mwifiex/debugfs.c
40861 +++ b/drivers/net/wireless/mwifiex/debugfs.c
40862 @@ -26,10 +26,17 @@
40863 static struct dentry *mwifiex_dfs_dir;
40864
40865 static char *bss_modes[] = {
40866 - "Unknown",
40867 - "Ad-hoc",
40868 - "Managed",
40869 - "Auto"
40870 + "UNSPECIFIED",
40871 + "ADHOC",
40872 + "STATION",
40873 + "AP",
40874 + "AP_VLAN",
40875 + "WDS",
40876 + "MONITOR",
40877 + "MESH_POINT",
40878 + "P2P_CLIENT",
40879 + "P2P_GO",
40880 + "P2P_DEVICE",
40881 };
40882
40883 /* size/addr for mwifiex_debug_info */
40884 @@ -200,7 +207,12 @@ mwifiex_info_read(struct file *file, char __user *ubuf,
40885 p += sprintf(p, "driver_version = %s", fmt);
40886 p += sprintf(p, "\nverext = %s", priv->version_str);
40887 p += sprintf(p, "\ninterface_name=\"%s\"\n", netdev->name);
40888 - p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]);
40889 +
40890 + if (info.bss_mode >= ARRAY_SIZE(bss_modes))
40891 + p += sprintf(p, "bss_mode=\"%d\"\n", info.bss_mode);
40892 + else
40893 + p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]);
40894 +
40895 p += sprintf(p, "media_state=\"%s\"\n",
40896 (!priv->media_connected ? "Disconnected" : "Connected"));
40897 p += sprintf(p, "mac_address=\"%pM\"\n", netdev->dev_addr);
40898 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40899 index 525fd75..6c9f791 100644
40900 --- a/drivers/net/wireless/rndis_wlan.c
40901 +++ b/drivers/net/wireless/rndis_wlan.c
40902 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40903
40904 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40905
40906 - if (rts_threshold < 0 || rts_threshold > 2347)
40907 + if (rts_threshold > 2347)
40908 rts_threshold = 2347;
40909
40910 tmp = cpu_to_le32(rts_threshold);
40911 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40912 index 086abb4..8279c30 100644
40913 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40914 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40915 @@ -396,7 +396,7 @@ struct rt2x00_intf {
40916 * for hardware which doesn't support hardware
40917 * sequence counting.
40918 */
40919 - atomic_t seqno;
40920 + atomic_unchecked_t seqno;
40921 };
40922
40923 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40924 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40925 index 4d91795..62fccff 100644
40926 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40927 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40928 @@ -251,9 +251,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40929 * sequence counter given by mac80211.
40930 */
40931 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40932 - seqno = atomic_add_return(0x10, &intf->seqno);
40933 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40934 else
40935 - seqno = atomic_read(&intf->seqno);
40936 + seqno = atomic_read_unchecked(&intf->seqno);
40937
40938 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40939 hdr->seq_ctrl |= cpu_to_le16(seqno);
40940 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40941 index e57ee48..541cf6c 100644
40942 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40943 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40944 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40945
40946 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40947
40948 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40949 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40950 + pax_open_kernel();
40951 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40952 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40953 + pax_close_kernel();
40954
40955 wl1251_info("using dedicated interrupt line");
40956 } else {
40957 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40958 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40959 + pax_open_kernel();
40960 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40961 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40962 + pax_close_kernel();
40963
40964 wl1251_info("using SDIO interrupt");
40965 }
40966 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40967 index 09694e3..24ccec7 100644
40968 --- a/drivers/net/wireless/ti/wl12xx/main.c
40969 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40970 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40971 sizeof(wl->conf.mem));
40972
40973 /* read data preparation is only needed by wl127x */
40974 - wl->ops->prepare_read = wl127x_prepare_read;
40975 + pax_open_kernel();
40976 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40977 + pax_close_kernel();
40978
40979 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40980 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40981 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40982 sizeof(wl->conf.mem));
40983
40984 /* read data preparation is only needed by wl127x */
40985 - wl->ops->prepare_read = wl127x_prepare_read;
40986 + pax_open_kernel();
40987 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40988 + pax_close_kernel();
40989
40990 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40991 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40992 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40993 index da3ef1b..4790b95 100644
40994 --- a/drivers/net/wireless/ti/wl18xx/main.c
40995 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40996 @@ -1664,8 +1664,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40997 }
40998
40999 if (!checksum_param) {
41000 - wl18xx_ops.set_rx_csum = NULL;
41001 - wl18xx_ops.init_vif = NULL;
41002 + pax_open_kernel();
41003 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41004 + *(void **)&wl18xx_ops.init_vif = NULL;
41005 + pax_close_kernel();
41006 }
41007
41008 /* Enable 11a Band only if we have 5G antennas */
41009 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41010 index 7ef0b4a..ff65c28 100644
41011 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41012 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41013 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
41014 {
41015 struct zd_usb *usb = urb->context;
41016 struct zd_usb_interrupt *intr = &usb->intr;
41017 - int len;
41018 + unsigned int len;
41019 u16 int_num;
41020
41021 ZD_ASSERT(in_interrupt());
41022 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41023 index d93b2b6..ae50401 100644
41024 --- a/drivers/oprofile/buffer_sync.c
41025 +++ b/drivers/oprofile/buffer_sync.c
41026 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41027 if (cookie == NO_COOKIE)
41028 offset = pc;
41029 if (cookie == INVALID_COOKIE) {
41030 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41031 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41032 offset = pc;
41033 }
41034 if (cookie != last_cookie) {
41035 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41036 /* add userspace sample */
41037
41038 if (!mm) {
41039 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41040 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41041 return 0;
41042 }
41043
41044 cookie = lookup_dcookie(mm, s->eip, &offset);
41045
41046 if (cookie == INVALID_COOKIE) {
41047 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41048 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41049 return 0;
41050 }
41051
41052 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41053 /* ignore backtraces if failed to add a sample */
41054 if (state == sb_bt_start) {
41055 state = sb_bt_ignore;
41056 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41057 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41058 }
41059 }
41060 release_mm(mm);
41061 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41062 index c0cc4e7..44d4e54 100644
41063 --- a/drivers/oprofile/event_buffer.c
41064 +++ b/drivers/oprofile/event_buffer.c
41065 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41066 }
41067
41068 if (buffer_pos == buffer_size) {
41069 - atomic_inc(&oprofile_stats.event_lost_overflow);
41070 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41071 return;
41072 }
41073
41074 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41075 index ed2c3ec..deda85a 100644
41076 --- a/drivers/oprofile/oprof.c
41077 +++ b/drivers/oprofile/oprof.c
41078 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41079 if (oprofile_ops.switch_events())
41080 return;
41081
41082 - atomic_inc(&oprofile_stats.multiplex_counter);
41083 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41084 start_switch_worker();
41085 }
41086
41087 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41088 index 84a208d..d61b0a1 100644
41089 --- a/drivers/oprofile/oprofile_files.c
41090 +++ b/drivers/oprofile/oprofile_files.c
41091 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41092
41093 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41094
41095 -static ssize_t timeout_read(struct file *file, char __user *buf,
41096 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41097 size_t count, loff_t *offset)
41098 {
41099 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41100 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41101 index 917d28e..d62d981 100644
41102 --- a/drivers/oprofile/oprofile_stats.c
41103 +++ b/drivers/oprofile/oprofile_stats.c
41104 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41105 cpu_buf->sample_invalid_eip = 0;
41106 }
41107
41108 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41109 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41110 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41111 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41112 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41113 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41114 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41115 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41116 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41117 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41118 }
41119
41120
41121 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41122 index 38b6fc0..b5cbfce 100644
41123 --- a/drivers/oprofile/oprofile_stats.h
41124 +++ b/drivers/oprofile/oprofile_stats.h
41125 @@ -13,11 +13,11 @@
41126 #include <linux/atomic.h>
41127
41128 struct oprofile_stat_struct {
41129 - atomic_t sample_lost_no_mm;
41130 - atomic_t sample_lost_no_mapping;
41131 - atomic_t bt_lost_no_mapping;
41132 - atomic_t event_lost_overflow;
41133 - atomic_t multiplex_counter;
41134 + atomic_unchecked_t sample_lost_no_mm;
41135 + atomic_unchecked_t sample_lost_no_mapping;
41136 + atomic_unchecked_t bt_lost_no_mapping;
41137 + atomic_unchecked_t event_lost_overflow;
41138 + atomic_unchecked_t multiplex_counter;
41139 };
41140
41141 extern struct oprofile_stat_struct oprofile_stats;
41142 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41143 index 7c12d9c..558bf3bb 100644
41144 --- a/drivers/oprofile/oprofilefs.c
41145 +++ b/drivers/oprofile/oprofilefs.c
41146 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
41147
41148
41149 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41150 - char const *name, atomic_t *val)
41151 + char const *name, atomic_unchecked_t *val)
41152 {
41153 return __oprofilefs_create_file(sb, root, name,
41154 &atomic_ro_fops, 0444, val);
41155 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41156 index 93404f7..4a313d8 100644
41157 --- a/drivers/oprofile/timer_int.c
41158 +++ b/drivers/oprofile/timer_int.c
41159 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41160 return NOTIFY_OK;
41161 }
41162
41163 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41164 +static struct notifier_block oprofile_cpu_notifier = {
41165 .notifier_call = oprofile_cpu_notify,
41166 };
41167
41168 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41169 index 3f56bc0..707d642 100644
41170 --- a/drivers/parport/procfs.c
41171 +++ b/drivers/parport/procfs.c
41172 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41173
41174 *ppos += len;
41175
41176 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41177 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41178 }
41179
41180 #ifdef CONFIG_PARPORT_1284
41181 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41182
41183 *ppos += len;
41184
41185 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41186 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41187 }
41188 #endif /* IEEE1284.3 support. */
41189
41190 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41191 index c35e8ad..fc33beb 100644
41192 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41193 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41194 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41195 goto init_cleanup;
41196 }
41197
41198 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41199 + pax_open_kernel();
41200 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41201 + pax_close_kernel();
41202 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41203
41204 return retval;
41205 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41206 index a6a71c4..c91097b 100644
41207 --- a/drivers/pci/hotplug/cpcihp_generic.c
41208 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41209 @@ -73,7 +73,6 @@ static u16 port;
41210 static unsigned int enum_bit;
41211 static u8 enum_mask;
41212
41213 -static struct cpci_hp_controller_ops generic_hpc_ops;
41214 static struct cpci_hp_controller generic_hpc;
41215
41216 static int __init validate_parameters(void)
41217 @@ -139,6 +138,10 @@ static int query_enum(void)
41218 return ((value & enum_mask) == enum_mask);
41219 }
41220
41221 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41222 + .query_enum = query_enum,
41223 +};
41224 +
41225 static int __init cpcihp_generic_init(void)
41226 {
41227 int status;
41228 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41229 pci_dev_put(dev);
41230
41231 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41232 - generic_hpc_ops.query_enum = query_enum;
41233 generic_hpc.ops = &generic_hpc_ops;
41234
41235 status = cpci_hp_register_controller(&generic_hpc);
41236 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41237 index 449b4bb..257e2e8 100644
41238 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41239 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41240 @@ -59,7 +59,6 @@
41241 /* local variables */
41242 static bool debug;
41243 static bool poll;
41244 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41245 static struct cpci_hp_controller zt5550_hpc;
41246
41247 /* Primary cPCI bus bridge device */
41248 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41249 return 0;
41250 }
41251
41252 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41253 + .query_enum = zt5550_hc_query_enum,
41254 +};
41255 +
41256 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41257 {
41258 int status;
41259 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41260 dbg("returned from zt5550_hc_config");
41261
41262 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41263 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41264 zt5550_hpc.ops = &zt5550_hpc_ops;
41265 if(!poll) {
41266 zt5550_hpc.irq = hc_dev->irq;
41267 zt5550_hpc.irq_flags = IRQF_SHARED;
41268 zt5550_hpc.dev_id = hc_dev;
41269
41270 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41271 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41272 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41273 + pax_open_kernel();
41274 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41275 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41276 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41277 + pax_open_kernel();
41278 } else {
41279 info("using ENUM# polling mode");
41280 }
41281 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41282 index 76ba8a1..20ca857 100644
41283 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41284 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41285 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41286
41287 void compaq_nvram_init (void __iomem *rom_start)
41288 {
41289 +
41290 +#ifndef CONFIG_PAX_KERNEXEC
41291 if (rom_start) {
41292 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41293 }
41294 +#endif
41295 +
41296 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41297
41298 /* initialize our int15 lock */
41299 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41300 index 202f4a9..8ee47d0 100644
41301 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41302 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41303 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41304 return -EINVAL;
41305 }
41306
41307 - slot->ops->owner = owner;
41308 - slot->ops->mod_name = mod_name;
41309 + pax_open_kernel();
41310 + *(struct module **)&slot->ops->owner = owner;
41311 + *(const char **)&slot->ops->mod_name = mod_name;
41312 + pax_close_kernel();
41313
41314 mutex_lock(&pci_hp_mutex);
41315 /*
41316 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41317 index 7d72c5e..edce02c 100644
41318 --- a/drivers/pci/hotplug/pciehp_core.c
41319 +++ b/drivers/pci/hotplug/pciehp_core.c
41320 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41321 struct slot *slot = ctrl->slot;
41322 struct hotplug_slot *hotplug = NULL;
41323 struct hotplug_slot_info *info = NULL;
41324 - struct hotplug_slot_ops *ops = NULL;
41325 + hotplug_slot_ops_no_const *ops = NULL;
41326 char name[SLOT_NAME_SIZE];
41327 int retval = -ENOMEM;
41328
41329 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41330 index 9c6e9bb..2916736 100644
41331 --- a/drivers/pci/pci-sysfs.c
41332 +++ b/drivers/pci/pci-sysfs.c
41333 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41334 {
41335 /* allocate attribute structure, piggyback attribute name */
41336 int name_len = write_combine ? 13 : 10;
41337 - struct bin_attribute *res_attr;
41338 + bin_attribute_no_const *res_attr;
41339 int retval;
41340
41341 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41342 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41343 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41344 {
41345 int retval;
41346 - struct bin_attribute *attr;
41347 + bin_attribute_no_const *attr;
41348
41349 /* If the device has VPD, try to expose it in sysfs. */
41350 if (dev->vpd) {
41351 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41352 {
41353 int retval;
41354 int rom_size = 0;
41355 - struct bin_attribute *attr;
41356 + bin_attribute_no_const *attr;
41357
41358 if (!sysfs_initialized)
41359 return -EACCES;
41360 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41361 index 7346ee6..41520eb 100644
41362 --- a/drivers/pci/pci.h
41363 +++ b/drivers/pci/pci.h
41364 @@ -93,7 +93,7 @@ struct pci_vpd_ops {
41365 struct pci_vpd {
41366 unsigned int len;
41367 const struct pci_vpd_ops *ops;
41368 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41369 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41370 };
41371
41372 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41373 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41374 index d320df6..ca9a8f6 100644
41375 --- a/drivers/pci/pcie/aspm.c
41376 +++ b/drivers/pci/pcie/aspm.c
41377 @@ -27,9 +27,9 @@
41378 #define MODULE_PARAM_PREFIX "pcie_aspm."
41379
41380 /* Note: those are not register definitions */
41381 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41382 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41383 -#define ASPM_STATE_L1 (4) /* L1 state */
41384 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41385 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41386 +#define ASPM_STATE_L1 (4U) /* L1 state */
41387 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41388 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41389
41390 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41391 index 563771f..4e3c368 100644
41392 --- a/drivers/pci/probe.c
41393 +++ b/drivers/pci/probe.c
41394 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41395 struct pci_bus_region region;
41396 bool bar_too_big = false, bar_disabled = false;
41397
41398 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41399 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41400
41401 /* No printks while decoding is disabled! */
41402 if (!dev->mmio_always_on) {
41403 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41404 index 0b00947..64f7c0a 100644
41405 --- a/drivers/pci/proc.c
41406 +++ b/drivers/pci/proc.c
41407 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41408 static int __init pci_proc_init(void)
41409 {
41410 struct pci_dev *dev = NULL;
41411 +
41412 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41413 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41414 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41415 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41416 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41417 +#endif
41418 +#else
41419 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41420 +#endif
41421 proc_create("devices", 0, proc_bus_pci_dir,
41422 &proc_bus_pci_dev_operations);
41423 proc_initialized = 1;
41424 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41425 index 3e5b4497..dcdfb70 100644
41426 --- a/drivers/platform/x86/chromeos_laptop.c
41427 +++ b/drivers/platform/x86/chromeos_laptop.c
41428 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41429 return 0;
41430 }
41431
41432 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41433 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41434 {
41435 .ident = "Samsung Series 5 550 - Touchpad",
41436 .matches = {
41437 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41438 index 6b22938..bc9700e 100644
41439 --- a/drivers/platform/x86/msi-laptop.c
41440 +++ b/drivers/platform/x86/msi-laptop.c
41441 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41442
41443 if (!quirks->ec_read_only) {
41444 /* allow userland write sysfs file */
41445 - dev_attr_bluetooth.store = store_bluetooth;
41446 - dev_attr_wlan.store = store_wlan;
41447 - dev_attr_threeg.store = store_threeg;
41448 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41449 - dev_attr_wlan.attr.mode |= S_IWUSR;
41450 - dev_attr_threeg.attr.mode |= S_IWUSR;
41451 + pax_open_kernel();
41452 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41453 + *(void **)&dev_attr_wlan.store = store_wlan;
41454 + *(void **)&dev_attr_threeg.store = store_threeg;
41455 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41456 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41457 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41458 + pax_close_kernel();
41459 }
41460
41461 /* disable hardware control by fn key */
41462 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41463 index 14d4dce..b129917 100644
41464 --- a/drivers/platform/x86/sony-laptop.c
41465 +++ b/drivers/platform/x86/sony-laptop.c
41466 @@ -2465,7 +2465,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41467 }
41468
41469 /* High speed charging function */
41470 -static struct device_attribute *hsc_handle;
41471 +static device_attribute_no_const *hsc_handle;
41472
41473 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41474 struct device_attribute *attr,
41475 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41476 index edec135..59a24a3 100644
41477 --- a/drivers/platform/x86/thinkpad_acpi.c
41478 +++ b/drivers/platform/x86/thinkpad_acpi.c
41479 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41480 return 0;
41481 }
41482
41483 -void static hotkey_mask_warn_incomplete_mask(void)
41484 +static void hotkey_mask_warn_incomplete_mask(void)
41485 {
41486 /* log only what the user can fix... */
41487 const u32 wantedmask = hotkey_driver_mask &
41488 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41489 }
41490 }
41491
41492 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41493 - struct tp_nvram_state *newn,
41494 - const u32 event_mask)
41495 -{
41496 -
41497 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41498 do { \
41499 if ((event_mask & (1 << __scancode)) && \
41500 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41501 tpacpi_hotkey_send_key(__scancode); \
41502 } while (0)
41503
41504 - void issue_volchange(const unsigned int oldvol,
41505 - const unsigned int newvol)
41506 - {
41507 - unsigned int i = oldvol;
41508 +static void issue_volchange(const unsigned int oldvol,
41509 + const unsigned int newvol,
41510 + const u32 event_mask)
41511 +{
41512 + unsigned int i = oldvol;
41513
41514 - while (i > newvol) {
41515 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41516 - i--;
41517 - }
41518 - while (i < newvol) {
41519 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41520 - i++;
41521 - }
41522 + while (i > newvol) {
41523 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41524 + i--;
41525 }
41526 + while (i < newvol) {
41527 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41528 + i++;
41529 + }
41530 +}
41531
41532 - void issue_brightnesschange(const unsigned int oldbrt,
41533 - const unsigned int newbrt)
41534 - {
41535 - unsigned int i = oldbrt;
41536 +static void issue_brightnesschange(const unsigned int oldbrt,
41537 + const unsigned int newbrt,
41538 + const u32 event_mask)
41539 +{
41540 + unsigned int i = oldbrt;
41541
41542 - while (i > newbrt) {
41543 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41544 - i--;
41545 - }
41546 - while (i < newbrt) {
41547 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41548 - i++;
41549 - }
41550 + while (i > newbrt) {
41551 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41552 + i--;
41553 + }
41554 + while (i < newbrt) {
41555 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41556 + i++;
41557 }
41558 +}
41559
41560 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41561 + struct tp_nvram_state *newn,
41562 + const u32 event_mask)
41563 +{
41564 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41565 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41566 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41567 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41568 oldn->volume_level != newn->volume_level) {
41569 /* recently muted, or repeated mute keypress, or
41570 * multiple presses ending in mute */
41571 - issue_volchange(oldn->volume_level, newn->volume_level);
41572 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41573 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41574 }
41575 } else {
41576 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41577 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41578 }
41579 if (oldn->volume_level != newn->volume_level) {
41580 - issue_volchange(oldn->volume_level, newn->volume_level);
41581 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41582 } else if (oldn->volume_toggle != newn->volume_toggle) {
41583 /* repeated vol up/down keypress at end of scale ? */
41584 if (newn->volume_level == 0)
41585 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41586 /* handle brightness */
41587 if (oldn->brightness_level != newn->brightness_level) {
41588 issue_brightnesschange(oldn->brightness_level,
41589 - newn->brightness_level);
41590 + newn->brightness_level,
41591 + event_mask);
41592 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41593 /* repeated key presses that didn't change state */
41594 if (newn->brightness_level == 0)
41595 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41596 && !tp_features.bright_unkfw)
41597 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41598 }
41599 +}
41600
41601 #undef TPACPI_COMPARE_KEY
41602 #undef TPACPI_MAY_SEND_KEY
41603 -}
41604
41605 /*
41606 * Polling driver
41607 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41608 index 769d265..a3a05ca 100644
41609 --- a/drivers/pnp/pnpbios/bioscalls.c
41610 +++ b/drivers/pnp/pnpbios/bioscalls.c
41611 @@ -58,7 +58,7 @@ do { \
41612 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41613 } while(0)
41614
41615 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41616 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41617 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41618
41619 /*
41620 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41621
41622 cpu = get_cpu();
41623 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41624 +
41625 + pax_open_kernel();
41626 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41627 + pax_close_kernel();
41628
41629 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41630 spin_lock_irqsave(&pnp_bios_lock, flags);
41631 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41632 :"memory");
41633 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41634
41635 + pax_open_kernel();
41636 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41637 + pax_close_kernel();
41638 +
41639 put_cpu();
41640
41641 /* If we get here and this is set then the PnP BIOS faulted on us. */
41642 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41643 return status;
41644 }
41645
41646 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41647 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41648 {
41649 int i;
41650
41651 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41652 pnp_bios_callpoint.offset = header->fields.pm16offset;
41653 pnp_bios_callpoint.segment = PNP_CS16;
41654
41655 + pax_open_kernel();
41656 +
41657 for_each_possible_cpu(i) {
41658 struct desc_struct *gdt = get_cpu_gdt_table(i);
41659 if (!gdt)
41660 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41661 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41662 (unsigned long)__va(header->fields.pm16dseg));
41663 }
41664 +
41665 + pax_close_kernel();
41666 }
41667 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41668 index 3e6db1c..1fbbdae 100644
41669 --- a/drivers/pnp/resource.c
41670 +++ b/drivers/pnp/resource.c
41671 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41672 return 1;
41673
41674 /* check if the resource is valid */
41675 - if (*irq < 0 || *irq > 15)
41676 + if (*irq > 15)
41677 return 0;
41678
41679 /* check if the resource is reserved */
41680 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41681 return 1;
41682
41683 /* check if the resource is valid */
41684 - if (*dma < 0 || *dma == 4 || *dma > 7)
41685 + if (*dma == 4 || *dma > 7)
41686 return 0;
41687
41688 /* check if the resource is reserved */
41689 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41690 index 7df7c5f..bd48c47 100644
41691 --- a/drivers/power/pda_power.c
41692 +++ b/drivers/power/pda_power.c
41693 @@ -37,7 +37,11 @@ static int polling;
41694
41695 #ifdef CONFIG_USB_OTG_UTILS
41696 static struct usb_phy *transceiver;
41697 -static struct notifier_block otg_nb;
41698 +static int otg_handle_notification(struct notifier_block *nb,
41699 + unsigned long event, void *unused);
41700 +static struct notifier_block otg_nb = {
41701 + .notifier_call = otg_handle_notification
41702 +};
41703 #endif
41704
41705 static struct regulator *ac_draw;
41706 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41707
41708 #ifdef CONFIG_USB_OTG_UTILS
41709 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41710 - otg_nb.notifier_call = otg_handle_notification;
41711 ret = usb_register_notifier(transceiver, &otg_nb);
41712 if (ret) {
41713 dev_err(dev, "failure to register otg notifier\n");
41714 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41715 index cc439fd..8fa30df 100644
41716 --- a/drivers/power/power_supply.h
41717 +++ b/drivers/power/power_supply.h
41718 @@ -16,12 +16,12 @@ struct power_supply;
41719
41720 #ifdef CONFIG_SYSFS
41721
41722 -extern void power_supply_init_attrs(struct device_type *dev_type);
41723 +extern void power_supply_init_attrs(void);
41724 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41725
41726 #else
41727
41728 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41729 +static inline void power_supply_init_attrs(void) {}
41730 #define power_supply_uevent NULL
41731
41732 #endif /* CONFIG_SYSFS */
41733 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41734 index 5deac43..608c5ff 100644
41735 --- a/drivers/power/power_supply_core.c
41736 +++ b/drivers/power/power_supply_core.c
41737 @@ -24,7 +24,10 @@
41738 struct class *power_supply_class;
41739 EXPORT_SYMBOL_GPL(power_supply_class);
41740
41741 -static struct device_type power_supply_dev_type;
41742 +extern const struct attribute_group *power_supply_attr_groups[];
41743 +static struct device_type power_supply_dev_type = {
41744 + .groups = power_supply_attr_groups,
41745 +};
41746
41747 static int __power_supply_changed_work(struct device *dev, void *data)
41748 {
41749 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41750 return PTR_ERR(power_supply_class);
41751
41752 power_supply_class->dev_uevent = power_supply_uevent;
41753 - power_supply_init_attrs(&power_supply_dev_type);
41754 + power_supply_init_attrs();
41755
41756 return 0;
41757 }
41758 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41759 index 29178f7..c65f324 100644
41760 --- a/drivers/power/power_supply_sysfs.c
41761 +++ b/drivers/power/power_supply_sysfs.c
41762 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
41763 .is_visible = power_supply_attr_is_visible,
41764 };
41765
41766 -static const struct attribute_group *power_supply_attr_groups[] = {
41767 +const struct attribute_group *power_supply_attr_groups[] = {
41768 &power_supply_attr_group,
41769 NULL,
41770 };
41771
41772 -void power_supply_init_attrs(struct device_type *dev_type)
41773 +void power_supply_init_attrs(void)
41774 {
41775 int i;
41776
41777 - dev_type->groups = power_supply_attr_groups;
41778 -
41779 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41780 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41781 }
41782 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41783 index 4d7c635..9860196 100644
41784 --- a/drivers/regulator/max8660.c
41785 +++ b/drivers/regulator/max8660.c
41786 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41787 max8660->shadow_regs[MAX8660_OVER1] = 5;
41788 } else {
41789 /* Otherwise devices can be toggled via software */
41790 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41791 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41792 + pax_open_kernel();
41793 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41794 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41795 + pax_close_kernel();
41796 }
41797
41798 /*
41799 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41800 index 9a8ea91..c483dd9 100644
41801 --- a/drivers/regulator/max8973-regulator.c
41802 +++ b/drivers/regulator/max8973-regulator.c
41803 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41804 if (!pdata->enable_ext_control) {
41805 max->desc.enable_reg = MAX8973_VOUT;
41806 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41807 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41808 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41809 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41810 + pax_open_kernel();
41811 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41812 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41813 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41814 + pax_close_kernel();
41815 }
41816
41817 max->enable_external_control = pdata->enable_ext_control;
41818 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41819 index 9891aec..beb3083 100644
41820 --- a/drivers/regulator/mc13892-regulator.c
41821 +++ b/drivers/regulator/mc13892-regulator.c
41822 @@ -583,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41823 }
41824 mc13xxx_unlock(mc13892);
41825
41826 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41827 + pax_open_kernel();
41828 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41829 = mc13892_vcam_set_mode;
41830 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41831 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41832 = mc13892_vcam_get_mode;
41833 + pax_close_kernel();
41834
41835 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41836 ARRAY_SIZE(mc13892_regulators),
41837 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41838 index cc5bea9..689f7d9 100644
41839 --- a/drivers/rtc/rtc-cmos.c
41840 +++ b/drivers/rtc/rtc-cmos.c
41841 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41842 hpet_rtc_timer_init();
41843
41844 /* export at least the first block of NVRAM */
41845 - nvram.size = address_space - NVRAM_OFFSET;
41846 + pax_open_kernel();
41847 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41848 + pax_close_kernel();
41849 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41850 if (retval < 0) {
41851 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41852 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41853 index d049393..bb20be0 100644
41854 --- a/drivers/rtc/rtc-dev.c
41855 +++ b/drivers/rtc/rtc-dev.c
41856 @@ -16,6 +16,7 @@
41857 #include <linux/module.h>
41858 #include <linux/rtc.h>
41859 #include <linux/sched.h>
41860 +#include <linux/grsecurity.h>
41861 #include "rtc-core.h"
41862
41863 static dev_t rtc_devt;
41864 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
41865 if (copy_from_user(&tm, uarg, sizeof(tm)))
41866 return -EFAULT;
41867
41868 + gr_log_timechange();
41869 +
41870 return rtc_set_time(rtc, &tm);
41871
41872 case RTC_PIE_ON:
41873 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41874 index 970a236..3613169 100644
41875 --- a/drivers/rtc/rtc-ds1307.c
41876 +++ b/drivers/rtc/rtc-ds1307.c
41877 @@ -106,7 +106,7 @@ struct ds1307 {
41878 u8 offset; /* register's offset */
41879 u8 regs[11];
41880 u16 nvram_offset;
41881 - struct bin_attribute *nvram;
41882 + bin_attribute_no_const *nvram;
41883 enum ds_type type;
41884 unsigned long flags;
41885 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41886 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41887 index 130f29a..6179d03 100644
41888 --- a/drivers/rtc/rtc-m48t59.c
41889 +++ b/drivers/rtc/rtc-m48t59.c
41890 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41891 goto out;
41892 }
41893
41894 - m48t59_nvram_attr.size = pdata->offset;
41895 + pax_open_kernel();
41896 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41897 + pax_close_kernel();
41898
41899 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41900 if (ret) {
41901 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41902 index e693af6..2e525b6 100644
41903 --- a/drivers/scsi/bfa/bfa_fcpim.h
41904 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41905 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41906
41907 struct bfa_itn_s {
41908 bfa_isr_func_t isr;
41909 -};
41910 +} __no_const;
41911
41912 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41913 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41914 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41915 index 23a90e7..9cf04ee 100644
41916 --- a/drivers/scsi/bfa/bfa_ioc.h
41917 +++ b/drivers/scsi/bfa/bfa_ioc.h
41918 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41919 bfa_ioc_disable_cbfn_t disable_cbfn;
41920 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41921 bfa_ioc_reset_cbfn_t reset_cbfn;
41922 -};
41923 +} __no_const;
41924
41925 /*
41926 * IOC event notification mechanism.
41927 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41928 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41929 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41930 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41931 -};
41932 +} __no_const;
41933
41934 /*
41935 * Queue element to wait for room in request queue. FIFO order is
41936 diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
41937 index 439c012..b63d534 100644
41938 --- a/drivers/scsi/bfa/bfad_debugfs.c
41939 +++ b/drivers/scsi/bfa/bfad_debugfs.c
41940 @@ -186,7 +186,7 @@ bfad_debugfs_lseek(struct file *file, loff_t offset, int orig)
41941 file->f_pos += offset;
41942 break;
41943 case 2:
41944 - file->f_pos = debug->buffer_len - offset;
41945 + file->f_pos = debug->buffer_len + offset;
41946 break;
41947 default:
41948 return -EINVAL;
41949 diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
41950 index adc1f7f..85e1ffd 100644
41951 --- a/drivers/scsi/fnic/fnic_debugfs.c
41952 +++ b/drivers/scsi/fnic/fnic_debugfs.c
41953 @@ -174,7 +174,7 @@ static loff_t fnic_trace_debugfs_lseek(struct file *file,
41954 pos = file->f_pos + offset;
41955 break;
41956 case 2:
41957 - pos = fnic_dbg_prt->buffer_len - offset;
41958 + pos = fnic_dbg_prt->buffer_len + offset;
41959 }
41960 return (pos < 0 || pos > fnic_dbg_prt->buffer_len) ?
41961 -EINVAL : (file->f_pos = pos);
41962 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41963 index df0c3c7..b00e1d0 100644
41964 --- a/drivers/scsi/hosts.c
41965 +++ b/drivers/scsi/hosts.c
41966 @@ -42,7 +42,7 @@
41967 #include "scsi_logging.h"
41968
41969
41970 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41971 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41972
41973
41974 static void scsi_host_cls_release(struct device *dev)
41975 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41976 * subtract one because we increment first then return, but we need to
41977 * know what the next host number was before increment
41978 */
41979 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41980 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41981 shost->dma_channel = 0xff;
41982
41983 /* These three are default values which can be overridden */
41984 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41985 index 7f4f790..b75b92a 100644
41986 --- a/drivers/scsi/hpsa.c
41987 +++ b/drivers/scsi/hpsa.c
41988 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41989 unsigned long flags;
41990
41991 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41992 - return h->access.command_completed(h, q);
41993 + return h->access->command_completed(h, q);
41994
41995 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41996 a = rq->head[rq->current_entry];
41997 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
41998 while (!list_empty(&h->reqQ)) {
41999 c = list_entry(h->reqQ.next, struct CommandList, list);
42000 /* can't do anything if fifo is full */
42001 - if ((h->access.fifo_full(h))) {
42002 + if ((h->access->fifo_full(h))) {
42003 dev_warn(&h->pdev->dev, "fifo full\n");
42004 break;
42005 }
42006 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
42007
42008 /* Tell the controller execute command */
42009 spin_unlock_irqrestore(&h->lock, flags);
42010 - h->access.submit_command(h, c);
42011 + h->access->submit_command(h, c);
42012 spin_lock_irqsave(&h->lock, flags);
42013 }
42014 spin_unlock_irqrestore(&h->lock, flags);
42015 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
42016
42017 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42018 {
42019 - return h->access.command_completed(h, q);
42020 + return h->access->command_completed(h, q);
42021 }
42022
42023 static inline bool interrupt_pending(struct ctlr_info *h)
42024 {
42025 - return h->access.intr_pending(h);
42026 + return h->access->intr_pending(h);
42027 }
42028
42029 static inline long interrupt_not_for_us(struct ctlr_info *h)
42030 {
42031 - return (h->access.intr_pending(h) == 0) ||
42032 + return (h->access->intr_pending(h) == 0) ||
42033 (h->interrupts_enabled == 0);
42034 }
42035
42036 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42037 if (prod_index < 0)
42038 return -ENODEV;
42039 h->product_name = products[prod_index].product_name;
42040 - h->access = *(products[prod_index].access);
42041 + h->access = products[prod_index].access;
42042
42043 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42044 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42045 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42046
42047 assert_spin_locked(&lockup_detector_lock);
42048 remove_ctlr_from_lockup_detector_list(h);
42049 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42050 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42051 spin_lock_irqsave(&h->lock, flags);
42052 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42053 spin_unlock_irqrestore(&h->lock, flags);
42054 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
42055 }
42056
42057 /* make sure the board interrupts are off */
42058 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42059 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42060
42061 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42062 goto clean2;
42063 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
42064 * fake ones to scoop up any residual completions.
42065 */
42066 spin_lock_irqsave(&h->lock, flags);
42067 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42068 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42069 spin_unlock_irqrestore(&h->lock, flags);
42070 free_irqs(h);
42071 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42072 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
42073 dev_info(&h->pdev->dev, "Board READY.\n");
42074 dev_info(&h->pdev->dev,
42075 "Waiting for stale completions to drain.\n");
42076 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42077 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42078 msleep(10000);
42079 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42080 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42081
42082 rc = controller_reset_failed(h->cfgtable);
42083 if (rc)
42084 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
42085 }
42086
42087 /* Turn the interrupts on so we can service requests */
42088 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42089 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42090
42091 hpsa_hba_inquiry(h);
42092 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42093 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42094 * To write all data in the battery backed cache to disks
42095 */
42096 hpsa_flush_cache(h);
42097 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42098 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42099 hpsa_free_irqs_and_disable_msix(h);
42100 }
42101
42102 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42103 return;
42104 }
42105 /* Change the access methods to the performant access methods */
42106 - h->access = SA5_performant_access;
42107 + h->access = &SA5_performant_access;
42108 h->transMethod = CFGTBL_Trans_Performant;
42109 }
42110
42111 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42112 index 9816479..c5d4e97 100644
42113 --- a/drivers/scsi/hpsa.h
42114 +++ b/drivers/scsi/hpsa.h
42115 @@ -79,7 +79,7 @@ struct ctlr_info {
42116 unsigned int msix_vector;
42117 unsigned int msi_vector;
42118 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42119 - struct access_method access;
42120 + struct access_method *access;
42121
42122 /* queue and queue Info */
42123 struct list_head reqQ;
42124 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42125 index c772d8d..35c362c 100644
42126 --- a/drivers/scsi/libfc/fc_exch.c
42127 +++ b/drivers/scsi/libfc/fc_exch.c
42128 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42129 u16 pool_max_index;
42130
42131 struct {
42132 - atomic_t no_free_exch;
42133 - atomic_t no_free_exch_xid;
42134 - atomic_t xid_not_found;
42135 - atomic_t xid_busy;
42136 - atomic_t seq_not_found;
42137 - atomic_t non_bls_resp;
42138 + atomic_unchecked_t no_free_exch;
42139 + atomic_unchecked_t no_free_exch_xid;
42140 + atomic_unchecked_t xid_not_found;
42141 + atomic_unchecked_t xid_busy;
42142 + atomic_unchecked_t seq_not_found;
42143 + atomic_unchecked_t non_bls_resp;
42144 } stats;
42145 };
42146
42147 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42148 /* allocate memory for exchange */
42149 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42150 if (!ep) {
42151 - atomic_inc(&mp->stats.no_free_exch);
42152 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42153 goto out;
42154 }
42155 memset(ep, 0, sizeof(*ep));
42156 @@ -786,7 +786,7 @@ out:
42157 return ep;
42158 err:
42159 spin_unlock_bh(&pool->lock);
42160 - atomic_inc(&mp->stats.no_free_exch_xid);
42161 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42162 mempool_free(ep, mp->ep_pool);
42163 return NULL;
42164 }
42165 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42166 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42167 ep = fc_exch_find(mp, xid);
42168 if (!ep) {
42169 - atomic_inc(&mp->stats.xid_not_found);
42170 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42171 reject = FC_RJT_OX_ID;
42172 goto out;
42173 }
42174 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42175 ep = fc_exch_find(mp, xid);
42176 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42177 if (ep) {
42178 - atomic_inc(&mp->stats.xid_busy);
42179 + atomic_inc_unchecked(&mp->stats.xid_busy);
42180 reject = FC_RJT_RX_ID;
42181 goto rel;
42182 }
42183 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42184 }
42185 xid = ep->xid; /* get our XID */
42186 } else if (!ep) {
42187 - atomic_inc(&mp->stats.xid_not_found);
42188 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42189 reject = FC_RJT_RX_ID; /* XID not found */
42190 goto out;
42191 }
42192 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42193 } else {
42194 sp = &ep->seq;
42195 if (sp->id != fh->fh_seq_id) {
42196 - atomic_inc(&mp->stats.seq_not_found);
42197 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42198 if (f_ctl & FC_FC_END_SEQ) {
42199 /*
42200 * Update sequence_id based on incoming last
42201 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42202
42203 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42204 if (!ep) {
42205 - atomic_inc(&mp->stats.xid_not_found);
42206 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42207 goto out;
42208 }
42209 if (ep->esb_stat & ESB_ST_COMPLETE) {
42210 - atomic_inc(&mp->stats.xid_not_found);
42211 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42212 goto rel;
42213 }
42214 if (ep->rxid == FC_XID_UNKNOWN)
42215 ep->rxid = ntohs(fh->fh_rx_id);
42216 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42217 - atomic_inc(&mp->stats.xid_not_found);
42218 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42219 goto rel;
42220 }
42221 if (ep->did != ntoh24(fh->fh_s_id) &&
42222 ep->did != FC_FID_FLOGI) {
42223 - atomic_inc(&mp->stats.xid_not_found);
42224 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42225 goto rel;
42226 }
42227 sof = fr_sof(fp);
42228 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42229 sp->ssb_stat |= SSB_ST_RESP;
42230 sp->id = fh->fh_seq_id;
42231 } else if (sp->id != fh->fh_seq_id) {
42232 - atomic_inc(&mp->stats.seq_not_found);
42233 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42234 goto rel;
42235 }
42236
42237 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42238 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42239
42240 if (!sp)
42241 - atomic_inc(&mp->stats.xid_not_found);
42242 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42243 else
42244 - atomic_inc(&mp->stats.non_bls_resp);
42245 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42246
42247 fc_frame_free(fp);
42248 }
42249 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42250
42251 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42252 mp = ema->mp;
42253 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42254 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42255 st->fc_no_free_exch_xid +=
42256 - atomic_read(&mp->stats.no_free_exch_xid);
42257 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42258 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42259 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42260 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42261 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42262 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42263 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42264 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42265 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42266 }
42267 }
42268 EXPORT_SYMBOL(fc_exch_update_stats);
42269 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42270 index bdb81cd..d3c7c2c 100644
42271 --- a/drivers/scsi/libsas/sas_ata.c
42272 +++ b/drivers/scsi/libsas/sas_ata.c
42273 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42274 .postreset = ata_std_postreset,
42275 .error_handler = ata_std_error_handler,
42276 .post_internal_cmd = sas_ata_post_internal,
42277 - .qc_defer = ata_std_qc_defer,
42278 + .qc_defer = ata_std_qc_defer,
42279 .qc_prep = ata_noop_qc_prep,
42280 .qc_issue = sas_ata_qc_issue,
42281 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42282 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42283 index 7706c99..3b4fc0c 100644
42284 --- a/drivers/scsi/lpfc/lpfc.h
42285 +++ b/drivers/scsi/lpfc/lpfc.h
42286 @@ -424,7 +424,7 @@ struct lpfc_vport {
42287 struct dentry *debug_nodelist;
42288 struct dentry *vport_debugfs_root;
42289 struct lpfc_debugfs_trc *disc_trc;
42290 - atomic_t disc_trc_cnt;
42291 + atomic_unchecked_t disc_trc_cnt;
42292 #endif
42293 uint8_t stat_data_enabled;
42294 uint8_t stat_data_blocked;
42295 @@ -853,8 +853,8 @@ struct lpfc_hba {
42296 struct timer_list fabric_block_timer;
42297 unsigned long bit_flags;
42298 #define FABRIC_COMANDS_BLOCKED 0
42299 - atomic_t num_rsrc_err;
42300 - atomic_t num_cmd_success;
42301 + atomic_unchecked_t num_rsrc_err;
42302 + atomic_unchecked_t num_cmd_success;
42303 unsigned long last_rsrc_error_time;
42304 unsigned long last_ramp_down_time;
42305 unsigned long last_ramp_up_time;
42306 @@ -890,7 +890,7 @@ struct lpfc_hba {
42307
42308 struct dentry *debug_slow_ring_trc;
42309 struct lpfc_debugfs_trc *slow_ring_trc;
42310 - atomic_t slow_ring_trc_cnt;
42311 + atomic_unchecked_t slow_ring_trc_cnt;
42312 /* iDiag debugfs sub-directory */
42313 struct dentry *idiag_root;
42314 struct dentry *idiag_pci_cfg;
42315 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42316 index f63f5ff..32549a4 100644
42317 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42318 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42319 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42320
42321 #include <linux/debugfs.h>
42322
42323 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42324 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42325 static unsigned long lpfc_debugfs_start_time = 0L;
42326
42327 /* iDiag */
42328 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42329 lpfc_debugfs_enable = 0;
42330
42331 len = 0;
42332 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42333 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42334 (lpfc_debugfs_max_disc_trc - 1);
42335 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42336 dtp = vport->disc_trc + i;
42337 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42338 lpfc_debugfs_enable = 0;
42339
42340 len = 0;
42341 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42342 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42343 (lpfc_debugfs_max_slow_ring_trc - 1);
42344 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42345 dtp = phba->slow_ring_trc + i;
42346 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42347 !vport || !vport->disc_trc)
42348 return;
42349
42350 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42351 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42352 (lpfc_debugfs_max_disc_trc - 1);
42353 dtp = vport->disc_trc + index;
42354 dtp->fmt = fmt;
42355 dtp->data1 = data1;
42356 dtp->data2 = data2;
42357 dtp->data3 = data3;
42358 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42359 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42360 dtp->jif = jiffies;
42361 #endif
42362 return;
42363 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42364 !phba || !phba->slow_ring_trc)
42365 return;
42366
42367 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42368 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42369 (lpfc_debugfs_max_slow_ring_trc - 1);
42370 dtp = phba->slow_ring_trc + index;
42371 dtp->fmt = fmt;
42372 dtp->data1 = data1;
42373 dtp->data2 = data2;
42374 dtp->data3 = data3;
42375 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42376 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42377 dtp->jif = jiffies;
42378 #endif
42379 return;
42380 @@ -1178,7 +1178,7 @@ lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
42381 pos = file->f_pos + off;
42382 break;
42383 case 2:
42384 - pos = debug->len - off;
42385 + pos = debug->len + off;
42386 }
42387 return (pos < 0 || pos > debug->len) ? -EINVAL : (file->f_pos = pos);
42388 }
42389 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42390 "slow_ring buffer\n");
42391 goto debug_failed;
42392 }
42393 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42394 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42395 memset(phba->slow_ring_trc, 0,
42396 (sizeof(struct lpfc_debugfs_trc) *
42397 lpfc_debugfs_max_slow_ring_trc));
42398 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42399 "buffer\n");
42400 goto debug_failed;
42401 }
42402 - atomic_set(&vport->disc_trc_cnt, 0);
42403 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42404
42405 snprintf(name, sizeof(name), "discovery_trace");
42406 vport->debug_disc_trc =
42407 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42408 index 314b4f6..7005d10 100644
42409 --- a/drivers/scsi/lpfc/lpfc_init.c
42410 +++ b/drivers/scsi/lpfc/lpfc_init.c
42411 @@ -10551,8 +10551,10 @@ lpfc_init(void)
42412 "misc_register returned with status %d", error);
42413
42414 if (lpfc_enable_npiv) {
42415 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42416 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42417 + pax_open_kernel();
42418 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42419 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42420 + pax_close_kernel();
42421 }
42422 lpfc_transport_template =
42423 fc_attach_transport(&lpfc_transport_functions);
42424 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42425 index 98af07c..7625fb5 100644
42426 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42427 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42428 @@ -325,7 +325,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42429 uint32_t evt_posted;
42430
42431 spin_lock_irqsave(&phba->hbalock, flags);
42432 - atomic_inc(&phba->num_rsrc_err);
42433 + atomic_inc_unchecked(&phba->num_rsrc_err);
42434 phba->last_rsrc_error_time = jiffies;
42435
42436 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42437 @@ -366,7 +366,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42438 unsigned long flags;
42439 struct lpfc_hba *phba = vport->phba;
42440 uint32_t evt_posted;
42441 - atomic_inc(&phba->num_cmd_success);
42442 + atomic_inc_unchecked(&phba->num_cmd_success);
42443
42444 if (vport->cfg_lun_queue_depth <= queue_depth)
42445 return;
42446 @@ -410,8 +410,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42447 unsigned long num_rsrc_err, num_cmd_success;
42448 int i;
42449
42450 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42451 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42452 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42453 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42454
42455 /*
42456 * The error and success command counters are global per
42457 @@ -439,8 +439,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42458 }
42459 }
42460 lpfc_destroy_vport_work_array(phba, vports);
42461 - atomic_set(&phba->num_rsrc_err, 0);
42462 - atomic_set(&phba->num_cmd_success, 0);
42463 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42464 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42465 }
42466
42467 /**
42468 @@ -474,8 +474,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42469 }
42470 }
42471 lpfc_destroy_vport_work_array(phba, vports);
42472 - atomic_set(&phba->num_rsrc_err, 0);
42473 - atomic_set(&phba->num_cmd_success, 0);
42474 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42475 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42476 }
42477
42478 /**
42479 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42480 index b46f5e9..c4c4ccb 100644
42481 --- a/drivers/scsi/pmcraid.c
42482 +++ b/drivers/scsi/pmcraid.c
42483 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42484 res->scsi_dev = scsi_dev;
42485 scsi_dev->hostdata = res;
42486 res->change_detected = 0;
42487 - atomic_set(&res->read_failures, 0);
42488 - atomic_set(&res->write_failures, 0);
42489 + atomic_set_unchecked(&res->read_failures, 0);
42490 + atomic_set_unchecked(&res->write_failures, 0);
42491 rc = 0;
42492 }
42493 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42494 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42495
42496 /* If this was a SCSI read/write command keep count of errors */
42497 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42498 - atomic_inc(&res->read_failures);
42499 + atomic_inc_unchecked(&res->read_failures);
42500 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42501 - atomic_inc(&res->write_failures);
42502 + atomic_inc_unchecked(&res->write_failures);
42503
42504 if (!RES_IS_GSCSI(res->cfg_entry) &&
42505 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42506 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42507 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42508 * hrrq_id assigned here in queuecommand
42509 */
42510 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42511 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42512 pinstance->num_hrrq;
42513 cmd->cmd_done = pmcraid_io_done;
42514
42515 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42516 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42517 * hrrq_id assigned here in queuecommand
42518 */
42519 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42520 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42521 pinstance->num_hrrq;
42522
42523 if (request_size) {
42524 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42525
42526 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42527 /* add resources only after host is added into system */
42528 - if (!atomic_read(&pinstance->expose_resources))
42529 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42530 return;
42531
42532 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42533 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42534 init_waitqueue_head(&pinstance->reset_wait_q);
42535
42536 atomic_set(&pinstance->outstanding_cmds, 0);
42537 - atomic_set(&pinstance->last_message_id, 0);
42538 - atomic_set(&pinstance->expose_resources, 0);
42539 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42540 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42541
42542 INIT_LIST_HEAD(&pinstance->free_res_q);
42543 INIT_LIST_HEAD(&pinstance->used_res_q);
42544 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42545 /* Schedule worker thread to handle CCN and take care of adding and
42546 * removing devices to OS
42547 */
42548 - atomic_set(&pinstance->expose_resources, 1);
42549 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42550 schedule_work(&pinstance->worker_q);
42551 return rc;
42552
42553 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42554 index e1d150f..6c6df44 100644
42555 --- a/drivers/scsi/pmcraid.h
42556 +++ b/drivers/scsi/pmcraid.h
42557 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42558 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42559
42560 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42561 - atomic_t last_message_id;
42562 + atomic_unchecked_t last_message_id;
42563
42564 /* configuration table */
42565 struct pmcraid_config_table *cfg_table;
42566 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42567 atomic_t outstanding_cmds;
42568
42569 /* should add/delete resources to mid-layer now ?*/
42570 - atomic_t expose_resources;
42571 + atomic_unchecked_t expose_resources;
42572
42573
42574
42575 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42576 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42577 };
42578 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42579 - atomic_t read_failures; /* count of failed READ commands */
42580 - atomic_t write_failures; /* count of failed WRITE commands */
42581 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42582 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42583
42584 /* To indicate add/delete/modify during CCN */
42585 u8 change_detected;
42586 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42587 index b3db9dc..c3b1756 100644
42588 --- a/drivers/scsi/qla2xxx/qla_attr.c
42589 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42590 @@ -1971,7 +1971,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42591 return 0;
42592 }
42593
42594 -struct fc_function_template qla2xxx_transport_functions = {
42595 +fc_function_template_no_const qla2xxx_transport_functions = {
42596
42597 .show_host_node_name = 1,
42598 .show_host_port_name = 1,
42599 @@ -2018,7 +2018,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42600 .bsg_timeout = qla24xx_bsg_timeout,
42601 };
42602
42603 -struct fc_function_template qla2xxx_transport_vport_functions = {
42604 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42605
42606 .show_host_node_name = 1,
42607 .show_host_port_name = 1,
42608 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42609 index b310fa9..b9b3944 100644
42610 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42611 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42612 @@ -523,8 +523,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42613 struct device_attribute;
42614 extern struct device_attribute *qla2x00_host_attrs[];
42615 struct fc_function_template;
42616 -extern struct fc_function_template qla2xxx_transport_functions;
42617 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42618 +extern fc_function_template_no_const qla2xxx_transport_functions;
42619 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42620 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42621 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42622 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42623 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42624 index 2c6dd3d..e5ecd82 100644
42625 --- a/drivers/scsi/qla2xxx/qla_os.c
42626 +++ b/drivers/scsi/qla2xxx/qla_os.c
42627 @@ -1554,8 +1554,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42628 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42629 /* Ok, a 64bit DMA mask is applicable. */
42630 ha->flags.enable_64bit_addressing = 1;
42631 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42632 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42633 + pax_open_kernel();
42634 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42635 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42636 + pax_close_kernel();
42637 return;
42638 }
42639 }
42640 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42641 index 129f5dd..ade53e8 100644
42642 --- a/drivers/scsi/qla4xxx/ql4_def.h
42643 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42644 @@ -275,7 +275,7 @@ struct ddb_entry {
42645 * (4000 only) */
42646 atomic_t relogin_timer; /* Max Time to wait for
42647 * relogin to complete */
42648 - atomic_t relogin_retry_count; /* Num of times relogin has been
42649 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42650 * retried */
42651 uint32_t default_time2wait; /* Default Min time between
42652 * relogins (+aens) */
42653 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42654 index 6142729..b6a85c9 100644
42655 --- a/drivers/scsi/qla4xxx/ql4_os.c
42656 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42657 @@ -2622,12 +2622,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42658 */
42659 if (!iscsi_is_session_online(cls_sess)) {
42660 /* Reset retry relogin timer */
42661 - atomic_inc(&ddb_entry->relogin_retry_count);
42662 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42663 DEBUG2(ql4_printk(KERN_INFO, ha,
42664 "%s: index[%d] relogin timed out-retrying"
42665 " relogin (%d), retry (%d)\n", __func__,
42666 ddb_entry->fw_ddb_index,
42667 - atomic_read(&ddb_entry->relogin_retry_count),
42668 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42669 ddb_entry->default_time2wait + 4));
42670 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42671 atomic_set(&ddb_entry->retry_relogin_timer,
42672 @@ -4742,7 +4742,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42673
42674 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42675 atomic_set(&ddb_entry->relogin_timer, 0);
42676 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42677 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42678 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42679 ddb_entry->default_relogin_timeout =
42680 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42681 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42682 index 2c0d0ec..4e8681a 100644
42683 --- a/drivers/scsi/scsi.c
42684 +++ b/drivers/scsi/scsi.c
42685 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42686 unsigned long timeout;
42687 int rtn = 0;
42688
42689 - atomic_inc(&cmd->device->iorequest_cnt);
42690 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42691
42692 /* check if the device is still usable */
42693 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42694 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42695 index c31187d..0ead8c3 100644
42696 --- a/drivers/scsi/scsi_lib.c
42697 +++ b/drivers/scsi/scsi_lib.c
42698 @@ -1459,7 +1459,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42699 shost = sdev->host;
42700 scsi_init_cmd_errh(cmd);
42701 cmd->result = DID_NO_CONNECT << 16;
42702 - atomic_inc(&cmd->device->iorequest_cnt);
42703 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42704
42705 /*
42706 * SCSI request completion path will do scsi_device_unbusy(),
42707 @@ -1485,9 +1485,9 @@ static void scsi_softirq_done(struct request *rq)
42708
42709 INIT_LIST_HEAD(&cmd->eh_entry);
42710
42711 - atomic_inc(&cmd->device->iodone_cnt);
42712 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42713 if (cmd->result)
42714 - atomic_inc(&cmd->device->ioerr_cnt);
42715 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42716
42717 disposition = scsi_decide_disposition(cmd);
42718 if (disposition != SUCCESS &&
42719 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42720 index 931a7d9..0c2a754 100644
42721 --- a/drivers/scsi/scsi_sysfs.c
42722 +++ b/drivers/scsi/scsi_sysfs.c
42723 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42724 char *buf) \
42725 { \
42726 struct scsi_device *sdev = to_scsi_device(dev); \
42727 - unsigned long long count = atomic_read(&sdev->field); \
42728 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42729 return snprintf(buf, 20, "0x%llx\n", count); \
42730 } \
42731 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42732 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42733 index 84a1fdf..693b0d6 100644
42734 --- a/drivers/scsi/scsi_tgt_lib.c
42735 +++ b/drivers/scsi/scsi_tgt_lib.c
42736 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42737 int err;
42738
42739 dprintk("%lx %u\n", uaddr, len);
42740 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42741 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42742 if (err) {
42743 /*
42744 * TODO: need to fixup sg_tablesize, max_segment_size,
42745 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42746 index e894ca7..de9d7660 100644
42747 --- a/drivers/scsi/scsi_transport_fc.c
42748 +++ b/drivers/scsi/scsi_transport_fc.c
42749 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42750 * Netlink Infrastructure
42751 */
42752
42753 -static atomic_t fc_event_seq;
42754 +static atomic_unchecked_t fc_event_seq;
42755
42756 /**
42757 * fc_get_event_number - Obtain the next sequential FC event number
42758 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42759 u32
42760 fc_get_event_number(void)
42761 {
42762 - return atomic_add_return(1, &fc_event_seq);
42763 + return atomic_add_return_unchecked(1, &fc_event_seq);
42764 }
42765 EXPORT_SYMBOL(fc_get_event_number);
42766
42767 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42768 {
42769 int error;
42770
42771 - atomic_set(&fc_event_seq, 0);
42772 + atomic_set_unchecked(&fc_event_seq, 0);
42773
42774 error = transport_class_register(&fc_host_class);
42775 if (error)
42776 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42777 char *cp;
42778
42779 *val = simple_strtoul(buf, &cp, 0);
42780 - if ((*cp && (*cp != '\n')) || (*val < 0))
42781 + if (*cp && (*cp != '\n'))
42782 return -EINVAL;
42783 /*
42784 * Check for overflow; dev_loss_tmo is u32
42785 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42786 index 0a74b97..fa8d648 100644
42787 --- a/drivers/scsi/scsi_transport_iscsi.c
42788 +++ b/drivers/scsi/scsi_transport_iscsi.c
42789 @@ -79,7 +79,7 @@ struct iscsi_internal {
42790 struct transport_container session_cont;
42791 };
42792
42793 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42794 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42795 static struct workqueue_struct *iscsi_eh_timer_workq;
42796
42797 static DEFINE_IDA(iscsi_sess_ida);
42798 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42799 int err;
42800
42801 ihost = shost->shost_data;
42802 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42803 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42804
42805 if (target_id == ISCSI_MAX_TARGET) {
42806 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42807 @@ -2955,7 +2955,7 @@ static __init int iscsi_transport_init(void)
42808 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42809 ISCSI_TRANSPORT_VERSION);
42810
42811 - atomic_set(&iscsi_session_nr, 0);
42812 + atomic_set_unchecked(&iscsi_session_nr, 0);
42813
42814 err = class_register(&iscsi_transport_class);
42815 if (err)
42816 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42817 index f379c7f..e8fc69c 100644
42818 --- a/drivers/scsi/scsi_transport_srp.c
42819 +++ b/drivers/scsi/scsi_transport_srp.c
42820 @@ -33,7 +33,7 @@
42821 #include "scsi_transport_srp_internal.h"
42822
42823 struct srp_host_attrs {
42824 - atomic_t next_port_id;
42825 + atomic_unchecked_t next_port_id;
42826 };
42827 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42828
42829 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42830 struct Scsi_Host *shost = dev_to_shost(dev);
42831 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42832
42833 - atomic_set(&srp_host->next_port_id, 0);
42834 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42835 return 0;
42836 }
42837
42838 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42839 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42840 rport->roles = ids->roles;
42841
42842 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42843 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42844 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42845
42846 transport_setup_device(&rport->dev);
42847 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42848 index 82910cc..7c350ad 100644
42849 --- a/drivers/scsi/sd.c
42850 +++ b/drivers/scsi/sd.c
42851 @@ -2929,7 +2929,7 @@ static int sd_probe(struct device *dev)
42852 sdkp->disk = gd;
42853 sdkp->index = index;
42854 atomic_set(&sdkp->openers, 0);
42855 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42856 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42857
42858 if (!sdp->request_queue->rq_timeout) {
42859 if (sdp->type != TYPE_MOD)
42860 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42861 index 9f0c465..47194ee 100644
42862 --- a/drivers/scsi/sg.c
42863 +++ b/drivers/scsi/sg.c
42864 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42865 sdp->disk->disk_name,
42866 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42867 NULL,
42868 - (char *)arg);
42869 + (char __user *)arg);
42870 case BLKTRACESTART:
42871 return blk_trace_startstop(sdp->device->request_queue, 1);
42872 case BLKTRACESTOP:
42873 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42874 index 004b10f..7c98d51 100644
42875 --- a/drivers/spi/spi.c
42876 +++ b/drivers/spi/spi.c
42877 @@ -1620,7 +1620,7 @@ int spi_bus_unlock(struct spi_master *master)
42878 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42879
42880 /* portable code must never pass more than 32 bytes */
42881 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42882 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42883
42884 static u8 *buf;
42885
42886 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42887 index 93af756..a4bc5bf 100644
42888 --- a/drivers/staging/iio/iio_hwmon.c
42889 +++ b/drivers/staging/iio/iio_hwmon.c
42890 @@ -67,7 +67,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
42891 {
42892 struct device *dev = &pdev->dev;
42893 struct iio_hwmon_state *st;
42894 - struct sensor_device_attribute *a;
42895 + sensor_device_attribute_no_const *a;
42896 int ret, i;
42897 int in_i = 1, temp_i = 1, curr_i = 1;
42898 enum iio_chan_type type;
42899 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42900 index 34afc16..ffe44dd 100644
42901 --- a/drivers/staging/octeon/ethernet-rx.c
42902 +++ b/drivers/staging/octeon/ethernet-rx.c
42903 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42904 /* Increment RX stats for virtual ports */
42905 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42906 #ifdef CONFIG_64BIT
42907 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42908 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42909 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42910 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42911 #else
42912 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42913 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42914 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42915 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42916 #endif
42917 }
42918 netif_receive_skb(skb);
42919 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42920 dev->name);
42921 */
42922 #ifdef CONFIG_64BIT
42923 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42924 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42925 #else
42926 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42927 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42928 #endif
42929 dev_kfree_skb_irq(skb);
42930 }
42931 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42932 index c3a90e7..023619a 100644
42933 --- a/drivers/staging/octeon/ethernet.c
42934 +++ b/drivers/staging/octeon/ethernet.c
42935 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42936 * since the RX tasklet also increments it.
42937 */
42938 #ifdef CONFIG_64BIT
42939 - atomic64_add(rx_status.dropped_packets,
42940 - (atomic64_t *)&priv->stats.rx_dropped);
42941 + atomic64_add_unchecked(rx_status.dropped_packets,
42942 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42943 #else
42944 - atomic_add(rx_status.dropped_packets,
42945 - (atomic_t *)&priv->stats.rx_dropped);
42946 + atomic_add_unchecked(rx_status.dropped_packets,
42947 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42948 #endif
42949 }
42950
42951 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42952 index dc23395..cf7e9b1 100644
42953 --- a/drivers/staging/rtl8712/rtl871x_io.h
42954 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42955 @@ -108,7 +108,7 @@ struct _io_ops {
42956 u8 *pmem);
42957 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42958 u8 *pmem);
42959 -};
42960 +} __no_const;
42961
42962 struct io_req {
42963 struct list_head list;
42964 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42965 index 1f5088b..0e59820 100644
42966 --- a/drivers/staging/sbe-2t3e3/netdev.c
42967 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42968 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42969 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42970
42971 if (rlen)
42972 - if (copy_to_user(data, &resp, rlen))
42973 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42974 return -EFAULT;
42975
42976 return 0;
42977 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42978 index 5dddc4d..34fcb2f 100644
42979 --- a/drivers/staging/usbip/vhci.h
42980 +++ b/drivers/staging/usbip/vhci.h
42981 @@ -83,7 +83,7 @@ struct vhci_hcd {
42982 unsigned resuming:1;
42983 unsigned long re_timeout;
42984
42985 - atomic_t seqnum;
42986 + atomic_unchecked_t seqnum;
42987
42988 /*
42989 * NOTE:
42990 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42991 index f1ca084..7b5c0c3 100644
42992 --- a/drivers/staging/usbip/vhci_hcd.c
42993 +++ b/drivers/staging/usbip/vhci_hcd.c
42994 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
42995
42996 spin_lock(&vdev->priv_lock);
42997
42998 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42999 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43000 if (priv->seqnum == 0xffff)
43001 dev_info(&urb->dev->dev, "seqnum max\n");
43002
43003 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43004 return -ENOMEM;
43005 }
43006
43007 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43008 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43009 if (unlink->seqnum == 0xffff)
43010 pr_info("seqnum max\n");
43011
43012 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
43013 vdev->rhport = rhport;
43014 }
43015
43016 - atomic_set(&vhci->seqnum, 0);
43017 + atomic_set_unchecked(&vhci->seqnum, 0);
43018 spin_lock_init(&vhci->lock);
43019
43020 hcd->power_budget = 0; /* no limit */
43021 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43022 index faf8e60..c46f8ab 100644
43023 --- a/drivers/staging/usbip/vhci_rx.c
43024 +++ b/drivers/staging/usbip/vhci_rx.c
43025 @@ -76,7 +76,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43026 if (!urb) {
43027 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43028 pr_info("max seqnum %d\n",
43029 - atomic_read(&the_controller->seqnum));
43030 + atomic_read_unchecked(&the_controller->seqnum));
43031 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43032 return;
43033 }
43034 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43035 index 5f13890..36a044b 100644
43036 --- a/drivers/staging/vt6655/hostap.c
43037 +++ b/drivers/staging/vt6655/hostap.c
43038 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
43039 *
43040 */
43041
43042 +static net_device_ops_no_const apdev_netdev_ops;
43043 +
43044 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43045 {
43046 PSDevice apdev_priv;
43047 struct net_device *dev = pDevice->dev;
43048 int ret;
43049 - const struct net_device_ops apdev_netdev_ops = {
43050 - .ndo_start_xmit = pDevice->tx_80211,
43051 - };
43052
43053 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43054
43055 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43056 *apdev_priv = *pDevice;
43057 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43058
43059 + /* only half broken now */
43060 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43061 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43062
43063 pDevice->apdev->type = ARPHRD_IEEE80211;
43064 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43065 index a94e66f..31984d0 100644
43066 --- a/drivers/staging/vt6656/hostap.c
43067 +++ b/drivers/staging/vt6656/hostap.c
43068 @@ -60,14 +60,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(struct vnt_private *pDevice, int rtnl_locked)
43075 {
43076 struct vnt_private *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 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *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/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43095 index a2b7e03..9ff4bbd 100644
43096 --- a/drivers/staging/zcache/tmem.c
43097 +++ b/drivers/staging/zcache/tmem.c
43098 @@ -50,7 +50,7 @@
43099 * A tmem host implementation must use this function to register callbacks
43100 * for memory allocation.
43101 */
43102 -static struct tmem_hostops tmem_hostops;
43103 +static tmem_hostops_no_const tmem_hostops;
43104
43105 static void tmem_objnode_tree_init(void);
43106
43107 @@ -64,7 +64,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43108 * A tmem host implementation must use this function to register
43109 * callbacks for a page-accessible memory (PAM) implementation.
43110 */
43111 -static struct tmem_pamops tmem_pamops;
43112 +static tmem_pamops_no_const tmem_pamops;
43113
43114 void tmem_register_pamops(struct tmem_pamops *m)
43115 {
43116 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43117 index adbe5a8..d387359 100644
43118 --- a/drivers/staging/zcache/tmem.h
43119 +++ b/drivers/staging/zcache/tmem.h
43120 @@ -226,6 +226,7 @@ struct tmem_pamops {
43121 int (*replace_in_obj)(void *, struct tmem_obj *);
43122 #endif
43123 };
43124 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43125 extern void tmem_register_pamops(struct tmem_pamops *m);
43126
43127 /* memory allocation methods provided by the host implementation */
43128 @@ -235,6 +236,7 @@ struct tmem_hostops {
43129 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43130 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43131 };
43132 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43133 extern void tmem_register_hostops(struct tmem_hostops *m);
43134
43135 /* core tmem accessor functions */
43136 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43137 index 2e4d655..fd72e68 100644
43138 --- a/drivers/target/target_core_device.c
43139 +++ b/drivers/target/target_core_device.c
43140 @@ -1414,7 +1414,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43141 spin_lock_init(&dev->se_port_lock);
43142 spin_lock_init(&dev->se_tmr_lock);
43143 spin_lock_init(&dev->qf_cmd_lock);
43144 - atomic_set(&dev->dev_ordered_id, 0);
43145 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43146 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43147 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43148 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43149 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43150 index fc9a5a0..1d5975e 100644
43151 --- a/drivers/target/target_core_transport.c
43152 +++ b/drivers/target/target_core_transport.c
43153 @@ -1081,7 +1081,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43154 * Used to determine when ORDERED commands should go from
43155 * Dormant to Active status.
43156 */
43157 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43158 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43159 smp_mb__after_atomic_inc();
43160 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43161 cmd->se_ordered_id, cmd->sam_task_attr,
43162 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43163 index 345bd0e..61d5375 100644
43164 --- a/drivers/tty/cyclades.c
43165 +++ b/drivers/tty/cyclades.c
43166 @@ -1576,10 +1576,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43167 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43168 info->port.count);
43169 #endif
43170 - info->port.count++;
43171 + atomic_inc(&info->port.count);
43172 #ifdef CY_DEBUG_COUNT
43173 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43174 - current->pid, info->port.count);
43175 + current->pid, atomic_read(&info->port.count));
43176 #endif
43177
43178 /*
43179 @@ -3978,7 +3978,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43180 for (j = 0; j < cy_card[i].nports; j++) {
43181 info = &cy_card[i].ports[j];
43182
43183 - if (info->port.count) {
43184 + if (atomic_read(&info->port.count)) {
43185 /* XXX is the ldisc num worth this? */
43186 struct tty_struct *tty;
43187 struct tty_ldisc *ld;
43188 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43189 index eb255e8..f637a57 100644
43190 --- a/drivers/tty/hvc/hvc_console.c
43191 +++ b/drivers/tty/hvc/hvc_console.c
43192 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43193
43194 spin_lock_irqsave(&hp->port.lock, flags);
43195 /* Check and then increment for fast path open. */
43196 - if (hp->port.count++ > 0) {
43197 + if (atomic_inc_return(&hp->port.count) > 1) {
43198 spin_unlock_irqrestore(&hp->port.lock, flags);
43199 hvc_kick();
43200 return 0;
43201 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43202
43203 spin_lock_irqsave(&hp->port.lock, flags);
43204
43205 - if (--hp->port.count == 0) {
43206 + if (atomic_dec_return(&hp->port.count) == 0) {
43207 spin_unlock_irqrestore(&hp->port.lock, flags);
43208 /* We are done with the tty pointer now. */
43209 tty_port_tty_set(&hp->port, NULL);
43210 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43211 */
43212 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43213 } else {
43214 - if (hp->port.count < 0)
43215 + if (atomic_read(&hp->port.count) < 0)
43216 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43217 - hp->vtermno, hp->port.count);
43218 + hp->vtermno, atomic_read(&hp->port.count));
43219 spin_unlock_irqrestore(&hp->port.lock, flags);
43220 }
43221 }
43222 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43223 * open->hangup case this can be called after the final close so prevent
43224 * that from happening for now.
43225 */
43226 - if (hp->port.count <= 0) {
43227 + if (atomic_read(&hp->port.count) <= 0) {
43228 spin_unlock_irqrestore(&hp->port.lock, flags);
43229 return;
43230 }
43231
43232 - hp->port.count = 0;
43233 + atomic_set(&hp->port.count, 0);
43234 spin_unlock_irqrestore(&hp->port.lock, flags);
43235 tty_port_tty_set(&hp->port, NULL);
43236
43237 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43238 return -EPIPE;
43239
43240 /* FIXME what's this (unprotected) check for? */
43241 - if (hp->port.count <= 0)
43242 + if (atomic_read(&hp->port.count) <= 0)
43243 return -EIO;
43244
43245 spin_lock_irqsave(&hp->lock, flags);
43246 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43247 index 81e939e..95ead10 100644
43248 --- a/drivers/tty/hvc/hvcs.c
43249 +++ b/drivers/tty/hvc/hvcs.c
43250 @@ -83,6 +83,7 @@
43251 #include <asm/hvcserver.h>
43252 #include <asm/uaccess.h>
43253 #include <asm/vio.h>
43254 +#include <asm/local.h>
43255
43256 /*
43257 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43258 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43259
43260 spin_lock_irqsave(&hvcsd->lock, flags);
43261
43262 - if (hvcsd->port.count > 0) {
43263 + if (atomic_read(&hvcsd->port.count) > 0) {
43264 spin_unlock_irqrestore(&hvcsd->lock, flags);
43265 printk(KERN_INFO "HVCS: vterm state unchanged. "
43266 "The hvcs device node is still in use.\n");
43267 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43268 }
43269 }
43270
43271 - hvcsd->port.count = 0;
43272 + atomic_set(&hvcsd->port.count, 0);
43273 hvcsd->port.tty = tty;
43274 tty->driver_data = hvcsd;
43275
43276 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43277 unsigned long flags;
43278
43279 spin_lock_irqsave(&hvcsd->lock, flags);
43280 - hvcsd->port.count++;
43281 + atomic_inc(&hvcsd->port.count);
43282 hvcsd->todo_mask |= HVCS_SCHED_READ;
43283 spin_unlock_irqrestore(&hvcsd->lock, flags);
43284
43285 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43286 hvcsd = tty->driver_data;
43287
43288 spin_lock_irqsave(&hvcsd->lock, flags);
43289 - if (--hvcsd->port.count == 0) {
43290 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43291
43292 vio_disable_interrupts(hvcsd->vdev);
43293
43294 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43295
43296 free_irq(irq, hvcsd);
43297 return;
43298 - } else if (hvcsd->port.count < 0) {
43299 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43300 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43301 " is missmanaged.\n",
43302 - hvcsd->vdev->unit_address, hvcsd->port.count);
43303 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43304 }
43305
43306 spin_unlock_irqrestore(&hvcsd->lock, flags);
43307 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43308
43309 spin_lock_irqsave(&hvcsd->lock, flags);
43310 /* Preserve this so that we know how many kref refs to put */
43311 - temp_open_count = hvcsd->port.count;
43312 + temp_open_count = atomic_read(&hvcsd->port.count);
43313
43314 /*
43315 * Don't kref put inside the spinlock because the destruction
43316 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43317 tty->driver_data = NULL;
43318 hvcsd->port.tty = NULL;
43319
43320 - hvcsd->port.count = 0;
43321 + atomic_set(&hvcsd->port.count, 0);
43322
43323 /* This will drop any buffered data on the floor which is OK in a hangup
43324 * scenario. */
43325 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
43326 * the middle of a write operation? This is a crummy place to do this
43327 * but we want to keep it all in the spinlock.
43328 */
43329 - if (hvcsd->port.count <= 0) {
43330 + if (atomic_read(&hvcsd->port.count) <= 0) {
43331 spin_unlock_irqrestore(&hvcsd->lock, flags);
43332 return -ENODEV;
43333 }
43334 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43335 {
43336 struct hvcs_struct *hvcsd = tty->driver_data;
43337
43338 - if (!hvcsd || hvcsd->port.count <= 0)
43339 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43340 return 0;
43341
43342 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43343 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43344 index 8fd72ff..34a0bed 100644
43345 --- a/drivers/tty/ipwireless/tty.c
43346 +++ b/drivers/tty/ipwireless/tty.c
43347 @@ -29,6 +29,7 @@
43348 #include <linux/tty_driver.h>
43349 #include <linux/tty_flip.h>
43350 #include <linux/uaccess.h>
43351 +#include <asm/local.h>
43352
43353 #include "tty.h"
43354 #include "network.h"
43355 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43356 mutex_unlock(&tty->ipw_tty_mutex);
43357 return -ENODEV;
43358 }
43359 - if (tty->port.count == 0)
43360 + if (atomic_read(&tty->port.count) == 0)
43361 tty->tx_bytes_queued = 0;
43362
43363 - tty->port.count++;
43364 + atomic_inc(&tty->port.count);
43365
43366 tty->port.tty = linux_tty;
43367 linux_tty->driver_data = tty;
43368 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43369
43370 static void do_ipw_close(struct ipw_tty *tty)
43371 {
43372 - tty->port.count--;
43373 -
43374 - if (tty->port.count == 0) {
43375 + if (atomic_dec_return(&tty->port.count) == 0) {
43376 struct tty_struct *linux_tty = tty->port.tty;
43377
43378 if (linux_tty != NULL) {
43379 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43380 return;
43381
43382 mutex_lock(&tty->ipw_tty_mutex);
43383 - if (tty->port.count == 0) {
43384 + if (atomic_read(&tty->port.count) == 0) {
43385 mutex_unlock(&tty->ipw_tty_mutex);
43386 return;
43387 }
43388 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43389
43390 mutex_lock(&tty->ipw_tty_mutex);
43391
43392 - if (!tty->port.count) {
43393 + if (!atomic_read(&tty->port.count)) {
43394 mutex_unlock(&tty->ipw_tty_mutex);
43395 return;
43396 }
43397 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43398 return -ENODEV;
43399
43400 mutex_lock(&tty->ipw_tty_mutex);
43401 - if (!tty->port.count) {
43402 + if (!atomic_read(&tty->port.count)) {
43403 mutex_unlock(&tty->ipw_tty_mutex);
43404 return -EINVAL;
43405 }
43406 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43407 if (!tty)
43408 return -ENODEV;
43409
43410 - if (!tty->port.count)
43411 + if (!atomic_read(&tty->port.count))
43412 return -EINVAL;
43413
43414 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43415 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43416 if (!tty)
43417 return 0;
43418
43419 - if (!tty->port.count)
43420 + if (!atomic_read(&tty->port.count))
43421 return 0;
43422
43423 return tty->tx_bytes_queued;
43424 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43425 if (!tty)
43426 return -ENODEV;
43427
43428 - if (!tty->port.count)
43429 + if (!atomic_read(&tty->port.count))
43430 return -EINVAL;
43431
43432 return get_control_lines(tty);
43433 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43434 if (!tty)
43435 return -ENODEV;
43436
43437 - if (!tty->port.count)
43438 + if (!atomic_read(&tty->port.count))
43439 return -EINVAL;
43440
43441 return set_control_lines(tty, set, clear);
43442 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43443 if (!tty)
43444 return -ENODEV;
43445
43446 - if (!tty->port.count)
43447 + if (!atomic_read(&tty->port.count))
43448 return -EINVAL;
43449
43450 /* FIXME: Exactly how is the tty object locked here .. */
43451 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43452 * are gone */
43453 mutex_lock(&ttyj->ipw_tty_mutex);
43454 }
43455 - while (ttyj->port.count)
43456 + while (atomic_read(&ttyj->port.count))
43457 do_ipw_close(ttyj);
43458 ipwireless_disassociate_network_ttys(network,
43459 ttyj->channel_idx);
43460 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43461 index adeac25..787a0a1 100644
43462 --- a/drivers/tty/moxa.c
43463 +++ b/drivers/tty/moxa.c
43464 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43465 }
43466
43467 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43468 - ch->port.count++;
43469 + atomic_inc(&ch->port.count);
43470 tty->driver_data = ch;
43471 tty_port_tty_set(&ch->port, tty);
43472 mutex_lock(&ch->port.mutex);
43473 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43474 index 4a43ef5d7..aa71f27 100644
43475 --- a/drivers/tty/n_gsm.c
43476 +++ b/drivers/tty/n_gsm.c
43477 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43478 spin_lock_init(&dlci->lock);
43479 mutex_init(&dlci->mutex);
43480 dlci->fifo = &dlci->_fifo;
43481 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43482 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43483 kfree(dlci);
43484 return NULL;
43485 }
43486 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43487 struct gsm_dlci *dlci = tty->driver_data;
43488 struct tty_port *port = &dlci->port;
43489
43490 - port->count++;
43491 + atomic_inc(&port->count);
43492 dlci_get(dlci);
43493 dlci_get(dlci->gsm->dlci[0]);
43494 mux_get(dlci->gsm);
43495 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43496 index 1f8cba6..47b06c2 100644
43497 --- a/drivers/tty/n_tty.c
43498 +++ b/drivers/tty/n_tty.c
43499 @@ -2205,6 +2205,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43500 {
43501 *ops = tty_ldisc_N_TTY;
43502 ops->owner = NULL;
43503 - ops->refcount = ops->flags = 0;
43504 + atomic_set(&ops->refcount, 0);
43505 + ops->flags = 0;
43506 }
43507 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43508 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43509 index 125e0fd..8c50690 100644
43510 --- a/drivers/tty/pty.c
43511 +++ b/drivers/tty/pty.c
43512 @@ -800,8 +800,10 @@ static void __init unix98_pty_init(void)
43513 panic("Couldn't register Unix98 pts driver");
43514
43515 /* Now create the /dev/ptmx special device */
43516 + pax_open_kernel();
43517 tty_default_fops(&ptmx_fops);
43518 - ptmx_fops.open = ptmx_open;
43519 + *(void **)&ptmx_fops.open = ptmx_open;
43520 + pax_close_kernel();
43521
43522 cdev_init(&ptmx_cdev, &ptmx_fops);
43523 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43524 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43525 index 1d27003..959f452 100644
43526 --- a/drivers/tty/rocket.c
43527 +++ b/drivers/tty/rocket.c
43528 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43529 tty->driver_data = info;
43530 tty_port_tty_set(port, tty);
43531
43532 - if (port->count++ == 0) {
43533 + if (atomic_inc_return(&port->count) == 1) {
43534 atomic_inc(&rp_num_ports_open);
43535
43536 #ifdef ROCKET_DEBUG_OPEN
43537 @@ -932,7 +932,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43538 #endif
43539 }
43540 #ifdef ROCKET_DEBUG_OPEN
43541 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43542 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43543 #endif
43544
43545 /*
43546 @@ -1527,7 +1527,7 @@ static void rp_hangup(struct tty_struct *tty)
43547 spin_unlock_irqrestore(&info->port.lock, flags);
43548 return;
43549 }
43550 - if (info->port.count)
43551 + if (atomic_read(&info->port.count))
43552 atomic_dec(&rp_num_ports_open);
43553 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43554 spin_unlock_irqrestore(&info->port.lock, flags);
43555 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43556 index 1002054..dd644a8 100644
43557 --- a/drivers/tty/serial/kgdboc.c
43558 +++ b/drivers/tty/serial/kgdboc.c
43559 @@ -24,8 +24,9 @@
43560 #define MAX_CONFIG_LEN 40
43561
43562 static struct kgdb_io kgdboc_io_ops;
43563 +static struct kgdb_io kgdboc_io_ops_console;
43564
43565 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43566 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43567 static int configured = -1;
43568
43569 static char config[MAX_CONFIG_LEN];
43570 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43571 kgdboc_unregister_kbd();
43572 if (configured == 1)
43573 kgdb_unregister_io_module(&kgdboc_io_ops);
43574 + else if (configured == 2)
43575 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43576 }
43577
43578 static int configure_kgdboc(void)
43579 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43580 int err;
43581 char *cptr = config;
43582 struct console *cons;
43583 + int is_console = 0;
43584
43585 err = kgdboc_option_setup(config);
43586 if (err || !strlen(config) || isspace(config[0]))
43587 goto noconfig;
43588
43589 err = -ENODEV;
43590 - kgdboc_io_ops.is_console = 0;
43591 kgdb_tty_driver = NULL;
43592
43593 kgdboc_use_kms = 0;
43594 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43595 int idx;
43596 if (cons->device && cons->device(cons, &idx) == p &&
43597 idx == tty_line) {
43598 - kgdboc_io_ops.is_console = 1;
43599 + is_console = 1;
43600 break;
43601 }
43602 cons = cons->next;
43603 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43604 kgdb_tty_line = tty_line;
43605
43606 do_register:
43607 - err = kgdb_register_io_module(&kgdboc_io_ops);
43608 + if (is_console) {
43609 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43610 + configured = 2;
43611 + } else {
43612 + err = kgdb_register_io_module(&kgdboc_io_ops);
43613 + configured = 1;
43614 + }
43615 if (err)
43616 goto noconfig;
43617
43618 @@ -205,8 +214,6 @@ do_register:
43619 if (err)
43620 goto nmi_con_failed;
43621
43622 - configured = 1;
43623 -
43624 return 0;
43625
43626 nmi_con_failed:
43627 @@ -223,7 +230,7 @@ noconfig:
43628 static int __init init_kgdboc(void)
43629 {
43630 /* Already configured? */
43631 - if (configured == 1)
43632 + if (configured >= 1)
43633 return 0;
43634
43635 return configure_kgdboc();
43636 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43637 if (config[len - 1] == '\n')
43638 config[len - 1] = '\0';
43639
43640 - if (configured == 1)
43641 + if (configured >= 1)
43642 cleanup_kgdboc();
43643
43644 /* Go and configure with the new params. */
43645 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43646 .post_exception = kgdboc_post_exp_handler,
43647 };
43648
43649 +static struct kgdb_io kgdboc_io_ops_console = {
43650 + .name = "kgdboc",
43651 + .read_char = kgdboc_get_char,
43652 + .write_char = kgdboc_put_char,
43653 + .pre_exception = kgdboc_pre_exp_handler,
43654 + .post_exception = kgdboc_post_exp_handler,
43655 + .is_console = 1
43656 +};
43657 +
43658 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43659 /* This is only available if kgdboc is a built in for early debugging */
43660 static int __init kgdboc_early_init(char *opt)
43661 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43662 index 2769a38..f3dbe48 100644
43663 --- a/drivers/tty/serial/samsung.c
43664 +++ b/drivers/tty/serial/samsung.c
43665 @@ -451,11 +451,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43666 }
43667 }
43668
43669 +static int s3c64xx_serial_startup(struct uart_port *port);
43670 static int s3c24xx_serial_startup(struct uart_port *port)
43671 {
43672 struct s3c24xx_uart_port *ourport = to_ourport(port);
43673 int ret;
43674
43675 + /* Startup sequence is different for s3c64xx and higher SoC's */
43676 + if (s3c24xx_serial_has_interrupt_mask(port))
43677 + return s3c64xx_serial_startup(port);
43678 +
43679 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43680 port->mapbase, port->membase);
43681
43682 @@ -1120,10 +1125,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43683 /* setup info for port */
43684 port->dev = &platdev->dev;
43685
43686 - /* Startup sequence is different for s3c64xx and higher SoC's */
43687 - if (s3c24xx_serial_has_interrupt_mask(port))
43688 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43689 -
43690 port->uartclk = 1;
43691
43692 if (cfg->uart_flags & UPF_CONS_FLOW) {
43693 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43694 index 8fbb6d2..822a9e6 100644
43695 --- a/drivers/tty/serial/serial_core.c
43696 +++ b/drivers/tty/serial/serial_core.c
43697 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43698 uart_flush_buffer(tty);
43699 uart_shutdown(tty, state);
43700 spin_lock_irqsave(&port->lock, flags);
43701 - port->count = 0;
43702 + atomic_set(&port->count, 0);
43703 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43704 spin_unlock_irqrestore(&port->lock, flags);
43705 tty_port_tty_set(port, NULL);
43706 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43707 goto end;
43708 }
43709
43710 - port->count++;
43711 + atomic_inc(&port->count);
43712 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43713 retval = -ENXIO;
43714 goto err_dec_count;
43715 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43716 /*
43717 * Make sure the device is in D0 state.
43718 */
43719 - if (port->count == 1)
43720 + if (atomic_read(&port->count) == 1)
43721 uart_change_pm(state, UART_PM_STATE_ON);
43722
43723 /*
43724 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43725 end:
43726 return retval;
43727 err_dec_count:
43728 - port->count--;
43729 + atomic_inc(&port->count);
43730 mutex_unlock(&port->mutex);
43731 goto end;
43732 }
43733 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43734 index 8983276..72a4090 100644
43735 --- a/drivers/tty/synclink.c
43736 +++ b/drivers/tty/synclink.c
43737 @@ -3093,7 +3093,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43738
43739 if (debug_level >= DEBUG_LEVEL_INFO)
43740 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43741 - __FILE__,__LINE__, info->device_name, info->port.count);
43742 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43743
43744 if (tty_port_close_start(&info->port, tty, filp) == 0)
43745 goto cleanup;
43746 @@ -3111,7 +3111,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43747 cleanup:
43748 if (debug_level >= DEBUG_LEVEL_INFO)
43749 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43750 - tty->driver->name, info->port.count);
43751 + tty->driver->name, atomic_read(&info->port.count));
43752
43753 } /* end of mgsl_close() */
43754
43755 @@ -3210,8 +3210,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43756
43757 mgsl_flush_buffer(tty);
43758 shutdown(info);
43759 -
43760 - info->port.count = 0;
43761 +
43762 + atomic_set(&info->port.count, 0);
43763 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43764 info->port.tty = NULL;
43765
43766 @@ -3300,12 +3300,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43767
43768 if (debug_level >= DEBUG_LEVEL_INFO)
43769 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43770 - __FILE__,__LINE__, tty->driver->name, port->count );
43771 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43772
43773 spin_lock_irqsave(&info->irq_spinlock, flags);
43774 if (!tty_hung_up_p(filp)) {
43775 extra_count = true;
43776 - port->count--;
43777 + atomic_dec(&port->count);
43778 }
43779 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43780 port->blocked_open++;
43781 @@ -3334,7 +3334,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43782
43783 if (debug_level >= DEBUG_LEVEL_INFO)
43784 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43785 - __FILE__,__LINE__, tty->driver->name, port->count );
43786 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43787
43788 tty_unlock(tty);
43789 schedule();
43790 @@ -3346,12 +3346,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43791
43792 /* FIXME: Racy on hangup during close wait */
43793 if (extra_count)
43794 - port->count++;
43795 + atomic_inc(&port->count);
43796 port->blocked_open--;
43797
43798 if (debug_level >= DEBUG_LEVEL_INFO)
43799 printk("%s(%d):block_til_ready after blocking 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 if (!retval)
43804 port->flags |= ASYNC_NORMAL_ACTIVE;
43805 @@ -3403,7 +3403,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43806
43807 if (debug_level >= DEBUG_LEVEL_INFO)
43808 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43809 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43810 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43811
43812 /* If port is closing, signal caller to try again */
43813 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43814 @@ -3422,10 +3422,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43815 spin_unlock_irqrestore(&info->netlock, flags);
43816 goto cleanup;
43817 }
43818 - info->port.count++;
43819 + atomic_inc(&info->port.count);
43820 spin_unlock_irqrestore(&info->netlock, flags);
43821
43822 - if (info->port.count == 1) {
43823 + if (atomic_read(&info->port.count) == 1) {
43824 /* 1st open on this device, init hardware */
43825 retval = startup(info);
43826 if (retval < 0)
43827 @@ -3449,8 +3449,8 @@ cleanup:
43828 if (retval) {
43829 if (tty->count == 1)
43830 info->port.tty = NULL; /* tty layer will release tty struct */
43831 - if(info->port.count)
43832 - info->port.count--;
43833 + if (atomic_read(&info->port.count))
43834 + atomic_dec(&info->port.count);
43835 }
43836
43837 return retval;
43838 @@ -7668,7 +7668,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43839 unsigned short new_crctype;
43840
43841 /* return error if TTY interface open */
43842 - if (info->port.count)
43843 + if (atomic_read(&info->port.count))
43844 return -EBUSY;
43845
43846 switch (encoding)
43847 @@ -7763,7 +7763,7 @@ static int hdlcdev_open(struct net_device *dev)
43848
43849 /* arbitrate between network and tty opens */
43850 spin_lock_irqsave(&info->netlock, flags);
43851 - if (info->port.count != 0 || info->netcount != 0) {
43852 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43853 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43854 spin_unlock_irqrestore(&info->netlock, flags);
43855 return -EBUSY;
43856 @@ -7849,7 +7849,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43857 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43858
43859 /* return error if TTY interface open */
43860 - if (info->port.count)
43861 + if (atomic_read(&info->port.count))
43862 return -EBUSY;
43863
43864 if (cmd != SIOCWANDEV)
43865 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43866 index aa9eece..d8baaec 100644
43867 --- a/drivers/tty/synclink_gt.c
43868 +++ b/drivers/tty/synclink_gt.c
43869 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43870 tty->driver_data = info;
43871 info->port.tty = tty;
43872
43873 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43874 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43875
43876 /* If port is closing, signal caller to try again */
43877 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43878 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43879 mutex_unlock(&info->port.mutex);
43880 goto cleanup;
43881 }
43882 - info->port.count++;
43883 + atomic_inc(&info->port.count);
43884 spin_unlock_irqrestore(&info->netlock, flags);
43885
43886 - if (info->port.count == 1) {
43887 + if (atomic_read(&info->port.count) == 1) {
43888 /* 1st open on this device, init hardware */
43889 retval = startup(info);
43890 if (retval < 0) {
43891 @@ -715,8 +715,8 @@ cleanup:
43892 if (retval) {
43893 if (tty->count == 1)
43894 info->port.tty = NULL; /* tty layer will release tty struct */
43895 - if(info->port.count)
43896 - info->port.count--;
43897 + if(atomic_read(&info->port.count))
43898 + atomic_dec(&info->port.count);
43899 }
43900
43901 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43902 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43903
43904 if (sanity_check(info, tty->name, "close"))
43905 return;
43906 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43907 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43908
43909 if (tty_port_close_start(&info->port, tty, filp) == 0)
43910 goto cleanup;
43911 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43912 tty_port_close_end(&info->port, tty);
43913 info->port.tty = NULL;
43914 cleanup:
43915 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43916 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43917 }
43918
43919 static void hangup(struct tty_struct *tty)
43920 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
43921 shutdown(info);
43922
43923 spin_lock_irqsave(&info->port.lock, flags);
43924 - info->port.count = 0;
43925 + atomic_set(&info->port.count, 0);
43926 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43927 info->port.tty = NULL;
43928 spin_unlock_irqrestore(&info->port.lock, flags);
43929 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43930 unsigned short new_crctype;
43931
43932 /* return error if TTY interface open */
43933 - if (info->port.count)
43934 + if (atomic_read(&info->port.count))
43935 return -EBUSY;
43936
43937 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43938 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
43939
43940 /* arbitrate between network and tty opens */
43941 spin_lock_irqsave(&info->netlock, flags);
43942 - if (info->port.count != 0 || info->netcount != 0) {
43943 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43944 DBGINFO(("%s hdlc_open busy\n", dev->name));
43945 spin_unlock_irqrestore(&info->netlock, flags);
43946 return -EBUSY;
43947 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43948 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43949
43950 /* return error if TTY interface open */
43951 - if (info->port.count)
43952 + if (atomic_read(&info->port.count))
43953 return -EBUSY;
43954
43955 if (cmd != SIOCWANDEV)
43956 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43957 if (port == NULL)
43958 continue;
43959 spin_lock(&port->lock);
43960 - if ((port->port.count || port->netcount) &&
43961 + if ((atomic_read(&port->port.count) || port->netcount) &&
43962 port->pending_bh && !port->bh_running &&
43963 !port->bh_requested) {
43964 DBGISR(("%s bh queued\n", port->device_name));
43965 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43966 spin_lock_irqsave(&info->lock, flags);
43967 if (!tty_hung_up_p(filp)) {
43968 extra_count = true;
43969 - port->count--;
43970 + atomic_dec(&port->count);
43971 }
43972 spin_unlock_irqrestore(&info->lock, flags);
43973 port->blocked_open++;
43974 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43975 remove_wait_queue(&port->open_wait, &wait);
43976
43977 if (extra_count)
43978 - port->count++;
43979 + atomic_inc(&port->count);
43980 port->blocked_open--;
43981
43982 if (!retval)
43983 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43984 index 6d5780c..aa4d8cd 100644
43985 --- a/drivers/tty/synclinkmp.c
43986 +++ b/drivers/tty/synclinkmp.c
43987 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43988
43989 if (debug_level >= DEBUG_LEVEL_INFO)
43990 printk("%s(%d):%s open(), old ref count = %d\n",
43991 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43992 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43993
43994 /* If port is closing, signal caller to try again */
43995 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43996 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43997 spin_unlock_irqrestore(&info->netlock, flags);
43998 goto cleanup;
43999 }
44000 - info->port.count++;
44001 + atomic_inc(&info->port.count);
44002 spin_unlock_irqrestore(&info->netlock, flags);
44003
44004 - if (info->port.count == 1) {
44005 + if (atomic_read(&info->port.count) == 1) {
44006 /* 1st open on this device, init hardware */
44007 retval = startup(info);
44008 if (retval < 0)
44009 @@ -796,8 +796,8 @@ cleanup:
44010 if (retval) {
44011 if (tty->count == 1)
44012 info->port.tty = NULL; /* tty layer will release tty struct */
44013 - if(info->port.count)
44014 - info->port.count--;
44015 + if(atomic_read(&info->port.count))
44016 + atomic_dec(&info->port.count);
44017 }
44018
44019 return retval;
44020 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44021
44022 if (debug_level >= DEBUG_LEVEL_INFO)
44023 printk("%s(%d):%s close() entry, count=%d\n",
44024 - __FILE__,__LINE__, info->device_name, info->port.count);
44025 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44026
44027 if (tty_port_close_start(&info->port, tty, filp) == 0)
44028 goto cleanup;
44029 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44030 cleanup:
44031 if (debug_level >= DEBUG_LEVEL_INFO)
44032 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44033 - tty->driver->name, info->port.count);
44034 + tty->driver->name, atomic_read(&info->port.count));
44035 }
44036
44037 /* Called by tty_hangup() when a hangup is signaled.
44038 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
44039 shutdown(info);
44040
44041 spin_lock_irqsave(&info->port.lock, flags);
44042 - info->port.count = 0;
44043 + atomic_set(&info->port.count, 0);
44044 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44045 info->port.tty = NULL;
44046 spin_unlock_irqrestore(&info->port.lock, flags);
44047 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44048 unsigned short new_crctype;
44049
44050 /* return error if TTY interface open */
44051 - if (info->port.count)
44052 + if (atomic_read(&info->port.count))
44053 return -EBUSY;
44054
44055 switch (encoding)
44056 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
44057
44058 /* arbitrate between network and tty opens */
44059 spin_lock_irqsave(&info->netlock, flags);
44060 - if (info->port.count != 0 || info->netcount != 0) {
44061 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44062 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44063 spin_unlock_irqrestore(&info->netlock, flags);
44064 return -EBUSY;
44065 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44066 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44067
44068 /* return error if TTY interface open */
44069 - if (info->port.count)
44070 + if (atomic_read(&info->port.count))
44071 return -EBUSY;
44072
44073 if (cmd != SIOCWANDEV)
44074 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44075 * do not request bottom half processing if the
44076 * device is not open in a normal mode.
44077 */
44078 - if ( port && (port->port.count || port->netcount) &&
44079 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44080 port->pending_bh && !port->bh_running &&
44081 !port->bh_requested ) {
44082 if ( debug_level >= DEBUG_LEVEL_ISR )
44083 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44084
44085 if (debug_level >= DEBUG_LEVEL_INFO)
44086 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44087 - __FILE__,__LINE__, tty->driver->name, port->count );
44088 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44089
44090 spin_lock_irqsave(&info->lock, flags);
44091 if (!tty_hung_up_p(filp)) {
44092 extra_count = true;
44093 - port->count--;
44094 + atomic_dec(&port->count);
44095 }
44096 spin_unlock_irqrestore(&info->lock, flags);
44097 port->blocked_open++;
44098 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44099
44100 if (debug_level >= DEBUG_LEVEL_INFO)
44101 printk("%s(%d):%s block_til_ready() count=%d\n",
44102 - __FILE__,__LINE__, tty->driver->name, port->count );
44103 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44104
44105 tty_unlock(tty);
44106 schedule();
44107 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44108 remove_wait_queue(&port->open_wait, &wait);
44109
44110 if (extra_count)
44111 - port->count++;
44112 + atomic_inc(&port->count);
44113 port->blocked_open--;
44114
44115 if (debug_level >= DEBUG_LEVEL_INFO)
44116 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44117 - __FILE__,__LINE__, tty->driver->name, port->count );
44118 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44119
44120 if (!retval)
44121 port->flags |= ASYNC_NORMAL_ACTIVE;
44122 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44123 index 3687f0c..6b9b808 100644
44124 --- a/drivers/tty/sysrq.c
44125 +++ b/drivers/tty/sysrq.c
44126 @@ -995,7 +995,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44127 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44128 size_t count, loff_t *ppos)
44129 {
44130 - if (count) {
44131 + if (count && capable(CAP_SYS_ADMIN)) {
44132 char c;
44133
44134 if (get_user(c, buf))
44135 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44136 index a9cd0b9..47b9336 100644
44137 --- a/drivers/tty/tty_io.c
44138 +++ b/drivers/tty/tty_io.c
44139 @@ -3398,7 +3398,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44140
44141 void tty_default_fops(struct file_operations *fops)
44142 {
44143 - *fops = tty_fops;
44144 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44145 }
44146
44147 /*
44148 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44149 index d794087..e4f49e5 100644
44150 --- a/drivers/tty/tty_ldisc.c
44151 +++ b/drivers/tty/tty_ldisc.c
44152 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
44153 if (atomic_dec_and_test(&ld->users)) {
44154 struct tty_ldisc_ops *ldo = ld->ops;
44155
44156 - ldo->refcount--;
44157 + atomic_dec(&ldo->refcount);
44158 module_put(ldo->owner);
44159 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44160
44161 @@ -93,7 +93,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44162 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44163 tty_ldiscs[disc] = new_ldisc;
44164 new_ldisc->num = disc;
44165 - new_ldisc->refcount = 0;
44166 + atomic_set(&new_ldisc->refcount, 0);
44167 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44168
44169 return ret;
44170 @@ -121,7 +121,7 @@ int tty_unregister_ldisc(int disc)
44171 return -EINVAL;
44172
44173 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44174 - if (tty_ldiscs[disc]->refcount)
44175 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44176 ret = -EBUSY;
44177 else
44178 tty_ldiscs[disc] = NULL;
44179 @@ -142,7 +142,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44180 if (ldops) {
44181 ret = ERR_PTR(-EAGAIN);
44182 if (try_module_get(ldops->owner)) {
44183 - ldops->refcount++;
44184 + atomic_inc(&ldops->refcount);
44185 ret = ldops;
44186 }
44187 }
44188 @@ -155,7 +155,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44189 unsigned long flags;
44190
44191 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44192 - ldops->refcount--;
44193 + atomic_dec(&ldops->refcount);
44194 module_put(ldops->owner);
44195 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44196 }
44197 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44198 index b7ff59d..7c6105e 100644
44199 --- a/drivers/tty/tty_port.c
44200 +++ b/drivers/tty/tty_port.c
44201 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44202 unsigned long flags;
44203
44204 spin_lock_irqsave(&port->lock, flags);
44205 - port->count = 0;
44206 + atomic_set(&port->count, 0);
44207 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44208 if (port->tty) {
44209 set_bit(TTY_IO_ERROR, &port->tty->flags);
44210 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44211 /* The port lock protects the port counts */
44212 spin_lock_irqsave(&port->lock, flags);
44213 if (!tty_hung_up_p(filp))
44214 - port->count--;
44215 + atomic_dec(&port->count);
44216 port->blocked_open++;
44217 spin_unlock_irqrestore(&port->lock, flags);
44218
44219 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44220 we must not mess that up further */
44221 spin_lock_irqsave(&port->lock, flags);
44222 if (!tty_hung_up_p(filp))
44223 - port->count++;
44224 + atomic_inc(&port->count);
44225 port->blocked_open--;
44226 if (retval == 0)
44227 port->flags |= ASYNC_NORMAL_ACTIVE;
44228 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
44229 return 0;
44230 }
44231
44232 - if (tty->count == 1 && port->count != 1) {
44233 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44234 printk(KERN_WARNING
44235 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44236 - port->count);
44237 - port->count = 1;
44238 + atomic_read(&port->count));
44239 + atomic_set(&port->count, 1);
44240 }
44241 - if (--port->count < 0) {
44242 + if (atomic_dec_return(&port->count) < 0) {
44243 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44244 - port->count);
44245 - port->count = 0;
44246 + atomic_read(&port->count));
44247 + atomic_set(&port->count, 0);
44248 }
44249
44250 - if (port->count) {
44251 + if (atomic_read(&port->count)) {
44252 spin_unlock_irqrestore(&port->lock, flags);
44253 if (port->ops->drop)
44254 port->ops->drop(port);
44255 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44256 {
44257 spin_lock_irq(&port->lock);
44258 if (!tty_hung_up_p(filp))
44259 - ++port->count;
44260 + atomic_inc(&port->count);
44261 spin_unlock_irq(&port->lock);
44262 tty_port_tty_set(port, tty);
44263
44264 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44265 index a9af1b9a..1e08e7f 100644
44266 --- a/drivers/tty/vt/keyboard.c
44267 +++ b/drivers/tty/vt/keyboard.c
44268 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44269 kbd->kbdmode == VC_OFF) &&
44270 value != KVAL(K_SAK))
44271 return; /* SAK is allowed even in raw mode */
44272 +
44273 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44274 + {
44275 + void *func = fn_handler[value];
44276 + if (func == fn_show_state || func == fn_show_ptregs ||
44277 + func == fn_show_mem)
44278 + return;
44279 + }
44280 +#endif
44281 +
44282 fn_handler[value](vc);
44283 }
44284
44285 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44286 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44287 return -EFAULT;
44288
44289 - if (!capable(CAP_SYS_TTY_CONFIG))
44290 - perm = 0;
44291 -
44292 switch (cmd) {
44293 case KDGKBENT:
44294 /* Ensure another thread doesn't free it under us */
44295 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44296 spin_unlock_irqrestore(&kbd_event_lock, flags);
44297 return put_user(val, &user_kbe->kb_value);
44298 case KDSKBENT:
44299 + if (!capable(CAP_SYS_TTY_CONFIG))
44300 + perm = 0;
44301 +
44302 if (!perm)
44303 return -EPERM;
44304 if (!i && v == K_NOSUCHMAP) {
44305 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44306 int i, j, k;
44307 int ret;
44308
44309 - if (!capable(CAP_SYS_TTY_CONFIG))
44310 - perm = 0;
44311 -
44312 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44313 if (!kbs) {
44314 ret = -ENOMEM;
44315 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44316 kfree(kbs);
44317 return ((p && *p) ? -EOVERFLOW : 0);
44318 case KDSKBSENT:
44319 + if (!capable(CAP_SYS_TTY_CONFIG))
44320 + perm = 0;
44321 +
44322 if (!perm) {
44323 ret = -EPERM;
44324 goto reterr;
44325 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44326 index c8b9262..7e824e6 100644
44327 --- a/drivers/uio/uio.c
44328 +++ b/drivers/uio/uio.c
44329 @@ -25,6 +25,7 @@
44330 #include <linux/kobject.h>
44331 #include <linux/cdev.h>
44332 #include <linux/uio_driver.h>
44333 +#include <asm/local.h>
44334
44335 #define UIO_MAX_DEVICES (1U << MINORBITS)
44336
44337 @@ -32,10 +33,10 @@ struct uio_device {
44338 struct module *owner;
44339 struct device *dev;
44340 int minor;
44341 - atomic_t event;
44342 + atomic_unchecked_t event;
44343 struct fasync_struct *async_queue;
44344 wait_queue_head_t wait;
44345 - int vma_count;
44346 + local_t vma_count;
44347 struct uio_info *info;
44348 struct kobject *map_dir;
44349 struct kobject *portio_dir;
44350 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44351 struct device_attribute *attr, char *buf)
44352 {
44353 struct uio_device *idev = dev_get_drvdata(dev);
44354 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44355 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44356 }
44357
44358 static struct device_attribute uio_class_attributes[] = {
44359 @@ -397,7 +398,7 @@ void uio_event_notify(struct uio_info *info)
44360 {
44361 struct uio_device *idev = info->uio_dev;
44362
44363 - atomic_inc(&idev->event);
44364 + atomic_inc_unchecked(&idev->event);
44365 wake_up_interruptible(&idev->wait);
44366 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44367 }
44368 @@ -450,7 +451,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44369 }
44370
44371 listener->dev = idev;
44372 - listener->event_count = atomic_read(&idev->event);
44373 + listener->event_count = atomic_read_unchecked(&idev->event);
44374 filep->private_data = listener;
44375
44376 if (idev->info->open) {
44377 @@ -501,7 +502,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44378 return -EIO;
44379
44380 poll_wait(filep, &idev->wait, wait);
44381 - if (listener->event_count != atomic_read(&idev->event))
44382 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44383 return POLLIN | POLLRDNORM;
44384 return 0;
44385 }
44386 @@ -526,7 +527,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44387 do {
44388 set_current_state(TASK_INTERRUPTIBLE);
44389
44390 - event_count = atomic_read(&idev->event);
44391 + event_count = atomic_read_unchecked(&idev->event);
44392 if (event_count != listener->event_count) {
44393 if (copy_to_user(buf, &event_count, count))
44394 retval = -EFAULT;
44395 @@ -595,13 +596,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44396 static void uio_vma_open(struct vm_area_struct *vma)
44397 {
44398 struct uio_device *idev = vma->vm_private_data;
44399 - idev->vma_count++;
44400 + local_inc(&idev->vma_count);
44401 }
44402
44403 static void uio_vma_close(struct vm_area_struct *vma)
44404 {
44405 struct uio_device *idev = vma->vm_private_data;
44406 - idev->vma_count--;
44407 + local_dec(&idev->vma_count);
44408 }
44409
44410 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44411 @@ -808,7 +809,7 @@ int __uio_register_device(struct module *owner,
44412 idev->owner = owner;
44413 idev->info = info;
44414 init_waitqueue_head(&idev->wait);
44415 - atomic_set(&idev->event, 0);
44416 + atomic_set_unchecked(&idev->event, 0);
44417
44418 ret = uio_get_minor(idev);
44419 if (ret)
44420 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44421 index 8a7eb77..c00402f 100644
44422 --- a/drivers/usb/atm/cxacru.c
44423 +++ b/drivers/usb/atm/cxacru.c
44424 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44425 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44426 if (ret < 2)
44427 return -EINVAL;
44428 - if (index < 0 || index > 0x7f)
44429 + if (index > 0x7f)
44430 return -EINVAL;
44431 pos += tmp;
44432
44433 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44434 index 35f10bf..6a38a0b 100644
44435 --- a/drivers/usb/atm/usbatm.c
44436 +++ b/drivers/usb/atm/usbatm.c
44437 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44438 if (printk_ratelimit())
44439 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44440 __func__, vpi, vci);
44441 - atomic_inc(&vcc->stats->rx_err);
44442 + atomic_inc_unchecked(&vcc->stats->rx_err);
44443 return;
44444 }
44445
44446 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44447 if (length > ATM_MAX_AAL5_PDU) {
44448 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44449 __func__, length, vcc);
44450 - atomic_inc(&vcc->stats->rx_err);
44451 + atomic_inc_unchecked(&vcc->stats->rx_err);
44452 goto out;
44453 }
44454
44455 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44456 if (sarb->len < pdu_length) {
44457 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44458 __func__, pdu_length, sarb->len, vcc);
44459 - atomic_inc(&vcc->stats->rx_err);
44460 + atomic_inc_unchecked(&vcc->stats->rx_err);
44461 goto out;
44462 }
44463
44464 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44465 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44466 __func__, vcc);
44467 - atomic_inc(&vcc->stats->rx_err);
44468 + atomic_inc_unchecked(&vcc->stats->rx_err);
44469 goto out;
44470 }
44471
44472 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44473 if (printk_ratelimit())
44474 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44475 __func__, length);
44476 - atomic_inc(&vcc->stats->rx_drop);
44477 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44478 goto out;
44479 }
44480
44481 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44482
44483 vcc->push(vcc, skb);
44484
44485 - atomic_inc(&vcc->stats->rx);
44486 + atomic_inc_unchecked(&vcc->stats->rx);
44487 out:
44488 skb_trim(sarb, 0);
44489 }
44490 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44491 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44492
44493 usbatm_pop(vcc, skb);
44494 - atomic_inc(&vcc->stats->tx);
44495 + atomic_inc_unchecked(&vcc->stats->tx);
44496
44497 skb = skb_dequeue(&instance->sndqueue);
44498 }
44499 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44500 if (!left--)
44501 return sprintf(page,
44502 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44503 - atomic_read(&atm_dev->stats.aal5.tx),
44504 - atomic_read(&atm_dev->stats.aal5.tx_err),
44505 - atomic_read(&atm_dev->stats.aal5.rx),
44506 - atomic_read(&atm_dev->stats.aal5.rx_err),
44507 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44508 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44509 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44510 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44511 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44512 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44513
44514 if (!left--) {
44515 if (instance->disconnected)
44516 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44517 index 2a3bbdf..91d72cf 100644
44518 --- a/drivers/usb/core/devices.c
44519 +++ b/drivers/usb/core/devices.c
44520 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44521 * time it gets called.
44522 */
44523 static struct device_connect_event {
44524 - atomic_t count;
44525 + atomic_unchecked_t count;
44526 wait_queue_head_t wait;
44527 } device_event = {
44528 .count = ATOMIC_INIT(1),
44529 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44530
44531 void usbfs_conn_disc_event(void)
44532 {
44533 - atomic_add(2, &device_event.count);
44534 + atomic_add_unchecked(2, &device_event.count);
44535 wake_up(&device_event.wait);
44536 }
44537
44538 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44539
44540 poll_wait(file, &device_event.wait, wait);
44541
44542 - event_count = atomic_read(&device_event.count);
44543 + event_count = atomic_read_unchecked(&device_event.count);
44544 if (file->f_version != event_count) {
44545 file->f_version = event_count;
44546 return POLLIN | POLLRDNORM;
44547 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44548 index f9ec44c..eb5779f 100644
44549 --- a/drivers/usb/core/hcd.c
44550 +++ b/drivers/usb/core/hcd.c
44551 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44552 */
44553 usb_get_urb(urb);
44554 atomic_inc(&urb->use_count);
44555 - atomic_inc(&urb->dev->urbnum);
44556 + atomic_inc_unchecked(&urb->dev->urbnum);
44557 usbmon_urb_submit(&hcd->self, urb);
44558
44559 /* NOTE requirements on root-hub callers (usbfs and the hub
44560 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44561 urb->hcpriv = NULL;
44562 INIT_LIST_HEAD(&urb->urb_list);
44563 atomic_dec(&urb->use_count);
44564 - atomic_dec(&urb->dev->urbnum);
44565 + atomic_dec_unchecked(&urb->dev->urbnum);
44566 if (atomic_read(&urb->reject))
44567 wake_up(&usb_kill_urb_queue);
44568 usb_put_urb(urb);
44569 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44570 index 444d30e..f15c850 100644
44571 --- a/drivers/usb/core/message.c
44572 +++ b/drivers/usb/core/message.c
44573 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44574 * method can wait for it to complete. Since you don't have a handle on the
44575 * URB used, you can't cancel the request.
44576 */
44577 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44578 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44579 __u8 requesttype, __u16 value, __u16 index, void *data,
44580 __u16 size, int timeout)
44581 {
44582 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44583 index 3f81a3d..a3aa993 100644
44584 --- a/drivers/usb/core/sysfs.c
44585 +++ b/drivers/usb/core/sysfs.c
44586 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44587 struct usb_device *udev;
44588
44589 udev = to_usb_device(dev);
44590 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44591 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44592 }
44593 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44594
44595 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44596 index f81b925..78d22ec 100644
44597 --- a/drivers/usb/core/usb.c
44598 +++ b/drivers/usb/core/usb.c
44599 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44600 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44601 dev->state = USB_STATE_ATTACHED;
44602 dev->lpm_disable_count = 1;
44603 - atomic_set(&dev->urbnum, 0);
44604 + atomic_set_unchecked(&dev->urbnum, 0);
44605
44606 INIT_LIST_HEAD(&dev->ep0.urb_list);
44607 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44608 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44609 index 5e29dde..eca992f 100644
44610 --- a/drivers/usb/early/ehci-dbgp.c
44611 +++ b/drivers/usb/early/ehci-dbgp.c
44612 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44613
44614 #ifdef CONFIG_KGDB
44615 static struct kgdb_io kgdbdbgp_io_ops;
44616 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44617 +static struct kgdb_io kgdbdbgp_io_ops_console;
44618 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44619 #else
44620 #define dbgp_kgdb_mode (0)
44621 #endif
44622 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44623 .write_char = kgdbdbgp_write_char,
44624 };
44625
44626 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44627 + .name = "kgdbdbgp",
44628 + .read_char = kgdbdbgp_read_char,
44629 + .write_char = kgdbdbgp_write_char,
44630 + .is_console = 1
44631 +};
44632 +
44633 static int kgdbdbgp_wait_time;
44634
44635 static int __init kgdbdbgp_parse_config(char *str)
44636 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44637 ptr++;
44638 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44639 }
44640 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44641 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44642 + if (early_dbgp_console.index != -1)
44643 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44644 + else
44645 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44646
44647 return 0;
44648 }
44649 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44650 index b369292..9f3ba40 100644
44651 --- a/drivers/usb/gadget/u_serial.c
44652 +++ b/drivers/usb/gadget/u_serial.c
44653 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44654 spin_lock_irq(&port->port_lock);
44655
44656 /* already open? Great. */
44657 - if (port->port.count) {
44658 + if (atomic_read(&port->port.count)) {
44659 status = 0;
44660 - port->port.count++;
44661 + atomic_inc(&port->port.count);
44662
44663 /* currently opening/closing? wait ... */
44664 } else if (port->openclose) {
44665 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44666 tty->driver_data = port;
44667 port->port.tty = tty;
44668
44669 - port->port.count = 1;
44670 + atomic_set(&port->port.count, 1);
44671 port->openclose = false;
44672
44673 /* if connected, start the I/O stream */
44674 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44675
44676 spin_lock_irq(&port->port_lock);
44677
44678 - if (port->port.count != 1) {
44679 - if (port->port.count == 0)
44680 + if (atomic_read(&port->port.count) != 1) {
44681 + if (atomic_read(&port->port.count) == 0)
44682 WARN_ON(1);
44683 else
44684 - --port->port.count;
44685 + atomic_dec(&port->port.count);
44686 goto exit;
44687 }
44688
44689 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44690 * and sleep if necessary
44691 */
44692 port->openclose = true;
44693 - port->port.count = 0;
44694 + atomic_set(&port->port.count, 0);
44695
44696 gser = port->port_usb;
44697 if (gser && gser->disconnect)
44698 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44699 int cond;
44700
44701 spin_lock_irq(&port->port_lock);
44702 - cond = (port->port.count == 0) && !port->openclose;
44703 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44704 spin_unlock_irq(&port->port_lock);
44705 return cond;
44706 }
44707 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44708 /* if it's already open, start I/O ... and notify the serial
44709 * protocol about open/close status (connect/disconnect).
44710 */
44711 - if (port->port.count) {
44712 + if (atomic_read(&port->port.count)) {
44713 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44714 gs_start_io(port);
44715 if (gser->connect)
44716 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44717
44718 port->port_usb = NULL;
44719 gser->ioport = NULL;
44720 - if (port->port.count > 0 || port->openclose) {
44721 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44722 wake_up_interruptible(&port->drain_wait);
44723 if (port->port.tty)
44724 tty_hangup(port->port.tty);
44725 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44726
44727 /* finally, free any unused/unusable I/O buffers */
44728 spin_lock_irqsave(&port->port_lock, flags);
44729 - if (port->port.count == 0 && !port->openclose)
44730 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44731 gs_buf_free(&port->port_write_buf);
44732 gs_free_requests(gser->out, &port->read_pool, NULL);
44733 gs_free_requests(gser->out, &port->read_queue, NULL);
44734 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44735 index 5f3bcd3..bfca43f 100644
44736 --- a/drivers/usb/serial/console.c
44737 +++ b/drivers/usb/serial/console.c
44738 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44739
44740 info->port = port;
44741
44742 - ++port->port.count;
44743 + atomic_inc(&port->port.count);
44744 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44745 if (serial->type->set_termios) {
44746 /*
44747 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44748 }
44749 /* Now that any required fake tty operations are completed restore
44750 * the tty port count */
44751 - --port->port.count;
44752 + atomic_dec(&port->port.count);
44753 /* The console is special in terms of closing the device so
44754 * indicate this port is now acting as a system console. */
44755 port->port.console = 1;
44756 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44757 free_tty:
44758 kfree(tty);
44759 reset_open_count:
44760 - port->port.count = 0;
44761 + atomic_set(&port->port.count, 0);
44762 usb_autopm_put_interface(serial->interface);
44763 error_get_interface:
44764 usb_serial_put(serial);
44765 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44766 index 6c3586a..a94e621 100644
44767 --- a/drivers/usb/storage/realtek_cr.c
44768 +++ b/drivers/usb/storage/realtek_cr.c
44769 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44770
44771 buf = kmalloc(len, GFP_NOIO);
44772 if (buf == NULL)
44773 - return USB_STOR_TRANSPORT_ERROR;
44774 + return -ENOMEM;
44775
44776 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44777
44778 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44779 index 75f70f0..d467e1a 100644
44780 --- a/drivers/usb/storage/usb.h
44781 +++ b/drivers/usb/storage/usb.h
44782 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44783 __u8 useProtocol;
44784 __u8 useTransport;
44785 int (*initFunction)(struct us_data *);
44786 -};
44787 +} __do_const;
44788
44789
44790 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44791 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44792 index d6bea3e..60b250e 100644
44793 --- a/drivers/usb/wusbcore/wa-hc.h
44794 +++ b/drivers/usb/wusbcore/wa-hc.h
44795 @@ -192,7 +192,7 @@ struct wahc {
44796 struct list_head xfer_delayed_list;
44797 spinlock_t xfer_list_lock;
44798 struct work_struct xfer_work;
44799 - atomic_t xfer_id_count;
44800 + atomic_unchecked_t xfer_id_count;
44801 };
44802
44803
44804 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44805 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44806 spin_lock_init(&wa->xfer_list_lock);
44807 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44808 - atomic_set(&wa->xfer_id_count, 1);
44809 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44810 }
44811
44812 /**
44813 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44814 index 6ef94bc..1b41265 100644
44815 --- a/drivers/usb/wusbcore/wa-xfer.c
44816 +++ b/drivers/usb/wusbcore/wa-xfer.c
44817 @@ -296,7 +296,7 @@ out:
44818 */
44819 static void wa_xfer_id_init(struct wa_xfer *xfer)
44820 {
44821 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44822 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44823 }
44824
44825 /*
44826 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44827 index 8c55011..eed4ae1a 100644
44828 --- a/drivers/video/aty/aty128fb.c
44829 +++ b/drivers/video/aty/aty128fb.c
44830 @@ -149,7 +149,7 @@ enum {
44831 };
44832
44833 /* Must match above enum */
44834 -static char * const r128_family[] = {
44835 +static const char * const r128_family[] = {
44836 "AGP",
44837 "PCI",
44838 "PRO AGP",
44839 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44840 index 4f27fdc..d3537e6 100644
44841 --- a/drivers/video/aty/atyfb_base.c
44842 +++ b/drivers/video/aty/atyfb_base.c
44843 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44844 par->accel_flags = var->accel_flags; /* hack */
44845
44846 if (var->accel_flags) {
44847 - info->fbops->fb_sync = atyfb_sync;
44848 + pax_open_kernel();
44849 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44850 + pax_close_kernel();
44851 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44852 } else {
44853 - info->fbops->fb_sync = NULL;
44854 + pax_open_kernel();
44855 + *(void **)&info->fbops->fb_sync = NULL;
44856 + pax_close_kernel();
44857 info->flags |= FBINFO_HWACCEL_DISABLED;
44858 }
44859
44860 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44861 index 95ec042..e6affdd 100644
44862 --- a/drivers/video/aty/mach64_cursor.c
44863 +++ b/drivers/video/aty/mach64_cursor.c
44864 @@ -7,6 +7,7 @@
44865 #include <linux/string.h>
44866
44867 #include <asm/io.h>
44868 +#include <asm/pgtable.h>
44869
44870 #ifdef __sparc__
44871 #include <asm/fbio.h>
44872 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44873 info->sprite.buf_align = 16; /* and 64 lines tall. */
44874 info->sprite.flags = FB_PIXMAP_IO;
44875
44876 - info->fbops->fb_cursor = atyfb_cursor;
44877 + pax_open_kernel();
44878 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44879 + pax_close_kernel();
44880
44881 return 0;
44882 }
44883 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44884 index 6c5ed6b..b727c88 100644
44885 --- a/drivers/video/backlight/kb3886_bl.c
44886 +++ b/drivers/video/backlight/kb3886_bl.c
44887 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44888 static unsigned long kb3886bl_flags;
44889 #define KB3886BL_SUSPENDED 0x01
44890
44891 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44892 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44893 {
44894 .ident = "Sahara Touch-iT",
44895 .matches = {
44896 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44897 index 900aa4e..6d49418 100644
44898 --- a/drivers/video/fb_defio.c
44899 +++ b/drivers/video/fb_defio.c
44900 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44901
44902 BUG_ON(!fbdefio);
44903 mutex_init(&fbdefio->lock);
44904 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44905 + pax_open_kernel();
44906 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44907 + pax_close_kernel();
44908 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44909 INIT_LIST_HEAD(&fbdefio->pagelist);
44910 if (fbdefio->delay == 0) /* set a default of 1 s */
44911 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44912 page->mapping = NULL;
44913 }
44914
44915 - info->fbops->fb_mmap = NULL;
44916 + *(void **)&info->fbops->fb_mmap = NULL;
44917 mutex_destroy(&fbdefio->lock);
44918 }
44919 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44920 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44921 index 5c3960d..15cf8fc 100644
44922 --- a/drivers/video/fbcmap.c
44923 +++ b/drivers/video/fbcmap.c
44924 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44925 rc = -ENODEV;
44926 goto out;
44927 }
44928 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44929 - !info->fbops->fb_setcmap)) {
44930 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44931 rc = -EINVAL;
44932 goto out1;
44933 }
44934 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44935 index 86291dc..7cc5962 100644
44936 --- a/drivers/video/fbmem.c
44937 +++ b/drivers/video/fbmem.c
44938 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44939 image->dx += image->width + 8;
44940 }
44941 } else if (rotate == FB_ROTATE_UD) {
44942 - for (x = 0; x < num && image->dx >= 0; x++) {
44943 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44944 info->fbops->fb_imageblit(info, image);
44945 image->dx -= image->width + 8;
44946 }
44947 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44948 image->dy += image->height + 8;
44949 }
44950 } else if (rotate == FB_ROTATE_CCW) {
44951 - for (x = 0; x < num && image->dy >= 0; x++) {
44952 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44953 info->fbops->fb_imageblit(info, image);
44954 image->dy -= image->height + 8;
44955 }
44956 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44957 return -EFAULT;
44958 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44959 return -EINVAL;
44960 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44961 + if (con2fb.framebuffer >= FB_MAX)
44962 return -EINVAL;
44963 if (!registered_fb[con2fb.framebuffer])
44964 request_module("fb%d", con2fb.framebuffer);
44965 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44966 index 7672d2e..b56437f 100644
44967 --- a/drivers/video/i810/i810_accel.c
44968 +++ b/drivers/video/i810/i810_accel.c
44969 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44970 }
44971 }
44972 printk("ringbuffer lockup!!!\n");
44973 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44974 i810_report_error(mmio);
44975 par->dev_flags |= LOCKUP;
44976 info->pixmap.scan_align = 1;
44977 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44978 index 3c14e43..eafa544 100644
44979 --- a/drivers/video/logo/logo_linux_clut224.ppm
44980 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44981 @@ -1,1604 +1,1123 @@
44982 P3
44983 -# Standard 224-color Linux logo
44984 80 80
44985 255
44986 - 0 0 0 0 0 0 0 0 0 0 0 0
44987 - 0 0 0 0 0 0 0 0 0 0 0 0
44988 - 0 0 0 0 0 0 0 0 0 0 0 0
44989 - 0 0 0 0 0 0 0 0 0 0 0 0
44990 - 0 0 0 0 0 0 0 0 0 0 0 0
44991 - 0 0 0 0 0 0 0 0 0 0 0 0
44992 - 0 0 0 0 0 0 0 0 0 0 0 0
44993 - 0 0 0 0 0 0 0 0 0 0 0 0
44994 - 0 0 0 0 0 0 0 0 0 0 0 0
44995 - 6 6 6 6 6 6 10 10 10 10 10 10
44996 - 10 10 10 6 6 6 6 6 6 6 6 6
44997 - 0 0 0 0 0 0 0 0 0 0 0 0
44998 - 0 0 0 0 0 0 0 0 0 0 0 0
44999 - 0 0 0 0 0 0 0 0 0 0 0 0
45000 - 0 0 0 0 0 0 0 0 0 0 0 0
45001 - 0 0 0 0 0 0 0 0 0 0 0 0
45002 - 0 0 0 0 0 0 0 0 0 0 0 0
45003 - 0 0 0 0 0 0 0 0 0 0 0 0
45004 - 0 0 0 0 0 0 0 0 0 0 0 0
45005 - 0 0 0 0 0 0 0 0 0 0 0 0
45006 - 0 0 0 0 0 0 0 0 0 0 0 0
45007 - 0 0 0 0 0 0 0 0 0 0 0 0
45008 - 0 0 0 0 0 0 0 0 0 0 0 0
45009 - 0 0 0 0 0 0 0 0 0 0 0 0
45010 - 0 0 0 0 0 0 0 0 0 0 0 0
45011 - 0 0 0 0 0 0 0 0 0 0 0 0
45012 - 0 0 0 0 0 0 0 0 0 0 0 0
45013 - 0 0 0 0 0 0 0 0 0 0 0 0
45014 - 0 0 0 6 6 6 10 10 10 14 14 14
45015 - 22 22 22 26 26 26 30 30 30 34 34 34
45016 - 30 30 30 30 30 30 26 26 26 18 18 18
45017 - 14 14 14 10 10 10 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45026 - 0 0 0 0 0 0 0 0 0 0 0 0
45027 - 0 0 0 0 0 1 0 0 1 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 - 6 6 6 14 14 14 26 26 26 42 42 42
45035 - 54 54 54 66 66 66 78 78 78 78 78 78
45036 - 78 78 78 74 74 74 66 66 66 54 54 54
45037 - 42 42 42 26 26 26 18 18 18 10 10 10
45038 - 6 6 6 0 0 0 0 0 0 0 0 0
45039 - 0 0 0 0 0 0 0 0 0 0 0 0
45040 - 0 0 0 0 0 0 0 0 0 0 0 0
45041 - 0 0 0 0 0 0 0 0 0 0 0 0
45042 - 0 0 0 0 0 0 0 0 0 0 0 0
45043 - 0 0 0 0 0 0 0 0 0 0 0 0
45044 - 0 0 0 0 0 0 0 0 0 0 0 0
45045 - 0 0 0 0 0 0 0 0 0 0 0 0
45046 - 0 0 0 0 0 0 0 0 0 0 0 0
45047 - 0 0 1 0 0 0 0 0 0 0 0 0
45048 - 0 0 0 0 0 0 0 0 0 0 0 0
45049 - 0 0 0 0 0 0 0 0 0 0 0 0
45050 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45054 - 22 22 22 42 42 42 66 66 66 86 86 86
45055 - 66 66 66 38 38 38 38 38 38 22 22 22
45056 - 26 26 26 34 34 34 54 54 54 66 66 66
45057 - 86 86 86 70 70 70 46 46 46 26 26 26
45058 - 14 14 14 6 6 6 0 0 0 0 0 0
45059 - 0 0 0 0 0 0 0 0 0 0 0 0
45060 - 0 0 0 0 0 0 0 0 0 0 0 0
45061 - 0 0 0 0 0 0 0 0 0 0 0 0
45062 - 0 0 0 0 0 0 0 0 0 0 0 0
45063 - 0 0 0 0 0 0 0 0 0 0 0 0
45064 - 0 0 0 0 0 0 0 0 0 0 0 0
45065 - 0 0 0 0 0 0 0 0 0 0 0 0
45066 - 0 0 0 0 0 0 0 0 0 0 0 0
45067 - 0 0 1 0 0 1 0 0 1 0 0 0
45068 - 0 0 0 0 0 0 0 0 0 0 0 0
45069 - 0 0 0 0 0 0 0 0 0 0 0 0
45070 - 0 0 0 0 0 0 0 0 0 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 10 10 10 26 26 26
45074 - 50 50 50 82 82 82 58 58 58 6 6 6
45075 - 2 2 6 2 2 6 2 2 6 2 2 6
45076 - 2 2 6 2 2 6 2 2 6 2 2 6
45077 - 6 6 6 54 54 54 86 86 86 66 66 66
45078 - 38 38 38 18 18 18 6 6 6 0 0 0
45079 - 0 0 0 0 0 0 0 0 0 0 0 0
45080 - 0 0 0 0 0 0 0 0 0 0 0 0
45081 - 0 0 0 0 0 0 0 0 0 0 0 0
45082 - 0 0 0 0 0 0 0 0 0 0 0 0
45083 - 0 0 0 0 0 0 0 0 0 0 0 0
45084 - 0 0 0 0 0 0 0 0 0 0 0 0
45085 - 0 0 0 0 0 0 0 0 0 0 0 0
45086 - 0 0 0 0 0 0 0 0 0 0 0 0
45087 - 0 0 0 0 0 0 0 0 0 0 0 0
45088 - 0 0 0 0 0 0 0 0 0 0 0 0
45089 - 0 0 0 0 0 0 0 0 0 0 0 0
45090 - 0 0 0 0 0 0 0 0 0 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 6 6 6 22 22 22 50 50 50
45094 - 78 78 78 34 34 34 2 2 6 2 2 6
45095 - 2 2 6 2 2 6 2 2 6 2 2 6
45096 - 2 2 6 2 2 6 2 2 6 2 2 6
45097 - 2 2 6 2 2 6 6 6 6 70 70 70
45098 - 78 78 78 46 46 46 22 22 22 6 6 6
45099 - 0 0 0 0 0 0 0 0 0 0 0 0
45100 - 0 0 0 0 0 0 0 0 0 0 0 0
45101 - 0 0 0 0 0 0 0 0 0 0 0 0
45102 - 0 0 0 0 0 0 0 0 0 0 0 0
45103 - 0 0 0 0 0 0 0 0 0 0 0 0
45104 - 0 0 0 0 0 0 0 0 0 0 0 0
45105 - 0 0 0 0 0 0 0 0 0 0 0 0
45106 - 0 0 0 0 0 0 0 0 0 0 0 0
45107 - 0 0 1 0 0 1 0 0 1 0 0 0
45108 - 0 0 0 0 0 0 0 0 0 0 0 0
45109 - 0 0 0 0 0 0 0 0 0 0 0 0
45110 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 18 18 18 42 42 42 82 82 82
45114 - 26 26 26 2 2 6 2 2 6 2 2 6
45115 - 2 2 6 2 2 6 2 2 6 2 2 6
45116 - 2 2 6 2 2 6 2 2 6 14 14 14
45117 - 46 46 46 34 34 34 6 6 6 2 2 6
45118 - 42 42 42 78 78 78 42 42 42 18 18 18
45119 - 6 6 6 0 0 0 0 0 0 0 0 0
45120 - 0 0 0 0 0 0 0 0 0 0 0 0
45121 - 0 0 0 0 0 0 0 0 0 0 0 0
45122 - 0 0 0 0 0 0 0 0 0 0 0 0
45123 - 0 0 0 0 0 0 0 0 0 0 0 0
45124 - 0 0 0 0 0 0 0 0 0 0 0 0
45125 - 0 0 0 0 0 0 0 0 0 0 0 0
45126 - 0 0 0 0 0 0 0 0 0 0 0 0
45127 - 0 0 1 0 0 0 0 0 1 0 0 0
45128 - 0 0 0 0 0 0 0 0 0 0 0 0
45129 - 0 0 0 0 0 0 0 0 0 0 0 0
45130 - 0 0 0 0 0 0 0 0 0 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 - 10 10 10 30 30 30 66 66 66 58 58 58
45134 - 2 2 6 2 2 6 2 2 6 2 2 6
45135 - 2 2 6 2 2 6 2 2 6 2 2 6
45136 - 2 2 6 2 2 6 2 2 6 26 26 26
45137 - 86 86 86 101 101 101 46 46 46 10 10 10
45138 - 2 2 6 58 58 58 70 70 70 34 34 34
45139 - 10 10 10 0 0 0 0 0 0 0 0 0
45140 - 0 0 0 0 0 0 0 0 0 0 0 0
45141 - 0 0 0 0 0 0 0 0 0 0 0 0
45142 - 0 0 0 0 0 0 0 0 0 0 0 0
45143 - 0 0 0 0 0 0 0 0 0 0 0 0
45144 - 0 0 0 0 0 0 0 0 0 0 0 0
45145 - 0 0 0 0 0 0 0 0 0 0 0 0
45146 - 0 0 0 0 0 0 0 0 0 0 0 0
45147 - 0 0 1 0 0 1 0 0 1 0 0 0
45148 - 0 0 0 0 0 0 0 0 0 0 0 0
45149 - 0 0 0 0 0 0 0 0 0 0 0 0
45150 - 0 0 0 0 0 0 0 0 0 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 - 14 14 14 42 42 42 86 86 86 10 10 10
45154 - 2 2 6 2 2 6 2 2 6 2 2 6
45155 - 2 2 6 2 2 6 2 2 6 2 2 6
45156 - 2 2 6 2 2 6 2 2 6 30 30 30
45157 - 94 94 94 94 94 94 58 58 58 26 26 26
45158 - 2 2 6 6 6 6 78 78 78 54 54 54
45159 - 22 22 22 6 6 6 0 0 0 0 0 0
45160 - 0 0 0 0 0 0 0 0 0 0 0 0
45161 - 0 0 0 0 0 0 0 0 0 0 0 0
45162 - 0 0 0 0 0 0 0 0 0 0 0 0
45163 - 0 0 0 0 0 0 0 0 0 0 0 0
45164 - 0 0 0 0 0 0 0 0 0 0 0 0
45165 - 0 0 0 0 0 0 0 0 0 0 0 0
45166 - 0 0 0 0 0 0 0 0 0 0 0 0
45167 - 0 0 0 0 0 0 0 0 0 0 0 0
45168 - 0 0 0 0 0 0 0 0 0 0 0 0
45169 - 0 0 0 0 0 0 0 0 0 0 0 0
45170 - 0 0 0 0 0 0 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 6 6 6
45173 - 22 22 22 62 62 62 62 62 62 2 2 6
45174 - 2 2 6 2 2 6 2 2 6 2 2 6
45175 - 2 2 6 2 2 6 2 2 6 2 2 6
45176 - 2 2 6 2 2 6 2 2 6 26 26 26
45177 - 54 54 54 38 38 38 18 18 18 10 10 10
45178 - 2 2 6 2 2 6 34 34 34 82 82 82
45179 - 38 38 38 14 14 14 0 0 0 0 0 0
45180 - 0 0 0 0 0 0 0 0 0 0 0 0
45181 - 0 0 0 0 0 0 0 0 0 0 0 0
45182 - 0 0 0 0 0 0 0 0 0 0 0 0
45183 - 0 0 0 0 0 0 0 0 0 0 0 0
45184 - 0 0 0 0 0 0 0 0 0 0 0 0
45185 - 0 0 0 0 0 0 0 0 0 0 0 0
45186 - 0 0 0 0 0 0 0 0 0 0 0 0
45187 - 0 0 0 0 0 1 0 0 1 0 0 0
45188 - 0 0 0 0 0 0 0 0 0 0 0 0
45189 - 0 0 0 0 0 0 0 0 0 0 0 0
45190 - 0 0 0 0 0 0 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 6 6 6
45193 - 30 30 30 78 78 78 30 30 30 2 2 6
45194 - 2 2 6 2 2 6 2 2 6 2 2 6
45195 - 2 2 6 2 2 6 2 2 6 2 2 6
45196 - 2 2 6 2 2 6 2 2 6 10 10 10
45197 - 10 10 10 2 2 6 2 2 6 2 2 6
45198 - 2 2 6 2 2 6 2 2 6 78 78 78
45199 - 50 50 50 18 18 18 6 6 6 0 0 0
45200 - 0 0 0 0 0 0 0 0 0 0 0 0
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 0 0 0 0 0 0 0 0 0 0 0 0
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 0 0 0 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 0 0 0 0 0 0
45206 - 0 0 0 0 0 0 0 0 0 0 0 0
45207 - 0 0 1 0 0 0 0 0 0 0 0 0
45208 - 0 0 0 0 0 0 0 0 0 0 0 0
45209 - 0 0 0 0 0 0 0 0 0 0 0 0
45210 - 0 0 0 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 10 10 10
45213 - 38 38 38 86 86 86 14 14 14 2 2 6
45214 - 2 2 6 2 2 6 2 2 6 2 2 6
45215 - 2 2 6 2 2 6 2 2 6 2 2 6
45216 - 2 2 6 2 2 6 2 2 6 2 2 6
45217 - 2 2 6 2 2 6 2 2 6 2 2 6
45218 - 2 2 6 2 2 6 2 2 6 54 54 54
45219 - 66 66 66 26 26 26 6 6 6 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 0 0 0
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 0 0 0 0 0 0 0 0 0 0 0 0
45225 - 0 0 0 0 0 0 0 0 0 0 0 0
45226 - 0 0 0 0 0 0 0 0 0 0 0 0
45227 - 0 0 0 0 0 1 0 0 1 0 0 0
45228 - 0 0 0 0 0 0 0 0 0 0 0 0
45229 - 0 0 0 0 0 0 0 0 0 0 0 0
45230 - 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 14 14 14
45233 - 42 42 42 82 82 82 2 2 6 2 2 6
45234 - 2 2 6 6 6 6 10 10 10 2 2 6
45235 - 2 2 6 2 2 6 2 2 6 2 2 6
45236 - 2 2 6 2 2 6 2 2 6 6 6 6
45237 - 14 14 14 10 10 10 2 2 6 2 2 6
45238 - 2 2 6 2 2 6 2 2 6 18 18 18
45239 - 82 82 82 34 34 34 10 10 10 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 0 0 0 0 0 0 0 0 0 0 0 0
45245 - 0 0 0 0 0 0 0 0 0 0 0 0
45246 - 0 0 0 0 0 0 0 0 0 0 0 0
45247 - 0 0 1 0 0 0 0 0 0 0 0 0
45248 - 0 0 0 0 0 0 0 0 0 0 0 0
45249 - 0 0 0 0 0 0 0 0 0 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 14 14 14
45253 - 46 46 46 86 86 86 2 2 6 2 2 6
45254 - 6 6 6 6 6 6 22 22 22 34 34 34
45255 - 6 6 6 2 2 6 2 2 6 2 2 6
45256 - 2 2 6 2 2 6 18 18 18 34 34 34
45257 - 10 10 10 50 50 50 22 22 22 2 2 6
45258 - 2 2 6 2 2 6 2 2 6 10 10 10
45259 - 86 86 86 42 42 42 14 14 14 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 0 0 0 0 0 0 0 0 0 0
45263 - 0 0 0 0 0 0 0 0 0 0 0 0
45264 - 0 0 0 0 0 0 0 0 0 0 0 0
45265 - 0 0 0 0 0 0 0 0 0 0 0 0
45266 - 0 0 0 0 0 0 0 0 0 0 0 0
45267 - 0 0 1 0 0 1 0 0 1 0 0 0
45268 - 0 0 0 0 0 0 0 0 0 0 0 0
45269 - 0 0 0 0 0 0 0 0 0 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 14 14 14
45273 - 46 46 46 86 86 86 2 2 6 2 2 6
45274 - 38 38 38 116 116 116 94 94 94 22 22 22
45275 - 22 22 22 2 2 6 2 2 6 2 2 6
45276 - 14 14 14 86 86 86 138 138 138 162 162 162
45277 -154 154 154 38 38 38 26 26 26 6 6 6
45278 - 2 2 6 2 2 6 2 2 6 2 2 6
45279 - 86 86 86 46 46 46 14 14 14 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 0 0 0 0 0 0 0 0 0 0
45283 - 0 0 0 0 0 0 0 0 0 0 0 0
45284 - 0 0 0 0 0 0 0 0 0 0 0 0
45285 - 0 0 0 0 0 0 0 0 0 0 0 0
45286 - 0 0 0 0 0 0 0 0 0 0 0 0
45287 - 0 0 0 0 0 0 0 0 0 0 0 0
45288 - 0 0 0 0 0 0 0 0 0 0 0 0
45289 - 0 0 0 0 0 0 0 0 0 0 0 0
45290 - 0 0 0 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 14 14 14
45293 - 46 46 46 86 86 86 2 2 6 14 14 14
45294 -134 134 134 198 198 198 195 195 195 116 116 116
45295 - 10 10 10 2 2 6 2 2 6 6 6 6
45296 -101 98 89 187 187 187 210 210 210 218 218 218
45297 -214 214 214 134 134 134 14 14 14 6 6 6
45298 - 2 2 6 2 2 6 2 2 6 2 2 6
45299 - 86 86 86 50 50 50 18 18 18 6 6 6
45300 - 0 0 0 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 0 0 0
45305 - 0 0 0 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 0 0 0 0 0 1 0 0 0
45307 - 0 0 1 0 0 1 0 0 1 0 0 0
45308 - 0 0 0 0 0 0 0 0 0 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 0 0 0 0 0 0 0 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 14 14 14
45313 - 46 46 46 86 86 86 2 2 6 54 54 54
45314 -218 218 218 195 195 195 226 226 226 246 246 246
45315 - 58 58 58 2 2 6 2 2 6 30 30 30
45316 -210 210 210 253 253 253 174 174 174 123 123 123
45317 -221 221 221 234 234 234 74 74 74 2 2 6
45318 - 2 2 6 2 2 6 2 2 6 2 2 6
45319 - 70 70 70 58 58 58 22 22 22 6 6 6
45320 - 0 0 0 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 0 0 0
45322 - 0 0 0 0 0 0 0 0 0 0 0 0
45323 - 0 0 0 0 0 0 0 0 0 0 0 0
45324 - 0 0 0 0 0 0 0 0 0 0 0 0
45325 - 0 0 0 0 0 0 0 0 0 0 0 0
45326 - 0 0 0 0 0 0 0 0 0 0 0 0
45327 - 0 0 0 0 0 0 0 0 0 0 0 0
45328 - 0 0 0 0 0 0 0 0 0 0 0 0
45329 - 0 0 0 0 0 0 0 0 0 0 0 0
45330 - 0 0 0 0 0 0 0 0 0 0 0 0
45331 - 0 0 0 0 0 0 0 0 0 0 0 0
45332 - 0 0 0 0 0 0 0 0 0 14 14 14
45333 - 46 46 46 82 82 82 2 2 6 106 106 106
45334 -170 170 170 26 26 26 86 86 86 226 226 226
45335 -123 123 123 10 10 10 14 14 14 46 46 46
45336 -231 231 231 190 190 190 6 6 6 70 70 70
45337 - 90 90 90 238 238 238 158 158 158 2 2 6
45338 - 2 2 6 2 2 6 2 2 6 2 2 6
45339 - 70 70 70 58 58 58 22 22 22 6 6 6
45340 - 0 0 0 0 0 0 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 0 0 0
45342 - 0 0 0 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 0 0 0 0 0 0 0 0 0
45344 - 0 0 0 0 0 0 0 0 0 0 0 0
45345 - 0 0 0 0 0 0 0 0 0 0 0 0
45346 - 0 0 0 0 0 0 0 0 1 0 0 0
45347 - 0 0 1 0 0 1 0 0 1 0 0 0
45348 - 0 0 0 0 0 0 0 0 0 0 0 0
45349 - 0 0 0 0 0 0 0 0 0 0 0 0
45350 - 0 0 0 0 0 0 0 0 0 0 0 0
45351 - 0 0 0 0 0 0 0 0 0 0 0 0
45352 - 0 0 0 0 0 0 0 0 0 14 14 14
45353 - 42 42 42 86 86 86 6 6 6 116 116 116
45354 -106 106 106 6 6 6 70 70 70 149 149 149
45355 -128 128 128 18 18 18 38 38 38 54 54 54
45356 -221 221 221 106 106 106 2 2 6 14 14 14
45357 - 46 46 46 190 190 190 198 198 198 2 2 6
45358 - 2 2 6 2 2 6 2 2 6 2 2 6
45359 - 74 74 74 62 62 62 22 22 22 6 6 6
45360 - 0 0 0 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 0 0 0 0 0 0 0
45363 - 0 0 0 0 0 0 0 0 0 0 0 0
45364 - 0 0 0 0 0 0 0 0 0 0 0 0
45365 - 0 0 0 0 0 0 0 0 0 0 0 0
45366 - 0 0 0 0 0 0 0 0 1 0 0 0
45367 - 0 0 1 0 0 0 0 0 1 0 0 0
45368 - 0 0 0 0 0 0 0 0 0 0 0 0
45369 - 0 0 0 0 0 0 0 0 0 0 0 0
45370 - 0 0 0 0 0 0 0 0 0 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 14 14 14
45373 - 42 42 42 94 94 94 14 14 14 101 101 101
45374 -128 128 128 2 2 6 18 18 18 116 116 116
45375 -118 98 46 121 92 8 121 92 8 98 78 10
45376 -162 162 162 106 106 106 2 2 6 2 2 6
45377 - 2 2 6 195 195 195 195 195 195 6 6 6
45378 - 2 2 6 2 2 6 2 2 6 2 2 6
45379 - 74 74 74 62 62 62 22 22 22 6 6 6
45380 - 0 0 0 0 0 0 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 0 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 0 0 0 0 0 0 0 0 0
45384 - 0 0 0 0 0 0 0 0 0 0 0 0
45385 - 0 0 0 0 0 0 0 0 0 0 0 0
45386 - 0 0 0 0 0 0 0 0 1 0 0 1
45387 - 0 0 1 0 0 0 0 0 1 0 0 0
45388 - 0 0 0 0 0 0 0 0 0 0 0 0
45389 - 0 0 0 0 0 0 0 0 0 0 0 0
45390 - 0 0 0 0 0 0 0 0 0 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 0 0 0
45392 - 0 0 0 0 0 0 0 0 0 10 10 10
45393 - 38 38 38 90 90 90 14 14 14 58 58 58
45394 -210 210 210 26 26 26 54 38 6 154 114 10
45395 -226 170 11 236 186 11 225 175 15 184 144 12
45396 -215 174 15 175 146 61 37 26 9 2 2 6
45397 - 70 70 70 246 246 246 138 138 138 2 2 6
45398 - 2 2 6 2 2 6 2 2 6 2 2 6
45399 - 70 70 70 66 66 66 26 26 26 6 6 6
45400 - 0 0 0 0 0 0 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 0 0 0 0 0 0 0
45403 - 0 0 0 0 0 0 0 0 0 0 0 0
45404 - 0 0 0 0 0 0 0 0 0 0 0 0
45405 - 0 0 0 0 0 0 0 0 0 0 0 0
45406 - 0 0 0 0 0 0 0 0 0 0 0 0
45407 - 0 0 0 0 0 0 0 0 0 0 0 0
45408 - 0 0 0 0 0 0 0 0 0 0 0 0
45409 - 0 0 0 0 0 0 0 0 0 0 0 0
45410 - 0 0 0 0 0 0 0 0 0 0 0 0
45411 - 0 0 0 0 0 0 0 0 0 0 0 0
45412 - 0 0 0 0 0 0 0 0 0 10 10 10
45413 - 38 38 38 86 86 86 14 14 14 10 10 10
45414 -195 195 195 188 164 115 192 133 9 225 175 15
45415 -239 182 13 234 190 10 232 195 16 232 200 30
45416 -245 207 45 241 208 19 232 195 16 184 144 12
45417 -218 194 134 211 206 186 42 42 42 2 2 6
45418 - 2 2 6 2 2 6 2 2 6 2 2 6
45419 - 50 50 50 74 74 74 30 30 30 6 6 6
45420 - 0 0 0 0 0 0 0 0 0 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 0 0 0
45423 - 0 0 0 0 0 0 0 0 0 0 0 0
45424 - 0 0 0 0 0 0 0 0 0 0 0 0
45425 - 0 0 0 0 0 0 0 0 0 0 0 0
45426 - 0 0 0 0 0 0 0 0 0 0 0 0
45427 - 0 0 0 0 0 0 0 0 0 0 0 0
45428 - 0 0 0 0 0 0 0 0 0 0 0 0
45429 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
45433 - 34 34 34 86 86 86 14 14 14 2 2 6
45434 -121 87 25 192 133 9 219 162 10 239 182 13
45435 -236 186 11 232 195 16 241 208 19 244 214 54
45436 -246 218 60 246 218 38 246 215 20 241 208 19
45437 -241 208 19 226 184 13 121 87 25 2 2 6
45438 - 2 2 6 2 2 6 2 2 6 2 2 6
45439 - 50 50 50 82 82 82 34 34 34 10 10 10
45440 - 0 0 0 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 0 0 0 0 0 0 0
45443 - 0 0 0 0 0 0 0 0 0 0 0 0
45444 - 0 0 0 0 0 0 0 0 0 0 0 0
45445 - 0 0 0 0 0 0 0 0 0 0 0 0
45446 - 0 0 0 0 0 0 0 0 0 0 0 0
45447 - 0 0 0 0 0 0 0 0 0 0 0 0
45448 - 0 0 0 0 0 0 0 0 0 0 0 0
45449 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
45453 - 34 34 34 82 82 82 30 30 30 61 42 6
45454 -180 123 7 206 145 10 230 174 11 239 182 13
45455 -234 190 10 238 202 15 241 208 19 246 218 74
45456 -246 218 38 246 215 20 246 215 20 246 215 20
45457 -226 184 13 215 174 15 184 144 12 6 6 6
45458 - 2 2 6 2 2 6 2 2 6 2 2 6
45459 - 26 26 26 94 94 94 42 42 42 14 14 14
45460 - 0 0 0 0 0 0 0 0 0 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 0 0 0
45463 - 0 0 0 0 0 0 0 0 0 0 0 0
45464 - 0 0 0 0 0 0 0 0 0 0 0 0
45465 - 0 0 0 0 0 0 0 0 0 0 0 0
45466 - 0 0 0 0 0 0 0 0 0 0 0 0
45467 - 0 0 0 0 0 0 0 0 0 0 0 0
45468 - 0 0 0 0 0 0 0 0 0 0 0 0
45469 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
45473 - 30 30 30 78 78 78 50 50 50 104 69 6
45474 -192 133 9 216 158 10 236 178 12 236 186 11
45475 -232 195 16 241 208 19 244 214 54 245 215 43
45476 -246 215 20 246 215 20 241 208 19 198 155 10
45477 -200 144 11 216 158 10 156 118 10 2 2 6
45478 - 2 2 6 2 2 6 2 2 6 2 2 6
45479 - 6 6 6 90 90 90 54 54 54 18 18 18
45480 - 6 6 6 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 0 0 0 0 0 0 0 0 0 0
45483 - 0 0 0 0 0 0 0 0 0 0 0 0
45484 - 0 0 0 0 0 0 0 0 0 0 0 0
45485 - 0 0 0 0 0 0 0 0 0 0 0 0
45486 - 0 0 0 0 0 0 0 0 0 0 0 0
45487 - 0 0 0 0 0 0 0 0 0 0 0 0
45488 - 0 0 0 0 0 0 0 0 0 0 0 0
45489 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
45493 - 30 30 30 78 78 78 46 46 46 22 22 22
45494 -137 92 6 210 162 10 239 182 13 238 190 10
45495 -238 202 15 241 208 19 246 215 20 246 215 20
45496 -241 208 19 203 166 17 185 133 11 210 150 10
45497 -216 158 10 210 150 10 102 78 10 2 2 6
45498 - 6 6 6 54 54 54 14 14 14 2 2 6
45499 - 2 2 6 62 62 62 74 74 74 30 30 30
45500 - 10 10 10 0 0 0 0 0 0 0 0 0
45501 - 0 0 0 0 0 0 0 0 0 0 0 0
45502 - 0 0 0 0 0 0 0 0 0 0 0 0
45503 - 0 0 0 0 0 0 0 0 0 0 0 0
45504 - 0 0 0 0 0 0 0 0 0 0 0 0
45505 - 0 0 0 0 0 0 0 0 0 0 0 0
45506 - 0 0 0 0 0 0 0 0 0 0 0 0
45507 - 0 0 0 0 0 0 0 0 0 0 0 0
45508 - 0 0 0 0 0 0 0 0 0 0 0 0
45509 - 0 0 0 0 0 0 0 0 0 0 0 0
45510 - 0 0 0 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 10 10 10
45513 - 34 34 34 78 78 78 50 50 50 6 6 6
45514 - 94 70 30 139 102 15 190 146 13 226 184 13
45515 -232 200 30 232 195 16 215 174 15 190 146 13
45516 -168 122 10 192 133 9 210 150 10 213 154 11
45517 -202 150 34 182 157 106 101 98 89 2 2 6
45518 - 2 2 6 78 78 78 116 116 116 58 58 58
45519 - 2 2 6 22 22 22 90 90 90 46 46 46
45520 - 18 18 18 6 6 6 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 0 0 0 0
45522 - 0 0 0 0 0 0 0 0 0 0 0 0
45523 - 0 0 0 0 0 0 0 0 0 0 0 0
45524 - 0 0 0 0 0 0 0 0 0 0 0 0
45525 - 0 0 0 0 0 0 0 0 0 0 0 0
45526 - 0 0 0 0 0 0 0 0 0 0 0 0
45527 - 0 0 0 0 0 0 0 0 0 0 0 0
45528 - 0 0 0 0 0 0 0 0 0 0 0 0
45529 - 0 0 0 0 0 0 0 0 0 0 0 0
45530 - 0 0 0 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 10 10 10
45533 - 38 38 38 86 86 86 50 50 50 6 6 6
45534 -128 128 128 174 154 114 156 107 11 168 122 10
45535 -198 155 10 184 144 12 197 138 11 200 144 11
45536 -206 145 10 206 145 10 197 138 11 188 164 115
45537 -195 195 195 198 198 198 174 174 174 14 14 14
45538 - 2 2 6 22 22 22 116 116 116 116 116 116
45539 - 22 22 22 2 2 6 74 74 74 70 70 70
45540 - 30 30 30 10 10 10 0 0 0 0 0 0
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 0 0 0
45543 - 0 0 0 0 0 0 0 0 0 0 0 0
45544 - 0 0 0 0 0 0 0 0 0 0 0 0
45545 - 0 0 0 0 0 0 0 0 0 0 0 0
45546 - 0 0 0 0 0 0 0 0 0 0 0 0
45547 - 0 0 0 0 0 0 0 0 0 0 0 0
45548 - 0 0 0 0 0 0 0 0 0 0 0 0
45549 - 0 0 0 0 0 0 0 0 0 0 0 0
45550 - 0 0 0 0 0 0 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 6 6 6 18 18 18
45553 - 50 50 50 101 101 101 26 26 26 10 10 10
45554 -138 138 138 190 190 190 174 154 114 156 107 11
45555 -197 138 11 200 144 11 197 138 11 192 133 9
45556 -180 123 7 190 142 34 190 178 144 187 187 187
45557 -202 202 202 221 221 221 214 214 214 66 66 66
45558 - 2 2 6 2 2 6 50 50 50 62 62 62
45559 - 6 6 6 2 2 6 10 10 10 90 90 90
45560 - 50 50 50 18 18 18 6 6 6 0 0 0
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 0 0 0 0 0 0
45563 - 0 0 0 0 0 0 0 0 0 0 0 0
45564 - 0 0 0 0 0 0 0 0 0 0 0 0
45565 - 0 0 0 0 0 0 0 0 0 0 0 0
45566 - 0 0 0 0 0 0 0 0 0 0 0 0
45567 - 0 0 0 0 0 0 0 0 0 0 0 0
45568 - 0 0 0 0 0 0 0 0 0 0 0 0
45569 - 0 0 0 0 0 0 0 0 0 0 0 0
45570 - 0 0 0 0 0 0 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 10 10 10 34 34 34
45573 - 74 74 74 74 74 74 2 2 6 6 6 6
45574 -144 144 144 198 198 198 190 190 190 178 166 146
45575 -154 121 60 156 107 11 156 107 11 168 124 44
45576 -174 154 114 187 187 187 190 190 190 210 210 210
45577 -246 246 246 253 253 253 253 253 253 182 182 182
45578 - 6 6 6 2 2 6 2 2 6 2 2 6
45579 - 2 2 6 2 2 6 2 2 6 62 62 62
45580 - 74 74 74 34 34 34 14 14 14 0 0 0
45581 - 0 0 0 0 0 0 0 0 0 0 0 0
45582 - 0 0 0 0 0 0 0 0 0 0 0 0
45583 - 0 0 0 0 0 0 0 0 0 0 0 0
45584 - 0 0 0 0 0 0 0 0 0 0 0 0
45585 - 0 0 0 0 0 0 0 0 0 0 0 0
45586 - 0 0 0 0 0 0 0 0 0 0 0 0
45587 - 0 0 0 0 0 0 0 0 0 0 0 0
45588 - 0 0 0 0 0 0 0 0 0 0 0 0
45589 - 0 0 0 0 0 0 0 0 0 0 0 0
45590 - 0 0 0 0 0 0 0 0 0 0 0 0
45591 - 0 0 0 0 0 0 0 0 0 0 0 0
45592 - 0 0 0 10 10 10 22 22 22 54 54 54
45593 - 94 94 94 18 18 18 2 2 6 46 46 46
45594 -234 234 234 221 221 221 190 190 190 190 190 190
45595 -190 190 190 187 187 187 187 187 187 190 190 190
45596 -190 190 190 195 195 195 214 214 214 242 242 242
45597 -253 253 253 253 253 253 253 253 253 253 253 253
45598 - 82 82 82 2 2 6 2 2 6 2 2 6
45599 - 2 2 6 2 2 6 2 2 6 14 14 14
45600 - 86 86 86 54 54 54 22 22 22 6 6 6
45601 - 0 0 0 0 0 0 0 0 0 0 0 0
45602 - 0 0 0 0 0 0 0 0 0 0 0 0
45603 - 0 0 0 0 0 0 0 0 0 0 0 0
45604 - 0 0 0 0 0 0 0 0 0 0 0 0
45605 - 0 0 0 0 0 0 0 0 0 0 0 0
45606 - 0 0 0 0 0 0 0 0 0 0 0 0
45607 - 0 0 0 0 0 0 0 0 0 0 0 0
45608 - 0 0 0 0 0 0 0 0 0 0 0 0
45609 - 0 0 0 0 0 0 0 0 0 0 0 0
45610 - 0 0 0 0 0 0 0 0 0 0 0 0
45611 - 0 0 0 0 0 0 0 0 0 0 0 0
45612 - 6 6 6 18 18 18 46 46 46 90 90 90
45613 - 46 46 46 18 18 18 6 6 6 182 182 182
45614 -253 253 253 246 246 246 206 206 206 190 190 190
45615 -190 190 190 190 190 190 190 190 190 190 190 190
45616 -206 206 206 231 231 231 250 250 250 253 253 253
45617 -253 253 253 253 253 253 253 253 253 253 253 253
45618 -202 202 202 14 14 14 2 2 6 2 2 6
45619 - 2 2 6 2 2 6 2 2 6 2 2 6
45620 - 42 42 42 86 86 86 42 42 42 18 18 18
45621 - 6 6 6 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 0 0 0 0 0 0 0 0 0
45623 - 0 0 0 0 0 0 0 0 0 0 0 0
45624 - 0 0 0 0 0 0 0 0 0 0 0 0
45625 - 0 0 0 0 0 0 0 0 0 0 0 0
45626 - 0 0 0 0 0 0 0 0 0 0 0 0
45627 - 0 0 0 0 0 0 0 0 0 0 0 0
45628 - 0 0 0 0 0 0 0 0 0 0 0 0
45629 - 0 0 0 0 0 0 0 0 0 0 0 0
45630 - 0 0 0 0 0 0 0 0 0 0 0 0
45631 - 0 0 0 0 0 0 0 0 0 6 6 6
45632 - 14 14 14 38 38 38 74 74 74 66 66 66
45633 - 2 2 6 6 6 6 90 90 90 250 250 250
45634 -253 253 253 253 253 253 238 238 238 198 198 198
45635 -190 190 190 190 190 190 195 195 195 221 221 221
45636 -246 246 246 253 253 253 253 253 253 253 253 253
45637 -253 253 253 253 253 253 253 253 253 253 253 253
45638 -253 253 253 82 82 82 2 2 6 2 2 6
45639 - 2 2 6 2 2 6 2 2 6 2 2 6
45640 - 2 2 6 78 78 78 70 70 70 34 34 34
45641 - 14 14 14 6 6 6 0 0 0 0 0 0
45642 - 0 0 0 0 0 0 0 0 0 0 0 0
45643 - 0 0 0 0 0 0 0 0 0 0 0 0
45644 - 0 0 0 0 0 0 0 0 0 0 0 0
45645 - 0 0 0 0 0 0 0 0 0 0 0 0
45646 - 0 0 0 0 0 0 0 0 0 0 0 0
45647 - 0 0 0 0 0 0 0 0 0 0 0 0
45648 - 0 0 0 0 0 0 0 0 0 0 0 0
45649 - 0 0 0 0 0 0 0 0 0 0 0 0
45650 - 0 0 0 0 0 0 0 0 0 0 0 0
45651 - 0 0 0 0 0 0 0 0 0 14 14 14
45652 - 34 34 34 66 66 66 78 78 78 6 6 6
45653 - 2 2 6 18 18 18 218 218 218 253 253 253
45654 -253 253 253 253 253 253 253 253 253 246 246 246
45655 -226 226 226 231 231 231 246 246 246 253 253 253
45656 -253 253 253 253 253 253 253 253 253 253 253 253
45657 -253 253 253 253 253 253 253 253 253 253 253 253
45658 -253 253 253 178 178 178 2 2 6 2 2 6
45659 - 2 2 6 2 2 6 2 2 6 2 2 6
45660 - 2 2 6 18 18 18 90 90 90 62 62 62
45661 - 30 30 30 10 10 10 0 0 0 0 0 0
45662 - 0 0 0 0 0 0 0 0 0 0 0 0
45663 - 0 0 0 0 0 0 0 0 0 0 0 0
45664 - 0 0 0 0 0 0 0 0 0 0 0 0
45665 - 0 0 0 0 0 0 0 0 0 0 0 0
45666 - 0 0 0 0 0 0 0 0 0 0 0 0
45667 - 0 0 0 0 0 0 0 0 0 0 0 0
45668 - 0 0 0 0 0 0 0 0 0 0 0 0
45669 - 0 0 0 0 0 0 0 0 0 0 0 0
45670 - 0 0 0 0 0 0 0 0 0 0 0 0
45671 - 0 0 0 0 0 0 10 10 10 26 26 26
45672 - 58 58 58 90 90 90 18 18 18 2 2 6
45673 - 2 2 6 110 110 110 253 253 253 253 253 253
45674 -253 253 253 253 253 253 253 253 253 253 253 253
45675 -250 250 250 253 253 253 253 253 253 253 253 253
45676 -253 253 253 253 253 253 253 253 253 253 253 253
45677 -253 253 253 253 253 253 253 253 253 253 253 253
45678 -253 253 253 231 231 231 18 18 18 2 2 6
45679 - 2 2 6 2 2 6 2 2 6 2 2 6
45680 - 2 2 6 2 2 6 18 18 18 94 94 94
45681 - 54 54 54 26 26 26 10 10 10 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 0 0 0
45683 - 0 0 0 0 0 0 0 0 0 0 0 0
45684 - 0 0 0 0 0 0 0 0 0 0 0 0
45685 - 0 0 0 0 0 0 0 0 0 0 0 0
45686 - 0 0 0 0 0 0 0 0 0 0 0 0
45687 - 0 0 0 0 0 0 0 0 0 0 0 0
45688 - 0 0 0 0 0 0 0 0 0 0 0 0
45689 - 0 0 0 0 0 0 0 0 0 0 0 0
45690 - 0 0 0 0 0 0 0 0 0 0 0 0
45691 - 0 0 0 6 6 6 22 22 22 50 50 50
45692 - 90 90 90 26 26 26 2 2 6 2 2 6
45693 - 14 14 14 195 195 195 250 250 250 253 253 253
45694 -253 253 253 253 253 253 253 253 253 253 253 253
45695 -253 253 253 253 253 253 253 253 253 253 253 253
45696 -253 253 253 253 253 253 253 253 253 253 253 253
45697 -253 253 253 253 253 253 253 253 253 253 253 253
45698 -250 250 250 242 242 242 54 54 54 2 2 6
45699 - 2 2 6 2 2 6 2 2 6 2 2 6
45700 - 2 2 6 2 2 6 2 2 6 38 38 38
45701 - 86 86 86 50 50 50 22 22 22 6 6 6
45702 - 0 0 0 0 0 0 0 0 0 0 0 0
45703 - 0 0 0 0 0 0 0 0 0 0 0 0
45704 - 0 0 0 0 0 0 0 0 0 0 0 0
45705 - 0 0 0 0 0 0 0 0 0 0 0 0
45706 - 0 0 0 0 0 0 0 0 0 0 0 0
45707 - 0 0 0 0 0 0 0 0 0 0 0 0
45708 - 0 0 0 0 0 0 0 0 0 0 0 0
45709 - 0 0 0 0 0 0 0 0 0 0 0 0
45710 - 0 0 0 0 0 0 0 0 0 0 0 0
45711 - 6 6 6 14 14 14 38 38 38 82 82 82
45712 - 34 34 34 2 2 6 2 2 6 2 2 6
45713 - 42 42 42 195 195 195 246 246 246 253 253 253
45714 -253 253 253 253 253 253 253 253 253 250 250 250
45715 -242 242 242 242 242 242 250 250 250 253 253 253
45716 -253 253 253 253 253 253 253 253 253 253 253 253
45717 -253 253 253 250 250 250 246 246 246 238 238 238
45718 -226 226 226 231 231 231 101 101 101 6 6 6
45719 - 2 2 6 2 2 6 2 2 6 2 2 6
45720 - 2 2 6 2 2 6 2 2 6 2 2 6
45721 - 38 38 38 82 82 82 42 42 42 14 14 14
45722 - 6 6 6 0 0 0 0 0 0 0 0 0
45723 - 0 0 0 0 0 0 0 0 0 0 0 0
45724 - 0 0 0 0 0 0 0 0 0 0 0 0
45725 - 0 0 0 0 0 0 0 0 0 0 0 0
45726 - 0 0 0 0 0 0 0 0 0 0 0 0
45727 - 0 0 0 0 0 0 0 0 0 0 0 0
45728 - 0 0 0 0 0 0 0 0 0 0 0 0
45729 - 0 0 0 0 0 0 0 0 0 0 0 0
45730 - 0 0 0 0 0 0 0 0 0 0 0 0
45731 - 10 10 10 26 26 26 62 62 62 66 66 66
45732 - 2 2 6 2 2 6 2 2 6 6 6 6
45733 - 70 70 70 170 170 170 206 206 206 234 234 234
45734 -246 246 246 250 250 250 250 250 250 238 238 238
45735 -226 226 226 231 231 231 238 238 238 250 250 250
45736 -250 250 250 250 250 250 246 246 246 231 231 231
45737 -214 214 214 206 206 206 202 202 202 202 202 202
45738 -198 198 198 202 202 202 182 182 182 18 18 18
45739 - 2 2 6 2 2 6 2 2 6 2 2 6
45740 - 2 2 6 2 2 6 2 2 6 2 2 6
45741 - 2 2 6 62 62 62 66 66 66 30 30 30
45742 - 10 10 10 0 0 0 0 0 0 0 0 0
45743 - 0 0 0 0 0 0 0 0 0 0 0 0
45744 - 0 0 0 0 0 0 0 0 0 0 0 0
45745 - 0 0 0 0 0 0 0 0 0 0 0 0
45746 - 0 0 0 0 0 0 0 0 0 0 0 0
45747 - 0 0 0 0 0 0 0 0 0 0 0 0
45748 - 0 0 0 0 0 0 0 0 0 0 0 0
45749 - 0 0 0 0 0 0 0 0 0 0 0 0
45750 - 0 0 0 0 0 0 0 0 0 0 0 0
45751 - 14 14 14 42 42 42 82 82 82 18 18 18
45752 - 2 2 6 2 2 6 2 2 6 10 10 10
45753 - 94 94 94 182 182 182 218 218 218 242 242 242
45754 -250 250 250 253 253 253 253 253 253 250 250 250
45755 -234 234 234 253 253 253 253 253 253 253 253 253
45756 -253 253 253 253 253 253 253 253 253 246 246 246
45757 -238 238 238 226 226 226 210 210 210 202 202 202
45758 -195 195 195 195 195 195 210 210 210 158 158 158
45759 - 6 6 6 14 14 14 50 50 50 14 14 14
45760 - 2 2 6 2 2 6 2 2 6 2 2 6
45761 - 2 2 6 6 6 6 86 86 86 46 46 46
45762 - 18 18 18 6 6 6 0 0 0 0 0 0
45763 - 0 0 0 0 0 0 0 0 0 0 0 0
45764 - 0 0 0 0 0 0 0 0 0 0 0 0
45765 - 0 0 0 0 0 0 0 0 0 0 0 0
45766 - 0 0 0 0 0 0 0 0 0 0 0 0
45767 - 0 0 0 0 0 0 0 0 0 0 0 0
45768 - 0 0 0 0 0 0 0 0 0 0 0 0
45769 - 0 0 0 0 0 0 0 0 0 0 0 0
45770 - 0 0 0 0 0 0 0 0 0 6 6 6
45771 - 22 22 22 54 54 54 70 70 70 2 2 6
45772 - 2 2 6 10 10 10 2 2 6 22 22 22
45773 -166 166 166 231 231 231 250 250 250 253 253 253
45774 -253 253 253 253 253 253 253 253 253 250 250 250
45775 -242 242 242 253 253 253 253 253 253 253 253 253
45776 -253 253 253 253 253 253 253 253 253 253 253 253
45777 -253 253 253 253 253 253 253 253 253 246 246 246
45778 -231 231 231 206 206 206 198 198 198 226 226 226
45779 - 94 94 94 2 2 6 6 6 6 38 38 38
45780 - 30 30 30 2 2 6 2 2 6 2 2 6
45781 - 2 2 6 2 2 6 62 62 62 66 66 66
45782 - 26 26 26 10 10 10 0 0 0 0 0 0
45783 - 0 0 0 0 0 0 0 0 0 0 0 0
45784 - 0 0 0 0 0 0 0 0 0 0 0 0
45785 - 0 0 0 0 0 0 0 0 0 0 0 0
45786 - 0 0 0 0 0 0 0 0 0 0 0 0
45787 - 0 0 0 0 0 0 0 0 0 0 0 0
45788 - 0 0 0 0 0 0 0 0 0 0 0 0
45789 - 0 0 0 0 0 0 0 0 0 0 0 0
45790 - 0 0 0 0 0 0 0 0 0 10 10 10
45791 - 30 30 30 74 74 74 50 50 50 2 2 6
45792 - 26 26 26 26 26 26 2 2 6 106 106 106
45793 -238 238 238 253 253 253 253 253 253 253 253 253
45794 -253 253 253 253 253 253 253 253 253 253 253 253
45795 -253 253 253 253 253 253 253 253 253 253 253 253
45796 -253 253 253 253 253 253 253 253 253 253 253 253
45797 -253 253 253 253 253 253 253 253 253 253 253 253
45798 -253 253 253 246 246 246 218 218 218 202 202 202
45799 -210 210 210 14 14 14 2 2 6 2 2 6
45800 - 30 30 30 22 22 22 2 2 6 2 2 6
45801 - 2 2 6 2 2 6 18 18 18 86 86 86
45802 - 42 42 42 14 14 14 0 0 0 0 0 0
45803 - 0 0 0 0 0 0 0 0 0 0 0 0
45804 - 0 0 0 0 0 0 0 0 0 0 0 0
45805 - 0 0 0 0 0 0 0 0 0 0 0 0
45806 - 0 0 0 0 0 0 0 0 0 0 0 0
45807 - 0 0 0 0 0 0 0 0 0 0 0 0
45808 - 0 0 0 0 0 0 0 0 0 0 0 0
45809 - 0 0 0 0 0 0 0 0 0 0 0 0
45810 - 0 0 0 0 0 0 0 0 0 14 14 14
45811 - 42 42 42 90 90 90 22 22 22 2 2 6
45812 - 42 42 42 2 2 6 18 18 18 218 218 218
45813 -253 253 253 253 253 253 253 253 253 253 253 253
45814 -253 253 253 253 253 253 253 253 253 253 253 253
45815 -253 253 253 253 253 253 253 253 253 253 253 253
45816 -253 253 253 253 253 253 253 253 253 253 253 253
45817 -253 253 253 253 253 253 253 253 253 253 253 253
45818 -253 253 253 253 253 253 250 250 250 221 221 221
45819 -218 218 218 101 101 101 2 2 6 14 14 14
45820 - 18 18 18 38 38 38 10 10 10 2 2 6
45821 - 2 2 6 2 2 6 2 2 6 78 78 78
45822 - 58 58 58 22 22 22 6 6 6 0 0 0
45823 - 0 0 0 0 0 0 0 0 0 0 0 0
45824 - 0 0 0 0 0 0 0 0 0 0 0 0
45825 - 0 0 0 0 0 0 0 0 0 0 0 0
45826 - 0 0 0 0 0 0 0 0 0 0 0 0
45827 - 0 0 0 0 0 0 0 0 0 0 0 0
45828 - 0 0 0 0 0 0 0 0 0 0 0 0
45829 - 0 0 0 0 0 0 0 0 0 0 0 0
45830 - 0 0 0 0 0 0 6 6 6 18 18 18
45831 - 54 54 54 82 82 82 2 2 6 26 26 26
45832 - 22 22 22 2 2 6 123 123 123 253 253 253
45833 -253 253 253 253 253 253 253 253 253 253 253 253
45834 -253 253 253 253 253 253 253 253 253 253 253 253
45835 -253 253 253 253 253 253 253 253 253 253 253 253
45836 -253 253 253 253 253 253 253 253 253 253 253 253
45837 -253 253 253 253 253 253 253 253 253 253 253 253
45838 -253 253 253 253 253 253 253 253 253 250 250 250
45839 -238 238 238 198 198 198 6 6 6 38 38 38
45840 - 58 58 58 26 26 26 38 38 38 2 2 6
45841 - 2 2 6 2 2 6 2 2 6 46 46 46
45842 - 78 78 78 30 30 30 10 10 10 0 0 0
45843 - 0 0 0 0 0 0 0 0 0 0 0 0
45844 - 0 0 0 0 0 0 0 0 0 0 0 0
45845 - 0 0 0 0 0 0 0 0 0 0 0 0
45846 - 0 0 0 0 0 0 0 0 0 0 0 0
45847 - 0 0 0 0 0 0 0 0 0 0 0 0
45848 - 0 0 0 0 0 0 0 0 0 0 0 0
45849 - 0 0 0 0 0 0 0 0 0 0 0 0
45850 - 0 0 0 0 0 0 10 10 10 30 30 30
45851 - 74 74 74 58 58 58 2 2 6 42 42 42
45852 - 2 2 6 22 22 22 231 231 231 253 253 253
45853 -253 253 253 253 253 253 253 253 253 253 253 253
45854 -253 253 253 253 253 253 253 253 253 250 250 250
45855 -253 253 253 253 253 253 253 253 253 253 253 253
45856 -253 253 253 253 253 253 253 253 253 253 253 253
45857 -253 253 253 253 253 253 253 253 253 253 253 253
45858 -253 253 253 253 253 253 253 253 253 253 253 253
45859 -253 253 253 246 246 246 46 46 46 38 38 38
45860 - 42 42 42 14 14 14 38 38 38 14 14 14
45861 - 2 2 6 2 2 6 2 2 6 6 6 6
45862 - 86 86 86 46 46 46 14 14 14 0 0 0
45863 - 0 0 0 0 0 0 0 0 0 0 0 0
45864 - 0 0 0 0 0 0 0 0 0 0 0 0
45865 - 0 0 0 0 0 0 0 0 0 0 0 0
45866 - 0 0 0 0 0 0 0 0 0 0 0 0
45867 - 0 0 0 0 0 0 0 0 0 0 0 0
45868 - 0 0 0 0 0 0 0 0 0 0 0 0
45869 - 0 0 0 0 0 0 0 0 0 0 0 0
45870 - 0 0 0 6 6 6 14 14 14 42 42 42
45871 - 90 90 90 18 18 18 18 18 18 26 26 26
45872 - 2 2 6 116 116 116 253 253 253 253 253 253
45873 -253 253 253 253 253 253 253 253 253 253 253 253
45874 -253 253 253 253 253 253 250 250 250 238 238 238
45875 -253 253 253 253 253 253 253 253 253 253 253 253
45876 -253 253 253 253 253 253 253 253 253 253 253 253
45877 -253 253 253 253 253 253 253 253 253 253 253 253
45878 -253 253 253 253 253 253 253 253 253 253 253 253
45879 -253 253 253 253 253 253 94 94 94 6 6 6
45880 - 2 2 6 2 2 6 10 10 10 34 34 34
45881 - 2 2 6 2 2 6 2 2 6 2 2 6
45882 - 74 74 74 58 58 58 22 22 22 6 6 6
45883 - 0 0 0 0 0 0 0 0 0 0 0 0
45884 - 0 0 0 0 0 0 0 0 0 0 0 0
45885 - 0 0 0 0 0 0 0 0 0 0 0 0
45886 - 0 0 0 0 0 0 0 0 0 0 0 0
45887 - 0 0 0 0 0 0 0 0 0 0 0 0
45888 - 0 0 0 0 0 0 0 0 0 0 0 0
45889 - 0 0 0 0 0 0 0 0 0 0 0 0
45890 - 0 0 0 10 10 10 26 26 26 66 66 66
45891 - 82 82 82 2 2 6 38 38 38 6 6 6
45892 - 14 14 14 210 210 210 253 253 253 253 253 253
45893 -253 253 253 253 253 253 253 253 253 253 253 253
45894 -253 253 253 253 253 253 246 246 246 242 242 242
45895 -253 253 253 253 253 253 253 253 253 253 253 253
45896 -253 253 253 253 253 253 253 253 253 253 253 253
45897 -253 253 253 253 253 253 253 253 253 253 253 253
45898 -253 253 253 253 253 253 253 253 253 253 253 253
45899 -253 253 253 253 253 253 144 144 144 2 2 6
45900 - 2 2 6 2 2 6 2 2 6 46 46 46
45901 - 2 2 6 2 2 6 2 2 6 2 2 6
45902 - 42 42 42 74 74 74 30 30 30 10 10 10
45903 - 0 0 0 0 0 0 0 0 0 0 0 0
45904 - 0 0 0 0 0 0 0 0 0 0 0 0
45905 - 0 0 0 0 0 0 0 0 0 0 0 0
45906 - 0 0 0 0 0 0 0 0 0 0 0 0
45907 - 0 0 0 0 0 0 0 0 0 0 0 0
45908 - 0 0 0 0 0 0 0 0 0 0 0 0
45909 - 0 0 0 0 0 0 0 0 0 0 0 0
45910 - 6 6 6 14 14 14 42 42 42 90 90 90
45911 - 26 26 26 6 6 6 42 42 42 2 2 6
45912 - 74 74 74 250 250 250 253 253 253 253 253 253
45913 -253 253 253 253 253 253 253 253 253 253 253 253
45914 -253 253 253 253 253 253 242 242 242 242 242 242
45915 -253 253 253 253 253 253 253 253 253 253 253 253
45916 -253 253 253 253 253 253 253 253 253 253 253 253
45917 -253 253 253 253 253 253 253 253 253 253 253 253
45918 -253 253 253 253 253 253 253 253 253 253 253 253
45919 -253 253 253 253 253 253 182 182 182 2 2 6
45920 - 2 2 6 2 2 6 2 2 6 46 46 46
45921 - 2 2 6 2 2 6 2 2 6 2 2 6
45922 - 10 10 10 86 86 86 38 38 38 10 10 10
45923 - 0 0 0 0 0 0 0 0 0 0 0 0
45924 - 0 0 0 0 0 0 0 0 0 0 0 0
45925 - 0 0 0 0 0 0 0 0 0 0 0 0
45926 - 0 0 0 0 0 0 0 0 0 0 0 0
45927 - 0 0 0 0 0 0 0 0 0 0 0 0
45928 - 0 0 0 0 0 0 0 0 0 0 0 0
45929 - 0 0 0 0 0 0 0 0 0 0 0 0
45930 - 10 10 10 26 26 26 66 66 66 82 82 82
45931 - 2 2 6 22 22 22 18 18 18 2 2 6
45932 -149 149 149 253 253 253 253 253 253 253 253 253
45933 -253 253 253 253 253 253 253 253 253 253 253 253
45934 -253 253 253 253 253 253 234 234 234 242 242 242
45935 -253 253 253 253 253 253 253 253 253 253 253 253
45936 -253 253 253 253 253 253 253 253 253 253 253 253
45937 -253 253 253 253 253 253 253 253 253 253 253 253
45938 -253 253 253 253 253 253 253 253 253 253 253 253
45939 -253 253 253 253 253 253 206 206 206 2 2 6
45940 - 2 2 6 2 2 6 2 2 6 38 38 38
45941 - 2 2 6 2 2 6 2 2 6 2 2 6
45942 - 6 6 6 86 86 86 46 46 46 14 14 14
45943 - 0 0 0 0 0 0 0 0 0 0 0 0
45944 - 0 0 0 0 0 0 0 0 0 0 0 0
45945 - 0 0 0 0 0 0 0 0 0 0 0 0
45946 - 0 0 0 0 0 0 0 0 0 0 0 0
45947 - 0 0 0 0 0 0 0 0 0 0 0 0
45948 - 0 0 0 0 0 0 0 0 0 0 0 0
45949 - 0 0 0 0 0 0 0 0 0 6 6 6
45950 - 18 18 18 46 46 46 86 86 86 18 18 18
45951 - 2 2 6 34 34 34 10 10 10 6 6 6
45952 -210 210 210 253 253 253 253 253 253 253 253 253
45953 -253 253 253 253 253 253 253 253 253 253 253 253
45954 -253 253 253 253 253 253 234 234 234 242 242 242
45955 -253 253 253 253 253 253 253 253 253 253 253 253
45956 -253 253 253 253 253 253 253 253 253 253 253 253
45957 -253 253 253 253 253 253 253 253 253 253 253 253
45958 -253 253 253 253 253 253 253 253 253 253 253 253
45959 -253 253 253 253 253 253 221 221 221 6 6 6
45960 - 2 2 6 2 2 6 6 6 6 30 30 30
45961 - 2 2 6 2 2 6 2 2 6 2 2 6
45962 - 2 2 6 82 82 82 54 54 54 18 18 18
45963 - 6 6 6 0 0 0 0 0 0 0 0 0
45964 - 0 0 0 0 0 0 0 0 0 0 0 0
45965 - 0 0 0 0 0 0 0 0 0 0 0 0
45966 - 0 0 0 0 0 0 0 0 0 0 0 0
45967 - 0 0 0 0 0 0 0 0 0 0 0 0
45968 - 0 0 0 0 0 0 0 0 0 0 0 0
45969 - 0 0 0 0 0 0 0 0 0 10 10 10
45970 - 26 26 26 66 66 66 62 62 62 2 2 6
45971 - 2 2 6 38 38 38 10 10 10 26 26 26
45972 -238 238 238 253 253 253 253 253 253 253 253 253
45973 -253 253 253 253 253 253 253 253 253 253 253 253
45974 -253 253 253 253 253 253 231 231 231 238 238 238
45975 -253 253 253 253 253 253 253 253 253 253 253 253
45976 -253 253 253 253 253 253 253 253 253 253 253 253
45977 -253 253 253 253 253 253 253 253 253 253 253 253
45978 -253 253 253 253 253 253 253 253 253 253 253 253
45979 -253 253 253 253 253 253 231 231 231 6 6 6
45980 - 2 2 6 2 2 6 10 10 10 30 30 30
45981 - 2 2 6 2 2 6 2 2 6 2 2 6
45982 - 2 2 6 66 66 66 58 58 58 22 22 22
45983 - 6 6 6 0 0 0 0 0 0 0 0 0
45984 - 0 0 0 0 0 0 0 0 0 0 0 0
45985 - 0 0 0 0 0 0 0 0 0 0 0 0
45986 - 0 0 0 0 0 0 0 0 0 0 0 0
45987 - 0 0 0 0 0 0 0 0 0 0 0 0
45988 - 0 0 0 0 0 0 0 0 0 0 0 0
45989 - 0 0 0 0 0 0 0 0 0 10 10 10
45990 - 38 38 38 78 78 78 6 6 6 2 2 6
45991 - 2 2 6 46 46 46 14 14 14 42 42 42
45992 -246 246 246 253 253 253 253 253 253 253 253 253
45993 -253 253 253 253 253 253 253 253 253 253 253 253
45994 -253 253 253 253 253 253 231 231 231 242 242 242
45995 -253 253 253 253 253 253 253 253 253 253 253 253
45996 -253 253 253 253 253 253 253 253 253 253 253 253
45997 -253 253 253 253 253 253 253 253 253 253 253 253
45998 -253 253 253 253 253 253 253 253 253 253 253 253
45999 -253 253 253 253 253 253 234 234 234 10 10 10
46000 - 2 2 6 2 2 6 22 22 22 14 14 14
46001 - 2 2 6 2 2 6 2 2 6 2 2 6
46002 - 2 2 6 66 66 66 62 62 62 22 22 22
46003 - 6 6 6 0 0 0 0 0 0 0 0 0
46004 - 0 0 0 0 0 0 0 0 0 0 0 0
46005 - 0 0 0 0 0 0 0 0 0 0 0 0
46006 - 0 0 0 0 0 0 0 0 0 0 0 0
46007 - 0 0 0 0 0 0 0 0 0 0 0 0
46008 - 0 0 0 0 0 0 0 0 0 0 0 0
46009 - 0 0 0 0 0 0 6 6 6 18 18 18
46010 - 50 50 50 74 74 74 2 2 6 2 2 6
46011 - 14 14 14 70 70 70 34 34 34 62 62 62
46012 -250 250 250 253 253 253 253 253 253 253 253 253
46013 -253 253 253 253 253 253 253 253 253 253 253 253
46014 -253 253 253 253 253 253 231 231 231 246 246 246
46015 -253 253 253 253 253 253 253 253 253 253 253 253
46016 -253 253 253 253 253 253 253 253 253 253 253 253
46017 -253 253 253 253 253 253 253 253 253 253 253 253
46018 -253 253 253 253 253 253 253 253 253 253 253 253
46019 -253 253 253 253 253 253 234 234 234 14 14 14
46020 - 2 2 6 2 2 6 30 30 30 2 2 6
46021 - 2 2 6 2 2 6 2 2 6 2 2 6
46022 - 2 2 6 66 66 66 62 62 62 22 22 22
46023 - 6 6 6 0 0 0 0 0 0 0 0 0
46024 - 0 0 0 0 0 0 0 0 0 0 0 0
46025 - 0 0 0 0 0 0 0 0 0 0 0 0
46026 - 0 0 0 0 0 0 0 0 0 0 0 0
46027 - 0 0 0 0 0 0 0 0 0 0 0 0
46028 - 0 0 0 0 0 0 0 0 0 0 0 0
46029 - 0 0 0 0 0 0 6 6 6 18 18 18
46030 - 54 54 54 62 62 62 2 2 6 2 2 6
46031 - 2 2 6 30 30 30 46 46 46 70 70 70
46032 -250 250 250 253 253 253 253 253 253 253 253 253
46033 -253 253 253 253 253 253 253 253 253 253 253 253
46034 -253 253 253 253 253 253 231 231 231 246 246 246
46035 -253 253 253 253 253 253 253 253 253 253 253 253
46036 -253 253 253 253 253 253 253 253 253 253 253 253
46037 -253 253 253 253 253 253 253 253 253 253 253 253
46038 -253 253 253 253 253 253 253 253 253 253 253 253
46039 -253 253 253 253 253 253 226 226 226 10 10 10
46040 - 2 2 6 6 6 6 30 30 30 2 2 6
46041 - 2 2 6 2 2 6 2 2 6 2 2 6
46042 - 2 2 6 66 66 66 58 58 58 22 22 22
46043 - 6 6 6 0 0 0 0 0 0 0 0 0
46044 - 0 0 0 0 0 0 0 0 0 0 0 0
46045 - 0 0 0 0 0 0 0 0 0 0 0 0
46046 - 0 0 0 0 0 0 0 0 0 0 0 0
46047 - 0 0 0 0 0 0 0 0 0 0 0 0
46048 - 0 0 0 0 0 0 0 0 0 0 0 0
46049 - 0 0 0 0 0 0 6 6 6 22 22 22
46050 - 58 58 58 62 62 62 2 2 6 2 2 6
46051 - 2 2 6 2 2 6 30 30 30 78 78 78
46052 -250 250 250 253 253 253 253 253 253 253 253 253
46053 -253 253 253 253 253 253 253 253 253 253 253 253
46054 -253 253 253 253 253 253 231 231 231 246 246 246
46055 -253 253 253 253 253 253 253 253 253 253 253 253
46056 -253 253 253 253 253 253 253 253 253 253 253 253
46057 -253 253 253 253 253 253 253 253 253 253 253 253
46058 -253 253 253 253 253 253 253 253 253 253 253 253
46059 -253 253 253 253 253 253 206 206 206 2 2 6
46060 - 22 22 22 34 34 34 18 14 6 22 22 22
46061 - 26 26 26 18 18 18 6 6 6 2 2 6
46062 - 2 2 6 82 82 82 54 54 54 18 18 18
46063 - 6 6 6 0 0 0 0 0 0 0 0 0
46064 - 0 0 0 0 0 0 0 0 0 0 0 0
46065 - 0 0 0 0 0 0 0 0 0 0 0 0
46066 - 0 0 0 0 0 0 0 0 0 0 0 0
46067 - 0 0 0 0 0 0 0 0 0 0 0 0
46068 - 0 0 0 0 0 0 0 0 0 0 0 0
46069 - 0 0 0 0 0 0 6 6 6 26 26 26
46070 - 62 62 62 106 106 106 74 54 14 185 133 11
46071 -210 162 10 121 92 8 6 6 6 62 62 62
46072 -238 238 238 253 253 253 253 253 253 253 253 253
46073 -253 253 253 253 253 253 253 253 253 253 253 253
46074 -253 253 253 253 253 253 231 231 231 246 246 246
46075 -253 253 253 253 253 253 253 253 253 253 253 253
46076 -253 253 253 253 253 253 253 253 253 253 253 253
46077 -253 253 253 253 253 253 253 253 253 253 253 253
46078 -253 253 253 253 253 253 253 253 253 253 253 253
46079 -253 253 253 253 253 253 158 158 158 18 18 18
46080 - 14 14 14 2 2 6 2 2 6 2 2 6
46081 - 6 6 6 18 18 18 66 66 66 38 38 38
46082 - 6 6 6 94 94 94 50 50 50 18 18 18
46083 - 6 6 6 0 0 0 0 0 0 0 0 0
46084 - 0 0 0 0 0 0 0 0 0 0 0 0
46085 - 0 0 0 0 0 0 0 0 0 0 0 0
46086 - 0 0 0 0 0 0 0 0 0 0 0 0
46087 - 0 0 0 0 0 0 0 0 0 0 0 0
46088 - 0 0 0 0 0 0 0 0 0 6 6 6
46089 - 10 10 10 10 10 10 18 18 18 38 38 38
46090 - 78 78 78 142 134 106 216 158 10 242 186 14
46091 -246 190 14 246 190 14 156 118 10 10 10 10
46092 - 90 90 90 238 238 238 253 253 253 253 253 253
46093 -253 253 253 253 253 253 253 253 253 253 253 253
46094 -253 253 253 253 253 253 231 231 231 250 250 250
46095 -253 253 253 253 253 253 253 253 253 253 253 253
46096 -253 253 253 253 253 253 253 253 253 253 253 253
46097 -253 253 253 253 253 253 253 253 253 253 253 253
46098 -253 253 253 253 253 253 253 253 253 246 230 190
46099 -238 204 91 238 204 91 181 142 44 37 26 9
46100 - 2 2 6 2 2 6 2 2 6 2 2 6
46101 - 2 2 6 2 2 6 38 38 38 46 46 46
46102 - 26 26 26 106 106 106 54 54 54 18 18 18
46103 - 6 6 6 0 0 0 0 0 0 0 0 0
46104 - 0 0 0 0 0 0 0 0 0 0 0 0
46105 - 0 0 0 0 0 0 0 0 0 0 0 0
46106 - 0 0 0 0 0 0 0 0 0 0 0 0
46107 - 0 0 0 0 0 0 0 0 0 0 0 0
46108 - 0 0 0 6 6 6 14 14 14 22 22 22
46109 - 30 30 30 38 38 38 50 50 50 70 70 70
46110 -106 106 106 190 142 34 226 170 11 242 186 14
46111 -246 190 14 246 190 14 246 190 14 154 114 10
46112 - 6 6 6 74 74 74 226 226 226 253 253 253
46113 -253 253 253 253 253 253 253 253 253 253 253 253
46114 -253 253 253 253 253 253 231 231 231 250 250 250
46115 -253 253 253 253 253 253 253 253 253 253 253 253
46116 -253 253 253 253 253 253 253 253 253 253 253 253
46117 -253 253 253 253 253 253 253 253 253 253 253 253
46118 -253 253 253 253 253 253 253 253 253 228 184 62
46119 -241 196 14 241 208 19 232 195 16 38 30 10
46120 - 2 2 6 2 2 6 2 2 6 2 2 6
46121 - 2 2 6 6 6 6 30 30 30 26 26 26
46122 -203 166 17 154 142 90 66 66 66 26 26 26
46123 - 6 6 6 0 0 0 0 0 0 0 0 0
46124 - 0 0 0 0 0 0 0 0 0 0 0 0
46125 - 0 0 0 0 0 0 0 0 0 0 0 0
46126 - 0 0 0 0 0 0 0 0 0 0 0 0
46127 - 0 0 0 0 0 0 0 0 0 0 0 0
46128 - 6 6 6 18 18 18 38 38 38 58 58 58
46129 - 78 78 78 86 86 86 101 101 101 123 123 123
46130 -175 146 61 210 150 10 234 174 13 246 186 14
46131 -246 190 14 246 190 14 246 190 14 238 190 10
46132 -102 78 10 2 2 6 46 46 46 198 198 198
46133 -253 253 253 253 253 253 253 253 253 253 253 253
46134 -253 253 253 253 253 253 234 234 234 242 242 242
46135 -253 253 253 253 253 253 253 253 253 253 253 253
46136 -253 253 253 253 253 253 253 253 253 253 253 253
46137 -253 253 253 253 253 253 253 253 253 253 253 253
46138 -253 253 253 253 253 253 253 253 253 224 178 62
46139 -242 186 14 241 196 14 210 166 10 22 18 6
46140 - 2 2 6 2 2 6 2 2 6 2 2 6
46141 - 2 2 6 2 2 6 6 6 6 121 92 8
46142 -238 202 15 232 195 16 82 82 82 34 34 34
46143 - 10 10 10 0 0 0 0 0 0 0 0 0
46144 - 0 0 0 0 0 0 0 0 0 0 0 0
46145 - 0 0 0 0 0 0 0 0 0 0 0 0
46146 - 0 0 0 0 0 0 0 0 0 0 0 0
46147 - 0 0 0 0 0 0 0 0 0 0 0 0
46148 - 14 14 14 38 38 38 70 70 70 154 122 46
46149 -190 142 34 200 144 11 197 138 11 197 138 11
46150 -213 154 11 226 170 11 242 186 14 246 190 14
46151 -246 190 14 246 190 14 246 190 14 246 190 14
46152 -225 175 15 46 32 6 2 2 6 22 22 22
46153 -158 158 158 250 250 250 253 253 253 253 253 253
46154 -253 253 253 253 253 253 253 253 253 253 253 253
46155 -253 253 253 253 253 253 253 253 253 253 253 253
46156 -253 253 253 253 253 253 253 253 253 253 253 253
46157 -253 253 253 253 253 253 253 253 253 253 253 253
46158 -253 253 253 250 250 250 242 242 242 224 178 62
46159 -239 182 13 236 186 11 213 154 11 46 32 6
46160 - 2 2 6 2 2 6 2 2 6 2 2 6
46161 - 2 2 6 2 2 6 61 42 6 225 175 15
46162 -238 190 10 236 186 11 112 100 78 42 42 42
46163 - 14 14 14 0 0 0 0 0 0 0 0 0
46164 - 0 0 0 0 0 0 0 0 0 0 0 0
46165 - 0 0 0 0 0 0 0 0 0 0 0 0
46166 - 0 0 0 0 0 0 0 0 0 0 0 0
46167 - 0 0 0 0 0 0 0 0 0 6 6 6
46168 - 22 22 22 54 54 54 154 122 46 213 154 11
46169 -226 170 11 230 174 11 226 170 11 226 170 11
46170 -236 178 12 242 186 14 246 190 14 246 190 14
46171 -246 190 14 246 190 14 246 190 14 246 190 14
46172 -241 196 14 184 144 12 10 10 10 2 2 6
46173 - 6 6 6 116 116 116 242 242 242 253 253 253
46174 -253 253 253 253 253 253 253 253 253 253 253 253
46175 -253 253 253 253 253 253 253 253 253 253 253 253
46176 -253 253 253 253 253 253 253 253 253 253 253 253
46177 -253 253 253 253 253 253 253 253 253 253 253 253
46178 -253 253 253 231 231 231 198 198 198 214 170 54
46179 -236 178 12 236 178 12 210 150 10 137 92 6
46180 - 18 14 6 2 2 6 2 2 6 2 2 6
46181 - 6 6 6 70 47 6 200 144 11 236 178 12
46182 -239 182 13 239 182 13 124 112 88 58 58 58
46183 - 22 22 22 6 6 6 0 0 0 0 0 0
46184 - 0 0 0 0 0 0 0 0 0 0 0 0
46185 - 0 0 0 0 0 0 0 0 0 0 0 0
46186 - 0 0 0 0 0 0 0 0 0 0 0 0
46187 - 0 0 0 0 0 0 0 0 0 10 10 10
46188 - 30 30 30 70 70 70 180 133 36 226 170 11
46189 -239 182 13 242 186 14 242 186 14 246 186 14
46190 -246 190 14 246 190 14 246 190 14 246 190 14
46191 -246 190 14 246 190 14 246 190 14 246 190 14
46192 -246 190 14 232 195 16 98 70 6 2 2 6
46193 - 2 2 6 2 2 6 66 66 66 221 221 221
46194 -253 253 253 253 253 253 253 253 253 253 253 253
46195 -253 253 253 253 253 253 253 253 253 253 253 253
46196 -253 253 253 253 253 253 253 253 253 253 253 253
46197 -253 253 253 253 253 253 253 253 253 253 253 253
46198 -253 253 253 206 206 206 198 198 198 214 166 58
46199 -230 174 11 230 174 11 216 158 10 192 133 9
46200 -163 110 8 116 81 8 102 78 10 116 81 8
46201 -167 114 7 197 138 11 226 170 11 239 182 13
46202 -242 186 14 242 186 14 162 146 94 78 78 78
46203 - 34 34 34 14 14 14 6 6 6 0 0 0
46204 - 0 0 0 0 0 0 0 0 0 0 0 0
46205 - 0 0 0 0 0 0 0 0 0 0 0 0
46206 - 0 0 0 0 0 0 0 0 0 0 0 0
46207 - 0 0 0 0 0 0 0 0 0 6 6 6
46208 - 30 30 30 78 78 78 190 142 34 226 170 11
46209 -239 182 13 246 190 14 246 190 14 246 190 14
46210 -246 190 14 246 190 14 246 190 14 246 190 14
46211 -246 190 14 246 190 14 246 190 14 246 190 14
46212 -246 190 14 241 196 14 203 166 17 22 18 6
46213 - 2 2 6 2 2 6 2 2 6 38 38 38
46214 -218 218 218 253 253 253 253 253 253 253 253 253
46215 -253 253 253 253 253 253 253 253 253 253 253 253
46216 -253 253 253 253 253 253 253 253 253 253 253 253
46217 -253 253 253 253 253 253 253 253 253 253 253 253
46218 -250 250 250 206 206 206 198 198 198 202 162 69
46219 -226 170 11 236 178 12 224 166 10 210 150 10
46220 -200 144 11 197 138 11 192 133 9 197 138 11
46221 -210 150 10 226 170 11 242 186 14 246 190 14
46222 -246 190 14 246 186 14 225 175 15 124 112 88
46223 - 62 62 62 30 30 30 14 14 14 6 6 6
46224 - 0 0 0 0 0 0 0 0 0 0 0 0
46225 - 0 0 0 0 0 0 0 0 0 0 0 0
46226 - 0 0 0 0 0 0 0 0 0 0 0 0
46227 - 0 0 0 0 0 0 0 0 0 10 10 10
46228 - 30 30 30 78 78 78 174 135 50 224 166 10
46229 -239 182 13 246 190 14 246 190 14 246 190 14
46230 -246 190 14 246 190 14 246 190 14 246 190 14
46231 -246 190 14 246 190 14 246 190 14 246 190 14
46232 -246 190 14 246 190 14 241 196 14 139 102 15
46233 - 2 2 6 2 2 6 2 2 6 2 2 6
46234 - 78 78 78 250 250 250 253 253 253 253 253 253
46235 -253 253 253 253 253 253 253 253 253 253 253 253
46236 -253 253 253 253 253 253 253 253 253 253 253 253
46237 -253 253 253 253 253 253 253 253 253 253 253 253
46238 -250 250 250 214 214 214 198 198 198 190 150 46
46239 -219 162 10 236 178 12 234 174 13 224 166 10
46240 -216 158 10 213 154 11 213 154 11 216 158 10
46241 -226 170 11 239 182 13 246 190 14 246 190 14
46242 -246 190 14 246 190 14 242 186 14 206 162 42
46243 -101 101 101 58 58 58 30 30 30 14 14 14
46244 - 6 6 6 0 0 0 0 0 0 0 0 0
46245 - 0 0 0 0 0 0 0 0 0 0 0 0
46246 - 0 0 0 0 0 0 0 0 0 0 0 0
46247 - 0 0 0 0 0 0 0 0 0 10 10 10
46248 - 30 30 30 74 74 74 174 135 50 216 158 10
46249 -236 178 12 246 190 14 246 190 14 246 190 14
46250 -246 190 14 246 190 14 246 190 14 246 190 14
46251 -246 190 14 246 190 14 246 190 14 246 190 14
46252 -246 190 14 246 190 14 241 196 14 226 184 13
46253 - 61 42 6 2 2 6 2 2 6 2 2 6
46254 - 22 22 22 238 238 238 253 253 253 253 253 253
46255 -253 253 253 253 253 253 253 253 253 253 253 253
46256 -253 253 253 253 253 253 253 253 253 253 253 253
46257 -253 253 253 253 253 253 253 253 253 253 253 253
46258 -253 253 253 226 226 226 187 187 187 180 133 36
46259 -216 158 10 236 178 12 239 182 13 236 178 12
46260 -230 174 11 226 170 11 226 170 11 230 174 11
46261 -236 178 12 242 186 14 246 190 14 246 190 14
46262 -246 190 14 246 190 14 246 186 14 239 182 13
46263 -206 162 42 106 106 106 66 66 66 34 34 34
46264 - 14 14 14 6 6 6 0 0 0 0 0 0
46265 - 0 0 0 0 0 0 0 0 0 0 0 0
46266 - 0 0 0 0 0 0 0 0 0 0 0 0
46267 - 0 0 0 0 0 0 0 0 0 6 6 6
46268 - 26 26 26 70 70 70 163 133 67 213 154 11
46269 -236 178 12 246 190 14 246 190 14 246 190 14
46270 -246 190 14 246 190 14 246 190 14 246 190 14
46271 -246 190 14 246 190 14 246 190 14 246 190 14
46272 -246 190 14 246 190 14 246 190 14 241 196 14
46273 -190 146 13 18 14 6 2 2 6 2 2 6
46274 - 46 46 46 246 246 246 253 253 253 253 253 253
46275 -253 253 253 253 253 253 253 253 253 253 253 253
46276 -253 253 253 253 253 253 253 253 253 253 253 253
46277 -253 253 253 253 253 253 253 253 253 253 253 253
46278 -253 253 253 221 221 221 86 86 86 156 107 11
46279 -216 158 10 236 178 12 242 186 14 246 186 14
46280 -242 186 14 239 182 13 239 182 13 242 186 14
46281 -242 186 14 246 186 14 246 190 14 246 190 14
46282 -246 190 14 246 190 14 246 190 14 246 190 14
46283 -242 186 14 225 175 15 142 122 72 66 66 66
46284 - 30 30 30 10 10 10 0 0 0 0 0 0
46285 - 0 0 0 0 0 0 0 0 0 0 0 0
46286 - 0 0 0 0 0 0 0 0 0 0 0 0
46287 - 0 0 0 0 0 0 0 0 0 6 6 6
46288 - 26 26 26 70 70 70 163 133 67 210 150 10
46289 -236 178 12 246 190 14 246 190 14 246 190 14
46290 -246 190 14 246 190 14 246 190 14 246 190 14
46291 -246 190 14 246 190 14 246 190 14 246 190 14
46292 -246 190 14 246 190 14 246 190 14 246 190 14
46293 -232 195 16 121 92 8 34 34 34 106 106 106
46294 -221 221 221 253 253 253 253 253 253 253 253 253
46295 -253 253 253 253 253 253 253 253 253 253 253 253
46296 -253 253 253 253 253 253 253 253 253 253 253 253
46297 -253 253 253 253 253 253 253 253 253 253 253 253
46298 -242 242 242 82 82 82 18 14 6 163 110 8
46299 -216 158 10 236 178 12 242 186 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 246 190 14
46303 -246 190 14 246 190 14 242 186 14 163 133 67
46304 - 46 46 46 18 18 18 6 6 6 0 0 0
46305 - 0 0 0 0 0 0 0 0 0 0 0 0
46306 - 0 0 0 0 0 0 0 0 0 0 0 0
46307 - 0 0 0 0 0 0 0 0 0 10 10 10
46308 - 30 30 30 78 78 78 163 133 67 210 150 10
46309 -236 178 12 246 186 14 246 190 14 246 190 14
46310 -246 190 14 246 190 14 246 190 14 246 190 14
46311 -246 190 14 246 190 14 246 190 14 246 190 14
46312 -246 190 14 246 190 14 246 190 14 246 190 14
46313 -241 196 14 215 174 15 190 178 144 253 253 253
46314 -253 253 253 253 253 253 253 253 253 253 253 253
46315 -253 253 253 253 253 253 253 253 253 253 253 253
46316 -253 253 253 253 253 253 253 253 253 253 253 253
46317 -253 253 253 253 253 253 253 253 253 218 218 218
46318 - 58 58 58 2 2 6 22 18 6 167 114 7
46319 -216 158 10 236 178 12 246 186 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 -246 190 14 246 186 14 242 186 14 190 150 46
46324 - 54 54 54 22 22 22 6 6 6 0 0 0
46325 - 0 0 0 0 0 0 0 0 0 0 0 0
46326 - 0 0 0 0 0 0 0 0 0 0 0 0
46327 - 0 0 0 0 0 0 0 0 0 14 14 14
46328 - 38 38 38 86 86 86 180 133 36 213 154 11
46329 -236 178 12 246 186 14 246 190 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 232 195 16 190 146 13 214 214 214
46334 -253 253 253 253 253 253 253 253 253 253 253 253
46335 -253 253 253 253 253 253 253 253 253 253 253 253
46336 -253 253 253 253 253 253 253 253 253 253 253 253
46337 -253 253 253 250 250 250 170 170 170 26 26 26
46338 - 2 2 6 2 2 6 37 26 9 163 110 8
46339 -219 162 10 239 182 13 246 186 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 -246 186 14 236 178 12 224 166 10 142 122 72
46344 - 46 46 46 18 18 18 6 6 6 0 0 0
46345 - 0 0 0 0 0 0 0 0 0 0 0 0
46346 - 0 0 0 0 0 0 0 0 0 0 0 0
46347 - 0 0 0 0 0 0 6 6 6 18 18 18
46348 - 50 50 50 109 106 95 192 133 9 224 166 10
46349 -242 186 14 246 190 14 246 190 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 -242 186 14 226 184 13 210 162 10 142 110 46
46354 -226 226 226 253 253 253 253 253 253 253 253 253
46355 -253 253 253 253 253 253 253 253 253 253 253 253
46356 -253 253 253 253 253 253 253 253 253 253 253 253
46357 -198 198 198 66 66 66 2 2 6 2 2 6
46358 - 2 2 6 2 2 6 50 34 6 156 107 11
46359 -219 162 10 239 182 13 246 186 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 242 186 14
46363 -234 174 13 213 154 11 154 122 46 66 66 66
46364 - 30 30 30 10 10 10 0 0 0 0 0 0
46365 - 0 0 0 0 0 0 0 0 0 0 0 0
46366 - 0 0 0 0 0 0 0 0 0 0 0 0
46367 - 0 0 0 0 0 0 6 6 6 22 22 22
46368 - 58 58 58 154 121 60 206 145 10 234 174 13
46369 -242 186 14 246 186 14 246 190 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 210 162 10 163 110 8
46374 - 61 42 6 138 138 138 218 218 218 250 250 250
46375 -253 253 253 253 253 253 253 253 253 250 250 250
46376 -242 242 242 210 210 210 144 144 144 66 66 66
46377 - 6 6 6 2 2 6 2 2 6 2 2 6
46378 - 2 2 6 2 2 6 61 42 6 163 110 8
46379 -216 158 10 236 178 12 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 239 182 13 230 174 11 216 158 10
46383 -190 142 34 124 112 88 70 70 70 38 38 38
46384 - 18 18 18 6 6 6 0 0 0 0 0 0
46385 - 0 0 0 0 0 0 0 0 0 0 0 0
46386 - 0 0 0 0 0 0 0 0 0 0 0 0
46387 - 0 0 0 0 0 0 6 6 6 22 22 22
46388 - 62 62 62 168 124 44 206 145 10 224 166 10
46389 -236 178 12 239 182 13 242 186 14 242 186 14
46390 -246 186 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 246 190 14
46393 -246 190 14 236 178 12 216 158 10 175 118 6
46394 - 80 54 7 2 2 6 6 6 6 30 30 30
46395 - 54 54 54 62 62 62 50 50 50 38 38 38
46396 - 14 14 14 2 2 6 2 2 6 2 2 6
46397 - 2 2 6 2 2 6 2 2 6 2 2 6
46398 - 2 2 6 6 6 6 80 54 7 167 114 7
46399 -213 154 11 236 178 12 246 190 14 246 190 14
46400 -246 190 14 246 190 14 246 190 14 246 190 14
46401 -246 190 14 242 186 14 239 182 13 239 182 13
46402 -230 174 11 210 150 10 174 135 50 124 112 88
46403 - 82 82 82 54 54 54 34 34 34 18 18 18
46404 - 6 6 6 0 0 0 0 0 0 0 0 0
46405 - 0 0 0 0 0 0 0 0 0 0 0 0
46406 - 0 0 0 0 0 0 0 0 0 0 0 0
46407 - 0 0 0 0 0 0 6 6 6 18 18 18
46408 - 50 50 50 158 118 36 192 133 9 200 144 11
46409 -216 158 10 219 162 10 224 166 10 226 170 11
46410 -230 174 11 236 178 12 239 182 13 239 182 13
46411 -242 186 14 246 186 14 246 190 14 246 190 14
46412 -246 190 14 246 190 14 246 190 14 246 190 14
46413 -246 186 14 230 174 11 210 150 10 163 110 8
46414 -104 69 6 10 10 10 2 2 6 2 2 6
46415 - 2 2 6 2 2 6 2 2 6 2 2 6
46416 - 2 2 6 2 2 6 2 2 6 2 2 6
46417 - 2 2 6 2 2 6 2 2 6 2 2 6
46418 - 2 2 6 6 6 6 91 60 6 167 114 7
46419 -206 145 10 230 174 11 242 186 14 246 190 14
46420 -246 190 14 246 190 14 246 186 14 242 186 14
46421 -239 182 13 230 174 11 224 166 10 213 154 11
46422 -180 133 36 124 112 88 86 86 86 58 58 58
46423 - 38 38 38 22 22 22 10 10 10 6 6 6
46424 - 0 0 0 0 0 0 0 0 0 0 0 0
46425 - 0 0 0 0 0 0 0 0 0 0 0 0
46426 - 0 0 0 0 0 0 0 0 0 0 0 0
46427 - 0 0 0 0 0 0 0 0 0 14 14 14
46428 - 34 34 34 70 70 70 138 110 50 158 118 36
46429 -167 114 7 180 123 7 192 133 9 197 138 11
46430 -200 144 11 206 145 10 213 154 11 219 162 10
46431 -224 166 10 230 174 11 239 182 13 242 186 14
46432 -246 186 14 246 186 14 246 186 14 246 186 14
46433 -239 182 13 216 158 10 185 133 11 152 99 6
46434 -104 69 6 18 14 6 2 2 6 2 2 6
46435 - 2 2 6 2 2 6 2 2 6 2 2 6
46436 - 2 2 6 2 2 6 2 2 6 2 2 6
46437 - 2 2 6 2 2 6 2 2 6 2 2 6
46438 - 2 2 6 6 6 6 80 54 7 152 99 6
46439 -192 133 9 219 162 10 236 178 12 239 182 13
46440 -246 186 14 242 186 14 239 182 13 236 178 12
46441 -224 166 10 206 145 10 192 133 9 154 121 60
46442 - 94 94 94 62 62 62 42 42 42 22 22 22
46443 - 14 14 14 6 6 6 0 0 0 0 0 0
46444 - 0 0 0 0 0 0 0 0 0 0 0 0
46445 - 0 0 0 0 0 0 0 0 0 0 0 0
46446 - 0 0 0 0 0 0 0 0 0 0 0 0
46447 - 0 0 0 0 0 0 0 0 0 6 6 6
46448 - 18 18 18 34 34 34 58 58 58 78 78 78
46449 -101 98 89 124 112 88 142 110 46 156 107 11
46450 -163 110 8 167 114 7 175 118 6 180 123 7
46451 -185 133 11 197 138 11 210 150 10 219 162 10
46452 -226 170 11 236 178 12 236 178 12 234 174 13
46453 -219 162 10 197 138 11 163 110 8 130 83 6
46454 - 91 60 6 10 10 10 2 2 6 2 2 6
46455 - 18 18 18 38 38 38 38 38 38 38 38 38
46456 - 38 38 38 38 38 38 38 38 38 38 38 38
46457 - 38 38 38 38 38 38 26 26 26 2 2 6
46458 - 2 2 6 6 6 6 70 47 6 137 92 6
46459 -175 118 6 200 144 11 219 162 10 230 174 11
46460 -234 174 13 230 174 11 219 162 10 210 150 10
46461 -192 133 9 163 110 8 124 112 88 82 82 82
46462 - 50 50 50 30 30 30 14 14 14 6 6 6
46463 - 0 0 0 0 0 0 0 0 0 0 0 0
46464 - 0 0 0 0 0 0 0 0 0 0 0 0
46465 - 0 0 0 0 0 0 0 0 0 0 0 0
46466 - 0 0 0 0 0 0 0 0 0 0 0 0
46467 - 0 0 0 0 0 0 0 0 0 0 0 0
46468 - 6 6 6 14 14 14 22 22 22 34 34 34
46469 - 42 42 42 58 58 58 74 74 74 86 86 86
46470 -101 98 89 122 102 70 130 98 46 121 87 25
46471 -137 92 6 152 99 6 163 110 8 180 123 7
46472 -185 133 11 197 138 11 206 145 10 200 144 11
46473 -180 123 7 156 107 11 130 83 6 104 69 6
46474 - 50 34 6 54 54 54 110 110 110 101 98 89
46475 - 86 86 86 82 82 82 78 78 78 78 78 78
46476 - 78 78 78 78 78 78 78 78 78 78 78 78
46477 - 78 78 78 82 82 82 86 86 86 94 94 94
46478 -106 106 106 101 101 101 86 66 34 124 80 6
46479 -156 107 11 180 123 7 192 133 9 200 144 11
46480 -206 145 10 200 144 11 192 133 9 175 118 6
46481 -139 102 15 109 106 95 70 70 70 42 42 42
46482 - 22 22 22 10 10 10 0 0 0 0 0 0
46483 - 0 0 0 0 0 0 0 0 0 0 0 0
46484 - 0 0 0 0 0 0 0 0 0 0 0 0
46485 - 0 0 0 0 0 0 0 0 0 0 0 0
46486 - 0 0 0 0 0 0 0 0 0 0 0 0
46487 - 0 0 0 0 0 0 0 0 0 0 0 0
46488 - 0 0 0 0 0 0 6 6 6 10 10 10
46489 - 14 14 14 22 22 22 30 30 30 38 38 38
46490 - 50 50 50 62 62 62 74 74 74 90 90 90
46491 -101 98 89 112 100 78 121 87 25 124 80 6
46492 -137 92 6 152 99 6 152 99 6 152 99 6
46493 -138 86 6 124 80 6 98 70 6 86 66 30
46494 -101 98 89 82 82 82 58 58 58 46 46 46
46495 - 38 38 38 34 34 34 34 34 34 34 34 34
46496 - 34 34 34 34 34 34 34 34 34 34 34 34
46497 - 34 34 34 34 34 34 38 38 38 42 42 42
46498 - 54 54 54 82 82 82 94 86 76 91 60 6
46499 -134 86 6 156 107 11 167 114 7 175 118 6
46500 -175 118 6 167 114 7 152 99 6 121 87 25
46501 -101 98 89 62 62 62 34 34 34 18 18 18
46502 - 6 6 6 0 0 0 0 0 0 0 0 0
46503 - 0 0 0 0 0 0 0 0 0 0 0 0
46504 - 0 0 0 0 0 0 0 0 0 0 0 0
46505 - 0 0 0 0 0 0 0 0 0 0 0 0
46506 - 0 0 0 0 0 0 0 0 0 0 0 0
46507 - 0 0 0 0 0 0 0 0 0 0 0 0
46508 - 0 0 0 0 0 0 0 0 0 0 0 0
46509 - 0 0 0 6 6 6 6 6 6 10 10 10
46510 - 18 18 18 22 22 22 30 30 30 42 42 42
46511 - 50 50 50 66 66 66 86 86 86 101 98 89
46512 -106 86 58 98 70 6 104 69 6 104 69 6
46513 -104 69 6 91 60 6 82 62 34 90 90 90
46514 - 62 62 62 38 38 38 22 22 22 14 14 14
46515 - 10 10 10 10 10 10 10 10 10 10 10 10
46516 - 10 10 10 10 10 10 6 6 6 10 10 10
46517 - 10 10 10 10 10 10 10 10 10 14 14 14
46518 - 22 22 22 42 42 42 70 70 70 89 81 66
46519 - 80 54 7 104 69 6 124 80 6 137 92 6
46520 -134 86 6 116 81 8 100 82 52 86 86 86
46521 - 58 58 58 30 30 30 14 14 14 6 6 6
46522 - 0 0 0 0 0 0 0 0 0 0 0 0
46523 - 0 0 0 0 0 0 0 0 0 0 0 0
46524 - 0 0 0 0 0 0 0 0 0 0 0 0
46525 - 0 0 0 0 0 0 0 0 0 0 0 0
46526 - 0 0 0 0 0 0 0 0 0 0 0 0
46527 - 0 0 0 0 0 0 0 0 0 0 0 0
46528 - 0 0 0 0 0 0 0 0 0 0 0 0
46529 - 0 0 0 0 0 0 0 0 0 0 0 0
46530 - 0 0 0 6 6 6 10 10 10 14 14 14
46531 - 18 18 18 26 26 26 38 38 38 54 54 54
46532 - 70 70 70 86 86 86 94 86 76 89 81 66
46533 - 89 81 66 86 86 86 74 74 74 50 50 50
46534 - 30 30 30 14 14 14 6 6 6 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 - 6 6 6 18 18 18 34 34 34 58 58 58
46539 - 82 82 82 89 81 66 89 81 66 89 81 66
46540 - 94 86 66 94 86 76 74 74 74 50 50 50
46541 - 26 26 26 14 14 14 6 6 6 0 0 0
46542 - 0 0 0 0 0 0 0 0 0 0 0 0
46543 - 0 0 0 0 0 0 0 0 0 0 0 0
46544 - 0 0 0 0 0 0 0 0 0 0 0 0
46545 - 0 0 0 0 0 0 0 0 0 0 0 0
46546 - 0 0 0 0 0 0 0 0 0 0 0 0
46547 - 0 0 0 0 0 0 0 0 0 0 0 0
46548 - 0 0 0 0 0 0 0 0 0 0 0 0
46549 - 0 0 0 0 0 0 0 0 0 0 0 0
46550 - 0 0 0 0 0 0 0 0 0 0 0 0
46551 - 6 6 6 6 6 6 14 14 14 18 18 18
46552 - 30 30 30 38 38 38 46 46 46 54 54 54
46553 - 50 50 50 42 42 42 30 30 30 18 18 18
46554 - 10 10 10 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 6 6 6 14 14 14 26 26 26
46559 - 38 38 38 50 50 50 58 58 58 58 58 58
46560 - 54 54 54 42 42 42 30 30 30 18 18 18
46561 - 10 10 10 0 0 0 0 0 0 0 0 0
46562 - 0 0 0 0 0 0 0 0 0 0 0 0
46563 - 0 0 0 0 0 0 0 0 0 0 0 0
46564 - 0 0 0 0 0 0 0 0 0 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 - 0 0 0 0 0 0 0 0 0 0 0 0
46569 - 0 0 0 0 0 0 0 0 0 0 0 0
46570 - 0 0 0 0 0 0 0 0 0 0 0 0
46571 - 0 0 0 0 0 0 0 0 0 6 6 6
46572 - 6 6 6 10 10 10 14 14 14 18 18 18
46573 - 18 18 18 14 14 14 10 10 10 6 6 6
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 6 6 6
46579 - 14 14 14 18 18 18 22 22 22 22 22 22
46580 - 18 18 18 14 14 14 10 10 10 6 6 6
46581 - 0 0 0 0 0 0 0 0 0 0 0 0
46582 - 0 0 0 0 0 0 0 0 0 0 0 0
46583 - 0 0 0 0 0 0 0 0 0 0 0 0
46584 - 0 0 0 0 0 0 0 0 0 0 0 0
46585 - 0 0 0 0 0 0 0 0 0 0 0 0
46586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46590 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46599 +4 4 4 4 4 4
46600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46604 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46613 +4 4 4 4 4 4
46614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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 3 3 3 0 0 0 0 0 0
46675 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 1 1 1 0 0 0
46680 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46681 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46683 +4 4 4 4 4 4
46684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46685 +4 4 4 4 4 4 4 4 4 4 4 4 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 2 2 2 0 0 0 3 4 3 26 28 28
46689 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46690 +5 5 5 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 3 3 3 0 0 0 1 1 1 6 6 6
46694 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46695 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46696 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46697 +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 4 4 4 4 4 4 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 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46703 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46704 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46707 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46708 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46709 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46710 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46711 +4 4 4 4 4 4
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 4 4 4 4 4 4 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 5 5 5 5 5 5 2 2 2 0 0 0
46716 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46717 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46718 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46720 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46721 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46722 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46723 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46724 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46725 +4 4 4 4 4 4
46726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46727 +4 4 4 4 4 4 4 4 4 4 4 4 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 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46730 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46731 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46732 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46733 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46734 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46735 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46736 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46737 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46738 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46739 +4 4 4 4 4 4
46740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46743 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46744 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46745 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46746 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46747 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46748 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46749 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46750 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46751 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46752 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46753 +4 4 4 4 4 4
46754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46756 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46757 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46758 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46759 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46760 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46761 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46762 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46763 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46764 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46765 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46766 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46767 +4 4 4 4 4 4
46768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46770 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46771 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46772 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46773 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46774 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46775 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46776 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46777 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46778 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46779 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46780 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46781 +4 4 4 4 4 4
46782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46784 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46785 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46786 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46787 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46788 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46789 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46790 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46791 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46792 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46793 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46794 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46795 +4 4 4 4 4 4
46796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46798 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46799 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46800 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46801 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46802 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46803 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46804 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46805 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46806 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46807 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46808 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46809 +4 4 4 4 4 4
46810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46811 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46812 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46813 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46814 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46815 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46816 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46817 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46818 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46819 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46820 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46821 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46822 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46823 +4 4 4 4 4 4
46824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46825 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46826 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46827 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46828 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46829 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46830 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46831 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46832 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46833 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46834 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46835 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46836 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46837 +0 0 0 4 4 4
46838 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46839 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46840 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46841 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46842 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46843 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46844 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46845 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46846 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46847 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46848 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46849 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46850 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46851 +2 0 0 0 0 0
46852 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46853 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46854 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46855 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46856 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46857 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46858 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46859 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46860 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46861 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46862 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46863 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46864 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46865 +37 38 37 0 0 0
46866 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46867 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46868 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46869 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46870 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46871 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46872 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46873 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46874 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46875 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46876 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46877 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46878 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46879 +85 115 134 4 0 0
46880 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46881 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46882 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46883 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46884 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46885 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46886 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46887 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46888 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46889 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46890 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46891 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46892 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46893 +60 73 81 4 0 0
46894 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46895 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46896 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46897 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46898 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46899 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46900 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46901 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46902 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46903 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46904 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46905 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46906 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46907 +16 19 21 4 0 0
46908 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46909 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46910 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46911 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46912 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46913 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46914 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46915 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46916 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46917 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46918 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46919 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46920 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46921 +4 0 0 4 3 3
46922 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46923 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46924 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46926 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46927 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46928 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46929 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46930 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46931 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46932 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46933 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46934 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46935 +3 2 2 4 4 4
46936 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46937 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46938 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46939 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46940 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46941 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46942 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46943 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46944 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46945 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46946 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46947 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46948 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46949 +4 4 4 4 4 4
46950 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46951 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46952 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46953 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46954 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46955 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46956 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46957 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46958 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46959 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46960 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46961 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46962 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46963 +4 4 4 4 4 4
46964 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46965 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46966 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46967 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46968 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46969 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46970 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46971 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46972 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46973 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46974 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46975 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46976 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46977 +5 5 5 5 5 5
46978 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46979 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46980 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46981 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46982 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46983 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46984 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46985 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46986 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46987 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46988 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46989 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46990 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46991 +5 5 5 4 4 4
46992 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46993 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46994 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46995 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46996 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46997 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46998 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46999 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47000 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47001 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47002 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47003 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47005 +4 4 4 4 4 4
47006 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47007 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47008 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47009 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47010 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47011 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47012 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47013 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47014 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47015 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47016 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47017 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47019 +4 4 4 4 4 4
47020 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47021 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47022 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47023 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47024 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47025 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47026 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47027 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47028 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47029 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47030 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47033 +4 4 4 4 4 4
47034 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47035 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47036 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47037 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47038 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47039 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47040 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47041 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47042 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47043 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47044 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47047 +4 4 4 4 4 4
47048 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47049 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47050 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47051 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47052 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47053 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47054 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47055 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47056 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47057 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47058 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47061 +4 4 4 4 4 4
47062 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47063 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47064 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47065 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47066 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47067 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47068 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47069 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47070 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47071 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47072 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47075 +4 4 4 4 4 4
47076 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47077 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47078 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47079 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47080 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47081 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47082 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47083 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47084 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47085 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47086 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47089 +4 4 4 4 4 4
47090 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47091 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47092 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47093 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47094 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47095 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47096 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47097 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47098 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47099 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47100 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47103 +4 4 4 4 4 4
47104 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47105 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47106 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47107 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47108 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47109 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47110 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47111 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47112 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47113 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47114 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47117 +4 4 4 4 4 4
47118 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47119 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47120 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47121 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47122 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47123 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47124 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47125 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47126 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47127 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47128 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47131 +4 4 4 4 4 4
47132 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47133 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47134 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47135 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47136 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47137 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47138 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47139 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47140 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47141 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47142 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47145 +4 4 4 4 4 4
47146 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47147 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47148 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47149 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47150 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47151 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47152 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47153 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47154 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47155 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47156 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47159 +4 4 4 4 4 4
47160 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47161 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47162 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47163 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47164 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47165 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47166 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47167 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47168 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47169 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47170 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47172 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47173 +4 4 4 4 4 4
47174 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47175 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47176 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47177 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47178 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47179 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47180 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47181 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47182 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47183 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47184 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47186 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47187 +4 4 4 4 4 4
47188 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47189 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47190 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47191 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47192 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47193 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47194 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47195 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47196 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47197 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47198 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47200 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47201 +4 4 4 4 4 4
47202 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47203 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47204 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47205 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47206 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47207 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47208 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47209 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47210 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47211 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47212 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47214 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47215 +4 4 4 4 4 4
47216 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47217 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47218 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47219 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47220 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47221 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47222 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47223 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47224 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47225 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47226 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47228 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47229 +4 4 4 4 4 4
47230 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47231 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47232 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47233 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47234 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47235 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47236 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47237 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47238 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47239 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47240 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47242 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47243 +4 4 4 4 4 4
47244 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47245 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47246 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47247 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47248 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47249 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47250 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47251 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47252 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47253 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47254 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47256 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47257 +4 4 4 4 4 4
47258 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47259 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47260 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47261 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47262 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47263 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47264 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47265 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47266 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47267 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47268 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47270 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47271 +4 4 4 4 4 4
47272 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47273 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47274 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47275 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47276 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47277 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47278 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47279 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47280 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47281 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47282 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47284 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47285 +4 4 4 4 4 4
47286 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47287 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47288 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47289 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47290 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47291 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47292 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47293 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47294 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47295 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47296 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47298 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47299 +4 4 4 4 4 4
47300 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47301 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47302 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47303 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47304 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47305 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47306 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47307 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47308 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47309 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47310 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47311 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47312 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47313 +4 4 4 4 4 4
47314 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47315 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47316 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47317 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47318 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47319 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47320 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47321 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47322 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47323 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47324 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47325 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47326 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47327 +4 4 4 4 4 4
47328 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47329 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47330 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47331 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47332 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47333 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47334 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47335 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47336 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47337 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47338 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47340 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47341 +4 4 4 4 4 4
47342 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47343 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47344 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47345 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47346 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47347 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47348 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47349 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47350 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47351 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47352 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47353 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47355 +4 4 4 4 4 4
47356 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47357 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47358 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47359 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47360 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47361 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47362 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47363 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47364 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47365 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47366 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47369 +4 4 4 4 4 4
47370 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47371 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47372 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47373 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47374 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47375 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47376 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47377 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47378 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47379 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47380 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47383 +4 4 4 4 4 4
47384 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47385 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47386 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47387 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47388 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47389 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47390 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47391 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47392 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47393 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47394 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47397 +4 4 4 4 4 4
47398 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47399 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47400 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47401 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47402 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47403 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47404 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47405 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47406 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47407 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47411 +4 4 4 4 4 4
47412 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47413 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47414 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47415 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47416 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47417 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47418 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47419 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47420 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47421 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47425 +4 4 4 4 4 4
47426 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47427 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47428 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47429 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47430 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47431 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47432 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47433 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47434 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47435 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
47440 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47441 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47442 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47443 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47444 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47445 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47446 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47447 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47448 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47449 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47451 +4 4 4 4 4 4 4 4 4 4 4 4 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
47454 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47455 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47456 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47457 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47458 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47459 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47460 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47461 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47462 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47465 +4 4 4 4 4 4 4 4 4 4 4 4 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
47468 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47469 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47470 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47471 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47472 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47473 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47474 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47475 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47476 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47479 +4 4 4 4 4 4 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
47482 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47483 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47484 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47485 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47486 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47487 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47488 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47489 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47490 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
47496 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47497 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47498 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47499 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47500 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47501 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47502 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47503 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47506 +4 4 4 4 4 4 4 4 4 4 4 4 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
47510 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47511 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47512 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47513 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47514 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47515 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47516 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47517 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47520 +4 4 4 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
47524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47525 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47526 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47527 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47528 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47529 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47530 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47531 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
47538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47539 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47540 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47541 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47542 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47543 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47544 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47545 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47547 +4 4 4 4 4 4 4 4 4 4 4 4 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
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 4 4 4 5 5 5 5 5 5 5 5 5
47554 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47555 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47556 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47557 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47558 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47559 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47561 +4 4 4 4 4 4 4 4 4 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
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 4 4 4 4 4 4 4 4 4 4 4 4
47568 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47569 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47570 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47571 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47572 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47573 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47575 +4 4 4 4 4 4 4 4 4 4 4 4 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
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 4 4 4 4 4 4 4 4 4 4 4 4
47582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47583 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47584 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47585 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47586 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47589 +4 4 4 4 4 4 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
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 4 4 4 4 4 4 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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47598 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47599 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47600 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47603 +4 4 4 4 4 4 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
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 4 4 4 4 4 4 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 5 5 5 4 3 3 5 5 5 6 6 6
47612 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47613 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47614 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 4 4 4 4 4 4 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 5 5 5 4 3 3 5 5 5
47626 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47627 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47628 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 4 4 4 4 4 4 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 5 5 5
47640 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47641 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47642 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47655 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47656 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47669 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47670 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47672 +4 4 4 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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 5 5 5 4 3 3 6 6 6
47683 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47686 +4 4 4 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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 5 5 5 4 3 3
47697 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47700 +4 4 4 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
47706 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47707 index fe92eed..106e085 100644
47708 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47709 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47710 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47711 struct mb862xxfb_par *par = info->par;
47712
47713 if (info->var.bits_per_pixel == 32) {
47714 - info->fbops->fb_fillrect = cfb_fillrect;
47715 - info->fbops->fb_copyarea = cfb_copyarea;
47716 - info->fbops->fb_imageblit = cfb_imageblit;
47717 + pax_open_kernel();
47718 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47719 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47720 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47721 + pax_close_kernel();
47722 } else {
47723 outreg(disp, GC_L0EM, 3);
47724 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47725 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47726 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47727 + pax_open_kernel();
47728 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47729 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47730 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47731 + pax_close_kernel();
47732 }
47733 outreg(draw, GDC_REG_DRAW_BASE, 0);
47734 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47735 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47736 index ff22871..b129bed 100644
47737 --- a/drivers/video/nvidia/nvidia.c
47738 +++ b/drivers/video/nvidia/nvidia.c
47739 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47740 info->fix.line_length = (info->var.xres_virtual *
47741 info->var.bits_per_pixel) >> 3;
47742 if (info->var.accel_flags) {
47743 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47744 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47745 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47746 - info->fbops->fb_sync = nvidiafb_sync;
47747 + pax_open_kernel();
47748 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47749 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47750 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47751 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47752 + pax_close_kernel();
47753 info->pixmap.scan_align = 4;
47754 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47755 info->flags |= FBINFO_READS_FAST;
47756 NVResetGraphics(info);
47757 } else {
47758 - info->fbops->fb_imageblit = cfb_imageblit;
47759 - info->fbops->fb_fillrect = cfb_fillrect;
47760 - info->fbops->fb_copyarea = cfb_copyarea;
47761 - info->fbops->fb_sync = NULL;
47762 + pax_open_kernel();
47763 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47764 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47765 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47766 + *(void **)&info->fbops->fb_sync = NULL;
47767 + pax_close_kernel();
47768 info->pixmap.scan_align = 1;
47769 info->flags |= FBINFO_HWACCEL_DISABLED;
47770 info->flags &= ~FBINFO_READS_FAST;
47771 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47772 info->pixmap.size = 8 * 1024;
47773 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47774
47775 - if (!hwcur)
47776 - info->fbops->fb_cursor = NULL;
47777 + if (!hwcur) {
47778 + pax_open_kernel();
47779 + *(void **)&info->fbops->fb_cursor = NULL;
47780 + pax_close_kernel();
47781 + }
47782
47783 info->var.accel_flags = (!noaccel);
47784
47785 diff --git a/drivers/video/output.c b/drivers/video/output.c
47786 index 0d6f2cd..6285b97 100644
47787 --- a/drivers/video/output.c
47788 +++ b/drivers/video/output.c
47789 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
47790 new_dev->props = op;
47791 new_dev->dev.class = &video_output_class;
47792 new_dev->dev.parent = dev;
47793 - dev_set_name(&new_dev->dev, name);
47794 + dev_set_name(&new_dev->dev, "%s", name);
47795 dev_set_drvdata(&new_dev->dev, devdata);
47796 ret_code = device_register(&new_dev->dev);
47797 if (ret_code) {
47798 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47799 index 76d9053..dec2bfd 100644
47800 --- a/drivers/video/s1d13xxxfb.c
47801 +++ b/drivers/video/s1d13xxxfb.c
47802 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47803
47804 switch(prod_id) {
47805 case S1D13506_PROD_ID: /* activate acceleration */
47806 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47807 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47808 + pax_open_kernel();
47809 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47810 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47811 + pax_close_kernel();
47812 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47813 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47814 break;
47815 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47816 index 97bd662..39fab85 100644
47817 --- a/drivers/video/smscufx.c
47818 +++ b/drivers/video/smscufx.c
47819 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47820 fb_deferred_io_cleanup(info);
47821 kfree(info->fbdefio);
47822 info->fbdefio = NULL;
47823 - info->fbops->fb_mmap = ufx_ops_mmap;
47824 + pax_open_kernel();
47825 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47826 + pax_close_kernel();
47827 }
47828
47829 pr_debug("released /dev/fb%d user=%d count=%d",
47830 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47831 index 86d449e..8e04dc5 100644
47832 --- a/drivers/video/udlfb.c
47833 +++ b/drivers/video/udlfb.c
47834 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47835 dlfb_urb_completion(urb);
47836
47837 error:
47838 - atomic_add(bytes_sent, &dev->bytes_sent);
47839 - atomic_add(bytes_identical, &dev->bytes_identical);
47840 - atomic_add(width*height*2, &dev->bytes_rendered);
47841 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47842 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47843 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47844 end_cycles = get_cycles();
47845 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47846 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47847 >> 10)), /* Kcycles */
47848 &dev->cpu_kcycles_used);
47849
47850 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47851 dlfb_urb_completion(urb);
47852
47853 error:
47854 - atomic_add(bytes_sent, &dev->bytes_sent);
47855 - atomic_add(bytes_identical, &dev->bytes_identical);
47856 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47857 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47858 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47859 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47860 end_cycles = get_cycles();
47861 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47862 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47863 >> 10)), /* Kcycles */
47864 &dev->cpu_kcycles_used);
47865 }
47866 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47867 fb_deferred_io_cleanup(info);
47868 kfree(info->fbdefio);
47869 info->fbdefio = NULL;
47870 - info->fbops->fb_mmap = dlfb_ops_mmap;
47871 + pax_open_kernel();
47872 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47873 + pax_close_kernel();
47874 }
47875
47876 pr_warn("released /dev/fb%d user=%d count=%d\n",
47877 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47878 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47879 struct dlfb_data *dev = fb_info->par;
47880 return snprintf(buf, PAGE_SIZE, "%u\n",
47881 - atomic_read(&dev->bytes_rendered));
47882 + atomic_read_unchecked(&dev->bytes_rendered));
47883 }
47884
47885 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47886 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47887 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47888 struct dlfb_data *dev = fb_info->par;
47889 return snprintf(buf, PAGE_SIZE, "%u\n",
47890 - atomic_read(&dev->bytes_identical));
47891 + atomic_read_unchecked(&dev->bytes_identical));
47892 }
47893
47894 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47895 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47896 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47897 struct dlfb_data *dev = fb_info->par;
47898 return snprintf(buf, PAGE_SIZE, "%u\n",
47899 - atomic_read(&dev->bytes_sent));
47900 + atomic_read_unchecked(&dev->bytes_sent));
47901 }
47902
47903 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47904 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47905 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47906 struct dlfb_data *dev = fb_info->par;
47907 return snprintf(buf, PAGE_SIZE, "%u\n",
47908 - atomic_read(&dev->cpu_kcycles_used));
47909 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47910 }
47911
47912 static ssize_t edid_show(
47913 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47914 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47915 struct dlfb_data *dev = fb_info->par;
47916
47917 - atomic_set(&dev->bytes_rendered, 0);
47918 - atomic_set(&dev->bytes_identical, 0);
47919 - atomic_set(&dev->bytes_sent, 0);
47920 - atomic_set(&dev->cpu_kcycles_used, 0);
47921 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47922 + atomic_set_unchecked(&dev->bytes_identical, 0);
47923 + atomic_set_unchecked(&dev->bytes_sent, 0);
47924 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47925
47926 return count;
47927 }
47928 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47929 index d428445..79a78df 100644
47930 --- a/drivers/video/uvesafb.c
47931 +++ b/drivers/video/uvesafb.c
47932 @@ -19,6 +19,7 @@
47933 #include <linux/io.h>
47934 #include <linux/mutex.h>
47935 #include <linux/slab.h>
47936 +#include <linux/moduleloader.h>
47937 #include <video/edid.h>
47938 #include <video/uvesafb.h>
47939 #ifdef CONFIG_X86
47940 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47941 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47942 par->pmi_setpal = par->ypan = 0;
47943 } else {
47944 +
47945 +#ifdef CONFIG_PAX_KERNEXEC
47946 +#ifdef CONFIG_MODULES
47947 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47948 +#endif
47949 + if (!par->pmi_code) {
47950 + par->pmi_setpal = par->ypan = 0;
47951 + return 0;
47952 + }
47953 +#endif
47954 +
47955 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47956 + task->t.regs.edi);
47957 +
47958 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47959 + pax_open_kernel();
47960 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47961 + pax_close_kernel();
47962 +
47963 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47964 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47965 +#else
47966 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47967 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47968 +#endif
47969 +
47970 printk(KERN_INFO "uvesafb: protected mode interface info at "
47971 "%04x:%04x\n",
47972 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47973 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47974 par->ypan = ypan;
47975
47976 if (par->pmi_setpal || par->ypan) {
47977 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47978 if (__supported_pte_mask & _PAGE_NX) {
47979 par->pmi_setpal = par->ypan = 0;
47980 printk(KERN_WARNING "uvesafb: NX protection is actively."
47981 "We have better not to use the PMI.\n");
47982 - } else {
47983 + } else
47984 +#endif
47985 uvesafb_vbe_getpmi(task, par);
47986 - }
47987 }
47988 #else
47989 /* The protected mode interface is not available on non-x86. */
47990 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47991 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47992
47993 /* Disable blanking if the user requested so. */
47994 - if (!blank)
47995 - info->fbops->fb_blank = NULL;
47996 + if (!blank) {
47997 + pax_open_kernel();
47998 + *(void **)&info->fbops->fb_blank = NULL;
47999 + pax_close_kernel();
48000 + }
48001
48002 /*
48003 * Find out how much IO memory is required for the mode with
48004 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48005 info->flags = FBINFO_FLAG_DEFAULT |
48006 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48007
48008 - if (!par->ypan)
48009 - info->fbops->fb_pan_display = NULL;
48010 + if (!par->ypan) {
48011 + pax_open_kernel();
48012 + *(void **)&info->fbops->fb_pan_display = NULL;
48013 + pax_close_kernel();
48014 + }
48015 }
48016
48017 static void uvesafb_init_mtrr(struct fb_info *info)
48018 @@ -1836,6 +1866,11 @@ out:
48019 if (par->vbe_modes)
48020 kfree(par->vbe_modes);
48021
48022 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48023 + if (par->pmi_code)
48024 + module_free_exec(NULL, par->pmi_code);
48025 +#endif
48026 +
48027 framebuffer_release(info);
48028 return err;
48029 }
48030 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48031 kfree(par->vbe_state_orig);
48032 if (par->vbe_state_saved)
48033 kfree(par->vbe_state_saved);
48034 +
48035 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48036 + if (par->pmi_code)
48037 + module_free_exec(NULL, par->pmi_code);
48038 +#endif
48039 +
48040 }
48041
48042 framebuffer_release(info);
48043 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48044 index 501b340..d80aa17 100644
48045 --- a/drivers/video/vesafb.c
48046 +++ b/drivers/video/vesafb.c
48047 @@ -9,6 +9,7 @@
48048 */
48049
48050 #include <linux/module.h>
48051 +#include <linux/moduleloader.h>
48052 #include <linux/kernel.h>
48053 #include <linux/errno.h>
48054 #include <linux/string.h>
48055 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48056 static int vram_total __initdata; /* Set total amount of memory */
48057 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48058 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48059 -static void (*pmi_start)(void) __read_mostly;
48060 -static void (*pmi_pal) (void) __read_mostly;
48061 +static void (*pmi_start)(void) __read_only;
48062 +static void (*pmi_pal) (void) __read_only;
48063 static int depth __read_mostly;
48064 static int vga_compat __read_mostly;
48065 /* --------------------------------------------------------------------- */
48066 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48067 unsigned int size_vmode;
48068 unsigned int size_remap;
48069 unsigned int size_total;
48070 + void *pmi_code = NULL;
48071
48072 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48073 return -ENODEV;
48074 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48075 size_remap = size_total;
48076 vesafb_fix.smem_len = size_remap;
48077
48078 -#ifndef __i386__
48079 - screen_info.vesapm_seg = 0;
48080 -#endif
48081 -
48082 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48083 printk(KERN_WARNING
48084 "vesafb: cannot reserve video memory at 0x%lx\n",
48085 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48086 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48087 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48088
48089 +#ifdef __i386__
48090 +
48091 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48092 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48093 + if (!pmi_code)
48094 +#elif !defined(CONFIG_PAX_KERNEXEC)
48095 + if (0)
48096 +#endif
48097 +
48098 +#endif
48099 + screen_info.vesapm_seg = 0;
48100 +
48101 if (screen_info.vesapm_seg) {
48102 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48103 - screen_info.vesapm_seg,screen_info.vesapm_off);
48104 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48105 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48106 }
48107
48108 if (screen_info.vesapm_seg < 0xc000)
48109 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48110
48111 if (ypan || pmi_setpal) {
48112 unsigned short *pmi_base;
48113 +
48114 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48115 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48116 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48117 +
48118 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48119 + pax_open_kernel();
48120 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48121 +#else
48122 + pmi_code = pmi_base;
48123 +#endif
48124 +
48125 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48126 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48127 +
48128 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48129 + pmi_start = ktva_ktla(pmi_start);
48130 + pmi_pal = ktva_ktla(pmi_pal);
48131 + pax_close_kernel();
48132 +#endif
48133 +
48134 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48135 if (pmi_base[3]) {
48136 printk(KERN_INFO "vesafb: pmi: ports = ");
48137 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48138 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48139 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48140
48141 - if (!ypan)
48142 - info->fbops->fb_pan_display = NULL;
48143 + if (!ypan) {
48144 + pax_open_kernel();
48145 + *(void **)&info->fbops->fb_pan_display = NULL;
48146 + pax_close_kernel();
48147 + }
48148
48149 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48150 err = -ENOMEM;
48151 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48152 info->node, info->fix.id);
48153 return 0;
48154 err:
48155 +
48156 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48157 + module_free_exec(NULL, pmi_code);
48158 +#endif
48159 +
48160 if (info->screen_base)
48161 iounmap(info->screen_base);
48162 framebuffer_release(info);
48163 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48164 index 88714ae..16c2e11 100644
48165 --- a/drivers/video/via/via_clock.h
48166 +++ b/drivers/video/via/via_clock.h
48167 @@ -56,7 +56,7 @@ struct via_clock {
48168
48169 void (*set_engine_pll_state)(u8 state);
48170 void (*set_engine_pll)(struct via_pll_config config);
48171 -};
48172 +} __no_const;
48173
48174
48175 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48176 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48177 index fef20db..d28b1ab 100644
48178 --- a/drivers/xen/xenfs/xenstored.c
48179 +++ b/drivers/xen/xenfs/xenstored.c
48180 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48181 static int xsd_kva_open(struct inode *inode, struct file *file)
48182 {
48183 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48184 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48185 + NULL);
48186 +#else
48187 xen_store_interface);
48188 +#endif
48189 +
48190 if (!file->private_data)
48191 return -ENOMEM;
48192 return 0;
48193 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
48194 index 0ad61c6..f198bd7 100644
48195 --- a/fs/9p/vfs_addr.c
48196 +++ b/fs/9p/vfs_addr.c
48197 @@ -185,7 +185,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
48198
48199 retval = v9fs_file_write_internal(inode,
48200 v9inode->writeback_fid,
48201 - (__force const char __user *)buffer,
48202 + (const char __force_user *)buffer,
48203 len, &offset, 0);
48204 if (retval > 0)
48205 retval = 0;
48206 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48207 index d86edc8..40ff2fb 100644
48208 --- a/fs/9p/vfs_inode.c
48209 +++ b/fs/9p/vfs_inode.c
48210 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48211 void
48212 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48213 {
48214 - char *s = nd_get_link(nd);
48215 + const char *s = nd_get_link(nd);
48216
48217 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48218 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48219 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48220 index 0efd152..b5802ad 100644
48221 --- a/fs/Kconfig.binfmt
48222 +++ b/fs/Kconfig.binfmt
48223 @@ -89,7 +89,7 @@ config HAVE_AOUT
48224
48225 config BINFMT_AOUT
48226 tristate "Kernel support for a.out and ECOFF binaries"
48227 - depends on HAVE_AOUT
48228 + depends on HAVE_AOUT && BROKEN
48229 ---help---
48230 A.out (Assembler.OUTput) is a set of formats for libraries and
48231 executables used in the earliest versions of UNIX. Linux used
48232 diff --git a/fs/aio.c b/fs/aio.c
48233 index 1dc8786..d3b29e8 100644
48234 --- a/fs/aio.c
48235 +++ b/fs/aio.c
48236 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48237 size += sizeof(struct io_event) * nr_events;
48238 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48239
48240 - if (nr_pages < 0)
48241 + if (nr_pages <= 0)
48242 return -EINVAL;
48243
48244 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48245 @@ -1375,18 +1375,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
48246 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48247 {
48248 ssize_t ret;
48249 + struct iovec iovstack;
48250
48251 #ifdef CONFIG_COMPAT
48252 if (compat)
48253 ret = compat_rw_copy_check_uvector(type,
48254 (struct compat_iovec __user *)kiocb->ki_buf,
48255 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48256 + kiocb->ki_nbytes, 1, &iovstack,
48257 &kiocb->ki_iovec);
48258 else
48259 #endif
48260 ret = rw_copy_check_uvector(type,
48261 (struct iovec __user *)kiocb->ki_buf,
48262 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48263 + kiocb->ki_nbytes, 1, &iovstack,
48264 &kiocb->ki_iovec);
48265 if (ret < 0)
48266 goto out;
48267 @@ -1395,6 +1396,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48268 if (ret < 0)
48269 goto out;
48270
48271 + if (kiocb->ki_iovec == &iovstack) {
48272 + kiocb->ki_inline_vec = iovstack;
48273 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48274 + }
48275 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48276 kiocb->ki_cur_seg = 0;
48277 /* ki_nbytes/left now reflect bytes instead of segs */
48278 diff --git a/fs/attr.c b/fs/attr.c
48279 index 1449adb..a2038c2 100644
48280 --- a/fs/attr.c
48281 +++ b/fs/attr.c
48282 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48283 unsigned long limit;
48284
48285 limit = rlimit(RLIMIT_FSIZE);
48286 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48287 if (limit != RLIM_INFINITY && offset > limit)
48288 goto out_sig;
48289 if (offset > inode->i_sb->s_maxbytes)
48290 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48291 index 3db70da..7aeec5b 100644
48292 --- a/fs/autofs4/waitq.c
48293 +++ b/fs/autofs4/waitq.c
48294 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48295 {
48296 unsigned long sigpipe, flags;
48297 mm_segment_t fs;
48298 - const char *data = (const char *)addr;
48299 + const char __user *data = (const char __force_user *)addr;
48300 ssize_t wr = 0;
48301
48302 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48303 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48304 return 1;
48305 }
48306
48307 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48308 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48309 +#endif
48310 +
48311 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48312 enum autofs_notify notify)
48313 {
48314 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48315
48316 /* If this is a direct mount request create a dummy name */
48317 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48318 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48319 + /* this name does get written to userland via autofs4_write() */
48320 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48321 +#else
48322 qstr.len = sprintf(name, "%p", dentry);
48323 +#endif
48324 else {
48325 qstr.len = autofs4_getpath(sbi, dentry, &name);
48326 if (!qstr.len) {
48327 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48328 index 2722387..c8dd2a7 100644
48329 --- a/fs/befs/endian.h
48330 +++ b/fs/befs/endian.h
48331 @@ -11,7 +11,7 @@
48332
48333 #include <asm/byteorder.h>
48334
48335 -static inline u64
48336 +static inline u64 __intentional_overflow(-1)
48337 fs64_to_cpu(const struct super_block *sb, fs64 n)
48338 {
48339 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48340 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48341 return (__force fs64)cpu_to_be64(n);
48342 }
48343
48344 -static inline u32
48345 +static inline u32 __intentional_overflow(-1)
48346 fs32_to_cpu(const struct super_block *sb, fs32 n)
48347 {
48348 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48349 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48350 index 8615ee8..388ed68 100644
48351 --- a/fs/befs/linuxvfs.c
48352 +++ b/fs/befs/linuxvfs.c
48353 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48354 {
48355 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48356 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48357 - char *link = nd_get_link(nd);
48358 + const char *link = nd_get_link(nd);
48359 if (!IS_ERR(link))
48360 kfree(link);
48361 }
48362 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48363 index bbc8f88..7c7ac97 100644
48364 --- a/fs/binfmt_aout.c
48365 +++ b/fs/binfmt_aout.c
48366 @@ -16,6 +16,7 @@
48367 #include <linux/string.h>
48368 #include <linux/fs.h>
48369 #include <linux/file.h>
48370 +#include <linux/security.h>
48371 #include <linux/stat.h>
48372 #include <linux/fcntl.h>
48373 #include <linux/ptrace.h>
48374 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48375 #endif
48376 # define START_STACK(u) ((void __user *)u.start_stack)
48377
48378 + memset(&dump, 0, sizeof(dump));
48379 +
48380 fs = get_fs();
48381 set_fs(KERNEL_DS);
48382 has_dumped = 1;
48383 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48384
48385 /* If the size of the dump file exceeds the rlimit, then see what would happen
48386 if we wrote the stack, but not the data area. */
48387 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48388 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48389 dump.u_dsize = 0;
48390
48391 /* Make sure we have enough room to write the stack and data areas. */
48392 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48393 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48394 dump.u_ssize = 0;
48395
48396 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48397 rlim = rlimit(RLIMIT_DATA);
48398 if (rlim >= RLIM_INFINITY)
48399 rlim = ~0;
48400 +
48401 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48402 if (ex.a_data + ex.a_bss > rlim)
48403 return -ENOMEM;
48404
48405 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48406
48407 install_exec_creds(bprm);
48408
48409 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48410 + current->mm->pax_flags = 0UL;
48411 +#endif
48412 +
48413 +#ifdef CONFIG_PAX_PAGEEXEC
48414 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48415 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48416 +
48417 +#ifdef CONFIG_PAX_EMUTRAMP
48418 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48419 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48420 +#endif
48421 +
48422 +#ifdef CONFIG_PAX_MPROTECT
48423 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48424 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48425 +#endif
48426 +
48427 + }
48428 +#endif
48429 +
48430 if (N_MAGIC(ex) == OMAGIC) {
48431 unsigned long text_addr, map_size;
48432 loff_t pos;
48433 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48434 }
48435
48436 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48437 - PROT_READ | PROT_WRITE | PROT_EXEC,
48438 + PROT_READ | PROT_WRITE,
48439 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48440 fd_offset + ex.a_text);
48441 if (error != N_DATADDR(ex)) {
48442 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48443 index 86af964..5d53bf6 100644
48444 --- a/fs/binfmt_elf.c
48445 +++ b/fs/binfmt_elf.c
48446 @@ -34,6 +34,7 @@
48447 #include <linux/utsname.h>
48448 #include <linux/coredump.h>
48449 #include <linux/sched.h>
48450 +#include <linux/xattr.h>
48451 #include <asm/uaccess.h>
48452 #include <asm/param.h>
48453 #include <asm/page.h>
48454 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48455 #define elf_core_dump NULL
48456 #endif
48457
48458 +#ifdef CONFIG_PAX_MPROTECT
48459 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48460 +#endif
48461 +
48462 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48463 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48464 #else
48465 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
48466 .load_binary = load_elf_binary,
48467 .load_shlib = load_elf_library,
48468 .core_dump = elf_core_dump,
48469 +
48470 +#ifdef CONFIG_PAX_MPROTECT
48471 + .handle_mprotect= elf_handle_mprotect,
48472 +#endif
48473 +
48474 .min_coredump = ELF_EXEC_PAGESIZE,
48475 };
48476
48477 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
48478
48479 static int set_brk(unsigned long start, unsigned long end)
48480 {
48481 + unsigned long e = end;
48482 +
48483 start = ELF_PAGEALIGN(start);
48484 end = ELF_PAGEALIGN(end);
48485 if (end > start) {
48486 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
48487 if (BAD_ADDR(addr))
48488 return addr;
48489 }
48490 - current->mm->start_brk = current->mm->brk = end;
48491 + current->mm->start_brk = current->mm->brk = e;
48492 return 0;
48493 }
48494
48495 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48496 elf_addr_t __user *u_rand_bytes;
48497 const char *k_platform = ELF_PLATFORM;
48498 const char *k_base_platform = ELF_BASE_PLATFORM;
48499 - unsigned char k_rand_bytes[16];
48500 + u32 k_rand_bytes[4];
48501 int items;
48502 elf_addr_t *elf_info;
48503 int ei_index = 0;
48504 const struct cred *cred = current_cred();
48505 struct vm_area_struct *vma;
48506 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48507
48508 /*
48509 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48510 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48511 * Generate 16 random bytes for userspace PRNG seeding.
48512 */
48513 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48514 - u_rand_bytes = (elf_addr_t __user *)
48515 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48516 + srandom32(k_rand_bytes[0] ^ random32());
48517 + srandom32(k_rand_bytes[1] ^ random32());
48518 + srandom32(k_rand_bytes[2] ^ random32());
48519 + srandom32(k_rand_bytes[3] ^ random32());
48520 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48521 + u_rand_bytes = (elf_addr_t __user *) p;
48522 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48523 return -EFAULT;
48524
48525 @@ -315,9 +332,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48526 return -EFAULT;
48527 current->mm->env_end = p;
48528
48529 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48530 +
48531 /* Put the elf_info on the stack in the right place. */
48532 sp = (elf_addr_t __user *)envp + 1;
48533 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48534 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48535 return -EFAULT;
48536 return 0;
48537 }
48538 @@ -385,15 +404,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48539 an ELF header */
48540
48541 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48542 - struct file *interpreter, unsigned long *interp_map_addr,
48543 - unsigned long no_base)
48544 + struct file *interpreter, unsigned long no_base)
48545 {
48546 struct elf_phdr *elf_phdata;
48547 struct elf_phdr *eppnt;
48548 - unsigned long load_addr = 0;
48549 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48550 int load_addr_set = 0;
48551 unsigned long last_bss = 0, elf_bss = 0;
48552 - unsigned long error = ~0UL;
48553 + unsigned long error = -EINVAL;
48554 unsigned long total_size;
48555 int retval, i, size;
48556
48557 @@ -439,6 +457,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48558 goto out_close;
48559 }
48560
48561 +#ifdef CONFIG_PAX_SEGMEXEC
48562 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48563 + pax_task_size = SEGMEXEC_TASK_SIZE;
48564 +#endif
48565 +
48566 eppnt = elf_phdata;
48567 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48568 if (eppnt->p_type == PT_LOAD) {
48569 @@ -462,8 +485,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48570 map_addr = elf_map(interpreter, load_addr + vaddr,
48571 eppnt, elf_prot, elf_type, total_size);
48572 total_size = 0;
48573 - if (!*interp_map_addr)
48574 - *interp_map_addr = map_addr;
48575 error = map_addr;
48576 if (BAD_ADDR(map_addr))
48577 goto out_close;
48578 @@ -482,8 +503,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48579 k = load_addr + eppnt->p_vaddr;
48580 if (BAD_ADDR(k) ||
48581 eppnt->p_filesz > eppnt->p_memsz ||
48582 - eppnt->p_memsz > TASK_SIZE ||
48583 - TASK_SIZE - eppnt->p_memsz < k) {
48584 + eppnt->p_memsz > pax_task_size ||
48585 + pax_task_size - eppnt->p_memsz < k) {
48586 error = -ENOMEM;
48587 goto out_close;
48588 }
48589 @@ -535,6 +556,315 @@ out:
48590 return error;
48591 }
48592
48593 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48594 +#ifdef CONFIG_PAX_SOFTMODE
48595 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48596 +{
48597 + unsigned long pax_flags = 0UL;
48598 +
48599 +#ifdef CONFIG_PAX_PAGEEXEC
48600 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48601 + pax_flags |= MF_PAX_PAGEEXEC;
48602 +#endif
48603 +
48604 +#ifdef CONFIG_PAX_SEGMEXEC
48605 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48606 + pax_flags |= MF_PAX_SEGMEXEC;
48607 +#endif
48608 +
48609 +#ifdef CONFIG_PAX_EMUTRAMP
48610 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48611 + pax_flags |= MF_PAX_EMUTRAMP;
48612 +#endif
48613 +
48614 +#ifdef CONFIG_PAX_MPROTECT
48615 + if (elf_phdata->p_flags & PF_MPROTECT)
48616 + pax_flags |= MF_PAX_MPROTECT;
48617 +#endif
48618 +
48619 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48620 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48621 + pax_flags |= MF_PAX_RANDMMAP;
48622 +#endif
48623 +
48624 + return pax_flags;
48625 +}
48626 +#endif
48627 +
48628 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48629 +{
48630 + unsigned long pax_flags = 0UL;
48631 +
48632 +#ifdef CONFIG_PAX_PAGEEXEC
48633 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48634 + pax_flags |= MF_PAX_PAGEEXEC;
48635 +#endif
48636 +
48637 +#ifdef CONFIG_PAX_SEGMEXEC
48638 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48639 + pax_flags |= MF_PAX_SEGMEXEC;
48640 +#endif
48641 +
48642 +#ifdef CONFIG_PAX_EMUTRAMP
48643 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48644 + pax_flags |= MF_PAX_EMUTRAMP;
48645 +#endif
48646 +
48647 +#ifdef CONFIG_PAX_MPROTECT
48648 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48649 + pax_flags |= MF_PAX_MPROTECT;
48650 +#endif
48651 +
48652 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48653 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48654 + pax_flags |= MF_PAX_RANDMMAP;
48655 +#endif
48656 +
48657 + return pax_flags;
48658 +}
48659 +#endif
48660 +
48661 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48662 +#ifdef CONFIG_PAX_SOFTMODE
48663 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48664 +{
48665 + unsigned long pax_flags = 0UL;
48666 +
48667 +#ifdef CONFIG_PAX_PAGEEXEC
48668 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48669 + pax_flags |= MF_PAX_PAGEEXEC;
48670 +#endif
48671 +
48672 +#ifdef CONFIG_PAX_SEGMEXEC
48673 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48674 + pax_flags |= MF_PAX_SEGMEXEC;
48675 +#endif
48676 +
48677 +#ifdef CONFIG_PAX_EMUTRAMP
48678 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48679 + pax_flags |= MF_PAX_EMUTRAMP;
48680 +#endif
48681 +
48682 +#ifdef CONFIG_PAX_MPROTECT
48683 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48684 + pax_flags |= MF_PAX_MPROTECT;
48685 +#endif
48686 +
48687 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48688 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48689 + pax_flags |= MF_PAX_RANDMMAP;
48690 +#endif
48691 +
48692 + return pax_flags;
48693 +}
48694 +#endif
48695 +
48696 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48697 +{
48698 + unsigned long pax_flags = 0UL;
48699 +
48700 +#ifdef CONFIG_PAX_PAGEEXEC
48701 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48702 + pax_flags |= MF_PAX_PAGEEXEC;
48703 +#endif
48704 +
48705 +#ifdef CONFIG_PAX_SEGMEXEC
48706 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48707 + pax_flags |= MF_PAX_SEGMEXEC;
48708 +#endif
48709 +
48710 +#ifdef CONFIG_PAX_EMUTRAMP
48711 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48712 + pax_flags |= MF_PAX_EMUTRAMP;
48713 +#endif
48714 +
48715 +#ifdef CONFIG_PAX_MPROTECT
48716 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48717 + pax_flags |= MF_PAX_MPROTECT;
48718 +#endif
48719 +
48720 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48721 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48722 + pax_flags |= MF_PAX_RANDMMAP;
48723 +#endif
48724 +
48725 + return pax_flags;
48726 +}
48727 +#endif
48728 +
48729 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48730 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48731 +{
48732 + unsigned long pax_flags = 0UL;
48733 +
48734 +#ifdef CONFIG_PAX_EI_PAX
48735 +
48736 +#ifdef CONFIG_PAX_PAGEEXEC
48737 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48738 + pax_flags |= MF_PAX_PAGEEXEC;
48739 +#endif
48740 +
48741 +#ifdef CONFIG_PAX_SEGMEXEC
48742 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48743 + pax_flags |= MF_PAX_SEGMEXEC;
48744 +#endif
48745 +
48746 +#ifdef CONFIG_PAX_EMUTRAMP
48747 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48748 + pax_flags |= MF_PAX_EMUTRAMP;
48749 +#endif
48750 +
48751 +#ifdef CONFIG_PAX_MPROTECT
48752 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48753 + pax_flags |= MF_PAX_MPROTECT;
48754 +#endif
48755 +
48756 +#ifdef CONFIG_PAX_ASLR
48757 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48758 + pax_flags |= MF_PAX_RANDMMAP;
48759 +#endif
48760 +
48761 +#else
48762 +
48763 +#ifdef CONFIG_PAX_PAGEEXEC
48764 + pax_flags |= MF_PAX_PAGEEXEC;
48765 +#endif
48766 +
48767 +#ifdef CONFIG_PAX_SEGMEXEC
48768 + pax_flags |= MF_PAX_SEGMEXEC;
48769 +#endif
48770 +
48771 +#ifdef CONFIG_PAX_MPROTECT
48772 + pax_flags |= MF_PAX_MPROTECT;
48773 +#endif
48774 +
48775 +#ifdef CONFIG_PAX_RANDMMAP
48776 + if (randomize_va_space)
48777 + pax_flags |= MF_PAX_RANDMMAP;
48778 +#endif
48779 +
48780 +#endif
48781 +
48782 + return pax_flags;
48783 +}
48784 +
48785 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48786 +{
48787 +
48788 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48789 + unsigned long i;
48790 +
48791 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48792 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48793 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48794 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48795 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48796 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48797 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48798 + return ~0UL;
48799 +
48800 +#ifdef CONFIG_PAX_SOFTMODE
48801 + if (pax_softmode)
48802 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48803 + else
48804 +#endif
48805 +
48806 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48807 + break;
48808 + }
48809 +#endif
48810 +
48811 + return ~0UL;
48812 +}
48813 +
48814 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48815 +{
48816 +
48817 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48818 + ssize_t xattr_size, i;
48819 + unsigned char xattr_value[sizeof("pemrs") - 1];
48820 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48821 +
48822 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
48823 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
48824 + return ~0UL;
48825 +
48826 + for (i = 0; i < xattr_size; i++)
48827 + switch (xattr_value[i]) {
48828 + default:
48829 + return ~0UL;
48830 +
48831 +#define parse_flag(option1, option2, flag) \
48832 + case option1: \
48833 + if (pax_flags_hardmode & MF_PAX_##flag) \
48834 + return ~0UL; \
48835 + pax_flags_hardmode |= MF_PAX_##flag; \
48836 + break; \
48837 + case option2: \
48838 + if (pax_flags_softmode & MF_PAX_##flag) \
48839 + return ~0UL; \
48840 + pax_flags_softmode |= MF_PAX_##flag; \
48841 + break;
48842 +
48843 + parse_flag('p', 'P', PAGEEXEC);
48844 + parse_flag('e', 'E', EMUTRAMP);
48845 + parse_flag('m', 'M', MPROTECT);
48846 + parse_flag('r', 'R', RANDMMAP);
48847 + parse_flag('s', 'S', SEGMEXEC);
48848 +
48849 +#undef parse_flag
48850 + }
48851 +
48852 + if (pax_flags_hardmode & pax_flags_softmode)
48853 + return ~0UL;
48854 +
48855 +#ifdef CONFIG_PAX_SOFTMODE
48856 + if (pax_softmode)
48857 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48858 + else
48859 +#endif
48860 +
48861 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48862 +#else
48863 + return ~0UL;
48864 +#endif
48865 +
48866 +}
48867 +
48868 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48869 +{
48870 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48871 +
48872 + pax_flags = pax_parse_ei_pax(elf_ex);
48873 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48874 + xattr_pax_flags = pax_parse_xattr_pax(file);
48875 +
48876 + if (pt_pax_flags == ~0UL)
48877 + pt_pax_flags = xattr_pax_flags;
48878 + else if (xattr_pax_flags == ~0UL)
48879 + xattr_pax_flags = pt_pax_flags;
48880 + if (pt_pax_flags != xattr_pax_flags)
48881 + return -EINVAL;
48882 + if (pt_pax_flags != ~0UL)
48883 + pax_flags = pt_pax_flags;
48884 +
48885 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48886 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48887 + if ((__supported_pte_mask & _PAGE_NX))
48888 + pax_flags &= ~MF_PAX_SEGMEXEC;
48889 + else
48890 + pax_flags &= ~MF_PAX_PAGEEXEC;
48891 + }
48892 +#endif
48893 +
48894 + if (0 > pax_check_flags(&pax_flags))
48895 + return -EINVAL;
48896 +
48897 + current->mm->pax_flags = pax_flags;
48898 + return 0;
48899 +}
48900 +#endif
48901 +
48902 /*
48903 * These are the functions used to load ELF style executables and shared
48904 * libraries. There is no binary dependent code anywhere else.
48905 @@ -551,6 +881,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48906 {
48907 unsigned int random_variable = 0;
48908
48909 +#ifdef CONFIG_PAX_RANDUSTACK
48910 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48911 + return stack_top - current->mm->delta_stack;
48912 +#endif
48913 +
48914 if ((current->flags & PF_RANDOMIZE) &&
48915 !(current->personality & ADDR_NO_RANDOMIZE)) {
48916 random_variable = get_random_int() & STACK_RND_MASK;
48917 @@ -569,7 +904,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48918 unsigned long load_addr = 0, load_bias = 0;
48919 int load_addr_set = 0;
48920 char * elf_interpreter = NULL;
48921 - unsigned long error;
48922 + unsigned long error = 0;
48923 struct elf_phdr *elf_ppnt, *elf_phdata;
48924 unsigned long elf_bss, elf_brk;
48925 int retval, i;
48926 @@ -579,12 +914,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48927 unsigned long start_code, end_code, start_data, end_data;
48928 unsigned long reloc_func_desc __maybe_unused = 0;
48929 int executable_stack = EXSTACK_DEFAULT;
48930 - unsigned long def_flags = 0;
48931 struct pt_regs *regs = current_pt_regs();
48932 struct {
48933 struct elfhdr elf_ex;
48934 struct elfhdr interp_elf_ex;
48935 } *loc;
48936 + unsigned long pax_task_size = TASK_SIZE;
48937
48938 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48939 if (!loc) {
48940 @@ -720,11 +1055,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48941 goto out_free_dentry;
48942
48943 /* OK, This is the point of no return */
48944 - current->mm->def_flags = def_flags;
48945 +
48946 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48947 + current->mm->pax_flags = 0UL;
48948 +#endif
48949 +
48950 +#ifdef CONFIG_PAX_DLRESOLVE
48951 + current->mm->call_dl_resolve = 0UL;
48952 +#endif
48953 +
48954 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48955 + current->mm->call_syscall = 0UL;
48956 +#endif
48957 +
48958 +#ifdef CONFIG_PAX_ASLR
48959 + current->mm->delta_mmap = 0UL;
48960 + current->mm->delta_stack = 0UL;
48961 +#endif
48962 +
48963 + current->mm->def_flags = 0;
48964 +
48965 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48966 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48967 + send_sig(SIGKILL, current, 0);
48968 + goto out_free_dentry;
48969 + }
48970 +#endif
48971 +
48972 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48973 + pax_set_initial_flags(bprm);
48974 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48975 + if (pax_set_initial_flags_func)
48976 + (pax_set_initial_flags_func)(bprm);
48977 +#endif
48978 +
48979 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48980 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48981 + current->mm->context.user_cs_limit = PAGE_SIZE;
48982 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
48983 + }
48984 +#endif
48985 +
48986 +#ifdef CONFIG_PAX_SEGMEXEC
48987 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48988 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48989 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48990 + pax_task_size = SEGMEXEC_TASK_SIZE;
48991 + current->mm->def_flags |= VM_NOHUGEPAGE;
48992 + }
48993 +#endif
48994 +
48995 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48996 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48997 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48998 + put_cpu();
48999 + }
49000 +#endif
49001
49002 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49003 may depend on the personality. */
49004 SET_PERSONALITY(loc->elf_ex);
49005 +
49006 +#ifdef CONFIG_PAX_ASLR
49007 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49008 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49009 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49010 + }
49011 +#endif
49012 +
49013 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49014 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49015 + executable_stack = EXSTACK_DISABLE_X;
49016 + current->personality &= ~READ_IMPLIES_EXEC;
49017 + } else
49018 +#endif
49019 +
49020 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49021 current->personality |= READ_IMPLIES_EXEC;
49022
49023 @@ -815,6 +1220,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49024 #else
49025 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49026 #endif
49027 +
49028 +#ifdef CONFIG_PAX_RANDMMAP
49029 + /* PaX: randomize base address at the default exe base if requested */
49030 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49031 +#ifdef CONFIG_SPARC64
49032 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49033 +#else
49034 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49035 +#endif
49036 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49037 + elf_flags |= MAP_FIXED;
49038 + }
49039 +#endif
49040 +
49041 }
49042
49043 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49044 @@ -847,9 +1266,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49045 * allowed task size. Note that p_filesz must always be
49046 * <= p_memsz so it is only necessary to check p_memsz.
49047 */
49048 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49049 - elf_ppnt->p_memsz > TASK_SIZE ||
49050 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49051 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49052 + elf_ppnt->p_memsz > pax_task_size ||
49053 + pax_task_size - elf_ppnt->p_memsz < k) {
49054 /* set_brk can never work. Avoid overflows. */
49055 send_sig(SIGKILL, current, 0);
49056 retval = -EINVAL;
49057 @@ -888,17 +1307,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
49058 goto out_free_dentry;
49059 }
49060 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49061 - send_sig(SIGSEGV, current, 0);
49062 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49063 - goto out_free_dentry;
49064 + /*
49065 + * This bss-zeroing can fail if the ELF
49066 + * file specifies odd protections. So
49067 + * we don't check the return value
49068 + */
49069 }
49070
49071 +#ifdef CONFIG_PAX_RANDMMAP
49072 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49073 + unsigned long start, size, flags;
49074 + vm_flags_t vm_flags;
49075 +
49076 + start = ELF_PAGEALIGN(elf_brk);
49077 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49078 + flags = MAP_FIXED | MAP_PRIVATE;
49079 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49080 +
49081 + down_write(&current->mm->mmap_sem);
49082 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49083 + retval = -ENOMEM;
49084 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49085 +// if (current->personality & ADDR_NO_RANDOMIZE)
49086 +// vm_flags |= VM_READ | VM_MAYREAD;
49087 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
49088 + retval = IS_ERR_VALUE(start) ? start : 0;
49089 + }
49090 + up_write(&current->mm->mmap_sem);
49091 + if (retval == 0)
49092 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49093 + if (retval < 0) {
49094 + send_sig(SIGKILL, current, 0);
49095 + goto out_free_dentry;
49096 + }
49097 + }
49098 +#endif
49099 +
49100 if (elf_interpreter) {
49101 - unsigned long interp_map_addr = 0;
49102 -
49103 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49104 interpreter,
49105 - &interp_map_addr,
49106 load_bias);
49107 if (!IS_ERR((void *)elf_entry)) {
49108 /*
49109 @@ -1120,7 +1567,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49110 * Decide what to dump of a segment, part, all or none.
49111 */
49112 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49113 - unsigned long mm_flags)
49114 + unsigned long mm_flags, long signr)
49115 {
49116 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49117
49118 @@ -1158,7 +1605,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49119 if (vma->vm_file == NULL)
49120 return 0;
49121
49122 - if (FILTER(MAPPED_PRIVATE))
49123 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49124 goto whole;
49125
49126 /*
49127 @@ -1383,9 +1830,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49128 {
49129 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49130 int i = 0;
49131 - do
49132 + do {
49133 i += 2;
49134 - while (auxv[i - 2] != AT_NULL);
49135 + } while (auxv[i - 2] != AT_NULL);
49136 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49137 }
49138
49139 @@ -1394,7 +1841,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
49140 {
49141 mm_segment_t old_fs = get_fs();
49142 set_fs(KERNEL_DS);
49143 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
49144 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
49145 set_fs(old_fs);
49146 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
49147 }
49148 @@ -2015,14 +2462,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49149 }
49150
49151 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49152 - unsigned long mm_flags)
49153 + struct coredump_params *cprm)
49154 {
49155 struct vm_area_struct *vma;
49156 size_t size = 0;
49157
49158 for (vma = first_vma(current, gate_vma); vma != NULL;
49159 vma = next_vma(vma, gate_vma))
49160 - size += vma_dump_size(vma, mm_flags);
49161 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49162 return size;
49163 }
49164
49165 @@ -2116,7 +2563,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49166
49167 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49168
49169 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49170 + offset += elf_core_vma_data_size(gate_vma, cprm);
49171 offset += elf_core_extra_data_size();
49172 e_shoff = offset;
49173
49174 @@ -2130,10 +2577,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49175 offset = dataoff;
49176
49177 size += sizeof(*elf);
49178 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49179 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49180 goto end_coredump;
49181
49182 size += sizeof(*phdr4note);
49183 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49184 if (size > cprm->limit
49185 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49186 goto end_coredump;
49187 @@ -2147,7 +2596,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49188 phdr.p_offset = offset;
49189 phdr.p_vaddr = vma->vm_start;
49190 phdr.p_paddr = 0;
49191 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49192 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49193 phdr.p_memsz = vma->vm_end - vma->vm_start;
49194 offset += phdr.p_filesz;
49195 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49196 @@ -2158,6 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49197 phdr.p_align = ELF_EXEC_PAGESIZE;
49198
49199 size += sizeof(phdr);
49200 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49201 if (size > cprm->limit
49202 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49203 goto end_coredump;
49204 @@ -2182,7 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49205 unsigned long addr;
49206 unsigned long end;
49207
49208 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49209 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49210
49211 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49212 struct page *page;
49213 @@ -2191,6 +2641,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49214 page = get_dump_page(addr);
49215 if (page) {
49216 void *kaddr = kmap(page);
49217 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49218 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49219 !dump_write(cprm->file, kaddr,
49220 PAGE_SIZE);
49221 @@ -2208,6 +2659,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49222
49223 if (e_phnum == PN_XNUM) {
49224 size += sizeof(*shdr4extnum);
49225 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49226 if (size > cprm->limit
49227 || !dump_write(cprm->file, shdr4extnum,
49228 sizeof(*shdr4extnum)))
49229 @@ -2228,6 +2680,97 @@ out:
49230
49231 #endif /* CONFIG_ELF_CORE */
49232
49233 +#ifdef CONFIG_PAX_MPROTECT
49234 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49235 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49236 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49237 + *
49238 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49239 + * basis because we want to allow the common case and not the special ones.
49240 + */
49241 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49242 +{
49243 + struct elfhdr elf_h;
49244 + struct elf_phdr elf_p;
49245 + unsigned long i;
49246 + unsigned long oldflags;
49247 + bool is_textrel_rw, is_textrel_rx, is_relro;
49248 +
49249 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49250 + return;
49251 +
49252 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49253 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49254 +
49255 +#ifdef CONFIG_PAX_ELFRELOCS
49256 + /* possible TEXTREL */
49257 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49258 + 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);
49259 +#else
49260 + is_textrel_rw = false;
49261 + is_textrel_rx = false;
49262 +#endif
49263 +
49264 + /* possible RELRO */
49265 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49266 +
49267 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49268 + return;
49269 +
49270 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49271 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49272 +
49273 +#ifdef CONFIG_PAX_ETEXECRELOCS
49274 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49275 +#else
49276 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49277 +#endif
49278 +
49279 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49280 + !elf_check_arch(&elf_h) ||
49281 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49282 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49283 + return;
49284 +
49285 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49286 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49287 + return;
49288 + switch (elf_p.p_type) {
49289 + case PT_DYNAMIC:
49290 + if (!is_textrel_rw && !is_textrel_rx)
49291 + continue;
49292 + i = 0UL;
49293 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49294 + elf_dyn dyn;
49295 +
49296 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49297 + return;
49298 + if (dyn.d_tag == DT_NULL)
49299 + return;
49300 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49301 + gr_log_textrel(vma);
49302 + if (is_textrel_rw)
49303 + vma->vm_flags |= VM_MAYWRITE;
49304 + else
49305 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49306 + vma->vm_flags &= ~VM_MAYWRITE;
49307 + return;
49308 + }
49309 + i++;
49310 + }
49311 + return;
49312 +
49313 + case PT_GNU_RELRO:
49314 + if (!is_relro)
49315 + continue;
49316 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49317 + vma->vm_flags &= ~VM_MAYWRITE;
49318 + return;
49319 + }
49320 + }
49321 +}
49322 +#endif
49323 +
49324 static int __init init_elf_binfmt(void)
49325 {
49326 register_binfmt(&elf_format);
49327 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49328 index 2036d21..b0430d0 100644
49329 --- a/fs/binfmt_flat.c
49330 +++ b/fs/binfmt_flat.c
49331 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49332 realdatastart = (unsigned long) -ENOMEM;
49333 printk("Unable to allocate RAM for process data, errno %d\n",
49334 (int)-realdatastart);
49335 + down_write(&current->mm->mmap_sem);
49336 vm_munmap(textpos, text_len);
49337 + up_write(&current->mm->mmap_sem);
49338 ret = realdatastart;
49339 goto err;
49340 }
49341 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49342 }
49343 if (IS_ERR_VALUE(result)) {
49344 printk("Unable to read data+bss, errno %d\n", (int)-result);
49345 + down_write(&current->mm->mmap_sem);
49346 vm_munmap(textpos, text_len);
49347 vm_munmap(realdatastart, len);
49348 + up_write(&current->mm->mmap_sem);
49349 ret = result;
49350 goto err;
49351 }
49352 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49353 }
49354 if (IS_ERR_VALUE(result)) {
49355 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49356 + down_write(&current->mm->mmap_sem);
49357 vm_munmap(textpos, text_len + data_len + extra +
49358 MAX_SHARED_LIBS * sizeof(unsigned long));
49359 + up_write(&current->mm->mmap_sem);
49360 ret = result;
49361 goto err;
49362 }
49363 diff --git a/fs/bio.c b/fs/bio.c
49364 index b96fc6c..431d628 100644
49365 --- a/fs/bio.c
49366 +++ b/fs/bio.c
49367 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49368 /*
49369 * Overflow, abort
49370 */
49371 - if (end < start)
49372 + if (end < start || end - start > INT_MAX - nr_pages)
49373 return ERR_PTR(-EINVAL);
49374
49375 nr_pages += end - start;
49376 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49377 /*
49378 * Overflow, abort
49379 */
49380 - if (end < start)
49381 + if (end < start || end - start > INT_MAX - nr_pages)
49382 return ERR_PTR(-EINVAL);
49383
49384 nr_pages += end - start;
49385 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49386 const int read = bio_data_dir(bio) == READ;
49387 struct bio_map_data *bmd = bio->bi_private;
49388 int i;
49389 - char *p = bmd->sgvecs[0].iov_base;
49390 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49391
49392 __bio_for_each_segment(bvec, bio, i, 0) {
49393 char *addr = page_address(bvec->bv_page);
49394 diff --git a/fs/block_dev.c b/fs/block_dev.c
49395 index aae187a..fd790ba 100644
49396 --- a/fs/block_dev.c
49397 +++ b/fs/block_dev.c
49398 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49399 else if (bdev->bd_contains == bdev)
49400 return true; /* is a whole device which isn't held */
49401
49402 - else if (whole->bd_holder == bd_may_claim)
49403 + else if (whole->bd_holder == (void *)bd_may_claim)
49404 return true; /* is a partition of a device that is being partitioned */
49405 else if (whole->bd_holder != NULL)
49406 return false; /* is a partition of a held device */
49407 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49408 index ca9d8f1..8c0142d 100644
49409 --- a/fs/btrfs/ctree.c
49410 +++ b/fs/btrfs/ctree.c
49411 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49412 free_extent_buffer(buf);
49413 add_root_to_dirty_list(root);
49414 } else {
49415 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49416 - parent_start = parent->start;
49417 - else
49418 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49419 + if (parent)
49420 + parent_start = parent->start;
49421 + else
49422 + parent_start = 0;
49423 + } else
49424 parent_start = 0;
49425
49426 WARN_ON(trans->transid != btrfs_header_generation(parent));
49427 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49428 index f49b62f..07834ab 100644
49429 --- a/fs/btrfs/ioctl.c
49430 +++ b/fs/btrfs/ioctl.c
49431 @@ -3077,9 +3077,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49432 for (i = 0; i < num_types; i++) {
49433 struct btrfs_space_info *tmp;
49434
49435 + /* Don't copy in more than we allocated */
49436 if (!slot_count)
49437 break;
49438
49439 + slot_count--;
49440 +
49441 info = NULL;
49442 rcu_read_lock();
49443 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49444 @@ -3101,10 +3104,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49445 memcpy(dest, &space, sizeof(space));
49446 dest++;
49447 space_args.total_spaces++;
49448 - slot_count--;
49449 }
49450 - if (!slot_count)
49451 - break;
49452 }
49453 up_read(&info->groups_sem);
49454 }
49455 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49456 index f6b8859..54fe8c5 100644
49457 --- a/fs/btrfs/super.c
49458 +++ b/fs/btrfs/super.c
49459 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49460 function, line, errstr);
49461 return;
49462 }
49463 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49464 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49465 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49466 }
49467 /*
49468 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49469 index 622f469..e8d2d55 100644
49470 --- a/fs/cachefiles/bind.c
49471 +++ b/fs/cachefiles/bind.c
49472 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49473 args);
49474
49475 /* start by checking things over */
49476 - ASSERT(cache->fstop_percent >= 0 &&
49477 - cache->fstop_percent < cache->fcull_percent &&
49478 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49479 cache->fcull_percent < cache->frun_percent &&
49480 cache->frun_percent < 100);
49481
49482 - ASSERT(cache->bstop_percent >= 0 &&
49483 - cache->bstop_percent < cache->bcull_percent &&
49484 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49485 cache->bcull_percent < cache->brun_percent &&
49486 cache->brun_percent < 100);
49487
49488 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49489 index 0a1467b..6a53245 100644
49490 --- a/fs/cachefiles/daemon.c
49491 +++ b/fs/cachefiles/daemon.c
49492 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49493 if (n > buflen)
49494 return -EMSGSIZE;
49495
49496 - if (copy_to_user(_buffer, buffer, n) != 0)
49497 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49498 return -EFAULT;
49499
49500 return n;
49501 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49502 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49503 return -EIO;
49504
49505 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49506 + if (datalen > PAGE_SIZE - 1)
49507 return -EOPNOTSUPP;
49508
49509 /* drag the command string into the kernel so we can parse it */
49510 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49511 if (args[0] != '%' || args[1] != '\0')
49512 return -EINVAL;
49513
49514 - if (fstop < 0 || fstop >= cache->fcull_percent)
49515 + if (fstop >= cache->fcull_percent)
49516 return cachefiles_daemon_range_error(cache, args);
49517
49518 cache->fstop_percent = fstop;
49519 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49520 if (args[0] != '%' || args[1] != '\0')
49521 return -EINVAL;
49522
49523 - if (bstop < 0 || bstop >= cache->bcull_percent)
49524 + if (bstop >= cache->bcull_percent)
49525 return cachefiles_daemon_range_error(cache, args);
49526
49527 cache->bstop_percent = bstop;
49528 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49529 index 4938251..7e01445 100644
49530 --- a/fs/cachefiles/internal.h
49531 +++ b/fs/cachefiles/internal.h
49532 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49533 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49534 struct rb_root active_nodes; /* active nodes (can't be culled) */
49535 rwlock_t active_lock; /* lock for active_nodes */
49536 - atomic_t gravecounter; /* graveyard uniquifier */
49537 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49538 unsigned frun_percent; /* when to stop culling (% files) */
49539 unsigned fcull_percent; /* when to start culling (% files) */
49540 unsigned fstop_percent; /* when to stop allocating (% files) */
49541 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49542 * proc.c
49543 */
49544 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49545 -extern atomic_t cachefiles_lookup_histogram[HZ];
49546 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49547 -extern atomic_t cachefiles_create_histogram[HZ];
49548 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49549 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49550 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49551
49552 extern int __init cachefiles_proc_init(void);
49553 extern void cachefiles_proc_cleanup(void);
49554 static inline
49555 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49556 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49557 {
49558 unsigned long jif = jiffies - start_jif;
49559 if (jif >= HZ)
49560 jif = HZ - 1;
49561 - atomic_inc(&histogram[jif]);
49562 + atomic_inc_unchecked(&histogram[jif]);
49563 }
49564
49565 #else
49566 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49567 index 8c01c5fc..15f982e 100644
49568 --- a/fs/cachefiles/namei.c
49569 +++ b/fs/cachefiles/namei.c
49570 @@ -317,7 +317,7 @@ try_again:
49571 /* first step is to make up a grave dentry in the graveyard */
49572 sprintf(nbuffer, "%08x%08x",
49573 (uint32_t) get_seconds(),
49574 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49575 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49576
49577 /* do the multiway lock magic */
49578 trap = lock_rename(cache->graveyard, dir);
49579 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49580 index eccd339..4c1d995 100644
49581 --- a/fs/cachefiles/proc.c
49582 +++ b/fs/cachefiles/proc.c
49583 @@ -14,9 +14,9 @@
49584 #include <linux/seq_file.h>
49585 #include "internal.h"
49586
49587 -atomic_t cachefiles_lookup_histogram[HZ];
49588 -atomic_t cachefiles_mkdir_histogram[HZ];
49589 -atomic_t cachefiles_create_histogram[HZ];
49590 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49591 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49592 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49593
49594 /*
49595 * display the latency histogram
49596 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49597 return 0;
49598 default:
49599 index = (unsigned long) v - 3;
49600 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49601 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49602 - z = atomic_read(&cachefiles_create_histogram[index]);
49603 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49604 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49605 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49606 if (x == 0 && y == 0 && z == 0)
49607 return 0;
49608
49609 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49610 index 4809922..aab2c39 100644
49611 --- a/fs/cachefiles/rdwr.c
49612 +++ b/fs/cachefiles/rdwr.c
49613 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49614 old_fs = get_fs();
49615 set_fs(KERNEL_DS);
49616 ret = file->f_op->write(
49617 - file, (const void __user *) data, len, &pos);
49618 + file, (const void __force_user *) data, len, &pos);
49619 set_fs(old_fs);
49620 kunmap(page);
49621 if (ret != len)
49622 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49623 index 6d797f4..0ace2e5 100644
49624 --- a/fs/ceph/dir.c
49625 +++ b/fs/ceph/dir.c
49626 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49627 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49628 struct ceph_mds_client *mdsc = fsc->mdsc;
49629 unsigned frag = fpos_frag(filp->f_pos);
49630 - int off = fpos_off(filp->f_pos);
49631 + unsigned int off = fpos_off(filp->f_pos);
49632 int err;
49633 u32 ftype;
49634 struct ceph_mds_reply_info_parsed *rinfo;
49635 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49636 index d9ea6ed..1e6c8ac 100644
49637 --- a/fs/cifs/cifs_debug.c
49638 +++ b/fs/cifs/cifs_debug.c
49639 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49640
49641 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49642 #ifdef CONFIG_CIFS_STATS2
49643 - atomic_set(&totBufAllocCount, 0);
49644 - atomic_set(&totSmBufAllocCount, 0);
49645 + atomic_set_unchecked(&totBufAllocCount, 0);
49646 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49647 #endif /* CONFIG_CIFS_STATS2 */
49648 spin_lock(&cifs_tcp_ses_lock);
49649 list_for_each(tmp1, &cifs_tcp_ses_list) {
49650 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49651 tcon = list_entry(tmp3,
49652 struct cifs_tcon,
49653 tcon_list);
49654 - atomic_set(&tcon->num_smbs_sent, 0);
49655 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49656 if (server->ops->clear_stats)
49657 server->ops->clear_stats(tcon);
49658 }
49659 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49660 smBufAllocCount.counter, cifs_min_small);
49661 #ifdef CONFIG_CIFS_STATS2
49662 seq_printf(m, "Total Large %d Small %d Allocations\n",
49663 - atomic_read(&totBufAllocCount),
49664 - atomic_read(&totSmBufAllocCount));
49665 + atomic_read_unchecked(&totBufAllocCount),
49666 + atomic_read_unchecked(&totSmBufAllocCount));
49667 #endif /* CONFIG_CIFS_STATS2 */
49668
49669 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49670 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49671 if (tcon->need_reconnect)
49672 seq_puts(m, "\tDISCONNECTED ");
49673 seq_printf(m, "\nSMBs: %d",
49674 - atomic_read(&tcon->num_smbs_sent));
49675 + atomic_read_unchecked(&tcon->num_smbs_sent));
49676 if (server->ops->print_stats)
49677 server->ops->print_stats(m, tcon);
49678 }
49679 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49680 index 345fc89..b2acae5 100644
49681 --- a/fs/cifs/cifsfs.c
49682 +++ b/fs/cifs/cifsfs.c
49683 @@ -1033,7 +1033,7 @@ cifs_init_request_bufs(void)
49684 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49685 cifs_req_cachep = kmem_cache_create("cifs_request",
49686 CIFSMaxBufSize + max_hdr_size, 0,
49687 - SLAB_HWCACHE_ALIGN, NULL);
49688 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49689 if (cifs_req_cachep == NULL)
49690 return -ENOMEM;
49691
49692 @@ -1060,7 +1060,7 @@ cifs_init_request_bufs(void)
49693 efficient to alloc 1 per page off the slab compared to 17K (5page)
49694 alloc of large cifs buffers even when page debugging is on */
49695 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49696 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49697 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49698 NULL);
49699 if (cifs_sm_req_cachep == NULL) {
49700 mempool_destroy(cifs_req_poolp);
49701 @@ -1145,8 +1145,8 @@ init_cifs(void)
49702 atomic_set(&bufAllocCount, 0);
49703 atomic_set(&smBufAllocCount, 0);
49704 #ifdef CONFIG_CIFS_STATS2
49705 - atomic_set(&totBufAllocCount, 0);
49706 - atomic_set(&totSmBufAllocCount, 0);
49707 + atomic_set_unchecked(&totBufAllocCount, 0);
49708 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49709 #endif /* CONFIG_CIFS_STATS2 */
49710
49711 atomic_set(&midCount, 0);
49712 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49713 index 4f07f6f..55de8ce 100644
49714 --- a/fs/cifs/cifsglob.h
49715 +++ b/fs/cifs/cifsglob.h
49716 @@ -751,35 +751,35 @@ struct cifs_tcon {
49717 __u16 Flags; /* optional support bits */
49718 enum statusEnum tidStatus;
49719 #ifdef CONFIG_CIFS_STATS
49720 - atomic_t num_smbs_sent;
49721 + atomic_unchecked_t num_smbs_sent;
49722 union {
49723 struct {
49724 - atomic_t num_writes;
49725 - atomic_t num_reads;
49726 - atomic_t num_flushes;
49727 - atomic_t num_oplock_brks;
49728 - atomic_t num_opens;
49729 - atomic_t num_closes;
49730 - atomic_t num_deletes;
49731 - atomic_t num_mkdirs;
49732 - atomic_t num_posixopens;
49733 - atomic_t num_posixmkdirs;
49734 - atomic_t num_rmdirs;
49735 - atomic_t num_renames;
49736 - atomic_t num_t2renames;
49737 - atomic_t num_ffirst;
49738 - atomic_t num_fnext;
49739 - atomic_t num_fclose;
49740 - atomic_t num_hardlinks;
49741 - atomic_t num_symlinks;
49742 - atomic_t num_locks;
49743 - atomic_t num_acl_get;
49744 - atomic_t num_acl_set;
49745 + atomic_unchecked_t num_writes;
49746 + atomic_unchecked_t num_reads;
49747 + atomic_unchecked_t num_flushes;
49748 + atomic_unchecked_t num_oplock_brks;
49749 + atomic_unchecked_t num_opens;
49750 + atomic_unchecked_t num_closes;
49751 + atomic_unchecked_t num_deletes;
49752 + atomic_unchecked_t num_mkdirs;
49753 + atomic_unchecked_t num_posixopens;
49754 + atomic_unchecked_t num_posixmkdirs;
49755 + atomic_unchecked_t num_rmdirs;
49756 + atomic_unchecked_t num_renames;
49757 + atomic_unchecked_t num_t2renames;
49758 + atomic_unchecked_t num_ffirst;
49759 + atomic_unchecked_t num_fnext;
49760 + atomic_unchecked_t num_fclose;
49761 + atomic_unchecked_t num_hardlinks;
49762 + atomic_unchecked_t num_symlinks;
49763 + atomic_unchecked_t num_locks;
49764 + atomic_unchecked_t num_acl_get;
49765 + atomic_unchecked_t num_acl_set;
49766 } cifs_stats;
49767 #ifdef CONFIG_CIFS_SMB2
49768 struct {
49769 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49770 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49771 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49772 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49773 } smb2_stats;
49774 #endif /* CONFIG_CIFS_SMB2 */
49775 } stats;
49776 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49777 }
49778
49779 #ifdef CONFIG_CIFS_STATS
49780 -#define cifs_stats_inc atomic_inc
49781 +#define cifs_stats_inc atomic_inc_unchecked
49782
49783 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49784 unsigned int bytes)
49785 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49786 /* Various Debug counters */
49787 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49788 #ifdef CONFIG_CIFS_STATS2
49789 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49790 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49791 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49792 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49793 #endif
49794 GLOBAL_EXTERN atomic_t smBufAllocCount;
49795 GLOBAL_EXTERN atomic_t midCount;
49796 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49797 index 9f6c4c4..8de307a 100644
49798 --- a/fs/cifs/link.c
49799 +++ b/fs/cifs/link.c
49800 @@ -616,7 +616,7 @@ symlink_exit:
49801
49802 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49803 {
49804 - char *p = nd_get_link(nd);
49805 + const char *p = nd_get_link(nd);
49806 if (!IS_ERR(p))
49807 kfree(p);
49808 }
49809 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49810 index 1b15bf8..1ce489e 100644
49811 --- a/fs/cifs/misc.c
49812 +++ b/fs/cifs/misc.c
49813 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49814 memset(ret_buf, 0, buf_size + 3);
49815 atomic_inc(&bufAllocCount);
49816 #ifdef CONFIG_CIFS_STATS2
49817 - atomic_inc(&totBufAllocCount);
49818 + atomic_inc_unchecked(&totBufAllocCount);
49819 #endif /* CONFIG_CIFS_STATS2 */
49820 }
49821
49822 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49823 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49824 atomic_inc(&smBufAllocCount);
49825 #ifdef CONFIG_CIFS_STATS2
49826 - atomic_inc(&totSmBufAllocCount);
49827 + atomic_inc_unchecked(&totSmBufAllocCount);
49828 #endif /* CONFIG_CIFS_STATS2 */
49829
49830 }
49831 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49832 index 47bc5a8..10decbe 100644
49833 --- a/fs/cifs/smb1ops.c
49834 +++ b/fs/cifs/smb1ops.c
49835 @@ -586,27 +586,27 @@ static void
49836 cifs_clear_stats(struct cifs_tcon *tcon)
49837 {
49838 #ifdef CONFIG_CIFS_STATS
49839 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49840 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49841 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49842 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49843 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49844 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49845 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49846 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49847 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49848 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49849 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49850 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49851 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49852 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49853 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49854 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49855 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49856 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49857 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49858 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49859 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49860 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49861 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49862 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49863 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49864 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49865 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49866 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49867 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49868 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49869 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49870 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49871 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49872 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49873 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49874 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49875 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49876 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49877 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49878 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49879 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49880 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49881 #endif
49882 }
49883
49884 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49885 {
49886 #ifdef CONFIG_CIFS_STATS
49887 seq_printf(m, " Oplocks breaks: %d",
49888 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49889 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49890 seq_printf(m, "\nReads: %d Bytes: %llu",
49891 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49892 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49893 (long long)(tcon->bytes_read));
49894 seq_printf(m, "\nWrites: %d Bytes: %llu",
49895 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49896 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49897 (long long)(tcon->bytes_written));
49898 seq_printf(m, "\nFlushes: %d",
49899 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49900 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49901 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49902 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49903 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49904 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49905 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49906 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49907 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49908 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49909 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49910 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49911 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49912 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49913 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49914 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49915 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49916 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49917 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49918 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49919 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49920 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49921 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49922 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49923 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49924 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49925 seq_printf(m, "\nRenames: %d T2 Renames %d",
49926 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49927 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49928 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49929 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49930 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49931 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49932 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49933 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49934 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49935 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49936 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49937 #endif
49938 }
49939
49940 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49941 index bceffe7..cd1ae59 100644
49942 --- a/fs/cifs/smb2ops.c
49943 +++ b/fs/cifs/smb2ops.c
49944 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49945 #ifdef CONFIG_CIFS_STATS
49946 int i;
49947 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49948 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49949 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49950 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49951 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49952 }
49953 #endif
49954 }
49955 @@ -284,66 +284,66 @@ static void
49956 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49957 {
49958 #ifdef CONFIG_CIFS_STATS
49959 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49960 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49961 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49962 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49963 seq_printf(m, "\nNegotiates: %d sent %d failed",
49964 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49965 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49966 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49967 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49968 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49969 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49970 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49971 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49972 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49973 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49974 seq_printf(m, "\nLogoffs: %d sent %d failed",
49975 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49976 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49977 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49978 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49979 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49980 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49981 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49982 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49983 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49984 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49985 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49986 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49987 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49988 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49989 seq_printf(m, "\nCreates: %d sent %d failed",
49990 - atomic_read(&sent[SMB2_CREATE_HE]),
49991 - atomic_read(&failed[SMB2_CREATE_HE]));
49992 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49993 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49994 seq_printf(m, "\nCloses: %d sent %d failed",
49995 - atomic_read(&sent[SMB2_CLOSE_HE]),
49996 - atomic_read(&failed[SMB2_CLOSE_HE]));
49997 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49998 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49999 seq_printf(m, "\nFlushes: %d sent %d failed",
50000 - atomic_read(&sent[SMB2_FLUSH_HE]),
50001 - atomic_read(&failed[SMB2_FLUSH_HE]));
50002 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50003 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50004 seq_printf(m, "\nReads: %d sent %d failed",
50005 - atomic_read(&sent[SMB2_READ_HE]),
50006 - atomic_read(&failed[SMB2_READ_HE]));
50007 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50008 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50009 seq_printf(m, "\nWrites: %d sent %d failed",
50010 - atomic_read(&sent[SMB2_WRITE_HE]),
50011 - atomic_read(&failed[SMB2_WRITE_HE]));
50012 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50013 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50014 seq_printf(m, "\nLocks: %d sent %d failed",
50015 - atomic_read(&sent[SMB2_LOCK_HE]),
50016 - atomic_read(&failed[SMB2_LOCK_HE]));
50017 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50018 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50019 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50020 - atomic_read(&sent[SMB2_IOCTL_HE]),
50021 - atomic_read(&failed[SMB2_IOCTL_HE]));
50022 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50023 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50024 seq_printf(m, "\nCancels: %d sent %d failed",
50025 - atomic_read(&sent[SMB2_CANCEL_HE]),
50026 - atomic_read(&failed[SMB2_CANCEL_HE]));
50027 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50028 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50029 seq_printf(m, "\nEchos: %d sent %d failed",
50030 - atomic_read(&sent[SMB2_ECHO_HE]),
50031 - atomic_read(&failed[SMB2_ECHO_HE]));
50032 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50033 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50034 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50035 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50036 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50037 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50038 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50039 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50040 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50041 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50042 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50043 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50044 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50045 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50046 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50047 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50048 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50049 seq_printf(m, "\nSetInfos: %d sent %d failed",
50050 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50051 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50052 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50053 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50054 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50055 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50056 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50057 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50058 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50059 #endif
50060 }
50061
50062 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50063 index 41d9d07..dbb4772 100644
50064 --- a/fs/cifs/smb2pdu.c
50065 +++ b/fs/cifs/smb2pdu.c
50066 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50067 default:
50068 cERROR(1, "info level %u isn't supported",
50069 srch_inf->info_level);
50070 - rc = -EINVAL;
50071 - goto qdir_exit;
50072 + return -EINVAL;
50073 }
50074
50075 req->FileIndex = cpu_to_le32(index);
50076 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50077 index 1da168c..8bc7ff6 100644
50078 --- a/fs/coda/cache.c
50079 +++ b/fs/coda/cache.c
50080 @@ -24,7 +24,7 @@
50081 #include "coda_linux.h"
50082 #include "coda_cache.h"
50083
50084 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50085 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50086
50087 /* replace or extend an acl cache hit */
50088 void coda_cache_enter(struct inode *inode, int mask)
50089 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50090 struct coda_inode_info *cii = ITOC(inode);
50091
50092 spin_lock(&cii->c_lock);
50093 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50094 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50095 if (!uid_eq(cii->c_uid, current_fsuid())) {
50096 cii->c_uid = current_fsuid();
50097 cii->c_cached_perm = mask;
50098 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50099 {
50100 struct coda_inode_info *cii = ITOC(inode);
50101 spin_lock(&cii->c_lock);
50102 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50103 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50104 spin_unlock(&cii->c_lock);
50105 }
50106
50107 /* remove all acl caches */
50108 void coda_cache_clear_all(struct super_block *sb)
50109 {
50110 - atomic_inc(&permission_epoch);
50111 + atomic_inc_unchecked(&permission_epoch);
50112 }
50113
50114
50115 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50116 spin_lock(&cii->c_lock);
50117 hit = (mask & cii->c_cached_perm) == mask &&
50118 uid_eq(cii->c_uid, current_fsuid()) &&
50119 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50120 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50121 spin_unlock(&cii->c_lock);
50122
50123 return hit;
50124 diff --git a/fs/compat.c b/fs/compat.c
50125 index d487985..c9e04b1 100644
50126 --- a/fs/compat.c
50127 +++ b/fs/compat.c
50128 @@ -54,7 +54,7 @@
50129 #include <asm/ioctls.h>
50130 #include "internal.h"
50131
50132 -int compat_log = 1;
50133 +int compat_log = 0;
50134
50135 int compat_printk(const char *fmt, ...)
50136 {
50137 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50138
50139 set_fs(KERNEL_DS);
50140 /* The __user pointer cast is valid because of the set_fs() */
50141 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50142 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50143 set_fs(oldfs);
50144 /* truncating is ok because it's a user address */
50145 if (!ret)
50146 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50147 goto out;
50148
50149 ret = -EINVAL;
50150 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50151 + if (nr_segs > UIO_MAXIOV)
50152 goto out;
50153 if (nr_segs > fast_segs) {
50154 ret = -ENOMEM;
50155 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50156
50157 struct compat_readdir_callback {
50158 struct compat_old_linux_dirent __user *dirent;
50159 + struct file * file;
50160 int result;
50161 };
50162
50163 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50164 buf->result = -EOVERFLOW;
50165 return -EOVERFLOW;
50166 }
50167 +
50168 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50169 + return 0;
50170 +
50171 buf->result++;
50172 dirent = buf->dirent;
50173 if (!access_ok(VERIFY_WRITE, dirent,
50174 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50175
50176 buf.result = 0;
50177 buf.dirent = dirent;
50178 + buf.file = f.file;
50179
50180 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50181 if (buf.result)
50182 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50183 struct compat_getdents_callback {
50184 struct compat_linux_dirent __user *current_dir;
50185 struct compat_linux_dirent __user *previous;
50186 + struct file * file;
50187 int count;
50188 int error;
50189 };
50190 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50191 buf->error = -EOVERFLOW;
50192 return -EOVERFLOW;
50193 }
50194 +
50195 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50196 + return 0;
50197 +
50198 dirent = buf->previous;
50199 if (dirent) {
50200 if (__put_user(offset, &dirent->d_off))
50201 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50202 buf.previous = NULL;
50203 buf.count = count;
50204 buf.error = 0;
50205 + buf.file = f.file;
50206
50207 error = vfs_readdir(f.file, compat_filldir, &buf);
50208 if (error >= 0)
50209 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50210 struct compat_getdents_callback64 {
50211 struct linux_dirent64 __user *current_dir;
50212 struct linux_dirent64 __user *previous;
50213 + struct file * file;
50214 int count;
50215 int error;
50216 };
50217 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50218 buf->error = -EINVAL; /* only used if we fail.. */
50219 if (reclen > buf->count)
50220 return -EINVAL;
50221 +
50222 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50223 + return 0;
50224 +
50225 dirent = buf->previous;
50226
50227 if (dirent) {
50228 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50229 buf.previous = NULL;
50230 buf.count = count;
50231 buf.error = 0;
50232 + buf.file = f.file;
50233
50234 error = vfs_readdir(f.file, compat_filldir64, &buf);
50235 if (error >= 0)
50236 error = buf.error;
50237 lastdirent = buf.previous;
50238 if (lastdirent) {
50239 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50240 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50241 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50242 error = -EFAULT;
50243 else
50244 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50245 index a81147e..20bf2b5 100644
50246 --- a/fs/compat_binfmt_elf.c
50247 +++ b/fs/compat_binfmt_elf.c
50248 @@ -30,11 +30,13 @@
50249 #undef elf_phdr
50250 #undef elf_shdr
50251 #undef elf_note
50252 +#undef elf_dyn
50253 #undef elf_addr_t
50254 #define elfhdr elf32_hdr
50255 #define elf_phdr elf32_phdr
50256 #define elf_shdr elf32_shdr
50257 #define elf_note elf32_note
50258 +#define elf_dyn Elf32_Dyn
50259 #define elf_addr_t Elf32_Addr
50260
50261 /*
50262 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50263 index 3ced75f..b28d192 100644
50264 --- a/fs/compat_ioctl.c
50265 +++ b/fs/compat_ioctl.c
50266 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50267 return -EFAULT;
50268 if (__get_user(udata, &ss32->iomem_base))
50269 return -EFAULT;
50270 - ss.iomem_base = compat_ptr(udata);
50271 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50272 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50273 __get_user(ss.port_high, &ss32->port_high))
50274 return -EFAULT;
50275 @@ -704,8 +704,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
50276 for (i = 0; i < nmsgs; i++) {
50277 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
50278 return -EFAULT;
50279 - if (get_user(datap, &umsgs[i].buf) ||
50280 - put_user(compat_ptr(datap), &tmsgs[i].buf))
50281 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
50282 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
50283 return -EFAULT;
50284 }
50285 return sys_ioctl(fd, cmd, (unsigned long)tdata);
50286 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50287 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50288 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50289 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50290 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50291 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50292 return -EFAULT;
50293
50294 return ioctl_preallocate(file, p);
50295 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50296 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50297 {
50298 unsigned int a, b;
50299 - a = *(unsigned int *)p;
50300 - b = *(unsigned int *)q;
50301 + a = *(const unsigned int *)p;
50302 + b = *(const unsigned int *)q;
50303 if (a > b)
50304 return 1;
50305 if (a < b)
50306 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50307 index 7aabc6a..34c1197 100644
50308 --- a/fs/configfs/dir.c
50309 +++ b/fs/configfs/dir.c
50310 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50311 }
50312 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50313 struct configfs_dirent *next;
50314 - const char * name;
50315 + const unsigned char * name;
50316 + char d_name[sizeof(next->s_dentry->d_iname)];
50317 int len;
50318 struct inode *inode = NULL;
50319
50320 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50321 continue;
50322
50323 name = configfs_get_name(next);
50324 - len = strlen(name);
50325 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50326 + len = next->s_dentry->d_name.len;
50327 + memcpy(d_name, name, len);
50328 + name = d_name;
50329 + } else
50330 + len = strlen(name);
50331
50332 /*
50333 * We'll have a dentry and an inode for
50334 diff --git a/fs/coredump.c b/fs/coredump.c
50335 index c647965..a77bff3 100644
50336 --- a/fs/coredump.c
50337 +++ b/fs/coredump.c
50338 @@ -52,7 +52,7 @@ struct core_name {
50339 char *corename;
50340 int used, size;
50341 };
50342 -static atomic_t call_count = ATOMIC_INIT(1);
50343 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50344
50345 /* The maximal length of core_pattern is also specified in sysctl.c */
50346
50347 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50348 {
50349 char *old_corename = cn->corename;
50350
50351 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50352 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50353 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50354
50355 if (!cn->corename) {
50356 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50357 int pid_in_pattern = 0;
50358 int err = 0;
50359
50360 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50361 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50362 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50363 cn->used = 0;
50364
50365 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50366 pipe = file_inode(file)->i_pipe;
50367
50368 pipe_lock(pipe);
50369 - pipe->readers++;
50370 - pipe->writers--;
50371 + atomic_inc(&pipe->readers);
50372 + atomic_dec(&pipe->writers);
50373
50374 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50375 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50376 wake_up_interruptible_sync(&pipe->wait);
50377 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50378 pipe_wait(pipe);
50379 }
50380
50381 - pipe->readers--;
50382 - pipe->writers++;
50383 + atomic_dec(&pipe->readers);
50384 + atomic_inc(&pipe->writers);
50385 pipe_unlock(pipe);
50386
50387 }
50388 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50389 int ispipe;
50390 struct files_struct *displaced;
50391 bool need_nonrelative = false;
50392 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50393 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50394 + long signr = siginfo->si_signo;
50395 struct coredump_params cprm = {
50396 .siginfo = siginfo,
50397 .regs = signal_pt_regs(),
50398 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50399 .mm_flags = mm->flags,
50400 };
50401
50402 - audit_core_dumps(siginfo->si_signo);
50403 + audit_core_dumps(signr);
50404 +
50405 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50406 + gr_handle_brute_attach(cprm.mm_flags);
50407
50408 binfmt = mm->binfmt;
50409 if (!binfmt || !binfmt->core_dump)
50410 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50411 need_nonrelative = true;
50412 }
50413
50414 - retval = coredump_wait(siginfo->si_signo, &core_state);
50415 + retval = coredump_wait(signr, &core_state);
50416 if (retval < 0)
50417 goto fail_creds;
50418
50419 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50420 }
50421 cprm.limit = RLIM_INFINITY;
50422
50423 - dump_count = atomic_inc_return(&core_dump_count);
50424 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50425 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50426 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50427 task_tgid_vnr(current), current->comm);
50428 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50429 } else {
50430 struct inode *inode;
50431
50432 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50433 +
50434 if (cprm.limit < binfmt->min_coredump)
50435 goto fail_unlock;
50436
50437 @@ -640,7 +646,7 @@ close_fail:
50438 filp_close(cprm.file, NULL);
50439 fail_dropcount:
50440 if (ispipe)
50441 - atomic_dec(&core_dump_count);
50442 + atomic_dec_unchecked(&core_dump_count);
50443 fail_unlock:
50444 kfree(cn.corename);
50445 fail_corename:
50446 @@ -659,7 +665,7 @@ fail:
50447 */
50448 int dump_write(struct file *file, const void *addr, int nr)
50449 {
50450 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50451 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50452 }
50453 EXPORT_SYMBOL(dump_write);
50454
50455 diff --git a/fs/dcache.c b/fs/dcache.c
50456 index e689268..f36956e 100644
50457 --- a/fs/dcache.c
50458 +++ b/fs/dcache.c
50459 @@ -3100,7 +3100,7 @@ void __init vfs_caches_init(unsigned long mempages)
50460 mempages -= reserve;
50461
50462 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50463 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50464 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50465
50466 dcache_init();
50467 inode_init();
50468 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50469 index 4888cb3..e0f7cf8 100644
50470 --- a/fs/debugfs/inode.c
50471 +++ b/fs/debugfs/inode.c
50472 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50473 */
50474 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50475 {
50476 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50477 + return __create_file(name, S_IFDIR | S_IRWXU,
50478 +#else
50479 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50480 +#endif
50481 parent, NULL, NULL);
50482 }
50483 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50484 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50485 index 5eab400..810a3f5 100644
50486 --- a/fs/ecryptfs/inode.c
50487 +++ b/fs/ecryptfs/inode.c
50488 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50489 old_fs = get_fs();
50490 set_fs(get_ds());
50491 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50492 - (char __user *)lower_buf,
50493 + (char __force_user *)lower_buf,
50494 PATH_MAX);
50495 set_fs(old_fs);
50496 if (rc < 0)
50497 @@ -706,7 +706,7 @@ out:
50498 static void
50499 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50500 {
50501 - char *buf = nd_get_link(nd);
50502 + const char *buf = nd_get_link(nd);
50503 if (!IS_ERR(buf)) {
50504 /* Free the char* */
50505 kfree(buf);
50506 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50507 index e4141f2..d8263e8 100644
50508 --- a/fs/ecryptfs/miscdev.c
50509 +++ b/fs/ecryptfs/miscdev.c
50510 @@ -304,7 +304,7 @@ check_list:
50511 goto out_unlock_msg_ctx;
50512 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50513 if (msg_ctx->msg) {
50514 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50515 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50516 goto out_unlock_msg_ctx;
50517 i += packet_length_size;
50518 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50519 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50520 index 6a16053..2155147 100644
50521 --- a/fs/ecryptfs/read_write.c
50522 +++ b/fs/ecryptfs/read_write.c
50523 @@ -240,7 +240,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50524 return -EIO;
50525 fs_save = get_fs();
50526 set_fs(get_ds());
50527 - rc = vfs_read(lower_file, data, size, &offset);
50528 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50529 set_fs(fs_save);
50530 return rc;
50531 }
50532 diff --git a/fs/exec.c b/fs/exec.c
50533 index 6d56ff2..3bc6638 100644
50534 --- a/fs/exec.c
50535 +++ b/fs/exec.c
50536 @@ -55,8 +55,20 @@
50537 #include <linux/pipe_fs_i.h>
50538 #include <linux/oom.h>
50539 #include <linux/compat.h>
50540 +#include <linux/random.h>
50541 +#include <linux/seq_file.h>
50542 +#include <linux/coredump.h>
50543 +#include <linux/mman.h>
50544 +
50545 +#ifdef CONFIG_PAX_REFCOUNT
50546 +#include <linux/kallsyms.h>
50547 +#include <linux/kdebug.h>
50548 +#endif
50549 +
50550 +#include <trace/events/fs.h>
50551
50552 #include <asm/uaccess.h>
50553 +#include <asm/sections.h>
50554 #include <asm/mmu_context.h>
50555 #include <asm/tlb.h>
50556
50557 @@ -66,6 +78,18 @@
50558
50559 #include <trace/events/sched.h>
50560
50561 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50562 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50563 +{
50564 + 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");
50565 +}
50566 +#endif
50567 +
50568 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50569 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50570 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50571 +#endif
50572 +
50573 int suid_dumpable = 0;
50574
50575 static LIST_HEAD(formats);
50576 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50577 {
50578 BUG_ON(!fmt);
50579 write_lock(&binfmt_lock);
50580 - insert ? list_add(&fmt->lh, &formats) :
50581 - list_add_tail(&fmt->lh, &formats);
50582 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50583 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50584 write_unlock(&binfmt_lock);
50585 }
50586
50587 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
50588 void unregister_binfmt(struct linux_binfmt * fmt)
50589 {
50590 write_lock(&binfmt_lock);
50591 - list_del(&fmt->lh);
50592 + pax_list_del((struct list_head *)&fmt->lh);
50593 write_unlock(&binfmt_lock);
50594 }
50595
50596 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50597 int write)
50598 {
50599 struct page *page;
50600 - int ret;
50601
50602 -#ifdef CONFIG_STACK_GROWSUP
50603 - if (write) {
50604 - ret = expand_downwards(bprm->vma, pos);
50605 - if (ret < 0)
50606 - return NULL;
50607 - }
50608 -#endif
50609 - ret = get_user_pages(current, bprm->mm, pos,
50610 - 1, write, 1, &page, NULL);
50611 - if (ret <= 0)
50612 + if (0 > expand_downwards(bprm->vma, pos))
50613 + return NULL;
50614 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50615 return NULL;
50616
50617 if (write) {
50618 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50619 if (size <= ARG_MAX)
50620 return page;
50621
50622 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50623 + // only allow 512KB for argv+env on suid/sgid binaries
50624 + // to prevent easy ASLR exhaustion
50625 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50626 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50627 + (size > (512 * 1024))) {
50628 + put_page(page);
50629 + return NULL;
50630 + }
50631 +#endif
50632 +
50633 /*
50634 * Limit to 1/4-th the stack size for the argv+env strings.
50635 * This ensures that:
50636 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50637 vma->vm_end = STACK_TOP_MAX;
50638 vma->vm_start = vma->vm_end - PAGE_SIZE;
50639 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50640 +
50641 +#ifdef CONFIG_PAX_SEGMEXEC
50642 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50643 +#endif
50644 +
50645 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50646 INIT_LIST_HEAD(&vma->anon_vma_chain);
50647
50648 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50649 mm->stack_vm = mm->total_vm = 1;
50650 up_write(&mm->mmap_sem);
50651 bprm->p = vma->vm_end - sizeof(void *);
50652 +
50653 +#ifdef CONFIG_PAX_RANDUSTACK
50654 + if (randomize_va_space)
50655 + bprm->p ^= random32() & ~PAGE_MASK;
50656 +#endif
50657 +
50658 return 0;
50659 err:
50660 up_write(&mm->mmap_sem);
50661 @@ -396,7 +434,7 @@ struct user_arg_ptr {
50662 } ptr;
50663 };
50664
50665 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50666 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50667 {
50668 const char __user *native;
50669
50670 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50671 compat_uptr_t compat;
50672
50673 if (get_user(compat, argv.ptr.compat + nr))
50674 - return ERR_PTR(-EFAULT);
50675 + return (const char __force_user *)ERR_PTR(-EFAULT);
50676
50677 return compat_ptr(compat);
50678 }
50679 #endif
50680
50681 if (get_user(native, argv.ptr.native + nr))
50682 - return ERR_PTR(-EFAULT);
50683 + return (const char __force_user *)ERR_PTR(-EFAULT);
50684
50685 return native;
50686 }
50687 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
50688 if (!p)
50689 break;
50690
50691 - if (IS_ERR(p))
50692 + if (IS_ERR((const char __force_kernel *)p))
50693 return -EFAULT;
50694
50695 if (i >= max)
50696 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50697
50698 ret = -EFAULT;
50699 str = get_user_arg_ptr(argv, argc);
50700 - if (IS_ERR(str))
50701 + if (IS_ERR((const char __force_kernel *)str))
50702 goto out;
50703
50704 len = strnlen_user(str, MAX_ARG_STRLEN);
50705 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50706 int r;
50707 mm_segment_t oldfs = get_fs();
50708 struct user_arg_ptr argv = {
50709 - .ptr.native = (const char __user *const __user *)__argv,
50710 + .ptr.native = (const char __force_user * const __force_user *)__argv,
50711 };
50712
50713 set_fs(KERNEL_DS);
50714 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50715 unsigned long new_end = old_end - shift;
50716 struct mmu_gather tlb;
50717
50718 - BUG_ON(new_start > new_end);
50719 + if (new_start >= new_end || new_start < mmap_min_addr)
50720 + return -ENOMEM;
50721
50722 /*
50723 * ensure there are no vmas between where we want to go
50724 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50725 if (vma != find_vma(mm, new_start))
50726 return -EFAULT;
50727
50728 +#ifdef CONFIG_PAX_SEGMEXEC
50729 + BUG_ON(pax_find_mirror_vma(vma));
50730 +#endif
50731 +
50732 /*
50733 * cover the whole range: [new_start, old_end)
50734 */
50735 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50736 stack_top = arch_align_stack(stack_top);
50737 stack_top = PAGE_ALIGN(stack_top);
50738
50739 - if (unlikely(stack_top < mmap_min_addr) ||
50740 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50741 - return -ENOMEM;
50742 -
50743 stack_shift = vma->vm_end - stack_top;
50744
50745 bprm->p -= stack_shift;
50746 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50747 bprm->exec -= stack_shift;
50748
50749 down_write(&mm->mmap_sem);
50750 +
50751 + /* Move stack pages down in memory. */
50752 + if (stack_shift) {
50753 + ret = shift_arg_pages(vma, stack_shift);
50754 + if (ret)
50755 + goto out_unlock;
50756 + }
50757 +
50758 vm_flags = VM_STACK_FLAGS;
50759
50760 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50761 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50762 + vm_flags &= ~VM_EXEC;
50763 +
50764 +#ifdef CONFIG_PAX_MPROTECT
50765 + if (mm->pax_flags & MF_PAX_MPROTECT)
50766 + vm_flags &= ~VM_MAYEXEC;
50767 +#endif
50768 +
50769 + }
50770 +#endif
50771 +
50772 /*
50773 * Adjust stack execute permissions; explicitly enable for
50774 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50775 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50776 goto out_unlock;
50777 BUG_ON(prev != vma);
50778
50779 - /* Move stack pages down in memory. */
50780 - if (stack_shift) {
50781 - ret = shift_arg_pages(vma, stack_shift);
50782 - if (ret)
50783 - goto out_unlock;
50784 - }
50785 -
50786 /* mprotect_fixup is overkill to remove the temporary stack flags */
50787 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50788
50789 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50790 #endif
50791 current->mm->start_stack = bprm->p;
50792 ret = expand_stack(vma, stack_base);
50793 +
50794 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50795 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50796 + unsigned long size;
50797 + vm_flags_t vm_flags;
50798 +
50799 + size = STACK_TOP - vma->vm_end;
50800 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50801 +
50802 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
50803 +
50804 +#ifdef CONFIG_X86
50805 + if (!ret) {
50806 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50807 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
50808 + }
50809 +#endif
50810 +
50811 + }
50812 +#endif
50813 +
50814 if (ret)
50815 ret = -EFAULT;
50816
50817 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
50818
50819 fsnotify_open(file);
50820
50821 + trace_open_exec(name);
50822 +
50823 err = deny_write_access(file);
50824 if (err)
50825 goto exit;
50826 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
50827 old_fs = get_fs();
50828 set_fs(get_ds());
50829 /* The cast to a user pointer is valid due to the set_fs() */
50830 - result = vfs_read(file, (void __user *)addr, count, &pos);
50831 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50832 set_fs(old_fs);
50833 return result;
50834 }
50835 @@ -1250,7 +1325,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50836 }
50837 rcu_read_unlock();
50838
50839 - if (p->fs->users > n_fs) {
50840 + if (atomic_read(&p->fs->users) > n_fs) {
50841 bprm->unsafe |= LSM_UNSAFE_SHARE;
50842 } else {
50843 res = -EAGAIN;
50844 @@ -1450,6 +1525,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50845
50846 EXPORT_SYMBOL(search_binary_handler);
50847
50848 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50849 +static DEFINE_PER_CPU(u64, exec_counter);
50850 +static int __init init_exec_counters(void)
50851 +{
50852 + unsigned int cpu;
50853 +
50854 + for_each_possible_cpu(cpu) {
50855 + per_cpu(exec_counter, cpu) = (u64)cpu;
50856 + }
50857 +
50858 + return 0;
50859 +}
50860 +early_initcall(init_exec_counters);
50861 +static inline void increment_exec_counter(void)
50862 +{
50863 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50864 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50865 +}
50866 +#else
50867 +static inline void increment_exec_counter(void) {}
50868 +#endif
50869 +
50870 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50871 + struct user_arg_ptr argv);
50872 +
50873 /*
50874 * sys_execve() executes a new program.
50875 */
50876 @@ -1457,6 +1557,11 @@ static int do_execve_common(const char *filename,
50877 struct user_arg_ptr argv,
50878 struct user_arg_ptr envp)
50879 {
50880 +#ifdef CONFIG_GRKERNSEC
50881 + struct file *old_exec_file;
50882 + struct acl_subject_label *old_acl;
50883 + struct rlimit old_rlim[RLIM_NLIMITS];
50884 +#endif
50885 struct linux_binprm *bprm;
50886 struct file *file;
50887 struct files_struct *displaced;
50888 @@ -1464,6 +1569,8 @@ static int do_execve_common(const char *filename,
50889 int retval;
50890 const struct cred *cred = current_cred();
50891
50892 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
50893 +
50894 /*
50895 * We move the actual failure in case of RLIMIT_NPROC excess from
50896 * set*uid() to execve() because too many poorly written programs
50897 @@ -1504,12 +1611,27 @@ static int do_execve_common(const char *filename,
50898 if (IS_ERR(file))
50899 goto out_unmark;
50900
50901 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50902 + retval = -EPERM;
50903 + goto out_file;
50904 + }
50905 +
50906 sched_exec();
50907
50908 bprm->file = file;
50909 bprm->filename = filename;
50910 bprm->interp = filename;
50911
50912 + if (gr_process_user_ban()) {
50913 + retval = -EPERM;
50914 + goto out_file;
50915 + }
50916 +
50917 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
50918 + retval = -EACCES;
50919 + goto out_file;
50920 + }
50921 +
50922 retval = bprm_mm_init(bprm);
50923 if (retval)
50924 goto out_file;
50925 @@ -1526,24 +1648,65 @@ static int do_execve_common(const char *filename,
50926 if (retval < 0)
50927 goto out;
50928
50929 +#ifdef CONFIG_GRKERNSEC
50930 + old_acl = current->acl;
50931 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50932 + old_exec_file = current->exec_file;
50933 + get_file(file);
50934 + current->exec_file = file;
50935 +#endif
50936 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50937 + /* limit suid stack to 8MB
50938 + * we saved the old limits above and will restore them if this exec fails
50939 + */
50940 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50941 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50942 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50943 +#endif
50944 +
50945 + if (!gr_tpe_allow(file)) {
50946 + retval = -EACCES;
50947 + goto out_fail;
50948 + }
50949 +
50950 + if (gr_check_crash_exec(file)) {
50951 + retval = -EACCES;
50952 + goto out_fail;
50953 + }
50954 +
50955 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
50956 + bprm->unsafe);
50957 + if (retval < 0)
50958 + goto out_fail;
50959 +
50960 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50961 if (retval < 0)
50962 - goto out;
50963 + goto out_fail;
50964
50965 bprm->exec = bprm->p;
50966 retval = copy_strings(bprm->envc, envp, bprm);
50967 if (retval < 0)
50968 - goto out;
50969 + goto out_fail;
50970
50971 retval = copy_strings(bprm->argc, argv, bprm);
50972 if (retval < 0)
50973 - goto out;
50974 + goto out_fail;
50975 +
50976 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
50977 +
50978 + gr_handle_exec_args(bprm, argv);
50979
50980 retval = search_binary_handler(bprm);
50981 if (retval < 0)
50982 - goto out;
50983 + goto out_fail;
50984 +#ifdef CONFIG_GRKERNSEC
50985 + if (old_exec_file)
50986 + fput(old_exec_file);
50987 +#endif
50988
50989 /* execve succeeded */
50990 +
50991 + increment_exec_counter();
50992 current->fs->in_exec = 0;
50993 current->in_execve = 0;
50994 acct_update_integrals(current);
50995 @@ -1552,6 +1715,14 @@ static int do_execve_common(const char *filename,
50996 put_files_struct(displaced);
50997 return retval;
50998
50999 +out_fail:
51000 +#ifdef CONFIG_GRKERNSEC
51001 + current->acl = old_acl;
51002 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51003 + fput(current->exec_file);
51004 + current->exec_file = old_exec_file;
51005 +#endif
51006 +
51007 out:
51008 if (bprm->mm) {
51009 acct_arg_size(bprm, 0);
51010 @@ -1700,3 +1871,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51011 return error;
51012 }
51013 #endif
51014 +
51015 +int pax_check_flags(unsigned long *flags)
51016 +{
51017 + int retval = 0;
51018 +
51019 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51020 + if (*flags & MF_PAX_SEGMEXEC)
51021 + {
51022 + *flags &= ~MF_PAX_SEGMEXEC;
51023 + retval = -EINVAL;
51024 + }
51025 +#endif
51026 +
51027 + if ((*flags & MF_PAX_PAGEEXEC)
51028 +
51029 +#ifdef CONFIG_PAX_PAGEEXEC
51030 + && (*flags & MF_PAX_SEGMEXEC)
51031 +#endif
51032 +
51033 + )
51034 + {
51035 + *flags &= ~MF_PAX_PAGEEXEC;
51036 + retval = -EINVAL;
51037 + }
51038 +
51039 + if ((*flags & MF_PAX_MPROTECT)
51040 +
51041 +#ifdef CONFIG_PAX_MPROTECT
51042 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51043 +#endif
51044 +
51045 + )
51046 + {
51047 + *flags &= ~MF_PAX_MPROTECT;
51048 + retval = -EINVAL;
51049 + }
51050 +
51051 + if ((*flags & MF_PAX_EMUTRAMP)
51052 +
51053 +#ifdef CONFIG_PAX_EMUTRAMP
51054 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51055 +#endif
51056 +
51057 + )
51058 + {
51059 + *flags &= ~MF_PAX_EMUTRAMP;
51060 + retval = -EINVAL;
51061 + }
51062 +
51063 + return retval;
51064 +}
51065 +
51066 +EXPORT_SYMBOL(pax_check_flags);
51067 +
51068 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51069 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51070 +{
51071 + struct task_struct *tsk = current;
51072 + struct mm_struct *mm = current->mm;
51073 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51074 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51075 + char *path_exec = NULL;
51076 + char *path_fault = NULL;
51077 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51078 + siginfo_t info = { };
51079 +
51080 + if (buffer_exec && buffer_fault) {
51081 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51082 +
51083 + down_read(&mm->mmap_sem);
51084 + vma = mm->mmap;
51085 + while (vma && (!vma_exec || !vma_fault)) {
51086 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51087 + vma_exec = vma;
51088 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51089 + vma_fault = vma;
51090 + vma = vma->vm_next;
51091 + }
51092 + if (vma_exec) {
51093 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51094 + if (IS_ERR(path_exec))
51095 + path_exec = "<path too long>";
51096 + else {
51097 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51098 + if (path_exec) {
51099 + *path_exec = 0;
51100 + path_exec = buffer_exec;
51101 + } else
51102 + path_exec = "<path too long>";
51103 + }
51104 + }
51105 + if (vma_fault) {
51106 + start = vma_fault->vm_start;
51107 + end = vma_fault->vm_end;
51108 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51109 + if (vma_fault->vm_file) {
51110 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51111 + if (IS_ERR(path_fault))
51112 + path_fault = "<path too long>";
51113 + else {
51114 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51115 + if (path_fault) {
51116 + *path_fault = 0;
51117 + path_fault = buffer_fault;
51118 + } else
51119 + path_fault = "<path too long>";
51120 + }
51121 + } else
51122 + path_fault = "<anonymous mapping>";
51123 + }
51124 + up_read(&mm->mmap_sem);
51125 + }
51126 + if (tsk->signal->curr_ip)
51127 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51128 + else
51129 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51130 + 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),
51131 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51132 + free_page((unsigned long)buffer_exec);
51133 + free_page((unsigned long)buffer_fault);
51134 + pax_report_insns(regs, pc, sp);
51135 + info.si_signo = SIGKILL;
51136 + info.si_errno = 0;
51137 + info.si_code = SI_KERNEL;
51138 + info.si_pid = 0;
51139 + info.si_uid = 0;
51140 + do_coredump(&info);
51141 +}
51142 +#endif
51143 +
51144 +#ifdef CONFIG_PAX_REFCOUNT
51145 +void pax_report_refcount_overflow(struct pt_regs *regs)
51146 +{
51147 + if (current->signal->curr_ip)
51148 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51149 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51150 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51151 + else
51152 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51153 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51154 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51155 + show_regs(regs);
51156 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51157 +}
51158 +#endif
51159 +
51160 +#ifdef CONFIG_PAX_USERCOPY
51161 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51162 +static noinline int check_stack_object(const void *obj, unsigned long len)
51163 +{
51164 + const void * const stack = task_stack_page(current);
51165 + const void * const stackend = stack + THREAD_SIZE;
51166 +
51167 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51168 + const void *frame = NULL;
51169 + const void *oldframe;
51170 +#endif
51171 +
51172 + if (obj + len < obj)
51173 + return -1;
51174 +
51175 + if (obj + len <= stack || stackend <= obj)
51176 + return 0;
51177 +
51178 + if (obj < stack || stackend < obj + len)
51179 + return -1;
51180 +
51181 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51182 + oldframe = __builtin_frame_address(1);
51183 + if (oldframe)
51184 + frame = __builtin_frame_address(2);
51185 + /*
51186 + low ----------------------------------------------> high
51187 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51188 + ^----------------^
51189 + allow copies only within here
51190 + */
51191 + while (stack <= frame && frame < stackend) {
51192 + /* if obj + len extends past the last frame, this
51193 + check won't pass and the next frame will be 0,
51194 + causing us to bail out and correctly report
51195 + the copy as invalid
51196 + */
51197 + if (obj + len <= frame)
51198 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51199 + oldframe = frame;
51200 + frame = *(const void * const *)frame;
51201 + }
51202 + return -1;
51203 +#else
51204 + return 1;
51205 +#endif
51206 +}
51207 +
51208 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51209 +{
51210 + if (current->signal->curr_ip)
51211 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51212 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51213 + else
51214 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51215 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51216 + dump_stack();
51217 + gr_handle_kernel_exploit();
51218 + do_group_exit(SIGKILL);
51219 +}
51220 +#endif
51221 +
51222 +#ifdef CONFIG_PAX_USERCOPY
51223 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51224 +{
51225 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51226 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51227 +#ifdef CONFIG_MODULES
51228 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
51229 +#else
51230 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51231 +#endif
51232 +
51233 +#else
51234 + unsigned long textlow = (unsigned long)_stext;
51235 + unsigned long texthigh = (unsigned long)_etext;
51236 +#endif
51237 +
51238 + if (high <= textlow || low > texthigh)
51239 + return false;
51240 + else
51241 + return true;
51242 +}
51243 +#endif
51244 +
51245 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51246 +{
51247 +
51248 +#ifdef CONFIG_PAX_USERCOPY
51249 + const char *type;
51250 +
51251 + if (!n)
51252 + return;
51253 +
51254 + type = check_heap_object(ptr, n);
51255 + if (!type) {
51256 + int ret = check_stack_object(ptr, n);
51257 + if (ret == 1 || ret == 2)
51258 + return;
51259 + if (ret == 0) {
51260 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51261 + type = "<kernel text>";
51262 + else
51263 + return;
51264 + } else
51265 + type = "<process stack>";
51266 + }
51267 +
51268 + pax_report_usercopy(ptr, n, to_user, type);
51269 +#endif
51270 +
51271 +}
51272 +EXPORT_SYMBOL(__check_object_size);
51273 +
51274 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51275 +void pax_track_stack(void)
51276 +{
51277 + unsigned long sp = (unsigned long)&sp;
51278 + if (sp < current_thread_info()->lowest_stack &&
51279 + sp > (unsigned long)task_stack_page(current))
51280 + current_thread_info()->lowest_stack = sp;
51281 +}
51282 +EXPORT_SYMBOL(pax_track_stack);
51283 +#endif
51284 +
51285 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51286 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51287 +{
51288 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51289 + dump_stack();
51290 + do_group_exit(SIGKILL);
51291 +}
51292 +EXPORT_SYMBOL(report_size_overflow);
51293 +#endif
51294 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51295 index 9f9992b..8b59411 100644
51296 --- a/fs/ext2/balloc.c
51297 +++ b/fs/ext2/balloc.c
51298 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51299
51300 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51301 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51302 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51303 + if (free_blocks < root_blocks + 1 &&
51304 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51305 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51306 - !in_group_p (sbi->s_resgid))) {
51307 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51308 return 0;
51309 }
51310 return 1;
51311 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51312 index 22548f5..41521d8 100644
51313 --- a/fs/ext3/balloc.c
51314 +++ b/fs/ext3/balloc.c
51315 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51316
51317 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51318 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51319 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51320 + if (free_blocks < root_blocks + 1 &&
51321 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51322 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51323 - !in_group_p (sbi->s_resgid))) {
51324 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51325 return 0;
51326 }
51327 return 1;
51328 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51329 index 92e68b3..115d987 100644
51330 --- a/fs/ext4/balloc.c
51331 +++ b/fs/ext4/balloc.c
51332 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51333 /* Hm, nope. Are (enough) root reserved clusters available? */
51334 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51335 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51336 - capable(CAP_SYS_RESOURCE) ||
51337 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51338 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51339 + capable_nolog(CAP_SYS_RESOURCE)) {
51340
51341 if (free_clusters >= (nclusters + dirty_clusters))
51342 return 1;
51343 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51344 index 3b83cd6..0f34dcd 100644
51345 --- a/fs/ext4/ext4.h
51346 +++ b/fs/ext4/ext4.h
51347 @@ -1254,19 +1254,19 @@ struct ext4_sb_info {
51348 unsigned long s_mb_last_start;
51349
51350 /* stats for buddy allocator */
51351 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51352 - atomic_t s_bal_success; /* we found long enough chunks */
51353 - atomic_t s_bal_allocated; /* in blocks */
51354 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51355 - atomic_t s_bal_goals; /* goal hits */
51356 - atomic_t s_bal_breaks; /* too long searches */
51357 - atomic_t s_bal_2orders; /* 2^order hits */
51358 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51359 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51360 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51361 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51362 + atomic_unchecked_t s_bal_goals; /* goal hits */
51363 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51364 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51365 spinlock_t s_bal_lock;
51366 unsigned long s_mb_buddies_generated;
51367 unsigned long long s_mb_generation_time;
51368 - atomic_t s_mb_lost_chunks;
51369 - atomic_t s_mb_preallocated;
51370 - atomic_t s_mb_discarded;
51371 + atomic_unchecked_t s_mb_lost_chunks;
51372 + atomic_unchecked_t s_mb_preallocated;
51373 + atomic_unchecked_t s_mb_discarded;
51374 atomic_t s_lock_busy;
51375
51376 /* locality groups */
51377 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51378 index f3190ab..84ffb21 100644
51379 --- a/fs/ext4/mballoc.c
51380 +++ b/fs/ext4/mballoc.c
51381 @@ -1754,7 +1754,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51382 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51383
51384 if (EXT4_SB(sb)->s_mb_stats)
51385 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51386 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51387
51388 break;
51389 }
51390 @@ -2059,7 +2059,7 @@ repeat:
51391 ac->ac_status = AC_STATUS_CONTINUE;
51392 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51393 cr = 3;
51394 - atomic_inc(&sbi->s_mb_lost_chunks);
51395 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51396 goto repeat;
51397 }
51398 }
51399 @@ -2567,25 +2567,25 @@ int ext4_mb_release(struct super_block *sb)
51400 if (sbi->s_mb_stats) {
51401 ext4_msg(sb, KERN_INFO,
51402 "mballoc: %u blocks %u reqs (%u success)",
51403 - atomic_read(&sbi->s_bal_allocated),
51404 - atomic_read(&sbi->s_bal_reqs),
51405 - atomic_read(&sbi->s_bal_success));
51406 + atomic_read_unchecked(&sbi->s_bal_allocated),
51407 + atomic_read_unchecked(&sbi->s_bal_reqs),
51408 + atomic_read_unchecked(&sbi->s_bal_success));
51409 ext4_msg(sb, KERN_INFO,
51410 "mballoc: %u extents scanned, %u goal hits, "
51411 "%u 2^N hits, %u breaks, %u lost",
51412 - atomic_read(&sbi->s_bal_ex_scanned),
51413 - atomic_read(&sbi->s_bal_goals),
51414 - atomic_read(&sbi->s_bal_2orders),
51415 - atomic_read(&sbi->s_bal_breaks),
51416 - atomic_read(&sbi->s_mb_lost_chunks));
51417 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51418 + atomic_read_unchecked(&sbi->s_bal_goals),
51419 + atomic_read_unchecked(&sbi->s_bal_2orders),
51420 + atomic_read_unchecked(&sbi->s_bal_breaks),
51421 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51422 ext4_msg(sb, KERN_INFO,
51423 "mballoc: %lu generated and it took %Lu",
51424 sbi->s_mb_buddies_generated,
51425 sbi->s_mb_generation_time);
51426 ext4_msg(sb, KERN_INFO,
51427 "mballoc: %u preallocated, %u discarded",
51428 - atomic_read(&sbi->s_mb_preallocated),
51429 - atomic_read(&sbi->s_mb_discarded));
51430 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51431 + atomic_read_unchecked(&sbi->s_mb_discarded));
51432 }
51433
51434 free_percpu(sbi->s_locality_groups);
51435 @@ -3039,16 +3039,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51436 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51437
51438 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51439 - atomic_inc(&sbi->s_bal_reqs);
51440 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51441 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51442 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51443 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51444 - atomic_inc(&sbi->s_bal_success);
51445 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51446 + atomic_inc_unchecked(&sbi->s_bal_success);
51447 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51448 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51449 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51450 - atomic_inc(&sbi->s_bal_goals);
51451 + atomic_inc_unchecked(&sbi->s_bal_goals);
51452 if (ac->ac_found > sbi->s_mb_max_to_scan)
51453 - atomic_inc(&sbi->s_bal_breaks);
51454 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51455 }
51456
51457 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51458 @@ -3448,7 +3448,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51459 trace_ext4_mb_new_inode_pa(ac, pa);
51460
51461 ext4_mb_use_inode_pa(ac, pa);
51462 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51463 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51464
51465 ei = EXT4_I(ac->ac_inode);
51466 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51467 @@ -3508,7 +3508,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51468 trace_ext4_mb_new_group_pa(ac, pa);
51469
51470 ext4_mb_use_group_pa(ac, pa);
51471 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51472 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51473
51474 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51475 lg = ac->ac_lg;
51476 @@ -3597,7 +3597,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51477 * from the bitmap and continue.
51478 */
51479 }
51480 - atomic_add(free, &sbi->s_mb_discarded);
51481 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51482
51483 return err;
51484 }
51485 @@ -3615,7 +3615,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51486 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51487 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51488 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51489 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51490 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51491 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51492
51493 return 0;
51494 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
51495 index b3b1f7d..cff51d5 100644
51496 --- a/fs/ext4/mmp.c
51497 +++ b/fs/ext4/mmp.c
51498 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
51499 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
51500 const char *function, unsigned int line, const char *msg)
51501 {
51502 - __ext4_warning(sb, function, line, msg);
51503 + __ext4_warning(sb, function, line, "%s", msg);
51504 __ext4_warning(sb, function, line,
51505 "MMP failure info: last update time: %llu, last update "
51506 "node: %s, last update device: %s\n",
51507 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
51508 index 3beae6a..8cc5637 100644
51509 --- a/fs/ext4/resize.c
51510 +++ b/fs/ext4/resize.c
51511 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
51512 ext4_fsblk_t end = start + input->blocks_count;
51513 ext4_group_t group = input->group;
51514 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
51515 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
51516 - ext4_fsblk_t metaend = start + overhead;
51517 + unsigned overhead;
51518 + ext4_fsblk_t metaend;
51519 struct buffer_head *bh = NULL;
51520 ext4_grpblk_t free_blocks_count, offset;
51521 int err = -EINVAL;
51522
51523 + if (group != sbi->s_groups_count) {
51524 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51525 + input->group, sbi->s_groups_count);
51526 + return -EINVAL;
51527 + }
51528 +
51529 + overhead = ext4_group_overhead_blocks(sb, group);
51530 + metaend = start + overhead;
51531 input->free_blocks_count = free_blocks_count =
51532 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
51533
51534 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
51535 free_blocks_count, input->reserved_blocks);
51536
51537 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
51538 - if (group != sbi->s_groups_count)
51539 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51540 - input->group, sbi->s_groups_count);
51541 - else if (offset != 0)
51542 + if (offset != 0)
51543 ext4_warning(sb, "Last group not full");
51544 else if (input->reserved_blocks > input->blocks_count / 5)
51545 ext4_warning(sb, "Reserved blocks too high (%u)",
51546 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51547 index febbe0e..d0cdc02 100644
51548 --- a/fs/ext4/super.c
51549 +++ b/fs/ext4/super.c
51550 @@ -1238,7 +1238,7 @@ static ext4_fsblk_t get_sb_block(void **data)
51551 }
51552
51553 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
51554 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51555 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51556 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
51557
51558 #ifdef CONFIG_QUOTA
51559 @@ -2380,7 +2380,7 @@ struct ext4_attr {
51560 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51561 const char *, size_t);
51562 int offset;
51563 -};
51564 +} __do_const;
51565
51566 static int parse_strtoul(const char *buf,
51567 unsigned long max, unsigned long *value)
51568 diff --git a/fs/fcntl.c b/fs/fcntl.c
51569 index 6599222..e7bf0de 100644
51570 --- a/fs/fcntl.c
51571 +++ b/fs/fcntl.c
51572 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51573 if (err)
51574 return err;
51575
51576 + if (gr_handle_chroot_fowner(pid, type))
51577 + return -ENOENT;
51578 + if (gr_check_protected_task_fowner(pid, type))
51579 + return -EACCES;
51580 +
51581 f_modown(filp, pid, type, force);
51582 return 0;
51583 }
51584 diff --git a/fs/fhandle.c b/fs/fhandle.c
51585 index 999ff5c..41f4109 100644
51586 --- a/fs/fhandle.c
51587 +++ b/fs/fhandle.c
51588 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51589 } else
51590 retval = 0;
51591 /* copy the mount id */
51592 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51593 - sizeof(*mnt_id)) ||
51594 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51595 copy_to_user(ufh, handle,
51596 sizeof(struct file_handle) + handle_bytes))
51597 retval = -EFAULT;
51598 diff --git a/fs/fifo.c b/fs/fifo.c
51599 index cf6f434..3d7942c 100644
51600 --- a/fs/fifo.c
51601 +++ b/fs/fifo.c
51602 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51603 */
51604 filp->f_op = &read_pipefifo_fops;
51605 pipe->r_counter++;
51606 - if (pipe->readers++ == 0)
51607 + if (atomic_inc_return(&pipe->readers) == 1)
51608 wake_up_partner(inode);
51609
51610 - if (!pipe->writers) {
51611 + if (!atomic_read(&pipe->writers)) {
51612 if ((filp->f_flags & O_NONBLOCK)) {
51613 /* suppress POLLHUP until we have
51614 * seen a writer */
51615 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51616 * errno=ENXIO when there is no process reading the FIFO.
51617 */
51618 ret = -ENXIO;
51619 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51620 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51621 goto err;
51622
51623 filp->f_op = &write_pipefifo_fops;
51624 pipe->w_counter++;
51625 - if (!pipe->writers++)
51626 + if (atomic_inc_return(&pipe->writers) == 1)
51627 wake_up_partner(inode);
51628
51629 - if (!pipe->readers) {
51630 + if (!atomic_read(&pipe->readers)) {
51631 if (wait_for_partner(inode, &pipe->r_counter))
51632 goto err_wr;
51633 }
51634 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51635 */
51636 filp->f_op = &rdwr_pipefifo_fops;
51637
51638 - pipe->readers++;
51639 - pipe->writers++;
51640 + atomic_inc(&pipe->readers);
51641 + atomic_inc(&pipe->writers);
51642 pipe->r_counter++;
51643 pipe->w_counter++;
51644 - if (pipe->readers == 1 || pipe->writers == 1)
51645 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51646 wake_up_partner(inode);
51647 break;
51648
51649 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51650 return 0;
51651
51652 err_rd:
51653 - if (!--pipe->readers)
51654 + if (atomic_dec_and_test(&pipe->readers))
51655 wake_up_interruptible(&pipe->wait);
51656 ret = -ERESTARTSYS;
51657 goto err;
51658
51659 err_wr:
51660 - if (!--pipe->writers)
51661 + if (atomic_dec_and_test(&pipe->writers))
51662 wake_up_interruptible(&pipe->wait);
51663 ret = -ERESTARTSYS;
51664 goto err;
51665
51666 err:
51667 - if (!pipe->readers && !pipe->writers)
51668 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51669 free_pipe_info(inode);
51670
51671 err_nocleanup:
51672 diff --git a/fs/file.c b/fs/file.c
51673 index 3906d95..5fe379b 100644
51674 --- a/fs/file.c
51675 +++ b/fs/file.c
51676 @@ -16,6 +16,7 @@
51677 #include <linux/slab.h>
51678 #include <linux/vmalloc.h>
51679 #include <linux/file.h>
51680 +#include <linux/security.h>
51681 #include <linux/fdtable.h>
51682 #include <linux/bitops.h>
51683 #include <linux/interrupt.h>
51684 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51685 if (!file)
51686 return __close_fd(files, fd);
51687
51688 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51689 if (fd >= rlimit(RLIMIT_NOFILE))
51690 return -EBADF;
51691
51692 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51693 if (unlikely(oldfd == newfd))
51694 return -EINVAL;
51695
51696 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51697 if (newfd >= rlimit(RLIMIT_NOFILE))
51698 return -EBADF;
51699
51700 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51701 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51702 {
51703 int err;
51704 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51705 if (from >= rlimit(RLIMIT_NOFILE))
51706 return -EINVAL;
51707 err = alloc_fd(from, flags);
51708 diff --git a/fs/filesystems.c b/fs/filesystems.c
51709 index 92567d9..fcd8cbf 100644
51710 --- a/fs/filesystems.c
51711 +++ b/fs/filesystems.c
51712 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
51713 int len = dot ? dot - name : strlen(name);
51714
51715 fs = __get_fs_type(name, len);
51716 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51717 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
51718 +#else
51719 if (!fs && (request_module("fs-%.*s", len, name) == 0))
51720 +#endif
51721 fs = __get_fs_type(name, len);
51722
51723 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51724 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51725 index d8ac61d..79a36f0 100644
51726 --- a/fs/fs_struct.c
51727 +++ b/fs/fs_struct.c
51728 @@ -4,6 +4,7 @@
51729 #include <linux/path.h>
51730 #include <linux/slab.h>
51731 #include <linux/fs_struct.h>
51732 +#include <linux/grsecurity.h>
51733 #include "internal.h"
51734
51735 /*
51736 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
51737 write_seqcount_begin(&fs->seq);
51738 old_root = fs->root;
51739 fs->root = *path;
51740 + gr_set_chroot_entries(current, path);
51741 write_seqcount_end(&fs->seq);
51742 spin_unlock(&fs->lock);
51743 if (old_root.dentry)
51744 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
51745 int hits = 0;
51746 spin_lock(&fs->lock);
51747 write_seqcount_begin(&fs->seq);
51748 + /* this root replacement is only done by pivot_root,
51749 + leave grsec's chroot tagging alone for this task
51750 + so that a pivoted root isn't treated as a chroot
51751 + */
51752 hits += replace_path(&fs->root, old_root, new_root);
51753 hits += replace_path(&fs->pwd, old_root, new_root);
51754 write_seqcount_end(&fs->seq);
51755 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
51756 task_lock(tsk);
51757 spin_lock(&fs->lock);
51758 tsk->fs = NULL;
51759 - kill = !--fs->users;
51760 + gr_clear_chroot_entries(tsk);
51761 + kill = !atomic_dec_return(&fs->users);
51762 spin_unlock(&fs->lock);
51763 task_unlock(tsk);
51764 if (kill)
51765 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51766 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51767 /* We don't need to lock fs - think why ;-) */
51768 if (fs) {
51769 - fs->users = 1;
51770 + atomic_set(&fs->users, 1);
51771 fs->in_exec = 0;
51772 spin_lock_init(&fs->lock);
51773 seqcount_init(&fs->seq);
51774 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51775 spin_lock(&old->lock);
51776 fs->root = old->root;
51777 path_get(&fs->root);
51778 + /* instead of calling gr_set_chroot_entries here,
51779 + we call it from every caller of this function
51780 + */
51781 fs->pwd = old->pwd;
51782 path_get(&fs->pwd);
51783 spin_unlock(&old->lock);
51784 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
51785
51786 task_lock(current);
51787 spin_lock(&fs->lock);
51788 - kill = !--fs->users;
51789 + kill = !atomic_dec_return(&fs->users);
51790 current->fs = new_fs;
51791 + gr_set_chroot_entries(current, &new_fs->root);
51792 spin_unlock(&fs->lock);
51793 task_unlock(current);
51794
51795 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51796
51797 int current_umask(void)
51798 {
51799 - return current->fs->umask;
51800 + return current->fs->umask | gr_acl_umask();
51801 }
51802 EXPORT_SYMBOL(current_umask);
51803
51804 /* to be mentioned only in INIT_TASK */
51805 struct fs_struct init_fs = {
51806 - .users = 1,
51807 + .users = ATOMIC_INIT(1),
51808 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51809 .seq = SEQCNT_ZERO,
51810 .umask = 0022,
51811 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51812 index e2cba1f..17a25bb 100644
51813 --- a/fs/fscache/cookie.c
51814 +++ b/fs/fscache/cookie.c
51815 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51816 parent ? (char *) parent->def->name : "<no-parent>",
51817 def->name, netfs_data);
51818
51819 - fscache_stat(&fscache_n_acquires);
51820 + fscache_stat_unchecked(&fscache_n_acquires);
51821
51822 /* if there's no parent cookie, then we don't create one here either */
51823 if (!parent) {
51824 - fscache_stat(&fscache_n_acquires_null);
51825 + fscache_stat_unchecked(&fscache_n_acquires_null);
51826 _leave(" [no parent]");
51827 return NULL;
51828 }
51829 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51830 /* allocate and initialise a cookie */
51831 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51832 if (!cookie) {
51833 - fscache_stat(&fscache_n_acquires_oom);
51834 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51835 _leave(" [ENOMEM]");
51836 return NULL;
51837 }
51838 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51839
51840 switch (cookie->def->type) {
51841 case FSCACHE_COOKIE_TYPE_INDEX:
51842 - fscache_stat(&fscache_n_cookie_index);
51843 + fscache_stat_unchecked(&fscache_n_cookie_index);
51844 break;
51845 case FSCACHE_COOKIE_TYPE_DATAFILE:
51846 - fscache_stat(&fscache_n_cookie_data);
51847 + fscache_stat_unchecked(&fscache_n_cookie_data);
51848 break;
51849 default:
51850 - fscache_stat(&fscache_n_cookie_special);
51851 + fscache_stat_unchecked(&fscache_n_cookie_special);
51852 break;
51853 }
51854
51855 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51856 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51857 atomic_dec(&parent->n_children);
51858 __fscache_cookie_put(cookie);
51859 - fscache_stat(&fscache_n_acquires_nobufs);
51860 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51861 _leave(" = NULL");
51862 return NULL;
51863 }
51864 }
51865
51866 - fscache_stat(&fscache_n_acquires_ok);
51867 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51868 _leave(" = %p", cookie);
51869 return cookie;
51870 }
51871 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51872 cache = fscache_select_cache_for_object(cookie->parent);
51873 if (!cache) {
51874 up_read(&fscache_addremove_sem);
51875 - fscache_stat(&fscache_n_acquires_no_cache);
51876 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51877 _leave(" = -ENOMEDIUM [no cache]");
51878 return -ENOMEDIUM;
51879 }
51880 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51881 object = cache->ops->alloc_object(cache, cookie);
51882 fscache_stat_d(&fscache_n_cop_alloc_object);
51883 if (IS_ERR(object)) {
51884 - fscache_stat(&fscache_n_object_no_alloc);
51885 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51886 ret = PTR_ERR(object);
51887 goto error;
51888 }
51889
51890 - fscache_stat(&fscache_n_object_alloc);
51891 + fscache_stat_unchecked(&fscache_n_object_alloc);
51892
51893 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51894
51895 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51896
51897 _enter("{%s}", cookie->def->name);
51898
51899 - fscache_stat(&fscache_n_invalidates);
51900 + fscache_stat_unchecked(&fscache_n_invalidates);
51901
51902 /* Only permit invalidation of data files. Invalidating an index will
51903 * require the caller to release all its attachments to the tree rooted
51904 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51905 {
51906 struct fscache_object *object;
51907
51908 - fscache_stat(&fscache_n_updates);
51909 + fscache_stat_unchecked(&fscache_n_updates);
51910
51911 if (!cookie) {
51912 - fscache_stat(&fscache_n_updates_null);
51913 + fscache_stat_unchecked(&fscache_n_updates_null);
51914 _leave(" [no cookie]");
51915 return;
51916 }
51917 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51918 struct fscache_object *object;
51919 unsigned long event;
51920
51921 - fscache_stat(&fscache_n_relinquishes);
51922 + fscache_stat_unchecked(&fscache_n_relinquishes);
51923 if (retire)
51924 - fscache_stat(&fscache_n_relinquishes_retire);
51925 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51926
51927 if (!cookie) {
51928 - fscache_stat(&fscache_n_relinquishes_null);
51929 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51930 _leave(" [no cookie]");
51931 return;
51932 }
51933 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51934
51935 /* wait for the cookie to finish being instantiated (or to fail) */
51936 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51937 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51938 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51939 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51940 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51941 }
51942 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51943 index ee38fef..0a326d4 100644
51944 --- a/fs/fscache/internal.h
51945 +++ b/fs/fscache/internal.h
51946 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51947 * stats.c
51948 */
51949 #ifdef CONFIG_FSCACHE_STATS
51950 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51951 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51952 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51953 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51954
51955 -extern atomic_t fscache_n_op_pend;
51956 -extern atomic_t fscache_n_op_run;
51957 -extern atomic_t fscache_n_op_enqueue;
51958 -extern atomic_t fscache_n_op_deferred_release;
51959 -extern atomic_t fscache_n_op_release;
51960 -extern atomic_t fscache_n_op_gc;
51961 -extern atomic_t fscache_n_op_cancelled;
51962 -extern atomic_t fscache_n_op_rejected;
51963 +extern atomic_unchecked_t fscache_n_op_pend;
51964 +extern atomic_unchecked_t fscache_n_op_run;
51965 +extern atomic_unchecked_t fscache_n_op_enqueue;
51966 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51967 +extern atomic_unchecked_t fscache_n_op_release;
51968 +extern atomic_unchecked_t fscache_n_op_gc;
51969 +extern atomic_unchecked_t fscache_n_op_cancelled;
51970 +extern atomic_unchecked_t fscache_n_op_rejected;
51971
51972 -extern atomic_t fscache_n_attr_changed;
51973 -extern atomic_t fscache_n_attr_changed_ok;
51974 -extern atomic_t fscache_n_attr_changed_nobufs;
51975 -extern atomic_t fscache_n_attr_changed_nomem;
51976 -extern atomic_t fscache_n_attr_changed_calls;
51977 +extern atomic_unchecked_t fscache_n_attr_changed;
51978 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51979 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51980 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51981 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51982
51983 -extern atomic_t fscache_n_allocs;
51984 -extern atomic_t fscache_n_allocs_ok;
51985 -extern atomic_t fscache_n_allocs_wait;
51986 -extern atomic_t fscache_n_allocs_nobufs;
51987 -extern atomic_t fscache_n_allocs_intr;
51988 -extern atomic_t fscache_n_allocs_object_dead;
51989 -extern atomic_t fscache_n_alloc_ops;
51990 -extern atomic_t fscache_n_alloc_op_waits;
51991 +extern atomic_unchecked_t fscache_n_allocs;
51992 +extern atomic_unchecked_t fscache_n_allocs_ok;
51993 +extern atomic_unchecked_t fscache_n_allocs_wait;
51994 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51995 +extern atomic_unchecked_t fscache_n_allocs_intr;
51996 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51997 +extern atomic_unchecked_t fscache_n_alloc_ops;
51998 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51999
52000 -extern atomic_t fscache_n_retrievals;
52001 -extern atomic_t fscache_n_retrievals_ok;
52002 -extern atomic_t fscache_n_retrievals_wait;
52003 -extern atomic_t fscache_n_retrievals_nodata;
52004 -extern atomic_t fscache_n_retrievals_nobufs;
52005 -extern atomic_t fscache_n_retrievals_intr;
52006 -extern atomic_t fscache_n_retrievals_nomem;
52007 -extern atomic_t fscache_n_retrievals_object_dead;
52008 -extern atomic_t fscache_n_retrieval_ops;
52009 -extern atomic_t fscache_n_retrieval_op_waits;
52010 +extern atomic_unchecked_t fscache_n_retrievals;
52011 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52012 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52013 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52014 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52015 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52016 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52017 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52018 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52019 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52020
52021 -extern atomic_t fscache_n_stores;
52022 -extern atomic_t fscache_n_stores_ok;
52023 -extern atomic_t fscache_n_stores_again;
52024 -extern atomic_t fscache_n_stores_nobufs;
52025 -extern atomic_t fscache_n_stores_oom;
52026 -extern atomic_t fscache_n_store_ops;
52027 -extern atomic_t fscache_n_store_calls;
52028 -extern atomic_t fscache_n_store_pages;
52029 -extern atomic_t fscache_n_store_radix_deletes;
52030 -extern atomic_t fscache_n_store_pages_over_limit;
52031 +extern atomic_unchecked_t fscache_n_stores;
52032 +extern atomic_unchecked_t fscache_n_stores_ok;
52033 +extern atomic_unchecked_t fscache_n_stores_again;
52034 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52035 +extern atomic_unchecked_t fscache_n_stores_oom;
52036 +extern atomic_unchecked_t fscache_n_store_ops;
52037 +extern atomic_unchecked_t fscache_n_store_calls;
52038 +extern atomic_unchecked_t fscache_n_store_pages;
52039 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52040 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52041
52042 -extern atomic_t fscache_n_store_vmscan_not_storing;
52043 -extern atomic_t fscache_n_store_vmscan_gone;
52044 -extern atomic_t fscache_n_store_vmscan_busy;
52045 -extern atomic_t fscache_n_store_vmscan_cancelled;
52046 -extern atomic_t fscache_n_store_vmscan_wait;
52047 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52048 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52049 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52050 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52051 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52052
52053 -extern atomic_t fscache_n_marks;
52054 -extern atomic_t fscache_n_uncaches;
52055 +extern atomic_unchecked_t fscache_n_marks;
52056 +extern atomic_unchecked_t fscache_n_uncaches;
52057
52058 -extern atomic_t fscache_n_acquires;
52059 -extern atomic_t fscache_n_acquires_null;
52060 -extern atomic_t fscache_n_acquires_no_cache;
52061 -extern atomic_t fscache_n_acquires_ok;
52062 -extern atomic_t fscache_n_acquires_nobufs;
52063 -extern atomic_t fscache_n_acquires_oom;
52064 +extern atomic_unchecked_t fscache_n_acquires;
52065 +extern atomic_unchecked_t fscache_n_acquires_null;
52066 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52067 +extern atomic_unchecked_t fscache_n_acquires_ok;
52068 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52069 +extern atomic_unchecked_t fscache_n_acquires_oom;
52070
52071 -extern atomic_t fscache_n_invalidates;
52072 -extern atomic_t fscache_n_invalidates_run;
52073 +extern atomic_unchecked_t fscache_n_invalidates;
52074 +extern atomic_unchecked_t fscache_n_invalidates_run;
52075
52076 -extern atomic_t fscache_n_updates;
52077 -extern atomic_t fscache_n_updates_null;
52078 -extern atomic_t fscache_n_updates_run;
52079 +extern atomic_unchecked_t fscache_n_updates;
52080 +extern atomic_unchecked_t fscache_n_updates_null;
52081 +extern atomic_unchecked_t fscache_n_updates_run;
52082
52083 -extern atomic_t fscache_n_relinquishes;
52084 -extern atomic_t fscache_n_relinquishes_null;
52085 -extern atomic_t fscache_n_relinquishes_waitcrt;
52086 -extern atomic_t fscache_n_relinquishes_retire;
52087 +extern atomic_unchecked_t fscache_n_relinquishes;
52088 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52089 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52090 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52091
52092 -extern atomic_t fscache_n_cookie_index;
52093 -extern atomic_t fscache_n_cookie_data;
52094 -extern atomic_t fscache_n_cookie_special;
52095 +extern atomic_unchecked_t fscache_n_cookie_index;
52096 +extern atomic_unchecked_t fscache_n_cookie_data;
52097 +extern atomic_unchecked_t fscache_n_cookie_special;
52098
52099 -extern atomic_t fscache_n_object_alloc;
52100 -extern atomic_t fscache_n_object_no_alloc;
52101 -extern atomic_t fscache_n_object_lookups;
52102 -extern atomic_t fscache_n_object_lookups_negative;
52103 -extern atomic_t fscache_n_object_lookups_positive;
52104 -extern atomic_t fscache_n_object_lookups_timed_out;
52105 -extern atomic_t fscache_n_object_created;
52106 -extern atomic_t fscache_n_object_avail;
52107 -extern atomic_t fscache_n_object_dead;
52108 +extern atomic_unchecked_t fscache_n_object_alloc;
52109 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52110 +extern atomic_unchecked_t fscache_n_object_lookups;
52111 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52112 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52113 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52114 +extern atomic_unchecked_t fscache_n_object_created;
52115 +extern atomic_unchecked_t fscache_n_object_avail;
52116 +extern atomic_unchecked_t fscache_n_object_dead;
52117
52118 -extern atomic_t fscache_n_checkaux_none;
52119 -extern atomic_t fscache_n_checkaux_okay;
52120 -extern atomic_t fscache_n_checkaux_update;
52121 -extern atomic_t fscache_n_checkaux_obsolete;
52122 +extern atomic_unchecked_t fscache_n_checkaux_none;
52123 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52124 +extern atomic_unchecked_t fscache_n_checkaux_update;
52125 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52126
52127 extern atomic_t fscache_n_cop_alloc_object;
52128 extern atomic_t fscache_n_cop_lookup_object;
52129 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52130 atomic_inc(stat);
52131 }
52132
52133 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52134 +{
52135 + atomic_inc_unchecked(stat);
52136 +}
52137 +
52138 static inline void fscache_stat_d(atomic_t *stat)
52139 {
52140 atomic_dec(stat);
52141 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52142
52143 #define __fscache_stat(stat) (NULL)
52144 #define fscache_stat(stat) do {} while (0)
52145 +#define fscache_stat_unchecked(stat) do {} while (0)
52146 #define fscache_stat_d(stat) do {} while (0)
52147 #endif
52148
52149 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52150 index 50d41c1..10ee117 100644
52151 --- a/fs/fscache/object.c
52152 +++ b/fs/fscache/object.c
52153 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52154 /* Invalidate an object on disk */
52155 case FSCACHE_OBJECT_INVALIDATING:
52156 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52157 - fscache_stat(&fscache_n_invalidates_run);
52158 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52159 fscache_stat(&fscache_n_cop_invalidate_object);
52160 fscache_invalidate_object(object);
52161 fscache_stat_d(&fscache_n_cop_invalidate_object);
52162 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52163 /* update the object metadata on disk */
52164 case FSCACHE_OBJECT_UPDATING:
52165 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52166 - fscache_stat(&fscache_n_updates_run);
52167 + fscache_stat_unchecked(&fscache_n_updates_run);
52168 fscache_stat(&fscache_n_cop_update_object);
52169 object->cache->ops->update_object(object);
52170 fscache_stat_d(&fscache_n_cop_update_object);
52171 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52172 spin_lock(&object->lock);
52173 object->state = FSCACHE_OBJECT_DEAD;
52174 spin_unlock(&object->lock);
52175 - fscache_stat(&fscache_n_object_dead);
52176 + fscache_stat_unchecked(&fscache_n_object_dead);
52177 goto terminal_transit;
52178
52179 /* handle the parent cache of this object being withdrawn from
52180 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52181 spin_lock(&object->lock);
52182 object->state = FSCACHE_OBJECT_DEAD;
52183 spin_unlock(&object->lock);
52184 - fscache_stat(&fscache_n_object_dead);
52185 + fscache_stat_unchecked(&fscache_n_object_dead);
52186 goto terminal_transit;
52187
52188 /* complain about the object being woken up once it is
52189 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52190 parent->cookie->def->name, cookie->def->name,
52191 object->cache->tag->name);
52192
52193 - fscache_stat(&fscache_n_object_lookups);
52194 + fscache_stat_unchecked(&fscache_n_object_lookups);
52195 fscache_stat(&fscache_n_cop_lookup_object);
52196 ret = object->cache->ops->lookup_object(object);
52197 fscache_stat_d(&fscache_n_cop_lookup_object);
52198 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52199 if (ret == -ETIMEDOUT) {
52200 /* probably stuck behind another object, so move this one to
52201 * the back of the queue */
52202 - fscache_stat(&fscache_n_object_lookups_timed_out);
52203 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52204 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52205 }
52206
52207 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52208
52209 spin_lock(&object->lock);
52210 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52211 - fscache_stat(&fscache_n_object_lookups_negative);
52212 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52213
52214 /* transit here to allow write requests to begin stacking up
52215 * and read requests to begin returning ENODATA */
52216 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52217 * result, in which case there may be data available */
52218 spin_lock(&object->lock);
52219 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52220 - fscache_stat(&fscache_n_object_lookups_positive);
52221 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52222
52223 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52224
52225 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52226 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52227 } else {
52228 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52229 - fscache_stat(&fscache_n_object_created);
52230 + fscache_stat_unchecked(&fscache_n_object_created);
52231
52232 object->state = FSCACHE_OBJECT_AVAILABLE;
52233 spin_unlock(&object->lock);
52234 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52235 fscache_enqueue_dependents(object);
52236
52237 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52238 - fscache_stat(&fscache_n_object_avail);
52239 + fscache_stat_unchecked(&fscache_n_object_avail);
52240
52241 _leave("");
52242 }
52243 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52244 enum fscache_checkaux result;
52245
52246 if (!object->cookie->def->check_aux) {
52247 - fscache_stat(&fscache_n_checkaux_none);
52248 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52249 return FSCACHE_CHECKAUX_OKAY;
52250 }
52251
52252 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52253 switch (result) {
52254 /* entry okay as is */
52255 case FSCACHE_CHECKAUX_OKAY:
52256 - fscache_stat(&fscache_n_checkaux_okay);
52257 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52258 break;
52259
52260 /* entry requires update */
52261 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52262 - fscache_stat(&fscache_n_checkaux_update);
52263 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52264 break;
52265
52266 /* entry requires deletion */
52267 case FSCACHE_CHECKAUX_OBSOLETE:
52268 - fscache_stat(&fscache_n_checkaux_obsolete);
52269 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52270 break;
52271
52272 default:
52273 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52274 index 762a9ec..2023284 100644
52275 --- a/fs/fscache/operation.c
52276 +++ b/fs/fscache/operation.c
52277 @@ -17,7 +17,7 @@
52278 #include <linux/slab.h>
52279 #include "internal.h"
52280
52281 -atomic_t fscache_op_debug_id;
52282 +atomic_unchecked_t fscache_op_debug_id;
52283 EXPORT_SYMBOL(fscache_op_debug_id);
52284
52285 /**
52286 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52287 ASSERTCMP(atomic_read(&op->usage), >, 0);
52288 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52289
52290 - fscache_stat(&fscache_n_op_enqueue);
52291 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52292 switch (op->flags & FSCACHE_OP_TYPE) {
52293 case FSCACHE_OP_ASYNC:
52294 _debug("queue async");
52295 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52296 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52297 if (op->processor)
52298 fscache_enqueue_operation(op);
52299 - fscache_stat(&fscache_n_op_run);
52300 + fscache_stat_unchecked(&fscache_n_op_run);
52301 }
52302
52303 /*
52304 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52305 if (object->n_in_progress > 0) {
52306 atomic_inc(&op->usage);
52307 list_add_tail(&op->pend_link, &object->pending_ops);
52308 - fscache_stat(&fscache_n_op_pend);
52309 + fscache_stat_unchecked(&fscache_n_op_pend);
52310 } else if (!list_empty(&object->pending_ops)) {
52311 atomic_inc(&op->usage);
52312 list_add_tail(&op->pend_link, &object->pending_ops);
52313 - fscache_stat(&fscache_n_op_pend);
52314 + fscache_stat_unchecked(&fscache_n_op_pend);
52315 fscache_start_operations(object);
52316 } else {
52317 ASSERTCMP(object->n_in_progress, ==, 0);
52318 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52319 object->n_exclusive++; /* reads and writes must wait */
52320 atomic_inc(&op->usage);
52321 list_add_tail(&op->pend_link, &object->pending_ops);
52322 - fscache_stat(&fscache_n_op_pend);
52323 + fscache_stat_unchecked(&fscache_n_op_pend);
52324 ret = 0;
52325 } else {
52326 /* If we're in any other state, there must have been an I/O
52327 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52328 if (object->n_exclusive > 0) {
52329 atomic_inc(&op->usage);
52330 list_add_tail(&op->pend_link, &object->pending_ops);
52331 - fscache_stat(&fscache_n_op_pend);
52332 + fscache_stat_unchecked(&fscache_n_op_pend);
52333 } else if (!list_empty(&object->pending_ops)) {
52334 atomic_inc(&op->usage);
52335 list_add_tail(&op->pend_link, &object->pending_ops);
52336 - fscache_stat(&fscache_n_op_pend);
52337 + fscache_stat_unchecked(&fscache_n_op_pend);
52338 fscache_start_operations(object);
52339 } else {
52340 ASSERTCMP(object->n_exclusive, ==, 0);
52341 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52342 object->n_ops++;
52343 atomic_inc(&op->usage);
52344 list_add_tail(&op->pend_link, &object->pending_ops);
52345 - fscache_stat(&fscache_n_op_pend);
52346 + fscache_stat_unchecked(&fscache_n_op_pend);
52347 ret = 0;
52348 } else if (object->state == FSCACHE_OBJECT_DYING ||
52349 object->state == FSCACHE_OBJECT_LC_DYING ||
52350 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52351 - fscache_stat(&fscache_n_op_rejected);
52352 + fscache_stat_unchecked(&fscache_n_op_rejected);
52353 op->state = FSCACHE_OP_ST_CANCELLED;
52354 ret = -ENOBUFS;
52355 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52356 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52357 ret = -EBUSY;
52358 if (op->state == FSCACHE_OP_ST_PENDING) {
52359 ASSERT(!list_empty(&op->pend_link));
52360 - fscache_stat(&fscache_n_op_cancelled);
52361 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52362 list_del_init(&op->pend_link);
52363 if (do_cancel)
52364 do_cancel(op);
52365 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52366 while (!list_empty(&object->pending_ops)) {
52367 op = list_entry(object->pending_ops.next,
52368 struct fscache_operation, pend_link);
52369 - fscache_stat(&fscache_n_op_cancelled);
52370 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52371 list_del_init(&op->pend_link);
52372
52373 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52374 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52375 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52376 op->state = FSCACHE_OP_ST_DEAD;
52377
52378 - fscache_stat(&fscache_n_op_release);
52379 + fscache_stat_unchecked(&fscache_n_op_release);
52380
52381 if (op->release) {
52382 op->release(op);
52383 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52384 * lock, and defer it otherwise */
52385 if (!spin_trylock(&object->lock)) {
52386 _debug("defer put");
52387 - fscache_stat(&fscache_n_op_deferred_release);
52388 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52389
52390 cache = object->cache;
52391 spin_lock(&cache->op_gc_list_lock);
52392 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52393
52394 _debug("GC DEFERRED REL OBJ%x OP%x",
52395 object->debug_id, op->debug_id);
52396 - fscache_stat(&fscache_n_op_gc);
52397 + fscache_stat_unchecked(&fscache_n_op_gc);
52398
52399 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52400 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52401 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52402 index ff000e5..c44ec6d 100644
52403 --- a/fs/fscache/page.c
52404 +++ b/fs/fscache/page.c
52405 @@ -61,7 +61,7 @@ try_again:
52406 val = radix_tree_lookup(&cookie->stores, page->index);
52407 if (!val) {
52408 rcu_read_unlock();
52409 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52410 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52411 __fscache_uncache_page(cookie, page);
52412 return true;
52413 }
52414 @@ -91,11 +91,11 @@ try_again:
52415 spin_unlock(&cookie->stores_lock);
52416
52417 if (xpage) {
52418 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52419 - fscache_stat(&fscache_n_store_radix_deletes);
52420 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52421 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52422 ASSERTCMP(xpage, ==, page);
52423 } else {
52424 - fscache_stat(&fscache_n_store_vmscan_gone);
52425 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52426 }
52427
52428 wake_up_bit(&cookie->flags, 0);
52429 @@ -110,11 +110,11 @@ page_busy:
52430 * sleeping on memory allocation, so we may need to impose a timeout
52431 * too. */
52432 if (!(gfp & __GFP_WAIT)) {
52433 - fscache_stat(&fscache_n_store_vmscan_busy);
52434 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52435 return false;
52436 }
52437
52438 - fscache_stat(&fscache_n_store_vmscan_wait);
52439 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52440 __fscache_wait_on_page_write(cookie, page);
52441 gfp &= ~__GFP_WAIT;
52442 goto try_again;
52443 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52444 FSCACHE_COOKIE_STORING_TAG);
52445 if (!radix_tree_tag_get(&cookie->stores, page->index,
52446 FSCACHE_COOKIE_PENDING_TAG)) {
52447 - fscache_stat(&fscache_n_store_radix_deletes);
52448 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52449 xpage = radix_tree_delete(&cookie->stores, page->index);
52450 }
52451 spin_unlock(&cookie->stores_lock);
52452 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52453
52454 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52455
52456 - fscache_stat(&fscache_n_attr_changed_calls);
52457 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52458
52459 if (fscache_object_is_active(object)) {
52460 fscache_stat(&fscache_n_cop_attr_changed);
52461 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52462
52463 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52464
52465 - fscache_stat(&fscache_n_attr_changed);
52466 + fscache_stat_unchecked(&fscache_n_attr_changed);
52467
52468 op = kzalloc(sizeof(*op), GFP_KERNEL);
52469 if (!op) {
52470 - fscache_stat(&fscache_n_attr_changed_nomem);
52471 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52472 _leave(" = -ENOMEM");
52473 return -ENOMEM;
52474 }
52475 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52476 if (fscache_submit_exclusive_op(object, op) < 0)
52477 goto nobufs;
52478 spin_unlock(&cookie->lock);
52479 - fscache_stat(&fscache_n_attr_changed_ok);
52480 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52481 fscache_put_operation(op);
52482 _leave(" = 0");
52483 return 0;
52484 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52485 nobufs:
52486 spin_unlock(&cookie->lock);
52487 kfree(op);
52488 - fscache_stat(&fscache_n_attr_changed_nobufs);
52489 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52490 _leave(" = %d", -ENOBUFS);
52491 return -ENOBUFS;
52492 }
52493 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52494 /* allocate a retrieval operation and attempt to submit it */
52495 op = kzalloc(sizeof(*op), GFP_NOIO);
52496 if (!op) {
52497 - fscache_stat(&fscache_n_retrievals_nomem);
52498 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52499 return NULL;
52500 }
52501
52502 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52503 return 0;
52504 }
52505
52506 - fscache_stat(&fscache_n_retrievals_wait);
52507 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52508
52509 jif = jiffies;
52510 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52511 fscache_wait_bit_interruptible,
52512 TASK_INTERRUPTIBLE) != 0) {
52513 - fscache_stat(&fscache_n_retrievals_intr);
52514 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52515 _leave(" = -ERESTARTSYS");
52516 return -ERESTARTSYS;
52517 }
52518 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52519 */
52520 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52521 struct fscache_retrieval *op,
52522 - atomic_t *stat_op_waits,
52523 - atomic_t *stat_object_dead)
52524 + atomic_unchecked_t *stat_op_waits,
52525 + atomic_unchecked_t *stat_object_dead)
52526 {
52527 int ret;
52528
52529 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52530 goto check_if_dead;
52531
52532 _debug(">>> WT");
52533 - fscache_stat(stat_op_waits);
52534 + fscache_stat_unchecked(stat_op_waits);
52535 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52536 fscache_wait_bit_interruptible,
52537 TASK_INTERRUPTIBLE) != 0) {
52538 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52539
52540 check_if_dead:
52541 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52542 - fscache_stat(stat_object_dead);
52543 + fscache_stat_unchecked(stat_object_dead);
52544 _leave(" = -ENOBUFS [cancelled]");
52545 return -ENOBUFS;
52546 }
52547 if (unlikely(fscache_object_is_dead(object))) {
52548 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52549 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52550 - fscache_stat(stat_object_dead);
52551 + fscache_stat_unchecked(stat_object_dead);
52552 return -ENOBUFS;
52553 }
52554 return 0;
52555 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52556
52557 _enter("%p,%p,,,", cookie, page);
52558
52559 - fscache_stat(&fscache_n_retrievals);
52560 + fscache_stat_unchecked(&fscache_n_retrievals);
52561
52562 if (hlist_empty(&cookie->backing_objects))
52563 goto nobufs;
52564 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52565 goto nobufs_unlock_dec;
52566 spin_unlock(&cookie->lock);
52567
52568 - fscache_stat(&fscache_n_retrieval_ops);
52569 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52570
52571 /* pin the netfs read context in case we need to do the actual netfs
52572 * read because we've encountered a cache read failure */
52573 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52574
52575 error:
52576 if (ret == -ENOMEM)
52577 - fscache_stat(&fscache_n_retrievals_nomem);
52578 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52579 else if (ret == -ERESTARTSYS)
52580 - fscache_stat(&fscache_n_retrievals_intr);
52581 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52582 else if (ret == -ENODATA)
52583 - fscache_stat(&fscache_n_retrievals_nodata);
52584 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52585 else if (ret < 0)
52586 - fscache_stat(&fscache_n_retrievals_nobufs);
52587 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52588 else
52589 - fscache_stat(&fscache_n_retrievals_ok);
52590 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52591
52592 fscache_put_retrieval(op);
52593 _leave(" = %d", ret);
52594 @@ -467,7 +467,7 @@ nobufs_unlock:
52595 spin_unlock(&cookie->lock);
52596 kfree(op);
52597 nobufs:
52598 - fscache_stat(&fscache_n_retrievals_nobufs);
52599 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52600 _leave(" = -ENOBUFS");
52601 return -ENOBUFS;
52602 }
52603 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52604
52605 _enter("%p,,%d,,,", cookie, *nr_pages);
52606
52607 - fscache_stat(&fscache_n_retrievals);
52608 + fscache_stat_unchecked(&fscache_n_retrievals);
52609
52610 if (hlist_empty(&cookie->backing_objects))
52611 goto nobufs;
52612 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52613 goto nobufs_unlock_dec;
52614 spin_unlock(&cookie->lock);
52615
52616 - fscache_stat(&fscache_n_retrieval_ops);
52617 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52618
52619 /* pin the netfs read context in case we need to do the actual netfs
52620 * read because we've encountered a cache read failure */
52621 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52622
52623 error:
52624 if (ret == -ENOMEM)
52625 - fscache_stat(&fscache_n_retrievals_nomem);
52626 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52627 else if (ret == -ERESTARTSYS)
52628 - fscache_stat(&fscache_n_retrievals_intr);
52629 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52630 else if (ret == -ENODATA)
52631 - fscache_stat(&fscache_n_retrievals_nodata);
52632 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52633 else if (ret < 0)
52634 - fscache_stat(&fscache_n_retrievals_nobufs);
52635 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52636 else
52637 - fscache_stat(&fscache_n_retrievals_ok);
52638 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52639
52640 fscache_put_retrieval(op);
52641 _leave(" = %d", ret);
52642 @@ -591,7 +591,7 @@ nobufs_unlock:
52643 spin_unlock(&cookie->lock);
52644 kfree(op);
52645 nobufs:
52646 - fscache_stat(&fscache_n_retrievals_nobufs);
52647 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52648 _leave(" = -ENOBUFS");
52649 return -ENOBUFS;
52650 }
52651 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52652
52653 _enter("%p,%p,,,", cookie, page);
52654
52655 - fscache_stat(&fscache_n_allocs);
52656 + fscache_stat_unchecked(&fscache_n_allocs);
52657
52658 if (hlist_empty(&cookie->backing_objects))
52659 goto nobufs;
52660 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52661 goto nobufs_unlock;
52662 spin_unlock(&cookie->lock);
52663
52664 - fscache_stat(&fscache_n_alloc_ops);
52665 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52666
52667 ret = fscache_wait_for_retrieval_activation(
52668 object, op,
52669 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52670
52671 error:
52672 if (ret == -ERESTARTSYS)
52673 - fscache_stat(&fscache_n_allocs_intr);
52674 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52675 else if (ret < 0)
52676 - fscache_stat(&fscache_n_allocs_nobufs);
52677 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52678 else
52679 - fscache_stat(&fscache_n_allocs_ok);
52680 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52681
52682 fscache_put_retrieval(op);
52683 _leave(" = %d", ret);
52684 @@ -677,7 +677,7 @@ nobufs_unlock:
52685 spin_unlock(&cookie->lock);
52686 kfree(op);
52687 nobufs:
52688 - fscache_stat(&fscache_n_allocs_nobufs);
52689 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52690 _leave(" = -ENOBUFS");
52691 return -ENOBUFS;
52692 }
52693 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52694
52695 spin_lock(&cookie->stores_lock);
52696
52697 - fscache_stat(&fscache_n_store_calls);
52698 + fscache_stat_unchecked(&fscache_n_store_calls);
52699
52700 /* find a page to store */
52701 page = NULL;
52702 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52703 page = results[0];
52704 _debug("gang %d [%lx]", n, page->index);
52705 if (page->index > op->store_limit) {
52706 - fscache_stat(&fscache_n_store_pages_over_limit);
52707 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52708 goto superseded;
52709 }
52710
52711 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52712 spin_unlock(&cookie->stores_lock);
52713 spin_unlock(&object->lock);
52714
52715 - fscache_stat(&fscache_n_store_pages);
52716 + fscache_stat_unchecked(&fscache_n_store_pages);
52717 fscache_stat(&fscache_n_cop_write_page);
52718 ret = object->cache->ops->write_page(op, page);
52719 fscache_stat_d(&fscache_n_cop_write_page);
52720 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52721 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52722 ASSERT(PageFsCache(page));
52723
52724 - fscache_stat(&fscache_n_stores);
52725 + fscache_stat_unchecked(&fscache_n_stores);
52726
52727 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52728 _leave(" = -ENOBUFS [invalidating]");
52729 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52730 spin_unlock(&cookie->stores_lock);
52731 spin_unlock(&object->lock);
52732
52733 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52734 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52735 op->store_limit = object->store_limit;
52736
52737 if (fscache_submit_op(object, &op->op) < 0)
52738 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52739
52740 spin_unlock(&cookie->lock);
52741 radix_tree_preload_end();
52742 - fscache_stat(&fscache_n_store_ops);
52743 - fscache_stat(&fscache_n_stores_ok);
52744 + fscache_stat_unchecked(&fscache_n_store_ops);
52745 + fscache_stat_unchecked(&fscache_n_stores_ok);
52746
52747 /* the work queue now carries its own ref on the object */
52748 fscache_put_operation(&op->op);
52749 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52750 return 0;
52751
52752 already_queued:
52753 - fscache_stat(&fscache_n_stores_again);
52754 + fscache_stat_unchecked(&fscache_n_stores_again);
52755 already_pending:
52756 spin_unlock(&cookie->stores_lock);
52757 spin_unlock(&object->lock);
52758 spin_unlock(&cookie->lock);
52759 radix_tree_preload_end();
52760 kfree(op);
52761 - fscache_stat(&fscache_n_stores_ok);
52762 + fscache_stat_unchecked(&fscache_n_stores_ok);
52763 _leave(" = 0");
52764 return 0;
52765
52766 @@ -959,14 +959,14 @@ nobufs:
52767 spin_unlock(&cookie->lock);
52768 radix_tree_preload_end();
52769 kfree(op);
52770 - fscache_stat(&fscache_n_stores_nobufs);
52771 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52772 _leave(" = -ENOBUFS");
52773 return -ENOBUFS;
52774
52775 nomem_free:
52776 kfree(op);
52777 nomem:
52778 - fscache_stat(&fscache_n_stores_oom);
52779 + fscache_stat_unchecked(&fscache_n_stores_oom);
52780 _leave(" = -ENOMEM");
52781 return -ENOMEM;
52782 }
52783 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52784 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52785 ASSERTCMP(page, !=, NULL);
52786
52787 - fscache_stat(&fscache_n_uncaches);
52788 + fscache_stat_unchecked(&fscache_n_uncaches);
52789
52790 /* cache withdrawal may beat us to it */
52791 if (!PageFsCache(page))
52792 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52793 struct fscache_cookie *cookie = op->op.object->cookie;
52794
52795 #ifdef CONFIG_FSCACHE_STATS
52796 - atomic_inc(&fscache_n_marks);
52797 + atomic_inc_unchecked(&fscache_n_marks);
52798 #endif
52799
52800 _debug("- mark %p{%lx}", page, page->index);
52801 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52802 index 40d13c7..ddf52b9 100644
52803 --- a/fs/fscache/stats.c
52804 +++ b/fs/fscache/stats.c
52805 @@ -18,99 +18,99 @@
52806 /*
52807 * operation counters
52808 */
52809 -atomic_t fscache_n_op_pend;
52810 -atomic_t fscache_n_op_run;
52811 -atomic_t fscache_n_op_enqueue;
52812 -atomic_t fscache_n_op_requeue;
52813 -atomic_t fscache_n_op_deferred_release;
52814 -atomic_t fscache_n_op_release;
52815 -atomic_t fscache_n_op_gc;
52816 -atomic_t fscache_n_op_cancelled;
52817 -atomic_t fscache_n_op_rejected;
52818 +atomic_unchecked_t fscache_n_op_pend;
52819 +atomic_unchecked_t fscache_n_op_run;
52820 +atomic_unchecked_t fscache_n_op_enqueue;
52821 +atomic_unchecked_t fscache_n_op_requeue;
52822 +atomic_unchecked_t fscache_n_op_deferred_release;
52823 +atomic_unchecked_t fscache_n_op_release;
52824 +atomic_unchecked_t fscache_n_op_gc;
52825 +atomic_unchecked_t fscache_n_op_cancelled;
52826 +atomic_unchecked_t fscache_n_op_rejected;
52827
52828 -atomic_t fscache_n_attr_changed;
52829 -atomic_t fscache_n_attr_changed_ok;
52830 -atomic_t fscache_n_attr_changed_nobufs;
52831 -atomic_t fscache_n_attr_changed_nomem;
52832 -atomic_t fscache_n_attr_changed_calls;
52833 +atomic_unchecked_t fscache_n_attr_changed;
52834 +atomic_unchecked_t fscache_n_attr_changed_ok;
52835 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52836 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52837 +atomic_unchecked_t fscache_n_attr_changed_calls;
52838
52839 -atomic_t fscache_n_allocs;
52840 -atomic_t fscache_n_allocs_ok;
52841 -atomic_t fscache_n_allocs_wait;
52842 -atomic_t fscache_n_allocs_nobufs;
52843 -atomic_t fscache_n_allocs_intr;
52844 -atomic_t fscache_n_allocs_object_dead;
52845 -atomic_t fscache_n_alloc_ops;
52846 -atomic_t fscache_n_alloc_op_waits;
52847 +atomic_unchecked_t fscache_n_allocs;
52848 +atomic_unchecked_t fscache_n_allocs_ok;
52849 +atomic_unchecked_t fscache_n_allocs_wait;
52850 +atomic_unchecked_t fscache_n_allocs_nobufs;
52851 +atomic_unchecked_t fscache_n_allocs_intr;
52852 +atomic_unchecked_t fscache_n_allocs_object_dead;
52853 +atomic_unchecked_t fscache_n_alloc_ops;
52854 +atomic_unchecked_t fscache_n_alloc_op_waits;
52855
52856 -atomic_t fscache_n_retrievals;
52857 -atomic_t fscache_n_retrievals_ok;
52858 -atomic_t fscache_n_retrievals_wait;
52859 -atomic_t fscache_n_retrievals_nodata;
52860 -atomic_t fscache_n_retrievals_nobufs;
52861 -atomic_t fscache_n_retrievals_intr;
52862 -atomic_t fscache_n_retrievals_nomem;
52863 -atomic_t fscache_n_retrievals_object_dead;
52864 -atomic_t fscache_n_retrieval_ops;
52865 -atomic_t fscache_n_retrieval_op_waits;
52866 +atomic_unchecked_t fscache_n_retrievals;
52867 +atomic_unchecked_t fscache_n_retrievals_ok;
52868 +atomic_unchecked_t fscache_n_retrievals_wait;
52869 +atomic_unchecked_t fscache_n_retrievals_nodata;
52870 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52871 +atomic_unchecked_t fscache_n_retrievals_intr;
52872 +atomic_unchecked_t fscache_n_retrievals_nomem;
52873 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52874 +atomic_unchecked_t fscache_n_retrieval_ops;
52875 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52876
52877 -atomic_t fscache_n_stores;
52878 -atomic_t fscache_n_stores_ok;
52879 -atomic_t fscache_n_stores_again;
52880 -atomic_t fscache_n_stores_nobufs;
52881 -atomic_t fscache_n_stores_oom;
52882 -atomic_t fscache_n_store_ops;
52883 -atomic_t fscache_n_store_calls;
52884 -atomic_t fscache_n_store_pages;
52885 -atomic_t fscache_n_store_radix_deletes;
52886 -atomic_t fscache_n_store_pages_over_limit;
52887 +atomic_unchecked_t fscache_n_stores;
52888 +atomic_unchecked_t fscache_n_stores_ok;
52889 +atomic_unchecked_t fscache_n_stores_again;
52890 +atomic_unchecked_t fscache_n_stores_nobufs;
52891 +atomic_unchecked_t fscache_n_stores_oom;
52892 +atomic_unchecked_t fscache_n_store_ops;
52893 +atomic_unchecked_t fscache_n_store_calls;
52894 +atomic_unchecked_t fscache_n_store_pages;
52895 +atomic_unchecked_t fscache_n_store_radix_deletes;
52896 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52897
52898 -atomic_t fscache_n_store_vmscan_not_storing;
52899 -atomic_t fscache_n_store_vmscan_gone;
52900 -atomic_t fscache_n_store_vmscan_busy;
52901 -atomic_t fscache_n_store_vmscan_cancelled;
52902 -atomic_t fscache_n_store_vmscan_wait;
52903 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52904 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52905 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52906 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52907 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52908
52909 -atomic_t fscache_n_marks;
52910 -atomic_t fscache_n_uncaches;
52911 +atomic_unchecked_t fscache_n_marks;
52912 +atomic_unchecked_t fscache_n_uncaches;
52913
52914 -atomic_t fscache_n_acquires;
52915 -atomic_t fscache_n_acquires_null;
52916 -atomic_t fscache_n_acquires_no_cache;
52917 -atomic_t fscache_n_acquires_ok;
52918 -atomic_t fscache_n_acquires_nobufs;
52919 -atomic_t fscache_n_acquires_oom;
52920 +atomic_unchecked_t fscache_n_acquires;
52921 +atomic_unchecked_t fscache_n_acquires_null;
52922 +atomic_unchecked_t fscache_n_acquires_no_cache;
52923 +atomic_unchecked_t fscache_n_acquires_ok;
52924 +atomic_unchecked_t fscache_n_acquires_nobufs;
52925 +atomic_unchecked_t fscache_n_acquires_oom;
52926
52927 -atomic_t fscache_n_invalidates;
52928 -atomic_t fscache_n_invalidates_run;
52929 +atomic_unchecked_t fscache_n_invalidates;
52930 +atomic_unchecked_t fscache_n_invalidates_run;
52931
52932 -atomic_t fscache_n_updates;
52933 -atomic_t fscache_n_updates_null;
52934 -atomic_t fscache_n_updates_run;
52935 +atomic_unchecked_t fscache_n_updates;
52936 +atomic_unchecked_t fscache_n_updates_null;
52937 +atomic_unchecked_t fscache_n_updates_run;
52938
52939 -atomic_t fscache_n_relinquishes;
52940 -atomic_t fscache_n_relinquishes_null;
52941 -atomic_t fscache_n_relinquishes_waitcrt;
52942 -atomic_t fscache_n_relinquishes_retire;
52943 +atomic_unchecked_t fscache_n_relinquishes;
52944 +atomic_unchecked_t fscache_n_relinquishes_null;
52945 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52946 +atomic_unchecked_t fscache_n_relinquishes_retire;
52947
52948 -atomic_t fscache_n_cookie_index;
52949 -atomic_t fscache_n_cookie_data;
52950 -atomic_t fscache_n_cookie_special;
52951 +atomic_unchecked_t fscache_n_cookie_index;
52952 +atomic_unchecked_t fscache_n_cookie_data;
52953 +atomic_unchecked_t fscache_n_cookie_special;
52954
52955 -atomic_t fscache_n_object_alloc;
52956 -atomic_t fscache_n_object_no_alloc;
52957 -atomic_t fscache_n_object_lookups;
52958 -atomic_t fscache_n_object_lookups_negative;
52959 -atomic_t fscache_n_object_lookups_positive;
52960 -atomic_t fscache_n_object_lookups_timed_out;
52961 -atomic_t fscache_n_object_created;
52962 -atomic_t fscache_n_object_avail;
52963 -atomic_t fscache_n_object_dead;
52964 +atomic_unchecked_t fscache_n_object_alloc;
52965 +atomic_unchecked_t fscache_n_object_no_alloc;
52966 +atomic_unchecked_t fscache_n_object_lookups;
52967 +atomic_unchecked_t fscache_n_object_lookups_negative;
52968 +atomic_unchecked_t fscache_n_object_lookups_positive;
52969 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52970 +atomic_unchecked_t fscache_n_object_created;
52971 +atomic_unchecked_t fscache_n_object_avail;
52972 +atomic_unchecked_t fscache_n_object_dead;
52973
52974 -atomic_t fscache_n_checkaux_none;
52975 -atomic_t fscache_n_checkaux_okay;
52976 -atomic_t fscache_n_checkaux_update;
52977 -atomic_t fscache_n_checkaux_obsolete;
52978 +atomic_unchecked_t fscache_n_checkaux_none;
52979 +atomic_unchecked_t fscache_n_checkaux_okay;
52980 +atomic_unchecked_t fscache_n_checkaux_update;
52981 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52982
52983 atomic_t fscache_n_cop_alloc_object;
52984 atomic_t fscache_n_cop_lookup_object;
52985 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52986 seq_puts(m, "FS-Cache statistics\n");
52987
52988 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52989 - atomic_read(&fscache_n_cookie_index),
52990 - atomic_read(&fscache_n_cookie_data),
52991 - atomic_read(&fscache_n_cookie_special));
52992 + atomic_read_unchecked(&fscache_n_cookie_index),
52993 + atomic_read_unchecked(&fscache_n_cookie_data),
52994 + atomic_read_unchecked(&fscache_n_cookie_special));
52995
52996 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52997 - atomic_read(&fscache_n_object_alloc),
52998 - atomic_read(&fscache_n_object_no_alloc),
52999 - atomic_read(&fscache_n_object_avail),
53000 - atomic_read(&fscache_n_object_dead));
53001 + atomic_read_unchecked(&fscache_n_object_alloc),
53002 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53003 + atomic_read_unchecked(&fscache_n_object_avail),
53004 + atomic_read_unchecked(&fscache_n_object_dead));
53005 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53006 - atomic_read(&fscache_n_checkaux_none),
53007 - atomic_read(&fscache_n_checkaux_okay),
53008 - atomic_read(&fscache_n_checkaux_update),
53009 - atomic_read(&fscache_n_checkaux_obsolete));
53010 + atomic_read_unchecked(&fscache_n_checkaux_none),
53011 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53012 + atomic_read_unchecked(&fscache_n_checkaux_update),
53013 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53014
53015 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53016 - atomic_read(&fscache_n_marks),
53017 - atomic_read(&fscache_n_uncaches));
53018 + atomic_read_unchecked(&fscache_n_marks),
53019 + atomic_read_unchecked(&fscache_n_uncaches));
53020
53021 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53022 " oom=%u\n",
53023 - atomic_read(&fscache_n_acquires),
53024 - atomic_read(&fscache_n_acquires_null),
53025 - atomic_read(&fscache_n_acquires_no_cache),
53026 - atomic_read(&fscache_n_acquires_ok),
53027 - atomic_read(&fscache_n_acquires_nobufs),
53028 - atomic_read(&fscache_n_acquires_oom));
53029 + atomic_read_unchecked(&fscache_n_acquires),
53030 + atomic_read_unchecked(&fscache_n_acquires_null),
53031 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53032 + atomic_read_unchecked(&fscache_n_acquires_ok),
53033 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53034 + atomic_read_unchecked(&fscache_n_acquires_oom));
53035
53036 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53037 - atomic_read(&fscache_n_object_lookups),
53038 - atomic_read(&fscache_n_object_lookups_negative),
53039 - atomic_read(&fscache_n_object_lookups_positive),
53040 - atomic_read(&fscache_n_object_created),
53041 - atomic_read(&fscache_n_object_lookups_timed_out));
53042 + atomic_read_unchecked(&fscache_n_object_lookups),
53043 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53044 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53045 + atomic_read_unchecked(&fscache_n_object_created),
53046 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53047
53048 seq_printf(m, "Invals : n=%u run=%u\n",
53049 - atomic_read(&fscache_n_invalidates),
53050 - atomic_read(&fscache_n_invalidates_run));
53051 + atomic_read_unchecked(&fscache_n_invalidates),
53052 + atomic_read_unchecked(&fscache_n_invalidates_run));
53053
53054 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53055 - atomic_read(&fscache_n_updates),
53056 - atomic_read(&fscache_n_updates_null),
53057 - atomic_read(&fscache_n_updates_run));
53058 + atomic_read_unchecked(&fscache_n_updates),
53059 + atomic_read_unchecked(&fscache_n_updates_null),
53060 + atomic_read_unchecked(&fscache_n_updates_run));
53061
53062 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53063 - atomic_read(&fscache_n_relinquishes),
53064 - atomic_read(&fscache_n_relinquishes_null),
53065 - atomic_read(&fscache_n_relinquishes_waitcrt),
53066 - atomic_read(&fscache_n_relinquishes_retire));
53067 + atomic_read_unchecked(&fscache_n_relinquishes),
53068 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53069 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53070 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53071
53072 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53073 - atomic_read(&fscache_n_attr_changed),
53074 - atomic_read(&fscache_n_attr_changed_ok),
53075 - atomic_read(&fscache_n_attr_changed_nobufs),
53076 - atomic_read(&fscache_n_attr_changed_nomem),
53077 - atomic_read(&fscache_n_attr_changed_calls));
53078 + atomic_read_unchecked(&fscache_n_attr_changed),
53079 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53080 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53081 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53082 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53083
53084 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53085 - atomic_read(&fscache_n_allocs),
53086 - atomic_read(&fscache_n_allocs_ok),
53087 - atomic_read(&fscache_n_allocs_wait),
53088 - atomic_read(&fscache_n_allocs_nobufs),
53089 - atomic_read(&fscache_n_allocs_intr));
53090 + atomic_read_unchecked(&fscache_n_allocs),
53091 + atomic_read_unchecked(&fscache_n_allocs_ok),
53092 + atomic_read_unchecked(&fscache_n_allocs_wait),
53093 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53094 + atomic_read_unchecked(&fscache_n_allocs_intr));
53095 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53096 - atomic_read(&fscache_n_alloc_ops),
53097 - atomic_read(&fscache_n_alloc_op_waits),
53098 - atomic_read(&fscache_n_allocs_object_dead));
53099 + atomic_read_unchecked(&fscache_n_alloc_ops),
53100 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53101 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53102
53103 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53104 " int=%u oom=%u\n",
53105 - atomic_read(&fscache_n_retrievals),
53106 - atomic_read(&fscache_n_retrievals_ok),
53107 - atomic_read(&fscache_n_retrievals_wait),
53108 - atomic_read(&fscache_n_retrievals_nodata),
53109 - atomic_read(&fscache_n_retrievals_nobufs),
53110 - atomic_read(&fscache_n_retrievals_intr),
53111 - atomic_read(&fscache_n_retrievals_nomem));
53112 + atomic_read_unchecked(&fscache_n_retrievals),
53113 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53114 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53115 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53116 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53117 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53118 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53119 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53120 - atomic_read(&fscache_n_retrieval_ops),
53121 - atomic_read(&fscache_n_retrieval_op_waits),
53122 - atomic_read(&fscache_n_retrievals_object_dead));
53123 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53124 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53125 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53126
53127 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53128 - atomic_read(&fscache_n_stores),
53129 - atomic_read(&fscache_n_stores_ok),
53130 - atomic_read(&fscache_n_stores_again),
53131 - atomic_read(&fscache_n_stores_nobufs),
53132 - atomic_read(&fscache_n_stores_oom));
53133 + atomic_read_unchecked(&fscache_n_stores),
53134 + atomic_read_unchecked(&fscache_n_stores_ok),
53135 + atomic_read_unchecked(&fscache_n_stores_again),
53136 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53137 + atomic_read_unchecked(&fscache_n_stores_oom));
53138 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53139 - atomic_read(&fscache_n_store_ops),
53140 - atomic_read(&fscache_n_store_calls),
53141 - atomic_read(&fscache_n_store_pages),
53142 - atomic_read(&fscache_n_store_radix_deletes),
53143 - atomic_read(&fscache_n_store_pages_over_limit));
53144 + atomic_read_unchecked(&fscache_n_store_ops),
53145 + atomic_read_unchecked(&fscache_n_store_calls),
53146 + atomic_read_unchecked(&fscache_n_store_pages),
53147 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53148 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53149
53150 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53151 - atomic_read(&fscache_n_store_vmscan_not_storing),
53152 - atomic_read(&fscache_n_store_vmscan_gone),
53153 - atomic_read(&fscache_n_store_vmscan_busy),
53154 - atomic_read(&fscache_n_store_vmscan_cancelled),
53155 - atomic_read(&fscache_n_store_vmscan_wait));
53156 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53157 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53158 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53159 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53160 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53161
53162 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53163 - atomic_read(&fscache_n_op_pend),
53164 - atomic_read(&fscache_n_op_run),
53165 - atomic_read(&fscache_n_op_enqueue),
53166 - atomic_read(&fscache_n_op_cancelled),
53167 - atomic_read(&fscache_n_op_rejected));
53168 + atomic_read_unchecked(&fscache_n_op_pend),
53169 + atomic_read_unchecked(&fscache_n_op_run),
53170 + atomic_read_unchecked(&fscache_n_op_enqueue),
53171 + atomic_read_unchecked(&fscache_n_op_cancelled),
53172 + atomic_read_unchecked(&fscache_n_op_rejected));
53173 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53174 - atomic_read(&fscache_n_op_deferred_release),
53175 - atomic_read(&fscache_n_op_release),
53176 - atomic_read(&fscache_n_op_gc));
53177 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53178 + atomic_read_unchecked(&fscache_n_op_release),
53179 + atomic_read_unchecked(&fscache_n_op_gc));
53180
53181 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53182 atomic_read(&fscache_n_cop_alloc_object),
53183 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53184 index 6f96a8d..6019bb9 100644
53185 --- a/fs/fuse/cuse.c
53186 +++ b/fs/fuse/cuse.c
53187 @@ -597,10 +597,12 @@ static int __init cuse_init(void)
53188 INIT_LIST_HEAD(&cuse_conntbl[i]);
53189
53190 /* inherit and extend fuse_dev_operations */
53191 - cuse_channel_fops = fuse_dev_operations;
53192 - cuse_channel_fops.owner = THIS_MODULE;
53193 - cuse_channel_fops.open = cuse_channel_open;
53194 - cuse_channel_fops.release = cuse_channel_release;
53195 + pax_open_kernel();
53196 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53197 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53198 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53199 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53200 + pax_close_kernel();
53201
53202 cuse_class = class_create(THIS_MODULE, "cuse");
53203 if (IS_ERR(cuse_class))
53204 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53205 index 11dfa0c..6f64416 100644
53206 --- a/fs/fuse/dev.c
53207 +++ b/fs/fuse/dev.c
53208 @@ -1294,7 +1294,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53209 ret = 0;
53210 pipe_lock(pipe);
53211
53212 - if (!pipe->readers) {
53213 + if (!atomic_read(&pipe->readers)) {
53214 send_sig(SIGPIPE, current, 0);
53215 if (!ret)
53216 ret = -EPIPE;
53217 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53218 index 185c479..51b9986 100644
53219 --- a/fs/fuse/dir.c
53220 +++ b/fs/fuse/dir.c
53221 @@ -1415,7 +1415,7 @@ static char *read_link(struct dentry *dentry)
53222 return link;
53223 }
53224
53225 -static void free_link(char *link)
53226 +static void free_link(const char *link)
53227 {
53228 if (!IS_ERR(link))
53229 free_page((unsigned long) link);
53230 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53231 index cc00bd1..3edb692 100644
53232 --- a/fs/gfs2/inode.c
53233 +++ b/fs/gfs2/inode.c
53234 @@ -1500,7 +1500,7 @@ out:
53235
53236 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53237 {
53238 - char *s = nd_get_link(nd);
53239 + const char *s = nd_get_link(nd);
53240 if (!IS_ERR(s))
53241 kfree(s);
53242 }
53243 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53244 index a3f868a..bb308ae 100644
53245 --- a/fs/hugetlbfs/inode.c
53246 +++ b/fs/hugetlbfs/inode.c
53247 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53248 struct mm_struct *mm = current->mm;
53249 struct vm_area_struct *vma;
53250 struct hstate *h = hstate_file(file);
53251 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53252 struct vm_unmapped_area_info info;
53253
53254 if (len & ~huge_page_mask(h))
53255 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53256 return addr;
53257 }
53258
53259 +#ifdef CONFIG_PAX_RANDMMAP
53260 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53261 +#endif
53262 +
53263 if (addr) {
53264 addr = ALIGN(addr, huge_page_size(h));
53265 vma = find_vma(mm, addr);
53266 - if (TASK_SIZE - len >= addr &&
53267 - (!vma || addr + len <= vma->vm_start))
53268 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53269 return addr;
53270 }
53271
53272 info.flags = 0;
53273 info.length = len;
53274 info.low_limit = TASK_UNMAPPED_BASE;
53275 +
53276 +#ifdef CONFIG_PAX_RANDMMAP
53277 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53278 + info.low_limit += mm->delta_mmap;
53279 +#endif
53280 +
53281 info.high_limit = TASK_SIZE;
53282 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53283 info.align_offset = 0;
53284 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53285 };
53286 MODULE_ALIAS_FS("hugetlbfs");
53287
53288 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53289 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53290
53291 static int can_do_hugetlb_shm(void)
53292 {
53293 diff --git a/fs/inode.c b/fs/inode.c
53294 index a898b3d..9b5a214 100644
53295 --- a/fs/inode.c
53296 +++ b/fs/inode.c
53297 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
53298
53299 #ifdef CONFIG_SMP
53300 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53301 - static atomic_t shared_last_ino;
53302 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53303 + static atomic_unchecked_t shared_last_ino;
53304 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53305
53306 res = next - LAST_INO_BATCH;
53307 }
53308 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53309 index 4a6cf28..d3a29d3 100644
53310 --- a/fs/jffs2/erase.c
53311 +++ b/fs/jffs2/erase.c
53312 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53313 struct jffs2_unknown_node marker = {
53314 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53315 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53316 - .totlen = cpu_to_je32(c->cleanmarker_size)
53317 + .totlen = cpu_to_je32(c->cleanmarker_size),
53318 + .hdr_crc = cpu_to_je32(0)
53319 };
53320
53321 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53322 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53323 index a6597d6..41b30ec 100644
53324 --- a/fs/jffs2/wbuf.c
53325 +++ b/fs/jffs2/wbuf.c
53326 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53327 {
53328 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53329 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53330 - .totlen = constant_cpu_to_je32(8)
53331 + .totlen = constant_cpu_to_je32(8),
53332 + .hdr_crc = constant_cpu_to_je32(0)
53333 };
53334
53335 /*
53336 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53337 index 2003e83..40db287 100644
53338 --- a/fs/jfs/super.c
53339 +++ b/fs/jfs/super.c
53340 @@ -856,7 +856,7 @@ static int __init init_jfs_fs(void)
53341
53342 jfs_inode_cachep =
53343 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53344 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53345 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53346 init_once);
53347 if (jfs_inode_cachep == NULL)
53348 return -ENOMEM;
53349 diff --git a/fs/libfs.c b/fs/libfs.c
53350 index 916da8c..1588998 100644
53351 --- a/fs/libfs.c
53352 +++ b/fs/libfs.c
53353 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53354
53355 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53356 struct dentry *next;
53357 + char d_name[sizeof(next->d_iname)];
53358 + const unsigned char *name;
53359 +
53360 next = list_entry(p, struct dentry, d_u.d_child);
53361 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53362 if (!simple_positive(next)) {
53363 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53364
53365 spin_unlock(&next->d_lock);
53366 spin_unlock(&dentry->d_lock);
53367 - if (filldir(dirent, next->d_name.name,
53368 + name = next->d_name.name;
53369 + if (name == next->d_iname) {
53370 + memcpy(d_name, name, next->d_name.len);
53371 + name = d_name;
53372 + }
53373 + if (filldir(dirent, name,
53374 next->d_name.len, filp->f_pos,
53375 next->d_inode->i_ino,
53376 dt_type(next->d_inode)) < 0)
53377 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53378 index 9760ecb..9b838ef 100644
53379 --- a/fs/lockd/clntproc.c
53380 +++ b/fs/lockd/clntproc.c
53381 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53382 /*
53383 * Cookie counter for NLM requests
53384 */
53385 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53386 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53387
53388 void nlmclnt_next_cookie(struct nlm_cookie *c)
53389 {
53390 - u32 cookie = atomic_inc_return(&nlm_cookie);
53391 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53392
53393 memcpy(c->data, &cookie, 4);
53394 c->len=4;
53395 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
53396 index a2aa97d..10d6c41 100644
53397 --- a/fs/lockd/svc.c
53398 +++ b/fs/lockd/svc.c
53399 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
53400 svc_sock_update_bufs(serv);
53401 serv->sv_maxconn = nlm_max_connections;
53402
53403 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
53404 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
53405 if (IS_ERR(nlmsvc_task)) {
53406 error = PTR_ERR(nlmsvc_task);
53407 printk(KERN_WARNING
53408 diff --git a/fs/locks.c b/fs/locks.c
53409 index cb424a4..850e4dd 100644
53410 --- a/fs/locks.c
53411 +++ b/fs/locks.c
53412 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53413 return;
53414
53415 if (filp->f_op && filp->f_op->flock) {
53416 - struct file_lock fl = {
53417 + struct file_lock flock = {
53418 .fl_pid = current->tgid,
53419 .fl_file = filp,
53420 .fl_flags = FL_FLOCK,
53421 .fl_type = F_UNLCK,
53422 .fl_end = OFFSET_MAX,
53423 };
53424 - filp->f_op->flock(filp, F_SETLKW, &fl);
53425 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53426 - fl.fl_ops->fl_release_private(&fl);
53427 + filp->f_op->flock(filp, F_SETLKW, &flock);
53428 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53429 + flock.fl_ops->fl_release_private(&flock);
53430 }
53431
53432 lock_flocks();
53433 diff --git a/fs/namei.c b/fs/namei.c
53434 index 85e40d1..b66744e 100644
53435 --- a/fs/namei.c
53436 +++ b/fs/namei.c
53437 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53438 if (ret != -EACCES)
53439 return ret;
53440
53441 +#ifdef CONFIG_GRKERNSEC
53442 + /* we'll block if we have to log due to a denied capability use */
53443 + if (mask & MAY_NOT_BLOCK)
53444 + return -ECHILD;
53445 +#endif
53446 +
53447 if (S_ISDIR(inode->i_mode)) {
53448 /* DACs are overridable for directories */
53449 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53450 - return 0;
53451 if (!(mask & MAY_WRITE))
53452 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53453 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53454 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53455 return 0;
53456 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53457 + return 0;
53458 return -EACCES;
53459 }
53460 /*
53461 + * Searching includes executable on directories, else just read.
53462 + */
53463 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53464 + if (mask == MAY_READ)
53465 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53466 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53467 + return 0;
53468 +
53469 + /*
53470 * Read/write DACs are always overridable.
53471 * Executable DACs are overridable when there is
53472 * at least one exec bit set.
53473 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53474 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53475 return 0;
53476
53477 - /*
53478 - * Searching includes executable on directories, else just read.
53479 - */
53480 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53481 - if (mask == MAY_READ)
53482 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53483 - return 0;
53484 -
53485 return -EACCES;
53486 }
53487
53488 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53489 {
53490 struct dentry *dentry = link->dentry;
53491 int error;
53492 - char *s;
53493 + const char *s;
53494
53495 BUG_ON(nd->flags & LOOKUP_RCU);
53496
53497 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53498 if (error)
53499 goto out_put_nd_path;
53500
53501 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53502 + dentry->d_inode, dentry, nd->path.mnt)) {
53503 + error = -EACCES;
53504 + goto out_put_nd_path;
53505 + }
53506 +
53507 nd->last_type = LAST_BIND;
53508 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53509 error = PTR_ERR(*p);
53510 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53511 if (res)
53512 break;
53513 res = walk_component(nd, path, LOOKUP_FOLLOW);
53514 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53515 + res = -EACCES;
53516 put_link(nd, &link, cookie);
53517 } while (res > 0);
53518
53519 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53520 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53521 {
53522 unsigned long a, b, adata, bdata, mask, hash, len;
53523 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53524 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53525
53526 hash = a = 0;
53527 len = -sizeof(unsigned long);
53528 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53529 if (err)
53530 break;
53531 err = lookup_last(nd, &path);
53532 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53533 + err = -EACCES;
53534 put_link(nd, &link, cookie);
53535 }
53536 }
53537 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53538 if (!err)
53539 err = complete_walk(nd);
53540
53541 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53542 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53543 + path_put(&nd->path);
53544 + err = -ENOENT;
53545 + }
53546 + }
53547 +
53548 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53549 if (!nd->inode->i_op->lookup) {
53550 path_put(&nd->path);
53551 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53552 retval = path_lookupat(dfd, name->name,
53553 flags | LOOKUP_REVAL, nd);
53554
53555 - if (likely(!retval))
53556 + if (likely(!retval)) {
53557 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53558 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53559 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53560 + path_put(&nd->path);
53561 + return -ENOENT;
53562 + }
53563 + }
53564 + }
53565 return retval;
53566 }
53567
53568 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53569 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53570 return -EPERM;
53571
53572 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53573 + return -EPERM;
53574 + if (gr_handle_rawio(inode))
53575 + return -EPERM;
53576 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53577 + return -EACCES;
53578 +
53579 return 0;
53580 }
53581
53582 @@ -2602,7 +2641,7 @@ looked_up:
53583 * cleared otherwise prior to returning.
53584 */
53585 static int lookup_open(struct nameidata *nd, struct path *path,
53586 - struct file *file,
53587 + struct path *link, struct file *file,
53588 const struct open_flags *op,
53589 bool got_write, int *opened)
53590 {
53591 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53592 /* Negative dentry, just create the file */
53593 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53594 umode_t mode = op->mode;
53595 +
53596 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53597 + error = -EACCES;
53598 + goto out_dput;
53599 + }
53600 +
53601 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53602 + error = -EACCES;
53603 + goto out_dput;
53604 + }
53605 +
53606 if (!IS_POSIXACL(dir->d_inode))
53607 mode &= ~current_umask();
53608 /*
53609 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53610 nd->flags & LOOKUP_EXCL);
53611 if (error)
53612 goto out_dput;
53613 + else
53614 + gr_handle_create(dentry, nd->path.mnt);
53615 }
53616 out_no_open:
53617 path->dentry = dentry;
53618 @@ -2672,7 +2724,7 @@ out_dput:
53619 /*
53620 * Handle the last step of open()
53621 */
53622 -static int do_last(struct nameidata *nd, struct path *path,
53623 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53624 struct file *file, const struct open_flags *op,
53625 int *opened, struct filename *name)
53626 {
53627 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53628 error = complete_walk(nd);
53629 if (error)
53630 return error;
53631 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53632 + error = -ENOENT;
53633 + goto out;
53634 + }
53635 audit_inode(name, nd->path.dentry, 0);
53636 if (open_flag & O_CREAT) {
53637 error = -EISDIR;
53638 goto out;
53639 }
53640 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53641 + error = -EACCES;
53642 + goto out;
53643 + }
53644 goto finish_open;
53645 case LAST_BIND:
53646 error = complete_walk(nd);
53647 if (error)
53648 return error;
53649 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53650 + error = -ENOENT;
53651 + goto out;
53652 + }
53653 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53654 + error = -EACCES;
53655 + goto out;
53656 + }
53657 audit_inode(name, dir, 0);
53658 goto finish_open;
53659 }
53660 @@ -2759,7 +2827,7 @@ retry_lookup:
53661 */
53662 }
53663 mutex_lock(&dir->d_inode->i_mutex);
53664 - error = lookup_open(nd, path, file, op, got_write, opened);
53665 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53666 mutex_unlock(&dir->d_inode->i_mutex);
53667
53668 if (error <= 0) {
53669 @@ -2783,11 +2851,28 @@ retry_lookup:
53670 goto finish_open_created;
53671 }
53672
53673 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53674 + error = -ENOENT;
53675 + goto exit_dput;
53676 + }
53677 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53678 + error = -EACCES;
53679 + goto exit_dput;
53680 + }
53681 +
53682 /*
53683 * create/update audit record if it already exists.
53684 */
53685 - if (path->dentry->d_inode)
53686 + if (path->dentry->d_inode) {
53687 + /* only check if O_CREAT is specified, all other checks need to go
53688 + into may_open */
53689 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53690 + error = -EACCES;
53691 + goto exit_dput;
53692 + }
53693 +
53694 audit_inode(name, path->dentry, 0);
53695 + }
53696
53697 /*
53698 * If atomic_open() acquired write access it is dropped now due to
53699 @@ -2828,6 +2913,11 @@ finish_lookup:
53700 }
53701 }
53702 BUG_ON(inode != path->dentry->d_inode);
53703 + /* if we're resolving a symlink to another symlink */
53704 + if (link && gr_handle_symlink_owner(link, inode)) {
53705 + error = -EACCES;
53706 + goto out;
53707 + }
53708 return 1;
53709 }
53710
53711 @@ -2837,7 +2927,6 @@ finish_lookup:
53712 save_parent.dentry = nd->path.dentry;
53713 save_parent.mnt = mntget(path->mnt);
53714 nd->path.dentry = path->dentry;
53715 -
53716 }
53717 nd->inode = inode;
53718 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53719 @@ -2846,6 +2935,16 @@ finish_lookup:
53720 path_put(&save_parent);
53721 return error;
53722 }
53723 +
53724 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53725 + error = -ENOENT;
53726 + goto out;
53727 + }
53728 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53729 + error = -EACCES;
53730 + goto out;
53731 + }
53732 +
53733 error = -EISDIR;
53734 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53735 goto out;
53736 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53737 if (unlikely(error))
53738 goto out;
53739
53740 - error = do_last(nd, &path, file, op, &opened, pathname);
53741 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53742 while (unlikely(error > 0)) { /* trailing symlink */
53743 struct path link = path;
53744 void *cookie;
53745 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53746 error = follow_link(&link, nd, &cookie);
53747 if (unlikely(error))
53748 break;
53749 - error = do_last(nd, &path, file, op, &opened, pathname);
53750 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53751 put_link(nd, &link, cookie);
53752 }
53753 out:
53754 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53755 goto unlock;
53756
53757 error = -EEXIST;
53758 - if (dentry->d_inode)
53759 + if (dentry->d_inode) {
53760 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53761 + error = -ENOENT;
53762 + }
53763 goto fail;
53764 + }
53765 /*
53766 * Special case - lookup gave negative, but... we had foo/bar/
53767 * From the vfs_mknod() POV we just have a negative dentry -
53768 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53769 }
53770 EXPORT_SYMBOL(user_path_create);
53771
53772 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53773 +{
53774 + struct filename *tmp = getname(pathname);
53775 + struct dentry *res;
53776 + if (IS_ERR(tmp))
53777 + return ERR_CAST(tmp);
53778 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53779 + if (IS_ERR(res))
53780 + putname(tmp);
53781 + else
53782 + *to = tmp;
53783 + return res;
53784 +}
53785 +
53786 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53787 {
53788 int error = may_create(dir, dentry);
53789 @@ -3177,6 +3294,17 @@ retry:
53790
53791 if (!IS_POSIXACL(path.dentry->d_inode))
53792 mode &= ~current_umask();
53793 +
53794 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53795 + error = -EPERM;
53796 + goto out;
53797 + }
53798 +
53799 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53800 + error = -EACCES;
53801 + goto out;
53802 + }
53803 +
53804 error = security_path_mknod(&path, dentry, mode, dev);
53805 if (error)
53806 goto out;
53807 @@ -3193,6 +3321,8 @@ retry:
53808 break;
53809 }
53810 out:
53811 + if (!error)
53812 + gr_handle_create(dentry, path.mnt);
53813 done_path_create(&path, dentry);
53814 if (retry_estale(error, lookup_flags)) {
53815 lookup_flags |= LOOKUP_REVAL;
53816 @@ -3245,9 +3375,16 @@ retry:
53817
53818 if (!IS_POSIXACL(path.dentry->d_inode))
53819 mode &= ~current_umask();
53820 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53821 + error = -EACCES;
53822 + goto out;
53823 + }
53824 error = security_path_mkdir(&path, dentry, mode);
53825 if (!error)
53826 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53827 + if (!error)
53828 + gr_handle_create(dentry, path.mnt);
53829 +out:
53830 done_path_create(&path, dentry);
53831 if (retry_estale(error, lookup_flags)) {
53832 lookup_flags |= LOOKUP_REVAL;
53833 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53834 struct filename *name;
53835 struct dentry *dentry;
53836 struct nameidata nd;
53837 + ino_t saved_ino = 0;
53838 + dev_t saved_dev = 0;
53839 unsigned int lookup_flags = 0;
53840 retry:
53841 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53842 @@ -3360,10 +3499,21 @@ retry:
53843 error = -ENOENT;
53844 goto exit3;
53845 }
53846 +
53847 + saved_ino = dentry->d_inode->i_ino;
53848 + saved_dev = gr_get_dev_from_dentry(dentry);
53849 +
53850 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53851 + error = -EACCES;
53852 + goto exit3;
53853 + }
53854 +
53855 error = security_path_rmdir(&nd.path, dentry);
53856 if (error)
53857 goto exit3;
53858 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53859 + if (!error && (saved_dev || saved_ino))
53860 + gr_handle_delete(saved_ino, saved_dev);
53861 exit3:
53862 dput(dentry);
53863 exit2:
53864 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53865 struct dentry *dentry;
53866 struct nameidata nd;
53867 struct inode *inode = NULL;
53868 + ino_t saved_ino = 0;
53869 + dev_t saved_dev = 0;
53870 unsigned int lookup_flags = 0;
53871 retry:
53872 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53873 @@ -3455,10 +3607,22 @@ retry:
53874 if (!inode)
53875 goto slashes;
53876 ihold(inode);
53877 +
53878 + if (inode->i_nlink <= 1) {
53879 + saved_ino = inode->i_ino;
53880 + saved_dev = gr_get_dev_from_dentry(dentry);
53881 + }
53882 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53883 + error = -EACCES;
53884 + goto exit2;
53885 + }
53886 +
53887 error = security_path_unlink(&nd.path, dentry);
53888 if (error)
53889 goto exit2;
53890 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53891 + if (!error && (saved_ino || saved_dev))
53892 + gr_handle_delete(saved_ino, saved_dev);
53893 exit2:
53894 dput(dentry);
53895 }
53896 @@ -3536,9 +3700,17 @@ retry:
53897 if (IS_ERR(dentry))
53898 goto out_putname;
53899
53900 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53901 + error = -EACCES;
53902 + goto out;
53903 + }
53904 +
53905 error = security_path_symlink(&path, dentry, from->name);
53906 if (!error)
53907 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53908 + if (!error)
53909 + gr_handle_create(dentry, path.mnt);
53910 +out:
53911 done_path_create(&path, dentry);
53912 if (retry_estale(error, lookup_flags)) {
53913 lookup_flags |= LOOKUP_REVAL;
53914 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53915 {
53916 struct dentry *new_dentry;
53917 struct path old_path, new_path;
53918 + struct filename *to = NULL;
53919 int how = 0;
53920 int error;
53921
53922 @@ -3635,7 +3808,7 @@ retry:
53923 if (error)
53924 return error;
53925
53926 - new_dentry = user_path_create(newdfd, newname, &new_path,
53927 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53928 (how & LOOKUP_REVAL));
53929 error = PTR_ERR(new_dentry);
53930 if (IS_ERR(new_dentry))
53931 @@ -3647,11 +3820,28 @@ retry:
53932 error = may_linkat(&old_path);
53933 if (unlikely(error))
53934 goto out_dput;
53935 +
53936 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53937 + old_path.dentry->d_inode,
53938 + old_path.dentry->d_inode->i_mode, to)) {
53939 + error = -EACCES;
53940 + goto out_dput;
53941 + }
53942 +
53943 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53944 + old_path.dentry, old_path.mnt, to)) {
53945 + error = -EACCES;
53946 + goto out_dput;
53947 + }
53948 +
53949 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53950 if (error)
53951 goto out_dput;
53952 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53953 + if (!error)
53954 + gr_handle_create(new_dentry, new_path.mnt);
53955 out_dput:
53956 + putname(to);
53957 done_path_create(&new_path, new_dentry);
53958 if (retry_estale(error, how)) {
53959 how |= LOOKUP_REVAL;
53960 @@ -3897,12 +4087,21 @@ retry:
53961 if (new_dentry == trap)
53962 goto exit5;
53963
53964 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53965 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53966 + to);
53967 + if (error)
53968 + goto exit5;
53969 +
53970 error = security_path_rename(&oldnd.path, old_dentry,
53971 &newnd.path, new_dentry);
53972 if (error)
53973 goto exit5;
53974 error = vfs_rename(old_dir->d_inode, old_dentry,
53975 new_dir->d_inode, new_dentry);
53976 + if (!error)
53977 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53978 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53979 exit5:
53980 dput(new_dentry);
53981 exit4:
53982 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53983
53984 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53985 {
53986 + char tmpbuf[64];
53987 + const char *newlink;
53988 int len;
53989
53990 len = PTR_ERR(link);
53991 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53992 len = strlen(link);
53993 if (len > (unsigned) buflen)
53994 len = buflen;
53995 - if (copy_to_user(buffer, link, len))
53996 +
53997 + if (len < sizeof(tmpbuf)) {
53998 + memcpy(tmpbuf, link, len);
53999 + newlink = tmpbuf;
54000 + } else
54001 + newlink = link;
54002 +
54003 + if (copy_to_user(buffer, newlink, len))
54004 len = -EFAULT;
54005 out:
54006 return len;
54007 diff --git a/fs/namespace.c b/fs/namespace.c
54008 index e945b81..fc018e2 100644
54009 --- a/fs/namespace.c
54010 +++ b/fs/namespace.c
54011 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
54012 if (!(sb->s_flags & MS_RDONLY))
54013 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54014 up_write(&sb->s_umount);
54015 +
54016 + gr_log_remount(mnt->mnt_devname, retval);
54017 +
54018 return retval;
54019 }
54020
54021 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
54022 br_write_unlock(&vfsmount_lock);
54023 up_write(&namespace_sem);
54024 release_mounts(&umount_list);
54025 +
54026 + gr_log_unmount(mnt->mnt_devname, retval);
54027 +
54028 return retval;
54029 }
54030
54031 @@ -1257,7 +1263,7 @@ static inline bool may_mount(void)
54032 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
54033 */
54034
54035 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
54036 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
54037 {
54038 struct path path;
54039 struct mount *mnt;
54040 @@ -1297,7 +1303,7 @@ out:
54041 /*
54042 * The 2.0 compatible umount. No flags.
54043 */
54044 -SYSCALL_DEFINE1(oldumount, char __user *, name)
54045 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
54046 {
54047 return sys_umount(name, 0);
54048 }
54049 @@ -2267,6 +2273,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54050 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54051 MS_STRICTATIME);
54052
54053 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54054 + retval = -EPERM;
54055 + goto dput_out;
54056 + }
54057 +
54058 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54059 + retval = -EPERM;
54060 + goto dput_out;
54061 + }
54062 +
54063 if (flags & MS_REMOUNT)
54064 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54065 data_page);
54066 @@ -2281,6 +2297,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54067 dev_name, data_page);
54068 dput_out:
54069 path_put(&path);
54070 +
54071 + gr_log_mount(dev_name, dir_name, retval);
54072 +
54073 return retval;
54074 }
54075
54076 @@ -2454,8 +2473,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
54077 }
54078 EXPORT_SYMBOL(mount_subtree);
54079
54080 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
54081 - char __user *, type, unsigned long, flags, void __user *, data)
54082 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
54083 + const char __user *, type, unsigned long, flags, void __user *, data)
54084 {
54085 int ret;
54086 char *kernel_type;
54087 @@ -2567,6 +2586,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54088 if (error)
54089 goto out2;
54090
54091 + if (gr_handle_chroot_pivot()) {
54092 + error = -EPERM;
54093 + goto out2;
54094 + }
54095 +
54096 get_fs_root(current->fs, &root);
54097 error = lock_mount(&old);
54098 if (error)
54099 @@ -2815,7 +2839,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54100 !nsown_capable(CAP_SYS_ADMIN))
54101 return -EPERM;
54102
54103 - if (fs->users != 1)
54104 + if (atomic_read(&fs->users) != 1)
54105 return -EINVAL;
54106
54107 get_mnt_ns(mnt_ns);
54108 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
54109 index 5088b57..eabd719 100644
54110 --- a/fs/nfs/callback.c
54111 +++ b/fs/nfs/callback.c
54112 @@ -208,7 +208,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54113 struct svc_rqst *rqstp;
54114 int (*callback_svc)(void *vrqstp);
54115 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
54116 - char svc_name[12];
54117 int ret;
54118
54119 nfs_callback_bc_serv(minorversion, xprt, serv);
54120 @@ -232,10 +231,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54121
54122 svc_sock_update_bufs(serv);
54123
54124 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
54125 cb_info->serv = serv;
54126 cb_info->rqst = rqstp;
54127 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
54128 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
54129 if (IS_ERR(cb_info->task)) {
54130 ret = PTR_ERR(cb_info->task);
54131 svc_exit_thread(cb_info->rqst);
54132 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54133 index 59461c9..b17c57e 100644
54134 --- a/fs/nfs/callback_xdr.c
54135 +++ b/fs/nfs/callback_xdr.c
54136 @@ -51,7 +51,7 @@ struct callback_op {
54137 callback_decode_arg_t decode_args;
54138 callback_encode_res_t encode_res;
54139 long res_maxsize;
54140 -};
54141 +} __do_const;
54142
54143 static struct callback_op callback_ops[];
54144
54145 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54146 index 1f94167..79c4ce4 100644
54147 --- a/fs/nfs/inode.c
54148 +++ b/fs/nfs/inode.c
54149 @@ -1041,16 +1041,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54150 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54151 }
54152
54153 -static atomic_long_t nfs_attr_generation_counter;
54154 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54155
54156 static unsigned long nfs_read_attr_generation_counter(void)
54157 {
54158 - return atomic_long_read(&nfs_attr_generation_counter);
54159 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54160 }
54161
54162 unsigned long nfs_inc_attr_generation_counter(void)
54163 {
54164 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54165 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54166 }
54167
54168 void nfs_fattr_init(struct nfs_fattr *fattr)
54169 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
54170 index d41a351..7899577 100644
54171 --- a/fs/nfs/nfs4state.c
54172 +++ b/fs/nfs/nfs4state.c
54173 @@ -1182,7 +1182,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
54174 snprintf(buf, sizeof(buf), "%s-manager",
54175 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
54176 rcu_read_unlock();
54177 - task = kthread_run(nfs4_run_state_manager, clp, buf);
54178 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
54179 if (IS_ERR(task)) {
54180 printk(KERN_ERR "%s: kthread_run: %ld\n",
54181 __func__, PTR_ERR(task));
54182 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54183 index d401d01..10b3e62 100644
54184 --- a/fs/nfsd/nfs4proc.c
54185 +++ b/fs/nfsd/nfs4proc.c
54186 @@ -1109,7 +1109,7 @@ struct nfsd4_operation {
54187 nfsd4op_rsize op_rsize_bop;
54188 stateid_getter op_get_currentstateid;
54189 stateid_setter op_set_currentstateid;
54190 -};
54191 +} __do_const;
54192
54193 static struct nfsd4_operation nfsd4_ops[];
54194
54195 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54196 index 6eb0dc5..29067a9 100644
54197 --- a/fs/nfsd/nfs4xdr.c
54198 +++ b/fs/nfsd/nfs4xdr.c
54199 @@ -1457,7 +1457,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54200
54201 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54202
54203 -static nfsd4_dec nfsd4_dec_ops[] = {
54204 +static const nfsd4_dec nfsd4_dec_ops[] = {
54205 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54206 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54207 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54208 @@ -1497,7 +1497,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54209 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54210 };
54211
54212 -static nfsd4_dec nfsd41_dec_ops[] = {
54213 +static const nfsd4_dec nfsd41_dec_ops[] = {
54214 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54215 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54216 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54217 @@ -1559,7 +1559,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54218 };
54219
54220 struct nfsd4_minorversion_ops {
54221 - nfsd4_dec *decoders;
54222 + const nfsd4_dec *decoders;
54223 int nops;
54224 };
54225
54226 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
54227 index ca05f6d..b88c3a7 100644
54228 --- a/fs/nfsd/nfscache.c
54229 +++ b/fs/nfsd/nfscache.c
54230 @@ -461,13 +461,16 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
54231 {
54232 struct svc_cacherep *rp = rqstp->rq_cacherep;
54233 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
54234 - int len;
54235 + long len;
54236
54237 if (!rp)
54238 return;
54239
54240 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54241 - len >>= 2;
54242 + if (statp) {
54243 + len = (char*)statp - (char*)resv->iov_base;
54244 + len = resv->iov_len - len;
54245 + len >>= 2;
54246 + }
54247
54248 /* Don't cache excessive amounts of data and XDR failures */
54249 if (!statp || len > (256 >> 2)) {
54250 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54251 index 2b2e239..c915b48 100644
54252 --- a/fs/nfsd/vfs.c
54253 +++ b/fs/nfsd/vfs.c
54254 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54255 } else {
54256 oldfs = get_fs();
54257 set_fs(KERNEL_DS);
54258 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54259 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54260 set_fs(oldfs);
54261 }
54262
54263 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54264
54265 /* Write the data. */
54266 oldfs = get_fs(); set_fs(KERNEL_DS);
54267 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54268 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54269 set_fs(oldfs);
54270 if (host_err < 0)
54271 goto out_nfserr;
54272 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54273 */
54274
54275 oldfs = get_fs(); set_fs(KERNEL_DS);
54276 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54277 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54278 set_fs(oldfs);
54279
54280 if (host_err < 0)
54281 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54282 index fea6bd5..8ee9d81 100644
54283 --- a/fs/nls/nls_base.c
54284 +++ b/fs/nls/nls_base.c
54285 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54286
54287 int register_nls(struct nls_table * nls)
54288 {
54289 - struct nls_table ** tmp = &tables;
54290 + struct nls_table *tmp = tables;
54291
54292 if (nls->next)
54293 return -EBUSY;
54294
54295 spin_lock(&nls_lock);
54296 - while (*tmp) {
54297 - if (nls == *tmp) {
54298 + while (tmp) {
54299 + if (nls == tmp) {
54300 spin_unlock(&nls_lock);
54301 return -EBUSY;
54302 }
54303 - tmp = &(*tmp)->next;
54304 + tmp = tmp->next;
54305 }
54306 - nls->next = tables;
54307 + pax_open_kernel();
54308 + *(struct nls_table **)&nls->next = tables;
54309 + pax_close_kernel();
54310 tables = nls;
54311 spin_unlock(&nls_lock);
54312 return 0;
54313 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54314
54315 int unregister_nls(struct nls_table * nls)
54316 {
54317 - struct nls_table ** tmp = &tables;
54318 + struct nls_table * const * tmp = &tables;
54319
54320 spin_lock(&nls_lock);
54321 while (*tmp) {
54322 if (nls == *tmp) {
54323 - *tmp = nls->next;
54324 + pax_open_kernel();
54325 + *(struct nls_table **)tmp = nls->next;
54326 + pax_close_kernel();
54327 spin_unlock(&nls_lock);
54328 return 0;
54329 }
54330 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54331 index 7424929..35f6be5 100644
54332 --- a/fs/nls/nls_euc-jp.c
54333 +++ b/fs/nls/nls_euc-jp.c
54334 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54335 p_nls = load_nls("cp932");
54336
54337 if (p_nls) {
54338 - table.charset2upper = p_nls->charset2upper;
54339 - table.charset2lower = p_nls->charset2lower;
54340 + pax_open_kernel();
54341 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54342 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54343 + pax_close_kernel();
54344 return register_nls(&table);
54345 }
54346
54347 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54348 index e7bc1d7..06bd4bb 100644
54349 --- a/fs/nls/nls_koi8-ru.c
54350 +++ b/fs/nls/nls_koi8-ru.c
54351 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54352 p_nls = load_nls("koi8-u");
54353
54354 if (p_nls) {
54355 - table.charset2upper = p_nls->charset2upper;
54356 - table.charset2lower = p_nls->charset2lower;
54357 + pax_open_kernel();
54358 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54359 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54360 + pax_close_kernel();
54361 return register_nls(&table);
54362 }
54363
54364 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54365 index 5d84442..2c034ba 100644
54366 --- a/fs/notify/fanotify/fanotify_user.c
54367 +++ b/fs/notify/fanotify/fanotify_user.c
54368 @@ -121,6 +121,7 @@ static int fill_event_metadata(struct fsnotify_group *group,
54369 metadata->event_len = FAN_EVENT_METADATA_LEN;
54370 metadata->metadata_len = FAN_EVENT_METADATA_LEN;
54371 metadata->vers = FANOTIFY_METADATA_VERSION;
54372 + metadata->reserved = 0;
54373 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;
54374 metadata->pid = pid_vnr(event->tgid);
54375 if (unlikely(event->mask & FAN_Q_OVERFLOW))
54376 @@ -251,8 +252,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54377
54378 fd = fanotify_event_metadata.fd;
54379 ret = -EFAULT;
54380 - if (copy_to_user(buf, &fanotify_event_metadata,
54381 - fanotify_event_metadata.event_len))
54382 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54383 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54384 goto out_close_fd;
54385
54386 ret = prepare_for_access_response(group, event, fd);
54387 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54388 index 7b51b05..5ea5ef6 100644
54389 --- a/fs/notify/notification.c
54390 +++ b/fs/notify/notification.c
54391 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54392 * get set to 0 so it will never get 'freed'
54393 */
54394 static struct fsnotify_event *q_overflow_event;
54395 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54396 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54397
54398 /**
54399 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54400 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54401 */
54402 u32 fsnotify_get_cookie(void)
54403 {
54404 - return atomic_inc_return(&fsnotify_sync_cookie);
54405 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54406 }
54407 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54408
54409 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54410 index aa411c3..c260a84 100644
54411 --- a/fs/ntfs/dir.c
54412 +++ b/fs/ntfs/dir.c
54413 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54414 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54415 ~(s64)(ndir->itype.index.block_size - 1)));
54416 /* Bounds checks. */
54417 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54418 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54419 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54420 "inode 0x%lx or driver bug.", vdir->i_ino);
54421 goto err_out;
54422 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54423 index 5b2d4f0..c6de396 100644
54424 --- a/fs/ntfs/file.c
54425 +++ b/fs/ntfs/file.c
54426 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54427 #endif /* NTFS_RW */
54428 };
54429
54430 -const struct file_operations ntfs_empty_file_ops = {};
54431 +const struct file_operations ntfs_empty_file_ops __read_only;
54432
54433 -const struct inode_operations ntfs_empty_inode_ops = {};
54434 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54435 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54436 index aebeacd..0dcdd26 100644
54437 --- a/fs/ocfs2/localalloc.c
54438 +++ b/fs/ocfs2/localalloc.c
54439 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54440 goto bail;
54441 }
54442
54443 - atomic_inc(&osb->alloc_stats.moves);
54444 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54445
54446 bail:
54447 if (handle)
54448 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54449 index d355e6e..578d905 100644
54450 --- a/fs/ocfs2/ocfs2.h
54451 +++ b/fs/ocfs2/ocfs2.h
54452 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54453
54454 struct ocfs2_alloc_stats
54455 {
54456 - atomic_t moves;
54457 - atomic_t local_data;
54458 - atomic_t bitmap_data;
54459 - atomic_t bg_allocs;
54460 - atomic_t bg_extends;
54461 + atomic_unchecked_t moves;
54462 + atomic_unchecked_t local_data;
54463 + atomic_unchecked_t bitmap_data;
54464 + atomic_unchecked_t bg_allocs;
54465 + atomic_unchecked_t bg_extends;
54466 };
54467
54468 enum ocfs2_local_alloc_state
54469 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54470 index b7e74b5..19c6536 100644
54471 --- a/fs/ocfs2/suballoc.c
54472 +++ b/fs/ocfs2/suballoc.c
54473 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54474 mlog_errno(status);
54475 goto bail;
54476 }
54477 - atomic_inc(&osb->alloc_stats.bg_extends);
54478 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54479
54480 /* You should never ask for this much metadata */
54481 BUG_ON(bits_wanted >
54482 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54483 mlog_errno(status);
54484 goto bail;
54485 }
54486 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54487 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54488
54489 *suballoc_loc = res.sr_bg_blkno;
54490 *suballoc_bit_start = res.sr_bit_offset;
54491 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54492 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54493 res->sr_bits);
54494
54495 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54496 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54497
54498 BUG_ON(res->sr_bits != 1);
54499
54500 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54501 mlog_errno(status);
54502 goto bail;
54503 }
54504 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54505 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54506
54507 BUG_ON(res.sr_bits != 1);
54508
54509 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54510 cluster_start,
54511 num_clusters);
54512 if (!status)
54513 - atomic_inc(&osb->alloc_stats.local_data);
54514 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54515 } else {
54516 if (min_clusters > (osb->bitmap_cpg - 1)) {
54517 /* The only paths asking for contiguousness
54518 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54519 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54520 res.sr_bg_blkno,
54521 res.sr_bit_offset);
54522 - atomic_inc(&osb->alloc_stats.bitmap_data);
54523 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54524 *num_clusters = res.sr_bits;
54525 }
54526 }
54527 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54528 index 01b8516..579c4df 100644
54529 --- a/fs/ocfs2/super.c
54530 +++ b/fs/ocfs2/super.c
54531 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54532 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54533 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54534 "Stats",
54535 - atomic_read(&osb->alloc_stats.bitmap_data),
54536 - atomic_read(&osb->alloc_stats.local_data),
54537 - atomic_read(&osb->alloc_stats.bg_allocs),
54538 - atomic_read(&osb->alloc_stats.moves),
54539 - atomic_read(&osb->alloc_stats.bg_extends));
54540 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54541 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54542 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54543 + atomic_read_unchecked(&osb->alloc_stats.moves),
54544 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54545
54546 out += snprintf(buf + out, len - out,
54547 "%10s => State: %u Descriptor: %llu Size: %u bits "
54548 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54549 spin_lock_init(&osb->osb_xattr_lock);
54550 ocfs2_init_steal_slots(osb);
54551
54552 - atomic_set(&osb->alloc_stats.moves, 0);
54553 - atomic_set(&osb->alloc_stats.local_data, 0);
54554 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54555 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54556 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54557 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54558 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54559 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54560 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54561 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54562
54563 /* Copy the blockcheck stats from the superblock probe */
54564 osb->osb_ecc_stats = *stats;
54565 diff --git a/fs/open.c b/fs/open.c
54566 index 6835446..eadf09f 100644
54567 --- a/fs/open.c
54568 +++ b/fs/open.c
54569 @@ -32,6 +32,8 @@
54570 #include <linux/dnotify.h>
54571 #include <linux/compat.h>
54572
54573 +#define CREATE_TRACE_POINTS
54574 +#include <trace/events/fs.h>
54575 #include "internal.h"
54576
54577 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54578 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54579 error = locks_verify_truncate(inode, NULL, length);
54580 if (!error)
54581 error = security_path_truncate(path);
54582 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54583 + error = -EACCES;
54584 if (!error)
54585 error = do_truncate(path->dentry, length, 0, NULL);
54586
54587 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54588 error = locks_verify_truncate(inode, f.file, length);
54589 if (!error)
54590 error = security_path_truncate(&f.file->f_path);
54591 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54592 + error = -EACCES;
54593 if (!error)
54594 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54595 sb_end_write(inode->i_sb);
54596 @@ -388,6 +394,9 @@ retry:
54597 if (__mnt_is_readonly(path.mnt))
54598 res = -EROFS;
54599
54600 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54601 + res = -EACCES;
54602 +
54603 out_path_release:
54604 path_put(&path);
54605 if (retry_estale(res, lookup_flags)) {
54606 @@ -419,6 +428,8 @@ retry:
54607 if (error)
54608 goto dput_and_out;
54609
54610 + gr_log_chdir(path.dentry, path.mnt);
54611 +
54612 set_fs_pwd(current->fs, &path);
54613
54614 dput_and_out:
54615 @@ -448,6 +459,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54616 goto out_putf;
54617
54618 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54619 +
54620 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54621 + error = -EPERM;
54622 +
54623 + if (!error)
54624 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54625 +
54626 if (!error)
54627 set_fs_pwd(current->fs, &f.file->f_path);
54628 out_putf:
54629 @@ -477,7 +495,13 @@ retry:
54630 if (error)
54631 goto dput_and_out;
54632
54633 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54634 + goto dput_and_out;
54635 +
54636 set_fs_root(current->fs, &path);
54637 +
54638 + gr_handle_chroot_chdir(&path);
54639 +
54640 error = 0;
54641 dput_and_out:
54642 path_put(&path);
54643 @@ -499,6 +523,16 @@ static int chmod_common(struct path *path, umode_t mode)
54644 if (error)
54645 return error;
54646 mutex_lock(&inode->i_mutex);
54647 +
54648 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54649 + error = -EACCES;
54650 + goto out_unlock;
54651 + }
54652 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54653 + error = -EACCES;
54654 + goto out_unlock;
54655 + }
54656 +
54657 error = security_path_chmod(path, mode);
54658 if (error)
54659 goto out_unlock;
54660 @@ -559,6 +593,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54661 uid = make_kuid(current_user_ns(), user);
54662 gid = make_kgid(current_user_ns(), group);
54663
54664 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54665 + return -EACCES;
54666 +
54667 newattrs.ia_valid = ATTR_CTIME;
54668 if (user != (uid_t) -1) {
54669 if (!uid_valid(uid))
54670 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54671 } else {
54672 fsnotify_open(f);
54673 fd_install(fd, f);
54674 + trace_do_sys_open(tmp->name, flags, mode);
54675 }
54676 }
54677 putname(tmp);
54678 diff --git a/fs/pipe.c b/fs/pipe.c
54679 index 2234f3f..f9083a1 100644
54680 --- a/fs/pipe.c
54681 +++ b/fs/pipe.c
54682 @@ -438,9 +438,9 @@ redo:
54683 }
54684 if (bufs) /* More to do? */
54685 continue;
54686 - if (!pipe->writers)
54687 + if (!atomic_read(&pipe->writers))
54688 break;
54689 - if (!pipe->waiting_writers) {
54690 + if (!atomic_read(&pipe->waiting_writers)) {
54691 /* syscall merging: Usually we must not sleep
54692 * if O_NONBLOCK is set, or if we got some data.
54693 * But if a writer sleeps in kernel space, then
54694 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54695 mutex_lock(&inode->i_mutex);
54696 pipe = inode->i_pipe;
54697
54698 - if (!pipe->readers) {
54699 + if (!atomic_read(&pipe->readers)) {
54700 send_sig(SIGPIPE, current, 0);
54701 ret = -EPIPE;
54702 goto out;
54703 @@ -553,7 +553,7 @@ redo1:
54704 for (;;) {
54705 int bufs;
54706
54707 - if (!pipe->readers) {
54708 + if (!atomic_read(&pipe->readers)) {
54709 send_sig(SIGPIPE, current, 0);
54710 if (!ret)
54711 ret = -EPIPE;
54712 @@ -644,9 +644,9 @@ redo2:
54713 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54714 do_wakeup = 0;
54715 }
54716 - pipe->waiting_writers++;
54717 + atomic_inc(&pipe->waiting_writers);
54718 pipe_wait(pipe);
54719 - pipe->waiting_writers--;
54720 + atomic_dec(&pipe->waiting_writers);
54721 }
54722 out:
54723 mutex_unlock(&inode->i_mutex);
54724 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54725 mask = 0;
54726 if (filp->f_mode & FMODE_READ) {
54727 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54728 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54729 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54730 mask |= POLLHUP;
54731 }
54732
54733 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54734 * Most Unices do not set POLLERR for FIFOs but on Linux they
54735 * behave exactly like pipes for poll().
54736 */
54737 - if (!pipe->readers)
54738 + if (!atomic_read(&pipe->readers))
54739 mask |= POLLERR;
54740 }
54741
54742 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54743
54744 mutex_lock(&inode->i_mutex);
54745 pipe = inode->i_pipe;
54746 - pipe->readers -= decr;
54747 - pipe->writers -= decw;
54748 + atomic_sub(decr, &pipe->readers);
54749 + atomic_sub(decw, &pipe->writers);
54750
54751 - if (!pipe->readers && !pipe->writers) {
54752 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54753 free_pipe_info(inode);
54754 } else {
54755 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54756 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54757
54758 if (inode->i_pipe) {
54759 ret = 0;
54760 - inode->i_pipe->readers++;
54761 + atomic_inc(&inode->i_pipe->readers);
54762 }
54763
54764 mutex_unlock(&inode->i_mutex);
54765 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54766
54767 if (inode->i_pipe) {
54768 ret = 0;
54769 - inode->i_pipe->writers++;
54770 + atomic_inc(&inode->i_pipe->writers);
54771 }
54772
54773 mutex_unlock(&inode->i_mutex);
54774 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54775 if (inode->i_pipe) {
54776 ret = 0;
54777 if (filp->f_mode & FMODE_READ)
54778 - inode->i_pipe->readers++;
54779 + atomic_inc(&inode->i_pipe->readers);
54780 if (filp->f_mode & FMODE_WRITE)
54781 - inode->i_pipe->writers++;
54782 + atomic_inc(&inode->i_pipe->writers);
54783 }
54784
54785 mutex_unlock(&inode->i_mutex);
54786 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54787 inode->i_pipe = NULL;
54788 }
54789
54790 -static struct vfsmount *pipe_mnt __read_mostly;
54791 +struct vfsmount *pipe_mnt __read_mostly;
54792
54793 /*
54794 * pipefs_dname() is called from d_path().
54795 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54796 goto fail_iput;
54797 inode->i_pipe = pipe;
54798
54799 - pipe->readers = pipe->writers = 1;
54800 + atomic_set(&pipe->readers, 1);
54801 + atomic_set(&pipe->writers, 1);
54802 inode->i_fop = &rdwr_pipefifo_fops;
54803
54804 /*
54805 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54806 index 15af622..0e9f4467 100644
54807 --- a/fs/proc/Kconfig
54808 +++ b/fs/proc/Kconfig
54809 @@ -30,12 +30,12 @@ config PROC_FS
54810
54811 config PROC_KCORE
54812 bool "/proc/kcore support" if !ARM
54813 - depends on PROC_FS && MMU
54814 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54815
54816 config PROC_VMCORE
54817 bool "/proc/vmcore support"
54818 - depends on PROC_FS && CRASH_DUMP
54819 - default y
54820 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54821 + default n
54822 help
54823 Exports the dump image of crashed kernel in ELF format.
54824
54825 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54826 limited in memory.
54827
54828 config PROC_PAGE_MONITOR
54829 - default y
54830 - depends on PROC_FS && MMU
54831 + default n
54832 + depends on PROC_FS && MMU && !GRKERNSEC
54833 bool "Enable /proc page monitoring" if EXPERT
54834 help
54835 Various /proc files exist to monitor process memory utilization:
54836 diff --git a/fs/proc/array.c b/fs/proc/array.c
54837 index cbd0f1b..adec3f0 100644
54838 --- a/fs/proc/array.c
54839 +++ b/fs/proc/array.c
54840 @@ -60,6 +60,7 @@
54841 #include <linux/tty.h>
54842 #include <linux/string.h>
54843 #include <linux/mman.h>
54844 +#include <linux/grsecurity.h>
54845 #include <linux/proc_fs.h>
54846 #include <linux/ioport.h>
54847 #include <linux/uaccess.h>
54848 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54849 seq_putc(m, '\n');
54850 }
54851
54852 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54853 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54854 +{
54855 + if (p->mm)
54856 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54857 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54858 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54859 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54860 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54861 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54862 + else
54863 + seq_printf(m, "PaX:\t-----\n");
54864 +}
54865 +#endif
54866 +
54867 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54868 struct pid *pid, struct task_struct *task)
54869 {
54870 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54871 task_cpus_allowed(m, task);
54872 cpuset_task_status_allowed(m, task);
54873 task_context_switch_counts(m, task);
54874 +
54875 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54876 + task_pax(m, task);
54877 +#endif
54878 +
54879 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54880 + task_grsec_rbac(m, task);
54881 +#endif
54882 +
54883 return 0;
54884 }
54885
54886 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54887 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54888 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54889 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54890 +#endif
54891 +
54892 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54893 struct pid *pid, struct task_struct *task, int whole)
54894 {
54895 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54896 char tcomm[sizeof(task->comm)];
54897 unsigned long flags;
54898
54899 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54900 + if (current->exec_id != m->exec_id) {
54901 + gr_log_badprocpid("stat");
54902 + return 0;
54903 + }
54904 +#endif
54905 +
54906 state = *get_task_state(task);
54907 vsize = eip = esp = 0;
54908 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54909 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54910 gtime = task_gtime(task);
54911 }
54912
54913 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54914 + if (PAX_RAND_FLAGS(mm)) {
54915 + eip = 0;
54916 + esp = 0;
54917 + wchan = 0;
54918 + }
54919 +#endif
54920 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54921 + wchan = 0;
54922 + eip =0;
54923 + esp =0;
54924 +#endif
54925 +
54926 /* scale priority and nice values from timeslices to -20..20 */
54927 /* to make it look like a "normal" Unix priority/nice value */
54928 priority = task_prio(task);
54929 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54930 seq_put_decimal_ull(m, ' ', vsize);
54931 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54932 seq_put_decimal_ull(m, ' ', rsslim);
54933 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54934 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54935 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54936 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54937 +#else
54938 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54939 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54940 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54941 +#endif
54942 seq_put_decimal_ull(m, ' ', esp);
54943 seq_put_decimal_ull(m, ' ', eip);
54944 /* The signal information here is obsolete.
54945 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54946 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54947 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54948
54949 - if (mm && permitted) {
54950 + if (mm && permitted
54951 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54952 + && !PAX_RAND_FLAGS(mm)
54953 +#endif
54954 + ) {
54955 seq_put_decimal_ull(m, ' ', mm->start_data);
54956 seq_put_decimal_ull(m, ' ', mm->end_data);
54957 seq_put_decimal_ull(m, ' ', mm->start_brk);
54958 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54959 struct pid *pid, struct task_struct *task)
54960 {
54961 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54962 - struct mm_struct *mm = get_task_mm(task);
54963 + struct mm_struct *mm;
54964
54965 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54966 + if (current->exec_id != m->exec_id) {
54967 + gr_log_badprocpid("statm");
54968 + return 0;
54969 + }
54970 +#endif
54971 + mm = get_task_mm(task);
54972 if (mm) {
54973 size = task_statm(mm, &shared, &text, &data, &resident);
54974 mmput(mm);
54975 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54976 return 0;
54977 }
54978
54979 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54980 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
54981 +{
54982 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
54983 +}
54984 +#endif
54985 +
54986 #ifdef CONFIG_CHECKPOINT_RESTORE
54987 static struct pid *
54988 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
54989 diff --git a/fs/proc/base.c b/fs/proc/base.c
54990 index 69078c7..3e12a75 100644
54991 --- a/fs/proc/base.c
54992 +++ b/fs/proc/base.c
54993 @@ -112,6 +112,14 @@ struct pid_entry {
54994 union proc_op op;
54995 };
54996
54997 +struct getdents_callback {
54998 + struct linux_dirent __user * current_dir;
54999 + struct linux_dirent __user * previous;
55000 + struct file * file;
55001 + int count;
55002 + int error;
55003 +};
55004 +
55005 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55006 .name = (NAME), \
55007 .len = sizeof(NAME) - 1, \
55008 @@ -209,6 +217,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55009 if (!mm->arg_end)
55010 goto out_mm; /* Shh! No looking before we're done */
55011
55012 + if (gr_acl_handle_procpidmem(task))
55013 + goto out_mm;
55014 +
55015 len = mm->arg_end - mm->arg_start;
55016
55017 if (len > PAGE_SIZE)
55018 @@ -236,12 +247,28 @@ out:
55019 return res;
55020 }
55021
55022 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55023 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55024 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55025 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55026 +#endif
55027 +
55028 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55029 {
55030 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55031 int res = PTR_ERR(mm);
55032 if (mm && !IS_ERR(mm)) {
55033 unsigned int nwords = 0;
55034 +
55035 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55036 + /* allow if we're currently ptracing this task */
55037 + if (PAX_RAND_FLAGS(mm) &&
55038 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55039 + mmput(mm);
55040 + return 0;
55041 + }
55042 +#endif
55043 +
55044 do {
55045 nwords += 2;
55046 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55047 @@ -255,7 +282,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55048 }
55049
55050
55051 -#ifdef CONFIG_KALLSYMS
55052 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55053 /*
55054 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55055 * Returns the resolved symbol. If that fails, simply return the address.
55056 @@ -294,7 +321,7 @@ static void unlock_trace(struct task_struct *task)
55057 mutex_unlock(&task->signal->cred_guard_mutex);
55058 }
55059
55060 -#ifdef CONFIG_STACKTRACE
55061 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55062
55063 #define MAX_STACK_TRACE_DEPTH 64
55064
55065 @@ -486,7 +513,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55066 return count;
55067 }
55068
55069 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55070 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55071 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55072 {
55073 long nr;
55074 @@ -515,7 +542,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55075 /************************************************************************/
55076
55077 /* permission checks */
55078 -static int proc_fd_access_allowed(struct inode *inode)
55079 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55080 {
55081 struct task_struct *task;
55082 int allowed = 0;
55083 @@ -525,7 +552,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55084 */
55085 task = get_proc_task(inode);
55086 if (task) {
55087 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55088 + if (log)
55089 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55090 + else
55091 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55092 put_task_struct(task);
55093 }
55094 return allowed;
55095 @@ -556,10 +586,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55096 struct task_struct *task,
55097 int hide_pid_min)
55098 {
55099 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55100 + return false;
55101 +
55102 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55103 + rcu_read_lock();
55104 + {
55105 + const struct cred *tmpcred = current_cred();
55106 + const struct cred *cred = __task_cred(task);
55107 +
55108 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55109 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55110 + || in_group_p(grsec_proc_gid)
55111 +#endif
55112 + ) {
55113 + rcu_read_unlock();
55114 + return true;
55115 + }
55116 + }
55117 + rcu_read_unlock();
55118 +
55119 + if (!pid->hide_pid)
55120 + return false;
55121 +#endif
55122 +
55123 if (pid->hide_pid < hide_pid_min)
55124 return true;
55125 if (in_group_p(pid->pid_gid))
55126 return true;
55127 +
55128 return ptrace_may_access(task, PTRACE_MODE_READ);
55129 }
55130
55131 @@ -577,7 +632,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55132 put_task_struct(task);
55133
55134 if (!has_perms) {
55135 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55136 + {
55137 +#else
55138 if (pid->hide_pid == 2) {
55139 +#endif
55140 /*
55141 * Let's make getdents(), stat(), and open()
55142 * consistent with each other. If a process
55143 @@ -675,6 +734,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55144 if (!task)
55145 return -ESRCH;
55146
55147 + if (gr_acl_handle_procpidmem(task)) {
55148 + put_task_struct(task);
55149 + return -EPERM;
55150 + }
55151 +
55152 mm = mm_access(task, mode);
55153 put_task_struct(task);
55154
55155 @@ -690,6 +754,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55156
55157 file->private_data = mm;
55158
55159 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55160 + file->f_version = current->exec_id;
55161 +#endif
55162 +
55163 return 0;
55164 }
55165
55166 @@ -711,6 +779,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55167 ssize_t copied;
55168 char *page;
55169
55170 +#ifdef CONFIG_GRKERNSEC
55171 + if (write)
55172 + return -EPERM;
55173 +#endif
55174 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55175 + if (file->f_version != current->exec_id) {
55176 + gr_log_badprocpid("mem");
55177 + return 0;
55178 + }
55179 +#endif
55180 +
55181 if (!mm)
55182 return 0;
55183
55184 @@ -723,7 +802,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55185 goto free;
55186
55187 while (count > 0) {
55188 - int this_len = min_t(int, count, PAGE_SIZE);
55189 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55190
55191 if (write && copy_from_user(page, buf, this_len)) {
55192 copied = -EFAULT;
55193 @@ -815,6 +894,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55194 if (!mm)
55195 return 0;
55196
55197 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55198 + if (file->f_version != current->exec_id) {
55199 + gr_log_badprocpid("environ");
55200 + return 0;
55201 + }
55202 +#endif
55203 +
55204 page = (char *)__get_free_page(GFP_TEMPORARY);
55205 if (!page)
55206 return -ENOMEM;
55207 @@ -824,7 +910,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55208 goto free;
55209 while (count > 0) {
55210 size_t this_len, max_len;
55211 - int retval;
55212 + ssize_t retval;
55213
55214 if (src >= (mm->env_end - mm->env_start))
55215 break;
55216 @@ -1430,7 +1516,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55217 int error = -EACCES;
55218
55219 /* Are we allowed to snoop on the tasks file descriptors? */
55220 - if (!proc_fd_access_allowed(inode))
55221 + if (!proc_fd_access_allowed(inode, 0))
55222 goto out;
55223
55224 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55225 @@ -1474,8 +1560,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55226 struct path path;
55227
55228 /* Are we allowed to snoop on the tasks file descriptors? */
55229 - if (!proc_fd_access_allowed(inode))
55230 - goto out;
55231 + /* logging this is needed for learning on chromium to work properly,
55232 + but we don't want to flood the logs from 'ps' which does a readlink
55233 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55234 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55235 + */
55236 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55237 + if (!proc_fd_access_allowed(inode,0))
55238 + goto out;
55239 + } else {
55240 + if (!proc_fd_access_allowed(inode,1))
55241 + goto out;
55242 + }
55243
55244 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55245 if (error)
55246 @@ -1525,7 +1621,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55247 rcu_read_lock();
55248 cred = __task_cred(task);
55249 inode->i_uid = cred->euid;
55250 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55251 + inode->i_gid = grsec_proc_gid;
55252 +#else
55253 inode->i_gid = cred->egid;
55254 +#endif
55255 rcu_read_unlock();
55256 }
55257 security_task_to_inode(task, inode);
55258 @@ -1561,10 +1661,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55259 return -ENOENT;
55260 }
55261 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55262 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55263 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55264 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55265 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55266 +#endif
55267 task_dumpable(task)) {
55268 cred = __task_cred(task);
55269 stat->uid = cred->euid;
55270 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55271 + stat->gid = grsec_proc_gid;
55272 +#else
55273 stat->gid = cred->egid;
55274 +#endif
55275 }
55276 }
55277 rcu_read_unlock();
55278 @@ -1602,11 +1711,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55279
55280 if (task) {
55281 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55282 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55283 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55284 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55285 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55286 +#endif
55287 task_dumpable(task)) {
55288 rcu_read_lock();
55289 cred = __task_cred(task);
55290 inode->i_uid = cred->euid;
55291 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55292 + inode->i_gid = grsec_proc_gid;
55293 +#else
55294 inode->i_gid = cred->egid;
55295 +#endif
55296 rcu_read_unlock();
55297 } else {
55298 inode->i_uid = GLOBAL_ROOT_UID;
55299 @@ -2059,6 +2177,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55300 if (!task)
55301 goto out_no_task;
55302
55303 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55304 + goto out;
55305 +
55306 /*
55307 * Yes, it does not scale. And it should not. Don't add
55308 * new entries into /proc/<tgid>/ without very good reasons.
55309 @@ -2103,6 +2224,9 @@ static int proc_pident_readdir(struct file *filp,
55310 if (!task)
55311 goto out_no_task;
55312
55313 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55314 + goto out;
55315 +
55316 ret = 0;
55317 i = filp->f_pos;
55318 switch (i) {
55319 @@ -2516,7 +2640,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55320 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55321 #endif
55322 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55323 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55324 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55325 INF("syscall", S_IRUGO, proc_pid_syscall),
55326 #endif
55327 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55328 @@ -2541,10 +2665,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55329 #ifdef CONFIG_SECURITY
55330 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55331 #endif
55332 -#ifdef CONFIG_KALLSYMS
55333 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55334 INF("wchan", S_IRUGO, proc_pid_wchan),
55335 #endif
55336 -#ifdef CONFIG_STACKTRACE
55337 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55338 ONE("stack", S_IRUGO, proc_pid_stack),
55339 #endif
55340 #ifdef CONFIG_SCHEDSTATS
55341 @@ -2578,6 +2702,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55342 #ifdef CONFIG_HARDWALL
55343 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55344 #endif
55345 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55346 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55347 +#endif
55348 #ifdef CONFIG_USER_NS
55349 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55350 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55351 @@ -2707,7 +2834,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55352 if (!inode)
55353 goto out;
55354
55355 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55356 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55357 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55358 + inode->i_gid = grsec_proc_gid;
55359 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55360 +#else
55361 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55362 +#endif
55363 inode->i_op = &proc_tgid_base_inode_operations;
55364 inode->i_fop = &proc_tgid_base_operations;
55365 inode->i_flags|=S_IMMUTABLE;
55366 @@ -2745,7 +2879,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55367 if (!task)
55368 goto out;
55369
55370 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55371 + goto out_put_task;
55372 +
55373 result = proc_pid_instantiate(dir, dentry, task, NULL);
55374 +out_put_task:
55375 put_task_struct(task);
55376 out:
55377 return result;
55378 @@ -2808,6 +2946,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55379 static int fake_filldir(void *buf, const char *name, int namelen,
55380 loff_t offset, u64 ino, unsigned d_type)
55381 {
55382 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55383 + __buf->error = -EINVAL;
55384 return 0;
55385 }
55386
55387 @@ -2859,7 +2999,7 @@ static const struct pid_entry tid_base_stuff[] = {
55388 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55389 #endif
55390 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55391 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55392 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55393 INF("syscall", S_IRUGO, proc_pid_syscall),
55394 #endif
55395 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55396 @@ -2886,10 +3026,10 @@ static const struct pid_entry tid_base_stuff[] = {
55397 #ifdef CONFIG_SECURITY
55398 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55399 #endif
55400 -#ifdef CONFIG_KALLSYMS
55401 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55402 INF("wchan", S_IRUGO, proc_pid_wchan),
55403 #endif
55404 -#ifdef CONFIG_STACKTRACE
55405 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55406 ONE("stack", S_IRUGO, proc_pid_stack),
55407 #endif
55408 #ifdef CONFIG_SCHEDSTATS
55409 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55410 index 82676e3..5f8518a 100644
55411 --- a/fs/proc/cmdline.c
55412 +++ b/fs/proc/cmdline.c
55413 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55414
55415 static int __init proc_cmdline_init(void)
55416 {
55417 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55418 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55419 +#else
55420 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55421 +#endif
55422 return 0;
55423 }
55424 module_init(proc_cmdline_init);
55425 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55426 index b143471..bb105e5 100644
55427 --- a/fs/proc/devices.c
55428 +++ b/fs/proc/devices.c
55429 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55430
55431 static int __init proc_devices_init(void)
55432 {
55433 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55434 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55435 +#else
55436 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55437 +#endif
55438 return 0;
55439 }
55440 module_init(proc_devices_init);
55441 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55442 index d7a4a28..0201742 100644
55443 --- a/fs/proc/fd.c
55444 +++ b/fs/proc/fd.c
55445 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55446 if (!task)
55447 return -ENOENT;
55448
55449 - files = get_files_struct(task);
55450 + if (!gr_acl_handle_procpidmem(task))
55451 + files = get_files_struct(task);
55452 put_task_struct(task);
55453
55454 if (files) {
55455 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55456 */
55457 int proc_fd_permission(struct inode *inode, int mask)
55458 {
55459 + struct task_struct *task;
55460 int rv = generic_permission(inode, mask);
55461 - if (rv == 0)
55462 - return 0;
55463 +
55464 if (task_pid(current) == proc_pid(inode))
55465 rv = 0;
55466 +
55467 + task = get_proc_task(inode);
55468 + if (task == NULL)
55469 + return rv;
55470 +
55471 + if (gr_acl_handle_procpidmem(task))
55472 + rv = -EACCES;
55473 +
55474 + put_task_struct(task);
55475 +
55476 return rv;
55477 }
55478
55479 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55480 index 869116c..820cb27 100644
55481 --- a/fs/proc/inode.c
55482 +++ b/fs/proc/inode.c
55483 @@ -22,11 +22,17 @@
55484 #include <linux/seq_file.h>
55485 #include <linux/slab.h>
55486 #include <linux/mount.h>
55487 +#include <linux/grsecurity.h>
55488
55489 #include <asm/uaccess.h>
55490
55491 #include "internal.h"
55492
55493 +#ifdef CONFIG_PROC_SYSCTL
55494 +extern const struct inode_operations proc_sys_inode_operations;
55495 +extern const struct inode_operations proc_sys_dir_operations;
55496 +#endif
55497 +
55498 static void proc_evict_inode(struct inode *inode)
55499 {
55500 struct proc_dir_entry *de;
55501 @@ -54,6 +60,13 @@ static void proc_evict_inode(struct inode *inode)
55502 ns = PROC_I(inode)->ns;
55503 if (ns_ops && ns)
55504 ns_ops->put(ns);
55505 +
55506 +#ifdef CONFIG_PROC_SYSCTL
55507 + if (inode->i_op == &proc_sys_inode_operations ||
55508 + inode->i_op == &proc_sys_dir_operations)
55509 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55510 +#endif
55511 +
55512 }
55513
55514 static struct kmem_cache * proc_inode_cachep;
55515 @@ -456,7 +469,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55516 if (de->mode) {
55517 inode->i_mode = de->mode;
55518 inode->i_uid = de->uid;
55519 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55520 + inode->i_gid = grsec_proc_gid;
55521 +#else
55522 inode->i_gid = de->gid;
55523 +#endif
55524 }
55525 if (de->size)
55526 inode->i_size = de->size;
55527 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55528 index 85ff3a4..a512bd8 100644
55529 --- a/fs/proc/internal.h
55530 +++ b/fs/proc/internal.h
55531 @@ -56,6 +56,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55532 struct pid *pid, struct task_struct *task);
55533 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55534 struct pid *pid, struct task_struct *task);
55535 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55536 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55537 +#endif
55538 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55539
55540 extern const struct file_operations proc_tid_children_operations;
55541 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55542 index eda6f01..006ae24 100644
55543 --- a/fs/proc/kcore.c
55544 +++ b/fs/proc/kcore.c
55545 @@ -481,9 +481,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55546 * the addresses in the elf_phdr on our list.
55547 */
55548 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55549 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55550 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55551 + if (tsz > buflen)
55552 tsz = buflen;
55553 -
55554 +
55555 while (buflen) {
55556 struct kcore_list *m;
55557
55558 @@ -512,20 +513,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55559 kfree(elf_buf);
55560 } else {
55561 if (kern_addr_valid(start)) {
55562 - unsigned long n;
55563 + char *elf_buf;
55564 + mm_segment_t oldfs;
55565
55566 - n = copy_to_user(buffer, (char *)start, tsz);
55567 - /*
55568 - * We cannot distinguish between fault on source
55569 - * and fault on destination. When this happens
55570 - * we clear too and hope it will trigger the
55571 - * EFAULT again.
55572 - */
55573 - if (n) {
55574 - if (clear_user(buffer + tsz - n,
55575 - n))
55576 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55577 + if (!elf_buf)
55578 + return -ENOMEM;
55579 + oldfs = get_fs();
55580 + set_fs(KERNEL_DS);
55581 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55582 + set_fs(oldfs);
55583 + if (copy_to_user(buffer, elf_buf, tsz)) {
55584 + kfree(elf_buf);
55585 return -EFAULT;
55586 + }
55587 }
55588 + set_fs(oldfs);
55589 + kfree(elf_buf);
55590 } else {
55591 if (clear_user(buffer, tsz))
55592 return -EFAULT;
55593 @@ -545,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55594
55595 static int open_kcore(struct inode *inode, struct file *filp)
55596 {
55597 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55598 + return -EPERM;
55599 +#endif
55600 if (!capable(CAP_SYS_RAWIO))
55601 return -EPERM;
55602 if (kcore_need_update)
55603 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55604 index 1efaaa1..834e49a 100644
55605 --- a/fs/proc/meminfo.c
55606 +++ b/fs/proc/meminfo.c
55607 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55608 vmi.used >> 10,
55609 vmi.largest_chunk >> 10
55610 #ifdef CONFIG_MEMORY_FAILURE
55611 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55612 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55613 #endif
55614 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55615 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55616 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55617 index ccfd99b..1b7e255 100644
55618 --- a/fs/proc/nommu.c
55619 +++ b/fs/proc/nommu.c
55620 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55621 if (len < 1)
55622 len = 1;
55623 seq_printf(m, "%*c", len, ' ');
55624 - seq_path(m, &file->f_path, "");
55625 + seq_path(m, &file->f_path, "\n\\");
55626 }
55627
55628 seq_putc(m, '\n');
55629 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55630 index b4ac657..0842bd2 100644
55631 --- a/fs/proc/proc_net.c
55632 +++ b/fs/proc/proc_net.c
55633 @@ -23,6 +23,7 @@
55634 #include <linux/nsproxy.h>
55635 #include <net/net_namespace.h>
55636 #include <linux/seq_file.h>
55637 +#include <linux/grsecurity.h>
55638
55639 #include "internal.h"
55640
55641 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55642 struct task_struct *task;
55643 struct nsproxy *ns;
55644 struct net *net = NULL;
55645 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55646 + const struct cred *cred = current_cred();
55647 +#endif
55648 +
55649 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55650 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55651 + return net;
55652 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55653 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55654 + return net;
55655 +#endif
55656
55657 rcu_read_lock();
55658 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55659 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55660 index ac05f33..1e6dc7e 100644
55661 --- a/fs/proc/proc_sysctl.c
55662 +++ b/fs/proc/proc_sysctl.c
55663 @@ -13,11 +13,15 @@
55664 #include <linux/module.h>
55665 #include "internal.h"
55666
55667 +extern int gr_handle_chroot_sysctl(const int op);
55668 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55669 + const int op);
55670 +
55671 static const struct dentry_operations proc_sys_dentry_operations;
55672 static const struct file_operations proc_sys_file_operations;
55673 -static const struct inode_operations proc_sys_inode_operations;
55674 +const struct inode_operations proc_sys_inode_operations;
55675 static const struct file_operations proc_sys_dir_file_operations;
55676 -static const struct inode_operations proc_sys_dir_operations;
55677 +const struct inode_operations proc_sys_dir_operations;
55678
55679 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55680 {
55681 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55682
55683 err = NULL;
55684 d_set_d_op(dentry, &proc_sys_dentry_operations);
55685 +
55686 + gr_handle_proc_create(dentry, inode);
55687 +
55688 d_add(dentry, inode);
55689
55690 out:
55691 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55692 struct inode *inode = file_inode(filp);
55693 struct ctl_table_header *head = grab_header(inode);
55694 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55695 + int op = write ? MAY_WRITE : MAY_READ;
55696 ssize_t error;
55697 size_t res;
55698
55699 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55700 * and won't be until we finish.
55701 */
55702 error = -EPERM;
55703 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55704 + if (sysctl_perm(head, table, op))
55705 goto out;
55706
55707 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55708 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55709 if (!table->proc_handler)
55710 goto out;
55711
55712 +#ifdef CONFIG_GRKERNSEC
55713 + error = -EPERM;
55714 + if (gr_handle_chroot_sysctl(op))
55715 + goto out;
55716 + dget(filp->f_path.dentry);
55717 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55718 + dput(filp->f_path.dentry);
55719 + goto out;
55720 + }
55721 + dput(filp->f_path.dentry);
55722 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55723 + goto out;
55724 + if (write && !capable(CAP_SYS_ADMIN))
55725 + goto out;
55726 +#endif
55727 +
55728 /* careful: calling conventions are nasty here */
55729 res = count;
55730 error = table->proc_handler(table, write, buf, &res, ppos);
55731 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55732 return -ENOMEM;
55733 } else {
55734 d_set_d_op(child, &proc_sys_dentry_operations);
55735 +
55736 + gr_handle_proc_create(child, inode);
55737 +
55738 d_add(child, inode);
55739 }
55740 } else {
55741 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55742 if ((*pos)++ < file->f_pos)
55743 return 0;
55744
55745 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55746 + return 0;
55747 +
55748 if (unlikely(S_ISLNK(table->mode)))
55749 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55750 else
55751 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55752 if (IS_ERR(head))
55753 return PTR_ERR(head);
55754
55755 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55756 + return -ENOENT;
55757 +
55758 generic_fillattr(inode, stat);
55759 if (table)
55760 stat->mode = (stat->mode & S_IFMT) | table->mode;
55761 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55762 .llseek = generic_file_llseek,
55763 };
55764
55765 -static const struct inode_operations proc_sys_inode_operations = {
55766 +const struct inode_operations proc_sys_inode_operations = {
55767 .permission = proc_sys_permission,
55768 .setattr = proc_sys_setattr,
55769 .getattr = proc_sys_getattr,
55770 };
55771
55772 -static const struct inode_operations proc_sys_dir_operations = {
55773 +const struct inode_operations proc_sys_dir_operations = {
55774 .lookup = proc_sys_lookup,
55775 .permission = proc_sys_permission,
55776 .setattr = proc_sys_setattr,
55777 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55778 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55779 const char *name, int namelen)
55780 {
55781 - struct ctl_table *table;
55782 + ctl_table_no_const *table;
55783 struct ctl_dir *new;
55784 struct ctl_node *node;
55785 char *new_name;
55786 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55787 return NULL;
55788
55789 node = (struct ctl_node *)(new + 1);
55790 - table = (struct ctl_table *)(node + 1);
55791 + table = (ctl_table_no_const *)(node + 1);
55792 new_name = (char *)(table + 2);
55793 memcpy(new_name, name, namelen);
55794 new_name[namelen] = '\0';
55795 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55796 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55797 struct ctl_table_root *link_root)
55798 {
55799 - struct ctl_table *link_table, *entry, *link;
55800 + ctl_table_no_const *link_table, *link;
55801 + struct ctl_table *entry;
55802 struct ctl_table_header *links;
55803 struct ctl_node *node;
55804 char *link_name;
55805 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55806 return NULL;
55807
55808 node = (struct ctl_node *)(links + 1);
55809 - link_table = (struct ctl_table *)(node + nr_entries);
55810 + link_table = (ctl_table_no_const *)(node + nr_entries);
55811 link_name = (char *)&link_table[nr_entries + 1];
55812
55813 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55814 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55815 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55816 struct ctl_table *table)
55817 {
55818 - struct ctl_table *ctl_table_arg = NULL;
55819 - struct ctl_table *entry, *files;
55820 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55821 + struct ctl_table *entry;
55822 int nr_files = 0;
55823 int nr_dirs = 0;
55824 int err = -ENOMEM;
55825 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55826 nr_files++;
55827 }
55828
55829 - files = table;
55830 /* If there are mixed files and directories we need a new table */
55831 if (nr_dirs && nr_files) {
55832 - struct ctl_table *new;
55833 + ctl_table_no_const *new;
55834 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55835 GFP_KERNEL);
55836 if (!files)
55837 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55838 /* Register everything except a directory full of subdirectories */
55839 if (nr_files || !nr_dirs) {
55840 struct ctl_table_header *header;
55841 - header = __register_sysctl_table(set, path, files);
55842 + header = __register_sysctl_table(set, path, files ? files : table);
55843 if (!header) {
55844 kfree(ctl_table_arg);
55845 goto out;
55846 diff --git a/fs/proc/root.c b/fs/proc/root.c
55847 index 9c7fab1..ed1c8e0 100644
55848 --- a/fs/proc/root.c
55849 +++ b/fs/proc/root.c
55850 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55851 #ifdef CONFIG_PROC_DEVICETREE
55852 proc_device_tree_init();
55853 #endif
55854 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55855 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55856 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55857 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55858 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55859 +#endif
55860 +#else
55861 proc_mkdir("bus", NULL);
55862 +#endif
55863 proc_sys_init();
55864 }
55865
55866 diff --git a/fs/proc/self.c b/fs/proc/self.c
55867 index aa5cc3b..c91a5d0 100644
55868 --- a/fs/proc/self.c
55869 +++ b/fs/proc/self.c
55870 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55871 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55872 void *cookie)
55873 {
55874 - char *s = nd_get_link(nd);
55875 + const char *s = nd_get_link(nd);
55876 if (!IS_ERR(s))
55877 kfree(s);
55878 }
55879 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55880 index 3e636d8..83e3b71 100644
55881 --- a/fs/proc/task_mmu.c
55882 +++ b/fs/proc/task_mmu.c
55883 @@ -11,12 +11,19 @@
55884 #include <linux/rmap.h>
55885 #include <linux/swap.h>
55886 #include <linux/swapops.h>
55887 +#include <linux/grsecurity.h>
55888
55889 #include <asm/elf.h>
55890 #include <asm/uaccess.h>
55891 #include <asm/tlbflush.h>
55892 #include "internal.h"
55893
55894 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55895 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55896 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55897 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55898 +#endif
55899 +
55900 void task_mem(struct seq_file *m, struct mm_struct *mm)
55901 {
55902 unsigned long data, text, lib, swap;
55903 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55904 "VmExe:\t%8lu kB\n"
55905 "VmLib:\t%8lu kB\n"
55906 "VmPTE:\t%8lu kB\n"
55907 - "VmSwap:\t%8lu kB\n",
55908 - hiwater_vm << (PAGE_SHIFT-10),
55909 + "VmSwap:\t%8lu kB\n"
55910 +
55911 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55912 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55913 +#endif
55914 +
55915 + ,hiwater_vm << (PAGE_SHIFT-10),
55916 total_vm << (PAGE_SHIFT-10),
55917 mm->locked_vm << (PAGE_SHIFT-10),
55918 mm->pinned_vm << (PAGE_SHIFT-10),
55919 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55920 data << (PAGE_SHIFT-10),
55921 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55922 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55923 - swap << (PAGE_SHIFT-10));
55924 + swap << (PAGE_SHIFT-10)
55925 +
55926 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55927 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55928 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55929 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55930 +#else
55931 + , mm->context.user_cs_base
55932 + , mm->context.user_cs_limit
55933 +#endif
55934 +#endif
55935 +
55936 + );
55937 }
55938
55939 unsigned long task_vsize(struct mm_struct *mm)
55940 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55941 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55942 }
55943
55944 - /* We don't show the stack guard page in /proc/maps */
55945 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55946 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55947 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55948 +#else
55949 start = vma->vm_start;
55950 - if (stack_guard_page_start(vma, start))
55951 - start += PAGE_SIZE;
55952 end = vma->vm_end;
55953 - if (stack_guard_page_end(vma, end))
55954 - end -= PAGE_SIZE;
55955 +#endif
55956
55957 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55958 start,
55959 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55960 flags & VM_WRITE ? 'w' : '-',
55961 flags & VM_EXEC ? 'x' : '-',
55962 flags & VM_MAYSHARE ? 's' : 'p',
55963 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55964 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55965 +#else
55966 pgoff,
55967 +#endif
55968 MAJOR(dev), MINOR(dev), ino, &len);
55969
55970 /*
55971 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55972 */
55973 if (file) {
55974 pad_len_spaces(m, len);
55975 - seq_path(m, &file->f_path, "\n");
55976 + seq_path(m, &file->f_path, "\n\\");
55977 goto done;
55978 }
55979
55980 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55981 * Thread stack in /proc/PID/task/TID/maps or
55982 * the main process stack.
55983 */
55984 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
55985 - vma->vm_end >= mm->start_stack)) {
55986 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
55987 + (vma->vm_start <= mm->start_stack &&
55988 + vma->vm_end >= mm->start_stack)) {
55989 name = "[stack]";
55990 } else {
55991 /* Thread stack in /proc/PID/maps */
55992 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
55993 struct proc_maps_private *priv = m->private;
55994 struct task_struct *task = priv->task;
55995
55996 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55997 + if (current->exec_id != m->exec_id) {
55998 + gr_log_badprocpid("maps");
55999 + return 0;
56000 + }
56001 +#endif
56002 +
56003 show_map_vma(m, vma, is_pid);
56004
56005 if (m->count < m->size) /* vma is copied successfully */
56006 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56007 .private = &mss,
56008 };
56009
56010 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56011 + if (current->exec_id != m->exec_id) {
56012 + gr_log_badprocpid("smaps");
56013 + return 0;
56014 + }
56015 +#endif
56016 memset(&mss, 0, sizeof mss);
56017 - mss.vma = vma;
56018 - /* mmap_sem is held in m_start */
56019 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56020 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56021 -
56022 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56023 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56024 +#endif
56025 + mss.vma = vma;
56026 + /* mmap_sem is held in m_start */
56027 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56028 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56029 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56030 + }
56031 +#endif
56032 show_map_vma(m, vma, is_pid);
56033
56034 seq_printf(m,
56035 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56036 "KernelPageSize: %8lu kB\n"
56037 "MMUPageSize: %8lu kB\n"
56038 "Locked: %8lu kB\n",
56039 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56040 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56041 +#else
56042 (vma->vm_end - vma->vm_start) >> 10,
56043 +#endif
56044 mss.resident >> 10,
56045 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56046 mss.shared_clean >> 10,
56047 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56048 int n;
56049 char buffer[50];
56050
56051 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56052 + if (current->exec_id != m->exec_id) {
56053 + gr_log_badprocpid("numa_maps");
56054 + return 0;
56055 + }
56056 +#endif
56057 +
56058 if (!mm)
56059 return 0;
56060
56061 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56062 mpol_to_str(buffer, sizeof(buffer), pol);
56063 mpol_cond_put(pol);
56064
56065 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56066 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56067 +#else
56068 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56069 +#endif
56070
56071 if (file) {
56072 seq_printf(m, " file=");
56073 - seq_path(m, &file->f_path, "\n\t= ");
56074 + seq_path(m, &file->f_path, "\n\t\\= ");
56075 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56076 seq_printf(m, " heap");
56077 } else {
56078 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56079 index 56123a6..5a2f6ec 100644
56080 --- a/fs/proc/task_nommu.c
56081 +++ b/fs/proc/task_nommu.c
56082 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56083 else
56084 bytes += kobjsize(mm);
56085
56086 - if (current->fs && current->fs->users > 1)
56087 + if (current->fs && atomic_read(&current->fs->users) > 1)
56088 sbytes += kobjsize(current->fs);
56089 else
56090 bytes += kobjsize(current->fs);
56091 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56092
56093 if (file) {
56094 pad_len_spaces(m, len);
56095 - seq_path(m, &file->f_path, "");
56096 + seq_path(m, &file->f_path, "\n\\");
56097 } else if (mm) {
56098 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56099
56100 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
56101 index b870f74..e9048df 100644
56102 --- a/fs/proc/vmcore.c
56103 +++ b/fs/proc/vmcore.c
56104 @@ -98,9 +98,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
56105 nr_bytes = count;
56106
56107 /* If pfn is not ram, return zeros for sparse dump files */
56108 - if (pfn_is_ram(pfn) == 0)
56109 - memset(buf, 0, nr_bytes);
56110 - else {
56111 + if (pfn_is_ram(pfn) == 0) {
56112 + if (userbuf) {
56113 + if (clear_user((char __force_user *)buf, nr_bytes))
56114 + return -EFAULT;
56115 + } else
56116 + memset(buf, 0, nr_bytes);
56117 + } else {
56118 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
56119 offset, userbuf);
56120 if (tmp < 0)
56121 @@ -185,7 +189,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
56122 if (tsz > nr_bytes)
56123 tsz = nr_bytes;
56124
56125 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
56126 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
56127 if (tmp < 0)
56128 return tmp;
56129 buflen -= tsz;
56130 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56131 index b00fcc9..e0c6381 100644
56132 --- a/fs/qnx6/qnx6.h
56133 +++ b/fs/qnx6/qnx6.h
56134 @@ -74,7 +74,7 @@ enum {
56135 BYTESEX_BE,
56136 };
56137
56138 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56139 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56140 {
56141 if (sbi->s_bytesex == BYTESEX_LE)
56142 return le64_to_cpu((__force __le64)n);
56143 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56144 return (__force __fs64)cpu_to_be64(n);
56145 }
56146
56147 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56148 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56149 {
56150 if (sbi->s_bytesex == BYTESEX_LE)
56151 return le32_to_cpu((__force __le32)n);
56152 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56153 index 16e8abb..2dcf914 100644
56154 --- a/fs/quota/netlink.c
56155 +++ b/fs/quota/netlink.c
56156 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56157 void quota_send_warning(struct kqid qid, dev_t dev,
56158 const char warntype)
56159 {
56160 - static atomic_t seq;
56161 + static atomic_unchecked_t seq;
56162 struct sk_buff *skb;
56163 void *msg_head;
56164 int ret;
56165 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56166 "VFS: Not enough memory to send quota warning.\n");
56167 return;
56168 }
56169 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56170 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56171 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56172 if (!msg_head) {
56173 printk(KERN_ERR
56174 diff --git a/fs/read_write.c b/fs/read_write.c
56175 index e6ddc8d..9155227 100644
56176 --- a/fs/read_write.c
56177 +++ b/fs/read_write.c
56178 @@ -429,7 +429,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
56179
56180 old_fs = get_fs();
56181 set_fs(get_ds());
56182 - p = (__force const char __user *)buf;
56183 + p = (const char __force_user *)buf;
56184 if (count > MAX_RW_COUNT)
56185 count = MAX_RW_COUNT;
56186 if (file->f_op->write)
56187 diff --git a/fs/readdir.c b/fs/readdir.c
56188 index fee38e0..12fdf47 100644
56189 --- a/fs/readdir.c
56190 +++ b/fs/readdir.c
56191 @@ -17,6 +17,7 @@
56192 #include <linux/security.h>
56193 #include <linux/syscalls.h>
56194 #include <linux/unistd.h>
56195 +#include <linux/namei.h>
56196
56197 #include <asm/uaccess.h>
56198
56199 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56200
56201 struct readdir_callback {
56202 struct old_linux_dirent __user * dirent;
56203 + struct file * file;
56204 int result;
56205 };
56206
56207 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56208 buf->result = -EOVERFLOW;
56209 return -EOVERFLOW;
56210 }
56211 +
56212 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56213 + return 0;
56214 +
56215 buf->result++;
56216 dirent = buf->dirent;
56217 if (!access_ok(VERIFY_WRITE, dirent,
56218 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56219
56220 buf.result = 0;
56221 buf.dirent = dirent;
56222 + buf.file = f.file;
56223
56224 error = vfs_readdir(f.file, fillonedir, &buf);
56225 if (buf.result)
56226 @@ -139,6 +146,7 @@ struct linux_dirent {
56227 struct getdents_callback {
56228 struct linux_dirent __user * current_dir;
56229 struct linux_dirent __user * previous;
56230 + struct file * file;
56231 int count;
56232 int error;
56233 };
56234 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56235 buf->error = -EOVERFLOW;
56236 return -EOVERFLOW;
56237 }
56238 +
56239 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56240 + return 0;
56241 +
56242 dirent = buf->previous;
56243 if (dirent) {
56244 if (__put_user(offset, &dirent->d_off))
56245 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56246 buf.previous = NULL;
56247 buf.count = count;
56248 buf.error = 0;
56249 + buf.file = f.file;
56250
56251 error = vfs_readdir(f.file, filldir, &buf);
56252 if (error >= 0)
56253 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56254 struct getdents_callback64 {
56255 struct linux_dirent64 __user * current_dir;
56256 struct linux_dirent64 __user * previous;
56257 + struct file *file;
56258 int count;
56259 int error;
56260 };
56261 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56262 buf->error = -EINVAL; /* only used if we fail.. */
56263 if (reclen > buf->count)
56264 return -EINVAL;
56265 +
56266 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56267 + return 0;
56268 +
56269 dirent = buf->previous;
56270 if (dirent) {
56271 if (__put_user(offset, &dirent->d_off))
56272 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56273
56274 buf.current_dir = dirent;
56275 buf.previous = NULL;
56276 + buf.file = f.file;
56277 buf.count = count;
56278 buf.error = 0;
56279
56280 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56281 error = buf.error;
56282 lastdirent = buf.previous;
56283 if (lastdirent) {
56284 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56285 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56286 if (__put_user(d_off, &lastdirent->d_off))
56287 error = -EFAULT;
56288 else
56289 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56290 index 2b7882b..1c5ef48 100644
56291 --- a/fs/reiserfs/do_balan.c
56292 +++ b/fs/reiserfs/do_balan.c
56293 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56294 return;
56295 }
56296
56297 - atomic_inc(&(fs_generation(tb->tb_sb)));
56298 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56299 do_balance_starts(tb);
56300
56301 /* balance leaf returns 0 except if combining L R and S into
56302 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56303 index 9cc0740a..46bf953 100644
56304 --- a/fs/reiserfs/procfs.c
56305 +++ b/fs/reiserfs/procfs.c
56306 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56307 "SMALL_TAILS " : "NO_TAILS ",
56308 replay_only(sb) ? "REPLAY_ONLY " : "",
56309 convert_reiserfs(sb) ? "CONV " : "",
56310 - atomic_read(&r->s_generation_counter),
56311 + atomic_read_unchecked(&r->s_generation_counter),
56312 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56313 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56314 SF(s_good_search_by_key_reada), SF(s_bmaps),
56315 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56316 index 157e474..65a6114 100644
56317 --- a/fs/reiserfs/reiserfs.h
56318 +++ b/fs/reiserfs/reiserfs.h
56319 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56320 /* Comment? -Hans */
56321 wait_queue_head_t s_wait;
56322 /* To be obsoleted soon by per buffer seals.. -Hans */
56323 - atomic_t s_generation_counter; // increased by one every time the
56324 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56325 // tree gets re-balanced
56326 unsigned long s_properties; /* File system properties. Currently holds
56327 on-disk FS format */
56328 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56329 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56330
56331 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56332 -#define get_generation(s) atomic_read (&fs_generation(s))
56333 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56334 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56335 #define __fs_changed(gen,s) (gen != get_generation (s))
56336 #define fs_changed(gen,s) \
56337 diff --git a/fs/select.c b/fs/select.c
56338 index 8c1c96c..a0f9b6d 100644
56339 --- a/fs/select.c
56340 +++ b/fs/select.c
56341 @@ -20,6 +20,7 @@
56342 #include <linux/export.h>
56343 #include <linux/slab.h>
56344 #include <linux/poll.h>
56345 +#include <linux/security.h>
56346 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56347 #include <linux/file.h>
56348 #include <linux/fdtable.h>
56349 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56350 struct poll_list *walk = head;
56351 unsigned long todo = nfds;
56352
56353 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56354 if (nfds > rlimit(RLIMIT_NOFILE))
56355 return -EINVAL;
56356
56357 diff --git a/fs/seq_file.c b/fs/seq_file.c
56358 index 38bb59f..a304f9d 100644
56359 --- a/fs/seq_file.c
56360 +++ b/fs/seq_file.c
56361 @@ -10,6 +10,7 @@
56362 #include <linux/seq_file.h>
56363 #include <linux/slab.h>
56364 #include <linux/cred.h>
56365 +#include <linux/sched.h>
56366
56367 #include <asm/uaccess.h>
56368 #include <asm/page.h>
56369 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56370 #ifdef CONFIG_USER_NS
56371 p->user_ns = file->f_cred->user_ns;
56372 #endif
56373 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56374 + p->exec_id = current->exec_id;
56375 +#endif
56376
56377 /*
56378 * Wrappers around seq_open(e.g. swaps_open) need to be
56379 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56380 return 0;
56381 }
56382 if (!m->buf) {
56383 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56384 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56385 if (!m->buf)
56386 return -ENOMEM;
56387 }
56388 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56389 Eoverflow:
56390 m->op->stop(m, p);
56391 kfree(m->buf);
56392 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56393 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56394 return !m->buf ? -ENOMEM : -EAGAIN;
56395 }
56396
56397 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56398
56399 /* grab buffer if we didn't have one */
56400 if (!m->buf) {
56401 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56402 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56403 if (!m->buf)
56404 goto Enomem;
56405 }
56406 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56407 goto Fill;
56408 m->op->stop(m, p);
56409 kfree(m->buf);
56410 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56411 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56412 if (!m->buf)
56413 goto Enomem;
56414 m->count = 0;
56415 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56416 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56417 void *data)
56418 {
56419 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56420 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56421 int res = -ENOMEM;
56422
56423 if (op) {
56424 diff --git a/fs/splice.c b/fs/splice.c
56425 index 29e394e..b13c247 100644
56426 --- a/fs/splice.c
56427 +++ b/fs/splice.c
56428 @@ -195,7 +195,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56429 pipe_lock(pipe);
56430
56431 for (;;) {
56432 - if (!pipe->readers) {
56433 + if (!atomic_read(&pipe->readers)) {
56434 send_sig(SIGPIPE, current, 0);
56435 if (!ret)
56436 ret = -EPIPE;
56437 @@ -249,9 +249,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56438 do_wakeup = 0;
56439 }
56440
56441 - pipe->waiting_writers++;
56442 + atomic_inc(&pipe->waiting_writers);
56443 pipe_wait(pipe);
56444 - pipe->waiting_writers--;
56445 + atomic_dec(&pipe->waiting_writers);
56446 }
56447
56448 pipe_unlock(pipe);
56449 @@ -564,7 +564,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56450 old_fs = get_fs();
56451 set_fs(get_ds());
56452 /* The cast to a user pointer is valid due to the set_fs() */
56453 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56454 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56455 set_fs(old_fs);
56456
56457 return res;
56458 @@ -579,7 +579,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56459 old_fs = get_fs();
56460 set_fs(get_ds());
56461 /* The cast to a user pointer is valid due to the set_fs() */
56462 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
56463 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56464 set_fs(old_fs);
56465
56466 return res;
56467 @@ -632,7 +632,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56468 goto err;
56469
56470 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56471 - vec[i].iov_base = (void __user *) page_address(page);
56472 + vec[i].iov_base = (void __force_user *) page_address(page);
56473 vec[i].iov_len = this_len;
56474 spd.pages[i] = page;
56475 spd.nr_pages++;
56476 @@ -853,10 +853,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56477 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56478 {
56479 while (!pipe->nrbufs) {
56480 - if (!pipe->writers)
56481 + if (!atomic_read(&pipe->writers))
56482 return 0;
56483
56484 - if (!pipe->waiting_writers && sd->num_spliced)
56485 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56486 return 0;
56487
56488 if (sd->flags & SPLICE_F_NONBLOCK)
56489 @@ -1192,7 +1192,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56490 * out of the pipe right after the splice_to_pipe(). So set
56491 * PIPE_READERS appropriately.
56492 */
56493 - pipe->readers = 1;
56494 + atomic_set(&pipe->readers, 1);
56495
56496 current->splice_pipe = pipe;
56497 }
56498 @@ -1741,9 +1741,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56499 ret = -ERESTARTSYS;
56500 break;
56501 }
56502 - if (!pipe->writers)
56503 + if (!atomic_read(&pipe->writers))
56504 break;
56505 - if (!pipe->waiting_writers) {
56506 + if (!atomic_read(&pipe->waiting_writers)) {
56507 if (flags & SPLICE_F_NONBLOCK) {
56508 ret = -EAGAIN;
56509 break;
56510 @@ -1775,7 +1775,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56511 pipe_lock(pipe);
56512
56513 while (pipe->nrbufs >= pipe->buffers) {
56514 - if (!pipe->readers) {
56515 + if (!atomic_read(&pipe->readers)) {
56516 send_sig(SIGPIPE, current, 0);
56517 ret = -EPIPE;
56518 break;
56519 @@ -1788,9 +1788,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56520 ret = -ERESTARTSYS;
56521 break;
56522 }
56523 - pipe->waiting_writers++;
56524 + atomic_inc(&pipe->waiting_writers);
56525 pipe_wait(pipe);
56526 - pipe->waiting_writers--;
56527 + atomic_dec(&pipe->waiting_writers);
56528 }
56529
56530 pipe_unlock(pipe);
56531 @@ -1826,14 +1826,14 @@ retry:
56532 pipe_double_lock(ipipe, opipe);
56533
56534 do {
56535 - if (!opipe->readers) {
56536 + if (!atomic_read(&opipe->readers)) {
56537 send_sig(SIGPIPE, current, 0);
56538 if (!ret)
56539 ret = -EPIPE;
56540 break;
56541 }
56542
56543 - if (!ipipe->nrbufs && !ipipe->writers)
56544 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56545 break;
56546
56547 /*
56548 @@ -1930,7 +1930,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56549 pipe_double_lock(ipipe, opipe);
56550
56551 do {
56552 - if (!opipe->readers) {
56553 + if (!atomic_read(&opipe->readers)) {
56554 send_sig(SIGPIPE, current, 0);
56555 if (!ret)
56556 ret = -EPIPE;
56557 @@ -1975,7 +1975,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56558 * return EAGAIN if we have the potential of some data in the
56559 * future, otherwise just return 0
56560 */
56561 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56562 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56563 ret = -EAGAIN;
56564
56565 pipe_unlock(ipipe);
56566 diff --git a/fs/stat.c b/fs/stat.c
56567 index 04ce1ac..a13dd1e 100644
56568 --- a/fs/stat.c
56569 +++ b/fs/stat.c
56570 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56571 stat->gid = inode->i_gid;
56572 stat->rdev = inode->i_rdev;
56573 stat->size = i_size_read(inode);
56574 - stat->atime = inode->i_atime;
56575 - stat->mtime = inode->i_mtime;
56576 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56577 + stat->atime = inode->i_ctime;
56578 + stat->mtime = inode->i_ctime;
56579 + } else {
56580 + stat->atime = inode->i_atime;
56581 + stat->mtime = inode->i_mtime;
56582 + }
56583 stat->ctime = inode->i_ctime;
56584 stat->blksize = (1 << inode->i_blkbits);
56585 stat->blocks = inode->i_blocks;
56586 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
56587 if (retval)
56588 return retval;
56589
56590 - if (inode->i_op->getattr)
56591 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
56592 + if (inode->i_op->getattr) {
56593 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
56594 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56595 + stat->atime = stat->ctime;
56596 + stat->mtime = stat->ctime;
56597 + }
56598 + return retval;
56599 + }
56600
56601 generic_fillattr(inode, stat);
56602 return 0;
56603 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56604 index 15c68f9..36a8b3e 100644
56605 --- a/fs/sysfs/bin.c
56606 +++ b/fs/sysfs/bin.c
56607 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56608 return ret;
56609 }
56610
56611 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56612 - void *buf, int len, int write)
56613 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56614 + void *buf, size_t len, int write)
56615 {
56616 struct file *file = vma->vm_file;
56617 struct bin_buffer *bb = file->private_data;
56618 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56619 - int ret;
56620 + ssize_t ret;
56621
56622 if (!bb->vm_ops)
56623 return -EINVAL;
56624 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56625 index 6f31590..3c87c8a 100644
56626 --- a/fs/sysfs/dir.c
56627 +++ b/fs/sysfs/dir.c
56628 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56629 *
56630 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56631 */
56632 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56633 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56634 {
56635 unsigned long hash = init_name_hash();
56636 unsigned int len = strlen(name);
56637 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56638 struct sysfs_dirent *sd;
56639 int rc;
56640
56641 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56642 + const char *parent_name = parent_sd->s_name;
56643 +
56644 + mode = S_IFDIR | S_IRWXU;
56645 +
56646 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56647 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56648 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56649 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56650 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56651 +#endif
56652 +
56653 /* allocate */
56654 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56655 if (!sd)
56656 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56657 index 602f56d..6853db8 100644
56658 --- a/fs/sysfs/file.c
56659 +++ b/fs/sysfs/file.c
56660 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56661
56662 struct sysfs_open_dirent {
56663 atomic_t refcnt;
56664 - atomic_t event;
56665 + atomic_unchecked_t event;
56666 wait_queue_head_t poll;
56667 struct list_head buffers; /* goes through sysfs_buffer.list */
56668 };
56669 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56670 if (!sysfs_get_active(attr_sd))
56671 return -ENODEV;
56672
56673 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56674 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56675 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56676
56677 sysfs_put_active(attr_sd);
56678 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56679 return -ENOMEM;
56680
56681 atomic_set(&new_od->refcnt, 0);
56682 - atomic_set(&new_od->event, 1);
56683 + atomic_set_unchecked(&new_od->event, 1);
56684 init_waitqueue_head(&new_od->poll);
56685 INIT_LIST_HEAD(&new_od->buffers);
56686 goto retry;
56687 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56688
56689 sysfs_put_active(attr_sd);
56690
56691 - if (buffer->event != atomic_read(&od->event))
56692 + if (buffer->event != atomic_read_unchecked(&od->event))
56693 goto trigger;
56694
56695 return DEFAULT_POLLMASK;
56696 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56697
56698 od = sd->s_attr.open;
56699 if (od) {
56700 - atomic_inc(&od->event);
56701 + atomic_inc_unchecked(&od->event);
56702 wake_up_interruptible(&od->poll);
56703 }
56704
56705 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56706 index 8c940df..25b733e 100644
56707 --- a/fs/sysfs/symlink.c
56708 +++ b/fs/sysfs/symlink.c
56709 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56710
56711 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56712 {
56713 - char *page = nd_get_link(nd);
56714 + const char *page = nd_get_link(nd);
56715 if (!IS_ERR(page))
56716 free_page((unsigned long)page);
56717 }
56718 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56719 index 69d4889..a810bd4 100644
56720 --- a/fs/sysv/sysv.h
56721 +++ b/fs/sysv/sysv.h
56722 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56723 #endif
56724 }
56725
56726 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56727 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56728 {
56729 if (sbi->s_bytesex == BYTESEX_PDP)
56730 return PDP_swab((__force __u32)n);
56731 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56732 index e18b988..f1d4ad0f 100644
56733 --- a/fs/ubifs/io.c
56734 +++ b/fs/ubifs/io.c
56735 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56736 return err;
56737 }
56738
56739 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56740 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56741 {
56742 int err;
56743
56744 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56745 index c175b4d..8f36a16 100644
56746 --- a/fs/udf/misc.c
56747 +++ b/fs/udf/misc.c
56748 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56749
56750 u8 udf_tag_checksum(const struct tag *t)
56751 {
56752 - u8 *data = (u8 *)t;
56753 + const u8 *data = (const u8 *)t;
56754 u8 checksum = 0;
56755 int i;
56756 for (i = 0; i < sizeof(struct tag); ++i)
56757 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56758 index 8d974c4..b82f6ec 100644
56759 --- a/fs/ufs/swab.h
56760 +++ b/fs/ufs/swab.h
56761 @@ -22,7 +22,7 @@ enum {
56762 BYTESEX_BE
56763 };
56764
56765 -static inline u64
56766 +static inline u64 __intentional_overflow(-1)
56767 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56768 {
56769 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56770 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56771 return (__force __fs64)cpu_to_be64(n);
56772 }
56773
56774 -static inline u32
56775 +static inline u32 __intentional_overflow(-1)
56776 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56777 {
56778 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56779 diff --git a/fs/utimes.c b/fs/utimes.c
56780 index f4fb7ec..3fe03c0 100644
56781 --- a/fs/utimes.c
56782 +++ b/fs/utimes.c
56783 @@ -1,6 +1,7 @@
56784 #include <linux/compiler.h>
56785 #include <linux/file.h>
56786 #include <linux/fs.h>
56787 +#include <linux/security.h>
56788 #include <linux/linkage.h>
56789 #include <linux/mount.h>
56790 #include <linux/namei.h>
56791 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56792 goto mnt_drop_write_and_out;
56793 }
56794 }
56795 +
56796 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56797 + error = -EACCES;
56798 + goto mnt_drop_write_and_out;
56799 + }
56800 +
56801 mutex_lock(&inode->i_mutex);
56802 error = notify_change(path->dentry, &newattrs);
56803 mutex_unlock(&inode->i_mutex);
56804 diff --git a/fs/xattr.c b/fs/xattr.c
56805 index 3377dff..4d074d9 100644
56806 --- a/fs/xattr.c
56807 +++ b/fs/xattr.c
56808 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
56809 return rc;
56810 }
56811
56812 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
56813 +ssize_t
56814 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
56815 +{
56816 + struct inode *inode = dentry->d_inode;
56817 + ssize_t error;
56818 +
56819 + error = inode_permission(inode, MAY_EXEC);
56820 + if (error)
56821 + return error;
56822 +
56823 + if (inode->i_op->getxattr)
56824 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
56825 + else
56826 + error = -EOPNOTSUPP;
56827 +
56828 + return error;
56829 +}
56830 +EXPORT_SYMBOL(pax_getxattr);
56831 +#endif
56832 +
56833 ssize_t
56834 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
56835 {
56836 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56837 * Extended attribute SET operations
56838 */
56839 static long
56840 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56841 +setxattr(struct path *path, const char __user *name, const void __user *value,
56842 size_t size, int flags)
56843 {
56844 int error;
56845 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56846 posix_acl_fix_xattr_from_user(kvalue, size);
56847 }
56848
56849 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56850 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56851 + error = -EACCES;
56852 + goto out;
56853 + }
56854 +
56855 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56856 out:
56857 if (vvalue)
56858 vfree(vvalue);
56859 @@ -377,7 +403,7 @@ retry:
56860 return error;
56861 error = mnt_want_write(path.mnt);
56862 if (!error) {
56863 - error = setxattr(path.dentry, name, value, size, flags);
56864 + error = setxattr(&path, name, value, size, flags);
56865 mnt_drop_write(path.mnt);
56866 }
56867 path_put(&path);
56868 @@ -401,7 +427,7 @@ retry:
56869 return error;
56870 error = mnt_want_write(path.mnt);
56871 if (!error) {
56872 - error = setxattr(path.dentry, name, value, size, flags);
56873 + error = setxattr(&path, name, value, size, flags);
56874 mnt_drop_write(path.mnt);
56875 }
56876 path_put(&path);
56877 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56878 const void __user *,value, size_t, size, int, flags)
56879 {
56880 struct fd f = fdget(fd);
56881 - struct dentry *dentry;
56882 int error = -EBADF;
56883
56884 if (!f.file)
56885 return error;
56886 - dentry = f.file->f_path.dentry;
56887 - audit_inode(NULL, dentry, 0);
56888 + audit_inode(NULL, f.file->f_path.dentry, 0);
56889 error = mnt_want_write_file(f.file);
56890 if (!error) {
56891 - error = setxattr(dentry, name, value, size, flags);
56892 + error = setxattr(&f.file->f_path, name, value, size, flags);
56893 mnt_drop_write_file(f.file);
56894 }
56895 fdput(f);
56896 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56897 index 9fbea87..6b19972 100644
56898 --- a/fs/xattr_acl.c
56899 +++ b/fs/xattr_acl.c
56900 @@ -76,8 +76,8 @@ struct posix_acl *
56901 posix_acl_from_xattr(struct user_namespace *user_ns,
56902 const void *value, size_t size)
56903 {
56904 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56905 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56906 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56907 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56908 int count;
56909 struct posix_acl *acl;
56910 struct posix_acl_entry *acl_e;
56911 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56912 index b44af92..06073da 100644
56913 --- a/fs/xfs/xfs_bmap.c
56914 +++ b/fs/xfs/xfs_bmap.c
56915 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56916 int nmap,
56917 int ret_nmap);
56918 #else
56919 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56920 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56921 #endif /* DEBUG */
56922
56923 STATIC int
56924 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56925 index 1b9fc3e..e1bdde0 100644
56926 --- a/fs/xfs/xfs_dir2_sf.c
56927 +++ b/fs/xfs/xfs_dir2_sf.c
56928 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56929 }
56930
56931 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56932 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56933 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56934 + char name[sfep->namelen];
56935 + memcpy(name, sfep->name, sfep->namelen);
56936 + if (filldir(dirent, name, sfep->namelen,
56937 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56938 + *offset = off & 0x7fffffff;
56939 + return 0;
56940 + }
56941 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56942 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56943 *offset = off & 0x7fffffff;
56944 return 0;
56945 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56946 index d681e34..2a3f5ab 100644
56947 --- a/fs/xfs/xfs_ioctl.c
56948 +++ b/fs/xfs/xfs_ioctl.c
56949 @@ -127,7 +127,7 @@ xfs_find_handle(
56950 }
56951
56952 error = -EFAULT;
56953 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56954 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56955 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56956 goto out_put;
56957
56958 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56959 index ca9ecaa..60100c7 100644
56960 --- a/fs/xfs/xfs_iops.c
56961 +++ b/fs/xfs/xfs_iops.c
56962 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56963 struct nameidata *nd,
56964 void *p)
56965 {
56966 - char *s = nd_get_link(nd);
56967 + const char *s = nd_get_link(nd);
56968
56969 if (!IS_ERR(s))
56970 kfree(s);
56971 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56972 new file mode 100644
56973 index 0000000..4fb1dde
56974 --- /dev/null
56975 +++ b/grsecurity/Kconfig
56976 @@ -0,0 +1,1053 @@
56977 +#
56978 +# grecurity configuration
56979 +#
56980 +menu "Memory Protections"
56981 +depends on GRKERNSEC
56982 +
56983 +config GRKERNSEC_KMEM
56984 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56985 + default y if GRKERNSEC_CONFIG_AUTO
56986 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56987 + help
56988 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56989 + be written to or read from to modify or leak the contents of the running
56990 + kernel. /dev/port will also not be allowed to be opened and support
56991 + for /dev/cpu/*/msr will be removed. If you have module
56992 + support disabled, enabling this will close up five ways that are
56993 + currently used to insert malicious code into the running kernel.
56994 +
56995 + Even with all these features enabled, we still highly recommend that
56996 + you use the RBAC system, as it is still possible for an attacker to
56997 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56998 +
56999 + If you are not using XFree86, you may be able to stop this additional
57000 + case by enabling the 'Disable privileged I/O' option. Though nothing
57001 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57002 + but only to video memory, which is the only writing we allow in this
57003 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57004 + not be allowed to mprotect it with PROT_WRITE later.
57005 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57006 + from working.
57007 +
57008 + It is highly recommended that you say Y here if you meet all the
57009 + conditions above.
57010 +
57011 +config GRKERNSEC_VM86
57012 + bool "Restrict VM86 mode"
57013 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57014 + depends on X86_32
57015 +
57016 + help
57017 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57018 + make use of a special execution mode on 32bit x86 processors called
57019 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57020 + video cards and will still work with this option enabled. The purpose
57021 + of the option is to prevent exploitation of emulation errors in
57022 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57023 + Nearly all users should be able to enable this option.
57024 +
57025 +config GRKERNSEC_IO
57026 + bool "Disable privileged I/O"
57027 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57028 + depends on X86
57029 + select RTC_CLASS
57030 + select RTC_INTF_DEV
57031 + select RTC_DRV_CMOS
57032 +
57033 + help
57034 + If you say Y here, all ioperm and iopl calls will return an error.
57035 + Ioperm and iopl can be used to modify the running kernel.
57036 + Unfortunately, some programs need this access to operate properly,
57037 + the most notable of which are XFree86 and hwclock. hwclock can be
57038 + remedied by having RTC support in the kernel, so real-time
57039 + clock support is enabled if this option is enabled, to ensure
57040 + that hwclock operates correctly. XFree86 still will not
57041 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57042 + IF YOU USE XFree86. If you use XFree86 and you still want to
57043 + protect your kernel against modification, use the RBAC system.
57044 +
57045 +config GRKERNSEC_JIT_HARDEN
57046 + bool "Harden BPF JIT against spray attacks"
57047 + default y if GRKERNSEC_CONFIG_AUTO
57048 + depends on BPF_JIT
57049 + help
57050 + If you say Y here, the native code generated by the kernel's Berkeley
57051 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57052 + attacks that attempt to fit attacker-beneficial instructions in
57053 + 32bit immediate fields of JIT-generated native instructions. The
57054 + attacker will generally aim to cause an unintended instruction sequence
57055 + of JIT-generated native code to execute by jumping into the middle of
57056 + a generated instruction. This feature effectively randomizes the 32bit
57057 + immediate constants present in the generated code to thwart such attacks.
57058 +
57059 + If you're using KERNEXEC, it's recommended that you enable this option
57060 + to supplement the hardening of the kernel.
57061 +
57062 +config GRKERNSEC_PERF_HARDEN
57063 + bool "Disable unprivileged PERF_EVENTS usage by default"
57064 + default y if GRKERNSEC_CONFIG_AUTO
57065 + depends on PERF_EVENTS
57066 + help
57067 + If you say Y here, the range of acceptable values for the
57068 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
57069 + default to a new value: 3. When the sysctl is set to this value, no
57070 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
57071 +
57072 + Though PERF_EVENTS can be used legitimately for performance monitoring
57073 + and low-level application profiling, it is forced on regardless of
57074 + configuration, has been at fault for several vulnerabilities, and
57075 + creates new opportunities for side channels and other information leaks.
57076 +
57077 + This feature puts PERF_EVENTS into a secure default state and permits
57078 + the administrator to change out of it temporarily if unprivileged
57079 + application profiling is needed.
57080 +
57081 +config GRKERNSEC_RAND_THREADSTACK
57082 + bool "Insert random gaps between thread stacks"
57083 + default y if GRKERNSEC_CONFIG_AUTO
57084 + depends on PAX_RANDMMAP && !PPC
57085 + help
57086 + If you say Y here, a random-sized gap will be enforced between allocated
57087 + thread stacks. Glibc's NPTL and other threading libraries that
57088 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57089 + The implementation currently provides 8 bits of entropy for the gap.
57090 +
57091 + Many distributions do not compile threaded remote services with the
57092 + -fstack-check argument to GCC, causing the variable-sized stack-based
57093 + allocator, alloca(), to not probe the stack on allocation. This
57094 + permits an unbounded alloca() to skip over any guard page and potentially
57095 + modify another thread's stack reliably. An enforced random gap
57096 + reduces the reliability of such an attack and increases the chance
57097 + that such a read/write to another thread's stack instead lands in
57098 + an unmapped area, causing a crash and triggering grsecurity's
57099 + anti-bruteforcing logic.
57100 +
57101 +config GRKERNSEC_PROC_MEMMAP
57102 + bool "Harden ASLR against information leaks and entropy reduction"
57103 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57104 + depends on PAX_NOEXEC || PAX_ASLR
57105 + help
57106 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57107 + give no information about the addresses of its mappings if
57108 + PaX features that rely on random addresses are enabled on the task.
57109 + In addition to sanitizing this information and disabling other
57110 + dangerous sources of information, this option causes reads of sensitive
57111 + /proc/<pid> entries where the file descriptor was opened in a different
57112 + task than the one performing the read. Such attempts are logged.
57113 + This option also limits argv/env strings for suid/sgid binaries
57114 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57115 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57116 + binaries to prevent alternative mmap layouts from being abused.
57117 +
57118 + If you use PaX it is essential that you say Y here as it closes up
57119 + several holes that make full ASLR useless locally.
57120 +
57121 +config GRKERNSEC_BRUTE
57122 + bool "Deter exploit bruteforcing"
57123 + default y if GRKERNSEC_CONFIG_AUTO
57124 + help
57125 + If you say Y here, attempts to bruteforce exploits against forking
57126 + daemons such as apache or sshd, as well as against suid/sgid binaries
57127 + will be deterred. When a child of a forking daemon is killed by PaX
57128 + or crashes due to an illegal instruction or other suspicious signal,
57129 + the parent process will be delayed 30 seconds upon every subsequent
57130 + fork until the administrator is able to assess the situation and
57131 + restart the daemon.
57132 + In the suid/sgid case, the attempt is logged, the user has all their
57133 + processes terminated, and they are prevented from executing any further
57134 + processes for 15 minutes.
57135 + It is recommended that you also enable signal logging in the auditing
57136 + section so that logs are generated when a process triggers a suspicious
57137 + signal.
57138 + If the sysctl option is enabled, a sysctl option with name
57139 + "deter_bruteforce" is created.
57140 +
57141 +
57142 +config GRKERNSEC_MODHARDEN
57143 + bool "Harden module auto-loading"
57144 + default y if GRKERNSEC_CONFIG_AUTO
57145 + depends on MODULES
57146 + help
57147 + If you say Y here, module auto-loading in response to use of some
57148 + feature implemented by an unloaded module will be restricted to
57149 + root users. Enabling this option helps defend against attacks
57150 + by unprivileged users who abuse the auto-loading behavior to
57151 + cause a vulnerable module to load that is then exploited.
57152 +
57153 + If this option prevents a legitimate use of auto-loading for a
57154 + non-root user, the administrator can execute modprobe manually
57155 + with the exact name of the module mentioned in the alert log.
57156 + Alternatively, the administrator can add the module to the list
57157 + of modules loaded at boot by modifying init scripts.
57158 +
57159 + Modification of init scripts will most likely be needed on
57160 + Ubuntu servers with encrypted home directory support enabled,
57161 + as the first non-root user logging in will cause the ecb(aes),
57162 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57163 +
57164 +config GRKERNSEC_HIDESYM
57165 + bool "Hide kernel symbols"
57166 + default y if GRKERNSEC_CONFIG_AUTO
57167 + select PAX_USERCOPY_SLABS
57168 + help
57169 + If you say Y here, getting information on loaded modules, and
57170 + displaying all kernel symbols through a syscall will be restricted
57171 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57172 + /proc/kallsyms will be restricted to the root user. The RBAC
57173 + system can hide that entry even from root.
57174 +
57175 + This option also prevents leaking of kernel addresses through
57176 + several /proc entries.
57177 +
57178 + Note that this option is only effective provided the following
57179 + conditions are met:
57180 + 1) The kernel using grsecurity is not precompiled by some distribution
57181 + 2) You have also enabled GRKERNSEC_DMESG
57182 + 3) You are using the RBAC system and hiding other files such as your
57183 + kernel image and System.map. Alternatively, enabling this option
57184 + causes the permissions on /boot, /lib/modules, and the kernel
57185 + source directory to change at compile time to prevent
57186 + reading by non-root users.
57187 + If the above conditions are met, this option will aid in providing a
57188 + useful protection against local kernel exploitation of overflows
57189 + and arbitrary read/write vulnerabilities.
57190 +
57191 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
57192 + in addition to this feature.
57193 +
57194 +config GRKERNSEC_KERN_LOCKOUT
57195 + bool "Active kernel exploit response"
57196 + default y if GRKERNSEC_CONFIG_AUTO
57197 + depends on X86 || ARM || PPC || SPARC
57198 + help
57199 + If you say Y here, when a PaX alert is triggered due to suspicious
57200 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57201 + or an OOPS occurs due to bad memory accesses, instead of just
57202 + terminating the offending process (and potentially allowing
57203 + a subsequent exploit from the same user), we will take one of two
57204 + actions:
57205 + If the user was root, we will panic the system
57206 + If the user was non-root, we will log the attempt, terminate
57207 + all processes owned by the user, then prevent them from creating
57208 + any new processes until the system is restarted
57209 + This deters repeated kernel exploitation/bruteforcing attempts
57210 + and is useful for later forensics.
57211 +
57212 +endmenu
57213 +menu "Role Based Access Control Options"
57214 +depends on GRKERNSEC
57215 +
57216 +config GRKERNSEC_RBAC_DEBUG
57217 + bool
57218 +
57219 +config GRKERNSEC_NO_RBAC
57220 + bool "Disable RBAC system"
57221 + help
57222 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57223 + preventing the RBAC system from being enabled. You should only say Y
57224 + here if you have no intention of using the RBAC system, so as to prevent
57225 + an attacker with root access from misusing the RBAC system to hide files
57226 + and processes when loadable module support and /dev/[k]mem have been
57227 + locked down.
57228 +
57229 +config GRKERNSEC_ACL_HIDEKERN
57230 + bool "Hide kernel processes"
57231 + help
57232 + If you say Y here, all kernel threads will be hidden to all
57233 + processes but those whose subject has the "view hidden processes"
57234 + flag.
57235 +
57236 +config GRKERNSEC_ACL_MAXTRIES
57237 + int "Maximum tries before password lockout"
57238 + default 3
57239 + help
57240 + This option enforces the maximum number of times a user can attempt
57241 + to authorize themselves with the grsecurity RBAC system before being
57242 + denied the ability to attempt authorization again for a specified time.
57243 + The lower the number, the harder it will be to brute-force a password.
57244 +
57245 +config GRKERNSEC_ACL_TIMEOUT
57246 + int "Time to wait after max password tries, in seconds"
57247 + default 30
57248 + help
57249 + This option specifies the time the user must wait after attempting to
57250 + authorize to the RBAC system with the maximum number of invalid
57251 + passwords. The higher the number, the harder it will be to brute-force
57252 + a password.
57253 +
57254 +endmenu
57255 +menu "Filesystem Protections"
57256 +depends on GRKERNSEC
57257 +
57258 +config GRKERNSEC_PROC
57259 + bool "Proc restrictions"
57260 + default y if GRKERNSEC_CONFIG_AUTO
57261 + help
57262 + If you say Y here, the permissions of the /proc filesystem
57263 + will be altered to enhance system security and privacy. You MUST
57264 + choose either a user only restriction or a user and group restriction.
57265 + Depending upon the option you choose, you can either restrict users to
57266 + see only the processes they themselves run, or choose a group that can
57267 + view all processes and files normally restricted to root if you choose
57268 + the "restrict to user only" option. NOTE: If you're running identd or
57269 + ntpd as a non-root user, you will have to run it as the group you
57270 + specify here.
57271 +
57272 +config GRKERNSEC_PROC_USER
57273 + bool "Restrict /proc to user only"
57274 + depends on GRKERNSEC_PROC
57275 + help
57276 + If you say Y here, non-root users will only be able to view their own
57277 + processes, and restricts them from viewing network-related information,
57278 + and viewing kernel symbol and module information.
57279 +
57280 +config GRKERNSEC_PROC_USERGROUP
57281 + bool "Allow special group"
57282 + default y if GRKERNSEC_CONFIG_AUTO
57283 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57284 + help
57285 + If you say Y here, you will be able to select a group that will be
57286 + able to view all processes and network-related information. If you've
57287 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57288 + remain hidden. This option is useful if you want to run identd as
57289 + a non-root user. The group you select may also be chosen at boot time
57290 + via "grsec_proc_gid=" on the kernel commandline.
57291 +
57292 +config GRKERNSEC_PROC_GID
57293 + int "GID for special group"
57294 + depends on GRKERNSEC_PROC_USERGROUP
57295 + default 1001
57296 +
57297 +config GRKERNSEC_PROC_ADD
57298 + bool "Additional restrictions"
57299 + default y if GRKERNSEC_CONFIG_AUTO
57300 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57301 + help
57302 + If you say Y here, additional restrictions will be placed on
57303 + /proc that keep normal users from viewing device information and
57304 + slabinfo information that could be useful for exploits.
57305 +
57306 +config GRKERNSEC_LINK
57307 + bool "Linking restrictions"
57308 + default y if GRKERNSEC_CONFIG_AUTO
57309 + help
57310 + If you say Y here, /tmp race exploits will be prevented, since users
57311 + will no longer be able to follow symlinks owned by other users in
57312 + world-writable +t directories (e.g. /tmp), unless the owner of the
57313 + symlink is the owner of the directory. users will also not be
57314 + able to hardlink to files they do not own. If the sysctl option is
57315 + enabled, a sysctl option with name "linking_restrictions" is created.
57316 +
57317 +config GRKERNSEC_SYMLINKOWN
57318 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57319 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57320 + help
57321 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57322 + that prevents it from being used as a security feature. As Apache
57323 + verifies the symlink by performing a stat() against the target of
57324 + the symlink before it is followed, an attacker can setup a symlink
57325 + to point to a same-owned file, then replace the symlink with one
57326 + that targets another user's file just after Apache "validates" the
57327 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57328 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57329 + will be in place for the group you specify. If the sysctl option
57330 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57331 + created.
57332 +
57333 +config GRKERNSEC_SYMLINKOWN_GID
57334 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57335 + depends on GRKERNSEC_SYMLINKOWN
57336 + default 1006
57337 + help
57338 + Setting this GID determines what group kernel-enforced
57339 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57340 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57341 +
57342 +config GRKERNSEC_FIFO
57343 + bool "FIFO restrictions"
57344 + default y if GRKERNSEC_CONFIG_AUTO
57345 + help
57346 + If you say Y here, users will not be able to write to FIFOs they don't
57347 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57348 + the FIFO is the same owner of the directory it's held in. If the sysctl
57349 + option is enabled, a sysctl option with name "fifo_restrictions" is
57350 + created.
57351 +
57352 +config GRKERNSEC_SYSFS_RESTRICT
57353 + bool "Sysfs/debugfs restriction"
57354 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57355 + depends on SYSFS
57356 + help
57357 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57358 + any filesystem normally mounted under it (e.g. debugfs) will be
57359 + mostly accessible only by root. These filesystems generally provide access
57360 + to hardware and debug information that isn't appropriate for unprivileged
57361 + users of the system. Sysfs and debugfs have also become a large source
57362 + of new vulnerabilities, ranging from infoleaks to local compromise.
57363 + There has been very little oversight with an eye toward security involved
57364 + in adding new exporters of information to these filesystems, so their
57365 + use is discouraged.
57366 + For reasons of compatibility, a few directories have been whitelisted
57367 + for access by non-root users:
57368 + /sys/fs/selinux
57369 + /sys/fs/fuse
57370 + /sys/devices/system/cpu
57371 +
57372 +config GRKERNSEC_ROFS
57373 + bool "Runtime read-only mount protection"
57374 + help
57375 + If you say Y here, a sysctl option with name "romount_protect" will
57376 + be created. By setting this option to 1 at runtime, filesystems
57377 + will be protected in the following ways:
57378 + * No new writable mounts will be allowed
57379 + * Existing read-only mounts won't be able to be remounted read/write
57380 + * Write operations will be denied on all block devices
57381 + This option acts independently of grsec_lock: once it is set to 1,
57382 + it cannot be turned off. Therefore, please be mindful of the resulting
57383 + behavior if this option is enabled in an init script on a read-only
57384 + filesystem. This feature is mainly intended for secure embedded systems.
57385 +
57386 +config GRKERNSEC_DEVICE_SIDECHANNEL
57387 + bool "Eliminate stat/notify-based device sidechannels"
57388 + default y if GRKERNSEC_CONFIG_AUTO
57389 + help
57390 + If you say Y here, timing analyses on block or character
57391 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57392 + will be thwarted for unprivileged users. If a process without
57393 + CAP_MKNOD stats such a device, the last access and last modify times
57394 + will match the device's create time. No access or modify events
57395 + will be triggered through inotify/dnotify/fanotify for such devices.
57396 + This feature will prevent attacks that may at a minimum
57397 + allow an attacker to determine the administrator's password length.
57398 +
57399 +config GRKERNSEC_CHROOT
57400 + bool "Chroot jail restrictions"
57401 + default y if GRKERNSEC_CONFIG_AUTO
57402 + help
57403 + If you say Y here, you will be able to choose several options that will
57404 + make breaking out of a chrooted jail much more difficult. If you
57405 + encounter no software incompatibilities with the following options, it
57406 + is recommended that you enable each one.
57407 +
57408 +config GRKERNSEC_CHROOT_MOUNT
57409 + bool "Deny mounts"
57410 + default y if GRKERNSEC_CONFIG_AUTO
57411 + depends on GRKERNSEC_CHROOT
57412 + help
57413 + If you say Y here, processes inside a chroot will not be able to
57414 + mount or remount filesystems. If the sysctl option is enabled, a
57415 + sysctl option with name "chroot_deny_mount" is created.
57416 +
57417 +config GRKERNSEC_CHROOT_DOUBLE
57418 + bool "Deny double-chroots"
57419 + default y if GRKERNSEC_CONFIG_AUTO
57420 + depends on GRKERNSEC_CHROOT
57421 + help
57422 + If you say Y here, processes inside a chroot will not be able to chroot
57423 + again outside the chroot. This is a widely used method of breaking
57424 + out of a chroot jail and should not be allowed. If the sysctl
57425 + option is enabled, a sysctl option with name
57426 + "chroot_deny_chroot" is created.
57427 +
57428 +config GRKERNSEC_CHROOT_PIVOT
57429 + bool "Deny pivot_root in chroot"
57430 + default y if GRKERNSEC_CONFIG_AUTO
57431 + depends on GRKERNSEC_CHROOT
57432 + help
57433 + If you say Y here, processes inside a chroot will not be able to use
57434 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57435 + works similar to chroot in that it changes the root filesystem. This
57436 + function could be misused in a chrooted process to attempt to break out
57437 + of the chroot, and therefore should not be allowed. If the sysctl
57438 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57439 + created.
57440 +
57441 +config GRKERNSEC_CHROOT_CHDIR
57442 + bool "Enforce chdir(\"/\") on all chroots"
57443 + default y if GRKERNSEC_CONFIG_AUTO
57444 + depends on GRKERNSEC_CHROOT
57445 + help
57446 + If you say Y here, the current working directory of all newly-chrooted
57447 + applications will be set to the the root directory of the chroot.
57448 + The man page on chroot(2) states:
57449 + Note that this call does not change the current working
57450 + directory, so that `.' can be outside the tree rooted at
57451 + `/'. In particular, the super-user can escape from a
57452 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57453 +
57454 + It is recommended that you say Y here, since it's not known to break
57455 + any software. If the sysctl option is enabled, a sysctl option with
57456 + name "chroot_enforce_chdir" is created.
57457 +
57458 +config GRKERNSEC_CHROOT_CHMOD
57459 + bool "Deny (f)chmod +s"
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 chmod
57464 + or fchmod files to make them have suid or sgid bits. This protects
57465 + against another published method of breaking a chroot. If the sysctl
57466 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57467 + created.
57468 +
57469 +config GRKERNSEC_CHROOT_FCHDIR
57470 + bool "Deny fchdir out of chroot"
57471 + default y if GRKERNSEC_CONFIG_AUTO
57472 + depends on GRKERNSEC_CHROOT
57473 + help
57474 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57475 + to a file descriptor of the chrooting process that points to a directory
57476 + outside the filesystem will be stopped. If the sysctl option
57477 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57478 +
57479 +config GRKERNSEC_CHROOT_MKNOD
57480 + bool "Deny mknod"
57481 + default y if GRKERNSEC_CONFIG_AUTO
57482 + depends on GRKERNSEC_CHROOT
57483 + help
57484 + If you say Y here, processes inside a chroot will not be allowed to
57485 + mknod. The problem with using mknod inside a chroot is that it
57486 + would allow an attacker to create a device entry that is the same
57487 + as one on the physical root of your system, which could range from
57488 + anything from the console device to a device for your harddrive (which
57489 + they could then use to wipe the drive or steal data). It is recommended
57490 + that you say Y here, unless you run into software incompatibilities.
57491 + If the sysctl option is enabled, a sysctl option with name
57492 + "chroot_deny_mknod" is created.
57493 +
57494 +config GRKERNSEC_CHROOT_SHMAT
57495 + bool "Deny shmat() out of chroot"
57496 + default y if GRKERNSEC_CONFIG_AUTO
57497 + depends on GRKERNSEC_CHROOT
57498 + help
57499 + If you say Y here, processes inside a chroot will not be able to attach
57500 + to shared memory segments that were created outside of the chroot jail.
57501 + It is recommended that you say Y here. If the sysctl option is enabled,
57502 + a sysctl option with name "chroot_deny_shmat" is created.
57503 +
57504 +config GRKERNSEC_CHROOT_UNIX
57505 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57506 + default y if GRKERNSEC_CONFIG_AUTO
57507 + depends on GRKERNSEC_CHROOT
57508 + help
57509 + If you say Y here, processes inside a chroot will not be able to
57510 + connect to abstract (meaning not belonging to a filesystem) Unix
57511 + domain sockets that were bound outside of a chroot. It is recommended
57512 + that you say Y here. If the sysctl option is enabled, a sysctl option
57513 + with name "chroot_deny_unix" is created.
57514 +
57515 +config GRKERNSEC_CHROOT_FINDTASK
57516 + bool "Protect outside processes"
57517 + default y if GRKERNSEC_CONFIG_AUTO
57518 + depends on GRKERNSEC_CHROOT
57519 + help
57520 + If you say Y here, processes inside a chroot will not be able to
57521 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57522 + getsid, or view any process outside of the chroot. If the sysctl
57523 + option is enabled, a sysctl option with name "chroot_findtask" is
57524 + created.
57525 +
57526 +config GRKERNSEC_CHROOT_NICE
57527 + bool "Restrict priority changes"
57528 + default y if GRKERNSEC_CONFIG_AUTO
57529 + depends on GRKERNSEC_CHROOT
57530 + help
57531 + If you say Y here, processes inside a chroot will not be able to raise
57532 + the priority of processes in the chroot, or alter the priority of
57533 + processes outside the chroot. This provides more security than simply
57534 + removing CAP_SYS_NICE from the process' capability set. If the
57535 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57536 + is created.
57537 +
57538 +config GRKERNSEC_CHROOT_SYSCTL
57539 + bool "Deny sysctl writes"
57540 + default y if GRKERNSEC_CONFIG_AUTO
57541 + depends on GRKERNSEC_CHROOT
57542 + help
57543 + If you say Y here, an attacker in a chroot will not be able to
57544 + write to sysctl entries, either by sysctl(2) or through a /proc
57545 + interface. It is strongly recommended that you say Y here. If the
57546 + sysctl option is enabled, a sysctl option with name
57547 + "chroot_deny_sysctl" is created.
57548 +
57549 +config GRKERNSEC_CHROOT_CAPS
57550 + bool "Capability restrictions"
57551 + default y if GRKERNSEC_CONFIG_AUTO
57552 + depends on GRKERNSEC_CHROOT
57553 + help
57554 + If you say Y here, the capabilities on all processes within a
57555 + chroot jail will be lowered to stop module insertion, raw i/o,
57556 + system and net admin tasks, rebooting the system, modifying immutable
57557 + files, modifying IPC owned by another, and changing the system time.
57558 + This is left an option because it can break some apps. Disable this
57559 + if your chrooted apps are having problems performing those kinds of
57560 + tasks. If the sysctl option is enabled, a sysctl option with
57561 + name "chroot_caps" is created.
57562 +
57563 +config GRKERNSEC_CHROOT_INITRD
57564 + bool "Exempt initrd tasks from restrictions"
57565 + default y if GRKERNSEC_CONFIG_AUTO
57566 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57567 + help
57568 + If you say Y here, tasks started prior to init will be exempted from
57569 + grsecurity's chroot restrictions. This option is mainly meant to
57570 + resolve Plymouth's performing privileged operations unnecessarily
57571 + in a chroot.
57572 +
57573 +endmenu
57574 +menu "Kernel Auditing"
57575 +depends on GRKERNSEC
57576 +
57577 +config GRKERNSEC_AUDIT_GROUP
57578 + bool "Single group for auditing"
57579 + help
57580 + If you say Y here, the exec and chdir logging features will only operate
57581 + on a group you specify. This option is recommended if you only want to
57582 + watch certain users instead of having a large amount of logs from the
57583 + entire system. If the sysctl option is enabled, a sysctl option with
57584 + name "audit_group" is created.
57585 +
57586 +config GRKERNSEC_AUDIT_GID
57587 + int "GID for auditing"
57588 + depends on GRKERNSEC_AUDIT_GROUP
57589 + default 1007
57590 +
57591 +config GRKERNSEC_EXECLOG
57592 + bool "Exec logging"
57593 + help
57594 + If you say Y here, all execve() calls will be logged (since the
57595 + other exec*() calls are frontends to execve(), all execution
57596 + will be logged). Useful for shell-servers that like to keep track
57597 + of their users. If the sysctl option is enabled, a sysctl option with
57598 + name "exec_logging" is created.
57599 + WARNING: This option when enabled will produce a LOT of logs, especially
57600 + on an active system.
57601 +
57602 +config GRKERNSEC_RESLOG
57603 + bool "Resource logging"
57604 + default y if GRKERNSEC_CONFIG_AUTO
57605 + help
57606 + If you say Y here, all attempts to overstep resource limits will
57607 + be logged with the resource name, the requested size, and the current
57608 + limit. It is highly recommended that you say Y here. If the sysctl
57609 + option is enabled, a sysctl option with name "resource_logging" is
57610 + created. If the RBAC system is enabled, the sysctl value is ignored.
57611 +
57612 +config GRKERNSEC_CHROOT_EXECLOG
57613 + bool "Log execs within chroot"
57614 + help
57615 + If you say Y here, all executions inside a chroot jail will be logged
57616 + to syslog. This can cause a large amount of logs if certain
57617 + applications (eg. djb's daemontools) are installed on the system, and
57618 + is therefore left as an option. If the sysctl option is enabled, a
57619 + sysctl option with name "chroot_execlog" is created.
57620 +
57621 +config GRKERNSEC_AUDIT_PTRACE
57622 + bool "Ptrace logging"
57623 + help
57624 + If you say Y here, all attempts to attach to a process via ptrace
57625 + will be logged. If the sysctl option is enabled, a sysctl option
57626 + with name "audit_ptrace" is created.
57627 +
57628 +config GRKERNSEC_AUDIT_CHDIR
57629 + bool "Chdir logging"
57630 + help
57631 + If you say Y here, all chdir() calls will be logged. If the sysctl
57632 + option is enabled, a sysctl option with name "audit_chdir" is created.
57633 +
57634 +config GRKERNSEC_AUDIT_MOUNT
57635 + bool "(Un)Mount logging"
57636 + help
57637 + If you say Y here, all mounts and unmounts will be logged. If the
57638 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57639 + created.
57640 +
57641 +config GRKERNSEC_SIGNAL
57642 + bool "Signal logging"
57643 + default y if GRKERNSEC_CONFIG_AUTO
57644 + help
57645 + If you say Y here, certain important signals will be logged, such as
57646 + SIGSEGV, which will as a result inform you of when a error in a program
57647 + occurred, which in some cases could mean a possible exploit attempt.
57648 + If the sysctl option is enabled, a sysctl option with name
57649 + "signal_logging" is created.
57650 +
57651 +config GRKERNSEC_FORKFAIL
57652 + bool "Fork failure logging"
57653 + help
57654 + If you say Y here, all failed fork() attempts will be logged.
57655 + This could suggest a fork bomb, or someone attempting to overstep
57656 + their process limit. If the sysctl option is enabled, a sysctl option
57657 + with name "forkfail_logging" is created.
57658 +
57659 +config GRKERNSEC_TIME
57660 + bool "Time change logging"
57661 + default y if GRKERNSEC_CONFIG_AUTO
57662 + help
57663 + If you say Y here, any changes of the system clock will be logged.
57664 + If the sysctl option is enabled, a sysctl option with name
57665 + "timechange_logging" is created.
57666 +
57667 +config GRKERNSEC_PROC_IPADDR
57668 + bool "/proc/<pid>/ipaddr support"
57669 + default y if GRKERNSEC_CONFIG_AUTO
57670 + help
57671 + If you say Y here, a new entry will be added to each /proc/<pid>
57672 + directory that contains the IP address of the person using the task.
57673 + The IP is carried across local TCP and AF_UNIX stream sockets.
57674 + This information can be useful for IDS/IPSes to perform remote response
57675 + to a local attack. The entry is readable by only the owner of the
57676 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57677 + the RBAC system), and thus does not create privacy concerns.
57678 +
57679 +config GRKERNSEC_RWXMAP_LOG
57680 + bool 'Denied RWX mmap/mprotect logging'
57681 + default y if GRKERNSEC_CONFIG_AUTO
57682 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57683 + help
57684 + If you say Y here, calls to mmap() and mprotect() with explicit
57685 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57686 + denied by the PAX_MPROTECT feature. If the sysctl option is
57687 + enabled, a sysctl option with name "rwxmap_logging" is created.
57688 +
57689 +config GRKERNSEC_AUDIT_TEXTREL
57690 + bool 'ELF text relocations logging (READ HELP)'
57691 + depends on PAX_MPROTECT
57692 + help
57693 + If you say Y here, text relocations will be logged with the filename
57694 + of the offending library or binary. The purpose of the feature is
57695 + to help Linux distribution developers get rid of libraries and
57696 + binaries that need text relocations which hinder the future progress
57697 + of PaX. Only Linux distribution developers should say Y here, and
57698 + never on a production machine, as this option creates an information
57699 + leak that could aid an attacker in defeating the randomization of
57700 + a single memory region. If the sysctl option is enabled, a sysctl
57701 + option with name "audit_textrel" is created.
57702 +
57703 +endmenu
57704 +
57705 +menu "Executable Protections"
57706 +depends on GRKERNSEC
57707 +
57708 +config GRKERNSEC_DMESG
57709 + bool "Dmesg(8) restriction"
57710 + default y if GRKERNSEC_CONFIG_AUTO
57711 + help
57712 + If you say Y here, non-root users will not be able to use dmesg(8)
57713 + to view the contents of the kernel's circular log buffer.
57714 + The kernel's log buffer often contains kernel addresses and other
57715 + identifying information useful to an attacker in fingerprinting a
57716 + system for a targeted exploit.
57717 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57718 + created.
57719 +
57720 +config GRKERNSEC_HARDEN_PTRACE
57721 + bool "Deter ptrace-based process snooping"
57722 + default y if GRKERNSEC_CONFIG_AUTO
57723 + help
57724 + If you say Y here, TTY sniffers and other malicious monitoring
57725 + programs implemented through ptrace will be defeated. If you
57726 + have been using the RBAC system, this option has already been
57727 + enabled for several years for all users, with the ability to make
57728 + fine-grained exceptions.
57729 +
57730 + This option only affects the ability of non-root users to ptrace
57731 + processes that are not a descendent of the ptracing process.
57732 + This means that strace ./binary and gdb ./binary will still work,
57733 + but attaching to arbitrary processes will not. If the sysctl
57734 + option is enabled, a sysctl option with name "harden_ptrace" is
57735 + created.
57736 +
57737 +config GRKERNSEC_PTRACE_READEXEC
57738 + bool "Require read access to ptrace sensitive binaries"
57739 + default y if GRKERNSEC_CONFIG_AUTO
57740 + help
57741 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57742 + binaries. This option is useful in environments that
57743 + remove the read bits (e.g. file mode 4711) from suid binaries to
57744 + prevent infoleaking of their contents. This option adds
57745 + consistency to the use of that file mode, as the binary could normally
57746 + be read out when run without privileges while ptracing.
57747 +
57748 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57749 + is created.
57750 +
57751 +config GRKERNSEC_SETXID
57752 + bool "Enforce consistent multithreaded privileges"
57753 + default y if GRKERNSEC_CONFIG_AUTO
57754 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57755 + help
57756 + If you say Y here, a change from a root uid to a non-root uid
57757 + in a multithreaded application will cause the resulting uids,
57758 + gids, supplementary groups, and capabilities in that thread
57759 + to be propagated to the other threads of the process. In most
57760 + cases this is unnecessary, as glibc will emulate this behavior
57761 + on behalf of the application. Other libcs do not act in the
57762 + same way, allowing the other threads of the process to continue
57763 + running with root privileges. If the sysctl option is enabled,
57764 + a sysctl option with name "consistent_setxid" is created.
57765 +
57766 +config GRKERNSEC_TPE
57767 + bool "Trusted Path Execution (TPE)"
57768 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57769 + help
57770 + If you say Y here, you will be able to choose a gid to add to the
57771 + supplementary groups of users you want to mark as "untrusted."
57772 + These users will not be able to execute any files that are not in
57773 + root-owned directories writable only by root. If the sysctl option
57774 + is enabled, a sysctl option with name "tpe" is created.
57775 +
57776 +config GRKERNSEC_TPE_ALL
57777 + bool "Partially restrict all non-root users"
57778 + depends on GRKERNSEC_TPE
57779 + help
57780 + If you say Y here, all non-root users will be covered under
57781 + a weaker TPE restriction. This is separate from, and in addition to,
57782 + the main TPE options that you have selected elsewhere. Thus, if a
57783 + "trusted" GID is chosen, this restriction applies to even that GID.
57784 + Under this restriction, all non-root users will only be allowed to
57785 + execute files in directories they own that are not group or
57786 + world-writable, or in directories owned by root and writable only by
57787 + root. If the sysctl option is enabled, a sysctl option with name
57788 + "tpe_restrict_all" is created.
57789 +
57790 +config GRKERNSEC_TPE_INVERT
57791 + bool "Invert GID option"
57792 + depends on GRKERNSEC_TPE
57793 + help
57794 + If you say Y here, the group you specify in the TPE configuration will
57795 + decide what group TPE restrictions will be *disabled* for. This
57796 + option is useful if you want TPE restrictions to be applied to most
57797 + users on the system. If the sysctl option is enabled, a sysctl option
57798 + with name "tpe_invert" is created. Unlike other sysctl options, this
57799 + entry will default to on for backward-compatibility.
57800 +
57801 +config GRKERNSEC_TPE_GID
57802 + int
57803 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57804 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57805 +
57806 +config GRKERNSEC_TPE_UNTRUSTED_GID
57807 + int "GID for TPE-untrusted users"
57808 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57809 + default 1005
57810 + help
57811 + Setting this GID determines what group TPE restrictions will be
57812 + *enabled* for. If the sysctl option is enabled, a sysctl option
57813 + with name "tpe_gid" is created.
57814 +
57815 +config GRKERNSEC_TPE_TRUSTED_GID
57816 + int "GID for TPE-trusted users"
57817 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57818 + default 1005
57819 + help
57820 + Setting this GID determines what group TPE restrictions will be
57821 + *disabled* for. If the sysctl option is enabled, a sysctl option
57822 + with name "tpe_gid" is created.
57823 +
57824 +endmenu
57825 +menu "Network Protections"
57826 +depends on GRKERNSEC
57827 +
57828 +config GRKERNSEC_RANDNET
57829 + bool "Larger entropy pools"
57830 + default y if GRKERNSEC_CONFIG_AUTO
57831 + help
57832 + If you say Y here, the entropy pools used for many features of Linux
57833 + and grsecurity will be doubled in size. Since several grsecurity
57834 + features use additional randomness, it is recommended that you say Y
57835 + here. Saying Y here has a similar effect as modifying
57836 + /proc/sys/kernel/random/poolsize.
57837 +
57838 +config GRKERNSEC_BLACKHOLE
57839 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57840 + default y if GRKERNSEC_CONFIG_AUTO
57841 + depends on NET
57842 + help
57843 + If you say Y here, neither TCP resets nor ICMP
57844 + destination-unreachable packets will be sent in response to packets
57845 + sent to ports for which no associated listening process exists.
57846 + This feature supports both IPV4 and IPV6 and exempts the
57847 + loopback interface from blackholing. Enabling this feature
57848 + makes a host more resilient to DoS attacks and reduces network
57849 + visibility against scanners.
57850 +
57851 + The blackhole feature as-implemented is equivalent to the FreeBSD
57852 + blackhole feature, as it prevents RST responses to all packets, not
57853 + just SYNs. Under most application behavior this causes no
57854 + problems, but applications (like haproxy) may not close certain
57855 + connections in a way that cleanly terminates them on the remote
57856 + end, leaving the remote host in LAST_ACK state. Because of this
57857 + side-effect and to prevent intentional LAST_ACK DoSes, this
57858 + feature also adds automatic mitigation against such attacks.
57859 + The mitigation drastically reduces the amount of time a socket
57860 + can spend in LAST_ACK state. If you're using haproxy and not
57861 + all servers it connects to have this option enabled, consider
57862 + disabling this feature on the haproxy host.
57863 +
57864 + If the sysctl option is enabled, two sysctl options with names
57865 + "ip_blackhole" and "lastack_retries" will be created.
57866 + While "ip_blackhole" takes the standard zero/non-zero on/off
57867 + toggle, "lastack_retries" uses the same kinds of values as
57868 + "tcp_retries1" and "tcp_retries2". The default value of 4
57869 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57870 + state.
57871 +
57872 +config GRKERNSEC_NO_SIMULT_CONNECT
57873 + bool "Disable TCP Simultaneous Connect"
57874 + default y if GRKERNSEC_CONFIG_AUTO
57875 + depends on NET
57876 + help
57877 + If you say Y here, a feature by Willy Tarreau will be enabled that
57878 + removes a weakness in Linux's strict implementation of TCP that
57879 + allows two clients to connect to each other without either entering
57880 + a listening state. The weakness allows an attacker to easily prevent
57881 + a client from connecting to a known server provided the source port
57882 + for the connection is guessed correctly.
57883 +
57884 + As the weakness could be used to prevent an antivirus or IPS from
57885 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57886 + it should be eliminated by enabling this option. Though Linux is
57887 + one of few operating systems supporting simultaneous connect, it
57888 + has no legitimate use in practice and is rarely supported by firewalls.
57889 +
57890 +config GRKERNSEC_SOCKET
57891 + bool "Socket restrictions"
57892 + depends on NET
57893 + help
57894 + If you say Y here, you will be able to choose from several options.
57895 + If you assign a GID on your system and add it to the supplementary
57896 + groups of users you want to restrict socket access to, this patch
57897 + will perform up to three things, based on the option(s) you choose.
57898 +
57899 +config GRKERNSEC_SOCKET_ALL
57900 + bool "Deny any sockets to group"
57901 + depends on GRKERNSEC_SOCKET
57902 + help
57903 + If you say Y here, you will be able to choose a GID of whose users will
57904 + be unable to connect to other hosts from your machine or run server
57905 + applications from your machine. If the sysctl option is enabled, a
57906 + sysctl option with name "socket_all" is created.
57907 +
57908 +config GRKERNSEC_SOCKET_ALL_GID
57909 + int "GID to deny all sockets for"
57910 + depends on GRKERNSEC_SOCKET_ALL
57911 + default 1004
57912 + help
57913 + Here you can choose the GID to disable socket access for. Remember to
57914 + add the users you want socket access disabled for to the GID
57915 + specified here. If the sysctl option is enabled, a sysctl option
57916 + with name "socket_all_gid" is created.
57917 +
57918 +config GRKERNSEC_SOCKET_CLIENT
57919 + bool "Deny client sockets to group"
57920 + depends on GRKERNSEC_SOCKET
57921 + help
57922 + If you say Y here, you will be able to choose a GID of whose users will
57923 + be unable to connect to other hosts from your machine, but will be
57924 + able to run servers. If this option is enabled, all users in the group
57925 + you specify will have to use passive mode when initiating ftp transfers
57926 + from the shell on your machine. If the sysctl option is enabled, a
57927 + sysctl option with name "socket_client" is created.
57928 +
57929 +config GRKERNSEC_SOCKET_CLIENT_GID
57930 + int "GID to deny client sockets for"
57931 + depends on GRKERNSEC_SOCKET_CLIENT
57932 + default 1003
57933 + help
57934 + Here you can choose the GID to disable client socket access for.
57935 + Remember to add the users you want client socket access disabled for to
57936 + the GID specified here. If the sysctl option is enabled, a sysctl
57937 + option with name "socket_client_gid" is created.
57938 +
57939 +config GRKERNSEC_SOCKET_SERVER
57940 + bool "Deny server sockets to group"
57941 + depends on GRKERNSEC_SOCKET
57942 + help
57943 + If you say Y here, you will be able to choose a GID of whose users will
57944 + be unable to run server applications from your machine. If the sysctl
57945 + option is enabled, a sysctl option with name "socket_server" is created.
57946 +
57947 +config GRKERNSEC_SOCKET_SERVER_GID
57948 + int "GID to deny server sockets for"
57949 + depends on GRKERNSEC_SOCKET_SERVER
57950 + default 1002
57951 + help
57952 + Here you can choose the GID to disable server socket access for.
57953 + Remember to add the users you want server socket access disabled for to
57954 + the GID specified here. If the sysctl option is enabled, a sysctl
57955 + option with name "socket_server_gid" is created.
57956 +
57957 +endmenu
57958 +menu "Sysctl Support"
57959 +depends on GRKERNSEC && SYSCTL
57960 +
57961 +config GRKERNSEC_SYSCTL
57962 + bool "Sysctl support"
57963 + default y if GRKERNSEC_CONFIG_AUTO
57964 + help
57965 + If you say Y here, you will be able to change the options that
57966 + grsecurity runs with at bootup, without having to recompile your
57967 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57968 + to enable (1) or disable (0) various features. All the sysctl entries
57969 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57970 + All features enabled in the kernel configuration are disabled at boot
57971 + if you do not say Y to the "Turn on features by default" option.
57972 + All options should be set at startup, and the grsec_lock entry should
57973 + be set to a non-zero value after all the options are set.
57974 + *THIS IS EXTREMELY IMPORTANT*
57975 +
57976 +config GRKERNSEC_SYSCTL_DISTRO
57977 + bool "Extra sysctl support for distro makers (READ HELP)"
57978 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57979 + help
57980 + If you say Y here, additional sysctl options will be created
57981 + for features that affect processes running as root. Therefore,
57982 + it is critical when using this option that the grsec_lock entry be
57983 + enabled after boot. Only distros with prebuilt kernel packages
57984 + with this option enabled that can ensure grsec_lock is enabled
57985 + after boot should use this option.
57986 + *Failure to set grsec_lock after boot makes all grsec features
57987 + this option covers useless*
57988 +
57989 + Currently this option creates the following sysctl entries:
57990 + "Disable Privileged I/O": "disable_priv_io"
57991 +
57992 +config GRKERNSEC_SYSCTL_ON
57993 + bool "Turn on features by default"
57994 + default y if GRKERNSEC_CONFIG_AUTO
57995 + depends on GRKERNSEC_SYSCTL
57996 + help
57997 + If you say Y here, instead of having all features enabled in the
57998 + kernel configuration disabled at boot time, the features will be
57999 + enabled at boot time. It is recommended you say Y here unless
58000 + there is some reason you would want all sysctl-tunable features to
58001 + be disabled by default. As mentioned elsewhere, it is important
58002 + to enable the grsec_lock entry once you have finished modifying
58003 + the sysctl entries.
58004 +
58005 +endmenu
58006 +menu "Logging Options"
58007 +depends on GRKERNSEC
58008 +
58009 +config GRKERNSEC_FLOODTIME
58010 + int "Seconds in between log messages (minimum)"
58011 + default 10
58012 + help
58013 + This option allows you to enforce the number of seconds between
58014 + grsecurity log messages. The default should be suitable for most
58015 + people, however, if you choose to change it, choose a value small enough
58016 + to allow informative logs to be produced, but large enough to
58017 + prevent flooding.
58018 +
58019 +config GRKERNSEC_FLOODBURST
58020 + int "Number of messages in a burst (maximum)"
58021 + default 6
58022 + help
58023 + This option allows you to choose the maximum number of messages allowed
58024 + within the flood time interval you chose in a separate option. The
58025 + default should be suitable for most people, however if you find that
58026 + many of your logs are being interpreted as flooding, you may want to
58027 + raise this value.
58028 +
58029 +endmenu
58030 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58031 new file mode 100644
58032 index 0000000..1b9afa9
58033 --- /dev/null
58034 +++ b/grsecurity/Makefile
58035 @@ -0,0 +1,38 @@
58036 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58037 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58038 +# into an RBAC system
58039 +#
58040 +# All code in this directory and various hooks inserted throughout the kernel
58041 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58042 +# under the GPL v2 or higher
58043 +
58044 +KBUILD_CFLAGS += -Werror
58045 +
58046 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58047 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58048 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58049 +
58050 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58051 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58052 + gracl_learn.o grsec_log.o
58053 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58054 +
58055 +ifdef CONFIG_NET
58056 +obj-y += grsec_sock.o
58057 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58058 +endif
58059 +
58060 +ifndef CONFIG_GRKERNSEC
58061 +obj-y += grsec_disabled.o
58062 +endif
58063 +
58064 +ifdef CONFIG_GRKERNSEC_HIDESYM
58065 +extra-y := grsec_hidesym.o
58066 +$(obj)/grsec_hidesym.o:
58067 + @-chmod -f 500 /boot
58068 + @-chmod -f 500 /lib/modules
58069 + @-chmod -f 500 /lib64/modules
58070 + @-chmod -f 500 /lib32/modules
58071 + @-chmod -f 700 .
58072 + @echo ' grsec: protected kernel image paths'
58073 +endif
58074 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58075 new file mode 100644
58076 index 0000000..1248ee0
58077 --- /dev/null
58078 +++ b/grsecurity/gracl.c
58079 @@ -0,0 +1,4073 @@
58080 +#include <linux/kernel.h>
58081 +#include <linux/module.h>
58082 +#include <linux/sched.h>
58083 +#include <linux/mm.h>
58084 +#include <linux/file.h>
58085 +#include <linux/fs.h>
58086 +#include <linux/namei.h>
58087 +#include <linux/mount.h>
58088 +#include <linux/tty.h>
58089 +#include <linux/proc_fs.h>
58090 +#include <linux/lglock.h>
58091 +#include <linux/slab.h>
58092 +#include <linux/vmalloc.h>
58093 +#include <linux/types.h>
58094 +#include <linux/sysctl.h>
58095 +#include <linux/netdevice.h>
58096 +#include <linux/ptrace.h>
58097 +#include <linux/gracl.h>
58098 +#include <linux/gralloc.h>
58099 +#include <linux/security.h>
58100 +#include <linux/grinternal.h>
58101 +#include <linux/pid_namespace.h>
58102 +#include <linux/stop_machine.h>
58103 +#include <linux/fdtable.h>
58104 +#include <linux/percpu.h>
58105 +#include <linux/lglock.h>
58106 +#include <linux/hugetlb.h>
58107 +#include <linux/posix-timers.h>
58108 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58109 +#include <linux/magic.h>
58110 +#include <linux/pagemap.h>
58111 +#include "../fs/btrfs/async-thread.h"
58112 +#include "../fs/btrfs/ctree.h"
58113 +#include "../fs/btrfs/btrfs_inode.h"
58114 +#endif
58115 +#include "../fs/mount.h"
58116 +
58117 +#include <asm/uaccess.h>
58118 +#include <asm/errno.h>
58119 +#include <asm/mman.h>
58120 +
58121 +extern struct lglock vfsmount_lock;
58122 +
58123 +static struct acl_role_db acl_role_set;
58124 +static struct name_db name_set;
58125 +static struct inodev_db inodev_set;
58126 +
58127 +/* for keeping track of userspace pointers used for subjects, so we
58128 + can share references in the kernel as well
58129 +*/
58130 +
58131 +static struct path real_root;
58132 +
58133 +static struct acl_subj_map_db subj_map_set;
58134 +
58135 +static struct acl_role_label *default_role;
58136 +
58137 +static struct acl_role_label *role_list;
58138 +
58139 +static u16 acl_sp_role_value;
58140 +
58141 +extern char *gr_shared_page[4];
58142 +static DEFINE_MUTEX(gr_dev_mutex);
58143 +DEFINE_RWLOCK(gr_inode_lock);
58144 +
58145 +struct gr_arg *gr_usermode;
58146 +
58147 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58148 +
58149 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58150 +extern void gr_clear_learn_entries(void);
58151 +
58152 +unsigned char *gr_system_salt;
58153 +unsigned char *gr_system_sum;
58154 +
58155 +static struct sprole_pw **acl_special_roles = NULL;
58156 +static __u16 num_sprole_pws = 0;
58157 +
58158 +static struct acl_role_label *kernel_role = NULL;
58159 +
58160 +static unsigned int gr_auth_attempts = 0;
58161 +static unsigned long gr_auth_expires = 0UL;
58162 +
58163 +#ifdef CONFIG_NET
58164 +extern struct vfsmount *sock_mnt;
58165 +#endif
58166 +
58167 +extern struct vfsmount *pipe_mnt;
58168 +extern struct vfsmount *shm_mnt;
58169 +
58170 +#ifdef CONFIG_HUGETLBFS
58171 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58172 +#endif
58173 +
58174 +static struct acl_object_label *fakefs_obj_rw;
58175 +static struct acl_object_label *fakefs_obj_rwx;
58176 +
58177 +extern int gr_init_uidset(void);
58178 +extern void gr_free_uidset(void);
58179 +extern void gr_remove_uid(uid_t uid);
58180 +extern int gr_find_uid(uid_t uid);
58181 +
58182 +__inline__ int
58183 +gr_acl_is_enabled(void)
58184 +{
58185 + return (gr_status & GR_READY);
58186 +}
58187 +
58188 +static inline dev_t __get_dev(const struct dentry *dentry)
58189 +{
58190 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58191 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
58192 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
58193 + else
58194 +#endif
58195 + return dentry->d_sb->s_dev;
58196 +}
58197 +
58198 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58199 +{
58200 + return __get_dev(dentry);
58201 +}
58202 +
58203 +static char gr_task_roletype_to_char(struct task_struct *task)
58204 +{
58205 + switch (task->role->roletype &
58206 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58207 + GR_ROLE_SPECIAL)) {
58208 + case GR_ROLE_DEFAULT:
58209 + return 'D';
58210 + case GR_ROLE_USER:
58211 + return 'U';
58212 + case GR_ROLE_GROUP:
58213 + return 'G';
58214 + case GR_ROLE_SPECIAL:
58215 + return 'S';
58216 + }
58217 +
58218 + return 'X';
58219 +}
58220 +
58221 +char gr_roletype_to_char(void)
58222 +{
58223 + return gr_task_roletype_to_char(current);
58224 +}
58225 +
58226 +__inline__ int
58227 +gr_acl_tpe_check(void)
58228 +{
58229 + if (unlikely(!(gr_status & GR_READY)))
58230 + return 0;
58231 + if (current->role->roletype & GR_ROLE_TPE)
58232 + return 1;
58233 + else
58234 + return 0;
58235 +}
58236 +
58237 +int
58238 +gr_handle_rawio(const struct inode *inode)
58239 +{
58240 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58241 + if (inode && S_ISBLK(inode->i_mode) &&
58242 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58243 + !capable(CAP_SYS_RAWIO))
58244 + return 1;
58245 +#endif
58246 + return 0;
58247 +}
58248 +
58249 +static int
58250 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58251 +{
58252 + if (likely(lena != lenb))
58253 + return 0;
58254 +
58255 + return !memcmp(a, b, lena);
58256 +}
58257 +
58258 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58259 +{
58260 + *buflen -= namelen;
58261 + if (*buflen < 0)
58262 + return -ENAMETOOLONG;
58263 + *buffer -= namelen;
58264 + memcpy(*buffer, str, namelen);
58265 + return 0;
58266 +}
58267 +
58268 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58269 +{
58270 + return prepend(buffer, buflen, name->name, name->len);
58271 +}
58272 +
58273 +static int prepend_path(const struct path *path, struct path *root,
58274 + char **buffer, int *buflen)
58275 +{
58276 + struct dentry *dentry = path->dentry;
58277 + struct vfsmount *vfsmnt = path->mnt;
58278 + struct mount *mnt = real_mount(vfsmnt);
58279 + bool slash = false;
58280 + int error = 0;
58281 +
58282 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58283 + struct dentry * parent;
58284 +
58285 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58286 + /* Global root? */
58287 + if (!mnt_has_parent(mnt)) {
58288 + goto out;
58289 + }
58290 + dentry = mnt->mnt_mountpoint;
58291 + mnt = mnt->mnt_parent;
58292 + vfsmnt = &mnt->mnt;
58293 + continue;
58294 + }
58295 + parent = dentry->d_parent;
58296 + prefetch(parent);
58297 + spin_lock(&dentry->d_lock);
58298 + error = prepend_name(buffer, buflen, &dentry->d_name);
58299 + spin_unlock(&dentry->d_lock);
58300 + if (!error)
58301 + error = prepend(buffer, buflen, "/", 1);
58302 + if (error)
58303 + break;
58304 +
58305 + slash = true;
58306 + dentry = parent;
58307 + }
58308 +
58309 +out:
58310 + if (!error && !slash)
58311 + error = prepend(buffer, buflen, "/", 1);
58312 +
58313 + return error;
58314 +}
58315 +
58316 +/* this must be called with vfsmount_lock and rename_lock held */
58317 +
58318 +static char *__our_d_path(const struct path *path, struct path *root,
58319 + char *buf, int buflen)
58320 +{
58321 + char *res = buf + buflen;
58322 + int error;
58323 +
58324 + prepend(&res, &buflen, "\0", 1);
58325 + error = prepend_path(path, root, &res, &buflen);
58326 + if (error)
58327 + return ERR_PTR(error);
58328 +
58329 + return res;
58330 +}
58331 +
58332 +static char *
58333 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58334 +{
58335 + char *retval;
58336 +
58337 + retval = __our_d_path(path, root, buf, buflen);
58338 + if (unlikely(IS_ERR(retval)))
58339 + retval = strcpy(buf, "<path too long>");
58340 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58341 + retval[1] = '\0';
58342 +
58343 + return retval;
58344 +}
58345 +
58346 +static char *
58347 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58348 + char *buf, int buflen)
58349 +{
58350 + struct path path;
58351 + char *res;
58352 +
58353 + path.dentry = (struct dentry *)dentry;
58354 + path.mnt = (struct vfsmount *)vfsmnt;
58355 +
58356 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58357 + by the RBAC system */
58358 + res = gen_full_path(&path, &real_root, buf, buflen);
58359 +
58360 + return res;
58361 +}
58362 +
58363 +static char *
58364 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58365 + char *buf, int buflen)
58366 +{
58367 + char *res;
58368 + struct path path;
58369 + struct path root;
58370 + struct task_struct *reaper = init_pid_ns.child_reaper;
58371 +
58372 + path.dentry = (struct dentry *)dentry;
58373 + path.mnt = (struct vfsmount *)vfsmnt;
58374 +
58375 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58376 + get_fs_root(reaper->fs, &root);
58377 +
58378 + br_read_lock(&vfsmount_lock);
58379 + write_seqlock(&rename_lock);
58380 + res = gen_full_path(&path, &root, buf, buflen);
58381 + write_sequnlock(&rename_lock);
58382 + br_read_unlock(&vfsmount_lock);
58383 +
58384 + path_put(&root);
58385 + return res;
58386 +}
58387 +
58388 +static char *
58389 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58390 +{
58391 + char *ret;
58392 + br_read_lock(&vfsmount_lock);
58393 + write_seqlock(&rename_lock);
58394 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58395 + PAGE_SIZE);
58396 + write_sequnlock(&rename_lock);
58397 + br_read_unlock(&vfsmount_lock);
58398 + return ret;
58399 +}
58400 +
58401 +static char *
58402 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58403 +{
58404 + char *ret;
58405 + char *buf;
58406 + int buflen;
58407 +
58408 + br_read_lock(&vfsmount_lock);
58409 + write_seqlock(&rename_lock);
58410 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58411 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58412 + buflen = (int)(ret - buf);
58413 + if (buflen >= 5)
58414 + prepend(&ret, &buflen, "/proc", 5);
58415 + else
58416 + ret = strcpy(buf, "<path too long>");
58417 + write_sequnlock(&rename_lock);
58418 + br_read_unlock(&vfsmount_lock);
58419 + return ret;
58420 +}
58421 +
58422 +char *
58423 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58424 +{
58425 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58426 + PAGE_SIZE);
58427 +}
58428 +
58429 +char *
58430 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58431 +{
58432 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58433 + PAGE_SIZE);
58434 +}
58435 +
58436 +char *
58437 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58438 +{
58439 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58440 + PAGE_SIZE);
58441 +}
58442 +
58443 +char *
58444 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58445 +{
58446 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58447 + PAGE_SIZE);
58448 +}
58449 +
58450 +char *
58451 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58452 +{
58453 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58454 + PAGE_SIZE);
58455 +}
58456 +
58457 +__inline__ __u32
58458 +to_gr_audit(const __u32 reqmode)
58459 +{
58460 + /* masks off auditable permission flags, then shifts them to create
58461 + auditing flags, and adds the special case of append auditing if
58462 + we're requesting write */
58463 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58464 +}
58465 +
58466 +struct acl_subject_label *
58467 +lookup_subject_map(const struct acl_subject_label *userp)
58468 +{
58469 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58470 + struct subject_map *match;
58471 +
58472 + match = subj_map_set.s_hash[index];
58473 +
58474 + while (match && match->user != userp)
58475 + match = match->next;
58476 +
58477 + if (match != NULL)
58478 + return match->kernel;
58479 + else
58480 + return NULL;
58481 +}
58482 +
58483 +static void
58484 +insert_subj_map_entry(struct subject_map *subjmap)
58485 +{
58486 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58487 + struct subject_map **curr;
58488 +
58489 + subjmap->prev = NULL;
58490 +
58491 + curr = &subj_map_set.s_hash[index];
58492 + if (*curr != NULL)
58493 + (*curr)->prev = subjmap;
58494 +
58495 + subjmap->next = *curr;
58496 + *curr = subjmap;
58497 +
58498 + return;
58499 +}
58500 +
58501 +static struct acl_role_label *
58502 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58503 + const gid_t gid)
58504 +{
58505 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58506 + struct acl_role_label *match;
58507 + struct role_allowed_ip *ipp;
58508 + unsigned int x;
58509 + u32 curr_ip = task->signal->curr_ip;
58510 +
58511 + task->signal->saved_ip = curr_ip;
58512 +
58513 + match = acl_role_set.r_hash[index];
58514 +
58515 + while (match) {
58516 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58517 + for (x = 0; x < match->domain_child_num; x++) {
58518 + if (match->domain_children[x] == uid)
58519 + goto found;
58520 + }
58521 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58522 + break;
58523 + match = match->next;
58524 + }
58525 +found:
58526 + if (match == NULL) {
58527 + try_group:
58528 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58529 + match = acl_role_set.r_hash[index];
58530 +
58531 + while (match) {
58532 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58533 + for (x = 0; x < match->domain_child_num; x++) {
58534 + if (match->domain_children[x] == gid)
58535 + goto found2;
58536 + }
58537 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58538 + break;
58539 + match = match->next;
58540 + }
58541 +found2:
58542 + if (match == NULL)
58543 + match = default_role;
58544 + if (match->allowed_ips == NULL)
58545 + return match;
58546 + else {
58547 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58548 + if (likely
58549 + ((ntohl(curr_ip) & ipp->netmask) ==
58550 + (ntohl(ipp->addr) & ipp->netmask)))
58551 + return match;
58552 + }
58553 + match = default_role;
58554 + }
58555 + } else if (match->allowed_ips == NULL) {
58556 + return match;
58557 + } else {
58558 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58559 + if (likely
58560 + ((ntohl(curr_ip) & ipp->netmask) ==
58561 + (ntohl(ipp->addr) & ipp->netmask)))
58562 + return match;
58563 + }
58564 + goto try_group;
58565 + }
58566 +
58567 + return match;
58568 +}
58569 +
58570 +struct acl_subject_label *
58571 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58572 + const struct acl_role_label *role)
58573 +{
58574 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58575 + struct acl_subject_label *match;
58576 +
58577 + match = role->subj_hash[index];
58578 +
58579 + while (match && (match->inode != ino || match->device != dev ||
58580 + (match->mode & GR_DELETED))) {
58581 + match = match->next;
58582 + }
58583 +
58584 + if (match && !(match->mode & GR_DELETED))
58585 + return match;
58586 + else
58587 + return NULL;
58588 +}
58589 +
58590 +struct acl_subject_label *
58591 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58592 + const struct acl_role_label *role)
58593 +{
58594 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58595 + struct acl_subject_label *match;
58596 +
58597 + match = role->subj_hash[index];
58598 +
58599 + while (match && (match->inode != ino || match->device != dev ||
58600 + !(match->mode & GR_DELETED))) {
58601 + match = match->next;
58602 + }
58603 +
58604 + if (match && (match->mode & GR_DELETED))
58605 + return match;
58606 + else
58607 + return NULL;
58608 +}
58609 +
58610 +static struct acl_object_label *
58611 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58612 + const struct acl_subject_label *subj)
58613 +{
58614 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58615 + struct acl_object_label *match;
58616 +
58617 + match = subj->obj_hash[index];
58618 +
58619 + while (match && (match->inode != ino || match->device != dev ||
58620 + (match->mode & GR_DELETED))) {
58621 + match = match->next;
58622 + }
58623 +
58624 + if (match && !(match->mode & GR_DELETED))
58625 + return match;
58626 + else
58627 + return NULL;
58628 +}
58629 +
58630 +static struct acl_object_label *
58631 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58632 + const struct acl_subject_label *subj)
58633 +{
58634 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58635 + struct acl_object_label *match;
58636 +
58637 + match = subj->obj_hash[index];
58638 +
58639 + while (match && (match->inode != ino || match->device != dev ||
58640 + !(match->mode & GR_DELETED))) {
58641 + match = match->next;
58642 + }
58643 +
58644 + if (match && (match->mode & GR_DELETED))
58645 + return 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 name_entry *
58661 +lookup_name_entry(const char *name)
58662 +{
58663 + unsigned int len = strlen(name);
58664 + unsigned int key = full_name_hash(name, len);
58665 + unsigned int index = key % name_set.n_size;
58666 + struct name_entry *match;
58667 +
58668 + match = name_set.n_hash[index];
58669 +
58670 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58671 + match = match->next;
58672 +
58673 + return match;
58674 +}
58675 +
58676 +static struct name_entry *
58677 +lookup_name_entry_create(const char *name)
58678 +{
58679 + unsigned int len = strlen(name);
58680 + unsigned int key = full_name_hash(name, len);
58681 + unsigned int index = key % name_set.n_size;
58682 + struct name_entry *match;
58683 +
58684 + match = name_set.n_hash[index];
58685 +
58686 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58687 + !match->deleted))
58688 + match = match->next;
58689 +
58690 + if (match && match->deleted)
58691 + return match;
58692 +
58693 + match = name_set.n_hash[index];
58694 +
58695 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58696 + match->deleted))
58697 + match = match->next;
58698 +
58699 + if (match && !match->deleted)
58700 + return match;
58701 + else
58702 + return NULL;
58703 +}
58704 +
58705 +static struct inodev_entry *
58706 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58707 +{
58708 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58709 + struct inodev_entry *match;
58710 +
58711 + match = inodev_set.i_hash[index];
58712 +
58713 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58714 + match = match->next;
58715 +
58716 + return match;
58717 +}
58718 +
58719 +static void
58720 +insert_inodev_entry(struct inodev_entry *entry)
58721 +{
58722 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58723 + inodev_set.i_size);
58724 + struct inodev_entry **curr;
58725 +
58726 + entry->prev = NULL;
58727 +
58728 + curr = &inodev_set.i_hash[index];
58729 + if (*curr != NULL)
58730 + (*curr)->prev = entry;
58731 +
58732 + entry->next = *curr;
58733 + *curr = entry;
58734 +
58735 + return;
58736 +}
58737 +
58738 +static void
58739 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58740 +{
58741 + unsigned int index =
58742 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58743 + struct acl_role_label **curr;
58744 + struct acl_role_label *tmp, *tmp2;
58745 +
58746 + curr = &acl_role_set.r_hash[index];
58747 +
58748 + /* simple case, slot is empty, just set it to our role */
58749 + if (*curr == NULL) {
58750 + *curr = role;
58751 + } else {
58752 + /* example:
58753 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58754 + 2 -> 3
58755 + */
58756 + /* first check to see if we can already be reached via this slot */
58757 + tmp = *curr;
58758 + while (tmp && tmp != role)
58759 + tmp = tmp->next;
58760 + if (tmp == role) {
58761 + /* we don't need to add ourselves to this slot's chain */
58762 + return;
58763 + }
58764 + /* we need to add ourselves to this chain, two cases */
58765 + if (role->next == NULL) {
58766 + /* simple case, append the current chain to our role */
58767 + role->next = *curr;
58768 + *curr = role;
58769 + } else {
58770 + /* 1 -> 2 -> 3 -> 4
58771 + 2 -> 3 -> 4
58772 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58773 + */
58774 + /* trickier case: walk our role's chain until we find
58775 + the role for the start of the current slot's chain */
58776 + tmp = role;
58777 + tmp2 = *curr;
58778 + while (tmp->next && tmp->next != tmp2)
58779 + tmp = tmp->next;
58780 + if (tmp->next == tmp2) {
58781 + /* from example above, we found 3, so just
58782 + replace this slot's chain with ours */
58783 + *curr = role;
58784 + } else {
58785 + /* we didn't find a subset of our role's chain
58786 + in the current slot's chain, so append their
58787 + chain to ours, and set us as the first role in
58788 + the slot's chain
58789 +
58790 + we could fold this case with the case above,
58791 + but making it explicit for clarity
58792 + */
58793 + tmp->next = tmp2;
58794 + *curr = role;
58795 + }
58796 + }
58797 + }
58798 +
58799 + return;
58800 +}
58801 +
58802 +static void
58803 +insert_acl_role_label(struct acl_role_label *role)
58804 +{
58805 + int i;
58806 +
58807 + if (role_list == NULL) {
58808 + role_list = role;
58809 + role->prev = NULL;
58810 + } else {
58811 + role->prev = role_list;
58812 + role_list = role;
58813 + }
58814 +
58815 + /* used for hash chains */
58816 + role->next = NULL;
58817 +
58818 + if (role->roletype & GR_ROLE_DOMAIN) {
58819 + for (i = 0; i < role->domain_child_num; i++)
58820 + __insert_acl_role_label(role, role->domain_children[i]);
58821 + } else
58822 + __insert_acl_role_label(role, role->uidgid);
58823 +}
58824 +
58825 +static int
58826 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58827 +{
58828 + struct name_entry **curr, *nentry;
58829 + struct inodev_entry *ientry;
58830 + unsigned int len = strlen(name);
58831 + unsigned int key = full_name_hash(name, len);
58832 + unsigned int index = key % name_set.n_size;
58833 +
58834 + curr = &name_set.n_hash[index];
58835 +
58836 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58837 + curr = &((*curr)->next);
58838 +
58839 + if (*curr != NULL)
58840 + return 1;
58841 +
58842 + nentry = acl_alloc(sizeof (struct name_entry));
58843 + if (nentry == NULL)
58844 + return 0;
58845 + ientry = acl_alloc(sizeof (struct inodev_entry));
58846 + if (ientry == NULL)
58847 + return 0;
58848 + ientry->nentry = nentry;
58849 +
58850 + nentry->key = key;
58851 + nentry->name = name;
58852 + nentry->inode = inode;
58853 + nentry->device = device;
58854 + nentry->len = len;
58855 + nentry->deleted = deleted;
58856 +
58857 + nentry->prev = NULL;
58858 + curr = &name_set.n_hash[index];
58859 + if (*curr != NULL)
58860 + (*curr)->prev = nentry;
58861 + nentry->next = *curr;
58862 + *curr = nentry;
58863 +
58864 + /* insert us into the table searchable by inode/dev */
58865 + insert_inodev_entry(ientry);
58866 +
58867 + return 1;
58868 +}
58869 +
58870 +static void
58871 +insert_acl_obj_label(struct acl_object_label *obj,
58872 + struct acl_subject_label *subj)
58873 +{
58874 + unsigned int index =
58875 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58876 + struct acl_object_label **curr;
58877 +
58878 +
58879 + obj->prev = NULL;
58880 +
58881 + curr = &subj->obj_hash[index];
58882 + if (*curr != NULL)
58883 + (*curr)->prev = obj;
58884 +
58885 + obj->next = *curr;
58886 + *curr = obj;
58887 +
58888 + return;
58889 +}
58890 +
58891 +static void
58892 +insert_acl_subj_label(struct acl_subject_label *obj,
58893 + struct acl_role_label *role)
58894 +{
58895 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58896 + struct acl_subject_label **curr;
58897 +
58898 + obj->prev = NULL;
58899 +
58900 + curr = &role->subj_hash[index];
58901 + if (*curr != NULL)
58902 + (*curr)->prev = obj;
58903 +
58904 + obj->next = *curr;
58905 + *curr = obj;
58906 +
58907 + return;
58908 +}
58909 +
58910 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58911 +
58912 +static void *
58913 +create_table(__u32 * len, int elementsize)
58914 +{
58915 + unsigned int table_sizes[] = {
58916 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58917 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58918 + 4194301, 8388593, 16777213, 33554393, 67108859
58919 + };
58920 + void *newtable = NULL;
58921 + unsigned int pwr = 0;
58922 +
58923 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58924 + table_sizes[pwr] <= *len)
58925 + pwr++;
58926 +
58927 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58928 + return newtable;
58929 +
58930 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58931 + newtable =
58932 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58933 + else
58934 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58935 +
58936 + *len = table_sizes[pwr];
58937 +
58938 + return newtable;
58939 +}
58940 +
58941 +static int
58942 +init_variables(const struct gr_arg *arg)
58943 +{
58944 + struct task_struct *reaper = init_pid_ns.child_reaper;
58945 + unsigned int stacksize;
58946 +
58947 + subj_map_set.s_size = arg->role_db.num_subjects;
58948 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58949 + name_set.n_size = arg->role_db.num_objects;
58950 + inodev_set.i_size = arg->role_db.num_objects;
58951 +
58952 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58953 + !name_set.n_size || !inodev_set.i_size)
58954 + return 1;
58955 +
58956 + if (!gr_init_uidset())
58957 + return 1;
58958 +
58959 + /* set up the stack that holds allocation info */
58960 +
58961 + stacksize = arg->role_db.num_pointers + 5;
58962 +
58963 + if (!acl_alloc_stack_init(stacksize))
58964 + return 1;
58965 +
58966 + /* grab reference for the real root dentry and vfsmount */
58967 + get_fs_root(reaper->fs, &real_root);
58968 +
58969 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58970 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58971 +#endif
58972 +
58973 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58974 + if (fakefs_obj_rw == NULL)
58975 + return 1;
58976 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58977 +
58978 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58979 + if (fakefs_obj_rwx == NULL)
58980 + return 1;
58981 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58982 +
58983 + subj_map_set.s_hash =
58984 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58985 + acl_role_set.r_hash =
58986 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58987 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58988 + inodev_set.i_hash =
58989 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58990 +
58991 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58992 + !name_set.n_hash || !inodev_set.i_hash)
58993 + return 1;
58994 +
58995 + memset(subj_map_set.s_hash, 0,
58996 + sizeof(struct subject_map *) * subj_map_set.s_size);
58997 + memset(acl_role_set.r_hash, 0,
58998 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58999 + memset(name_set.n_hash, 0,
59000 + sizeof (struct name_entry *) * name_set.n_size);
59001 + memset(inodev_set.i_hash, 0,
59002 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59003 +
59004 + return 0;
59005 +}
59006 +
59007 +/* free information not needed after startup
59008 + currently contains user->kernel pointer mappings for subjects
59009 +*/
59010 +
59011 +static void
59012 +free_init_variables(void)
59013 +{
59014 + __u32 i;
59015 +
59016 + if (subj_map_set.s_hash) {
59017 + for (i = 0; i < subj_map_set.s_size; i++) {
59018 + if (subj_map_set.s_hash[i]) {
59019 + kfree(subj_map_set.s_hash[i]);
59020 + subj_map_set.s_hash[i] = NULL;
59021 + }
59022 + }
59023 +
59024 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59025 + PAGE_SIZE)
59026 + kfree(subj_map_set.s_hash);
59027 + else
59028 + vfree(subj_map_set.s_hash);
59029 + }
59030 +
59031 + return;
59032 +}
59033 +
59034 +static void
59035 +free_variables(void)
59036 +{
59037 + struct acl_subject_label *s;
59038 + struct acl_role_label *r;
59039 + struct task_struct *task, *task2;
59040 + unsigned int x;
59041 +
59042 + gr_clear_learn_entries();
59043 +
59044 + read_lock(&tasklist_lock);
59045 + do_each_thread(task2, task) {
59046 + task->acl_sp_role = 0;
59047 + task->acl_role_id = 0;
59048 + task->acl = NULL;
59049 + task->role = NULL;
59050 + } while_each_thread(task2, task);
59051 + read_unlock(&tasklist_lock);
59052 +
59053 + /* release the reference to the real root dentry and vfsmount */
59054 + path_put(&real_root);
59055 + memset(&real_root, 0, sizeof(real_root));
59056 +
59057 + /* free all object hash tables */
59058 +
59059 + FOR_EACH_ROLE_START(r)
59060 + if (r->subj_hash == NULL)
59061 + goto next_role;
59062 + FOR_EACH_SUBJECT_START(r, s, x)
59063 + if (s->obj_hash == NULL)
59064 + break;
59065 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59066 + kfree(s->obj_hash);
59067 + else
59068 + vfree(s->obj_hash);
59069 + FOR_EACH_SUBJECT_END(s, x)
59070 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59071 + if (s->obj_hash == NULL)
59072 + break;
59073 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59074 + kfree(s->obj_hash);
59075 + else
59076 + vfree(s->obj_hash);
59077 + FOR_EACH_NESTED_SUBJECT_END(s)
59078 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59079 + kfree(r->subj_hash);
59080 + else
59081 + vfree(r->subj_hash);
59082 + r->subj_hash = NULL;
59083 +next_role:
59084 + FOR_EACH_ROLE_END(r)
59085 +
59086 + acl_free_all();
59087 +
59088 + if (acl_role_set.r_hash) {
59089 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59090 + PAGE_SIZE)
59091 + kfree(acl_role_set.r_hash);
59092 + else
59093 + vfree(acl_role_set.r_hash);
59094 + }
59095 + if (name_set.n_hash) {
59096 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59097 + PAGE_SIZE)
59098 + kfree(name_set.n_hash);
59099 + else
59100 + vfree(name_set.n_hash);
59101 + }
59102 +
59103 + if (inodev_set.i_hash) {
59104 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59105 + PAGE_SIZE)
59106 + kfree(inodev_set.i_hash);
59107 + else
59108 + vfree(inodev_set.i_hash);
59109 + }
59110 +
59111 + gr_free_uidset();
59112 +
59113 + memset(&name_set, 0, sizeof (struct name_db));
59114 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59115 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59116 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59117 +
59118 + default_role = NULL;
59119 + kernel_role = NULL;
59120 + role_list = NULL;
59121 +
59122 + return;
59123 +}
59124 +
59125 +static __u32
59126 +count_user_objs(struct acl_object_label *userp)
59127 +{
59128 + struct acl_object_label o_tmp;
59129 + __u32 num = 0;
59130 +
59131 + while (userp) {
59132 + if (copy_from_user(&o_tmp, userp,
59133 + sizeof (struct acl_object_label)))
59134 + break;
59135 +
59136 + userp = o_tmp.prev;
59137 + num++;
59138 + }
59139 +
59140 + return num;
59141 +}
59142 +
59143 +static struct acl_subject_label *
59144 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59145 +
59146 +static int
59147 +copy_user_glob(struct acl_object_label *obj)
59148 +{
59149 + struct acl_object_label *g_tmp, **guser;
59150 + unsigned int len;
59151 + char *tmp;
59152 +
59153 + if (obj->globbed == NULL)
59154 + return 0;
59155 +
59156 + guser = &obj->globbed;
59157 + while (*guser) {
59158 + g_tmp = (struct acl_object_label *)
59159 + acl_alloc(sizeof (struct acl_object_label));
59160 + if (g_tmp == NULL)
59161 + return -ENOMEM;
59162 +
59163 + if (copy_from_user(g_tmp, *guser,
59164 + sizeof (struct acl_object_label)))
59165 + return -EFAULT;
59166 +
59167 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59168 +
59169 + if (!len || len >= PATH_MAX)
59170 + return -EINVAL;
59171 +
59172 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59173 + return -ENOMEM;
59174 +
59175 + if (copy_from_user(tmp, g_tmp->filename, len))
59176 + return -EFAULT;
59177 + tmp[len-1] = '\0';
59178 + g_tmp->filename = tmp;
59179 +
59180 + *guser = g_tmp;
59181 + guser = &(g_tmp->next);
59182 + }
59183 +
59184 + return 0;
59185 +}
59186 +
59187 +static int
59188 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59189 + struct acl_role_label *role)
59190 +{
59191 + struct acl_object_label *o_tmp;
59192 + unsigned int len;
59193 + int ret;
59194 + char *tmp;
59195 +
59196 + while (userp) {
59197 + if ((o_tmp = (struct acl_object_label *)
59198 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59199 + return -ENOMEM;
59200 +
59201 + if (copy_from_user(o_tmp, userp,
59202 + sizeof (struct acl_object_label)))
59203 + return -EFAULT;
59204 +
59205 + userp = o_tmp->prev;
59206 +
59207 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59208 +
59209 + if (!len || len >= PATH_MAX)
59210 + return -EINVAL;
59211 +
59212 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59213 + return -ENOMEM;
59214 +
59215 + if (copy_from_user(tmp, o_tmp->filename, len))
59216 + return -EFAULT;
59217 + tmp[len-1] = '\0';
59218 + o_tmp->filename = tmp;
59219 +
59220 + insert_acl_obj_label(o_tmp, subj);
59221 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59222 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59223 + return -ENOMEM;
59224 +
59225 + ret = copy_user_glob(o_tmp);
59226 + if (ret)
59227 + return ret;
59228 +
59229 + if (o_tmp->nested) {
59230 + int already_copied;
59231 +
59232 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59233 + if (IS_ERR(o_tmp->nested))
59234 + return PTR_ERR(o_tmp->nested);
59235 +
59236 + /* insert into nested subject list if we haven't copied this one yet
59237 + to prevent duplicate entries */
59238 + if (!already_copied) {
59239 + o_tmp->nested->next = role->hash->first;
59240 + role->hash->first = o_tmp->nested;
59241 + }
59242 + }
59243 + }
59244 +
59245 + return 0;
59246 +}
59247 +
59248 +static __u32
59249 +count_user_subjs(struct acl_subject_label *userp)
59250 +{
59251 + struct acl_subject_label s_tmp;
59252 + __u32 num = 0;
59253 +
59254 + while (userp) {
59255 + if (copy_from_user(&s_tmp, userp,
59256 + sizeof (struct acl_subject_label)))
59257 + break;
59258 +
59259 + userp = s_tmp.prev;
59260 + }
59261 +
59262 + return num;
59263 +}
59264 +
59265 +static int
59266 +copy_user_allowedips(struct acl_role_label *rolep)
59267 +{
59268 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59269 +
59270 + ruserip = rolep->allowed_ips;
59271 +
59272 + while (ruserip) {
59273 + rlast = rtmp;
59274 +
59275 + if ((rtmp = (struct role_allowed_ip *)
59276 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59277 + return -ENOMEM;
59278 +
59279 + if (copy_from_user(rtmp, ruserip,
59280 + sizeof (struct role_allowed_ip)))
59281 + return -EFAULT;
59282 +
59283 + ruserip = rtmp->prev;
59284 +
59285 + if (!rlast) {
59286 + rtmp->prev = NULL;
59287 + rolep->allowed_ips = rtmp;
59288 + } else {
59289 + rlast->next = rtmp;
59290 + rtmp->prev = rlast;
59291 + }
59292 +
59293 + if (!ruserip)
59294 + rtmp->next = NULL;
59295 + }
59296 +
59297 + return 0;
59298 +}
59299 +
59300 +static int
59301 +copy_user_transitions(struct acl_role_label *rolep)
59302 +{
59303 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59304 +
59305 + unsigned int len;
59306 + char *tmp;
59307 +
59308 + rusertp = rolep->transitions;
59309 +
59310 + while (rusertp) {
59311 + rlast = rtmp;
59312 +
59313 + if ((rtmp = (struct role_transition *)
59314 + acl_alloc(sizeof (struct role_transition))) == NULL)
59315 + return -ENOMEM;
59316 +
59317 + if (copy_from_user(rtmp, rusertp,
59318 + sizeof (struct role_transition)))
59319 + return -EFAULT;
59320 +
59321 + rusertp = rtmp->prev;
59322 +
59323 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59324 +
59325 + if (!len || len >= GR_SPROLE_LEN)
59326 + return -EINVAL;
59327 +
59328 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59329 + return -ENOMEM;
59330 +
59331 + if (copy_from_user(tmp, rtmp->rolename, len))
59332 + return -EFAULT;
59333 + tmp[len-1] = '\0';
59334 + rtmp->rolename = tmp;
59335 +
59336 + if (!rlast) {
59337 + rtmp->prev = NULL;
59338 + rolep->transitions = rtmp;
59339 + } else {
59340 + rlast->next = rtmp;
59341 + rtmp->prev = rlast;
59342 + }
59343 +
59344 + if (!rusertp)
59345 + rtmp->next = NULL;
59346 + }
59347 +
59348 + return 0;
59349 +}
59350 +
59351 +static struct acl_subject_label *
59352 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59353 +{
59354 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59355 + unsigned int len;
59356 + char *tmp;
59357 + __u32 num_objs;
59358 + struct acl_ip_label **i_tmp, *i_utmp2;
59359 + struct gr_hash_struct ghash;
59360 + struct subject_map *subjmap;
59361 + unsigned int i_num;
59362 + int err;
59363 +
59364 + if (already_copied != NULL)
59365 + *already_copied = 0;
59366 +
59367 + s_tmp = lookup_subject_map(userp);
59368 +
59369 + /* we've already copied this subject into the kernel, just return
59370 + the reference to it, and don't copy it over again
59371 + */
59372 + if (s_tmp) {
59373 + if (already_copied != NULL)
59374 + *already_copied = 1;
59375 + return(s_tmp);
59376 + }
59377 +
59378 + if ((s_tmp = (struct acl_subject_label *)
59379 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59380 + return ERR_PTR(-ENOMEM);
59381 +
59382 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59383 + if (subjmap == NULL)
59384 + return ERR_PTR(-ENOMEM);
59385 +
59386 + subjmap->user = userp;
59387 + subjmap->kernel = s_tmp;
59388 + insert_subj_map_entry(subjmap);
59389 +
59390 + if (copy_from_user(s_tmp, userp,
59391 + sizeof (struct acl_subject_label)))
59392 + return ERR_PTR(-EFAULT);
59393 +
59394 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59395 +
59396 + if (!len || len >= PATH_MAX)
59397 + return ERR_PTR(-EINVAL);
59398 +
59399 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59400 + return ERR_PTR(-ENOMEM);
59401 +
59402 + if (copy_from_user(tmp, s_tmp->filename, len))
59403 + return ERR_PTR(-EFAULT);
59404 + tmp[len-1] = '\0';
59405 + s_tmp->filename = tmp;
59406 +
59407 + if (!strcmp(s_tmp->filename, "/"))
59408 + role->root_label = s_tmp;
59409 +
59410 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59411 + return ERR_PTR(-EFAULT);
59412 +
59413 + /* copy user and group transition tables */
59414 +
59415 + if (s_tmp->user_trans_num) {
59416 + uid_t *uidlist;
59417 +
59418 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59419 + if (uidlist == NULL)
59420 + return ERR_PTR(-ENOMEM);
59421 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59422 + return ERR_PTR(-EFAULT);
59423 +
59424 + s_tmp->user_transitions = uidlist;
59425 + }
59426 +
59427 + if (s_tmp->group_trans_num) {
59428 + gid_t *gidlist;
59429 +
59430 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59431 + if (gidlist == NULL)
59432 + return ERR_PTR(-ENOMEM);
59433 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59434 + return ERR_PTR(-EFAULT);
59435 +
59436 + s_tmp->group_transitions = gidlist;
59437 + }
59438 +
59439 + /* set up object hash table */
59440 + num_objs = count_user_objs(ghash.first);
59441 +
59442 + s_tmp->obj_hash_size = num_objs;
59443 + s_tmp->obj_hash =
59444 + (struct acl_object_label **)
59445 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59446 +
59447 + if (!s_tmp->obj_hash)
59448 + return ERR_PTR(-ENOMEM);
59449 +
59450 + memset(s_tmp->obj_hash, 0,
59451 + s_tmp->obj_hash_size *
59452 + sizeof (struct acl_object_label *));
59453 +
59454 + /* add in objects */
59455 + err = copy_user_objs(ghash.first, s_tmp, role);
59456 +
59457 + if (err)
59458 + return ERR_PTR(err);
59459 +
59460 + /* set pointer for parent subject */
59461 + if (s_tmp->parent_subject) {
59462 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59463 +
59464 + if (IS_ERR(s_tmp2))
59465 + return s_tmp2;
59466 +
59467 + s_tmp->parent_subject = s_tmp2;
59468 + }
59469 +
59470 + /* add in ip acls */
59471 +
59472 + if (!s_tmp->ip_num) {
59473 + s_tmp->ips = NULL;
59474 + goto insert;
59475 + }
59476 +
59477 + i_tmp =
59478 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59479 + sizeof (struct acl_ip_label *));
59480 +
59481 + if (!i_tmp)
59482 + return ERR_PTR(-ENOMEM);
59483 +
59484 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59485 + *(i_tmp + i_num) =
59486 + (struct acl_ip_label *)
59487 + acl_alloc(sizeof (struct acl_ip_label));
59488 + if (!*(i_tmp + i_num))
59489 + return ERR_PTR(-ENOMEM);
59490 +
59491 + if (copy_from_user
59492 + (&i_utmp2, s_tmp->ips + i_num,
59493 + sizeof (struct acl_ip_label *)))
59494 + return ERR_PTR(-EFAULT);
59495 +
59496 + if (copy_from_user
59497 + (*(i_tmp + i_num), i_utmp2,
59498 + sizeof (struct acl_ip_label)))
59499 + return ERR_PTR(-EFAULT);
59500 +
59501 + if ((*(i_tmp + i_num))->iface == NULL)
59502 + continue;
59503 +
59504 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59505 + if (!len || len >= IFNAMSIZ)
59506 + return ERR_PTR(-EINVAL);
59507 + tmp = acl_alloc(len);
59508 + if (tmp == NULL)
59509 + return ERR_PTR(-ENOMEM);
59510 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59511 + return ERR_PTR(-EFAULT);
59512 + (*(i_tmp + i_num))->iface = tmp;
59513 + }
59514 +
59515 + s_tmp->ips = i_tmp;
59516 +
59517 +insert:
59518 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59519 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59520 + return ERR_PTR(-ENOMEM);
59521 +
59522 + return s_tmp;
59523 +}
59524 +
59525 +static int
59526 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59527 +{
59528 + struct acl_subject_label s_pre;
59529 + struct acl_subject_label * ret;
59530 + int err;
59531 +
59532 + while (userp) {
59533 + if (copy_from_user(&s_pre, userp,
59534 + sizeof (struct acl_subject_label)))
59535 + return -EFAULT;
59536 +
59537 + ret = do_copy_user_subj(userp, role, NULL);
59538 +
59539 + err = PTR_ERR(ret);
59540 + if (IS_ERR(ret))
59541 + return err;
59542 +
59543 + insert_acl_subj_label(ret, role);
59544 +
59545 + userp = s_pre.prev;
59546 + }
59547 +
59548 + return 0;
59549 +}
59550 +
59551 +static int
59552 +copy_user_acl(struct gr_arg *arg)
59553 +{
59554 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59555 + struct acl_subject_label *subj_list;
59556 + struct sprole_pw *sptmp;
59557 + struct gr_hash_struct *ghash;
59558 + uid_t *domainlist;
59559 + unsigned int r_num;
59560 + unsigned int len;
59561 + char *tmp;
59562 + int err = 0;
59563 + __u16 i;
59564 + __u32 num_subjs;
59565 +
59566 + /* we need a default and kernel role */
59567 + if (arg->role_db.num_roles < 2)
59568 + return -EINVAL;
59569 +
59570 + /* copy special role authentication info from userspace */
59571 +
59572 + num_sprole_pws = arg->num_sprole_pws;
59573 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59574 +
59575 + if (!acl_special_roles && num_sprole_pws)
59576 + return -ENOMEM;
59577 +
59578 + for (i = 0; i < num_sprole_pws; i++) {
59579 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59580 + if (!sptmp)
59581 + return -ENOMEM;
59582 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59583 + sizeof (struct sprole_pw)))
59584 + return -EFAULT;
59585 +
59586 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59587 +
59588 + if (!len || len >= GR_SPROLE_LEN)
59589 + return -EINVAL;
59590 +
59591 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59592 + return -ENOMEM;
59593 +
59594 + if (copy_from_user(tmp, sptmp->rolename, len))
59595 + return -EFAULT;
59596 +
59597 + tmp[len-1] = '\0';
59598 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59599 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59600 +#endif
59601 + sptmp->rolename = tmp;
59602 + acl_special_roles[i] = sptmp;
59603 + }
59604 +
59605 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59606 +
59607 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59608 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59609 +
59610 + if (!r_tmp)
59611 + return -ENOMEM;
59612 +
59613 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59614 + sizeof (struct acl_role_label *)))
59615 + return -EFAULT;
59616 +
59617 + if (copy_from_user(r_tmp, r_utmp2,
59618 + sizeof (struct acl_role_label)))
59619 + return -EFAULT;
59620 +
59621 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59622 +
59623 + if (!len || len >= PATH_MAX)
59624 + return -EINVAL;
59625 +
59626 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59627 + return -ENOMEM;
59628 +
59629 + if (copy_from_user(tmp, r_tmp->rolename, len))
59630 + return -EFAULT;
59631 +
59632 + tmp[len-1] = '\0';
59633 + r_tmp->rolename = tmp;
59634 +
59635 + if (!strcmp(r_tmp->rolename, "default")
59636 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59637 + default_role = r_tmp;
59638 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59639 + kernel_role = r_tmp;
59640 + }
59641 +
59642 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59643 + return -ENOMEM;
59644 +
59645 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59646 + return -EFAULT;
59647 +
59648 + r_tmp->hash = ghash;
59649 +
59650 + num_subjs = count_user_subjs(r_tmp->hash->first);
59651 +
59652 + r_tmp->subj_hash_size = num_subjs;
59653 + r_tmp->subj_hash =
59654 + (struct acl_subject_label **)
59655 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59656 +
59657 + if (!r_tmp->subj_hash)
59658 + return -ENOMEM;
59659 +
59660 + err = copy_user_allowedips(r_tmp);
59661 + if (err)
59662 + return err;
59663 +
59664 + /* copy domain info */
59665 + if (r_tmp->domain_children != NULL) {
59666 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59667 + if (domainlist == NULL)
59668 + return -ENOMEM;
59669 +
59670 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59671 + return -EFAULT;
59672 +
59673 + r_tmp->domain_children = domainlist;
59674 + }
59675 +
59676 + err = copy_user_transitions(r_tmp);
59677 + if (err)
59678 + return err;
59679 +
59680 + memset(r_tmp->subj_hash, 0,
59681 + r_tmp->subj_hash_size *
59682 + sizeof (struct acl_subject_label *));
59683 +
59684 + /* acquire the list of subjects, then NULL out
59685 + the list prior to parsing the subjects for this role,
59686 + as during this parsing the list is replaced with a list
59687 + of *nested* subjects for the role
59688 + */
59689 + subj_list = r_tmp->hash->first;
59690 +
59691 + /* set nested subject list to null */
59692 + r_tmp->hash->first = NULL;
59693 +
59694 + err = copy_user_subjs(subj_list, r_tmp);
59695 +
59696 + if (err)
59697 + return err;
59698 +
59699 + insert_acl_role_label(r_tmp);
59700 + }
59701 +
59702 + if (default_role == NULL || kernel_role == NULL)
59703 + return -EINVAL;
59704 +
59705 + return err;
59706 +}
59707 +
59708 +static int
59709 +gracl_init(struct gr_arg *args)
59710 +{
59711 + int error = 0;
59712 +
59713 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59714 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59715 +
59716 + if (init_variables(args)) {
59717 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59718 + error = -ENOMEM;
59719 + free_variables();
59720 + goto out;
59721 + }
59722 +
59723 + error = copy_user_acl(args);
59724 + free_init_variables();
59725 + if (error) {
59726 + free_variables();
59727 + goto out;
59728 + }
59729 +
59730 + if ((error = gr_set_acls(0))) {
59731 + free_variables();
59732 + goto out;
59733 + }
59734 +
59735 + pax_open_kernel();
59736 + gr_status |= GR_READY;
59737 + pax_close_kernel();
59738 +
59739 + out:
59740 + return error;
59741 +}
59742 +
59743 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59744 +
59745 +static int
59746 +glob_match(const char *p, const char *n)
59747 +{
59748 + char c;
59749 +
59750 + while ((c = *p++) != '\0') {
59751 + switch (c) {
59752 + case '?':
59753 + if (*n == '\0')
59754 + return 1;
59755 + else if (*n == '/')
59756 + return 1;
59757 + break;
59758 + case '\\':
59759 + if (*n != c)
59760 + return 1;
59761 + break;
59762 + case '*':
59763 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59764 + if (*n == '/')
59765 + return 1;
59766 + else if (c == '?') {
59767 + if (*n == '\0')
59768 + return 1;
59769 + else
59770 + ++n;
59771 + }
59772 + }
59773 + if (c == '\0') {
59774 + return 0;
59775 + } else {
59776 + const char *endp;
59777 +
59778 + if ((endp = strchr(n, '/')) == NULL)
59779 + endp = n + strlen(n);
59780 +
59781 + if (c == '[') {
59782 + for (--p; n < endp; ++n)
59783 + if (!glob_match(p, n))
59784 + return 0;
59785 + } else if (c == '/') {
59786 + while (*n != '\0' && *n != '/')
59787 + ++n;
59788 + if (*n == '/' && !glob_match(p, n + 1))
59789 + return 0;
59790 + } else {
59791 + for (--p; n < endp; ++n)
59792 + if (*n == c && !glob_match(p, n))
59793 + return 0;
59794 + }
59795 +
59796 + return 1;
59797 + }
59798 + case '[':
59799 + {
59800 + int not;
59801 + char cold;
59802 +
59803 + if (*n == '\0' || *n == '/')
59804 + return 1;
59805 +
59806 + not = (*p == '!' || *p == '^');
59807 + if (not)
59808 + ++p;
59809 +
59810 + c = *p++;
59811 + for (;;) {
59812 + unsigned char fn = (unsigned char)*n;
59813 +
59814 + if (c == '\0')
59815 + return 1;
59816 + else {
59817 + if (c == fn)
59818 + goto matched;
59819 + cold = c;
59820 + c = *p++;
59821 +
59822 + if (c == '-' && *p != ']') {
59823 + unsigned char cend = *p++;
59824 +
59825 + if (cend == '\0')
59826 + return 1;
59827 +
59828 + if (cold <= fn && fn <= cend)
59829 + goto matched;
59830 +
59831 + c = *p++;
59832 + }
59833 + }
59834 +
59835 + if (c == ']')
59836 + break;
59837 + }
59838 + if (!not)
59839 + return 1;
59840 + break;
59841 + matched:
59842 + while (c != ']') {
59843 + if (c == '\0')
59844 + return 1;
59845 +
59846 + c = *p++;
59847 + }
59848 + if (not)
59849 + return 1;
59850 + }
59851 + break;
59852 + default:
59853 + if (c != *n)
59854 + return 1;
59855 + }
59856 +
59857 + ++n;
59858 + }
59859 +
59860 + if (*n == '\0')
59861 + return 0;
59862 +
59863 + if (*n == '/')
59864 + return 0;
59865 +
59866 + return 1;
59867 +}
59868 +
59869 +static struct acl_object_label *
59870 +chk_glob_label(struct acl_object_label *globbed,
59871 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59872 +{
59873 + struct acl_object_label *tmp;
59874 +
59875 + if (*path == NULL)
59876 + *path = gr_to_filename_nolock(dentry, mnt);
59877 +
59878 + tmp = globbed;
59879 +
59880 + while (tmp) {
59881 + if (!glob_match(tmp->filename, *path))
59882 + return tmp;
59883 + tmp = tmp->next;
59884 + }
59885 +
59886 + return NULL;
59887 +}
59888 +
59889 +static struct acl_object_label *
59890 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59891 + const ino_t curr_ino, const dev_t curr_dev,
59892 + const struct acl_subject_label *subj, char **path, const int checkglob)
59893 +{
59894 + struct acl_subject_label *tmpsubj;
59895 + struct acl_object_label *retval;
59896 + struct acl_object_label *retval2;
59897 +
59898 + tmpsubj = (struct acl_subject_label *) subj;
59899 + read_lock(&gr_inode_lock);
59900 + do {
59901 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59902 + if (retval) {
59903 + if (checkglob && retval->globbed) {
59904 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59905 + if (retval2)
59906 + retval = retval2;
59907 + }
59908 + break;
59909 + }
59910 + } while ((tmpsubj = tmpsubj->parent_subject));
59911 + read_unlock(&gr_inode_lock);
59912 +
59913 + return retval;
59914 +}
59915 +
59916 +static __inline__ struct acl_object_label *
59917 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59918 + struct dentry *curr_dentry,
59919 + const struct acl_subject_label *subj, char **path, const int checkglob)
59920 +{
59921 + int newglob = checkglob;
59922 + ino_t inode;
59923 + dev_t device;
59924 +
59925 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59926 + as we don't want a / * rule to match instead of the / object
59927 + don't do this for create lookups that call this function though, since they're looking up
59928 + on the parent and thus need globbing checks on all paths
59929 + */
59930 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59931 + newglob = GR_NO_GLOB;
59932 +
59933 + spin_lock(&curr_dentry->d_lock);
59934 + inode = curr_dentry->d_inode->i_ino;
59935 + device = __get_dev(curr_dentry);
59936 + spin_unlock(&curr_dentry->d_lock);
59937 +
59938 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59939 +}
59940 +
59941 +#ifdef CONFIG_HUGETLBFS
59942 +static inline bool
59943 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59944 +{
59945 + int i;
59946 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59947 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59948 + return true;
59949 + }
59950 +
59951 + return false;
59952 +}
59953 +#endif
59954 +
59955 +static struct acl_object_label *
59956 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59957 + const struct acl_subject_label *subj, char *path, const int checkglob)
59958 +{
59959 + struct dentry *dentry = (struct dentry *) l_dentry;
59960 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59961 + struct mount *real_mnt = real_mount(mnt);
59962 + struct acl_object_label *retval;
59963 + struct dentry *parent;
59964 +
59965 + br_read_lock(&vfsmount_lock);
59966 + write_seqlock(&rename_lock);
59967 +
59968 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59969 +#ifdef CONFIG_NET
59970 + mnt == sock_mnt ||
59971 +#endif
59972 +#ifdef CONFIG_HUGETLBFS
59973 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59974 +#endif
59975 + /* ignore Eric Biederman */
59976 + IS_PRIVATE(l_dentry->d_inode))) {
59977 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59978 + goto out;
59979 + }
59980 +
59981 + for (;;) {
59982 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59983 + break;
59984 +
59985 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59986 + if (!mnt_has_parent(real_mnt))
59987 + break;
59988 +
59989 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59990 + if (retval != NULL)
59991 + goto out;
59992 +
59993 + dentry = real_mnt->mnt_mountpoint;
59994 + real_mnt = real_mnt->mnt_parent;
59995 + mnt = &real_mnt->mnt;
59996 + continue;
59997 + }
59998 +
59999 + parent = dentry->d_parent;
60000 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60001 + if (retval != NULL)
60002 + goto out;
60003 +
60004 + dentry = parent;
60005 + }
60006 +
60007 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60008 +
60009 + /* real_root is pinned so we don't have to hold a reference */
60010 + if (retval == NULL)
60011 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60012 +out:
60013 + write_sequnlock(&rename_lock);
60014 + br_read_unlock(&vfsmount_lock);
60015 +
60016 + BUG_ON(retval == NULL);
60017 +
60018 + return retval;
60019 +}
60020 +
60021 +static __inline__ struct acl_object_label *
60022 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60023 + const struct acl_subject_label *subj)
60024 +{
60025 + char *path = NULL;
60026 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60027 +}
60028 +
60029 +static __inline__ struct acl_object_label *
60030 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60031 + const struct acl_subject_label *subj)
60032 +{
60033 + char *path = NULL;
60034 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60035 +}
60036 +
60037 +static __inline__ struct acl_object_label *
60038 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60039 + const struct acl_subject_label *subj, char *path)
60040 +{
60041 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60042 +}
60043 +
60044 +static struct acl_subject_label *
60045 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60046 + const struct acl_role_label *role)
60047 +{
60048 + struct dentry *dentry = (struct dentry *) l_dentry;
60049 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60050 + struct mount *real_mnt = real_mount(mnt);
60051 + struct acl_subject_label *retval;
60052 + struct dentry *parent;
60053 +
60054 + br_read_lock(&vfsmount_lock);
60055 + write_seqlock(&rename_lock);
60056 +
60057 + for (;;) {
60058 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60059 + break;
60060 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60061 + if (!mnt_has_parent(real_mnt))
60062 + break;
60063 +
60064 + spin_lock(&dentry->d_lock);
60065 + read_lock(&gr_inode_lock);
60066 + retval =
60067 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60068 + __get_dev(dentry), role);
60069 + read_unlock(&gr_inode_lock);
60070 + spin_unlock(&dentry->d_lock);
60071 + if (retval != NULL)
60072 + goto out;
60073 +
60074 + dentry = real_mnt->mnt_mountpoint;
60075 + real_mnt = real_mnt->mnt_parent;
60076 + mnt = &real_mnt->mnt;
60077 + continue;
60078 + }
60079 +
60080 + spin_lock(&dentry->d_lock);
60081 + read_lock(&gr_inode_lock);
60082 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60083 + __get_dev(dentry), role);
60084 + read_unlock(&gr_inode_lock);
60085 + parent = dentry->d_parent;
60086 + spin_unlock(&dentry->d_lock);
60087 +
60088 + if (retval != NULL)
60089 + goto out;
60090 +
60091 + dentry = parent;
60092 + }
60093 +
60094 + spin_lock(&dentry->d_lock);
60095 + read_lock(&gr_inode_lock);
60096 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60097 + __get_dev(dentry), role);
60098 + read_unlock(&gr_inode_lock);
60099 + spin_unlock(&dentry->d_lock);
60100 +
60101 + if (unlikely(retval == NULL)) {
60102 + /* real_root is pinned, we don't need to hold a reference */
60103 + read_lock(&gr_inode_lock);
60104 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60105 + __get_dev(real_root.dentry), role);
60106 + read_unlock(&gr_inode_lock);
60107 + }
60108 +out:
60109 + write_sequnlock(&rename_lock);
60110 + br_read_unlock(&vfsmount_lock);
60111 +
60112 + BUG_ON(retval == NULL);
60113 +
60114 + return retval;
60115 +}
60116 +
60117 +static void
60118 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60119 +{
60120 + struct task_struct *task = current;
60121 + const struct cred *cred = current_cred();
60122 +
60123 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60124 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60125 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60126 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60127 +
60128 + return;
60129 +}
60130 +
60131 +static void
60132 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60133 +{
60134 + struct task_struct *task = current;
60135 + const struct cred *cred = current_cred();
60136 +
60137 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60138 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60139 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60140 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60141 +
60142 + return;
60143 +}
60144 +
60145 +static void
60146 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60147 +{
60148 + struct task_struct *task = current;
60149 + const struct cred *cred = current_cred();
60150 +
60151 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60152 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60153 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60154 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60155 +
60156 + return;
60157 +}
60158 +
60159 +__u32
60160 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60161 + const struct vfsmount * mnt)
60162 +{
60163 + __u32 retval = mode;
60164 + struct acl_subject_label *curracl;
60165 + struct acl_object_label *currobj;
60166 +
60167 + if (unlikely(!(gr_status & GR_READY)))
60168 + return (mode & ~GR_AUDITS);
60169 +
60170 + curracl = current->acl;
60171 +
60172 + currobj = chk_obj_label(dentry, mnt, curracl);
60173 + retval = currobj->mode & mode;
60174 +
60175 + /* if we're opening a specified transfer file for writing
60176 + (e.g. /dev/initctl), then transfer our role to init
60177 + */
60178 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60179 + current->role->roletype & GR_ROLE_PERSIST)) {
60180 + struct task_struct *task = init_pid_ns.child_reaper;
60181 +
60182 + if (task->role != current->role) {
60183 + task->acl_sp_role = 0;
60184 + task->acl_role_id = current->acl_role_id;
60185 + task->role = current->role;
60186 + rcu_read_lock();
60187 + read_lock(&grsec_exec_file_lock);
60188 + gr_apply_subject_to_task(task);
60189 + read_unlock(&grsec_exec_file_lock);
60190 + rcu_read_unlock();
60191 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60192 + }
60193 + }
60194 +
60195 + if (unlikely
60196 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60197 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60198 + __u32 new_mode = mode;
60199 +
60200 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60201 +
60202 + retval = new_mode;
60203 +
60204 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60205 + new_mode |= GR_INHERIT;
60206 +
60207 + if (!(mode & GR_NOLEARN))
60208 + gr_log_learn(dentry, mnt, new_mode);
60209 + }
60210 +
60211 + return retval;
60212 +}
60213 +
60214 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60215 + const struct dentry *parent,
60216 + const struct vfsmount *mnt)
60217 +{
60218 + struct name_entry *match;
60219 + struct acl_object_label *matchpo;
60220 + struct acl_subject_label *curracl;
60221 + char *path;
60222 +
60223 + if (unlikely(!(gr_status & GR_READY)))
60224 + return NULL;
60225 +
60226 + preempt_disable();
60227 + path = gr_to_filename_rbac(new_dentry, mnt);
60228 + match = lookup_name_entry_create(path);
60229 +
60230 + curracl = current->acl;
60231 +
60232 + if (match) {
60233 + read_lock(&gr_inode_lock);
60234 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60235 + read_unlock(&gr_inode_lock);
60236 +
60237 + if (matchpo) {
60238 + preempt_enable();
60239 + return matchpo;
60240 + }
60241 + }
60242 +
60243 + // lookup parent
60244 +
60245 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60246 +
60247 + preempt_enable();
60248 + return matchpo;
60249 +}
60250 +
60251 +__u32
60252 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60253 + const struct vfsmount * mnt, const __u32 mode)
60254 +{
60255 + struct acl_object_label *matchpo;
60256 + __u32 retval;
60257 +
60258 + if (unlikely(!(gr_status & GR_READY)))
60259 + return (mode & ~GR_AUDITS);
60260 +
60261 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60262 +
60263 + retval = matchpo->mode & mode;
60264 +
60265 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60266 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60267 + __u32 new_mode = mode;
60268 +
60269 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60270 +
60271 + gr_log_learn(new_dentry, mnt, new_mode);
60272 + return new_mode;
60273 + }
60274 +
60275 + return retval;
60276 +}
60277 +
60278 +__u32
60279 +gr_check_link(const struct dentry * new_dentry,
60280 + const struct dentry * parent_dentry,
60281 + const struct vfsmount * parent_mnt,
60282 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60283 +{
60284 + struct acl_object_label *obj;
60285 + __u32 oldmode, newmode;
60286 + __u32 needmode;
60287 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60288 + GR_DELETE | GR_INHERIT;
60289 +
60290 + if (unlikely(!(gr_status & GR_READY)))
60291 + return (GR_CREATE | GR_LINK);
60292 +
60293 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60294 + oldmode = obj->mode;
60295 +
60296 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60297 + newmode = obj->mode;
60298 +
60299 + needmode = newmode & checkmodes;
60300 +
60301 + // old name for hardlink must have at least the permissions of the new name
60302 + if ((oldmode & needmode) != needmode)
60303 + goto bad;
60304 +
60305 + // if old name had restrictions/auditing, make sure the new name does as well
60306 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60307 +
60308 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60309 + if (is_privileged_binary(old_dentry))
60310 + needmode |= GR_SETID;
60311 +
60312 + if ((newmode & needmode) != needmode)
60313 + goto bad;
60314 +
60315 + // enforce minimum permissions
60316 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60317 + return newmode;
60318 +bad:
60319 + needmode = oldmode;
60320 + if (is_privileged_binary(old_dentry))
60321 + needmode |= GR_SETID;
60322 +
60323 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60324 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60325 + return (GR_CREATE | GR_LINK);
60326 + } else if (newmode & GR_SUPPRESS)
60327 + return GR_SUPPRESS;
60328 + else
60329 + return 0;
60330 +}
60331 +
60332 +int
60333 +gr_check_hidden_task(const struct task_struct *task)
60334 +{
60335 + if (unlikely(!(gr_status & GR_READY)))
60336 + return 0;
60337 +
60338 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60339 + return 1;
60340 +
60341 + return 0;
60342 +}
60343 +
60344 +int
60345 +gr_check_protected_task(const struct task_struct *task)
60346 +{
60347 + if (unlikely(!(gr_status & GR_READY) || !task))
60348 + return 0;
60349 +
60350 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60351 + task->acl != current->acl)
60352 + return 1;
60353 +
60354 + return 0;
60355 +}
60356 +
60357 +int
60358 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60359 +{
60360 + struct task_struct *p;
60361 + int ret = 0;
60362 +
60363 + if (unlikely(!(gr_status & GR_READY) || !pid))
60364 + return ret;
60365 +
60366 + read_lock(&tasklist_lock);
60367 + do_each_pid_task(pid, type, p) {
60368 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60369 + p->acl != current->acl) {
60370 + ret = 1;
60371 + goto out;
60372 + }
60373 + } while_each_pid_task(pid, type, p);
60374 +out:
60375 + read_unlock(&tasklist_lock);
60376 +
60377 + return ret;
60378 +}
60379 +
60380 +void
60381 +gr_copy_label(struct task_struct *tsk)
60382 +{
60383 + tsk->signal->used_accept = 0;
60384 + tsk->acl_sp_role = 0;
60385 + tsk->acl_role_id = current->acl_role_id;
60386 + tsk->acl = current->acl;
60387 + tsk->role = current->role;
60388 + tsk->signal->curr_ip = current->signal->curr_ip;
60389 + tsk->signal->saved_ip = current->signal->saved_ip;
60390 + if (current->exec_file)
60391 + get_file(current->exec_file);
60392 + tsk->exec_file = current->exec_file;
60393 + tsk->is_writable = current->is_writable;
60394 + if (unlikely(current->signal->used_accept)) {
60395 + current->signal->curr_ip = 0;
60396 + current->signal->saved_ip = 0;
60397 + }
60398 +
60399 + return;
60400 +}
60401 +
60402 +static void
60403 +gr_set_proc_res(struct task_struct *task)
60404 +{
60405 + struct acl_subject_label *proc;
60406 + unsigned short i;
60407 +
60408 + proc = task->acl;
60409 +
60410 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60411 + return;
60412 +
60413 + for (i = 0; i < RLIM_NLIMITS; i++) {
60414 + if (!(proc->resmask & (1U << i)))
60415 + continue;
60416 +
60417 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60418 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60419 +
60420 + if (i == RLIMIT_CPU)
60421 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60422 + }
60423 +
60424 + return;
60425 +}
60426 +
60427 +extern int __gr_process_user_ban(struct user_struct *user);
60428 +
60429 +int
60430 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60431 +{
60432 + unsigned int i;
60433 + __u16 num;
60434 + uid_t *uidlist;
60435 + uid_t curuid;
60436 + int realok = 0;
60437 + int effectiveok = 0;
60438 + int fsok = 0;
60439 + uid_t globalreal, globaleffective, globalfs;
60440 +
60441 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60442 + struct user_struct *user;
60443 +
60444 + if (!uid_valid(real))
60445 + goto skipit;
60446 +
60447 + /* find user based on global namespace */
60448 +
60449 + globalreal = GR_GLOBAL_UID(real);
60450 +
60451 + user = find_user(make_kuid(&init_user_ns, globalreal));
60452 + if (user == NULL)
60453 + goto skipit;
60454 +
60455 + if (__gr_process_user_ban(user)) {
60456 + /* for find_user */
60457 + free_uid(user);
60458 + return 1;
60459 + }
60460 +
60461 + /* for find_user */
60462 + free_uid(user);
60463 +
60464 +skipit:
60465 +#endif
60466 +
60467 + if (unlikely(!(gr_status & GR_READY)))
60468 + return 0;
60469 +
60470 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60471 + gr_log_learn_uid_change(real, effective, fs);
60472 +
60473 + num = current->acl->user_trans_num;
60474 + uidlist = current->acl->user_transitions;
60475 +
60476 + if (uidlist == NULL)
60477 + return 0;
60478 +
60479 + if (!uid_valid(real)) {
60480 + realok = 1;
60481 + globalreal = (uid_t)-1;
60482 + } else {
60483 + globalreal = GR_GLOBAL_UID(real);
60484 + }
60485 + if (!uid_valid(effective)) {
60486 + effectiveok = 1;
60487 + globaleffective = (uid_t)-1;
60488 + } else {
60489 + globaleffective = GR_GLOBAL_UID(effective);
60490 + }
60491 + if (!uid_valid(fs)) {
60492 + fsok = 1;
60493 + globalfs = (uid_t)-1;
60494 + } else {
60495 + globalfs = GR_GLOBAL_UID(fs);
60496 + }
60497 +
60498 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60499 + for (i = 0; i < num; i++) {
60500 + curuid = uidlist[i];
60501 + if (globalreal == curuid)
60502 + realok = 1;
60503 + if (globaleffective == curuid)
60504 + effectiveok = 1;
60505 + if (globalfs == curuid)
60506 + fsok = 1;
60507 + }
60508 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60509 + for (i = 0; i < num; i++) {
60510 + curuid = uidlist[i];
60511 + if (globalreal == curuid)
60512 + break;
60513 + if (globaleffective == curuid)
60514 + break;
60515 + if (globalfs == curuid)
60516 + break;
60517 + }
60518 + /* not in deny list */
60519 + if (i == num) {
60520 + realok = 1;
60521 + effectiveok = 1;
60522 + fsok = 1;
60523 + }
60524 + }
60525 +
60526 + if (realok && effectiveok && fsok)
60527 + return 0;
60528 + else {
60529 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60530 + return 1;
60531 + }
60532 +}
60533 +
60534 +int
60535 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60536 +{
60537 + unsigned int i;
60538 + __u16 num;
60539 + gid_t *gidlist;
60540 + gid_t curgid;
60541 + int realok = 0;
60542 + int effectiveok = 0;
60543 + int fsok = 0;
60544 + gid_t globalreal, globaleffective, globalfs;
60545 +
60546 + if (unlikely(!(gr_status & GR_READY)))
60547 + return 0;
60548 +
60549 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60550 + gr_log_learn_gid_change(real, effective, fs);
60551 +
60552 + num = current->acl->group_trans_num;
60553 + gidlist = current->acl->group_transitions;
60554 +
60555 + if (gidlist == NULL)
60556 + return 0;
60557 +
60558 + if (!gid_valid(real)) {
60559 + realok = 1;
60560 + globalreal = (gid_t)-1;
60561 + } else {
60562 + globalreal = GR_GLOBAL_GID(real);
60563 + }
60564 + if (!gid_valid(effective)) {
60565 + effectiveok = 1;
60566 + globaleffective = (gid_t)-1;
60567 + } else {
60568 + globaleffective = GR_GLOBAL_GID(effective);
60569 + }
60570 + if (!gid_valid(fs)) {
60571 + fsok = 1;
60572 + globalfs = (gid_t)-1;
60573 + } else {
60574 + globalfs = GR_GLOBAL_GID(fs);
60575 + }
60576 +
60577 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60578 + for (i = 0; i < num; i++) {
60579 + curgid = gidlist[i];
60580 + if (globalreal == curgid)
60581 + realok = 1;
60582 + if (globaleffective == curgid)
60583 + effectiveok = 1;
60584 + if (globalfs == curgid)
60585 + fsok = 1;
60586 + }
60587 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60588 + for (i = 0; i < num; i++) {
60589 + curgid = gidlist[i];
60590 + if (globalreal == curgid)
60591 + break;
60592 + if (globaleffective == curgid)
60593 + break;
60594 + if (globalfs == curgid)
60595 + break;
60596 + }
60597 + /* not in deny list */
60598 + if (i == num) {
60599 + realok = 1;
60600 + effectiveok = 1;
60601 + fsok = 1;
60602 + }
60603 + }
60604 +
60605 + if (realok && effectiveok && fsok)
60606 + return 0;
60607 + else {
60608 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60609 + return 1;
60610 + }
60611 +}
60612 +
60613 +extern int gr_acl_is_capable(const int cap);
60614 +
60615 +void
60616 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60617 +{
60618 + struct acl_role_label *role = task->role;
60619 + struct acl_subject_label *subj = NULL;
60620 + struct acl_object_label *obj;
60621 + struct file *filp;
60622 + uid_t uid;
60623 + gid_t gid;
60624 +
60625 + if (unlikely(!(gr_status & GR_READY)))
60626 + return;
60627 +
60628 + uid = GR_GLOBAL_UID(kuid);
60629 + gid = GR_GLOBAL_GID(kgid);
60630 +
60631 + filp = task->exec_file;
60632 +
60633 + /* kernel process, we'll give them the kernel role */
60634 + if (unlikely(!filp)) {
60635 + task->role = kernel_role;
60636 + task->acl = kernel_role->root_label;
60637 + return;
60638 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60639 + role = lookup_acl_role_label(task, uid, gid);
60640 +
60641 + /* don't change the role if we're not a privileged process */
60642 + if (role && task->role != role &&
60643 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60644 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60645 + return;
60646 +
60647 + /* perform subject lookup in possibly new role
60648 + we can use this result below in the case where role == task->role
60649 + */
60650 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60651 +
60652 + /* if we changed uid/gid, but result in the same role
60653 + and are using inheritance, don't lose the inherited subject
60654 + if current subject is other than what normal lookup
60655 + would result in, we arrived via inheritance, don't
60656 + lose subject
60657 + */
60658 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60659 + (subj == task->acl)))
60660 + task->acl = subj;
60661 +
60662 + task->role = role;
60663 +
60664 + task->is_writable = 0;
60665 +
60666 + /* ignore additional mmap checks for processes that are writable
60667 + by the default ACL */
60668 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60669 + if (unlikely(obj->mode & GR_WRITE))
60670 + task->is_writable = 1;
60671 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60672 + if (unlikely(obj->mode & GR_WRITE))
60673 + task->is_writable = 1;
60674 +
60675 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60676 + 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);
60677 +#endif
60678 +
60679 + gr_set_proc_res(task);
60680 +
60681 + return;
60682 +}
60683 +
60684 +int
60685 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60686 + const int unsafe_flags)
60687 +{
60688 + struct task_struct *task = current;
60689 + struct acl_subject_label *newacl;
60690 + struct acl_object_label *obj;
60691 + __u32 retmode;
60692 +
60693 + if (unlikely(!(gr_status & GR_READY)))
60694 + return 0;
60695 +
60696 + newacl = chk_subj_label(dentry, mnt, task->role);
60697 +
60698 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60699 + did an exec
60700 + */
60701 + rcu_read_lock();
60702 + read_lock(&tasklist_lock);
60703 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60704 + (task->parent->acl->mode & GR_POVERRIDE))) {
60705 + read_unlock(&tasklist_lock);
60706 + rcu_read_unlock();
60707 + goto skip_check;
60708 + }
60709 + read_unlock(&tasklist_lock);
60710 + rcu_read_unlock();
60711 +
60712 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60713 + !(task->role->roletype & GR_ROLE_GOD) &&
60714 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60715 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60716 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60717 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60718 + else
60719 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60720 + return -EACCES;
60721 + }
60722 +
60723 +skip_check:
60724 +
60725 + obj = chk_obj_label(dentry, mnt, task->acl);
60726 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60727 +
60728 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60729 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60730 + if (obj->nested)
60731 + task->acl = obj->nested;
60732 + else
60733 + task->acl = newacl;
60734 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60735 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60736 +
60737 + task->is_writable = 0;
60738 +
60739 + /* ignore additional mmap checks for processes that are writable
60740 + by the default ACL */
60741 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60742 + if (unlikely(obj->mode & GR_WRITE))
60743 + task->is_writable = 1;
60744 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60745 + if (unlikely(obj->mode & GR_WRITE))
60746 + task->is_writable = 1;
60747 +
60748 + gr_set_proc_res(task);
60749 +
60750 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60751 + 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);
60752 +#endif
60753 + return 0;
60754 +}
60755 +
60756 +/* always called with valid inodev ptr */
60757 +static void
60758 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60759 +{
60760 + struct acl_object_label *matchpo;
60761 + struct acl_subject_label *matchps;
60762 + struct acl_subject_label *subj;
60763 + struct acl_role_label *role;
60764 + unsigned int x;
60765 +
60766 + FOR_EACH_ROLE_START(role)
60767 + FOR_EACH_SUBJECT_START(role, subj, x)
60768 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60769 + matchpo->mode |= GR_DELETED;
60770 + FOR_EACH_SUBJECT_END(subj,x)
60771 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60772 + /* nested subjects aren't in the role's subj_hash table */
60773 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60774 + matchpo->mode |= GR_DELETED;
60775 + FOR_EACH_NESTED_SUBJECT_END(subj)
60776 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60777 + matchps->mode |= GR_DELETED;
60778 + FOR_EACH_ROLE_END(role)
60779 +
60780 + inodev->nentry->deleted = 1;
60781 +
60782 + return;
60783 +}
60784 +
60785 +void
60786 +gr_handle_delete(const ino_t ino, const dev_t dev)
60787 +{
60788 + struct inodev_entry *inodev;
60789 +
60790 + if (unlikely(!(gr_status & GR_READY)))
60791 + return;
60792 +
60793 + write_lock(&gr_inode_lock);
60794 + inodev = lookup_inodev_entry(ino, dev);
60795 + if (inodev != NULL)
60796 + do_handle_delete(inodev, ino, dev);
60797 + write_unlock(&gr_inode_lock);
60798 +
60799 + return;
60800 +}
60801 +
60802 +static void
60803 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60804 + const ino_t newinode, const dev_t newdevice,
60805 + struct acl_subject_label *subj)
60806 +{
60807 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60808 + struct acl_object_label *match;
60809 +
60810 + match = subj->obj_hash[index];
60811 +
60812 + while (match && (match->inode != oldinode ||
60813 + match->device != olddevice ||
60814 + !(match->mode & GR_DELETED)))
60815 + match = match->next;
60816 +
60817 + if (match && (match->inode == oldinode)
60818 + && (match->device == olddevice)
60819 + && (match->mode & GR_DELETED)) {
60820 + if (match->prev == NULL) {
60821 + subj->obj_hash[index] = match->next;
60822 + if (match->next != NULL)
60823 + match->next->prev = NULL;
60824 + } else {
60825 + match->prev->next = match->next;
60826 + if (match->next != NULL)
60827 + match->next->prev = match->prev;
60828 + }
60829 + match->prev = NULL;
60830 + match->next = NULL;
60831 + match->inode = newinode;
60832 + match->device = newdevice;
60833 + match->mode &= ~GR_DELETED;
60834 +
60835 + insert_acl_obj_label(match, subj);
60836 + }
60837 +
60838 + return;
60839 +}
60840 +
60841 +static void
60842 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60843 + const ino_t newinode, const dev_t newdevice,
60844 + struct acl_role_label *role)
60845 +{
60846 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60847 + struct acl_subject_label *match;
60848 +
60849 + match = role->subj_hash[index];
60850 +
60851 + while (match && (match->inode != oldinode ||
60852 + match->device != olddevice ||
60853 + !(match->mode & GR_DELETED)))
60854 + match = match->next;
60855 +
60856 + if (match && (match->inode == oldinode)
60857 + && (match->device == olddevice)
60858 + && (match->mode & GR_DELETED)) {
60859 + if (match->prev == NULL) {
60860 + role->subj_hash[index] = match->next;
60861 + if (match->next != NULL)
60862 + match->next->prev = NULL;
60863 + } else {
60864 + match->prev->next = match->next;
60865 + if (match->next != NULL)
60866 + match->next->prev = match->prev;
60867 + }
60868 + match->prev = NULL;
60869 + match->next = NULL;
60870 + match->inode = newinode;
60871 + match->device = newdevice;
60872 + match->mode &= ~GR_DELETED;
60873 +
60874 + insert_acl_subj_label(match, role);
60875 + }
60876 +
60877 + return;
60878 +}
60879 +
60880 +static void
60881 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60882 + const ino_t newinode, const dev_t newdevice)
60883 +{
60884 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60885 + struct inodev_entry *match;
60886 +
60887 + match = inodev_set.i_hash[index];
60888 +
60889 + while (match && (match->nentry->inode != oldinode ||
60890 + match->nentry->device != olddevice || !match->nentry->deleted))
60891 + match = match->next;
60892 +
60893 + if (match && (match->nentry->inode == oldinode)
60894 + && (match->nentry->device == olddevice) &&
60895 + match->nentry->deleted) {
60896 + if (match->prev == NULL) {
60897 + inodev_set.i_hash[index] = match->next;
60898 + if (match->next != NULL)
60899 + match->next->prev = NULL;
60900 + } else {
60901 + match->prev->next = match->next;
60902 + if (match->next != NULL)
60903 + match->next->prev = match->prev;
60904 + }
60905 + match->prev = NULL;
60906 + match->next = NULL;
60907 + match->nentry->inode = newinode;
60908 + match->nentry->device = newdevice;
60909 + match->nentry->deleted = 0;
60910 +
60911 + insert_inodev_entry(match);
60912 + }
60913 +
60914 + return;
60915 +}
60916 +
60917 +static void
60918 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60919 +{
60920 + struct acl_subject_label *subj;
60921 + struct acl_role_label *role;
60922 + unsigned int x;
60923 +
60924 + FOR_EACH_ROLE_START(role)
60925 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60926 +
60927 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60928 + if ((subj->inode == ino) && (subj->device == dev)) {
60929 + subj->inode = ino;
60930 + subj->device = dev;
60931 + }
60932 + /* nested subjects aren't in the role's subj_hash table */
60933 + update_acl_obj_label(matchn->inode, matchn->device,
60934 + ino, dev, subj);
60935 + FOR_EACH_NESTED_SUBJECT_END(subj)
60936 + FOR_EACH_SUBJECT_START(role, subj, x)
60937 + update_acl_obj_label(matchn->inode, matchn->device,
60938 + ino, dev, subj);
60939 + FOR_EACH_SUBJECT_END(subj,x)
60940 + FOR_EACH_ROLE_END(role)
60941 +
60942 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60943 +
60944 + return;
60945 +}
60946 +
60947 +static void
60948 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60949 + const struct vfsmount *mnt)
60950 +{
60951 + ino_t ino = dentry->d_inode->i_ino;
60952 + dev_t dev = __get_dev(dentry);
60953 +
60954 + __do_handle_create(matchn, ino, dev);
60955 +
60956 + return;
60957 +}
60958 +
60959 +void
60960 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60961 +{
60962 + struct name_entry *matchn;
60963 +
60964 + if (unlikely(!(gr_status & GR_READY)))
60965 + return;
60966 +
60967 + preempt_disable();
60968 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60969 +
60970 + if (unlikely((unsigned long)matchn)) {
60971 + write_lock(&gr_inode_lock);
60972 + do_handle_create(matchn, dentry, mnt);
60973 + write_unlock(&gr_inode_lock);
60974 + }
60975 + preempt_enable();
60976 +
60977 + return;
60978 +}
60979 +
60980 +void
60981 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60982 +{
60983 + struct name_entry *matchn;
60984 +
60985 + if (unlikely(!(gr_status & GR_READY)))
60986 + return;
60987 +
60988 + preempt_disable();
60989 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60990 +
60991 + if (unlikely((unsigned long)matchn)) {
60992 + write_lock(&gr_inode_lock);
60993 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60994 + write_unlock(&gr_inode_lock);
60995 + }
60996 + preempt_enable();
60997 +
60998 + return;
60999 +}
61000 +
61001 +void
61002 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61003 + struct dentry *old_dentry,
61004 + struct dentry *new_dentry,
61005 + struct vfsmount *mnt, const __u8 replace)
61006 +{
61007 + struct name_entry *matchn;
61008 + struct inodev_entry *inodev;
61009 + struct inode *inode = new_dentry->d_inode;
61010 + ino_t old_ino = old_dentry->d_inode->i_ino;
61011 + dev_t old_dev = __get_dev(old_dentry);
61012 +
61013 + /* vfs_rename swaps the name and parent link for old_dentry and
61014 + new_dentry
61015 + at this point, old_dentry has the new name, parent link, and inode
61016 + for the renamed file
61017 + if a file is being replaced by a rename, new_dentry has the inode
61018 + and name for the replaced file
61019 + */
61020 +
61021 + if (unlikely(!(gr_status & GR_READY)))
61022 + return;
61023 +
61024 + preempt_disable();
61025 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61026 +
61027 + /* we wouldn't have to check d_inode if it weren't for
61028 + NFS silly-renaming
61029 + */
61030 +
61031 + write_lock(&gr_inode_lock);
61032 + if (unlikely(replace && inode)) {
61033 + ino_t new_ino = inode->i_ino;
61034 + dev_t new_dev = __get_dev(new_dentry);
61035 +
61036 + inodev = lookup_inodev_entry(new_ino, new_dev);
61037 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61038 + do_handle_delete(inodev, new_ino, new_dev);
61039 + }
61040 +
61041 + inodev = lookup_inodev_entry(old_ino, old_dev);
61042 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61043 + do_handle_delete(inodev, old_ino, old_dev);
61044 +
61045 + if (unlikely((unsigned long)matchn))
61046 + do_handle_create(matchn, old_dentry, mnt);
61047 +
61048 + write_unlock(&gr_inode_lock);
61049 + preempt_enable();
61050 +
61051 + return;
61052 +}
61053 +
61054 +static int
61055 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61056 + unsigned char **sum)
61057 +{
61058 + struct acl_role_label *r;
61059 + struct role_allowed_ip *ipp;
61060 + struct role_transition *trans;
61061 + unsigned int i;
61062 + int found = 0;
61063 + u32 curr_ip = current->signal->curr_ip;
61064 +
61065 + current->signal->saved_ip = curr_ip;
61066 +
61067 + /* check transition table */
61068 +
61069 + for (trans = current->role->transitions; trans; trans = trans->next) {
61070 + if (!strcmp(rolename, trans->rolename)) {
61071 + found = 1;
61072 + break;
61073 + }
61074 + }
61075 +
61076 + if (!found)
61077 + return 0;
61078 +
61079 + /* handle special roles that do not require authentication
61080 + and check ip */
61081 +
61082 + FOR_EACH_ROLE_START(r)
61083 + if (!strcmp(rolename, r->rolename) &&
61084 + (r->roletype & GR_ROLE_SPECIAL)) {
61085 + found = 0;
61086 + if (r->allowed_ips != NULL) {
61087 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61088 + if ((ntohl(curr_ip) & ipp->netmask) ==
61089 + (ntohl(ipp->addr) & ipp->netmask))
61090 + found = 1;
61091 + }
61092 + } else
61093 + found = 2;
61094 + if (!found)
61095 + return 0;
61096 +
61097 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61098 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61099 + *salt = NULL;
61100 + *sum = NULL;
61101 + return 1;
61102 + }
61103 + }
61104 + FOR_EACH_ROLE_END(r)
61105 +
61106 + for (i = 0; i < num_sprole_pws; i++) {
61107 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61108 + *salt = acl_special_roles[i]->salt;
61109 + *sum = acl_special_roles[i]->sum;
61110 + return 1;
61111 + }
61112 + }
61113 +
61114 + return 0;
61115 +}
61116 +
61117 +static void
61118 +assign_special_role(char *rolename)
61119 +{
61120 + struct acl_object_label *obj;
61121 + struct acl_role_label *r;
61122 + struct acl_role_label *assigned = NULL;
61123 + struct task_struct *tsk;
61124 + struct file *filp;
61125 +
61126 + FOR_EACH_ROLE_START(r)
61127 + if (!strcmp(rolename, r->rolename) &&
61128 + (r->roletype & GR_ROLE_SPECIAL)) {
61129 + assigned = r;
61130 + break;
61131 + }
61132 + FOR_EACH_ROLE_END(r)
61133 +
61134 + if (!assigned)
61135 + return;
61136 +
61137 + read_lock(&tasklist_lock);
61138 + read_lock(&grsec_exec_file_lock);
61139 +
61140 + tsk = current->real_parent;
61141 + if (tsk == NULL)
61142 + goto out_unlock;
61143 +
61144 + filp = tsk->exec_file;
61145 + if (filp == NULL)
61146 + goto out_unlock;
61147 +
61148 + tsk->is_writable = 0;
61149 +
61150 + tsk->acl_sp_role = 1;
61151 + tsk->acl_role_id = ++acl_sp_role_value;
61152 + tsk->role = assigned;
61153 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61154 +
61155 + /* ignore additional mmap checks for processes that are writable
61156 + by the default ACL */
61157 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61158 + if (unlikely(obj->mode & GR_WRITE))
61159 + tsk->is_writable = 1;
61160 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61161 + if (unlikely(obj->mode & GR_WRITE))
61162 + tsk->is_writable = 1;
61163 +
61164 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61165 + 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));
61166 +#endif
61167 +
61168 +out_unlock:
61169 + read_unlock(&grsec_exec_file_lock);
61170 + read_unlock(&tasklist_lock);
61171 + return;
61172 +}
61173 +
61174 +int gr_check_secure_terminal(struct task_struct *task)
61175 +{
61176 + struct task_struct *p, *p2, *p3;
61177 + struct files_struct *files;
61178 + struct fdtable *fdt;
61179 + struct file *our_file = NULL, *file;
61180 + int i;
61181 +
61182 + if (task->signal->tty == NULL)
61183 + return 1;
61184 +
61185 + files = get_files_struct(task);
61186 + if (files != NULL) {
61187 + rcu_read_lock();
61188 + fdt = files_fdtable(files);
61189 + for (i=0; i < fdt->max_fds; i++) {
61190 + file = fcheck_files(files, i);
61191 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61192 + get_file(file);
61193 + our_file = file;
61194 + }
61195 + }
61196 + rcu_read_unlock();
61197 + put_files_struct(files);
61198 + }
61199 +
61200 + if (our_file == NULL)
61201 + return 1;
61202 +
61203 + read_lock(&tasklist_lock);
61204 + do_each_thread(p2, p) {
61205 + files = get_files_struct(p);
61206 + if (files == NULL ||
61207 + (p->signal && p->signal->tty == task->signal->tty)) {
61208 + if (files != NULL)
61209 + put_files_struct(files);
61210 + continue;
61211 + }
61212 + rcu_read_lock();
61213 + fdt = files_fdtable(files);
61214 + for (i=0; i < fdt->max_fds; i++) {
61215 + file = fcheck_files(files, i);
61216 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61217 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61218 + p3 = task;
61219 + while (task_pid_nr(p3) > 0) {
61220 + if (p3 == p)
61221 + break;
61222 + p3 = p3->real_parent;
61223 + }
61224 + if (p3 == p)
61225 + break;
61226 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61227 + gr_handle_alertkill(p);
61228 + rcu_read_unlock();
61229 + put_files_struct(files);
61230 + read_unlock(&tasklist_lock);
61231 + fput(our_file);
61232 + return 0;
61233 + }
61234 + }
61235 + rcu_read_unlock();
61236 + put_files_struct(files);
61237 + } while_each_thread(p2, p);
61238 + read_unlock(&tasklist_lock);
61239 +
61240 + fput(our_file);
61241 + return 1;
61242 +}
61243 +
61244 +static int gr_rbac_disable(void *unused)
61245 +{
61246 + pax_open_kernel();
61247 + gr_status &= ~GR_READY;
61248 + pax_close_kernel();
61249 +
61250 + return 0;
61251 +}
61252 +
61253 +ssize_t
61254 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61255 +{
61256 + struct gr_arg_wrapper uwrap;
61257 + unsigned char *sprole_salt = NULL;
61258 + unsigned char *sprole_sum = NULL;
61259 + int error = sizeof (struct gr_arg_wrapper);
61260 + int error2 = 0;
61261 +
61262 + mutex_lock(&gr_dev_mutex);
61263 +
61264 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61265 + error = -EPERM;
61266 + goto out;
61267 + }
61268 +
61269 + if (count != sizeof (struct gr_arg_wrapper)) {
61270 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61271 + error = -EINVAL;
61272 + goto out;
61273 + }
61274 +
61275 +
61276 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61277 + gr_auth_expires = 0;
61278 + gr_auth_attempts = 0;
61279 + }
61280 +
61281 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61282 + error = -EFAULT;
61283 + goto out;
61284 + }
61285 +
61286 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61287 + error = -EINVAL;
61288 + goto out;
61289 + }
61290 +
61291 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61292 + error = -EFAULT;
61293 + goto out;
61294 + }
61295 +
61296 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61297 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61298 + time_after(gr_auth_expires, get_seconds())) {
61299 + error = -EBUSY;
61300 + goto out;
61301 + }
61302 +
61303 + /* if non-root trying to do anything other than use a special role,
61304 + do not attempt authentication, do not count towards authentication
61305 + locking
61306 + */
61307 +
61308 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61309 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61310 + gr_is_global_nonroot(current_uid())) {
61311 + error = -EPERM;
61312 + goto out;
61313 + }
61314 +
61315 + /* ensure pw and special role name are null terminated */
61316 +
61317 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61318 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61319 +
61320 + /* Okay.
61321 + * We have our enough of the argument structure..(we have yet
61322 + * to copy_from_user the tables themselves) . Copy the tables
61323 + * only if we need them, i.e. for loading operations. */
61324 +
61325 + switch (gr_usermode->mode) {
61326 + case GR_STATUS:
61327 + if (gr_status & GR_READY) {
61328 + error = 1;
61329 + if (!gr_check_secure_terminal(current))
61330 + error = 3;
61331 + } else
61332 + error = 2;
61333 + goto out;
61334 + case GR_SHUTDOWN:
61335 + if ((gr_status & GR_READY)
61336 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61337 + stop_machine(gr_rbac_disable, NULL, NULL);
61338 + free_variables();
61339 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61340 + memset(gr_system_salt, 0, GR_SALT_LEN);
61341 + memset(gr_system_sum, 0, GR_SHA_LEN);
61342 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61343 + } else if (gr_status & GR_READY) {
61344 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61345 + error = -EPERM;
61346 + } else {
61347 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61348 + error = -EAGAIN;
61349 + }
61350 + break;
61351 + case GR_ENABLE:
61352 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61353 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61354 + else {
61355 + if (gr_status & GR_READY)
61356 + error = -EAGAIN;
61357 + else
61358 + error = error2;
61359 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61360 + }
61361 + break;
61362 + case GR_RELOAD:
61363 + if (!(gr_status & GR_READY)) {
61364 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61365 + error = -EAGAIN;
61366 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61367 + stop_machine(gr_rbac_disable, NULL, NULL);
61368 + free_variables();
61369 + error2 = gracl_init(gr_usermode);
61370 + if (!error2)
61371 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61372 + else {
61373 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61374 + error = error2;
61375 + }
61376 + } else {
61377 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61378 + error = -EPERM;
61379 + }
61380 + break;
61381 + case GR_SEGVMOD:
61382 + if (unlikely(!(gr_status & GR_READY))) {
61383 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61384 + error = -EAGAIN;
61385 + break;
61386 + }
61387 +
61388 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61389 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61390 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61391 + struct acl_subject_label *segvacl;
61392 + segvacl =
61393 + lookup_acl_subj_label(gr_usermode->segv_inode,
61394 + gr_usermode->segv_device,
61395 + current->role);
61396 + if (segvacl) {
61397 + segvacl->crashes = 0;
61398 + segvacl->expires = 0;
61399 + }
61400 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61401 + gr_remove_uid(gr_usermode->segv_uid);
61402 + }
61403 + } else {
61404 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61405 + error = -EPERM;
61406 + }
61407 + break;
61408 + case GR_SPROLE:
61409 + case GR_SPROLEPAM:
61410 + if (unlikely(!(gr_status & GR_READY))) {
61411 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61412 + error = -EAGAIN;
61413 + break;
61414 + }
61415 +
61416 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61417 + current->role->expires = 0;
61418 + current->role->auth_attempts = 0;
61419 + }
61420 +
61421 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61422 + time_after(current->role->expires, get_seconds())) {
61423 + error = -EBUSY;
61424 + goto out;
61425 + }
61426 +
61427 + if (lookup_special_role_auth
61428 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61429 + && ((!sprole_salt && !sprole_sum)
61430 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61431 + char *p = "";
61432 + assign_special_role(gr_usermode->sp_role);
61433 + read_lock(&tasklist_lock);
61434 + if (current->real_parent)
61435 + p = current->real_parent->role->rolename;
61436 + read_unlock(&tasklist_lock);
61437 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61438 + p, acl_sp_role_value);
61439 + } else {
61440 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61441 + error = -EPERM;
61442 + if(!(current->role->auth_attempts++))
61443 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61444 +
61445 + goto out;
61446 + }
61447 + break;
61448 + case GR_UNSPROLE:
61449 + if (unlikely(!(gr_status & GR_READY))) {
61450 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61451 + error = -EAGAIN;
61452 + break;
61453 + }
61454 +
61455 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61456 + char *p = "";
61457 + int i = 0;
61458 +
61459 + read_lock(&tasklist_lock);
61460 + if (current->real_parent) {
61461 + p = current->real_parent->role->rolename;
61462 + i = current->real_parent->acl_role_id;
61463 + }
61464 + read_unlock(&tasklist_lock);
61465 +
61466 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61467 + gr_set_acls(1);
61468 + } else {
61469 + error = -EPERM;
61470 + goto out;
61471 + }
61472 + break;
61473 + default:
61474 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61475 + error = -EINVAL;
61476 + break;
61477 + }
61478 +
61479 + if (error != -EPERM)
61480 + goto out;
61481 +
61482 + if(!(gr_auth_attempts++))
61483 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61484 +
61485 + out:
61486 + mutex_unlock(&gr_dev_mutex);
61487 + return error;
61488 +}
61489 +
61490 +/* must be called with
61491 + rcu_read_lock();
61492 + read_lock(&tasklist_lock);
61493 + read_lock(&grsec_exec_file_lock);
61494 +*/
61495 +int gr_apply_subject_to_task(struct task_struct *task)
61496 +{
61497 + struct acl_object_label *obj;
61498 + char *tmpname;
61499 + struct acl_subject_label *tmpsubj;
61500 + struct file *filp;
61501 + struct name_entry *nmatch;
61502 +
61503 + filp = task->exec_file;
61504 + if (filp == NULL)
61505 + return 0;
61506 +
61507 + /* the following is to apply the correct subject
61508 + on binaries running when the RBAC system
61509 + is enabled, when the binaries have been
61510 + replaced or deleted since their execution
61511 + -----
61512 + when the RBAC system starts, the inode/dev
61513 + from exec_file will be one the RBAC system
61514 + is unaware of. It only knows the inode/dev
61515 + of the present file on disk, or the absence
61516 + of it.
61517 + */
61518 + preempt_disable();
61519 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61520 +
61521 + nmatch = lookup_name_entry(tmpname);
61522 + preempt_enable();
61523 + tmpsubj = NULL;
61524 + if (nmatch) {
61525 + if (nmatch->deleted)
61526 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61527 + else
61528 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61529 + if (tmpsubj != NULL)
61530 + task->acl = tmpsubj;
61531 + }
61532 + if (tmpsubj == NULL)
61533 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61534 + task->role);
61535 + if (task->acl) {
61536 + task->is_writable = 0;
61537 + /* ignore additional mmap checks for processes that are writable
61538 + by the default ACL */
61539 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61540 + if (unlikely(obj->mode & GR_WRITE))
61541 + task->is_writable = 1;
61542 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61543 + if (unlikely(obj->mode & GR_WRITE))
61544 + task->is_writable = 1;
61545 +
61546 + gr_set_proc_res(task);
61547 +
61548 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61549 + 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);
61550 +#endif
61551 + } else {
61552 + return 1;
61553 + }
61554 +
61555 + return 0;
61556 +}
61557 +
61558 +int
61559 +gr_set_acls(const int type)
61560 +{
61561 + struct task_struct *task, *task2;
61562 + struct acl_role_label *role = current->role;
61563 + __u16 acl_role_id = current->acl_role_id;
61564 + const struct cred *cred;
61565 + int ret;
61566 +
61567 + rcu_read_lock();
61568 + read_lock(&tasklist_lock);
61569 + read_lock(&grsec_exec_file_lock);
61570 + do_each_thread(task2, task) {
61571 + /* check to see if we're called from the exit handler,
61572 + if so, only replace ACLs that have inherited the admin
61573 + ACL */
61574 +
61575 + if (type && (task->role != role ||
61576 + task->acl_role_id != acl_role_id))
61577 + continue;
61578 +
61579 + task->acl_role_id = 0;
61580 + task->acl_sp_role = 0;
61581 +
61582 + if (task->exec_file) {
61583 + cred = __task_cred(task);
61584 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61585 + ret = gr_apply_subject_to_task(task);
61586 + if (ret) {
61587 + read_unlock(&grsec_exec_file_lock);
61588 + read_unlock(&tasklist_lock);
61589 + rcu_read_unlock();
61590 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61591 + return ret;
61592 + }
61593 + } else {
61594 + // it's a kernel process
61595 + task->role = kernel_role;
61596 + task->acl = kernel_role->root_label;
61597 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61598 + task->acl->mode &= ~GR_PROCFIND;
61599 +#endif
61600 + }
61601 + } while_each_thread(task2, task);
61602 + read_unlock(&grsec_exec_file_lock);
61603 + read_unlock(&tasklist_lock);
61604 + rcu_read_unlock();
61605 +
61606 + return 0;
61607 +}
61608 +
61609 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61610 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61611 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61612 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61613 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61614 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61615 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61616 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61617 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61618 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61619 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61620 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61621 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61622 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61623 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61624 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61625 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61626 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61627 +};
61628 +
61629 +void
61630 +gr_learn_resource(const struct task_struct *task,
61631 + const int res, const unsigned long wanted, const int gt)
61632 +{
61633 + struct acl_subject_label *acl;
61634 + const struct cred *cred;
61635 +
61636 + if (unlikely((gr_status & GR_READY) &&
61637 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61638 + goto skip_reslog;
61639 +
61640 + gr_log_resource(task, res, wanted, gt);
61641 +skip_reslog:
61642 +
61643 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61644 + return;
61645 +
61646 + acl = task->acl;
61647 +
61648 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61649 + !(acl->resmask & (1U << (unsigned short) res))))
61650 + return;
61651 +
61652 + if (wanted >= acl->res[res].rlim_cur) {
61653 + unsigned long res_add;
61654 +
61655 + res_add = wanted + res_learn_bumps[res];
61656 +
61657 + acl->res[res].rlim_cur = res_add;
61658 +
61659 + if (wanted > acl->res[res].rlim_max)
61660 + acl->res[res].rlim_max = res_add;
61661 +
61662 + /* only log the subject filename, since resource logging is supported for
61663 + single-subject learning only */
61664 + rcu_read_lock();
61665 + cred = __task_cred(task);
61666 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61667 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61668 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61669 + "", (unsigned long) res, &task->signal->saved_ip);
61670 + rcu_read_unlock();
61671 + }
61672 +
61673 + return;
61674 +}
61675 +EXPORT_SYMBOL(gr_learn_resource);
61676 +#endif
61677 +
61678 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61679 +void
61680 +pax_set_initial_flags(struct linux_binprm *bprm)
61681 +{
61682 + struct task_struct *task = current;
61683 + struct acl_subject_label *proc;
61684 + unsigned long flags;
61685 +
61686 + if (unlikely(!(gr_status & GR_READY)))
61687 + return;
61688 +
61689 + flags = pax_get_flags(task);
61690 +
61691 + proc = task->acl;
61692 +
61693 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61694 + flags &= ~MF_PAX_PAGEEXEC;
61695 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61696 + flags &= ~MF_PAX_SEGMEXEC;
61697 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61698 + flags &= ~MF_PAX_RANDMMAP;
61699 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61700 + flags &= ~MF_PAX_EMUTRAMP;
61701 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61702 + flags &= ~MF_PAX_MPROTECT;
61703 +
61704 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61705 + flags |= MF_PAX_PAGEEXEC;
61706 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61707 + flags |= MF_PAX_SEGMEXEC;
61708 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61709 + flags |= MF_PAX_RANDMMAP;
61710 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61711 + flags |= MF_PAX_EMUTRAMP;
61712 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61713 + flags |= MF_PAX_MPROTECT;
61714 +
61715 + pax_set_flags(task, flags);
61716 +
61717 + return;
61718 +}
61719 +#endif
61720 +
61721 +int
61722 +gr_handle_proc_ptrace(struct task_struct *task)
61723 +{
61724 + struct file *filp;
61725 + struct task_struct *tmp = task;
61726 + struct task_struct *curtemp = current;
61727 + __u32 retmode;
61728 +
61729 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61730 + if (unlikely(!(gr_status & GR_READY)))
61731 + return 0;
61732 +#endif
61733 +
61734 + read_lock(&tasklist_lock);
61735 + read_lock(&grsec_exec_file_lock);
61736 + filp = task->exec_file;
61737 +
61738 + while (task_pid_nr(tmp) > 0) {
61739 + if (tmp == curtemp)
61740 + break;
61741 + tmp = tmp->real_parent;
61742 + }
61743 +
61744 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61745 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61746 + read_unlock(&grsec_exec_file_lock);
61747 + read_unlock(&tasklist_lock);
61748 + return 1;
61749 + }
61750 +
61751 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61752 + if (!(gr_status & GR_READY)) {
61753 + read_unlock(&grsec_exec_file_lock);
61754 + read_unlock(&tasklist_lock);
61755 + return 0;
61756 + }
61757 +#endif
61758 +
61759 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61760 + read_unlock(&grsec_exec_file_lock);
61761 + read_unlock(&tasklist_lock);
61762 +
61763 + if (retmode & GR_NOPTRACE)
61764 + return 1;
61765 +
61766 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61767 + && (current->acl != task->acl || (current->acl != current->role->root_label
61768 + && task_pid_nr(current) != task_pid_nr(task))))
61769 + return 1;
61770 +
61771 + return 0;
61772 +}
61773 +
61774 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61775 +{
61776 + if (unlikely(!(gr_status & GR_READY)))
61777 + return;
61778 +
61779 + if (!(current->role->roletype & GR_ROLE_GOD))
61780 + return;
61781 +
61782 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61783 + p->role->rolename, gr_task_roletype_to_char(p),
61784 + p->acl->filename);
61785 +}
61786 +
61787 +int
61788 +gr_handle_ptrace(struct task_struct *task, const long request)
61789 +{
61790 + struct task_struct *tmp = task;
61791 + struct task_struct *curtemp = current;
61792 + __u32 retmode;
61793 +
61794 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61795 + if (unlikely(!(gr_status & GR_READY)))
61796 + return 0;
61797 +#endif
61798 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61799 + read_lock(&tasklist_lock);
61800 + while (task_pid_nr(tmp) > 0) {
61801 + if (tmp == curtemp)
61802 + break;
61803 + tmp = tmp->real_parent;
61804 + }
61805 +
61806 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61807 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61808 + read_unlock(&tasklist_lock);
61809 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61810 + return 1;
61811 + }
61812 + read_unlock(&tasklist_lock);
61813 + }
61814 +
61815 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61816 + if (!(gr_status & GR_READY))
61817 + return 0;
61818 +#endif
61819 +
61820 + read_lock(&grsec_exec_file_lock);
61821 + if (unlikely(!task->exec_file)) {
61822 + read_unlock(&grsec_exec_file_lock);
61823 + return 0;
61824 + }
61825 +
61826 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61827 + read_unlock(&grsec_exec_file_lock);
61828 +
61829 + if (retmode & GR_NOPTRACE) {
61830 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61831 + return 1;
61832 + }
61833 +
61834 + if (retmode & GR_PTRACERD) {
61835 + switch (request) {
61836 + case PTRACE_SEIZE:
61837 + case PTRACE_POKETEXT:
61838 + case PTRACE_POKEDATA:
61839 + case PTRACE_POKEUSR:
61840 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61841 + case PTRACE_SETREGS:
61842 + case PTRACE_SETFPREGS:
61843 +#endif
61844 +#ifdef CONFIG_X86
61845 + case PTRACE_SETFPXREGS:
61846 +#endif
61847 +#ifdef CONFIG_ALTIVEC
61848 + case PTRACE_SETVRREGS:
61849 +#endif
61850 + return 1;
61851 + default:
61852 + return 0;
61853 + }
61854 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61855 + !(current->role->roletype & GR_ROLE_GOD) &&
61856 + (current->acl != task->acl)) {
61857 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61858 + return 1;
61859 + }
61860 +
61861 + return 0;
61862 +}
61863 +
61864 +static int is_writable_mmap(const struct file *filp)
61865 +{
61866 + struct task_struct *task = current;
61867 + struct acl_object_label *obj, *obj2;
61868 +
61869 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61870 + !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))) {
61871 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61872 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61873 + task->role->root_label);
61874 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61875 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61876 + return 1;
61877 + }
61878 + }
61879 + return 0;
61880 +}
61881 +
61882 +int
61883 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61884 +{
61885 + __u32 mode;
61886 +
61887 + if (unlikely(!file || !(prot & PROT_EXEC)))
61888 + return 1;
61889 +
61890 + if (is_writable_mmap(file))
61891 + return 0;
61892 +
61893 + mode =
61894 + gr_search_file(file->f_path.dentry,
61895 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61896 + file->f_path.mnt);
61897 +
61898 + if (!gr_tpe_allow(file))
61899 + return 0;
61900 +
61901 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61902 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61903 + return 0;
61904 + } else if (unlikely(!(mode & GR_EXEC))) {
61905 + return 0;
61906 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61907 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61908 + return 1;
61909 + }
61910 +
61911 + return 1;
61912 +}
61913 +
61914 +int
61915 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61916 +{
61917 + __u32 mode;
61918 +
61919 + if (unlikely(!file || !(prot & PROT_EXEC)))
61920 + return 1;
61921 +
61922 + if (is_writable_mmap(file))
61923 + return 0;
61924 +
61925 + mode =
61926 + gr_search_file(file->f_path.dentry,
61927 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61928 + file->f_path.mnt);
61929 +
61930 + if (!gr_tpe_allow(file))
61931 + return 0;
61932 +
61933 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61934 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61935 + return 0;
61936 + } else if (unlikely(!(mode & GR_EXEC))) {
61937 + return 0;
61938 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61939 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61940 + return 1;
61941 + }
61942 +
61943 + return 1;
61944 +}
61945 +
61946 +void
61947 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61948 +{
61949 + unsigned long runtime;
61950 + unsigned long cputime;
61951 + unsigned int wday, cday;
61952 + __u8 whr, chr;
61953 + __u8 wmin, cmin;
61954 + __u8 wsec, csec;
61955 + struct timespec timeval;
61956 +
61957 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61958 + !(task->acl->mode & GR_PROCACCT)))
61959 + return;
61960 +
61961 + do_posix_clock_monotonic_gettime(&timeval);
61962 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61963 + wday = runtime / (3600 * 24);
61964 + runtime -= wday * (3600 * 24);
61965 + whr = runtime / 3600;
61966 + runtime -= whr * 3600;
61967 + wmin = runtime / 60;
61968 + runtime -= wmin * 60;
61969 + wsec = runtime;
61970 +
61971 + cputime = (task->utime + task->stime) / HZ;
61972 + cday = cputime / (3600 * 24);
61973 + cputime -= cday * (3600 * 24);
61974 + chr = cputime / 3600;
61975 + cputime -= chr * 3600;
61976 + cmin = cputime / 60;
61977 + cputime -= cmin * 60;
61978 + csec = cputime;
61979 +
61980 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61981 +
61982 + return;
61983 +}
61984 +
61985 +void gr_set_kernel_label(struct task_struct *task)
61986 +{
61987 + if (gr_status & GR_READY) {
61988 + task->role = kernel_role;
61989 + task->acl = kernel_role->root_label;
61990 + }
61991 + return;
61992 +}
61993 +
61994 +#ifdef CONFIG_TASKSTATS
61995 +int gr_is_taskstats_denied(int pid)
61996 +{
61997 + struct task_struct *task;
61998 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61999 + const struct cred *cred;
62000 +#endif
62001 + int ret = 0;
62002 +
62003 + /* restrict taskstats viewing to un-chrooted root users
62004 + who have the 'view' subject flag if the RBAC system is enabled
62005 + */
62006 +
62007 + rcu_read_lock();
62008 + read_lock(&tasklist_lock);
62009 + task = find_task_by_vpid(pid);
62010 + if (task) {
62011 +#ifdef CONFIG_GRKERNSEC_CHROOT
62012 + if (proc_is_chrooted(task))
62013 + ret = -EACCES;
62014 +#endif
62015 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62016 + cred = __task_cred(task);
62017 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62018 + if (gr_is_global_nonroot(cred->uid))
62019 + ret = -EACCES;
62020 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62021 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62022 + ret = -EACCES;
62023 +#endif
62024 +#endif
62025 + if (gr_status & GR_READY) {
62026 + if (!(task->acl->mode & GR_VIEW))
62027 + ret = -EACCES;
62028 + }
62029 + } else
62030 + ret = -ENOENT;
62031 +
62032 + read_unlock(&tasklist_lock);
62033 + rcu_read_unlock();
62034 +
62035 + return ret;
62036 +}
62037 +#endif
62038 +
62039 +/* AUXV entries are filled via a descendant of search_binary_handler
62040 + after we've already applied the subject for the target
62041 +*/
62042 +int gr_acl_enable_at_secure(void)
62043 +{
62044 + if (unlikely(!(gr_status & GR_READY)))
62045 + return 0;
62046 +
62047 + if (current->acl->mode & GR_ATSECURE)
62048 + return 1;
62049 +
62050 + return 0;
62051 +}
62052 +
62053 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62054 +{
62055 + struct task_struct *task = current;
62056 + struct dentry *dentry = file->f_path.dentry;
62057 + struct vfsmount *mnt = file->f_path.mnt;
62058 + struct acl_object_label *obj, *tmp;
62059 + struct acl_subject_label *subj;
62060 + unsigned int bufsize;
62061 + int is_not_root;
62062 + char *path;
62063 + dev_t dev = __get_dev(dentry);
62064 +
62065 + if (unlikely(!(gr_status & GR_READY)))
62066 + return 1;
62067 +
62068 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62069 + return 1;
62070 +
62071 + /* ignore Eric Biederman */
62072 + if (IS_PRIVATE(dentry->d_inode))
62073 + return 1;
62074 +
62075 + subj = task->acl;
62076 + read_lock(&gr_inode_lock);
62077 + do {
62078 + obj = lookup_acl_obj_label(ino, dev, subj);
62079 + if (obj != NULL) {
62080 + read_unlock(&gr_inode_lock);
62081 + return (obj->mode & GR_FIND) ? 1 : 0;
62082 + }
62083 + } while ((subj = subj->parent_subject));
62084 + read_unlock(&gr_inode_lock);
62085 +
62086 + /* this is purely an optimization since we're looking for an object
62087 + for the directory we're doing a readdir on
62088 + if it's possible for any globbed object to match the entry we're
62089 + filling into the directory, then the object we find here will be
62090 + an anchor point with attached globbed objects
62091 + */
62092 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62093 + if (obj->globbed == NULL)
62094 + return (obj->mode & GR_FIND) ? 1 : 0;
62095 +
62096 + is_not_root = ((obj->filename[0] == '/') &&
62097 + (obj->filename[1] == '\0')) ? 0 : 1;
62098 + bufsize = PAGE_SIZE - namelen - is_not_root;
62099 +
62100 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62101 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62102 + return 1;
62103 +
62104 + preempt_disable();
62105 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62106 + bufsize);
62107 +
62108 + bufsize = strlen(path);
62109 +
62110 + /* if base is "/", don't append an additional slash */
62111 + if (is_not_root)
62112 + *(path + bufsize) = '/';
62113 + memcpy(path + bufsize + is_not_root, name, namelen);
62114 + *(path + bufsize + namelen + is_not_root) = '\0';
62115 +
62116 + tmp = obj->globbed;
62117 + while (tmp) {
62118 + if (!glob_match(tmp->filename, path)) {
62119 + preempt_enable();
62120 + return (tmp->mode & GR_FIND) ? 1 : 0;
62121 + }
62122 + tmp = tmp->next;
62123 + }
62124 + preempt_enable();
62125 + return (obj->mode & GR_FIND) ? 1 : 0;
62126 +}
62127 +
62128 +void gr_put_exec_file(struct task_struct *task)
62129 +{
62130 + struct file *filp;
62131 +
62132 + write_lock(&grsec_exec_file_lock);
62133 + filp = task->exec_file;
62134 + task->exec_file = NULL;
62135 + write_unlock(&grsec_exec_file_lock);
62136 +
62137 + if (filp)
62138 + fput(filp);
62139 +
62140 + return;
62141 +}
62142 +
62143 +
62144 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62145 +EXPORT_SYMBOL(gr_acl_is_enabled);
62146 +#endif
62147 +EXPORT_SYMBOL(gr_set_kernel_label);
62148 +#ifdef CONFIG_SECURITY
62149 +EXPORT_SYMBOL(gr_check_user_change);
62150 +EXPORT_SYMBOL(gr_check_group_change);
62151 +#endif
62152 +
62153 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62154 new file mode 100644
62155 index 0000000..34fefda
62156 --- /dev/null
62157 +++ b/grsecurity/gracl_alloc.c
62158 @@ -0,0 +1,105 @@
62159 +#include <linux/kernel.h>
62160 +#include <linux/mm.h>
62161 +#include <linux/slab.h>
62162 +#include <linux/vmalloc.h>
62163 +#include <linux/gracl.h>
62164 +#include <linux/grsecurity.h>
62165 +
62166 +static unsigned long alloc_stack_next = 1;
62167 +static unsigned long alloc_stack_size = 1;
62168 +static void **alloc_stack;
62169 +
62170 +static __inline__ int
62171 +alloc_pop(void)
62172 +{
62173 + if (alloc_stack_next == 1)
62174 + return 0;
62175 +
62176 + kfree(alloc_stack[alloc_stack_next - 2]);
62177 +
62178 + alloc_stack_next--;
62179 +
62180 + return 1;
62181 +}
62182 +
62183 +static __inline__ int
62184 +alloc_push(void *buf)
62185 +{
62186 + if (alloc_stack_next >= alloc_stack_size)
62187 + return 1;
62188 +
62189 + alloc_stack[alloc_stack_next - 1] = buf;
62190 +
62191 + alloc_stack_next++;
62192 +
62193 + return 0;
62194 +}
62195 +
62196 +void *
62197 +acl_alloc(unsigned long len)
62198 +{
62199 + void *ret = NULL;
62200 +
62201 + if (!len || len > PAGE_SIZE)
62202 + goto out;
62203 +
62204 + ret = kmalloc(len, GFP_KERNEL);
62205 +
62206 + if (ret) {
62207 + if (alloc_push(ret)) {
62208 + kfree(ret);
62209 + ret = NULL;
62210 + }
62211 + }
62212 +
62213 +out:
62214 + return ret;
62215 +}
62216 +
62217 +void *
62218 +acl_alloc_num(unsigned long num, unsigned long len)
62219 +{
62220 + if (!len || (num > (PAGE_SIZE / len)))
62221 + return NULL;
62222 +
62223 + return acl_alloc(num * len);
62224 +}
62225 +
62226 +void
62227 +acl_free_all(void)
62228 +{
62229 + if (gr_acl_is_enabled() || !alloc_stack)
62230 + return;
62231 +
62232 + while (alloc_pop()) ;
62233 +
62234 + if (alloc_stack) {
62235 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62236 + kfree(alloc_stack);
62237 + else
62238 + vfree(alloc_stack);
62239 + }
62240 +
62241 + alloc_stack = NULL;
62242 + alloc_stack_size = 1;
62243 + alloc_stack_next = 1;
62244 +
62245 + return;
62246 +}
62247 +
62248 +int
62249 +acl_alloc_stack_init(unsigned long size)
62250 +{
62251 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62252 + alloc_stack =
62253 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62254 + else
62255 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62256 +
62257 + alloc_stack_size = size;
62258 +
62259 + if (!alloc_stack)
62260 + return 0;
62261 + else
62262 + return 1;
62263 +}
62264 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62265 new file mode 100644
62266 index 0000000..bdd51ea
62267 --- /dev/null
62268 +++ b/grsecurity/gracl_cap.c
62269 @@ -0,0 +1,110 @@
62270 +#include <linux/kernel.h>
62271 +#include <linux/module.h>
62272 +#include <linux/sched.h>
62273 +#include <linux/gracl.h>
62274 +#include <linux/grsecurity.h>
62275 +#include <linux/grinternal.h>
62276 +
62277 +extern const char *captab_log[];
62278 +extern int captab_log_entries;
62279 +
62280 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62281 +{
62282 + struct acl_subject_label *curracl;
62283 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62284 + kernel_cap_t cap_audit = __cap_empty_set;
62285 +
62286 + if (!gr_acl_is_enabled())
62287 + return 1;
62288 +
62289 + curracl = task->acl;
62290 +
62291 + cap_drop = curracl->cap_lower;
62292 + cap_mask = curracl->cap_mask;
62293 + cap_audit = curracl->cap_invert_audit;
62294 +
62295 + while ((curracl = curracl->parent_subject)) {
62296 + /* if the cap isn't specified in the current computed mask but is specified in the
62297 + current level subject, and is lowered in the current level subject, then add
62298 + it to the set of dropped capabilities
62299 + otherwise, add the current level subject's mask to the current computed mask
62300 + */
62301 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62302 + cap_raise(cap_mask, cap);
62303 + if (cap_raised(curracl->cap_lower, cap))
62304 + cap_raise(cap_drop, cap);
62305 + if (cap_raised(curracl->cap_invert_audit, cap))
62306 + cap_raise(cap_audit, cap);
62307 + }
62308 + }
62309 +
62310 + if (!cap_raised(cap_drop, cap)) {
62311 + if (cap_raised(cap_audit, cap))
62312 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62313 + return 1;
62314 + }
62315 +
62316 + curracl = task->acl;
62317 +
62318 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62319 + && cap_raised(cred->cap_effective, cap)) {
62320 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62321 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62322 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62323 + gr_to_filename(task->exec_file->f_path.dentry,
62324 + task->exec_file->f_path.mnt) : curracl->filename,
62325 + curracl->filename, 0UL,
62326 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62327 + return 1;
62328 + }
62329 +
62330 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62331 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62332 +
62333 + return 0;
62334 +}
62335 +
62336 +int
62337 +gr_acl_is_capable(const int cap)
62338 +{
62339 + return gr_task_acl_is_capable(current, current_cred(), cap);
62340 +}
62341 +
62342 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62343 +{
62344 + struct acl_subject_label *curracl;
62345 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62346 +
62347 + if (!gr_acl_is_enabled())
62348 + return 1;
62349 +
62350 + curracl = task->acl;
62351 +
62352 + cap_drop = curracl->cap_lower;
62353 + cap_mask = curracl->cap_mask;
62354 +
62355 + while ((curracl = curracl->parent_subject)) {
62356 + /* if the cap isn't specified in the current computed mask but is specified in the
62357 + current level subject, and is lowered in the current level subject, then add
62358 + it to the set of dropped capabilities
62359 + otherwise, add the current level subject's mask to the current computed mask
62360 + */
62361 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62362 + cap_raise(cap_mask, cap);
62363 + if (cap_raised(curracl->cap_lower, cap))
62364 + cap_raise(cap_drop, cap);
62365 + }
62366 + }
62367 +
62368 + if (!cap_raised(cap_drop, cap))
62369 + return 1;
62370 +
62371 + return 0;
62372 +}
62373 +
62374 +int
62375 +gr_acl_is_capable_nolog(const int cap)
62376 +{
62377 + return gr_task_acl_is_capable_nolog(current, cap);
62378 +}
62379 +
62380 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62381 new file mode 100644
62382 index 0000000..a340c17
62383 --- /dev/null
62384 +++ b/grsecurity/gracl_fs.c
62385 @@ -0,0 +1,431 @@
62386 +#include <linux/kernel.h>
62387 +#include <linux/sched.h>
62388 +#include <linux/types.h>
62389 +#include <linux/fs.h>
62390 +#include <linux/file.h>
62391 +#include <linux/stat.h>
62392 +#include <linux/grsecurity.h>
62393 +#include <linux/grinternal.h>
62394 +#include <linux/gracl.h>
62395 +
62396 +umode_t
62397 +gr_acl_umask(void)
62398 +{
62399 + if (unlikely(!gr_acl_is_enabled()))
62400 + return 0;
62401 +
62402 + return current->role->umask;
62403 +}
62404 +
62405 +__u32
62406 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62407 + const struct vfsmount * mnt)
62408 +{
62409 + __u32 mode;
62410 +
62411 + if (unlikely(!dentry->d_inode))
62412 + return GR_FIND;
62413 +
62414 + mode =
62415 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62416 +
62417 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62418 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62419 + return mode;
62420 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62421 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62422 + return 0;
62423 + } else if (unlikely(!(mode & GR_FIND)))
62424 + return 0;
62425 +
62426 + return GR_FIND;
62427 +}
62428 +
62429 +__u32
62430 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62431 + int acc_mode)
62432 +{
62433 + __u32 reqmode = GR_FIND;
62434 + __u32 mode;
62435 +
62436 + if (unlikely(!dentry->d_inode))
62437 + return reqmode;
62438 +
62439 + if (acc_mode & MAY_APPEND)
62440 + reqmode |= GR_APPEND;
62441 + else if (acc_mode & MAY_WRITE)
62442 + reqmode |= GR_WRITE;
62443 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62444 + reqmode |= GR_READ;
62445 +
62446 + mode =
62447 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62448 + mnt);
62449 +
62450 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62451 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62452 + reqmode & GR_READ ? " reading" : "",
62453 + reqmode & GR_WRITE ? " writing" : reqmode &
62454 + GR_APPEND ? " appending" : "");
62455 + return reqmode;
62456 + } else
62457 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62458 + {
62459 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62460 + reqmode & GR_READ ? " reading" : "",
62461 + reqmode & GR_WRITE ? " writing" : reqmode &
62462 + GR_APPEND ? " appending" : "");
62463 + return 0;
62464 + } else if (unlikely((mode & reqmode) != reqmode))
62465 + return 0;
62466 +
62467 + return reqmode;
62468 +}
62469 +
62470 +__u32
62471 +gr_acl_handle_creat(const struct dentry * dentry,
62472 + const struct dentry * p_dentry,
62473 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62474 + const int imode)
62475 +{
62476 + __u32 reqmode = GR_WRITE | GR_CREATE;
62477 + __u32 mode;
62478 +
62479 + if (acc_mode & MAY_APPEND)
62480 + reqmode |= GR_APPEND;
62481 + // if a directory was required or the directory already exists, then
62482 + // don't count this open as a read
62483 + if ((acc_mode & MAY_READ) &&
62484 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62485 + reqmode |= GR_READ;
62486 + if ((open_flags & O_CREAT) &&
62487 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62488 + reqmode |= GR_SETID;
62489 +
62490 + mode =
62491 + gr_check_create(dentry, p_dentry, p_mnt,
62492 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62493 +
62494 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62495 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62496 + reqmode & GR_READ ? " reading" : "",
62497 + reqmode & GR_WRITE ? " writing" : reqmode &
62498 + GR_APPEND ? " appending" : "");
62499 + return reqmode;
62500 + } else
62501 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62502 + {
62503 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62504 + reqmode & GR_READ ? " reading" : "",
62505 + reqmode & GR_WRITE ? " writing" : reqmode &
62506 + GR_APPEND ? " appending" : "");
62507 + return 0;
62508 + } else if (unlikely((mode & reqmode) != reqmode))
62509 + return 0;
62510 +
62511 + return reqmode;
62512 +}
62513 +
62514 +__u32
62515 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62516 + const int fmode)
62517 +{
62518 + __u32 mode, reqmode = GR_FIND;
62519 +
62520 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62521 + reqmode |= GR_EXEC;
62522 + if (fmode & S_IWOTH)
62523 + reqmode |= GR_WRITE;
62524 + if (fmode & S_IROTH)
62525 + reqmode |= GR_READ;
62526 +
62527 + mode =
62528 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62529 + mnt);
62530 +
62531 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62532 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62533 + reqmode & GR_READ ? " reading" : "",
62534 + reqmode & GR_WRITE ? " writing" : "",
62535 + reqmode & GR_EXEC ? " executing" : "");
62536 + return reqmode;
62537 + } else
62538 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62539 + {
62540 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62541 + reqmode & GR_READ ? " reading" : "",
62542 + reqmode & GR_WRITE ? " writing" : "",
62543 + reqmode & GR_EXEC ? " executing" : "");
62544 + return 0;
62545 + } else if (unlikely((mode & reqmode) != reqmode))
62546 + return 0;
62547 +
62548 + return reqmode;
62549 +}
62550 +
62551 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62552 +{
62553 + __u32 mode;
62554 +
62555 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62556 +
62557 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62558 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62559 + return mode;
62560 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62561 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62562 + return 0;
62563 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62564 + return 0;
62565 +
62566 + return (reqmode);
62567 +}
62568 +
62569 +__u32
62570 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62571 +{
62572 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62573 +}
62574 +
62575 +__u32
62576 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62577 +{
62578 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62579 +}
62580 +
62581 +__u32
62582 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62583 +{
62584 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62585 +}
62586 +
62587 +__u32
62588 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62589 +{
62590 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62591 +}
62592 +
62593 +__u32
62594 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62595 + umode_t *modeptr)
62596 +{
62597 + umode_t mode;
62598 +
62599 + *modeptr &= ~gr_acl_umask();
62600 + mode = *modeptr;
62601 +
62602 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62603 + return 1;
62604 +
62605 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62606 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62607 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62608 + GR_CHMOD_ACL_MSG);
62609 + } else {
62610 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62611 + }
62612 +}
62613 +
62614 +__u32
62615 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62616 +{
62617 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62618 +}
62619 +
62620 +__u32
62621 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62622 +{
62623 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62624 +}
62625 +
62626 +__u32
62627 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62628 +{
62629 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62630 +}
62631 +
62632 +__u32
62633 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62634 +{
62635 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62636 + GR_UNIXCONNECT_ACL_MSG);
62637 +}
62638 +
62639 +/* hardlinks require at minimum create and link permission,
62640 + any additional privilege required is based on the
62641 + privilege of the file being linked to
62642 +*/
62643 +__u32
62644 +gr_acl_handle_link(const struct dentry * new_dentry,
62645 + const struct dentry * parent_dentry,
62646 + const struct vfsmount * parent_mnt,
62647 + const struct dentry * old_dentry,
62648 + const struct vfsmount * old_mnt, const struct filename *to)
62649 +{
62650 + __u32 mode;
62651 + __u32 needmode = GR_CREATE | GR_LINK;
62652 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62653 +
62654 + mode =
62655 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62656 + old_mnt);
62657 +
62658 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62659 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62660 + return mode;
62661 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62662 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62663 + return 0;
62664 + } else if (unlikely((mode & needmode) != needmode))
62665 + return 0;
62666 +
62667 + return 1;
62668 +}
62669 +
62670 +__u32
62671 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62672 + const struct dentry * parent_dentry,
62673 + const struct vfsmount * parent_mnt, const struct filename *from)
62674 +{
62675 + __u32 needmode = GR_WRITE | GR_CREATE;
62676 + __u32 mode;
62677 +
62678 + mode =
62679 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62680 + GR_CREATE | GR_AUDIT_CREATE |
62681 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62682 +
62683 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62684 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62685 + return mode;
62686 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62687 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62688 + return 0;
62689 + } else if (unlikely((mode & needmode) != needmode))
62690 + return 0;
62691 +
62692 + return (GR_WRITE | GR_CREATE);
62693 +}
62694 +
62695 +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)
62696 +{
62697 + __u32 mode;
62698 +
62699 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62700 +
62701 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62702 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62703 + return mode;
62704 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62705 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62706 + return 0;
62707 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62708 + return 0;
62709 +
62710 + return (reqmode);
62711 +}
62712 +
62713 +__u32
62714 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62715 + const struct dentry * parent_dentry,
62716 + const struct vfsmount * parent_mnt,
62717 + const int mode)
62718 +{
62719 + __u32 reqmode = GR_WRITE | GR_CREATE;
62720 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62721 + reqmode |= GR_SETID;
62722 +
62723 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62724 + reqmode, GR_MKNOD_ACL_MSG);
62725 +}
62726 +
62727 +__u32
62728 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62729 + const struct dentry *parent_dentry,
62730 + const struct vfsmount *parent_mnt)
62731 +{
62732 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62733 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62734 +}
62735 +
62736 +#define RENAME_CHECK_SUCCESS(old, new) \
62737 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62738 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62739 +
62740 +int
62741 +gr_acl_handle_rename(struct dentry *new_dentry,
62742 + struct dentry *parent_dentry,
62743 + const struct vfsmount *parent_mnt,
62744 + struct dentry *old_dentry,
62745 + struct inode *old_parent_inode,
62746 + struct vfsmount *old_mnt, const struct filename *newname)
62747 +{
62748 + __u32 comp1, comp2;
62749 + int error = 0;
62750 +
62751 + if (unlikely(!gr_acl_is_enabled()))
62752 + return 0;
62753 +
62754 + if (!new_dentry->d_inode) {
62755 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62756 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62757 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62758 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62759 + GR_DELETE | GR_AUDIT_DELETE |
62760 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62761 + GR_SUPPRESS, old_mnt);
62762 + } else {
62763 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62764 + GR_CREATE | GR_DELETE |
62765 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62766 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62767 + GR_SUPPRESS, parent_mnt);
62768 + comp2 =
62769 + gr_search_file(old_dentry,
62770 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62771 + GR_DELETE | GR_AUDIT_DELETE |
62772 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62773 + }
62774 +
62775 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62776 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62777 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62778 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62779 + && !(comp2 & GR_SUPPRESS)) {
62780 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62781 + error = -EACCES;
62782 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62783 + error = -EACCES;
62784 +
62785 + return error;
62786 +}
62787 +
62788 +void
62789 +gr_acl_handle_exit(void)
62790 +{
62791 + u16 id;
62792 + char *rolename;
62793 +
62794 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62795 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62796 + id = current->acl_role_id;
62797 + rolename = current->role->rolename;
62798 + gr_set_acls(1);
62799 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62800 + }
62801 +
62802 + gr_put_exec_file(current);
62803 + return;
62804 +}
62805 +
62806 +int
62807 +gr_acl_handle_procpidmem(const struct task_struct *task)
62808 +{
62809 + if (unlikely(!gr_acl_is_enabled()))
62810 + return 0;
62811 +
62812 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62813 + return -EACCES;
62814 +
62815 + return 0;
62816 +}
62817 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62818 new file mode 100644
62819 index 0000000..8132048
62820 --- /dev/null
62821 +++ b/grsecurity/gracl_ip.c
62822 @@ -0,0 +1,387 @@
62823 +#include <linux/kernel.h>
62824 +#include <asm/uaccess.h>
62825 +#include <asm/errno.h>
62826 +#include <net/sock.h>
62827 +#include <linux/file.h>
62828 +#include <linux/fs.h>
62829 +#include <linux/net.h>
62830 +#include <linux/in.h>
62831 +#include <linux/skbuff.h>
62832 +#include <linux/ip.h>
62833 +#include <linux/udp.h>
62834 +#include <linux/types.h>
62835 +#include <linux/sched.h>
62836 +#include <linux/netdevice.h>
62837 +#include <linux/inetdevice.h>
62838 +#include <linux/gracl.h>
62839 +#include <linux/grsecurity.h>
62840 +#include <linux/grinternal.h>
62841 +
62842 +#define GR_BIND 0x01
62843 +#define GR_CONNECT 0x02
62844 +#define GR_INVERT 0x04
62845 +#define GR_BINDOVERRIDE 0x08
62846 +#define GR_CONNECTOVERRIDE 0x10
62847 +#define GR_SOCK_FAMILY 0x20
62848 +
62849 +static const char * gr_protocols[IPPROTO_MAX] = {
62850 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62851 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62852 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62853 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62854 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62855 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62856 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62857 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62858 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62859 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62860 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62861 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62862 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62863 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62864 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62865 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62866 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62867 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62868 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62869 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62870 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62871 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62872 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62873 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62874 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62875 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62876 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62877 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62878 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62879 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62880 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62881 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62882 + };
62883 +
62884 +static const char * gr_socktypes[SOCK_MAX] = {
62885 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62886 + "unknown:7", "unknown:8", "unknown:9", "packet"
62887 + };
62888 +
62889 +static const char * gr_sockfamilies[AF_MAX+1] = {
62890 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62891 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62892 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62893 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62894 + };
62895 +
62896 +const char *
62897 +gr_proto_to_name(unsigned char proto)
62898 +{
62899 + return gr_protocols[proto];
62900 +}
62901 +
62902 +const char *
62903 +gr_socktype_to_name(unsigned char type)
62904 +{
62905 + return gr_socktypes[type];
62906 +}
62907 +
62908 +const char *
62909 +gr_sockfamily_to_name(unsigned char family)
62910 +{
62911 + return gr_sockfamilies[family];
62912 +}
62913 +
62914 +int
62915 +gr_search_socket(const int domain, const int type, const int protocol)
62916 +{
62917 + struct acl_subject_label *curr;
62918 + const struct cred *cred = current_cred();
62919 +
62920 + if (unlikely(!gr_acl_is_enabled()))
62921 + goto exit;
62922 +
62923 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62924 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62925 + goto exit; // let the kernel handle it
62926 +
62927 + curr = current->acl;
62928 +
62929 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62930 + /* the family is allowed, if this is PF_INET allow it only if
62931 + the extra sock type/protocol checks pass */
62932 + if (domain == PF_INET)
62933 + goto inet_check;
62934 + goto exit;
62935 + } else {
62936 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62937 + __u32 fakeip = 0;
62938 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62939 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62940 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62941 + gr_to_filename(current->exec_file->f_path.dentry,
62942 + current->exec_file->f_path.mnt) :
62943 + curr->filename, curr->filename,
62944 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62945 + &current->signal->saved_ip);
62946 + goto exit;
62947 + }
62948 + goto exit_fail;
62949 + }
62950 +
62951 +inet_check:
62952 + /* the rest of this checking is for IPv4 only */
62953 + if (!curr->ips)
62954 + goto exit;
62955 +
62956 + if ((curr->ip_type & (1U << type)) &&
62957 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
62958 + goto exit;
62959 +
62960 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62961 + /* we don't place acls on raw sockets , and sometimes
62962 + dgram/ip sockets are opened for ioctl and not
62963 + bind/connect, so we'll fake a bind learn log */
62964 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62965 + __u32 fakeip = 0;
62966 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62967 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62968 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62969 + gr_to_filename(current->exec_file->f_path.dentry,
62970 + current->exec_file->f_path.mnt) :
62971 + curr->filename, curr->filename,
62972 + &fakeip, 0, type,
62973 + protocol, GR_CONNECT, &current->signal->saved_ip);
62974 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62975 + __u32 fakeip = 0;
62976 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62977 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62978 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62979 + gr_to_filename(current->exec_file->f_path.dentry,
62980 + current->exec_file->f_path.mnt) :
62981 + curr->filename, curr->filename,
62982 + &fakeip, 0, type,
62983 + protocol, GR_BIND, &current->signal->saved_ip);
62984 + }
62985 + /* we'll log when they use connect or bind */
62986 + goto exit;
62987 + }
62988 +
62989 +exit_fail:
62990 + if (domain == PF_INET)
62991 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62992 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62993 + else
62994 +#ifndef CONFIG_IPV6
62995 + if (domain != PF_INET6)
62996 +#endif
62997 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62998 + gr_socktype_to_name(type), protocol);
62999 +
63000 + return 0;
63001 +exit:
63002 + return 1;
63003 +}
63004 +
63005 +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)
63006 +{
63007 + if ((ip->mode & mode) &&
63008 + (ip_port >= ip->low) &&
63009 + (ip_port <= ip->high) &&
63010 + ((ntohl(ip_addr) & our_netmask) ==
63011 + (ntohl(our_addr) & our_netmask))
63012 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63013 + && (ip->type & (1U << type))) {
63014 + if (ip->mode & GR_INVERT)
63015 + return 2; // specifically denied
63016 + else
63017 + return 1; // allowed
63018 + }
63019 +
63020 + return 0; // not specifically allowed, may continue parsing
63021 +}
63022 +
63023 +static int
63024 +gr_search_connectbind(const int full_mode, struct sock *sk,
63025 + struct sockaddr_in *addr, const int type)
63026 +{
63027 + char iface[IFNAMSIZ] = {0};
63028 + struct acl_subject_label *curr;
63029 + struct acl_ip_label *ip;
63030 + struct inet_sock *isk;
63031 + struct net_device *dev;
63032 + struct in_device *idev;
63033 + unsigned long i;
63034 + int ret;
63035 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63036 + __u32 ip_addr = 0;
63037 + __u32 our_addr;
63038 + __u32 our_netmask;
63039 + char *p;
63040 + __u16 ip_port = 0;
63041 + const struct cred *cred = current_cred();
63042 +
63043 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63044 + return 0;
63045 +
63046 + curr = current->acl;
63047 + isk = inet_sk(sk);
63048 +
63049 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63050 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63051 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63052 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63053 + struct sockaddr_in saddr;
63054 + int err;
63055 +
63056 + saddr.sin_family = AF_INET;
63057 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63058 + saddr.sin_port = isk->inet_sport;
63059 +
63060 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63061 + if (err)
63062 + return err;
63063 +
63064 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63065 + if (err)
63066 + return err;
63067 + }
63068 +
63069 + if (!curr->ips)
63070 + return 0;
63071 +
63072 + ip_addr = addr->sin_addr.s_addr;
63073 + ip_port = ntohs(addr->sin_port);
63074 +
63075 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63076 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63077 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63078 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63079 + gr_to_filename(current->exec_file->f_path.dentry,
63080 + current->exec_file->f_path.mnt) :
63081 + curr->filename, curr->filename,
63082 + &ip_addr, ip_port, type,
63083 + sk->sk_protocol, mode, &current->signal->saved_ip);
63084 + return 0;
63085 + }
63086 +
63087 + for (i = 0; i < curr->ip_num; i++) {
63088 + ip = *(curr->ips + i);
63089 + if (ip->iface != NULL) {
63090 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63091 + p = strchr(iface, ':');
63092 + if (p != NULL)
63093 + *p = '\0';
63094 + dev = dev_get_by_name(sock_net(sk), iface);
63095 + if (dev == NULL)
63096 + continue;
63097 + idev = in_dev_get(dev);
63098 + if (idev == NULL) {
63099 + dev_put(dev);
63100 + continue;
63101 + }
63102 + rcu_read_lock();
63103 + for_ifa(idev) {
63104 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63105 + our_addr = ifa->ifa_address;
63106 + our_netmask = 0xffffffff;
63107 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63108 + if (ret == 1) {
63109 + rcu_read_unlock();
63110 + in_dev_put(idev);
63111 + dev_put(dev);
63112 + return 0;
63113 + } else if (ret == 2) {
63114 + rcu_read_unlock();
63115 + in_dev_put(idev);
63116 + dev_put(dev);
63117 + goto denied;
63118 + }
63119 + }
63120 + } endfor_ifa(idev);
63121 + rcu_read_unlock();
63122 + in_dev_put(idev);
63123 + dev_put(dev);
63124 + } else {
63125 + our_addr = ip->addr;
63126 + our_netmask = ip->netmask;
63127 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63128 + if (ret == 1)
63129 + return 0;
63130 + else if (ret == 2)
63131 + goto denied;
63132 + }
63133 + }
63134 +
63135 +denied:
63136 + if (mode == GR_BIND)
63137 + 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));
63138 + else if (mode == GR_CONNECT)
63139 + 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));
63140 +
63141 + return -EACCES;
63142 +}
63143 +
63144 +int
63145 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63146 +{
63147 + /* always allow disconnection of dgram sockets with connect */
63148 + if (addr->sin_family == AF_UNSPEC)
63149 + return 0;
63150 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63151 +}
63152 +
63153 +int
63154 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63155 +{
63156 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63157 +}
63158 +
63159 +int gr_search_listen(struct socket *sock)
63160 +{
63161 + struct sock *sk = sock->sk;
63162 + struct sockaddr_in addr;
63163 +
63164 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63165 + addr.sin_port = inet_sk(sk)->inet_sport;
63166 +
63167 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63168 +}
63169 +
63170 +int gr_search_accept(struct socket *sock)
63171 +{
63172 + struct sock *sk = sock->sk;
63173 + struct sockaddr_in addr;
63174 +
63175 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63176 + addr.sin_port = inet_sk(sk)->inet_sport;
63177 +
63178 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63179 +}
63180 +
63181 +int
63182 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63183 +{
63184 + if (addr)
63185 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63186 + else {
63187 + struct sockaddr_in sin;
63188 + const struct inet_sock *inet = inet_sk(sk);
63189 +
63190 + sin.sin_addr.s_addr = inet->inet_daddr;
63191 + sin.sin_port = inet->inet_dport;
63192 +
63193 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63194 + }
63195 +}
63196 +
63197 +int
63198 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63199 +{
63200 + struct sockaddr_in sin;
63201 +
63202 + if (unlikely(skb->len < sizeof (struct udphdr)))
63203 + return 0; // skip this packet
63204 +
63205 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63206 + sin.sin_port = udp_hdr(skb)->source;
63207 +
63208 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63209 +}
63210 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63211 new file mode 100644
63212 index 0000000..25f54ef
63213 --- /dev/null
63214 +++ b/grsecurity/gracl_learn.c
63215 @@ -0,0 +1,207 @@
63216 +#include <linux/kernel.h>
63217 +#include <linux/mm.h>
63218 +#include <linux/sched.h>
63219 +#include <linux/poll.h>
63220 +#include <linux/string.h>
63221 +#include <linux/file.h>
63222 +#include <linux/types.h>
63223 +#include <linux/vmalloc.h>
63224 +#include <linux/grinternal.h>
63225 +
63226 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63227 + size_t count, loff_t *ppos);
63228 +extern int gr_acl_is_enabled(void);
63229 +
63230 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63231 +static int gr_learn_attached;
63232 +
63233 +/* use a 512k buffer */
63234 +#define LEARN_BUFFER_SIZE (512 * 1024)
63235 +
63236 +static DEFINE_SPINLOCK(gr_learn_lock);
63237 +static DEFINE_MUTEX(gr_learn_user_mutex);
63238 +
63239 +/* we need to maintain two buffers, so that the kernel context of grlearn
63240 + uses a semaphore around the userspace copying, and the other kernel contexts
63241 + use a spinlock when copying into the buffer, since they cannot sleep
63242 +*/
63243 +static char *learn_buffer;
63244 +static char *learn_buffer_user;
63245 +static int learn_buffer_len;
63246 +static int learn_buffer_user_len;
63247 +
63248 +static ssize_t
63249 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63250 +{
63251 + DECLARE_WAITQUEUE(wait, current);
63252 + ssize_t retval = 0;
63253 +
63254 + add_wait_queue(&learn_wait, &wait);
63255 + set_current_state(TASK_INTERRUPTIBLE);
63256 + do {
63257 + mutex_lock(&gr_learn_user_mutex);
63258 + spin_lock(&gr_learn_lock);
63259 + if (learn_buffer_len)
63260 + break;
63261 + spin_unlock(&gr_learn_lock);
63262 + mutex_unlock(&gr_learn_user_mutex);
63263 + if (file->f_flags & O_NONBLOCK) {
63264 + retval = -EAGAIN;
63265 + goto out;
63266 + }
63267 + if (signal_pending(current)) {
63268 + retval = -ERESTARTSYS;
63269 + goto out;
63270 + }
63271 +
63272 + schedule();
63273 + } while (1);
63274 +
63275 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63276 + learn_buffer_user_len = learn_buffer_len;
63277 + retval = learn_buffer_len;
63278 + learn_buffer_len = 0;
63279 +
63280 + spin_unlock(&gr_learn_lock);
63281 +
63282 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63283 + retval = -EFAULT;
63284 +
63285 + mutex_unlock(&gr_learn_user_mutex);
63286 +out:
63287 + set_current_state(TASK_RUNNING);
63288 + remove_wait_queue(&learn_wait, &wait);
63289 + return retval;
63290 +}
63291 +
63292 +static unsigned int
63293 +poll_learn(struct file * file, poll_table * wait)
63294 +{
63295 + poll_wait(file, &learn_wait, wait);
63296 +
63297 + if (learn_buffer_len)
63298 + return (POLLIN | POLLRDNORM);
63299 +
63300 + return 0;
63301 +}
63302 +
63303 +void
63304 +gr_clear_learn_entries(void)
63305 +{
63306 + char *tmp;
63307 +
63308 + mutex_lock(&gr_learn_user_mutex);
63309 + spin_lock(&gr_learn_lock);
63310 + tmp = learn_buffer;
63311 + learn_buffer = NULL;
63312 + spin_unlock(&gr_learn_lock);
63313 + if (tmp)
63314 + vfree(tmp);
63315 + if (learn_buffer_user != NULL) {
63316 + vfree(learn_buffer_user);
63317 + learn_buffer_user = NULL;
63318 + }
63319 + learn_buffer_len = 0;
63320 + mutex_unlock(&gr_learn_user_mutex);
63321 +
63322 + return;
63323 +}
63324 +
63325 +void
63326 +gr_add_learn_entry(const char *fmt, ...)
63327 +{
63328 + va_list args;
63329 + unsigned int len;
63330 +
63331 + if (!gr_learn_attached)
63332 + return;
63333 +
63334 + spin_lock(&gr_learn_lock);
63335 +
63336 + /* leave a gap at the end so we know when it's "full" but don't have to
63337 + compute the exact length of the string we're trying to append
63338 + */
63339 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63340 + spin_unlock(&gr_learn_lock);
63341 + wake_up_interruptible(&learn_wait);
63342 + return;
63343 + }
63344 + if (learn_buffer == NULL) {
63345 + spin_unlock(&gr_learn_lock);
63346 + return;
63347 + }
63348 +
63349 + va_start(args, fmt);
63350 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63351 + va_end(args);
63352 +
63353 + learn_buffer_len += len + 1;
63354 +
63355 + spin_unlock(&gr_learn_lock);
63356 + wake_up_interruptible(&learn_wait);
63357 +
63358 + return;
63359 +}
63360 +
63361 +static int
63362 +open_learn(struct inode *inode, struct file *file)
63363 +{
63364 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63365 + return -EBUSY;
63366 + if (file->f_mode & FMODE_READ) {
63367 + int retval = 0;
63368 + mutex_lock(&gr_learn_user_mutex);
63369 + if (learn_buffer == NULL)
63370 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63371 + if (learn_buffer_user == NULL)
63372 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63373 + if (learn_buffer == NULL) {
63374 + retval = -ENOMEM;
63375 + goto out_error;
63376 + }
63377 + if (learn_buffer_user == NULL) {
63378 + retval = -ENOMEM;
63379 + goto out_error;
63380 + }
63381 + learn_buffer_len = 0;
63382 + learn_buffer_user_len = 0;
63383 + gr_learn_attached = 1;
63384 +out_error:
63385 + mutex_unlock(&gr_learn_user_mutex);
63386 + return retval;
63387 + }
63388 + return 0;
63389 +}
63390 +
63391 +static int
63392 +close_learn(struct inode *inode, struct file *file)
63393 +{
63394 + if (file->f_mode & FMODE_READ) {
63395 + char *tmp = NULL;
63396 + mutex_lock(&gr_learn_user_mutex);
63397 + spin_lock(&gr_learn_lock);
63398 + tmp = learn_buffer;
63399 + learn_buffer = NULL;
63400 + spin_unlock(&gr_learn_lock);
63401 + if (tmp)
63402 + vfree(tmp);
63403 + if (learn_buffer_user != NULL) {
63404 + vfree(learn_buffer_user);
63405 + learn_buffer_user = NULL;
63406 + }
63407 + learn_buffer_len = 0;
63408 + learn_buffer_user_len = 0;
63409 + gr_learn_attached = 0;
63410 + mutex_unlock(&gr_learn_user_mutex);
63411 + }
63412 +
63413 + return 0;
63414 +}
63415 +
63416 +const struct file_operations grsec_fops = {
63417 + .read = read_learn,
63418 + .write = write_grsec_handler,
63419 + .open = open_learn,
63420 + .release = close_learn,
63421 + .poll = poll_learn,
63422 +};
63423 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63424 new file mode 100644
63425 index 0000000..39645c9
63426 --- /dev/null
63427 +++ b/grsecurity/gracl_res.c
63428 @@ -0,0 +1,68 @@
63429 +#include <linux/kernel.h>
63430 +#include <linux/sched.h>
63431 +#include <linux/gracl.h>
63432 +#include <linux/grinternal.h>
63433 +
63434 +static const char *restab_log[] = {
63435 + [RLIMIT_CPU] = "RLIMIT_CPU",
63436 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63437 + [RLIMIT_DATA] = "RLIMIT_DATA",
63438 + [RLIMIT_STACK] = "RLIMIT_STACK",
63439 + [RLIMIT_CORE] = "RLIMIT_CORE",
63440 + [RLIMIT_RSS] = "RLIMIT_RSS",
63441 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63442 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63443 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63444 + [RLIMIT_AS] = "RLIMIT_AS",
63445 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63446 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63447 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63448 + [RLIMIT_NICE] = "RLIMIT_NICE",
63449 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63450 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63451 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63452 +};
63453 +
63454 +void
63455 +gr_log_resource(const struct task_struct *task,
63456 + const int res, const unsigned long wanted, const int gt)
63457 +{
63458 + const struct cred *cred;
63459 + unsigned long rlim;
63460 +
63461 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63462 + return;
63463 +
63464 + // not yet supported resource
63465 + if (unlikely(!restab_log[res]))
63466 + return;
63467 +
63468 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63469 + rlim = task_rlimit_max(task, res);
63470 + else
63471 + rlim = task_rlimit(task, res);
63472 +
63473 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63474 + return;
63475 +
63476 + rcu_read_lock();
63477 + cred = __task_cred(task);
63478 +
63479 + if (res == RLIMIT_NPROC &&
63480 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63481 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63482 + goto out_rcu_unlock;
63483 + else if (res == RLIMIT_MEMLOCK &&
63484 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63485 + goto out_rcu_unlock;
63486 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63487 + goto out_rcu_unlock;
63488 + rcu_read_unlock();
63489 +
63490 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63491 +
63492 + return;
63493 +out_rcu_unlock:
63494 + rcu_read_unlock();
63495 + return;
63496 +}
63497 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63498 new file mode 100644
63499 index 0000000..4dcc92a
63500 --- /dev/null
63501 +++ b/grsecurity/gracl_segv.c
63502 @@ -0,0 +1,305 @@
63503 +#include <linux/kernel.h>
63504 +#include <linux/mm.h>
63505 +#include <asm/uaccess.h>
63506 +#include <asm/errno.h>
63507 +#include <asm/mman.h>
63508 +#include <net/sock.h>
63509 +#include <linux/file.h>
63510 +#include <linux/fs.h>
63511 +#include <linux/net.h>
63512 +#include <linux/in.h>
63513 +#include <linux/slab.h>
63514 +#include <linux/types.h>
63515 +#include <linux/sched.h>
63516 +#include <linux/timer.h>
63517 +#include <linux/gracl.h>
63518 +#include <linux/grsecurity.h>
63519 +#include <linux/grinternal.h>
63520 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63521 +#include <linux/magic.h>
63522 +#include <linux/pagemap.h>
63523 +#include "../fs/btrfs/async-thread.h"
63524 +#include "../fs/btrfs/ctree.h"
63525 +#include "../fs/btrfs/btrfs_inode.h"
63526 +#endif
63527 +
63528 +static struct crash_uid *uid_set;
63529 +static unsigned short uid_used;
63530 +static DEFINE_SPINLOCK(gr_uid_lock);
63531 +extern rwlock_t gr_inode_lock;
63532 +extern struct acl_subject_label *
63533 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63534 + struct acl_role_label *role);
63535 +
63536 +static inline dev_t __get_dev(const struct dentry *dentry)
63537 +{
63538 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63539 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63540 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63541 + else
63542 +#endif
63543 + return dentry->d_sb->s_dev;
63544 +}
63545 +
63546 +int
63547 +gr_init_uidset(void)
63548 +{
63549 + uid_set =
63550 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63551 + uid_used = 0;
63552 +
63553 + return uid_set ? 1 : 0;
63554 +}
63555 +
63556 +void
63557 +gr_free_uidset(void)
63558 +{
63559 + if (uid_set)
63560 + kfree(uid_set);
63561 +
63562 + return;
63563 +}
63564 +
63565 +int
63566 +gr_find_uid(const uid_t uid)
63567 +{
63568 + struct crash_uid *tmp = uid_set;
63569 + uid_t buid;
63570 + int low = 0, high = uid_used - 1, mid;
63571 +
63572 + while (high >= low) {
63573 + mid = (low + high) >> 1;
63574 + buid = tmp[mid].uid;
63575 + if (buid == uid)
63576 + return mid;
63577 + if (buid > uid)
63578 + high = mid - 1;
63579 + if (buid < uid)
63580 + low = mid + 1;
63581 + }
63582 +
63583 + return -1;
63584 +}
63585 +
63586 +static __inline__ void
63587 +gr_insertsort(void)
63588 +{
63589 + unsigned short i, j;
63590 + struct crash_uid index;
63591 +
63592 + for (i = 1; i < uid_used; i++) {
63593 + index = uid_set[i];
63594 + j = i;
63595 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63596 + uid_set[j] = uid_set[j - 1];
63597 + j--;
63598 + }
63599 + uid_set[j] = index;
63600 + }
63601 +
63602 + return;
63603 +}
63604 +
63605 +static __inline__ void
63606 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63607 +{
63608 + int loc;
63609 + uid_t uid = GR_GLOBAL_UID(kuid);
63610 +
63611 + if (uid_used == GR_UIDTABLE_MAX)
63612 + return;
63613 +
63614 + loc = gr_find_uid(uid);
63615 +
63616 + if (loc >= 0) {
63617 + uid_set[loc].expires = expires;
63618 + return;
63619 + }
63620 +
63621 + uid_set[uid_used].uid = uid;
63622 + uid_set[uid_used].expires = expires;
63623 + uid_used++;
63624 +
63625 + gr_insertsort();
63626 +
63627 + return;
63628 +}
63629 +
63630 +void
63631 +gr_remove_uid(const unsigned short loc)
63632 +{
63633 + unsigned short i;
63634 +
63635 + for (i = loc + 1; i < uid_used; i++)
63636 + uid_set[i - 1] = uid_set[i];
63637 +
63638 + uid_used--;
63639 +
63640 + return;
63641 +}
63642 +
63643 +int
63644 +gr_check_crash_uid(const kuid_t kuid)
63645 +{
63646 + int loc;
63647 + int ret = 0;
63648 + uid_t uid;
63649 +
63650 + if (unlikely(!gr_acl_is_enabled()))
63651 + return 0;
63652 +
63653 + uid = GR_GLOBAL_UID(kuid);
63654 +
63655 + spin_lock(&gr_uid_lock);
63656 + loc = gr_find_uid(uid);
63657 +
63658 + if (loc < 0)
63659 + goto out_unlock;
63660 +
63661 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63662 + gr_remove_uid(loc);
63663 + else
63664 + ret = 1;
63665 +
63666 +out_unlock:
63667 + spin_unlock(&gr_uid_lock);
63668 + return ret;
63669 +}
63670 +
63671 +static __inline__ int
63672 +proc_is_setxid(const struct cred *cred)
63673 +{
63674 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63675 + !uid_eq(cred->uid, cred->fsuid))
63676 + return 1;
63677 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63678 + !gid_eq(cred->gid, cred->fsgid))
63679 + return 1;
63680 +
63681 + return 0;
63682 +}
63683 +
63684 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63685 +
63686 +void
63687 +gr_handle_crash(struct task_struct *task, const int sig)
63688 +{
63689 + struct acl_subject_label *curr;
63690 + struct task_struct *tsk, *tsk2;
63691 + const struct cred *cred;
63692 + const struct cred *cred2;
63693 +
63694 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63695 + return;
63696 +
63697 + if (unlikely(!gr_acl_is_enabled()))
63698 + return;
63699 +
63700 + curr = task->acl;
63701 +
63702 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63703 + return;
63704 +
63705 + if (time_before_eq(curr->expires, get_seconds())) {
63706 + curr->expires = 0;
63707 + curr->crashes = 0;
63708 + }
63709 +
63710 + curr->crashes++;
63711 +
63712 + if (!curr->expires)
63713 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63714 +
63715 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63716 + time_after(curr->expires, get_seconds())) {
63717 + rcu_read_lock();
63718 + cred = __task_cred(task);
63719 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63720 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63721 + spin_lock(&gr_uid_lock);
63722 + gr_insert_uid(cred->uid, curr->expires);
63723 + spin_unlock(&gr_uid_lock);
63724 + curr->expires = 0;
63725 + curr->crashes = 0;
63726 + read_lock(&tasklist_lock);
63727 + do_each_thread(tsk2, tsk) {
63728 + cred2 = __task_cred(tsk);
63729 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63730 + gr_fake_force_sig(SIGKILL, tsk);
63731 + } while_each_thread(tsk2, tsk);
63732 + read_unlock(&tasklist_lock);
63733 + } else {
63734 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63735 + read_lock(&tasklist_lock);
63736 + read_lock(&grsec_exec_file_lock);
63737 + do_each_thread(tsk2, tsk) {
63738 + if (likely(tsk != task)) {
63739 + // if this thread has the same subject as the one that triggered
63740 + // RES_CRASH and it's the same binary, kill it
63741 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63742 + gr_fake_force_sig(SIGKILL, tsk);
63743 + }
63744 + } while_each_thread(tsk2, tsk);
63745 + read_unlock(&grsec_exec_file_lock);
63746 + read_unlock(&tasklist_lock);
63747 + }
63748 + rcu_read_unlock();
63749 + }
63750 +
63751 + return;
63752 +}
63753 +
63754 +int
63755 +gr_check_crash_exec(const struct file *filp)
63756 +{
63757 + struct acl_subject_label *curr;
63758 +
63759 + if (unlikely(!gr_acl_is_enabled()))
63760 + return 0;
63761 +
63762 + read_lock(&gr_inode_lock);
63763 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63764 + __get_dev(filp->f_path.dentry),
63765 + current->role);
63766 + read_unlock(&gr_inode_lock);
63767 +
63768 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63769 + (!curr->crashes && !curr->expires))
63770 + return 0;
63771 +
63772 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63773 + time_after(curr->expires, get_seconds()))
63774 + return 1;
63775 + else if (time_before_eq(curr->expires, get_seconds())) {
63776 + curr->crashes = 0;
63777 + curr->expires = 0;
63778 + }
63779 +
63780 + return 0;
63781 +}
63782 +
63783 +void
63784 +gr_handle_alertkill(struct task_struct *task)
63785 +{
63786 + struct acl_subject_label *curracl;
63787 + __u32 curr_ip;
63788 + struct task_struct *p, *p2;
63789 +
63790 + if (unlikely(!gr_acl_is_enabled()))
63791 + return;
63792 +
63793 + curracl = task->acl;
63794 + curr_ip = task->signal->curr_ip;
63795 +
63796 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63797 + read_lock(&tasklist_lock);
63798 + do_each_thread(p2, p) {
63799 + if (p->signal->curr_ip == curr_ip)
63800 + gr_fake_force_sig(SIGKILL, p);
63801 + } while_each_thread(p2, p);
63802 + read_unlock(&tasklist_lock);
63803 + } else if (curracl->mode & GR_KILLPROC)
63804 + gr_fake_force_sig(SIGKILL, task);
63805 +
63806 + return;
63807 +}
63808 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63809 new file mode 100644
63810 index 0000000..98011b0
63811 --- /dev/null
63812 +++ b/grsecurity/gracl_shm.c
63813 @@ -0,0 +1,40 @@
63814 +#include <linux/kernel.h>
63815 +#include <linux/mm.h>
63816 +#include <linux/sched.h>
63817 +#include <linux/file.h>
63818 +#include <linux/ipc.h>
63819 +#include <linux/gracl.h>
63820 +#include <linux/grsecurity.h>
63821 +#include <linux/grinternal.h>
63822 +
63823 +int
63824 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63825 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63826 +{
63827 + struct task_struct *task;
63828 +
63829 + if (!gr_acl_is_enabled())
63830 + return 1;
63831 +
63832 + rcu_read_lock();
63833 + read_lock(&tasklist_lock);
63834 +
63835 + task = find_task_by_vpid(shm_cprid);
63836 +
63837 + if (unlikely(!task))
63838 + task = find_task_by_vpid(shm_lapid);
63839 +
63840 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63841 + (task_pid_nr(task) == shm_lapid)) &&
63842 + (task->acl->mode & GR_PROTSHM) &&
63843 + (task->acl != current->acl))) {
63844 + read_unlock(&tasklist_lock);
63845 + rcu_read_unlock();
63846 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63847 + return 0;
63848 + }
63849 + read_unlock(&tasklist_lock);
63850 + rcu_read_unlock();
63851 +
63852 + return 1;
63853 +}
63854 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63855 new file mode 100644
63856 index 0000000..bc0be01
63857 --- /dev/null
63858 +++ b/grsecurity/grsec_chdir.c
63859 @@ -0,0 +1,19 @@
63860 +#include <linux/kernel.h>
63861 +#include <linux/sched.h>
63862 +#include <linux/fs.h>
63863 +#include <linux/file.h>
63864 +#include <linux/grsecurity.h>
63865 +#include <linux/grinternal.h>
63866 +
63867 +void
63868 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63869 +{
63870 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63871 + if ((grsec_enable_chdir && grsec_enable_group &&
63872 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63873 + !grsec_enable_group)) {
63874 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63875 + }
63876 +#endif
63877 + return;
63878 +}
63879 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63880 new file mode 100644
63881 index 0000000..bd6e105
63882 --- /dev/null
63883 +++ b/grsecurity/grsec_chroot.c
63884 @@ -0,0 +1,370 @@
63885 +#include <linux/kernel.h>
63886 +#include <linux/module.h>
63887 +#include <linux/sched.h>
63888 +#include <linux/file.h>
63889 +#include <linux/fs.h>
63890 +#include <linux/mount.h>
63891 +#include <linux/types.h>
63892 +#include "../fs/mount.h"
63893 +#include <linux/grsecurity.h>
63894 +#include <linux/grinternal.h>
63895 +
63896 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63897 +static int gr_init_ran;
63898 +#endif
63899 +
63900 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
63901 +{
63902 +#ifdef CONFIG_GRKERNSEC
63903 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63904 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
63905 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63906 + && gr_init_ran
63907 +#endif
63908 + )
63909 + task->gr_is_chrooted = 1;
63910 + else {
63911 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63912 + if (task_pid_nr(task) == 1 && !gr_init_ran)
63913 + gr_init_ran = 1;
63914 +#endif
63915 + task->gr_is_chrooted = 0;
63916 + }
63917 +
63918 + task->gr_chroot_dentry = path->dentry;
63919 +#endif
63920 + return;
63921 +}
63922 +
63923 +void gr_clear_chroot_entries(struct task_struct *task)
63924 +{
63925 +#ifdef CONFIG_GRKERNSEC
63926 + task->gr_is_chrooted = 0;
63927 + task->gr_chroot_dentry = NULL;
63928 +#endif
63929 + return;
63930 +}
63931 +
63932 +int
63933 +gr_handle_chroot_unix(const pid_t pid)
63934 +{
63935 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63936 + struct task_struct *p;
63937 +
63938 + if (unlikely(!grsec_enable_chroot_unix))
63939 + return 1;
63940 +
63941 + if (likely(!proc_is_chrooted(current)))
63942 + return 1;
63943 +
63944 + rcu_read_lock();
63945 + read_lock(&tasklist_lock);
63946 + p = find_task_by_vpid_unrestricted(pid);
63947 + if (unlikely(p && !have_same_root(current, p))) {
63948 + read_unlock(&tasklist_lock);
63949 + rcu_read_unlock();
63950 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63951 + return 0;
63952 + }
63953 + read_unlock(&tasklist_lock);
63954 + rcu_read_unlock();
63955 +#endif
63956 + return 1;
63957 +}
63958 +
63959 +int
63960 +gr_handle_chroot_nice(void)
63961 +{
63962 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63963 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63964 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63965 + return -EPERM;
63966 + }
63967 +#endif
63968 + return 0;
63969 +}
63970 +
63971 +int
63972 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63973 +{
63974 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63975 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63976 + && proc_is_chrooted(current)) {
63977 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63978 + return -EACCES;
63979 + }
63980 +#endif
63981 + return 0;
63982 +}
63983 +
63984 +int
63985 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63986 +{
63987 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63988 + struct task_struct *p;
63989 + int ret = 0;
63990 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63991 + return ret;
63992 +
63993 + read_lock(&tasklist_lock);
63994 + do_each_pid_task(pid, type, p) {
63995 + if (!have_same_root(current, p)) {
63996 + ret = 1;
63997 + goto out;
63998 + }
63999 + } while_each_pid_task(pid, type, p);
64000 +out:
64001 + read_unlock(&tasklist_lock);
64002 + return ret;
64003 +#endif
64004 + return 0;
64005 +}
64006 +
64007 +int
64008 +gr_pid_is_chrooted(struct task_struct *p)
64009 +{
64010 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64011 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64012 + return 0;
64013 +
64014 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64015 + !have_same_root(current, p)) {
64016 + return 1;
64017 + }
64018 +#endif
64019 + return 0;
64020 +}
64021 +
64022 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64023 +
64024 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64025 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64026 +{
64027 + struct path path, currentroot;
64028 + int ret = 0;
64029 +
64030 + path.dentry = (struct dentry *)u_dentry;
64031 + path.mnt = (struct vfsmount *)u_mnt;
64032 + get_fs_root(current->fs, &currentroot);
64033 + if (path_is_under(&path, &currentroot))
64034 + ret = 1;
64035 + path_put(&currentroot);
64036 +
64037 + return ret;
64038 +}
64039 +#endif
64040 +
64041 +int
64042 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64043 +{
64044 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64045 + if (!grsec_enable_chroot_fchdir)
64046 + return 1;
64047 +
64048 + if (!proc_is_chrooted(current))
64049 + return 1;
64050 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64051 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64052 + return 0;
64053 + }
64054 +#endif
64055 + return 1;
64056 +}
64057 +
64058 +int
64059 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64060 + const time_t shm_createtime)
64061 +{
64062 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64063 + struct task_struct *p;
64064 + time_t starttime;
64065 +
64066 + if (unlikely(!grsec_enable_chroot_shmat))
64067 + return 1;
64068 +
64069 + if (likely(!proc_is_chrooted(current)))
64070 + return 1;
64071 +
64072 + rcu_read_lock();
64073 + read_lock(&tasklist_lock);
64074 +
64075 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64076 + starttime = p->start_time.tv_sec;
64077 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64078 + if (have_same_root(current, p)) {
64079 + goto allow;
64080 + } else {
64081 + read_unlock(&tasklist_lock);
64082 + rcu_read_unlock();
64083 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64084 + return 0;
64085 + }
64086 + }
64087 + /* creator exited, pid reuse, fall through to next check */
64088 + }
64089 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64090 + if (unlikely(!have_same_root(current, p))) {
64091 + read_unlock(&tasklist_lock);
64092 + rcu_read_unlock();
64093 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64094 + return 0;
64095 + }
64096 + }
64097 +
64098 +allow:
64099 + read_unlock(&tasklist_lock);
64100 + rcu_read_unlock();
64101 +#endif
64102 + return 1;
64103 +}
64104 +
64105 +void
64106 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64107 +{
64108 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64109 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64110 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64111 +#endif
64112 + return;
64113 +}
64114 +
64115 +int
64116 +gr_handle_chroot_mknod(const struct dentry *dentry,
64117 + const struct vfsmount *mnt, const int mode)
64118 +{
64119 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64120 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64121 + proc_is_chrooted(current)) {
64122 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64123 + return -EPERM;
64124 + }
64125 +#endif
64126 + return 0;
64127 +}
64128 +
64129 +int
64130 +gr_handle_chroot_mount(const struct dentry *dentry,
64131 + const struct vfsmount *mnt, const char *dev_name)
64132 +{
64133 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64134 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64135 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64136 + return -EPERM;
64137 + }
64138 +#endif
64139 + return 0;
64140 +}
64141 +
64142 +int
64143 +gr_handle_chroot_pivot(void)
64144 +{
64145 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64146 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64147 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64148 + return -EPERM;
64149 + }
64150 +#endif
64151 + return 0;
64152 +}
64153 +
64154 +int
64155 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64156 +{
64157 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64158 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64159 + !gr_is_outside_chroot(dentry, mnt)) {
64160 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64161 + return -EPERM;
64162 + }
64163 +#endif
64164 + return 0;
64165 +}
64166 +
64167 +extern const char *captab_log[];
64168 +extern int captab_log_entries;
64169 +
64170 +int
64171 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64172 +{
64173 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64174 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64175 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64176 + if (cap_raised(chroot_caps, cap)) {
64177 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64178 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64179 + }
64180 + return 0;
64181 + }
64182 + }
64183 +#endif
64184 + return 1;
64185 +}
64186 +
64187 +int
64188 +gr_chroot_is_capable(const int cap)
64189 +{
64190 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64191 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64192 +#endif
64193 + return 1;
64194 +}
64195 +
64196 +int
64197 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64198 +{
64199 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64200 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64201 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64202 + if (cap_raised(chroot_caps, cap)) {
64203 + return 0;
64204 + }
64205 + }
64206 +#endif
64207 + return 1;
64208 +}
64209 +
64210 +int
64211 +gr_chroot_is_capable_nolog(const int cap)
64212 +{
64213 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64214 + return gr_task_chroot_is_capable_nolog(current, cap);
64215 +#endif
64216 + return 1;
64217 +}
64218 +
64219 +int
64220 +gr_handle_chroot_sysctl(const int op)
64221 +{
64222 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64223 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64224 + proc_is_chrooted(current))
64225 + return -EACCES;
64226 +#endif
64227 + return 0;
64228 +}
64229 +
64230 +void
64231 +gr_handle_chroot_chdir(const struct path *path)
64232 +{
64233 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64234 + if (grsec_enable_chroot_chdir)
64235 + set_fs_pwd(current->fs, path);
64236 +#endif
64237 + return;
64238 +}
64239 +
64240 +int
64241 +gr_handle_chroot_chmod(const struct dentry *dentry,
64242 + const struct vfsmount *mnt, const int mode)
64243 +{
64244 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64245 + /* allow chmod +s on directories, but not files */
64246 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64247 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64248 + proc_is_chrooted(current)) {
64249 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64250 + return -EPERM;
64251 + }
64252 +#endif
64253 + return 0;
64254 +}
64255 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64256 new file mode 100644
64257 index 0000000..ce65ceb
64258 --- /dev/null
64259 +++ b/grsecurity/grsec_disabled.c
64260 @@ -0,0 +1,434 @@
64261 +#include <linux/kernel.h>
64262 +#include <linux/module.h>
64263 +#include <linux/sched.h>
64264 +#include <linux/file.h>
64265 +#include <linux/fs.h>
64266 +#include <linux/kdev_t.h>
64267 +#include <linux/net.h>
64268 +#include <linux/in.h>
64269 +#include <linux/ip.h>
64270 +#include <linux/skbuff.h>
64271 +#include <linux/sysctl.h>
64272 +
64273 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64274 +void
64275 +pax_set_initial_flags(struct linux_binprm *bprm)
64276 +{
64277 + return;
64278 +}
64279 +#endif
64280 +
64281 +#ifdef CONFIG_SYSCTL
64282 +__u32
64283 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64284 +{
64285 + return 0;
64286 +}
64287 +#endif
64288 +
64289 +#ifdef CONFIG_TASKSTATS
64290 +int gr_is_taskstats_denied(int pid)
64291 +{
64292 + return 0;
64293 +}
64294 +#endif
64295 +
64296 +int
64297 +gr_acl_is_enabled(void)
64298 +{
64299 + return 0;
64300 +}
64301 +
64302 +void
64303 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64304 +{
64305 + return;
64306 +}
64307 +
64308 +int
64309 +gr_handle_rawio(const struct inode *inode)
64310 +{
64311 + return 0;
64312 +}
64313 +
64314 +void
64315 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64316 +{
64317 + return;
64318 +}
64319 +
64320 +int
64321 +gr_handle_ptrace(struct task_struct *task, const long request)
64322 +{
64323 + return 0;
64324 +}
64325 +
64326 +int
64327 +gr_handle_proc_ptrace(struct task_struct *task)
64328 +{
64329 + return 0;
64330 +}
64331 +
64332 +int
64333 +gr_set_acls(const int type)
64334 +{
64335 + return 0;
64336 +}
64337 +
64338 +int
64339 +gr_check_hidden_task(const struct task_struct *tsk)
64340 +{
64341 + return 0;
64342 +}
64343 +
64344 +int
64345 +gr_check_protected_task(const struct task_struct *task)
64346 +{
64347 + return 0;
64348 +}
64349 +
64350 +int
64351 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64352 +{
64353 + return 0;
64354 +}
64355 +
64356 +void
64357 +gr_copy_label(struct task_struct *tsk)
64358 +{
64359 + return;
64360 +}
64361 +
64362 +void
64363 +gr_set_pax_flags(struct task_struct *task)
64364 +{
64365 + return;
64366 +}
64367 +
64368 +int
64369 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64370 + const int unsafe_share)
64371 +{
64372 + return 0;
64373 +}
64374 +
64375 +void
64376 +gr_handle_delete(const ino_t ino, const dev_t dev)
64377 +{
64378 + return;
64379 +}
64380 +
64381 +void
64382 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64383 +{
64384 + return;
64385 +}
64386 +
64387 +void
64388 +gr_handle_crash(struct task_struct *task, const int sig)
64389 +{
64390 + return;
64391 +}
64392 +
64393 +int
64394 +gr_check_crash_exec(const struct file *filp)
64395 +{
64396 + return 0;
64397 +}
64398 +
64399 +int
64400 +gr_check_crash_uid(const kuid_t uid)
64401 +{
64402 + return 0;
64403 +}
64404 +
64405 +void
64406 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64407 + struct dentry *old_dentry,
64408 + struct dentry *new_dentry,
64409 + struct vfsmount *mnt, const __u8 replace)
64410 +{
64411 + return;
64412 +}
64413 +
64414 +int
64415 +gr_search_socket(const int family, const int type, const int protocol)
64416 +{
64417 + return 1;
64418 +}
64419 +
64420 +int
64421 +gr_search_connectbind(const int mode, const struct socket *sock,
64422 + const struct sockaddr_in *addr)
64423 +{
64424 + return 0;
64425 +}
64426 +
64427 +void
64428 +gr_handle_alertkill(struct task_struct *task)
64429 +{
64430 + return;
64431 +}
64432 +
64433 +__u32
64434 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64435 +{
64436 + return 1;
64437 +}
64438 +
64439 +__u32
64440 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64441 + const struct vfsmount * mnt)
64442 +{
64443 + return 1;
64444 +}
64445 +
64446 +__u32
64447 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64448 + int acc_mode)
64449 +{
64450 + return 1;
64451 +}
64452 +
64453 +__u32
64454 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64455 +{
64456 + return 1;
64457 +}
64458 +
64459 +__u32
64460 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64461 +{
64462 + return 1;
64463 +}
64464 +
64465 +int
64466 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64467 + unsigned int *vm_flags)
64468 +{
64469 + return 1;
64470 +}
64471 +
64472 +__u32
64473 +gr_acl_handle_truncate(const struct dentry * dentry,
64474 + const struct vfsmount * mnt)
64475 +{
64476 + return 1;
64477 +}
64478 +
64479 +__u32
64480 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64481 +{
64482 + return 1;
64483 +}
64484 +
64485 +__u32
64486 +gr_acl_handle_access(const struct dentry * dentry,
64487 + const struct vfsmount * mnt, const int fmode)
64488 +{
64489 + return 1;
64490 +}
64491 +
64492 +__u32
64493 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64494 + umode_t *mode)
64495 +{
64496 + return 1;
64497 +}
64498 +
64499 +__u32
64500 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64501 +{
64502 + return 1;
64503 +}
64504 +
64505 +__u32
64506 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64507 +{
64508 + return 1;
64509 +}
64510 +
64511 +void
64512 +grsecurity_init(void)
64513 +{
64514 + return;
64515 +}
64516 +
64517 +umode_t gr_acl_umask(void)
64518 +{
64519 + return 0;
64520 +}
64521 +
64522 +__u32
64523 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64524 + const struct dentry * parent_dentry,
64525 + const struct vfsmount * parent_mnt,
64526 + const int mode)
64527 +{
64528 + return 1;
64529 +}
64530 +
64531 +__u32
64532 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64533 + const struct dentry * parent_dentry,
64534 + const struct vfsmount * parent_mnt)
64535 +{
64536 + return 1;
64537 +}
64538 +
64539 +__u32
64540 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64541 + const struct dentry * parent_dentry,
64542 + const struct vfsmount * parent_mnt, const struct filename *from)
64543 +{
64544 + return 1;
64545 +}
64546 +
64547 +__u32
64548 +gr_acl_handle_link(const struct dentry * new_dentry,
64549 + const struct dentry * parent_dentry,
64550 + const struct vfsmount * parent_mnt,
64551 + const struct dentry * old_dentry,
64552 + const struct vfsmount * old_mnt, const struct filename *to)
64553 +{
64554 + return 1;
64555 +}
64556 +
64557 +int
64558 +gr_acl_handle_rename(const struct dentry *new_dentry,
64559 + const struct dentry *parent_dentry,
64560 + const struct vfsmount *parent_mnt,
64561 + const struct dentry *old_dentry,
64562 + const struct inode *old_parent_inode,
64563 + const struct vfsmount *old_mnt, const struct filename *newname)
64564 +{
64565 + return 0;
64566 +}
64567 +
64568 +int
64569 +gr_acl_handle_filldir(const struct file *file, const char *name,
64570 + const int namelen, const ino_t ino)
64571 +{
64572 + return 1;
64573 +}
64574 +
64575 +int
64576 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64577 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64578 +{
64579 + return 1;
64580 +}
64581 +
64582 +int
64583 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64584 +{
64585 + return 0;
64586 +}
64587 +
64588 +int
64589 +gr_search_accept(const struct socket *sock)
64590 +{
64591 + return 0;
64592 +}
64593 +
64594 +int
64595 +gr_search_listen(const struct socket *sock)
64596 +{
64597 + return 0;
64598 +}
64599 +
64600 +int
64601 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64602 +{
64603 + return 0;
64604 +}
64605 +
64606 +__u32
64607 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64608 +{
64609 + return 1;
64610 +}
64611 +
64612 +__u32
64613 +gr_acl_handle_creat(const struct dentry * dentry,
64614 + const struct dentry * p_dentry,
64615 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64616 + const int imode)
64617 +{
64618 + return 1;
64619 +}
64620 +
64621 +void
64622 +gr_acl_handle_exit(void)
64623 +{
64624 + return;
64625 +}
64626 +
64627 +int
64628 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64629 +{
64630 + return 1;
64631 +}
64632 +
64633 +void
64634 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64635 +{
64636 + return;
64637 +}
64638 +
64639 +int
64640 +gr_acl_handle_procpidmem(const struct task_struct *task)
64641 +{
64642 + return 0;
64643 +}
64644 +
64645 +int
64646 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64647 +{
64648 + return 0;
64649 +}
64650 +
64651 +int
64652 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64653 +{
64654 + return 0;
64655 +}
64656 +
64657 +void
64658 +gr_set_kernel_label(struct task_struct *task)
64659 +{
64660 + return;
64661 +}
64662 +
64663 +int
64664 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64665 +{
64666 + return 0;
64667 +}
64668 +
64669 +int
64670 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64671 +{
64672 + return 0;
64673 +}
64674 +
64675 +int gr_acl_enable_at_secure(void)
64676 +{
64677 + return 0;
64678 +}
64679 +
64680 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64681 +{
64682 + return dentry->d_sb->s_dev;
64683 +}
64684 +
64685 +void gr_put_exec_file(struct task_struct *task)
64686 +{
64687 + return;
64688 +}
64689 +
64690 +EXPORT_SYMBOL(gr_set_kernel_label);
64691 +#ifdef CONFIG_SECURITY
64692 +EXPORT_SYMBOL(gr_check_user_change);
64693 +EXPORT_SYMBOL(gr_check_group_change);
64694 +#endif
64695 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64696 new file mode 100644
64697 index 0000000..387032b
64698 --- /dev/null
64699 +++ b/grsecurity/grsec_exec.c
64700 @@ -0,0 +1,187 @@
64701 +#include <linux/kernel.h>
64702 +#include <linux/sched.h>
64703 +#include <linux/file.h>
64704 +#include <linux/binfmts.h>
64705 +#include <linux/fs.h>
64706 +#include <linux/types.h>
64707 +#include <linux/grdefs.h>
64708 +#include <linux/grsecurity.h>
64709 +#include <linux/grinternal.h>
64710 +#include <linux/capability.h>
64711 +#include <linux/module.h>
64712 +#include <linux/compat.h>
64713 +
64714 +#include <asm/uaccess.h>
64715 +
64716 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64717 +static char gr_exec_arg_buf[132];
64718 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64719 +#endif
64720 +
64721 +struct user_arg_ptr {
64722 +#ifdef CONFIG_COMPAT
64723 + bool is_compat;
64724 +#endif
64725 + union {
64726 + const char __user *const __user *native;
64727 +#ifdef CONFIG_COMPAT
64728 + const compat_uptr_t __user *compat;
64729 +#endif
64730 + } ptr;
64731 +};
64732 +
64733 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64734 +
64735 +void
64736 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64737 +{
64738 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64739 + char *grarg = gr_exec_arg_buf;
64740 + unsigned int i, x, execlen = 0;
64741 + char c;
64742 +
64743 + if (!((grsec_enable_execlog && grsec_enable_group &&
64744 + in_group_p(grsec_audit_gid))
64745 + || (grsec_enable_execlog && !grsec_enable_group)))
64746 + return;
64747 +
64748 + mutex_lock(&gr_exec_arg_mutex);
64749 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64750 +
64751 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64752 + const char __user *p;
64753 + unsigned int len;
64754 +
64755 + p = get_user_arg_ptr(argv, i);
64756 + if (IS_ERR(p))
64757 + goto log;
64758 +
64759 + len = strnlen_user(p, 128 - execlen);
64760 + if (len > 128 - execlen)
64761 + len = 128 - execlen;
64762 + else if (len > 0)
64763 + len--;
64764 + if (copy_from_user(grarg + execlen, p, len))
64765 + goto log;
64766 +
64767 + /* rewrite unprintable characters */
64768 + for (x = 0; x < len; x++) {
64769 + c = *(grarg + execlen + x);
64770 + if (c < 32 || c > 126)
64771 + *(grarg + execlen + x) = ' ';
64772 + }
64773 +
64774 + execlen += len;
64775 + *(grarg + execlen) = ' ';
64776 + *(grarg + execlen + 1) = '\0';
64777 + execlen++;
64778 + }
64779 +
64780 + log:
64781 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64782 + bprm->file->f_path.mnt, grarg);
64783 + mutex_unlock(&gr_exec_arg_mutex);
64784 +#endif
64785 + return;
64786 +}
64787 +
64788 +#ifdef CONFIG_GRKERNSEC
64789 +extern int gr_acl_is_capable(const int cap);
64790 +extern int gr_acl_is_capable_nolog(const int cap);
64791 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64792 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64793 +extern int gr_chroot_is_capable(const int cap);
64794 +extern int gr_chroot_is_capable_nolog(const int cap);
64795 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64796 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64797 +#endif
64798 +
64799 +const char *captab_log[] = {
64800 + "CAP_CHOWN",
64801 + "CAP_DAC_OVERRIDE",
64802 + "CAP_DAC_READ_SEARCH",
64803 + "CAP_FOWNER",
64804 + "CAP_FSETID",
64805 + "CAP_KILL",
64806 + "CAP_SETGID",
64807 + "CAP_SETUID",
64808 + "CAP_SETPCAP",
64809 + "CAP_LINUX_IMMUTABLE",
64810 + "CAP_NET_BIND_SERVICE",
64811 + "CAP_NET_BROADCAST",
64812 + "CAP_NET_ADMIN",
64813 + "CAP_NET_RAW",
64814 + "CAP_IPC_LOCK",
64815 + "CAP_IPC_OWNER",
64816 + "CAP_SYS_MODULE",
64817 + "CAP_SYS_RAWIO",
64818 + "CAP_SYS_CHROOT",
64819 + "CAP_SYS_PTRACE",
64820 + "CAP_SYS_PACCT",
64821 + "CAP_SYS_ADMIN",
64822 + "CAP_SYS_BOOT",
64823 + "CAP_SYS_NICE",
64824 + "CAP_SYS_RESOURCE",
64825 + "CAP_SYS_TIME",
64826 + "CAP_SYS_TTY_CONFIG",
64827 + "CAP_MKNOD",
64828 + "CAP_LEASE",
64829 + "CAP_AUDIT_WRITE",
64830 + "CAP_AUDIT_CONTROL",
64831 + "CAP_SETFCAP",
64832 + "CAP_MAC_OVERRIDE",
64833 + "CAP_MAC_ADMIN",
64834 + "CAP_SYSLOG",
64835 + "CAP_WAKE_ALARM"
64836 +};
64837 +
64838 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64839 +
64840 +int gr_is_capable(const int cap)
64841 +{
64842 +#ifdef CONFIG_GRKERNSEC
64843 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64844 + return 1;
64845 + return 0;
64846 +#else
64847 + return 1;
64848 +#endif
64849 +}
64850 +
64851 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64852 +{
64853 +#ifdef CONFIG_GRKERNSEC
64854 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64855 + return 1;
64856 + return 0;
64857 +#else
64858 + return 1;
64859 +#endif
64860 +}
64861 +
64862 +int gr_is_capable_nolog(const int cap)
64863 +{
64864 +#ifdef CONFIG_GRKERNSEC
64865 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64866 + return 1;
64867 + return 0;
64868 +#else
64869 + return 1;
64870 +#endif
64871 +}
64872 +
64873 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64874 +{
64875 +#ifdef CONFIG_GRKERNSEC
64876 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64877 + return 1;
64878 + return 0;
64879 +#else
64880 + return 1;
64881 +#endif
64882 +}
64883 +
64884 +EXPORT_SYMBOL(gr_is_capable);
64885 +EXPORT_SYMBOL(gr_is_capable_nolog);
64886 +EXPORT_SYMBOL(gr_task_is_capable);
64887 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64888 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64889 new file mode 100644
64890 index 0000000..06cc6ea
64891 --- /dev/null
64892 +++ b/grsecurity/grsec_fifo.c
64893 @@ -0,0 +1,24 @@
64894 +#include <linux/kernel.h>
64895 +#include <linux/sched.h>
64896 +#include <linux/fs.h>
64897 +#include <linux/file.h>
64898 +#include <linux/grinternal.h>
64899 +
64900 +int
64901 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64902 + const struct dentry *dir, const int flag, const int acc_mode)
64903 +{
64904 +#ifdef CONFIG_GRKERNSEC_FIFO
64905 + const struct cred *cred = current_cred();
64906 +
64907 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64908 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64909 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64910 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64911 + if (!inode_permission(dentry->d_inode, acc_mode))
64912 + 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));
64913 + return -EACCES;
64914 + }
64915 +#endif
64916 + return 0;
64917 +}
64918 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64919 new file mode 100644
64920 index 0000000..8ca18bf
64921 --- /dev/null
64922 +++ b/grsecurity/grsec_fork.c
64923 @@ -0,0 +1,23 @@
64924 +#include <linux/kernel.h>
64925 +#include <linux/sched.h>
64926 +#include <linux/grsecurity.h>
64927 +#include <linux/grinternal.h>
64928 +#include <linux/errno.h>
64929 +
64930 +void
64931 +gr_log_forkfail(const int retval)
64932 +{
64933 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64934 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64935 + switch (retval) {
64936 + case -EAGAIN:
64937 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64938 + break;
64939 + case -ENOMEM:
64940 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64941 + break;
64942 + }
64943 + }
64944 +#endif
64945 + return;
64946 +}
64947 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64948 new file mode 100644
64949 index 0000000..a862e9f
64950 --- /dev/null
64951 +++ b/grsecurity/grsec_init.c
64952 @@ -0,0 +1,283 @@
64953 +#include <linux/kernel.h>
64954 +#include <linux/sched.h>
64955 +#include <linux/mm.h>
64956 +#include <linux/gracl.h>
64957 +#include <linux/slab.h>
64958 +#include <linux/vmalloc.h>
64959 +#include <linux/percpu.h>
64960 +#include <linux/module.h>
64961 +
64962 +int grsec_enable_ptrace_readexec;
64963 +int grsec_enable_setxid;
64964 +int grsec_enable_symlinkown;
64965 +kgid_t grsec_symlinkown_gid;
64966 +int grsec_enable_brute;
64967 +int grsec_enable_link;
64968 +int grsec_enable_dmesg;
64969 +int grsec_enable_harden_ptrace;
64970 +int grsec_enable_fifo;
64971 +int grsec_enable_execlog;
64972 +int grsec_enable_signal;
64973 +int grsec_enable_forkfail;
64974 +int grsec_enable_audit_ptrace;
64975 +int grsec_enable_time;
64976 +int grsec_enable_audit_textrel;
64977 +int grsec_enable_group;
64978 +kgid_t grsec_audit_gid;
64979 +int grsec_enable_chdir;
64980 +int grsec_enable_mount;
64981 +int grsec_enable_rofs;
64982 +int grsec_enable_chroot_findtask;
64983 +int grsec_enable_chroot_mount;
64984 +int grsec_enable_chroot_shmat;
64985 +int grsec_enable_chroot_fchdir;
64986 +int grsec_enable_chroot_double;
64987 +int grsec_enable_chroot_pivot;
64988 +int grsec_enable_chroot_chdir;
64989 +int grsec_enable_chroot_chmod;
64990 +int grsec_enable_chroot_mknod;
64991 +int grsec_enable_chroot_nice;
64992 +int grsec_enable_chroot_execlog;
64993 +int grsec_enable_chroot_caps;
64994 +int grsec_enable_chroot_sysctl;
64995 +int grsec_enable_chroot_unix;
64996 +int grsec_enable_tpe;
64997 +kgid_t grsec_tpe_gid;
64998 +int grsec_enable_blackhole;
64999 +#ifdef CONFIG_IPV6_MODULE
65000 +EXPORT_SYMBOL(grsec_enable_blackhole);
65001 +#endif
65002 +int grsec_lastack_retries;
65003 +int grsec_enable_tpe_all;
65004 +int grsec_enable_tpe_invert;
65005 +int grsec_enable_socket_all;
65006 +kgid_t grsec_socket_all_gid;
65007 +int grsec_enable_socket_client;
65008 +kgid_t grsec_socket_client_gid;
65009 +int grsec_enable_socket_server;
65010 +kgid_t grsec_socket_server_gid;
65011 +int grsec_resource_logging;
65012 +int grsec_disable_privio;
65013 +int grsec_enable_log_rwxmaps;
65014 +int grsec_lock;
65015 +
65016 +DEFINE_SPINLOCK(grsec_alert_lock);
65017 +unsigned long grsec_alert_wtime = 0;
65018 +unsigned long grsec_alert_fyet = 0;
65019 +
65020 +DEFINE_SPINLOCK(grsec_audit_lock);
65021 +
65022 +DEFINE_RWLOCK(grsec_exec_file_lock);
65023 +
65024 +char *gr_shared_page[4];
65025 +
65026 +char *gr_alert_log_fmt;
65027 +char *gr_audit_log_fmt;
65028 +char *gr_alert_log_buf;
65029 +char *gr_audit_log_buf;
65030 +
65031 +extern struct gr_arg *gr_usermode;
65032 +extern unsigned char *gr_system_salt;
65033 +extern unsigned char *gr_system_sum;
65034 +
65035 +void __init
65036 +grsecurity_init(void)
65037 +{
65038 + int j;
65039 + /* create the per-cpu shared pages */
65040 +
65041 +#ifdef CONFIG_X86
65042 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65043 +#endif
65044 +
65045 + for (j = 0; j < 4; j++) {
65046 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65047 + if (gr_shared_page[j] == NULL) {
65048 + panic("Unable to allocate grsecurity shared page");
65049 + return;
65050 + }
65051 + }
65052 +
65053 + /* allocate log buffers */
65054 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65055 + if (!gr_alert_log_fmt) {
65056 + panic("Unable to allocate grsecurity alert log format buffer");
65057 + return;
65058 + }
65059 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65060 + if (!gr_audit_log_fmt) {
65061 + panic("Unable to allocate grsecurity audit log format buffer");
65062 + return;
65063 + }
65064 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65065 + if (!gr_alert_log_buf) {
65066 + panic("Unable to allocate grsecurity alert log buffer");
65067 + return;
65068 + }
65069 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65070 + if (!gr_audit_log_buf) {
65071 + panic("Unable to allocate grsecurity audit log buffer");
65072 + return;
65073 + }
65074 +
65075 + /* allocate memory for authentication structure */
65076 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65077 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65078 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65079 +
65080 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65081 + panic("Unable to allocate grsecurity authentication structure");
65082 + return;
65083 + }
65084 +
65085 +
65086 +#ifdef CONFIG_GRKERNSEC_IO
65087 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65088 + grsec_disable_privio = 1;
65089 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65090 + grsec_disable_privio = 1;
65091 +#else
65092 + grsec_disable_privio = 0;
65093 +#endif
65094 +#endif
65095 +
65096 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65097 + /* for backward compatibility, tpe_invert always defaults to on if
65098 + enabled in the kernel
65099 + */
65100 + grsec_enable_tpe_invert = 1;
65101 +#endif
65102 +
65103 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65104 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65105 + grsec_lock = 1;
65106 +#endif
65107 +
65108 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65109 + grsec_enable_audit_textrel = 1;
65110 +#endif
65111 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65112 + grsec_enable_log_rwxmaps = 1;
65113 +#endif
65114 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65115 + grsec_enable_group = 1;
65116 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65117 +#endif
65118 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65119 + grsec_enable_ptrace_readexec = 1;
65120 +#endif
65121 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65122 + grsec_enable_chdir = 1;
65123 +#endif
65124 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65125 + grsec_enable_harden_ptrace = 1;
65126 +#endif
65127 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65128 + grsec_enable_mount = 1;
65129 +#endif
65130 +#ifdef CONFIG_GRKERNSEC_LINK
65131 + grsec_enable_link = 1;
65132 +#endif
65133 +#ifdef CONFIG_GRKERNSEC_BRUTE
65134 + grsec_enable_brute = 1;
65135 +#endif
65136 +#ifdef CONFIG_GRKERNSEC_DMESG
65137 + grsec_enable_dmesg = 1;
65138 +#endif
65139 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65140 + grsec_enable_blackhole = 1;
65141 + grsec_lastack_retries = 4;
65142 +#endif
65143 +#ifdef CONFIG_GRKERNSEC_FIFO
65144 + grsec_enable_fifo = 1;
65145 +#endif
65146 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65147 + grsec_enable_execlog = 1;
65148 +#endif
65149 +#ifdef CONFIG_GRKERNSEC_SETXID
65150 + grsec_enable_setxid = 1;
65151 +#endif
65152 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65153 + grsec_enable_signal = 1;
65154 +#endif
65155 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65156 + grsec_enable_forkfail = 1;
65157 +#endif
65158 +#ifdef CONFIG_GRKERNSEC_TIME
65159 + grsec_enable_time = 1;
65160 +#endif
65161 +#ifdef CONFIG_GRKERNSEC_RESLOG
65162 + grsec_resource_logging = 1;
65163 +#endif
65164 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65165 + grsec_enable_chroot_findtask = 1;
65166 +#endif
65167 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65168 + grsec_enable_chroot_unix = 1;
65169 +#endif
65170 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65171 + grsec_enable_chroot_mount = 1;
65172 +#endif
65173 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65174 + grsec_enable_chroot_fchdir = 1;
65175 +#endif
65176 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65177 + grsec_enable_chroot_shmat = 1;
65178 +#endif
65179 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65180 + grsec_enable_audit_ptrace = 1;
65181 +#endif
65182 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65183 + grsec_enable_chroot_double = 1;
65184 +#endif
65185 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65186 + grsec_enable_chroot_pivot = 1;
65187 +#endif
65188 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65189 + grsec_enable_chroot_chdir = 1;
65190 +#endif
65191 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65192 + grsec_enable_chroot_chmod = 1;
65193 +#endif
65194 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65195 + grsec_enable_chroot_mknod = 1;
65196 +#endif
65197 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65198 + grsec_enable_chroot_nice = 1;
65199 +#endif
65200 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65201 + grsec_enable_chroot_execlog = 1;
65202 +#endif
65203 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65204 + grsec_enable_chroot_caps = 1;
65205 +#endif
65206 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65207 + grsec_enable_chroot_sysctl = 1;
65208 +#endif
65209 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65210 + grsec_enable_symlinkown = 1;
65211 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65212 +#endif
65213 +#ifdef CONFIG_GRKERNSEC_TPE
65214 + grsec_enable_tpe = 1;
65215 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65216 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65217 + grsec_enable_tpe_all = 1;
65218 +#endif
65219 +#endif
65220 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65221 + grsec_enable_socket_all = 1;
65222 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65223 +#endif
65224 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65225 + grsec_enable_socket_client = 1;
65226 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65227 +#endif
65228 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65229 + grsec_enable_socket_server = 1;
65230 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65231 +#endif
65232 +#endif
65233 +
65234 + return;
65235 +}
65236 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65237 new file mode 100644
65238 index 0000000..5e05e20
65239 --- /dev/null
65240 +++ b/grsecurity/grsec_link.c
65241 @@ -0,0 +1,58 @@
65242 +#include <linux/kernel.h>
65243 +#include <linux/sched.h>
65244 +#include <linux/fs.h>
65245 +#include <linux/file.h>
65246 +#include <linux/grinternal.h>
65247 +
65248 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65249 +{
65250 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65251 + const struct inode *link_inode = link->dentry->d_inode;
65252 +
65253 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65254 + /* ignore root-owned links, e.g. /proc/self */
65255 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65256 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65257 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65258 + return 1;
65259 + }
65260 +#endif
65261 + return 0;
65262 +}
65263 +
65264 +int
65265 +gr_handle_follow_link(const struct inode *parent,
65266 + const struct inode *inode,
65267 + const struct dentry *dentry, const struct vfsmount *mnt)
65268 +{
65269 +#ifdef CONFIG_GRKERNSEC_LINK
65270 + const struct cred *cred = current_cred();
65271 +
65272 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65273 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65274 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65275 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65276 + return -EACCES;
65277 + }
65278 +#endif
65279 + return 0;
65280 +}
65281 +
65282 +int
65283 +gr_handle_hardlink(const struct dentry *dentry,
65284 + const struct vfsmount *mnt,
65285 + struct inode *inode, const int mode, const struct filename *to)
65286 +{
65287 +#ifdef CONFIG_GRKERNSEC_LINK
65288 + const struct cred *cred = current_cred();
65289 +
65290 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65291 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65292 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65293 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65294 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65295 + return -EPERM;
65296 + }
65297 +#endif
65298 + return 0;
65299 +}
65300 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65301 new file mode 100644
65302 index 0000000..7c06085
65303 --- /dev/null
65304 +++ b/grsecurity/grsec_log.c
65305 @@ -0,0 +1,326 @@
65306 +#include <linux/kernel.h>
65307 +#include <linux/sched.h>
65308 +#include <linux/file.h>
65309 +#include <linux/tty.h>
65310 +#include <linux/fs.h>
65311 +#include <linux/grinternal.h>
65312 +
65313 +#ifdef CONFIG_TREE_PREEMPT_RCU
65314 +#define DISABLE_PREEMPT() preempt_disable()
65315 +#define ENABLE_PREEMPT() preempt_enable()
65316 +#else
65317 +#define DISABLE_PREEMPT()
65318 +#define ENABLE_PREEMPT()
65319 +#endif
65320 +
65321 +#define BEGIN_LOCKS(x) \
65322 + DISABLE_PREEMPT(); \
65323 + rcu_read_lock(); \
65324 + read_lock(&tasklist_lock); \
65325 + read_lock(&grsec_exec_file_lock); \
65326 + if (x != GR_DO_AUDIT) \
65327 + spin_lock(&grsec_alert_lock); \
65328 + else \
65329 + spin_lock(&grsec_audit_lock)
65330 +
65331 +#define END_LOCKS(x) \
65332 + if (x != GR_DO_AUDIT) \
65333 + spin_unlock(&grsec_alert_lock); \
65334 + else \
65335 + spin_unlock(&grsec_audit_lock); \
65336 + read_unlock(&grsec_exec_file_lock); \
65337 + read_unlock(&tasklist_lock); \
65338 + rcu_read_unlock(); \
65339 + ENABLE_PREEMPT(); \
65340 + if (x == GR_DONT_AUDIT) \
65341 + gr_handle_alertkill(current)
65342 +
65343 +enum {
65344 + FLOODING,
65345 + NO_FLOODING
65346 +};
65347 +
65348 +extern char *gr_alert_log_fmt;
65349 +extern char *gr_audit_log_fmt;
65350 +extern char *gr_alert_log_buf;
65351 +extern char *gr_audit_log_buf;
65352 +
65353 +static int gr_log_start(int audit)
65354 +{
65355 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65356 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65357 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65358 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65359 + unsigned long curr_secs = get_seconds();
65360 +
65361 + if (audit == GR_DO_AUDIT)
65362 + goto set_fmt;
65363 +
65364 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65365 + grsec_alert_wtime = curr_secs;
65366 + grsec_alert_fyet = 0;
65367 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65368 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65369 + grsec_alert_fyet++;
65370 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65371 + grsec_alert_wtime = curr_secs;
65372 + grsec_alert_fyet++;
65373 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65374 + return FLOODING;
65375 + }
65376 + else return FLOODING;
65377 +
65378 +set_fmt:
65379 +#endif
65380 + memset(buf, 0, PAGE_SIZE);
65381 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65382 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65383 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65384 + } else if (current->signal->curr_ip) {
65385 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65386 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65387 + } else if (gr_acl_is_enabled()) {
65388 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65389 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65390 + } else {
65391 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65392 + strcpy(buf, fmt);
65393 + }
65394 +
65395 + return NO_FLOODING;
65396 +}
65397 +
65398 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65399 + __attribute__ ((format (printf, 2, 0)));
65400 +
65401 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65402 +{
65403 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65404 + unsigned int len = strlen(buf);
65405 +
65406 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65407 +
65408 + return;
65409 +}
65410 +
65411 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65412 + __attribute__ ((format (printf, 2, 3)));
65413 +
65414 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65415 +{
65416 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65417 + unsigned int len = strlen(buf);
65418 + va_list ap;
65419 +
65420 + va_start(ap, msg);
65421 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65422 + va_end(ap);
65423 +
65424 + return;
65425 +}
65426 +
65427 +static void gr_log_end(int audit, int append_default)
65428 +{
65429 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65430 + if (append_default) {
65431 + struct task_struct *task = current;
65432 + struct task_struct *parent = task->real_parent;
65433 + const struct cred *cred = __task_cred(task);
65434 + const struct cred *pcred = __task_cred(parent);
65435 + unsigned int len = strlen(buf);
65436 +
65437 + 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));
65438 + }
65439 +
65440 + printk("%s\n", buf);
65441 +
65442 + return;
65443 +}
65444 +
65445 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65446 +{
65447 + int logtype;
65448 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65449 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65450 + void *voidptr = NULL;
65451 + int num1 = 0, num2 = 0;
65452 + unsigned long ulong1 = 0, ulong2 = 0;
65453 + struct dentry *dentry = NULL;
65454 + struct vfsmount *mnt = NULL;
65455 + struct file *file = NULL;
65456 + struct task_struct *task = NULL;
65457 + const struct cred *cred, *pcred;
65458 + va_list ap;
65459 +
65460 + BEGIN_LOCKS(audit);
65461 + logtype = gr_log_start(audit);
65462 + if (logtype == FLOODING) {
65463 + END_LOCKS(audit);
65464 + return;
65465 + }
65466 + va_start(ap, argtypes);
65467 + switch (argtypes) {
65468 + case GR_TTYSNIFF:
65469 + task = va_arg(ap, struct task_struct *);
65470 + 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));
65471 + break;
65472 + case GR_SYSCTL_HIDDEN:
65473 + str1 = va_arg(ap, char *);
65474 + gr_log_middle_varargs(audit, msg, result, str1);
65475 + break;
65476 + case GR_RBAC:
65477 + dentry = va_arg(ap, struct dentry *);
65478 + mnt = va_arg(ap, struct vfsmount *);
65479 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65480 + break;
65481 + case GR_RBAC_STR:
65482 + dentry = va_arg(ap, struct dentry *);
65483 + mnt = va_arg(ap, struct vfsmount *);
65484 + str1 = va_arg(ap, char *);
65485 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65486 + break;
65487 + case GR_STR_RBAC:
65488 + str1 = va_arg(ap, char *);
65489 + dentry = va_arg(ap, struct dentry *);
65490 + mnt = va_arg(ap, struct vfsmount *);
65491 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65492 + break;
65493 + case GR_RBAC_MODE2:
65494 + dentry = va_arg(ap, struct dentry *);
65495 + mnt = va_arg(ap, struct vfsmount *);
65496 + str1 = va_arg(ap, char *);
65497 + str2 = va_arg(ap, char *);
65498 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65499 + break;
65500 + case GR_RBAC_MODE3:
65501 + dentry = va_arg(ap, struct dentry *);
65502 + mnt = va_arg(ap, struct vfsmount *);
65503 + str1 = va_arg(ap, char *);
65504 + str2 = va_arg(ap, char *);
65505 + str3 = va_arg(ap, char *);
65506 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65507 + break;
65508 + case GR_FILENAME:
65509 + dentry = va_arg(ap, struct dentry *);
65510 + mnt = va_arg(ap, struct vfsmount *);
65511 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65512 + break;
65513 + case GR_STR_FILENAME:
65514 + str1 = va_arg(ap, char *);
65515 + dentry = va_arg(ap, struct dentry *);
65516 + mnt = va_arg(ap, struct vfsmount *);
65517 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65518 + break;
65519 + case GR_FILENAME_STR:
65520 + dentry = va_arg(ap, struct dentry *);
65521 + mnt = va_arg(ap, struct vfsmount *);
65522 + str1 = va_arg(ap, char *);
65523 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65524 + break;
65525 + case GR_FILENAME_TWO_INT:
65526 + dentry = va_arg(ap, struct dentry *);
65527 + mnt = va_arg(ap, struct vfsmount *);
65528 + num1 = va_arg(ap, int);
65529 + num2 = va_arg(ap, int);
65530 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65531 + break;
65532 + case GR_FILENAME_TWO_INT_STR:
65533 + dentry = va_arg(ap, struct dentry *);
65534 + mnt = va_arg(ap, struct vfsmount *);
65535 + num1 = va_arg(ap, int);
65536 + num2 = va_arg(ap, int);
65537 + str1 = va_arg(ap, char *);
65538 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65539 + break;
65540 + case GR_TEXTREL:
65541 + file = va_arg(ap, struct file *);
65542 + ulong1 = va_arg(ap, unsigned long);
65543 + ulong2 = va_arg(ap, unsigned long);
65544 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65545 + break;
65546 + case GR_PTRACE:
65547 + task = va_arg(ap, struct task_struct *);
65548 + 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));
65549 + break;
65550 + case GR_RESOURCE:
65551 + task = va_arg(ap, struct task_struct *);
65552 + cred = __task_cred(task);
65553 + pcred = __task_cred(task->real_parent);
65554 + ulong1 = va_arg(ap, unsigned long);
65555 + str1 = va_arg(ap, char *);
65556 + ulong2 = va_arg(ap, unsigned long);
65557 + 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));
65558 + break;
65559 + case GR_CAP:
65560 + task = va_arg(ap, struct task_struct *);
65561 + cred = __task_cred(task);
65562 + pcred = __task_cred(task->real_parent);
65563 + str1 = va_arg(ap, char *);
65564 + 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));
65565 + break;
65566 + case GR_SIG:
65567 + str1 = va_arg(ap, char *);
65568 + voidptr = va_arg(ap, void *);
65569 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65570 + break;
65571 + case GR_SIG2:
65572 + task = va_arg(ap, struct task_struct *);
65573 + cred = __task_cred(task);
65574 + pcred = __task_cred(task->real_parent);
65575 + num1 = va_arg(ap, int);
65576 + 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));
65577 + break;
65578 + case GR_CRASH1:
65579 + task = va_arg(ap, struct task_struct *);
65580 + cred = __task_cred(task);
65581 + pcred = __task_cred(task->real_parent);
65582 + ulong1 = va_arg(ap, unsigned long);
65583 + 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);
65584 + break;
65585 + case GR_CRASH2:
65586 + task = va_arg(ap, struct task_struct *);
65587 + cred = __task_cred(task);
65588 + pcred = __task_cred(task->real_parent);
65589 + ulong1 = va_arg(ap, unsigned long);
65590 + 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);
65591 + break;
65592 + case GR_RWXMAP:
65593 + file = va_arg(ap, struct file *);
65594 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65595 + break;
65596 + case GR_PSACCT:
65597 + {
65598 + unsigned int wday, cday;
65599 + __u8 whr, chr;
65600 + __u8 wmin, cmin;
65601 + __u8 wsec, csec;
65602 + char cur_tty[64] = { 0 };
65603 + char parent_tty[64] = { 0 };
65604 +
65605 + task = va_arg(ap, struct task_struct *);
65606 + wday = va_arg(ap, unsigned int);
65607 + cday = va_arg(ap, unsigned int);
65608 + whr = va_arg(ap, int);
65609 + chr = va_arg(ap, int);
65610 + wmin = va_arg(ap, int);
65611 + cmin = va_arg(ap, int);
65612 + wsec = va_arg(ap, int);
65613 + csec = va_arg(ap, int);
65614 + ulong1 = va_arg(ap, unsigned long);
65615 + cred = __task_cred(task);
65616 + pcred = __task_cred(task->real_parent);
65617 +
65618 + 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));
65619 + }
65620 + break;
65621 + default:
65622 + gr_log_middle(audit, msg, ap);
65623 + }
65624 + va_end(ap);
65625 + // these don't need DEFAULTSECARGS printed on the end
65626 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65627 + gr_log_end(audit, 0);
65628 + else
65629 + gr_log_end(audit, 1);
65630 + END_LOCKS(audit);
65631 +}
65632 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65633 new file mode 100644
65634 index 0000000..f536303
65635 --- /dev/null
65636 +++ b/grsecurity/grsec_mem.c
65637 @@ -0,0 +1,40 @@
65638 +#include <linux/kernel.h>
65639 +#include <linux/sched.h>
65640 +#include <linux/mm.h>
65641 +#include <linux/mman.h>
65642 +#include <linux/grinternal.h>
65643 +
65644 +void
65645 +gr_handle_ioperm(void)
65646 +{
65647 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65648 + return;
65649 +}
65650 +
65651 +void
65652 +gr_handle_iopl(void)
65653 +{
65654 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65655 + return;
65656 +}
65657 +
65658 +void
65659 +gr_handle_mem_readwrite(u64 from, u64 to)
65660 +{
65661 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65662 + return;
65663 +}
65664 +
65665 +void
65666 +gr_handle_vm86(void)
65667 +{
65668 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65669 + return;
65670 +}
65671 +
65672 +void
65673 +gr_log_badprocpid(const char *entry)
65674 +{
65675 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65676 + return;
65677 +}
65678 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65679 new file mode 100644
65680 index 0000000..2131422
65681 --- /dev/null
65682 +++ b/grsecurity/grsec_mount.c
65683 @@ -0,0 +1,62 @@
65684 +#include <linux/kernel.h>
65685 +#include <linux/sched.h>
65686 +#include <linux/mount.h>
65687 +#include <linux/grsecurity.h>
65688 +#include <linux/grinternal.h>
65689 +
65690 +void
65691 +gr_log_remount(const char *devname, const int retval)
65692 +{
65693 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65694 + if (grsec_enable_mount && (retval >= 0))
65695 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65696 +#endif
65697 + return;
65698 +}
65699 +
65700 +void
65701 +gr_log_unmount(const char *devname, const int retval)
65702 +{
65703 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65704 + if (grsec_enable_mount && (retval >= 0))
65705 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65706 +#endif
65707 + return;
65708 +}
65709 +
65710 +void
65711 +gr_log_mount(const char *from, const char *to, const int retval)
65712 +{
65713 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65714 + if (grsec_enable_mount && (retval >= 0))
65715 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65716 +#endif
65717 + return;
65718 +}
65719 +
65720 +int
65721 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65722 +{
65723 +#ifdef CONFIG_GRKERNSEC_ROFS
65724 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65725 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65726 + return -EPERM;
65727 + } else
65728 + return 0;
65729 +#endif
65730 + return 0;
65731 +}
65732 +
65733 +int
65734 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65735 +{
65736 +#ifdef CONFIG_GRKERNSEC_ROFS
65737 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65738 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65739 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65740 + return -EPERM;
65741 + } else
65742 + return 0;
65743 +#endif
65744 + return 0;
65745 +}
65746 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65747 new file mode 100644
65748 index 0000000..a3b12a0
65749 --- /dev/null
65750 +++ b/grsecurity/grsec_pax.c
65751 @@ -0,0 +1,36 @@
65752 +#include <linux/kernel.h>
65753 +#include <linux/sched.h>
65754 +#include <linux/mm.h>
65755 +#include <linux/file.h>
65756 +#include <linux/grinternal.h>
65757 +#include <linux/grsecurity.h>
65758 +
65759 +void
65760 +gr_log_textrel(struct vm_area_struct * vma)
65761 +{
65762 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65763 + if (grsec_enable_audit_textrel)
65764 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65765 +#endif
65766 + return;
65767 +}
65768 +
65769 +void
65770 +gr_log_rwxmmap(struct file *file)
65771 +{
65772 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65773 + if (grsec_enable_log_rwxmaps)
65774 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65775 +#endif
65776 + return;
65777 +}
65778 +
65779 +void
65780 +gr_log_rwxmprotect(struct file *file)
65781 +{
65782 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65783 + if (grsec_enable_log_rwxmaps)
65784 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65785 +#endif
65786 + return;
65787 +}
65788 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65789 new file mode 100644
65790 index 0000000..f7f29aa
65791 --- /dev/null
65792 +++ b/grsecurity/grsec_ptrace.c
65793 @@ -0,0 +1,30 @@
65794 +#include <linux/kernel.h>
65795 +#include <linux/sched.h>
65796 +#include <linux/grinternal.h>
65797 +#include <linux/security.h>
65798 +
65799 +void
65800 +gr_audit_ptrace(struct task_struct *task)
65801 +{
65802 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65803 + if (grsec_enable_audit_ptrace)
65804 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65805 +#endif
65806 + return;
65807 +}
65808 +
65809 +int
65810 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65811 +{
65812 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65813 + const struct dentry *dentry = file->f_path.dentry;
65814 + const struct vfsmount *mnt = file->f_path.mnt;
65815 +
65816 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65817 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65818 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65819 + return -EACCES;
65820 + }
65821 +#endif
65822 + return 0;
65823 +}
65824 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65825 new file mode 100644
65826 index 0000000..e09715a
65827 --- /dev/null
65828 +++ b/grsecurity/grsec_sig.c
65829 @@ -0,0 +1,222 @@
65830 +#include <linux/kernel.h>
65831 +#include <linux/sched.h>
65832 +#include <linux/delay.h>
65833 +#include <linux/grsecurity.h>
65834 +#include <linux/grinternal.h>
65835 +#include <linux/hardirq.h>
65836 +
65837 +char *signames[] = {
65838 + [SIGSEGV] = "Segmentation fault",
65839 + [SIGILL] = "Illegal instruction",
65840 + [SIGABRT] = "Abort",
65841 + [SIGBUS] = "Invalid alignment/Bus error"
65842 +};
65843 +
65844 +void
65845 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65846 +{
65847 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65848 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65849 + (sig == SIGABRT) || (sig == SIGBUS))) {
65850 + if (task_pid_nr(t) == task_pid_nr(current)) {
65851 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65852 + } else {
65853 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65854 + }
65855 + }
65856 +#endif
65857 + return;
65858 +}
65859 +
65860 +int
65861 +gr_handle_signal(const struct task_struct *p, const int sig)
65862 +{
65863 +#ifdef CONFIG_GRKERNSEC
65864 + /* ignore the 0 signal for protected task checks */
65865 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65866 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65867 + return -EPERM;
65868 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65869 + return -EPERM;
65870 + }
65871 +#endif
65872 + return 0;
65873 +}
65874 +
65875 +#ifdef CONFIG_GRKERNSEC
65876 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65877 +
65878 +int gr_fake_force_sig(int sig, struct task_struct *t)
65879 +{
65880 + unsigned long int flags;
65881 + int ret, blocked, ignored;
65882 + struct k_sigaction *action;
65883 +
65884 + spin_lock_irqsave(&t->sighand->siglock, flags);
65885 + action = &t->sighand->action[sig-1];
65886 + ignored = action->sa.sa_handler == SIG_IGN;
65887 + blocked = sigismember(&t->blocked, sig);
65888 + if (blocked || ignored) {
65889 + action->sa.sa_handler = SIG_DFL;
65890 + if (blocked) {
65891 + sigdelset(&t->blocked, sig);
65892 + recalc_sigpending_and_wake(t);
65893 + }
65894 + }
65895 + if (action->sa.sa_handler == SIG_DFL)
65896 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65897 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65898 +
65899 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65900 +
65901 + return ret;
65902 +}
65903 +#endif
65904 +
65905 +#ifdef CONFIG_GRKERNSEC_BRUTE
65906 +#define GR_USER_BAN_TIME (15 * 60)
65907 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65908 +
65909 +static int __get_dumpable(unsigned long mm_flags)
65910 +{
65911 + int ret;
65912 +
65913 + ret = mm_flags & MMF_DUMPABLE_MASK;
65914 + return (ret >= 2) ? 2 : ret;
65915 +}
65916 +#endif
65917 +
65918 +void gr_handle_brute_attach(unsigned long mm_flags)
65919 +{
65920 +#ifdef CONFIG_GRKERNSEC_BRUTE
65921 + struct task_struct *p = current;
65922 + kuid_t uid = GLOBAL_ROOT_UID;
65923 + int daemon = 0;
65924 +
65925 + if (!grsec_enable_brute)
65926 + return;
65927 +
65928 + rcu_read_lock();
65929 + read_lock(&tasklist_lock);
65930 + read_lock(&grsec_exec_file_lock);
65931 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65932 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65933 + p->real_parent->brute = 1;
65934 + daemon = 1;
65935 + } else {
65936 + const struct cred *cred = __task_cred(p), *cred2;
65937 + struct task_struct *tsk, *tsk2;
65938 +
65939 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65940 + struct user_struct *user;
65941 +
65942 + uid = cred->uid;
65943 +
65944 + /* this is put upon execution past expiration */
65945 + user = find_user(uid);
65946 + if (user == NULL)
65947 + goto unlock;
65948 + user->banned = 1;
65949 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65950 + if (user->ban_expires == ~0UL)
65951 + user->ban_expires--;
65952 +
65953 + do_each_thread(tsk2, tsk) {
65954 + cred2 = __task_cred(tsk);
65955 + if (tsk != p && uid_eq(cred2->uid, uid))
65956 + gr_fake_force_sig(SIGKILL, tsk);
65957 + } while_each_thread(tsk2, tsk);
65958 + }
65959 + }
65960 +unlock:
65961 + read_unlock(&grsec_exec_file_lock);
65962 + read_unlock(&tasklist_lock);
65963 + rcu_read_unlock();
65964 +
65965 + if (gr_is_global_nonroot(uid))
65966 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65967 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65968 + else if (daemon)
65969 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65970 +
65971 +#endif
65972 + return;
65973 +}
65974 +
65975 +void gr_handle_brute_check(void)
65976 +{
65977 +#ifdef CONFIG_GRKERNSEC_BRUTE
65978 + struct task_struct *p = current;
65979 +
65980 + if (unlikely(p->brute)) {
65981 + if (!grsec_enable_brute)
65982 + p->brute = 0;
65983 + else if (time_before(get_seconds(), p->brute_expires))
65984 + msleep(30 * 1000);
65985 + }
65986 +#endif
65987 + return;
65988 +}
65989 +
65990 +void gr_handle_kernel_exploit(void)
65991 +{
65992 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65993 + const struct cred *cred;
65994 + struct task_struct *tsk, *tsk2;
65995 + struct user_struct *user;
65996 + kuid_t uid;
65997 +
65998 + if (in_irq() || in_serving_softirq() || in_nmi())
65999 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66000 +
66001 + uid = current_uid();
66002 +
66003 + if (gr_is_global_root(uid))
66004 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66005 + else {
66006 + /* kill all the processes of this user, hold a reference
66007 + to their creds struct, and prevent them from creating
66008 + another process until system reset
66009 + */
66010 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66011 + GR_GLOBAL_UID(uid));
66012 + /* we intentionally leak this ref */
66013 + user = get_uid(current->cred->user);
66014 + if (user) {
66015 + user->banned = 1;
66016 + user->ban_expires = ~0UL;
66017 + }
66018 +
66019 + read_lock(&tasklist_lock);
66020 + do_each_thread(tsk2, tsk) {
66021 + cred = __task_cred(tsk);
66022 + if (uid_eq(cred->uid, uid))
66023 + gr_fake_force_sig(SIGKILL, tsk);
66024 + } while_each_thread(tsk2, tsk);
66025 + read_unlock(&tasklist_lock);
66026 + }
66027 +#endif
66028 +}
66029 +
66030 +int __gr_process_user_ban(struct user_struct *user)
66031 +{
66032 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66033 + if (unlikely(user->banned)) {
66034 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
66035 + user->banned = 0;
66036 + user->ban_expires = 0;
66037 + free_uid(user);
66038 + } else
66039 + return -EPERM;
66040 + }
66041 +#endif
66042 + return 0;
66043 +}
66044 +
66045 +int gr_process_user_ban(void)
66046 +{
66047 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66048 + return __gr_process_user_ban(current->cred->user);
66049 +#endif
66050 + return 0;
66051 +}
66052 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66053 new file mode 100644
66054 index 0000000..4030d57
66055 --- /dev/null
66056 +++ b/grsecurity/grsec_sock.c
66057 @@ -0,0 +1,244 @@
66058 +#include <linux/kernel.h>
66059 +#include <linux/module.h>
66060 +#include <linux/sched.h>
66061 +#include <linux/file.h>
66062 +#include <linux/net.h>
66063 +#include <linux/in.h>
66064 +#include <linux/ip.h>
66065 +#include <net/sock.h>
66066 +#include <net/inet_sock.h>
66067 +#include <linux/grsecurity.h>
66068 +#include <linux/grinternal.h>
66069 +#include <linux/gracl.h>
66070 +
66071 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66072 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66073 +
66074 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66075 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66076 +
66077 +#ifdef CONFIG_UNIX_MODULE
66078 +EXPORT_SYMBOL(gr_acl_handle_unix);
66079 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66080 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66081 +EXPORT_SYMBOL(gr_handle_create);
66082 +#endif
66083 +
66084 +#ifdef CONFIG_GRKERNSEC
66085 +#define gr_conn_table_size 32749
66086 +struct conn_table_entry {
66087 + struct conn_table_entry *next;
66088 + struct signal_struct *sig;
66089 +};
66090 +
66091 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66092 +DEFINE_SPINLOCK(gr_conn_table_lock);
66093 +
66094 +extern const char * gr_socktype_to_name(unsigned char type);
66095 +extern const char * gr_proto_to_name(unsigned char proto);
66096 +extern const char * gr_sockfamily_to_name(unsigned char family);
66097 +
66098 +static __inline__ int
66099 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66100 +{
66101 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66102 +}
66103 +
66104 +static __inline__ int
66105 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66106 + __u16 sport, __u16 dport)
66107 +{
66108 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66109 + sig->gr_sport == sport && sig->gr_dport == dport))
66110 + return 1;
66111 + else
66112 + return 0;
66113 +}
66114 +
66115 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66116 +{
66117 + struct conn_table_entry **match;
66118 + unsigned int index;
66119 +
66120 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66121 + sig->gr_sport, sig->gr_dport,
66122 + gr_conn_table_size);
66123 +
66124 + newent->sig = sig;
66125 +
66126 + match = &gr_conn_table[index];
66127 + newent->next = *match;
66128 + *match = newent;
66129 +
66130 + return;
66131 +}
66132 +
66133 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66134 +{
66135 + struct conn_table_entry *match, *last = NULL;
66136 + unsigned int index;
66137 +
66138 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66139 + sig->gr_sport, sig->gr_dport,
66140 + gr_conn_table_size);
66141 +
66142 + match = gr_conn_table[index];
66143 + while (match && !conn_match(match->sig,
66144 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66145 + sig->gr_dport)) {
66146 + last = match;
66147 + match = match->next;
66148 + }
66149 +
66150 + if (match) {
66151 + if (last)
66152 + last->next = match->next;
66153 + else
66154 + gr_conn_table[index] = NULL;
66155 + kfree(match);
66156 + }
66157 +
66158 + return;
66159 +}
66160 +
66161 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66162 + __u16 sport, __u16 dport)
66163 +{
66164 + struct conn_table_entry *match;
66165 + unsigned int index;
66166 +
66167 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66168 +
66169 + match = gr_conn_table[index];
66170 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66171 + match = match->next;
66172 +
66173 + if (match)
66174 + return match->sig;
66175 + else
66176 + return NULL;
66177 +}
66178 +
66179 +#endif
66180 +
66181 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66182 +{
66183 +#ifdef CONFIG_GRKERNSEC
66184 + struct signal_struct *sig = task->signal;
66185 + struct conn_table_entry *newent;
66186 +
66187 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66188 + if (newent == NULL)
66189 + return;
66190 + /* no bh lock needed since we are called with bh disabled */
66191 + spin_lock(&gr_conn_table_lock);
66192 + gr_del_task_from_ip_table_nolock(sig);
66193 + sig->gr_saddr = inet->inet_rcv_saddr;
66194 + sig->gr_daddr = inet->inet_daddr;
66195 + sig->gr_sport = inet->inet_sport;
66196 + sig->gr_dport = inet->inet_dport;
66197 + gr_add_to_task_ip_table_nolock(sig, newent);
66198 + spin_unlock(&gr_conn_table_lock);
66199 +#endif
66200 + return;
66201 +}
66202 +
66203 +void gr_del_task_from_ip_table(struct task_struct *task)
66204 +{
66205 +#ifdef CONFIG_GRKERNSEC
66206 + spin_lock_bh(&gr_conn_table_lock);
66207 + gr_del_task_from_ip_table_nolock(task->signal);
66208 + spin_unlock_bh(&gr_conn_table_lock);
66209 +#endif
66210 + return;
66211 +}
66212 +
66213 +void
66214 +gr_attach_curr_ip(const struct sock *sk)
66215 +{
66216 +#ifdef CONFIG_GRKERNSEC
66217 + struct signal_struct *p, *set;
66218 + const struct inet_sock *inet = inet_sk(sk);
66219 +
66220 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66221 + return;
66222 +
66223 + set = current->signal;
66224 +
66225 + spin_lock_bh(&gr_conn_table_lock);
66226 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66227 + inet->inet_dport, inet->inet_sport);
66228 + if (unlikely(p != NULL)) {
66229 + set->curr_ip = p->curr_ip;
66230 + set->used_accept = 1;
66231 + gr_del_task_from_ip_table_nolock(p);
66232 + spin_unlock_bh(&gr_conn_table_lock);
66233 + return;
66234 + }
66235 + spin_unlock_bh(&gr_conn_table_lock);
66236 +
66237 + set->curr_ip = inet->inet_daddr;
66238 + set->used_accept = 1;
66239 +#endif
66240 + return;
66241 +}
66242 +
66243 +int
66244 +gr_handle_sock_all(const int family, const int type, const int protocol)
66245 +{
66246 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66247 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66248 + (family != AF_UNIX)) {
66249 + if (family == AF_INET)
66250 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66251 + else
66252 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66253 + return -EACCES;
66254 + }
66255 +#endif
66256 + return 0;
66257 +}
66258 +
66259 +int
66260 +gr_handle_sock_server(const struct sockaddr *sck)
66261 +{
66262 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66263 + if (grsec_enable_socket_server &&
66264 + in_group_p(grsec_socket_server_gid) &&
66265 + sck && (sck->sa_family != AF_UNIX) &&
66266 + (sck->sa_family != AF_LOCAL)) {
66267 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66268 + return -EACCES;
66269 + }
66270 +#endif
66271 + return 0;
66272 +}
66273 +
66274 +int
66275 +gr_handle_sock_server_other(const struct sock *sck)
66276 +{
66277 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66278 + if (grsec_enable_socket_server &&
66279 + in_group_p(grsec_socket_server_gid) &&
66280 + sck && (sck->sk_family != AF_UNIX) &&
66281 + (sck->sk_family != AF_LOCAL)) {
66282 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66283 + return -EACCES;
66284 + }
66285 +#endif
66286 + return 0;
66287 +}
66288 +
66289 +int
66290 +gr_handle_sock_client(const struct sockaddr *sck)
66291 +{
66292 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66293 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66294 + sck && (sck->sa_family != AF_UNIX) &&
66295 + (sck->sa_family != AF_LOCAL)) {
66296 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66297 + return -EACCES;
66298 + }
66299 +#endif
66300 + return 0;
66301 +}
66302 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66303 new file mode 100644
66304 index 0000000..f55ef0f
66305 --- /dev/null
66306 +++ b/grsecurity/grsec_sysctl.c
66307 @@ -0,0 +1,469 @@
66308 +#include <linux/kernel.h>
66309 +#include <linux/sched.h>
66310 +#include <linux/sysctl.h>
66311 +#include <linux/grsecurity.h>
66312 +#include <linux/grinternal.h>
66313 +
66314 +int
66315 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66316 +{
66317 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66318 + if (dirname == NULL || name == NULL)
66319 + return 0;
66320 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66321 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66322 + return -EACCES;
66323 + }
66324 +#endif
66325 + return 0;
66326 +}
66327 +
66328 +#ifdef CONFIG_GRKERNSEC_ROFS
66329 +static int __maybe_unused one = 1;
66330 +#endif
66331 +
66332 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66333 +struct ctl_table grsecurity_table[] = {
66334 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66335 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66336 +#ifdef CONFIG_GRKERNSEC_IO
66337 + {
66338 + .procname = "disable_priv_io",
66339 + .data = &grsec_disable_privio,
66340 + .maxlen = sizeof(int),
66341 + .mode = 0600,
66342 + .proc_handler = &proc_dointvec,
66343 + },
66344 +#endif
66345 +#endif
66346 +#ifdef CONFIG_GRKERNSEC_LINK
66347 + {
66348 + .procname = "linking_restrictions",
66349 + .data = &grsec_enable_link,
66350 + .maxlen = sizeof(int),
66351 + .mode = 0600,
66352 + .proc_handler = &proc_dointvec,
66353 + },
66354 +#endif
66355 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66356 + {
66357 + .procname = "enforce_symlinksifowner",
66358 + .data = &grsec_enable_symlinkown,
66359 + .maxlen = sizeof(int),
66360 + .mode = 0600,
66361 + .proc_handler = &proc_dointvec,
66362 + },
66363 + {
66364 + .procname = "symlinkown_gid",
66365 + .data = &grsec_symlinkown_gid,
66366 + .maxlen = sizeof(int),
66367 + .mode = 0600,
66368 + .proc_handler = &proc_dointvec,
66369 + },
66370 +#endif
66371 +#ifdef CONFIG_GRKERNSEC_BRUTE
66372 + {
66373 + .procname = "deter_bruteforce",
66374 + .data = &grsec_enable_brute,
66375 + .maxlen = sizeof(int),
66376 + .mode = 0600,
66377 + .proc_handler = &proc_dointvec,
66378 + },
66379 +#endif
66380 +#ifdef CONFIG_GRKERNSEC_FIFO
66381 + {
66382 + .procname = "fifo_restrictions",
66383 + .data = &grsec_enable_fifo,
66384 + .maxlen = sizeof(int),
66385 + .mode = 0600,
66386 + .proc_handler = &proc_dointvec,
66387 + },
66388 +#endif
66389 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66390 + {
66391 + .procname = "ptrace_readexec",
66392 + .data = &grsec_enable_ptrace_readexec,
66393 + .maxlen = sizeof(int),
66394 + .mode = 0600,
66395 + .proc_handler = &proc_dointvec,
66396 + },
66397 +#endif
66398 +#ifdef CONFIG_GRKERNSEC_SETXID
66399 + {
66400 + .procname = "consistent_setxid",
66401 + .data = &grsec_enable_setxid,
66402 + .maxlen = sizeof(int),
66403 + .mode = 0600,
66404 + .proc_handler = &proc_dointvec,
66405 + },
66406 +#endif
66407 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66408 + {
66409 + .procname = "ip_blackhole",
66410 + .data = &grsec_enable_blackhole,
66411 + .maxlen = sizeof(int),
66412 + .mode = 0600,
66413 + .proc_handler = &proc_dointvec,
66414 + },
66415 + {
66416 + .procname = "lastack_retries",
66417 + .data = &grsec_lastack_retries,
66418 + .maxlen = sizeof(int),
66419 + .mode = 0600,
66420 + .proc_handler = &proc_dointvec,
66421 + },
66422 +#endif
66423 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66424 + {
66425 + .procname = "exec_logging",
66426 + .data = &grsec_enable_execlog,
66427 + .maxlen = sizeof(int),
66428 + .mode = 0600,
66429 + .proc_handler = &proc_dointvec,
66430 + },
66431 +#endif
66432 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66433 + {
66434 + .procname = "rwxmap_logging",
66435 + .data = &grsec_enable_log_rwxmaps,
66436 + .maxlen = sizeof(int),
66437 + .mode = 0600,
66438 + .proc_handler = &proc_dointvec,
66439 + },
66440 +#endif
66441 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66442 + {
66443 + .procname = "signal_logging",
66444 + .data = &grsec_enable_signal,
66445 + .maxlen = sizeof(int),
66446 + .mode = 0600,
66447 + .proc_handler = &proc_dointvec,
66448 + },
66449 +#endif
66450 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66451 + {
66452 + .procname = "forkfail_logging",
66453 + .data = &grsec_enable_forkfail,
66454 + .maxlen = sizeof(int),
66455 + .mode = 0600,
66456 + .proc_handler = &proc_dointvec,
66457 + },
66458 +#endif
66459 +#ifdef CONFIG_GRKERNSEC_TIME
66460 + {
66461 + .procname = "timechange_logging",
66462 + .data = &grsec_enable_time,
66463 + .maxlen = sizeof(int),
66464 + .mode = 0600,
66465 + .proc_handler = &proc_dointvec,
66466 + },
66467 +#endif
66468 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66469 + {
66470 + .procname = "chroot_deny_shmat",
66471 + .data = &grsec_enable_chroot_shmat,
66472 + .maxlen = sizeof(int),
66473 + .mode = 0600,
66474 + .proc_handler = &proc_dointvec,
66475 + },
66476 +#endif
66477 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66478 + {
66479 + .procname = "chroot_deny_unix",
66480 + .data = &grsec_enable_chroot_unix,
66481 + .maxlen = sizeof(int),
66482 + .mode = 0600,
66483 + .proc_handler = &proc_dointvec,
66484 + },
66485 +#endif
66486 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66487 + {
66488 + .procname = "chroot_deny_mount",
66489 + .data = &grsec_enable_chroot_mount,
66490 + .maxlen = sizeof(int),
66491 + .mode = 0600,
66492 + .proc_handler = &proc_dointvec,
66493 + },
66494 +#endif
66495 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66496 + {
66497 + .procname = "chroot_deny_fchdir",
66498 + .data = &grsec_enable_chroot_fchdir,
66499 + .maxlen = sizeof(int),
66500 + .mode = 0600,
66501 + .proc_handler = &proc_dointvec,
66502 + },
66503 +#endif
66504 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66505 + {
66506 + .procname = "chroot_deny_chroot",
66507 + .data = &grsec_enable_chroot_double,
66508 + .maxlen = sizeof(int),
66509 + .mode = 0600,
66510 + .proc_handler = &proc_dointvec,
66511 + },
66512 +#endif
66513 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66514 + {
66515 + .procname = "chroot_deny_pivot",
66516 + .data = &grsec_enable_chroot_pivot,
66517 + .maxlen = sizeof(int),
66518 + .mode = 0600,
66519 + .proc_handler = &proc_dointvec,
66520 + },
66521 +#endif
66522 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66523 + {
66524 + .procname = "chroot_enforce_chdir",
66525 + .data = &grsec_enable_chroot_chdir,
66526 + .maxlen = sizeof(int),
66527 + .mode = 0600,
66528 + .proc_handler = &proc_dointvec,
66529 + },
66530 +#endif
66531 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66532 + {
66533 + .procname = "chroot_deny_chmod",
66534 + .data = &grsec_enable_chroot_chmod,
66535 + .maxlen = sizeof(int),
66536 + .mode = 0600,
66537 + .proc_handler = &proc_dointvec,
66538 + },
66539 +#endif
66540 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66541 + {
66542 + .procname = "chroot_deny_mknod",
66543 + .data = &grsec_enable_chroot_mknod,
66544 + .maxlen = sizeof(int),
66545 + .mode = 0600,
66546 + .proc_handler = &proc_dointvec,
66547 + },
66548 +#endif
66549 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66550 + {
66551 + .procname = "chroot_restrict_nice",
66552 + .data = &grsec_enable_chroot_nice,
66553 + .maxlen = sizeof(int),
66554 + .mode = 0600,
66555 + .proc_handler = &proc_dointvec,
66556 + },
66557 +#endif
66558 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66559 + {
66560 + .procname = "chroot_execlog",
66561 + .data = &grsec_enable_chroot_execlog,
66562 + .maxlen = sizeof(int),
66563 + .mode = 0600,
66564 + .proc_handler = &proc_dointvec,
66565 + },
66566 +#endif
66567 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66568 + {
66569 + .procname = "chroot_caps",
66570 + .data = &grsec_enable_chroot_caps,
66571 + .maxlen = sizeof(int),
66572 + .mode = 0600,
66573 + .proc_handler = &proc_dointvec,
66574 + },
66575 +#endif
66576 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66577 + {
66578 + .procname = "chroot_deny_sysctl",
66579 + .data = &grsec_enable_chroot_sysctl,
66580 + .maxlen = sizeof(int),
66581 + .mode = 0600,
66582 + .proc_handler = &proc_dointvec,
66583 + },
66584 +#endif
66585 +#ifdef CONFIG_GRKERNSEC_TPE
66586 + {
66587 + .procname = "tpe",
66588 + .data = &grsec_enable_tpe,
66589 + .maxlen = sizeof(int),
66590 + .mode = 0600,
66591 + .proc_handler = &proc_dointvec,
66592 + },
66593 + {
66594 + .procname = "tpe_gid",
66595 + .data = &grsec_tpe_gid,
66596 + .maxlen = sizeof(int),
66597 + .mode = 0600,
66598 + .proc_handler = &proc_dointvec,
66599 + },
66600 +#endif
66601 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66602 + {
66603 + .procname = "tpe_invert",
66604 + .data = &grsec_enable_tpe_invert,
66605 + .maxlen = sizeof(int),
66606 + .mode = 0600,
66607 + .proc_handler = &proc_dointvec,
66608 + },
66609 +#endif
66610 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66611 + {
66612 + .procname = "tpe_restrict_all",
66613 + .data = &grsec_enable_tpe_all,
66614 + .maxlen = sizeof(int),
66615 + .mode = 0600,
66616 + .proc_handler = &proc_dointvec,
66617 + },
66618 +#endif
66619 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66620 + {
66621 + .procname = "socket_all",
66622 + .data = &grsec_enable_socket_all,
66623 + .maxlen = sizeof(int),
66624 + .mode = 0600,
66625 + .proc_handler = &proc_dointvec,
66626 + },
66627 + {
66628 + .procname = "socket_all_gid",
66629 + .data = &grsec_socket_all_gid,
66630 + .maxlen = sizeof(int),
66631 + .mode = 0600,
66632 + .proc_handler = &proc_dointvec,
66633 + },
66634 +#endif
66635 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66636 + {
66637 + .procname = "socket_client",
66638 + .data = &grsec_enable_socket_client,
66639 + .maxlen = sizeof(int),
66640 + .mode = 0600,
66641 + .proc_handler = &proc_dointvec,
66642 + },
66643 + {
66644 + .procname = "socket_client_gid",
66645 + .data = &grsec_socket_client_gid,
66646 + .maxlen = sizeof(int),
66647 + .mode = 0600,
66648 + .proc_handler = &proc_dointvec,
66649 + },
66650 +#endif
66651 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66652 + {
66653 + .procname = "socket_server",
66654 + .data = &grsec_enable_socket_server,
66655 + .maxlen = sizeof(int),
66656 + .mode = 0600,
66657 + .proc_handler = &proc_dointvec,
66658 + },
66659 + {
66660 + .procname = "socket_server_gid",
66661 + .data = &grsec_socket_server_gid,
66662 + .maxlen = sizeof(int),
66663 + .mode = 0600,
66664 + .proc_handler = &proc_dointvec,
66665 + },
66666 +#endif
66667 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66668 + {
66669 + .procname = "audit_group",
66670 + .data = &grsec_enable_group,
66671 + .maxlen = sizeof(int),
66672 + .mode = 0600,
66673 + .proc_handler = &proc_dointvec,
66674 + },
66675 + {
66676 + .procname = "audit_gid",
66677 + .data = &grsec_audit_gid,
66678 + .maxlen = sizeof(int),
66679 + .mode = 0600,
66680 + .proc_handler = &proc_dointvec,
66681 + },
66682 +#endif
66683 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66684 + {
66685 + .procname = "audit_chdir",
66686 + .data = &grsec_enable_chdir,
66687 + .maxlen = sizeof(int),
66688 + .mode = 0600,
66689 + .proc_handler = &proc_dointvec,
66690 + },
66691 +#endif
66692 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66693 + {
66694 + .procname = "audit_mount",
66695 + .data = &grsec_enable_mount,
66696 + .maxlen = sizeof(int),
66697 + .mode = 0600,
66698 + .proc_handler = &proc_dointvec,
66699 + },
66700 +#endif
66701 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66702 + {
66703 + .procname = "audit_textrel",
66704 + .data = &grsec_enable_audit_textrel,
66705 + .maxlen = sizeof(int),
66706 + .mode = 0600,
66707 + .proc_handler = &proc_dointvec,
66708 + },
66709 +#endif
66710 +#ifdef CONFIG_GRKERNSEC_DMESG
66711 + {
66712 + .procname = "dmesg",
66713 + .data = &grsec_enable_dmesg,
66714 + .maxlen = sizeof(int),
66715 + .mode = 0600,
66716 + .proc_handler = &proc_dointvec,
66717 + },
66718 +#endif
66719 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66720 + {
66721 + .procname = "chroot_findtask",
66722 + .data = &grsec_enable_chroot_findtask,
66723 + .maxlen = sizeof(int),
66724 + .mode = 0600,
66725 + .proc_handler = &proc_dointvec,
66726 + },
66727 +#endif
66728 +#ifdef CONFIG_GRKERNSEC_RESLOG
66729 + {
66730 + .procname = "resource_logging",
66731 + .data = &grsec_resource_logging,
66732 + .maxlen = sizeof(int),
66733 + .mode = 0600,
66734 + .proc_handler = &proc_dointvec,
66735 + },
66736 +#endif
66737 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66738 + {
66739 + .procname = "audit_ptrace",
66740 + .data = &grsec_enable_audit_ptrace,
66741 + .maxlen = sizeof(int),
66742 + .mode = 0600,
66743 + .proc_handler = &proc_dointvec,
66744 + },
66745 +#endif
66746 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66747 + {
66748 + .procname = "harden_ptrace",
66749 + .data = &grsec_enable_harden_ptrace,
66750 + .maxlen = sizeof(int),
66751 + .mode = 0600,
66752 + .proc_handler = &proc_dointvec,
66753 + },
66754 +#endif
66755 + {
66756 + .procname = "grsec_lock",
66757 + .data = &grsec_lock,
66758 + .maxlen = sizeof(int),
66759 + .mode = 0600,
66760 + .proc_handler = &proc_dointvec,
66761 + },
66762 +#endif
66763 +#ifdef CONFIG_GRKERNSEC_ROFS
66764 + {
66765 + .procname = "romount_protect",
66766 + .data = &grsec_enable_rofs,
66767 + .maxlen = sizeof(int),
66768 + .mode = 0600,
66769 + .proc_handler = &proc_dointvec_minmax,
66770 + .extra1 = &one,
66771 + .extra2 = &one,
66772 + },
66773 +#endif
66774 + { }
66775 +};
66776 +#endif
66777 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66778 new file mode 100644
66779 index 0000000..0dc13c3
66780 --- /dev/null
66781 +++ b/grsecurity/grsec_time.c
66782 @@ -0,0 +1,16 @@
66783 +#include <linux/kernel.h>
66784 +#include <linux/sched.h>
66785 +#include <linux/grinternal.h>
66786 +#include <linux/module.h>
66787 +
66788 +void
66789 +gr_log_timechange(void)
66790 +{
66791 +#ifdef CONFIG_GRKERNSEC_TIME
66792 + if (grsec_enable_time)
66793 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66794 +#endif
66795 + return;
66796 +}
66797 +
66798 +EXPORT_SYMBOL(gr_log_timechange);
66799 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66800 new file mode 100644
66801 index 0000000..ee57dcf
66802 --- /dev/null
66803 +++ b/grsecurity/grsec_tpe.c
66804 @@ -0,0 +1,73 @@
66805 +#include <linux/kernel.h>
66806 +#include <linux/sched.h>
66807 +#include <linux/file.h>
66808 +#include <linux/fs.h>
66809 +#include <linux/grinternal.h>
66810 +
66811 +extern int gr_acl_tpe_check(void);
66812 +
66813 +int
66814 +gr_tpe_allow(const struct file *file)
66815 +{
66816 +#ifdef CONFIG_GRKERNSEC
66817 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66818 + const struct cred *cred = current_cred();
66819 + char *msg = NULL;
66820 + char *msg2 = NULL;
66821 +
66822 + // never restrict root
66823 + if (gr_is_global_root(cred->uid))
66824 + return 1;
66825 +
66826 + if (grsec_enable_tpe) {
66827 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66828 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66829 + msg = "not being in trusted group";
66830 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66831 + msg = "being in untrusted group";
66832 +#else
66833 + if (in_group_p(grsec_tpe_gid))
66834 + msg = "being in untrusted group";
66835 +#endif
66836 + }
66837 + if (!msg && gr_acl_tpe_check())
66838 + msg = "being in untrusted role";
66839 +
66840 + // not in any affected group/role
66841 + if (!msg)
66842 + goto next_check;
66843 +
66844 + if (gr_is_global_nonroot(inode->i_uid))
66845 + msg2 = "file in non-root-owned directory";
66846 + else if (inode->i_mode & S_IWOTH)
66847 + msg2 = "file in world-writable directory";
66848 + else if (inode->i_mode & S_IWGRP)
66849 + msg2 = "file in group-writable directory";
66850 +
66851 + if (msg && msg2) {
66852 + char fullmsg[70] = {0};
66853 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66854 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66855 + return 0;
66856 + }
66857 + msg = NULL;
66858 +next_check:
66859 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66860 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66861 + return 1;
66862 +
66863 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66864 + msg = "directory not owned by user";
66865 + else if (inode->i_mode & S_IWOTH)
66866 + msg = "file in world-writable directory";
66867 + else if (inode->i_mode & S_IWGRP)
66868 + msg = "file in group-writable directory";
66869 +
66870 + if (msg) {
66871 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66872 + return 0;
66873 + }
66874 +#endif
66875 +#endif
66876 + return 1;
66877 +}
66878 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66879 new file mode 100644
66880 index 0000000..9f7b1ac
66881 --- /dev/null
66882 +++ b/grsecurity/grsum.c
66883 @@ -0,0 +1,61 @@
66884 +#include <linux/err.h>
66885 +#include <linux/kernel.h>
66886 +#include <linux/sched.h>
66887 +#include <linux/mm.h>
66888 +#include <linux/scatterlist.h>
66889 +#include <linux/crypto.h>
66890 +#include <linux/gracl.h>
66891 +
66892 +
66893 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66894 +#error "crypto and sha256 must be built into the kernel"
66895 +#endif
66896 +
66897 +int
66898 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66899 +{
66900 + char *p;
66901 + struct crypto_hash *tfm;
66902 + struct hash_desc desc;
66903 + struct scatterlist sg;
66904 + unsigned char temp_sum[GR_SHA_LEN];
66905 + volatile int retval = 0;
66906 + volatile int dummy = 0;
66907 + unsigned int i;
66908 +
66909 + sg_init_table(&sg, 1);
66910 +
66911 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66912 + if (IS_ERR(tfm)) {
66913 + /* should never happen, since sha256 should be built in */
66914 + return 1;
66915 + }
66916 +
66917 + desc.tfm = tfm;
66918 + desc.flags = 0;
66919 +
66920 + crypto_hash_init(&desc);
66921 +
66922 + p = salt;
66923 + sg_set_buf(&sg, p, GR_SALT_LEN);
66924 + crypto_hash_update(&desc, &sg, sg.length);
66925 +
66926 + p = entry->pw;
66927 + sg_set_buf(&sg, p, strlen(p));
66928 +
66929 + crypto_hash_update(&desc, &sg, sg.length);
66930 +
66931 + crypto_hash_final(&desc, temp_sum);
66932 +
66933 + memset(entry->pw, 0, GR_PW_LEN);
66934 +
66935 + for (i = 0; i < GR_SHA_LEN; i++)
66936 + if (sum[i] != temp_sum[i])
66937 + retval = 1;
66938 + else
66939 + dummy = 1; // waste a cycle
66940 +
66941 + crypto_free_hash(tfm);
66942 +
66943 + return retval;
66944 +}
66945 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66946 index 77ff547..181834f 100644
66947 --- a/include/asm-generic/4level-fixup.h
66948 +++ b/include/asm-generic/4level-fixup.h
66949 @@ -13,8 +13,10 @@
66950 #define pmd_alloc(mm, pud, address) \
66951 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66952 NULL: pmd_offset(pud, address))
66953 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66954
66955 #define pud_alloc(mm, pgd, address) (pgd)
66956 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66957 #define pud_offset(pgd, start) (pgd)
66958 #define pud_none(pud) 0
66959 #define pud_bad(pud) 0
66960 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66961 index b7babf0..04ad282 100644
66962 --- a/include/asm-generic/atomic-long.h
66963 +++ b/include/asm-generic/atomic-long.h
66964 @@ -22,6 +22,12 @@
66965
66966 typedef atomic64_t atomic_long_t;
66967
66968 +#ifdef CONFIG_PAX_REFCOUNT
66969 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66970 +#else
66971 +typedef atomic64_t atomic_long_unchecked_t;
66972 +#endif
66973 +
66974 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66975
66976 static inline long atomic_long_read(atomic_long_t *l)
66977 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66978 return (long)atomic64_read(v);
66979 }
66980
66981 +#ifdef CONFIG_PAX_REFCOUNT
66982 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66983 +{
66984 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66985 +
66986 + return (long)atomic64_read_unchecked(v);
66987 +}
66988 +#endif
66989 +
66990 static inline void atomic_long_set(atomic_long_t *l, long i)
66991 {
66992 atomic64_t *v = (atomic64_t *)l;
66993 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66994 atomic64_set(v, i);
66995 }
66996
66997 +#ifdef CONFIG_PAX_REFCOUNT
66998 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66999 +{
67000 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67001 +
67002 + atomic64_set_unchecked(v, i);
67003 +}
67004 +#endif
67005 +
67006 static inline void atomic_long_inc(atomic_long_t *l)
67007 {
67008 atomic64_t *v = (atomic64_t *)l;
67009 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67010 atomic64_inc(v);
67011 }
67012
67013 +#ifdef CONFIG_PAX_REFCOUNT
67014 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67015 +{
67016 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67017 +
67018 + atomic64_inc_unchecked(v);
67019 +}
67020 +#endif
67021 +
67022 static inline void atomic_long_dec(atomic_long_t *l)
67023 {
67024 atomic64_t *v = (atomic64_t *)l;
67025 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67026 atomic64_dec(v);
67027 }
67028
67029 +#ifdef CONFIG_PAX_REFCOUNT
67030 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67031 +{
67032 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67033 +
67034 + atomic64_dec_unchecked(v);
67035 +}
67036 +#endif
67037 +
67038 static inline void atomic_long_add(long i, atomic_long_t *l)
67039 {
67040 atomic64_t *v = (atomic64_t *)l;
67041 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67042 atomic64_add(i, v);
67043 }
67044
67045 +#ifdef CONFIG_PAX_REFCOUNT
67046 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67047 +{
67048 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67049 +
67050 + atomic64_add_unchecked(i, v);
67051 +}
67052 +#endif
67053 +
67054 static inline void atomic_long_sub(long i, atomic_long_t *l)
67055 {
67056 atomic64_t *v = (atomic64_t *)l;
67057 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67058 atomic64_sub(i, v);
67059 }
67060
67061 +#ifdef CONFIG_PAX_REFCOUNT
67062 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67063 +{
67064 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67065 +
67066 + atomic64_sub_unchecked(i, v);
67067 +}
67068 +#endif
67069 +
67070 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67071 {
67072 atomic64_t *v = (atomic64_t *)l;
67073 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67074 return (long)atomic64_add_return(i, v);
67075 }
67076
67077 +#ifdef CONFIG_PAX_REFCOUNT
67078 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67079 +{
67080 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67081 +
67082 + return (long)atomic64_add_return_unchecked(i, v);
67083 +}
67084 +#endif
67085 +
67086 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67087 {
67088 atomic64_t *v = (atomic64_t *)l;
67089 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67090 return (long)atomic64_inc_return(v);
67091 }
67092
67093 +#ifdef CONFIG_PAX_REFCOUNT
67094 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67095 +{
67096 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67097 +
67098 + return (long)atomic64_inc_return_unchecked(v);
67099 +}
67100 +#endif
67101 +
67102 static inline long atomic_long_dec_return(atomic_long_t *l)
67103 {
67104 atomic64_t *v = (atomic64_t *)l;
67105 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67106
67107 typedef atomic_t atomic_long_t;
67108
67109 +#ifdef CONFIG_PAX_REFCOUNT
67110 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67111 +#else
67112 +typedef atomic_t atomic_long_unchecked_t;
67113 +#endif
67114 +
67115 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67116 static inline long atomic_long_read(atomic_long_t *l)
67117 {
67118 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67119 return (long)atomic_read(v);
67120 }
67121
67122 +#ifdef CONFIG_PAX_REFCOUNT
67123 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67124 +{
67125 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67126 +
67127 + return (long)atomic_read_unchecked(v);
67128 +}
67129 +#endif
67130 +
67131 static inline void atomic_long_set(atomic_long_t *l, long i)
67132 {
67133 atomic_t *v = (atomic_t *)l;
67134 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67135 atomic_set(v, i);
67136 }
67137
67138 +#ifdef CONFIG_PAX_REFCOUNT
67139 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67140 +{
67141 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67142 +
67143 + atomic_set_unchecked(v, i);
67144 +}
67145 +#endif
67146 +
67147 static inline void atomic_long_inc(atomic_long_t *l)
67148 {
67149 atomic_t *v = (atomic_t *)l;
67150 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67151 atomic_inc(v);
67152 }
67153
67154 +#ifdef CONFIG_PAX_REFCOUNT
67155 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67156 +{
67157 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67158 +
67159 + atomic_inc_unchecked(v);
67160 +}
67161 +#endif
67162 +
67163 static inline void atomic_long_dec(atomic_long_t *l)
67164 {
67165 atomic_t *v = (atomic_t *)l;
67166 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67167 atomic_dec(v);
67168 }
67169
67170 +#ifdef CONFIG_PAX_REFCOUNT
67171 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67172 +{
67173 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67174 +
67175 + atomic_dec_unchecked(v);
67176 +}
67177 +#endif
67178 +
67179 static inline void atomic_long_add(long i, atomic_long_t *l)
67180 {
67181 atomic_t *v = (atomic_t *)l;
67182 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67183 atomic_add(i, v);
67184 }
67185
67186 +#ifdef CONFIG_PAX_REFCOUNT
67187 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67188 +{
67189 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67190 +
67191 + atomic_add_unchecked(i, v);
67192 +}
67193 +#endif
67194 +
67195 static inline void atomic_long_sub(long i, atomic_long_t *l)
67196 {
67197 atomic_t *v = (atomic_t *)l;
67198 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67199 atomic_sub(i, v);
67200 }
67201
67202 +#ifdef CONFIG_PAX_REFCOUNT
67203 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67204 +{
67205 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67206 +
67207 + atomic_sub_unchecked(i, v);
67208 +}
67209 +#endif
67210 +
67211 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67212 {
67213 atomic_t *v = (atomic_t *)l;
67214 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67215 return (long)atomic_add_return(i, v);
67216 }
67217
67218 +#ifdef CONFIG_PAX_REFCOUNT
67219 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67220 +{
67221 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67222 +
67223 + return (long)atomic_add_return_unchecked(i, v);
67224 +}
67225 +
67226 +#endif
67227 +
67228 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67229 {
67230 atomic_t *v = (atomic_t *)l;
67231 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67232 return (long)atomic_inc_return(v);
67233 }
67234
67235 +#ifdef CONFIG_PAX_REFCOUNT
67236 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67237 +{
67238 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67239 +
67240 + return (long)atomic_inc_return_unchecked(v);
67241 +}
67242 +#endif
67243 +
67244 static inline long atomic_long_dec_return(atomic_long_t *l)
67245 {
67246 atomic_t *v = (atomic_t *)l;
67247 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67248
67249 #endif /* BITS_PER_LONG == 64 */
67250
67251 +#ifdef CONFIG_PAX_REFCOUNT
67252 +static inline void pax_refcount_needs_these_functions(void)
67253 +{
67254 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67255 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67256 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67257 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67258 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67259 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67260 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67261 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67262 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67263 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67264 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67265 +#ifdef CONFIG_X86
67266 + atomic_clear_mask_unchecked(0, NULL);
67267 + atomic_set_mask_unchecked(0, NULL);
67268 +#endif
67269 +
67270 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67271 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67272 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67273 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67274 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67275 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67276 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67277 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67278 +}
67279 +#else
67280 +#define atomic_read_unchecked(v) atomic_read(v)
67281 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67282 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67283 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67284 +#define atomic_inc_unchecked(v) atomic_inc(v)
67285 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67286 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67287 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67288 +#define atomic_dec_unchecked(v) atomic_dec(v)
67289 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67290 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67291 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67292 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67293 +
67294 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67295 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67296 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67297 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67298 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67299 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67300 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67301 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67302 +#endif
67303 +
67304 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67305 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67306 index 33bd2de..f31bff97 100644
67307 --- a/include/asm-generic/atomic.h
67308 +++ b/include/asm-generic/atomic.h
67309 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67310 * Atomically clears the bits set in @mask from @v
67311 */
67312 #ifndef atomic_clear_mask
67313 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67314 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67315 {
67316 unsigned long flags;
67317
67318 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67319 index b18ce4f..2ee2843 100644
67320 --- a/include/asm-generic/atomic64.h
67321 +++ b/include/asm-generic/atomic64.h
67322 @@ -16,6 +16,8 @@ typedef struct {
67323 long long counter;
67324 } atomic64_t;
67325
67326 +typedef atomic64_t atomic64_unchecked_t;
67327 +
67328 #define ATOMIC64_INIT(i) { (i) }
67329
67330 extern long long atomic64_read(const atomic64_t *v);
67331 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67332 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67333 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67334
67335 +#define atomic64_read_unchecked(v) atomic64_read(v)
67336 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67337 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67338 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67339 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67340 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67341 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67342 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67343 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67344 +
67345 #endif /* _ASM_GENERIC_ATOMIC64_H */
67346 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67347 index 1bfcfe5..e04c5c9 100644
67348 --- a/include/asm-generic/cache.h
67349 +++ b/include/asm-generic/cache.h
67350 @@ -6,7 +6,7 @@
67351 * cache lines need to provide their own cache.h.
67352 */
67353
67354 -#define L1_CACHE_SHIFT 5
67355 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67356 +#define L1_CACHE_SHIFT 5UL
67357 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67358
67359 #endif /* __ASM_GENERIC_CACHE_H */
67360 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67361 index 0d68a1e..b74a761 100644
67362 --- a/include/asm-generic/emergency-restart.h
67363 +++ b/include/asm-generic/emergency-restart.h
67364 @@ -1,7 +1,7 @@
67365 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67366 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67367
67368 -static inline void machine_emergency_restart(void)
67369 +static inline __noreturn void machine_emergency_restart(void)
67370 {
67371 machine_restart(NULL);
67372 }
67373 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67374 index 90f99c7..00ce236 100644
67375 --- a/include/asm-generic/kmap_types.h
67376 +++ b/include/asm-generic/kmap_types.h
67377 @@ -2,9 +2,9 @@
67378 #define _ASM_GENERIC_KMAP_TYPES_H
67379
67380 #ifdef __WITH_KM_FENCE
67381 -# define KM_TYPE_NR 41
67382 +# define KM_TYPE_NR 42
67383 #else
67384 -# define KM_TYPE_NR 20
67385 +# define KM_TYPE_NR 21
67386 #endif
67387
67388 #endif
67389 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67390 index 9ceb03b..62b0b8f 100644
67391 --- a/include/asm-generic/local.h
67392 +++ b/include/asm-generic/local.h
67393 @@ -23,24 +23,37 @@ typedef struct
67394 atomic_long_t a;
67395 } local_t;
67396
67397 +typedef struct {
67398 + atomic_long_unchecked_t a;
67399 +} local_unchecked_t;
67400 +
67401 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67402
67403 #define local_read(l) atomic_long_read(&(l)->a)
67404 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67405 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67406 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67407 #define local_inc(l) atomic_long_inc(&(l)->a)
67408 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67409 #define local_dec(l) atomic_long_dec(&(l)->a)
67410 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67411 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67412 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67413 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67414 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67415
67416 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67417 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67418 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67419 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67420 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67421 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67422 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67423 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67424 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67425
67426 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67427 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67428 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67429 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67430 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67431 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67432 index 725612b..9cc513a 100644
67433 --- a/include/asm-generic/pgtable-nopmd.h
67434 +++ b/include/asm-generic/pgtable-nopmd.h
67435 @@ -1,14 +1,19 @@
67436 #ifndef _PGTABLE_NOPMD_H
67437 #define _PGTABLE_NOPMD_H
67438
67439 -#ifndef __ASSEMBLY__
67440 -
67441 #include <asm-generic/pgtable-nopud.h>
67442
67443 -struct mm_struct;
67444 -
67445 #define __PAGETABLE_PMD_FOLDED
67446
67447 +#define PMD_SHIFT PUD_SHIFT
67448 +#define PTRS_PER_PMD 1
67449 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67450 +#define PMD_MASK (~(PMD_SIZE-1))
67451 +
67452 +#ifndef __ASSEMBLY__
67453 +
67454 +struct mm_struct;
67455 +
67456 /*
67457 * Having the pmd type consist of a pud gets the size right, and allows
67458 * us to conceptually access the pud entry that this pmd is folded into
67459 @@ -16,11 +21,6 @@ struct mm_struct;
67460 */
67461 typedef struct { pud_t pud; } pmd_t;
67462
67463 -#define PMD_SHIFT PUD_SHIFT
67464 -#define PTRS_PER_PMD 1
67465 -#define PMD_SIZE (1UL << PMD_SHIFT)
67466 -#define PMD_MASK (~(PMD_SIZE-1))
67467 -
67468 /*
67469 * The "pud_xxx()" functions here are trivial for a folded two-level
67470 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67471 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67472 index 810431d..0ec4804f 100644
67473 --- a/include/asm-generic/pgtable-nopud.h
67474 +++ b/include/asm-generic/pgtable-nopud.h
67475 @@ -1,10 +1,15 @@
67476 #ifndef _PGTABLE_NOPUD_H
67477 #define _PGTABLE_NOPUD_H
67478
67479 -#ifndef __ASSEMBLY__
67480 -
67481 #define __PAGETABLE_PUD_FOLDED
67482
67483 +#define PUD_SHIFT PGDIR_SHIFT
67484 +#define PTRS_PER_PUD 1
67485 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67486 +#define PUD_MASK (~(PUD_SIZE-1))
67487 +
67488 +#ifndef __ASSEMBLY__
67489 +
67490 /*
67491 * Having the pud type consist of a pgd gets the size right, and allows
67492 * us to conceptually access the pgd entry that this pud is folded into
67493 @@ -12,11 +17,6 @@
67494 */
67495 typedef struct { pgd_t pgd; } pud_t;
67496
67497 -#define PUD_SHIFT PGDIR_SHIFT
67498 -#define PTRS_PER_PUD 1
67499 -#define PUD_SIZE (1UL << PUD_SHIFT)
67500 -#define PUD_MASK (~(PUD_SIZE-1))
67501 -
67502 /*
67503 * The "pgd_xxx()" functions here are trivial for a folded two-level
67504 * setup: the pud is never bad, and a pud always exists (as it's folded
67505 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67506 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67507
67508 #define pgd_populate(mm, pgd, pud) do { } while (0)
67509 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67510 /*
67511 * (puds are folded into pgds so this doesn't get actually called,
67512 * but the define is needed for a generic inline function.)
67513 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67514 index a59ff51..2594a70 100644
67515 --- a/include/asm-generic/pgtable.h
67516 +++ b/include/asm-generic/pgtable.h
67517 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67518 }
67519 #endif /* CONFIG_NUMA_BALANCING */
67520
67521 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67522 +static inline unsigned long pax_open_kernel(void) { return 0; }
67523 +#endif
67524 +
67525 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67526 +static inline unsigned long pax_close_kernel(void) { return 0; }
67527 +#endif
67528 +
67529 #endif /* CONFIG_MMU */
67530
67531 #endif /* !__ASSEMBLY__ */
67532 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67533 index afa12c7..99d4da0 100644
67534 --- a/include/asm-generic/vmlinux.lds.h
67535 +++ b/include/asm-generic/vmlinux.lds.h
67536 @@ -245,6 +245,7 @@
67537 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67538 VMLINUX_SYMBOL(__start_rodata) = .; \
67539 *(.rodata) *(.rodata.*) \
67540 + *(.data..read_only) \
67541 *(__vermagic) /* Kernel version magic */ \
67542 . = ALIGN(8); \
67543 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67544 @@ -755,17 +756,18 @@
67545 * section in the linker script will go there too. @phdr should have
67546 * a leading colon.
67547 *
67548 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67549 + * Note that this macros defines per_cpu_load as an absolute symbol.
67550 * If there is no need to put the percpu section at a predetermined
67551 * address, use PERCPU_SECTION.
67552 */
67553 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67554 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67555 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67556 + per_cpu_load = .; \
67557 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67558 - LOAD_OFFSET) { \
67559 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67560 PERCPU_INPUT(cacheline) \
67561 } phdr \
67562 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67563 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67564
67565 /**
67566 * PERCPU_SECTION - define output section for percpu area, simple version
67567 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67568 index 418d270..bfd2794 100644
67569 --- a/include/crypto/algapi.h
67570 +++ b/include/crypto/algapi.h
67571 @@ -34,7 +34,7 @@ struct crypto_type {
67572 unsigned int maskclear;
67573 unsigned int maskset;
67574 unsigned int tfmsize;
67575 -};
67576 +} __do_const;
67577
67578 struct crypto_instance {
67579 struct crypto_alg alg;
67580 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67581 index f1ce786..086a7a5 100644
67582 --- a/include/drm/drmP.h
67583 +++ b/include/drm/drmP.h
67584 @@ -72,6 +72,7 @@
67585 #include <linux/workqueue.h>
67586 #include <linux/poll.h>
67587 #include <asm/pgalloc.h>
67588 +#include <asm/local.h>
67589 #include <drm/drm.h>
67590 #include <drm/drm_sarea.h>
67591
67592 @@ -296,10 +297,12 @@ do { \
67593 * \param cmd command.
67594 * \param arg argument.
67595 */
67596 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67597 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67598 + struct drm_file *file_priv);
67599 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67600 struct drm_file *file_priv);
67601
67602 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67603 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67604 unsigned long arg);
67605
67606 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67607 @@ -314,9 +317,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67608 struct drm_ioctl_desc {
67609 unsigned int cmd;
67610 int flags;
67611 - drm_ioctl_t *func;
67612 + drm_ioctl_t func;
67613 unsigned int cmd_drv;
67614 -};
67615 +} __do_const;
67616
67617 /**
67618 * Creates a driver or general drm_ioctl_desc array entry for the given
67619 @@ -1014,7 +1017,7 @@ struct drm_info_list {
67620 int (*show)(struct seq_file*, void*); /** show callback */
67621 u32 driver_features; /**< Required driver features for this entry */
67622 void *data;
67623 -};
67624 +} __do_const;
67625
67626 /**
67627 * debugfs node structure. This structure represents a debugfs file.
67628 @@ -1087,7 +1090,7 @@ struct drm_device {
67629
67630 /** \name Usage Counters */
67631 /*@{ */
67632 - int open_count; /**< Outstanding files open */
67633 + local_t open_count; /**< Outstanding files open */
67634 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67635 atomic_t vma_count; /**< Outstanding vma areas open */
67636 int buf_use; /**< Buffers in use -- cannot alloc */
67637 @@ -1098,7 +1101,7 @@ struct drm_device {
67638 /*@{ */
67639 unsigned long counters;
67640 enum drm_stat_type types[15];
67641 - atomic_t counts[15];
67642 + atomic_unchecked_t counts[15];
67643 /*@} */
67644
67645 struct list_head filelist;
67646 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67647 index f43d556..94d9343 100644
67648 --- a/include/drm/drm_crtc_helper.h
67649 +++ b/include/drm/drm_crtc_helper.h
67650 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67651 struct drm_connector *connector);
67652 /* disable encoder when not in use - more explicit than dpms off */
67653 void (*disable)(struct drm_encoder *encoder);
67654 -};
67655 +} __no_const;
67656
67657 /**
67658 * drm_connector_helper_funcs - helper operations for connectors
67659 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67660 index 72dcbe8..8db58d7 100644
67661 --- a/include/drm/ttm/ttm_memory.h
67662 +++ b/include/drm/ttm/ttm_memory.h
67663 @@ -48,7 +48,7 @@
67664
67665 struct ttm_mem_shrink {
67666 int (*do_shrink) (struct ttm_mem_shrink *);
67667 -};
67668 +} __no_const;
67669
67670 /**
67671 * struct ttm_mem_global - Global memory accounting structure.
67672 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67673 index 4b840e8..155d235 100644
67674 --- a/include/keys/asymmetric-subtype.h
67675 +++ b/include/keys/asymmetric-subtype.h
67676 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67677 /* Verify the signature on a key of this subtype (optional) */
67678 int (*verify_signature)(const struct key *key,
67679 const struct public_key_signature *sig);
67680 -};
67681 +} __do_const;
67682
67683 /**
67684 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67685 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67686 index c1da539..1dcec55 100644
67687 --- a/include/linux/atmdev.h
67688 +++ b/include/linux/atmdev.h
67689 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67690 #endif
67691
67692 struct k_atm_aal_stats {
67693 -#define __HANDLE_ITEM(i) atomic_t i
67694 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67695 __AAL_STAT_ITEMS
67696 #undef __HANDLE_ITEM
67697 };
67698 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67699 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67700 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67701 struct module *owner;
67702 -};
67703 +} __do_const ;
67704
67705 struct atmphy_ops {
67706 int (*start)(struct atm_dev *dev);
67707 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67708 index c3a0914..ec5d48a 100644
67709 --- a/include/linux/binfmts.h
67710 +++ b/include/linux/binfmts.h
67711 @@ -73,8 +73,9 @@ struct linux_binfmt {
67712 int (*load_binary)(struct linux_binprm *);
67713 int (*load_shlib)(struct file *);
67714 int (*core_dump)(struct coredump_params *cprm);
67715 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67716 unsigned long min_coredump; /* minimal dump size */
67717 -};
67718 +} __do_const;
67719
67720 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67721
67722 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67723 index 33f358f..7f2c27f 100644
67724 --- a/include/linux/blkdev.h
67725 +++ b/include/linux/blkdev.h
67726 @@ -1499,7 +1499,7 @@ struct block_device_operations {
67727 /* this callback is with swap_lock and sometimes page table lock held */
67728 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67729 struct module *owner;
67730 -};
67731 +} __do_const;
67732
67733 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67734 unsigned long);
67735 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67736 index 7c2e030..b72475d 100644
67737 --- a/include/linux/blktrace_api.h
67738 +++ b/include/linux/blktrace_api.h
67739 @@ -23,7 +23,7 @@ struct blk_trace {
67740 struct dentry *dir;
67741 struct dentry *dropped_file;
67742 struct dentry *msg_file;
67743 - atomic_t dropped;
67744 + atomic_unchecked_t dropped;
67745 };
67746
67747 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67748 diff --git a/include/linux/cache.h b/include/linux/cache.h
67749 index 4c57065..4307975 100644
67750 --- a/include/linux/cache.h
67751 +++ b/include/linux/cache.h
67752 @@ -16,6 +16,10 @@
67753 #define __read_mostly
67754 #endif
67755
67756 +#ifndef __read_only
67757 +#define __read_only __read_mostly
67758 +#endif
67759 +
67760 #ifndef ____cacheline_aligned
67761 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67762 #endif
67763 diff --git a/include/linux/capability.h b/include/linux/capability.h
67764 index d9a4f7f4..19f77d6 100644
67765 --- a/include/linux/capability.h
67766 +++ b/include/linux/capability.h
67767 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
67768 extern bool nsown_capable(int cap);
67769 extern bool inode_capable(const struct inode *inode, int cap);
67770 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
67771 +extern bool capable_nolog(int cap);
67772 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67773 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67774
67775 /* audit system wants to get cap info from files as well */
67776 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67777
67778 +extern int is_privileged_binary(const struct dentry *dentry);
67779 +
67780 #endif /* !_LINUX_CAPABILITY_H */
67781 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67782 index 8609d57..86e4d79 100644
67783 --- a/include/linux/cdrom.h
67784 +++ b/include/linux/cdrom.h
67785 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67786
67787 /* driver specifications */
67788 const int capability; /* capability flags */
67789 - int n_minors; /* number of active minor devices */
67790 /* handle uniform packets for scsi type devices (scsi,atapi) */
67791 int (*generic_packet) (struct cdrom_device_info *,
67792 struct packet_command *);
67793 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67794 index 42e55de..1cd0e66 100644
67795 --- a/include/linux/cleancache.h
67796 +++ b/include/linux/cleancache.h
67797 @@ -31,7 +31,7 @@ struct cleancache_ops {
67798 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67799 void (*invalidate_inode)(int, struct cleancache_filekey);
67800 void (*invalidate_fs)(int);
67801 -};
67802 +} __no_const;
67803
67804 extern struct cleancache_ops
67805 cleancache_register_ops(struct cleancache_ops *ops);
67806 diff --git a/include/linux/compat.h b/include/linux/compat.h
67807 index 377cd8c..2479845 100644
67808 --- a/include/linux/compat.h
67809 +++ b/include/linux/compat.h
67810 @@ -332,14 +332,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67811 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67812 int version, void __user *uptr);
67813 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67814 - void __user *uptr);
67815 + void __user *uptr) __intentional_overflow(0);
67816 #else
67817 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67818 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67819 compat_ssize_t msgsz, int msgflg);
67820 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67821 compat_ssize_t msgsz, long msgtyp, int msgflg);
67822 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67823 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67824 #endif
67825 long compat_sys_msgctl(int first, int second, void __user *uptr);
67826 long compat_sys_shmctl(int first, int second, void __user *uptr);
67827 @@ -442,7 +442,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67828 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67829 compat_ulong_t addr, compat_ulong_t data);
67830 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67831 - compat_long_t addr, compat_long_t data);
67832 + compat_ulong_t addr, compat_ulong_t data);
67833
67834 /*
67835 * epoll (fs/eventpoll.c) compat bits follow ...
67836 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67837 index 68b162d..660f5f0 100644
67838 --- a/include/linux/compiler-gcc4.h
67839 +++ b/include/linux/compiler-gcc4.h
67840 @@ -39,9 +39,29 @@
67841 # define __compiletime_warning(message) __attribute__((warning(message)))
67842 # define __compiletime_error(message) __attribute__((error(message)))
67843 #endif /* __CHECKER__ */
67844 +
67845 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67846 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67847 +#define __bos0(ptr) __bos((ptr), 0)
67848 +#define __bos1(ptr) __bos((ptr), 1)
67849 #endif /* GCC_VERSION >= 40300 */
67850
67851 #if GCC_VERSION >= 40500
67852 +
67853 +#ifdef CONSTIFY_PLUGIN
67854 +#define __no_const __attribute__((no_const))
67855 +#define __do_const __attribute__((do_const))
67856 +#endif
67857 +
67858 +#ifdef SIZE_OVERFLOW_PLUGIN
67859 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67860 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67861 +#endif
67862 +
67863 +#ifdef LATENT_ENTROPY_PLUGIN
67864 +#define __latent_entropy __attribute__((latent_entropy))
67865 +#endif
67866 +
67867 /*
67868 * Mark a position in code as unreachable. This can be used to
67869 * suppress control flow warnings after asm blocks that transfer
67870 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67871 index 10b8f23..5e0b083 100644
67872 --- a/include/linux/compiler.h
67873 +++ b/include/linux/compiler.h
67874 @@ -5,11 +5,14 @@
67875
67876 #ifdef __CHECKER__
67877 # define __user __attribute__((noderef, address_space(1)))
67878 +# define __force_user __force __user
67879 # define __kernel __attribute__((address_space(0)))
67880 +# define __force_kernel __force __kernel
67881 # define __safe __attribute__((safe))
67882 # define __force __attribute__((force))
67883 # define __nocast __attribute__((nocast))
67884 # define __iomem __attribute__((noderef, address_space(2)))
67885 +# define __force_iomem __force __iomem
67886 # define __must_hold(x) __attribute__((context(x,1,1)))
67887 # define __acquires(x) __attribute__((context(x,0,1)))
67888 # define __releases(x) __attribute__((context(x,1,0)))
67889 @@ -17,20 +20,37 @@
67890 # define __release(x) __context__(x,-1)
67891 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67892 # define __percpu __attribute__((noderef, address_space(3)))
67893 +# define __force_percpu __force __percpu
67894 #ifdef CONFIG_SPARSE_RCU_POINTER
67895 # define __rcu __attribute__((noderef, address_space(4)))
67896 +# define __force_rcu __force __rcu
67897 #else
67898 # define __rcu
67899 +# define __force_rcu
67900 #endif
67901 extern void __chk_user_ptr(const volatile void __user *);
67902 extern void __chk_io_ptr(const volatile void __iomem *);
67903 #else
67904 -# define __user
67905 -# define __kernel
67906 +# ifdef CHECKER_PLUGIN
67907 +//# define __user
67908 +//# define __force_user
67909 +//# define __kernel
67910 +//# define __force_kernel
67911 +# else
67912 +# ifdef STRUCTLEAK_PLUGIN
67913 +# define __user __attribute__((user))
67914 +# else
67915 +# define __user
67916 +# endif
67917 +# define __force_user
67918 +# define __kernel
67919 +# define __force_kernel
67920 +# endif
67921 # define __safe
67922 # define __force
67923 # define __nocast
67924 # define __iomem
67925 +# define __force_iomem
67926 # define __chk_user_ptr(x) (void)0
67927 # define __chk_io_ptr(x) (void)0
67928 # define __builtin_warning(x, y...) (1)
67929 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67930 # define __release(x) (void)0
67931 # define __cond_lock(x,c) (c)
67932 # define __percpu
67933 +# define __force_percpu
67934 # define __rcu
67935 +# define __force_rcu
67936 #endif
67937
67938 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67939 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67940 # define __attribute_const__ /* unimplemented */
67941 #endif
67942
67943 +#ifndef __no_const
67944 +# define __no_const
67945 +#endif
67946 +
67947 +#ifndef __do_const
67948 +# define __do_const
67949 +#endif
67950 +
67951 +#ifndef __size_overflow
67952 +# define __size_overflow(...)
67953 +#endif
67954 +
67955 +#ifndef __intentional_overflow
67956 +# define __intentional_overflow(...)
67957 +#endif
67958 +
67959 +#ifndef __latent_entropy
67960 +# define __latent_entropy
67961 +#endif
67962 +
67963 /*
67964 * Tell gcc if a function is cold. The compiler will assume any path
67965 * directly leading to the call is unlikely.
67966 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67967 #define __cold
67968 #endif
67969
67970 +#ifndef __alloc_size
67971 +#define __alloc_size(...)
67972 +#endif
67973 +
67974 +#ifndef __bos
67975 +#define __bos(ptr, arg)
67976 +#endif
67977 +
67978 +#ifndef __bos0
67979 +#define __bos0(ptr)
67980 +#endif
67981 +
67982 +#ifndef __bos1
67983 +#define __bos1(ptr)
67984 +#endif
67985 +
67986 /* Simple shorthand for a section definition */
67987 #ifndef __section
67988 # define __section(S) __attribute__ ((__section__(#S)))
67989 @@ -349,6 +407,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67990 * use is to mediate communication between process-level code and irq/NMI
67991 * handlers, all running on the same CPU.
67992 */
67993 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67994 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67995 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67996
67997 #endif /* __LINUX_COMPILER_H */
67998 diff --git a/include/linux/completion.h b/include/linux/completion.h
67999 index 33f0280..35c6568 100644
68000 --- a/include/linux/completion.h
68001 +++ b/include/linux/completion.h
68002 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
68003 extern void wait_for_completion(struct completion *);
68004 extern void wait_for_completion_io(struct completion *);
68005 extern int wait_for_completion_interruptible(struct completion *x);
68006 -extern int wait_for_completion_killable(struct completion *x);
68007 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68008 extern unsigned long wait_for_completion_timeout(struct completion *x,
68009 unsigned long timeout);
68010 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
68011 unsigned long timeout);
68012 extern long wait_for_completion_interruptible_timeout(
68013 - struct completion *x, unsigned long timeout);
68014 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68015 extern long wait_for_completion_killable_timeout(
68016 - struct completion *x, unsigned long timeout);
68017 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68018 extern bool try_wait_for_completion(struct completion *x);
68019 extern bool completion_done(struct completion *x);
68020
68021 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68022 index 34025df..d94bbbc 100644
68023 --- a/include/linux/configfs.h
68024 +++ b/include/linux/configfs.h
68025 @@ -125,7 +125,7 @@ struct configfs_attribute {
68026 const char *ca_name;
68027 struct module *ca_owner;
68028 umode_t ca_mode;
68029 -};
68030 +} __do_const;
68031
68032 /*
68033 * Users often need to create attribute structures for their configurable
68034 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68035 index 714e792..e6130d9 100644
68036 --- a/include/linux/cpu.h
68037 +++ b/include/linux/cpu.h
68038 @@ -115,7 +115,7 @@ enum {
68039 /* Need to know about CPUs going up/down? */
68040 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68041 #define cpu_notifier(fn, pri) { \
68042 - static struct notifier_block fn##_nb __cpuinitdata = \
68043 + static struct notifier_block fn##_nb = \
68044 { .notifier_call = fn, .priority = pri }; \
68045 register_cpu_notifier(&fn##_nb); \
68046 }
68047 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68048 index a22944c..4e695fe 100644
68049 --- a/include/linux/cpufreq.h
68050 +++ b/include/linux/cpufreq.h
68051 @@ -252,7 +252,7 @@ struct cpufreq_driver {
68052 int (*suspend) (struct cpufreq_policy *policy);
68053 int (*resume) (struct cpufreq_policy *policy);
68054 struct freq_attr **attr;
68055 -};
68056 +} __do_const;
68057
68058 /* flags */
68059
68060 @@ -311,6 +311,7 @@ struct global_attr {
68061 ssize_t (*store)(struct kobject *a, struct attribute *b,
68062 const char *c, size_t count);
68063 };
68064 +typedef struct global_attr __no_const global_attr_no_const;
68065
68066 #define define_one_global_ro(_name) \
68067 static struct global_attr _name = \
68068 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68069 index 480c14d..552896f 100644
68070 --- a/include/linux/cpuidle.h
68071 +++ b/include/linux/cpuidle.h
68072 @@ -52,7 +52,8 @@ struct cpuidle_state {
68073 int index);
68074
68075 int (*enter_dead) (struct cpuidle_device *dev, int index);
68076 -};
68077 +} __do_const;
68078 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68079
68080 /* Idle State Flags */
68081 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68082 @@ -194,7 +195,7 @@ struct cpuidle_governor {
68083 void (*reflect) (struct cpuidle_device *dev, int index);
68084
68085 struct module *owner;
68086 -};
68087 +} __do_const;
68088
68089 #ifdef CONFIG_CPU_IDLE
68090
68091 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68092 index 0325602..5e9feff 100644
68093 --- a/include/linux/cpumask.h
68094 +++ b/include/linux/cpumask.h
68095 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68096 }
68097
68098 /* Valid inputs for n are -1 and 0. */
68099 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68100 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68101 {
68102 return n+1;
68103 }
68104
68105 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68106 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68107 {
68108 return n+1;
68109 }
68110
68111 -static inline unsigned int cpumask_next_and(int n,
68112 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68113 const struct cpumask *srcp,
68114 const struct cpumask *andp)
68115 {
68116 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68117 *
68118 * Returns >= nr_cpu_ids if no further cpus set.
68119 */
68120 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68121 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68122 {
68123 /* -1 is a legal arg here. */
68124 if (n != -1)
68125 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68126 *
68127 * Returns >= nr_cpu_ids if no further cpus unset.
68128 */
68129 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68130 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68131 {
68132 /* -1 is a legal arg here. */
68133 if (n != -1)
68134 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68135 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68136 }
68137
68138 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68139 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68140 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68141
68142 /**
68143 diff --git a/include/linux/cred.h b/include/linux/cred.h
68144 index 04421e8..6bce4ef 100644
68145 --- a/include/linux/cred.h
68146 +++ b/include/linux/cred.h
68147 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68148 static inline void validate_process_creds(void)
68149 {
68150 }
68151 +static inline void validate_task_creds(struct task_struct *task)
68152 +{
68153 +}
68154 #endif
68155
68156 /**
68157 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68158 index b92eadf..b4ecdc1 100644
68159 --- a/include/linux/crypto.h
68160 +++ b/include/linux/crypto.h
68161 @@ -373,7 +373,7 @@ struct cipher_tfm {
68162 const u8 *key, unsigned int keylen);
68163 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68164 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68165 -};
68166 +} __no_const;
68167
68168 struct hash_tfm {
68169 int (*init)(struct hash_desc *desc);
68170 @@ -394,13 +394,13 @@ struct compress_tfm {
68171 int (*cot_decompress)(struct crypto_tfm *tfm,
68172 const u8 *src, unsigned int slen,
68173 u8 *dst, unsigned int *dlen);
68174 -};
68175 +} __no_const;
68176
68177 struct rng_tfm {
68178 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68179 unsigned int dlen);
68180 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68181 -};
68182 +} __no_const;
68183
68184 #define crt_ablkcipher crt_u.ablkcipher
68185 #define crt_aead crt_u.aead
68186 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68187 index 8acfe31..6ffccd63 100644
68188 --- a/include/linux/ctype.h
68189 +++ b/include/linux/ctype.h
68190 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68191 * Fast implementation of tolower() for internal usage. Do not use in your
68192 * code.
68193 */
68194 -static inline char _tolower(const char c)
68195 +static inline unsigned char _tolower(const unsigned char c)
68196 {
68197 return c | 0x20;
68198 }
68199 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68200 index 7925bf0..d5143d2 100644
68201 --- a/include/linux/decompress/mm.h
68202 +++ b/include/linux/decompress/mm.h
68203 @@ -77,7 +77,7 @@ static void free(void *where)
68204 * warnings when not needed (indeed large_malloc / large_free are not
68205 * needed by inflate */
68206
68207 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68208 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68209 #define free(a) kfree(a)
68210
68211 #define large_malloc(a) vmalloc(a)
68212 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68213 index fe8c447..bdc1f33 100644
68214 --- a/include/linux/devfreq.h
68215 +++ b/include/linux/devfreq.h
68216 @@ -114,7 +114,7 @@ struct devfreq_governor {
68217 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68218 int (*event_handler)(struct devfreq *devfreq,
68219 unsigned int event, void *data);
68220 -};
68221 +} __do_const;
68222
68223 /**
68224 * struct devfreq - Device devfreq structure
68225 diff --git a/include/linux/device.h b/include/linux/device.h
68226 index 9d6464e..8a5cc92 100644
68227 --- a/include/linux/device.h
68228 +++ b/include/linux/device.h
68229 @@ -295,7 +295,7 @@ struct subsys_interface {
68230 struct list_head node;
68231 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68232 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68233 -};
68234 +} __do_const;
68235
68236 int subsys_interface_register(struct subsys_interface *sif);
68237 void subsys_interface_unregister(struct subsys_interface *sif);
68238 @@ -475,7 +475,7 @@ struct device_type {
68239 void (*release)(struct device *dev);
68240
68241 const struct dev_pm_ops *pm;
68242 -};
68243 +} __do_const;
68244
68245 /* interface for exporting device attributes */
68246 struct device_attribute {
68247 @@ -485,11 +485,12 @@ struct device_attribute {
68248 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68249 const char *buf, size_t count);
68250 };
68251 +typedef struct device_attribute __no_const device_attribute_no_const;
68252
68253 struct dev_ext_attribute {
68254 struct device_attribute attr;
68255 void *var;
68256 -};
68257 +} __do_const;
68258
68259 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68260 char *buf);
68261 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68262 index 94af418..b1ca7a2 100644
68263 --- a/include/linux/dma-mapping.h
68264 +++ b/include/linux/dma-mapping.h
68265 @@ -54,7 +54,7 @@ struct dma_map_ops {
68266 u64 (*get_required_mask)(struct device *dev);
68267 #endif
68268 int is_phys;
68269 -};
68270 +} __do_const;
68271
68272 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68273
68274 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68275 index 91ac8da..a841318 100644
68276 --- a/include/linux/dmaengine.h
68277 +++ b/include/linux/dmaengine.h
68278 @@ -1034,9 +1034,9 @@ struct dma_pinned_list {
68279 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68280 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68281
68282 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68283 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68284 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68285 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68286 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68287 struct dma_pinned_list *pinned_list, struct page *page,
68288 unsigned int offset, size_t len);
68289
68290 diff --git a/include/linux/efi.h b/include/linux/efi.h
68291 index 3d7df3d..301f024 100644
68292 --- a/include/linux/efi.h
68293 +++ b/include/linux/efi.h
68294 @@ -740,6 +740,7 @@ struct efivar_operations {
68295 efi_set_variable_t *set_variable;
68296 efi_query_variable_store_t *query_variable_store;
68297 };
68298 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68299
68300 struct efivars {
68301 /*
68302 diff --git a/include/linux/elf.h b/include/linux/elf.h
68303 index 40a3c0e..4c45a38 100644
68304 --- a/include/linux/elf.h
68305 +++ b/include/linux/elf.h
68306 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
68307 #define elf_note elf32_note
68308 #define elf_addr_t Elf32_Off
68309 #define Elf_Half Elf32_Half
68310 +#define elf_dyn Elf32_Dyn
68311
68312 #else
68313
68314 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
68315 #define elf_note elf64_note
68316 #define elf_addr_t Elf64_Off
68317 #define Elf_Half Elf64_Half
68318 +#define elf_dyn Elf64_Dyn
68319
68320 #endif
68321
68322 diff --git a/include/linux/err.h b/include/linux/err.h
68323 index f2edce2..cc2082c 100644
68324 --- a/include/linux/err.h
68325 +++ b/include/linux/err.h
68326 @@ -19,12 +19,12 @@
68327
68328 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68329
68330 -static inline void * __must_check ERR_PTR(long error)
68331 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68332 {
68333 return (void *) error;
68334 }
68335
68336 -static inline long __must_check PTR_ERR(const void *ptr)
68337 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68338 {
68339 return (long) ptr;
68340 }
68341 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68342 index fcb51c8..bdafcf6 100644
68343 --- a/include/linux/extcon.h
68344 +++ b/include/linux/extcon.h
68345 @@ -134,7 +134,7 @@ struct extcon_dev {
68346 /* /sys/class/extcon/.../mutually_exclusive/... */
68347 struct attribute_group attr_g_muex;
68348 struct attribute **attrs_muex;
68349 - struct device_attribute *d_attrs_muex;
68350 + device_attribute_no_const *d_attrs_muex;
68351 };
68352
68353 /**
68354 diff --git a/include/linux/fb.h b/include/linux/fb.h
68355 index 58b9860..58e5516 100644
68356 --- a/include/linux/fb.h
68357 +++ b/include/linux/fb.h
68358 @@ -304,7 +304,7 @@ struct fb_ops {
68359 /* called at KDB enter and leave time to prepare the console */
68360 int (*fb_debug_enter)(struct fb_info *info);
68361 int (*fb_debug_leave)(struct fb_info *info);
68362 -};
68363 +} __do_const;
68364
68365 #ifdef CONFIG_FB_TILEBLITTING
68366 #define FB_TILE_CURSOR_NONE 0
68367 diff --git a/include/linux/filter.h b/include/linux/filter.h
68368 index c45eabc..baa0be5 100644
68369 --- a/include/linux/filter.h
68370 +++ b/include/linux/filter.h
68371 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68372
68373 struct sk_buff;
68374 struct sock;
68375 +struct bpf_jit_work;
68376
68377 struct sk_filter
68378 {
68379 @@ -27,6 +28,9 @@ struct sk_filter
68380 unsigned int len; /* Number of filter blocks */
68381 unsigned int (*bpf_func)(const struct sk_buff *skb,
68382 const struct sock_filter *filter);
68383 +#ifdef CONFIG_BPF_JIT
68384 + struct bpf_jit_work *work;
68385 +#endif
68386 struct rcu_head rcu;
68387 struct sock_filter insns[0];
68388 };
68389 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68390 index 3044254..9767f41 100644
68391 --- a/include/linux/frontswap.h
68392 +++ b/include/linux/frontswap.h
68393 @@ -11,7 +11,7 @@ struct frontswap_ops {
68394 int (*load)(unsigned, pgoff_t, struct page *);
68395 void (*invalidate_page)(unsigned, pgoff_t);
68396 void (*invalidate_area)(unsigned);
68397 -};
68398 +} __no_const;
68399
68400 extern bool frontswap_enabled;
68401 extern struct frontswap_ops
68402 diff --git a/include/linux/fs.h b/include/linux/fs.h
68403 index 2c28271..8d3d74c 100644
68404 --- a/include/linux/fs.h
68405 +++ b/include/linux/fs.h
68406 @@ -1541,7 +1541,8 @@ struct file_operations {
68407 long (*fallocate)(struct file *file, int mode, loff_t offset,
68408 loff_t len);
68409 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68410 -};
68411 +} __do_const;
68412 +typedef struct file_operations __no_const file_operations_no_const;
68413
68414 struct inode_operations {
68415 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68416 @@ -2672,4 +2673,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68417 inode->i_flags |= S_NOSEC;
68418 }
68419
68420 +static inline bool is_sidechannel_device(const struct inode *inode)
68421 +{
68422 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68423 + umode_t mode = inode->i_mode;
68424 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68425 +#else
68426 + return false;
68427 +#endif
68428 +}
68429 +
68430 #endif /* _LINUX_FS_H */
68431 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68432 index 2b93a9a..855d94a 100644
68433 --- a/include/linux/fs_struct.h
68434 +++ b/include/linux/fs_struct.h
68435 @@ -6,7 +6,7 @@
68436 #include <linux/seqlock.h>
68437
68438 struct fs_struct {
68439 - int users;
68440 + atomic_t users;
68441 spinlock_t lock;
68442 seqcount_t seq;
68443 int umask;
68444 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68445 index 5dfa0aa..6acf322 100644
68446 --- a/include/linux/fscache-cache.h
68447 +++ b/include/linux/fscache-cache.h
68448 @@ -112,7 +112,7 @@ struct fscache_operation {
68449 fscache_operation_release_t release;
68450 };
68451
68452 -extern atomic_t fscache_op_debug_id;
68453 +extern atomic_unchecked_t fscache_op_debug_id;
68454 extern void fscache_op_work_func(struct work_struct *work);
68455
68456 extern void fscache_enqueue_operation(struct fscache_operation *);
68457 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68458 INIT_WORK(&op->work, fscache_op_work_func);
68459 atomic_set(&op->usage, 1);
68460 op->state = FSCACHE_OP_ST_INITIALISED;
68461 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68462 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68463 op->processor = processor;
68464 op->release = release;
68465 INIT_LIST_HEAD(&op->pend_link);
68466 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68467 index 7a08623..4c07b0f 100644
68468 --- a/include/linux/fscache.h
68469 +++ b/include/linux/fscache.h
68470 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68471 * - this is mandatory for any object that may have data
68472 */
68473 void (*now_uncached)(void *cookie_netfs_data);
68474 -};
68475 +} __do_const;
68476
68477 /*
68478 * fscache cached network filesystem type
68479 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68480 index a78680a..87bd73e 100644
68481 --- a/include/linux/fsnotify.h
68482 +++ b/include/linux/fsnotify.h
68483 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68484 struct inode *inode = path->dentry->d_inode;
68485 __u32 mask = FS_ACCESS;
68486
68487 + if (is_sidechannel_device(inode))
68488 + return;
68489 +
68490 if (S_ISDIR(inode->i_mode))
68491 mask |= FS_ISDIR;
68492
68493 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68494 struct inode *inode = path->dentry->d_inode;
68495 __u32 mask = FS_MODIFY;
68496
68497 + if (is_sidechannel_device(inode))
68498 + return;
68499 +
68500 if (S_ISDIR(inode->i_mode))
68501 mask |= FS_ISDIR;
68502
68503 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68504 */
68505 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68506 {
68507 - return kstrdup(name, GFP_KERNEL);
68508 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68509 }
68510
68511 /*
68512 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68513 index 13a54d0..c6ce2a7 100644
68514 --- a/include/linux/ftrace_event.h
68515 +++ b/include/linux/ftrace_event.h
68516 @@ -274,7 +274,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68517 extern int trace_add_event_call(struct ftrace_event_call *call);
68518 extern void trace_remove_event_call(struct ftrace_event_call *call);
68519
68520 -#define is_signed_type(type) (((type)(-1)) < (type)0)
68521 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68522
68523 int trace_set_clr_event(const char *system, const char *event, int set);
68524
68525 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68526 index 9f3c275..911b591 100644
68527 --- a/include/linux/genhd.h
68528 +++ b/include/linux/genhd.h
68529 @@ -194,7 +194,7 @@ struct gendisk {
68530 struct kobject *slave_dir;
68531
68532 struct timer_rand_state *random;
68533 - atomic_t sync_io; /* RAID */
68534 + atomic_unchecked_t sync_io; /* RAID */
68535 struct disk_events *ev;
68536 #ifdef CONFIG_BLK_DEV_INTEGRITY
68537 struct blk_integrity *integrity;
68538 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68539 index 023bc34..b02b46a 100644
68540 --- a/include/linux/genl_magic_func.h
68541 +++ b/include/linux/genl_magic_func.h
68542 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68543 },
68544
68545 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68546 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68547 +static struct genl_ops ZZZ_genl_ops[] = {
68548 #include GENL_MAGIC_INCLUDE_FILE
68549 };
68550
68551 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68552 index 0f615eb..5c3832f 100644
68553 --- a/include/linux/gfp.h
68554 +++ b/include/linux/gfp.h
68555 @@ -35,6 +35,13 @@ struct vm_area_struct;
68556 #define ___GFP_NO_KSWAPD 0x400000u
68557 #define ___GFP_OTHER_NODE 0x800000u
68558 #define ___GFP_WRITE 0x1000000u
68559 +
68560 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68561 +#define ___GFP_USERCOPY 0x2000000u
68562 +#else
68563 +#define ___GFP_USERCOPY 0
68564 +#endif
68565 +
68566 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68567
68568 /*
68569 @@ -92,6 +99,7 @@ struct vm_area_struct;
68570 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68571 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68572 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68573 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68574
68575 /*
68576 * This may seem redundant, but it's a way of annotating false positives vs.
68577 @@ -99,7 +107,7 @@ struct vm_area_struct;
68578 */
68579 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68580
68581 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68582 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68583 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68584
68585 /* This equals 0, but use constants in case they ever change */
68586 @@ -153,6 +161,8 @@ struct vm_area_struct;
68587 /* 4GB DMA on some platforms */
68588 #define GFP_DMA32 __GFP_DMA32
68589
68590 +#define GFP_USERCOPY __GFP_USERCOPY
68591 +
68592 /* Convert GFP flags to their corresponding migrate type */
68593 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68594 {
68595 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68596 new file mode 100644
68597 index 0000000..ebe6d72
68598 --- /dev/null
68599 +++ b/include/linux/gracl.h
68600 @@ -0,0 +1,319 @@
68601 +#ifndef GR_ACL_H
68602 +#define GR_ACL_H
68603 +
68604 +#include <linux/grdefs.h>
68605 +#include <linux/resource.h>
68606 +#include <linux/capability.h>
68607 +#include <linux/dcache.h>
68608 +#include <asm/resource.h>
68609 +
68610 +/* Major status information */
68611 +
68612 +#define GR_VERSION "grsecurity 2.9.1"
68613 +#define GRSECURITY_VERSION 0x2901
68614 +
68615 +enum {
68616 + GR_SHUTDOWN = 0,
68617 + GR_ENABLE = 1,
68618 + GR_SPROLE = 2,
68619 + GR_RELOAD = 3,
68620 + GR_SEGVMOD = 4,
68621 + GR_STATUS = 5,
68622 + GR_UNSPROLE = 6,
68623 + GR_PASSSET = 7,
68624 + GR_SPROLEPAM = 8,
68625 +};
68626 +
68627 +/* Password setup definitions
68628 + * kernel/grhash.c */
68629 +enum {
68630 + GR_PW_LEN = 128,
68631 + GR_SALT_LEN = 16,
68632 + GR_SHA_LEN = 32,
68633 +};
68634 +
68635 +enum {
68636 + GR_SPROLE_LEN = 64,
68637 +};
68638 +
68639 +enum {
68640 + GR_NO_GLOB = 0,
68641 + GR_REG_GLOB,
68642 + GR_CREATE_GLOB
68643 +};
68644 +
68645 +#define GR_NLIMITS 32
68646 +
68647 +/* Begin Data Structures */
68648 +
68649 +struct sprole_pw {
68650 + unsigned char *rolename;
68651 + unsigned char salt[GR_SALT_LEN];
68652 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68653 +};
68654 +
68655 +struct name_entry {
68656 + __u32 key;
68657 + ino_t inode;
68658 + dev_t device;
68659 + char *name;
68660 + __u16 len;
68661 + __u8 deleted;
68662 + struct name_entry *prev;
68663 + struct name_entry *next;
68664 +};
68665 +
68666 +struct inodev_entry {
68667 + struct name_entry *nentry;
68668 + struct inodev_entry *prev;
68669 + struct inodev_entry *next;
68670 +};
68671 +
68672 +struct acl_role_db {
68673 + struct acl_role_label **r_hash;
68674 + __u32 r_size;
68675 +};
68676 +
68677 +struct inodev_db {
68678 + struct inodev_entry **i_hash;
68679 + __u32 i_size;
68680 +};
68681 +
68682 +struct name_db {
68683 + struct name_entry **n_hash;
68684 + __u32 n_size;
68685 +};
68686 +
68687 +struct crash_uid {
68688 + uid_t uid;
68689 + unsigned long expires;
68690 +};
68691 +
68692 +struct gr_hash_struct {
68693 + void **table;
68694 + void **nametable;
68695 + void *first;
68696 + __u32 table_size;
68697 + __u32 used_size;
68698 + int type;
68699 +};
68700 +
68701 +/* Userspace Grsecurity ACL data structures */
68702 +
68703 +struct acl_subject_label {
68704 + char *filename;
68705 + ino_t inode;
68706 + dev_t device;
68707 + __u32 mode;
68708 + kernel_cap_t cap_mask;
68709 + kernel_cap_t cap_lower;
68710 + kernel_cap_t cap_invert_audit;
68711 +
68712 + struct rlimit res[GR_NLIMITS];
68713 + __u32 resmask;
68714 +
68715 + __u8 user_trans_type;
68716 + __u8 group_trans_type;
68717 + uid_t *user_transitions;
68718 + gid_t *group_transitions;
68719 + __u16 user_trans_num;
68720 + __u16 group_trans_num;
68721 +
68722 + __u32 sock_families[2];
68723 + __u32 ip_proto[8];
68724 + __u32 ip_type;
68725 + struct acl_ip_label **ips;
68726 + __u32 ip_num;
68727 + __u32 inaddr_any_override;
68728 +
68729 + __u32 crashes;
68730 + unsigned long expires;
68731 +
68732 + struct acl_subject_label *parent_subject;
68733 + struct gr_hash_struct *hash;
68734 + struct acl_subject_label *prev;
68735 + struct acl_subject_label *next;
68736 +
68737 + struct acl_object_label **obj_hash;
68738 + __u32 obj_hash_size;
68739 + __u16 pax_flags;
68740 +};
68741 +
68742 +struct role_allowed_ip {
68743 + __u32 addr;
68744 + __u32 netmask;
68745 +
68746 + struct role_allowed_ip *prev;
68747 + struct role_allowed_ip *next;
68748 +};
68749 +
68750 +struct role_transition {
68751 + char *rolename;
68752 +
68753 + struct role_transition *prev;
68754 + struct role_transition *next;
68755 +};
68756 +
68757 +struct acl_role_label {
68758 + char *rolename;
68759 + uid_t uidgid;
68760 + __u16 roletype;
68761 +
68762 + __u16 auth_attempts;
68763 + unsigned long expires;
68764 +
68765 + struct acl_subject_label *root_label;
68766 + struct gr_hash_struct *hash;
68767 +
68768 + struct acl_role_label *prev;
68769 + struct acl_role_label *next;
68770 +
68771 + struct role_transition *transitions;
68772 + struct role_allowed_ip *allowed_ips;
68773 + uid_t *domain_children;
68774 + __u16 domain_child_num;
68775 +
68776 + umode_t umask;
68777 +
68778 + struct acl_subject_label **subj_hash;
68779 + __u32 subj_hash_size;
68780 +};
68781 +
68782 +struct user_acl_role_db {
68783 + struct acl_role_label **r_table;
68784 + __u32 num_pointers; /* Number of allocations to track */
68785 + __u32 num_roles; /* Number of roles */
68786 + __u32 num_domain_children; /* Number of domain children */
68787 + __u32 num_subjects; /* Number of subjects */
68788 + __u32 num_objects; /* Number of objects */
68789 +};
68790 +
68791 +struct acl_object_label {
68792 + char *filename;
68793 + ino_t inode;
68794 + dev_t device;
68795 + __u32 mode;
68796 +
68797 + struct acl_subject_label *nested;
68798 + struct acl_object_label *globbed;
68799 +
68800 + /* next two structures not used */
68801 +
68802 + struct acl_object_label *prev;
68803 + struct acl_object_label *next;
68804 +};
68805 +
68806 +struct acl_ip_label {
68807 + char *iface;
68808 + __u32 addr;
68809 + __u32 netmask;
68810 + __u16 low, high;
68811 + __u8 mode;
68812 + __u32 type;
68813 + __u32 proto[8];
68814 +
68815 + /* next two structures not used */
68816 +
68817 + struct acl_ip_label *prev;
68818 + struct acl_ip_label *next;
68819 +};
68820 +
68821 +struct gr_arg {
68822 + struct user_acl_role_db role_db;
68823 + unsigned char pw[GR_PW_LEN];
68824 + unsigned char salt[GR_SALT_LEN];
68825 + unsigned char sum[GR_SHA_LEN];
68826 + unsigned char sp_role[GR_SPROLE_LEN];
68827 + struct sprole_pw *sprole_pws;
68828 + dev_t segv_device;
68829 + ino_t segv_inode;
68830 + uid_t segv_uid;
68831 + __u16 num_sprole_pws;
68832 + __u16 mode;
68833 +};
68834 +
68835 +struct gr_arg_wrapper {
68836 + struct gr_arg *arg;
68837 + __u32 version;
68838 + __u32 size;
68839 +};
68840 +
68841 +struct subject_map {
68842 + struct acl_subject_label *user;
68843 + struct acl_subject_label *kernel;
68844 + struct subject_map *prev;
68845 + struct subject_map *next;
68846 +};
68847 +
68848 +struct acl_subj_map_db {
68849 + struct subject_map **s_hash;
68850 + __u32 s_size;
68851 +};
68852 +
68853 +/* End Data Structures Section */
68854 +
68855 +/* Hash functions generated by empirical testing by Brad Spengler
68856 + Makes good use of the low bits of the inode. Generally 0-1 times
68857 + in loop for successful match. 0-3 for unsuccessful match.
68858 + Shift/add algorithm with modulus of table size and an XOR*/
68859 +
68860 +static __inline__ unsigned int
68861 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68862 +{
68863 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68864 +}
68865 +
68866 + static __inline__ unsigned int
68867 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68868 +{
68869 + return ((const unsigned long)userp % sz);
68870 +}
68871 +
68872 +static __inline__ unsigned int
68873 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68874 +{
68875 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68876 +}
68877 +
68878 +static __inline__ unsigned int
68879 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68880 +{
68881 + return full_name_hash((const unsigned char *)name, len) % sz;
68882 +}
68883 +
68884 +#define FOR_EACH_ROLE_START(role) \
68885 + role = role_list; \
68886 + while (role) {
68887 +
68888 +#define FOR_EACH_ROLE_END(role) \
68889 + role = role->prev; \
68890 + }
68891 +
68892 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68893 + subj = NULL; \
68894 + iter = 0; \
68895 + while (iter < role->subj_hash_size) { \
68896 + if (subj == NULL) \
68897 + subj = role->subj_hash[iter]; \
68898 + if (subj == NULL) { \
68899 + iter++; \
68900 + continue; \
68901 + }
68902 +
68903 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68904 + subj = subj->next; \
68905 + if (subj == NULL) \
68906 + iter++; \
68907 + }
68908 +
68909 +
68910 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68911 + subj = role->hash->first; \
68912 + while (subj != NULL) {
68913 +
68914 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68915 + subj = subj->next; \
68916 + }
68917 +
68918 +#endif
68919 +
68920 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68921 new file mode 100644
68922 index 0000000..323ecf2
68923 --- /dev/null
68924 +++ b/include/linux/gralloc.h
68925 @@ -0,0 +1,9 @@
68926 +#ifndef __GRALLOC_H
68927 +#define __GRALLOC_H
68928 +
68929 +void acl_free_all(void);
68930 +int acl_alloc_stack_init(unsigned long size);
68931 +void *acl_alloc(unsigned long len);
68932 +void *acl_alloc_num(unsigned long num, unsigned long len);
68933 +
68934 +#endif
68935 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68936 new file mode 100644
68937 index 0000000..be66033
68938 --- /dev/null
68939 +++ b/include/linux/grdefs.h
68940 @@ -0,0 +1,140 @@
68941 +#ifndef GRDEFS_H
68942 +#define GRDEFS_H
68943 +
68944 +/* Begin grsecurity status declarations */
68945 +
68946 +enum {
68947 + GR_READY = 0x01,
68948 + GR_STATUS_INIT = 0x00 // disabled state
68949 +};
68950 +
68951 +/* Begin ACL declarations */
68952 +
68953 +/* Role flags */
68954 +
68955 +enum {
68956 + GR_ROLE_USER = 0x0001,
68957 + GR_ROLE_GROUP = 0x0002,
68958 + GR_ROLE_DEFAULT = 0x0004,
68959 + GR_ROLE_SPECIAL = 0x0008,
68960 + GR_ROLE_AUTH = 0x0010,
68961 + GR_ROLE_NOPW = 0x0020,
68962 + GR_ROLE_GOD = 0x0040,
68963 + GR_ROLE_LEARN = 0x0080,
68964 + GR_ROLE_TPE = 0x0100,
68965 + GR_ROLE_DOMAIN = 0x0200,
68966 + GR_ROLE_PAM = 0x0400,
68967 + GR_ROLE_PERSIST = 0x0800
68968 +};
68969 +
68970 +/* ACL Subject and Object mode flags */
68971 +enum {
68972 + GR_DELETED = 0x80000000
68973 +};
68974 +
68975 +/* ACL Object-only mode flags */
68976 +enum {
68977 + GR_READ = 0x00000001,
68978 + GR_APPEND = 0x00000002,
68979 + GR_WRITE = 0x00000004,
68980 + GR_EXEC = 0x00000008,
68981 + GR_FIND = 0x00000010,
68982 + GR_INHERIT = 0x00000020,
68983 + GR_SETID = 0x00000040,
68984 + GR_CREATE = 0x00000080,
68985 + GR_DELETE = 0x00000100,
68986 + GR_LINK = 0x00000200,
68987 + GR_AUDIT_READ = 0x00000400,
68988 + GR_AUDIT_APPEND = 0x00000800,
68989 + GR_AUDIT_WRITE = 0x00001000,
68990 + GR_AUDIT_EXEC = 0x00002000,
68991 + GR_AUDIT_FIND = 0x00004000,
68992 + GR_AUDIT_INHERIT= 0x00008000,
68993 + GR_AUDIT_SETID = 0x00010000,
68994 + GR_AUDIT_CREATE = 0x00020000,
68995 + GR_AUDIT_DELETE = 0x00040000,
68996 + GR_AUDIT_LINK = 0x00080000,
68997 + GR_PTRACERD = 0x00100000,
68998 + GR_NOPTRACE = 0x00200000,
68999 + GR_SUPPRESS = 0x00400000,
69000 + GR_NOLEARN = 0x00800000,
69001 + GR_INIT_TRANSFER= 0x01000000
69002 +};
69003 +
69004 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69005 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69006 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69007 +
69008 +/* ACL subject-only mode flags */
69009 +enum {
69010 + GR_KILL = 0x00000001,
69011 + GR_VIEW = 0x00000002,
69012 + GR_PROTECTED = 0x00000004,
69013 + GR_LEARN = 0x00000008,
69014 + GR_OVERRIDE = 0x00000010,
69015 + /* just a placeholder, this mode is only used in userspace */
69016 + GR_DUMMY = 0x00000020,
69017 + GR_PROTSHM = 0x00000040,
69018 + GR_KILLPROC = 0x00000080,
69019 + GR_KILLIPPROC = 0x00000100,
69020 + /* just a placeholder, this mode is only used in userspace */
69021 + GR_NOTROJAN = 0x00000200,
69022 + GR_PROTPROCFD = 0x00000400,
69023 + GR_PROCACCT = 0x00000800,
69024 + GR_RELAXPTRACE = 0x00001000,
69025 + //GR_NESTED = 0x00002000,
69026 + GR_INHERITLEARN = 0x00004000,
69027 + GR_PROCFIND = 0x00008000,
69028 + GR_POVERRIDE = 0x00010000,
69029 + GR_KERNELAUTH = 0x00020000,
69030 + GR_ATSECURE = 0x00040000,
69031 + GR_SHMEXEC = 0x00080000
69032 +};
69033 +
69034 +enum {
69035 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69036 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69037 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69038 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69039 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69040 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69041 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69042 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69043 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69044 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69045 +};
69046 +
69047 +enum {
69048 + GR_ID_USER = 0x01,
69049 + GR_ID_GROUP = 0x02,
69050 +};
69051 +
69052 +enum {
69053 + GR_ID_ALLOW = 0x01,
69054 + GR_ID_DENY = 0x02,
69055 +};
69056 +
69057 +#define GR_CRASH_RES 31
69058 +#define GR_UIDTABLE_MAX 500
69059 +
69060 +/* begin resource learning section */
69061 +enum {
69062 + GR_RLIM_CPU_BUMP = 60,
69063 + GR_RLIM_FSIZE_BUMP = 50000,
69064 + GR_RLIM_DATA_BUMP = 10000,
69065 + GR_RLIM_STACK_BUMP = 1000,
69066 + GR_RLIM_CORE_BUMP = 10000,
69067 + GR_RLIM_RSS_BUMP = 500000,
69068 + GR_RLIM_NPROC_BUMP = 1,
69069 + GR_RLIM_NOFILE_BUMP = 5,
69070 + GR_RLIM_MEMLOCK_BUMP = 50000,
69071 + GR_RLIM_AS_BUMP = 500000,
69072 + GR_RLIM_LOCKS_BUMP = 2,
69073 + GR_RLIM_SIGPENDING_BUMP = 5,
69074 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69075 + GR_RLIM_NICE_BUMP = 1,
69076 + GR_RLIM_RTPRIO_BUMP = 1,
69077 + GR_RLIM_RTTIME_BUMP = 1000000
69078 +};
69079 +
69080 +#endif
69081 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69082 new file mode 100644
69083 index 0000000..5402bce
69084 --- /dev/null
69085 +++ b/include/linux/grinternal.h
69086 @@ -0,0 +1,215 @@
69087 +#ifndef __GRINTERNAL_H
69088 +#define __GRINTERNAL_H
69089 +
69090 +#ifdef CONFIG_GRKERNSEC
69091 +
69092 +#include <linux/fs.h>
69093 +#include <linux/mnt_namespace.h>
69094 +#include <linux/nsproxy.h>
69095 +#include <linux/gracl.h>
69096 +#include <linux/grdefs.h>
69097 +#include <linux/grmsg.h>
69098 +
69099 +void gr_add_learn_entry(const char *fmt, ...)
69100 + __attribute__ ((format (printf, 1, 2)));
69101 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69102 + const struct vfsmount *mnt);
69103 +__u32 gr_check_create(const struct dentry *new_dentry,
69104 + const struct dentry *parent,
69105 + const struct vfsmount *mnt, const __u32 mode);
69106 +int gr_check_protected_task(const struct task_struct *task);
69107 +__u32 to_gr_audit(const __u32 reqmode);
69108 +int gr_set_acls(const int type);
69109 +int gr_apply_subject_to_task(struct task_struct *task);
69110 +int gr_acl_is_enabled(void);
69111 +char gr_roletype_to_char(void);
69112 +
69113 +void gr_handle_alertkill(struct task_struct *task);
69114 +char *gr_to_filename(const struct dentry *dentry,
69115 + const struct vfsmount *mnt);
69116 +char *gr_to_filename1(const struct dentry *dentry,
69117 + const struct vfsmount *mnt);
69118 +char *gr_to_filename2(const struct dentry *dentry,
69119 + const struct vfsmount *mnt);
69120 +char *gr_to_filename3(const struct dentry *dentry,
69121 + const struct vfsmount *mnt);
69122 +
69123 +extern int grsec_enable_ptrace_readexec;
69124 +extern int grsec_enable_harden_ptrace;
69125 +extern int grsec_enable_link;
69126 +extern int grsec_enable_fifo;
69127 +extern int grsec_enable_execve;
69128 +extern int grsec_enable_shm;
69129 +extern int grsec_enable_execlog;
69130 +extern int grsec_enable_signal;
69131 +extern int grsec_enable_audit_ptrace;
69132 +extern int grsec_enable_forkfail;
69133 +extern int grsec_enable_time;
69134 +extern int grsec_enable_rofs;
69135 +extern int grsec_enable_chroot_shmat;
69136 +extern int grsec_enable_chroot_mount;
69137 +extern int grsec_enable_chroot_double;
69138 +extern int grsec_enable_chroot_pivot;
69139 +extern int grsec_enable_chroot_chdir;
69140 +extern int grsec_enable_chroot_chmod;
69141 +extern int grsec_enable_chroot_mknod;
69142 +extern int grsec_enable_chroot_fchdir;
69143 +extern int grsec_enable_chroot_nice;
69144 +extern int grsec_enable_chroot_execlog;
69145 +extern int grsec_enable_chroot_caps;
69146 +extern int grsec_enable_chroot_sysctl;
69147 +extern int grsec_enable_chroot_unix;
69148 +extern int grsec_enable_symlinkown;
69149 +extern kgid_t grsec_symlinkown_gid;
69150 +extern int grsec_enable_tpe;
69151 +extern kgid_t grsec_tpe_gid;
69152 +extern int grsec_enable_tpe_all;
69153 +extern int grsec_enable_tpe_invert;
69154 +extern int grsec_enable_socket_all;
69155 +extern kgid_t grsec_socket_all_gid;
69156 +extern int grsec_enable_socket_client;
69157 +extern kgid_t grsec_socket_client_gid;
69158 +extern int grsec_enable_socket_server;
69159 +extern kgid_t grsec_socket_server_gid;
69160 +extern kgid_t grsec_audit_gid;
69161 +extern int grsec_enable_group;
69162 +extern int grsec_enable_audit_textrel;
69163 +extern int grsec_enable_log_rwxmaps;
69164 +extern int grsec_enable_mount;
69165 +extern int grsec_enable_chdir;
69166 +extern int grsec_resource_logging;
69167 +extern int grsec_enable_blackhole;
69168 +extern int grsec_lastack_retries;
69169 +extern int grsec_enable_brute;
69170 +extern int grsec_lock;
69171 +
69172 +extern spinlock_t grsec_alert_lock;
69173 +extern unsigned long grsec_alert_wtime;
69174 +extern unsigned long grsec_alert_fyet;
69175 +
69176 +extern spinlock_t grsec_audit_lock;
69177 +
69178 +extern rwlock_t grsec_exec_file_lock;
69179 +
69180 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69181 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69182 + (tsk)->exec_file->f_path.mnt) : "/")
69183 +
69184 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69185 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69186 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
69187 +
69188 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69189 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69190 + (tsk)->exec_file->f_path.mnt) : "/")
69191 +
69192 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69193 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69194 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
69195 +
69196 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69197 +
69198 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69199 +
69200 +#define GR_CHROOT_CAPS {{ \
69201 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69202 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69203 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69204 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69205 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69206 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69207 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69208 +
69209 +#define security_learn(normal_msg,args...) \
69210 +({ \
69211 + read_lock(&grsec_exec_file_lock); \
69212 + gr_add_learn_entry(normal_msg "\n", ## args); \
69213 + read_unlock(&grsec_exec_file_lock); \
69214 +})
69215 +
69216 +enum {
69217 + GR_DO_AUDIT,
69218 + GR_DONT_AUDIT,
69219 + /* used for non-audit messages that we shouldn't kill the task on */
69220 + GR_DONT_AUDIT_GOOD
69221 +};
69222 +
69223 +enum {
69224 + GR_TTYSNIFF,
69225 + GR_RBAC,
69226 + GR_RBAC_STR,
69227 + GR_STR_RBAC,
69228 + GR_RBAC_MODE2,
69229 + GR_RBAC_MODE3,
69230 + GR_FILENAME,
69231 + GR_SYSCTL_HIDDEN,
69232 + GR_NOARGS,
69233 + GR_ONE_INT,
69234 + GR_ONE_INT_TWO_STR,
69235 + GR_ONE_STR,
69236 + GR_STR_INT,
69237 + GR_TWO_STR_INT,
69238 + GR_TWO_INT,
69239 + GR_TWO_U64,
69240 + GR_THREE_INT,
69241 + GR_FIVE_INT_TWO_STR,
69242 + GR_TWO_STR,
69243 + GR_THREE_STR,
69244 + GR_FOUR_STR,
69245 + GR_STR_FILENAME,
69246 + GR_FILENAME_STR,
69247 + GR_FILENAME_TWO_INT,
69248 + GR_FILENAME_TWO_INT_STR,
69249 + GR_TEXTREL,
69250 + GR_PTRACE,
69251 + GR_RESOURCE,
69252 + GR_CAP,
69253 + GR_SIG,
69254 + GR_SIG2,
69255 + GR_CRASH1,
69256 + GR_CRASH2,
69257 + GR_PSACCT,
69258 + GR_RWXMAP
69259 +};
69260 +
69261 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69262 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69263 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69264 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69265 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69266 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69267 +#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)
69268 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69269 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69270 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69271 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69272 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69273 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69274 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69275 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69276 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69277 +#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)
69278 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69279 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69280 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69281 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69282 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69283 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69284 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69285 +#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)
69286 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69287 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69288 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69289 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69290 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69291 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69292 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69293 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69294 +#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)
69295 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69296 +
69297 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69298 +
69299 +#endif
69300 +
69301 +#endif
69302 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69303 new file mode 100644
69304 index 0000000..2bd4c8d
69305 --- /dev/null
69306 +++ b/include/linux/grmsg.h
69307 @@ -0,0 +1,111 @@
69308 +#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"
69309 +#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"
69310 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69311 +#define GR_STOPMOD_MSG "denied modification of module state by "
69312 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69313 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69314 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69315 +#define GR_IOPL_MSG "denied use of iopl() by "
69316 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69317 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69318 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69319 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69320 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69321 +#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"
69322 +#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"
69323 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69324 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69325 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69326 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69327 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69328 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69329 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69330 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69331 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69332 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69333 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69334 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69335 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69336 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69337 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69338 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69339 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69340 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69341 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69342 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69343 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69344 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69345 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69346 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69347 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69348 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69349 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69350 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69351 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69352 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69353 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69354 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69355 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69356 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69357 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69358 +#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"
69359 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69360 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69361 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69362 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69363 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69364 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69365 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69366 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69367 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69368 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69369 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69370 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69371 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69372 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69373 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69374 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69375 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69376 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69377 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69378 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69379 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69380 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69381 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69382 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69383 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69384 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69385 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69386 +#define GR_TIME_MSG "time set by "
69387 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69388 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69389 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69390 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69391 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69392 +#define GR_BIND_MSG "denied bind() by "
69393 +#define GR_CONNECT_MSG "denied connect() by "
69394 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69395 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69396 +#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"
69397 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69398 +#define GR_CAP_ACL_MSG "use of %s denied for "
69399 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69400 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69401 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69402 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69403 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69404 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69405 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69406 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69407 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69408 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69409 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69410 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69411 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69412 +#define GR_VM86_MSG "denied use of vm86 by "
69413 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69414 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69415 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69416 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69417 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69418 +#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 "
69419 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69420 new file mode 100644
69421 index 0000000..d7ef0ac
69422 --- /dev/null
69423 +++ b/include/linux/grsecurity.h
69424 @@ -0,0 +1,242 @@
69425 +#ifndef GR_SECURITY_H
69426 +#define GR_SECURITY_H
69427 +#include <linux/fs.h>
69428 +#include <linux/fs_struct.h>
69429 +#include <linux/binfmts.h>
69430 +#include <linux/gracl.h>
69431 +
69432 +/* notify of brain-dead configs */
69433 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69434 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69435 +#endif
69436 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69437 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69438 +#endif
69439 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69440 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69441 +#endif
69442 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69443 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69444 +#endif
69445 +
69446 +void gr_handle_brute_attach(unsigned long mm_flags);
69447 +void gr_handle_brute_check(void);
69448 +void gr_handle_kernel_exploit(void);
69449 +int gr_process_user_ban(void);
69450 +
69451 +char gr_roletype_to_char(void);
69452 +
69453 +int gr_acl_enable_at_secure(void);
69454 +
69455 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69456 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69457 +
69458 +void gr_del_task_from_ip_table(struct task_struct *p);
69459 +
69460 +int gr_pid_is_chrooted(struct task_struct *p);
69461 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69462 +int gr_handle_chroot_nice(void);
69463 +int gr_handle_chroot_sysctl(const int op);
69464 +int gr_handle_chroot_setpriority(struct task_struct *p,
69465 + const int niceval);
69466 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69467 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69468 + const struct vfsmount *mnt);
69469 +void gr_handle_chroot_chdir(const struct path *path);
69470 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69471 + const struct vfsmount *mnt, const int mode);
69472 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69473 + const struct vfsmount *mnt, const int mode);
69474 +int gr_handle_chroot_mount(const struct dentry *dentry,
69475 + const struct vfsmount *mnt,
69476 + const char *dev_name);
69477 +int gr_handle_chroot_pivot(void);
69478 +int gr_handle_chroot_unix(const pid_t pid);
69479 +
69480 +int gr_handle_rawio(const struct inode *inode);
69481 +
69482 +void gr_handle_ioperm(void);
69483 +void gr_handle_iopl(void);
69484 +
69485 +umode_t gr_acl_umask(void);
69486 +
69487 +int gr_tpe_allow(const struct file *file);
69488 +
69489 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
69490 +void gr_clear_chroot_entries(struct task_struct *task);
69491 +
69492 +void gr_log_forkfail(const int retval);
69493 +void gr_log_timechange(void);
69494 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69495 +void gr_log_chdir(const struct dentry *dentry,
69496 + const struct vfsmount *mnt);
69497 +void gr_log_chroot_exec(const struct dentry *dentry,
69498 + const struct vfsmount *mnt);
69499 +void gr_log_remount(const char *devname, const int retval);
69500 +void gr_log_unmount(const char *devname, const int retval);
69501 +void gr_log_mount(const char *from, const char *to, const int retval);
69502 +void gr_log_textrel(struct vm_area_struct *vma);
69503 +void gr_log_rwxmmap(struct file *file);
69504 +void gr_log_rwxmprotect(struct file *file);
69505 +
69506 +int gr_handle_follow_link(const struct inode *parent,
69507 + const struct inode *inode,
69508 + const struct dentry *dentry,
69509 + const struct vfsmount *mnt);
69510 +int gr_handle_fifo(const struct dentry *dentry,
69511 + const struct vfsmount *mnt,
69512 + const struct dentry *dir, const int flag,
69513 + const int acc_mode);
69514 +int gr_handle_hardlink(const struct dentry *dentry,
69515 + const struct vfsmount *mnt,
69516 + struct inode *inode,
69517 + const int mode, const struct filename *to);
69518 +
69519 +int gr_is_capable(const int cap);
69520 +int gr_is_capable_nolog(const int cap);
69521 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69522 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69523 +
69524 +void gr_copy_label(struct task_struct *tsk);
69525 +void gr_handle_crash(struct task_struct *task, const int sig);
69526 +int gr_handle_signal(const struct task_struct *p, const int sig);
69527 +int gr_check_crash_uid(const kuid_t uid);
69528 +int gr_check_protected_task(const struct task_struct *task);
69529 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69530 +int gr_acl_handle_mmap(const struct file *file,
69531 + const unsigned long prot);
69532 +int gr_acl_handle_mprotect(const struct file *file,
69533 + const unsigned long prot);
69534 +int gr_check_hidden_task(const struct task_struct *tsk);
69535 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69536 + const struct vfsmount *mnt);
69537 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69538 + const struct vfsmount *mnt);
69539 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69540 + const struct vfsmount *mnt, const int fmode);
69541 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69542 + const struct vfsmount *mnt, umode_t *mode);
69543 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69544 + const struct vfsmount *mnt);
69545 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69546 + const struct vfsmount *mnt);
69547 +int gr_handle_ptrace(struct task_struct *task, const long request);
69548 +int gr_handle_proc_ptrace(struct task_struct *task);
69549 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69550 + const struct vfsmount *mnt);
69551 +int gr_check_crash_exec(const struct file *filp);
69552 +int gr_acl_is_enabled(void);
69553 +void gr_set_kernel_label(struct task_struct *task);
69554 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69555 + const kgid_t gid);
69556 +int gr_set_proc_label(const struct dentry *dentry,
69557 + const struct vfsmount *mnt,
69558 + const int unsafe_flags);
69559 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69560 + const struct vfsmount *mnt);
69561 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69562 + const struct vfsmount *mnt, int acc_mode);
69563 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69564 + const struct dentry *p_dentry,
69565 + const struct vfsmount *p_mnt,
69566 + int open_flags, int acc_mode, const int imode);
69567 +void gr_handle_create(const struct dentry *dentry,
69568 + const struct vfsmount *mnt);
69569 +void gr_handle_proc_create(const struct dentry *dentry,
69570 + const struct inode *inode);
69571 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69572 + const struct dentry *parent_dentry,
69573 + const struct vfsmount *parent_mnt,
69574 + const int mode);
69575 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69576 + const struct dentry *parent_dentry,
69577 + const struct vfsmount *parent_mnt);
69578 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69579 + const struct vfsmount *mnt);
69580 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69581 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69582 + const struct vfsmount *mnt);
69583 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69584 + const struct dentry *parent_dentry,
69585 + const struct vfsmount *parent_mnt,
69586 + const struct filename *from);
69587 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69588 + const struct dentry *parent_dentry,
69589 + const struct vfsmount *parent_mnt,
69590 + const struct dentry *old_dentry,
69591 + const struct vfsmount *old_mnt, const struct filename *to);
69592 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69593 +int gr_acl_handle_rename(struct dentry *new_dentry,
69594 + struct dentry *parent_dentry,
69595 + const struct vfsmount *parent_mnt,
69596 + struct dentry *old_dentry,
69597 + struct inode *old_parent_inode,
69598 + struct vfsmount *old_mnt, const struct filename *newname);
69599 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69600 + struct dentry *old_dentry,
69601 + struct dentry *new_dentry,
69602 + struct vfsmount *mnt, const __u8 replace);
69603 +__u32 gr_check_link(const struct dentry *new_dentry,
69604 + const struct dentry *parent_dentry,
69605 + const struct vfsmount *parent_mnt,
69606 + const struct dentry *old_dentry,
69607 + const struct vfsmount *old_mnt);
69608 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69609 + const unsigned int namelen, const ino_t ino);
69610 +
69611 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69612 + const struct vfsmount *mnt);
69613 +void gr_acl_handle_exit(void);
69614 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69615 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69616 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69617 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69618 +void gr_audit_ptrace(struct task_struct *task);
69619 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69620 +void gr_put_exec_file(struct task_struct *task);
69621 +
69622 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69623 +
69624 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69625 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69626 + const unsigned long wanted, const int gt);
69627 +#else
69628 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69629 + const unsigned long wanted, const int gt)
69630 +{
69631 +}
69632 +#endif
69633 +
69634 +#ifdef CONFIG_GRKERNSEC_RESLOG
69635 +extern void gr_log_resource(const struct task_struct *task, const int res,
69636 + const unsigned long wanted, const int gt);
69637 +#else
69638 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69639 + const unsigned long wanted, const int gt)
69640 +{
69641 +}
69642 +#endif
69643 +
69644 +#ifdef CONFIG_GRKERNSEC
69645 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69646 +void gr_handle_vm86(void);
69647 +void gr_handle_mem_readwrite(u64 from, u64 to);
69648 +
69649 +void gr_log_badprocpid(const char *entry);
69650 +
69651 +extern int grsec_enable_dmesg;
69652 +extern int grsec_disable_privio;
69653 +
69654 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69655 +extern kgid_t grsec_proc_gid;
69656 +#endif
69657 +
69658 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69659 +extern int grsec_enable_chroot_findtask;
69660 +#endif
69661 +#ifdef CONFIG_GRKERNSEC_SETXID
69662 +extern int grsec_enable_setxid;
69663 +#endif
69664 +#endif
69665 +
69666 +#endif
69667 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69668 new file mode 100644
69669 index 0000000..e7ffaaf
69670 --- /dev/null
69671 +++ b/include/linux/grsock.h
69672 @@ -0,0 +1,19 @@
69673 +#ifndef __GRSOCK_H
69674 +#define __GRSOCK_H
69675 +
69676 +extern void gr_attach_curr_ip(const struct sock *sk);
69677 +extern int gr_handle_sock_all(const int family, const int type,
69678 + const int protocol);
69679 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69680 +extern int gr_handle_sock_server_other(const struct sock *sck);
69681 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69682 +extern int gr_search_connect(struct socket * sock,
69683 + struct sockaddr_in * addr);
69684 +extern int gr_search_bind(struct socket * sock,
69685 + struct sockaddr_in * addr);
69686 +extern int gr_search_listen(struct socket * sock);
69687 +extern int gr_search_accept(struct socket * sock);
69688 +extern int gr_search_socket(const int domain, const int type,
69689 + const int protocol);
69690 +
69691 +#endif
69692 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69693 index 7fb31da..08b5114 100644
69694 --- a/include/linux/highmem.h
69695 +++ b/include/linux/highmem.h
69696 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69697 kunmap_atomic(kaddr);
69698 }
69699
69700 +static inline void sanitize_highpage(struct page *page)
69701 +{
69702 + void *kaddr;
69703 + unsigned long flags;
69704 +
69705 + local_irq_save(flags);
69706 + kaddr = kmap_atomic(page);
69707 + clear_page(kaddr);
69708 + kunmap_atomic(kaddr);
69709 + local_irq_restore(flags);
69710 +}
69711 +
69712 static inline void zero_user_segments(struct page *page,
69713 unsigned start1, unsigned end1,
69714 unsigned start2, unsigned end2)
69715 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69716 index 1c7b89a..7f52502 100644
69717 --- a/include/linux/hwmon-sysfs.h
69718 +++ b/include/linux/hwmon-sysfs.h
69719 @@ -25,7 +25,8 @@
69720 struct sensor_device_attribute{
69721 struct device_attribute dev_attr;
69722 int index;
69723 -};
69724 +} __do_const;
69725 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69726 #define to_sensor_dev_attr(_dev_attr) \
69727 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69728
69729 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69730 struct device_attribute dev_attr;
69731 u8 index;
69732 u8 nr;
69733 -};
69734 +} __do_const;
69735 #define to_sensor_dev_attr_2(_dev_attr) \
69736 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69737
69738 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69739 index d0c4db7..61b3577 100644
69740 --- a/include/linux/i2c.h
69741 +++ b/include/linux/i2c.h
69742 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69743 /* To determine what the adapter supports */
69744 u32 (*functionality) (struct i2c_adapter *);
69745 };
69746 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69747
69748 /*
69749 * i2c_adapter is the structure used to identify a physical i2c bus along
69750 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69751 index d23c3c2..eb63c81 100644
69752 --- a/include/linux/i2o.h
69753 +++ b/include/linux/i2o.h
69754 @@ -565,7 +565,7 @@ struct i2o_controller {
69755 struct i2o_device *exec; /* Executive */
69756 #if BITS_PER_LONG == 64
69757 spinlock_t context_list_lock; /* lock for context_list */
69758 - atomic_t context_list_counter; /* needed for unique contexts */
69759 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69760 struct list_head context_list; /* list of context id's
69761 and pointers */
69762 #endif
69763 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69764 index aff7ad8..3942bbd 100644
69765 --- a/include/linux/if_pppox.h
69766 +++ b/include/linux/if_pppox.h
69767 @@ -76,7 +76,7 @@ struct pppox_proto {
69768 int (*ioctl)(struct socket *sock, unsigned int cmd,
69769 unsigned long arg);
69770 struct module *owner;
69771 -};
69772 +} __do_const;
69773
69774 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69775 extern void unregister_pppox_proto(int proto_num);
69776 diff --git a/include/linux/init.h b/include/linux/init.h
69777 index 8618147..0821126 100644
69778 --- a/include/linux/init.h
69779 +++ b/include/linux/init.h
69780 @@ -39,9 +39,36 @@
69781 * Also note, that this data cannot be "const".
69782 */
69783
69784 +#ifdef MODULE
69785 +#define add_init_latent_entropy
69786 +#define add_devinit_latent_entropy
69787 +#define add_cpuinit_latent_entropy
69788 +#define add_meminit_latent_entropy
69789 +#else
69790 +#define add_init_latent_entropy __latent_entropy
69791 +
69792 +#ifdef CONFIG_HOTPLUG
69793 +#define add_devinit_latent_entropy
69794 +#else
69795 +#define add_devinit_latent_entropy __latent_entropy
69796 +#endif
69797 +
69798 +#ifdef CONFIG_HOTPLUG_CPU
69799 +#define add_cpuinit_latent_entropy
69800 +#else
69801 +#define add_cpuinit_latent_entropy __latent_entropy
69802 +#endif
69803 +
69804 +#ifdef CONFIG_MEMORY_HOTPLUG
69805 +#define add_meminit_latent_entropy
69806 +#else
69807 +#define add_meminit_latent_entropy __latent_entropy
69808 +#endif
69809 +#endif
69810 +
69811 /* These are for everybody (although not all archs will actually
69812 discard it in modules) */
69813 -#define __init __section(.init.text) __cold notrace
69814 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69815 #define __initdata __section(.init.data)
69816 #define __initconst __constsection(.init.rodata)
69817 #define __exitdata __section(.exit.data)
69818 @@ -94,7 +121,7 @@
69819 #define __exit __section(.exit.text) __exitused __cold notrace
69820
69821 /* Used for HOTPLUG_CPU */
69822 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69823 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69824 #define __cpuinitdata __section(.cpuinit.data)
69825 #define __cpuinitconst __constsection(.cpuinit.rodata)
69826 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69827 @@ -102,7 +129,7 @@
69828 #define __cpuexitconst __constsection(.cpuexit.rodata)
69829
69830 /* Used for MEMORY_HOTPLUG */
69831 -#define __meminit __section(.meminit.text) __cold notrace
69832 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69833 #define __meminitdata __section(.meminit.data)
69834 #define __meminitconst __constsection(.meminit.rodata)
69835 #define __memexit __section(.memexit.text) __exitused __cold notrace
69836 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69837 index 5cd0f09..c9f67cc 100644
69838 --- a/include/linux/init_task.h
69839 +++ b/include/linux/init_task.h
69840 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
69841
69842 #define INIT_TASK_COMM "swapper"
69843
69844 +#ifdef CONFIG_X86
69845 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69846 +#else
69847 +#define INIT_TASK_THREAD_INFO
69848 +#endif
69849 +
69850 /*
69851 * INIT_TASK is used to set up the first task table, touch at
69852 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69853 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
69854 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69855 .comm = INIT_TASK_COMM, \
69856 .thread = INIT_THREAD, \
69857 + INIT_TASK_THREAD_INFO \
69858 .fs = &init_fs, \
69859 .files = &init_files, \
69860 .signal = &init_signals, \
69861 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69862 index 5fa5afe..ac55b25 100644
69863 --- a/include/linux/interrupt.h
69864 +++ b/include/linux/interrupt.h
69865 @@ -430,7 +430,7 @@ enum
69866 /* map softirq index to softirq name. update 'softirq_to_name' in
69867 * kernel/softirq.c when adding a new softirq.
69868 */
69869 -extern char *softirq_to_name[NR_SOFTIRQS];
69870 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69871
69872 /* softirq mask and active fields moved to irq_cpustat_t in
69873 * asm/hardirq.h to get better cache usage. KAO
69874 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69875
69876 struct softirq_action
69877 {
69878 - void (*action)(struct softirq_action *);
69879 -};
69880 + void (*action)(void);
69881 +} __no_const;
69882
69883 asmlinkage void do_softirq(void);
69884 asmlinkage void __do_softirq(void);
69885 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69886 +extern void open_softirq(int nr, void (*action)(void));
69887 extern void softirq_init(void);
69888 extern void __raise_softirq_irqoff(unsigned int nr);
69889
69890 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69891 index ba3b8a9..7e14ed8 100644
69892 --- a/include/linux/iommu.h
69893 +++ b/include/linux/iommu.h
69894 @@ -113,7 +113,7 @@ struct iommu_ops {
69895 u32 (*domain_get_windows)(struct iommu_domain *domain);
69896
69897 unsigned long pgsize_bitmap;
69898 -};
69899 +} __do_const;
69900
69901 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69902 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69903 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
69904 index 85ac9b9b..e5759ab 100644
69905 --- a/include/linux/ioport.h
69906 +++ b/include/linux/ioport.h
69907 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
69908 int adjust_resource(struct resource *res, resource_size_t start,
69909 resource_size_t size);
69910 resource_size_t resource_alignment(struct resource *res);
69911 -static inline resource_size_t resource_size(const struct resource *res)
69912 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
69913 {
69914 return res->end - res->start + 1;
69915 }
69916 diff --git a/include/linux/irq.h b/include/linux/irq.h
69917 index bc4e066..50468a9 100644
69918 --- a/include/linux/irq.h
69919 +++ b/include/linux/irq.h
69920 @@ -328,7 +328,8 @@ struct irq_chip {
69921 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69922
69923 unsigned long flags;
69924 -};
69925 +} __do_const;
69926 +typedef struct irq_chip __no_const irq_chip_no_const;
69927
69928 /*
69929 * irq_chip specific flags
69930 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
69931 index 3fd8e42..a73e966 100644
69932 --- a/include/linux/irqchip/arm-gic.h
69933 +++ b/include/linux/irqchip/arm-gic.h
69934 @@ -59,9 +59,11 @@
69935
69936 #ifndef __ASSEMBLY__
69937
69938 +#include <linux/irq.h>
69939 +
69940 struct device_node;
69941
69942 -extern struct irq_chip gic_arch_extn;
69943 +extern irq_chip_no_const gic_arch_extn;
69944
69945 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
69946 u32 offset, struct device_node *);
69947 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69948 index 6883e19..06992b1 100644
69949 --- a/include/linux/kallsyms.h
69950 +++ b/include/linux/kallsyms.h
69951 @@ -15,7 +15,8 @@
69952
69953 struct module;
69954
69955 -#ifdef CONFIG_KALLSYMS
69956 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69957 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69958 /* Lookup the address for a symbol. Returns 0 if not found. */
69959 unsigned long kallsyms_lookup_name(const char *name);
69960
69961 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69962 /* Stupid that this does nothing, but I didn't create this mess. */
69963 #define __print_symbol(fmt, addr)
69964 #endif /*CONFIG_KALLSYMS*/
69965 +#else /* when included by kallsyms.c, vsnprintf.c, or
69966 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69967 +extern void __print_symbol(const char *fmt, unsigned long address);
69968 +extern int sprint_backtrace(char *buffer, unsigned long address);
69969 +extern int sprint_symbol(char *buffer, unsigned long address);
69970 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69971 +const char *kallsyms_lookup(unsigned long addr,
69972 + unsigned long *symbolsize,
69973 + unsigned long *offset,
69974 + char **modname, char *namebuf);
69975 +#endif
69976
69977 /* This macro allows us to keep printk typechecking */
69978 static __printf(1, 2)
69979 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69980 index 518a53a..5e28358 100644
69981 --- a/include/linux/key-type.h
69982 +++ b/include/linux/key-type.h
69983 @@ -125,7 +125,7 @@ struct key_type {
69984 /* internal fields */
69985 struct list_head link; /* link in types list */
69986 struct lock_class_key lock_class; /* key->sem lock class */
69987 -};
69988 +} __do_const;
69989
69990 extern struct key_type key_type_keyring;
69991
69992 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69993 index c6e091b..a940adf 100644
69994 --- a/include/linux/kgdb.h
69995 +++ b/include/linux/kgdb.h
69996 @@ -52,7 +52,7 @@ extern int kgdb_connected;
69997 extern int kgdb_io_module_registered;
69998
69999 extern atomic_t kgdb_setting_breakpoint;
70000 -extern atomic_t kgdb_cpu_doing_single_step;
70001 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70002
70003 extern struct task_struct *kgdb_usethread;
70004 extern struct task_struct *kgdb_contthread;
70005 @@ -254,7 +254,7 @@ struct kgdb_arch {
70006 void (*correct_hw_break)(void);
70007
70008 void (*enable_nmi)(bool on);
70009 -};
70010 +} __do_const;
70011
70012 /**
70013 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
70014 @@ -279,7 +279,7 @@ struct kgdb_io {
70015 void (*pre_exception) (void);
70016 void (*post_exception) (void);
70017 int is_console;
70018 -};
70019 +} __do_const;
70020
70021 extern struct kgdb_arch arch_kgdb_ops;
70022
70023 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70024 index 5398d58..5883a34 100644
70025 --- a/include/linux/kmod.h
70026 +++ b/include/linux/kmod.h
70027 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70028 * usually useless though. */
70029 extern __printf(2, 3)
70030 int __request_module(bool wait, const char *name, ...);
70031 +extern __printf(3, 4)
70032 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70033 #define request_module(mod...) __request_module(true, mod)
70034 #define request_module_nowait(mod...) __request_module(false, mod)
70035 #define try_then_request_module(x, mod...) \
70036 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70037 index 939b112..ed6ed51 100644
70038 --- a/include/linux/kobject.h
70039 +++ b/include/linux/kobject.h
70040 @@ -111,7 +111,7 @@ struct kobj_type {
70041 struct attribute **default_attrs;
70042 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70043 const void *(*namespace)(struct kobject *kobj);
70044 -};
70045 +} __do_const;
70046
70047 struct kobj_uevent_env {
70048 char *envp[UEVENT_NUM_ENVP];
70049 @@ -134,6 +134,7 @@ struct kobj_attribute {
70050 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70051 const char *buf, size_t count);
70052 };
70053 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70054
70055 extern const struct sysfs_ops kobj_sysfs_ops;
70056
70057 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70058 index f66b065..c2c29b4 100644
70059 --- a/include/linux/kobject_ns.h
70060 +++ b/include/linux/kobject_ns.h
70061 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70062 const void *(*netlink_ns)(struct sock *sk);
70063 const void *(*initial_ns)(void);
70064 void (*drop_ns)(void *);
70065 -};
70066 +} __do_const;
70067
70068 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70069 int kobj_ns_type_registered(enum kobj_ns_type type);
70070 diff --git a/include/linux/kref.h b/include/linux/kref.h
70071 index 7419c02..aa2f02d 100644
70072 --- a/include/linux/kref.h
70073 +++ b/include/linux/kref.h
70074 @@ -65,7 +65,7 @@ static inline void kref_get(struct kref *kref)
70075 static inline int kref_sub(struct kref *kref, unsigned int count,
70076 void (*release)(struct kref *kref))
70077 {
70078 - WARN_ON(release == NULL);
70079 + BUG_ON(release == NULL);
70080
70081 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70082 release(kref);
70083 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70084 index c139582..0b5b102 100644
70085 --- a/include/linux/kvm_host.h
70086 +++ b/include/linux/kvm_host.h
70087 @@ -424,7 +424,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
70088 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
70089 void vcpu_put(struct kvm_vcpu *vcpu);
70090
70091 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70092 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70093 struct module *module);
70094 void kvm_exit(void);
70095
70096 @@ -582,7 +582,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70097 struct kvm_guest_debug *dbg);
70098 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70099
70100 -int kvm_arch_init(void *opaque);
70101 +int kvm_arch_init(const void *opaque);
70102 void kvm_arch_exit(void);
70103
70104 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70105 diff --git a/include/linux/libata.h b/include/linux/libata.h
70106 index eae7a05..2cdd875 100644
70107 --- a/include/linux/libata.h
70108 +++ b/include/linux/libata.h
70109 @@ -919,7 +919,7 @@ struct ata_port_operations {
70110 * fields must be pointers.
70111 */
70112 const struct ata_port_operations *inherits;
70113 -};
70114 +} __do_const;
70115
70116 struct ata_port_info {
70117 unsigned long flags;
70118 diff --git a/include/linux/list.h b/include/linux/list.h
70119 index 6a1f8df..eaec1ff 100644
70120 --- a/include/linux/list.h
70121 +++ b/include/linux/list.h
70122 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70123 extern void list_del(struct list_head *entry);
70124 #endif
70125
70126 +extern void __pax_list_add(struct list_head *new,
70127 + struct list_head *prev,
70128 + struct list_head *next);
70129 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70130 +{
70131 + __pax_list_add(new, head, head->next);
70132 +}
70133 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70134 +{
70135 + __pax_list_add(new, head->prev, head);
70136 +}
70137 +extern void pax_list_del(struct list_head *entry);
70138 +
70139 /**
70140 * list_replace - replace old entry by new one
70141 * @old : the element to be replaced
70142 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70143 INIT_LIST_HEAD(entry);
70144 }
70145
70146 +extern void pax_list_del_init(struct list_head *entry);
70147 +
70148 /**
70149 * list_move - delete from one list and add as another's head
70150 * @list: the entry to move
70151 diff --git a/include/linux/math64.h b/include/linux/math64.h
70152 index b8ba855..0148090 100644
70153 --- a/include/linux/math64.h
70154 +++ b/include/linux/math64.h
70155 @@ -14,7 +14,7 @@
70156 * This is commonly provided by 32bit archs to provide an optimized 64bit
70157 * divide.
70158 */
70159 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70160 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70161 {
70162 *remainder = dividend % divisor;
70163 return dividend / divisor;
70164 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70165 #define div64_long(x,y) div_s64((x),(y))
70166
70167 #ifndef div_u64_rem
70168 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70169 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70170 {
70171 *remainder = do_div(dividend, divisor);
70172 return dividend;
70173 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70174 * divide.
70175 */
70176 #ifndef div_u64
70177 -static inline u64 div_u64(u64 dividend, u32 divisor)
70178 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70179 {
70180 u32 remainder;
70181 return div_u64_rem(dividend, divisor, &remainder);
70182 diff --git a/include/linux/mm.h b/include/linux/mm.h
70183 index e2091b8..3c7b38c 100644
70184 --- a/include/linux/mm.h
70185 +++ b/include/linux/mm.h
70186 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
70187 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70188 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70189 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70190 +
70191 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70192 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70193 +#endif
70194 +
70195 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70196
70197 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70198 @@ -202,8 +207,8 @@ struct vm_operations_struct {
70199 /* called by access_process_vm when get_user_pages() fails, typically
70200 * for use by special VMAs that can switch between memory and hardware
70201 */
70202 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70203 - void *buf, int len, int write);
70204 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70205 + void *buf, size_t len, int write);
70206 #ifdef CONFIG_NUMA
70207 /*
70208 * set_policy() op must add a reference to any non-NULL @new mempolicy
70209 @@ -233,6 +238,7 @@ struct vm_operations_struct {
70210 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70211 unsigned long size, pgoff_t pgoff);
70212 };
70213 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70214
70215 struct mmu_gather;
70216 struct inode;
70217 @@ -970,8 +976,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70218 unsigned long *pfn);
70219 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70220 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70221 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70222 - void *buf, int len, int write);
70223 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70224 + void *buf, size_t len, int write);
70225
70226 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70227 loff_t const holebegin, loff_t const holelen)
70228 @@ -1010,9 +1016,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70229 }
70230 #endif
70231
70232 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70233 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70234 - void *buf, int len, int write);
70235 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70236 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70237 + void *buf, size_t len, int write);
70238
70239 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70240 unsigned long start, unsigned long nr_pages,
70241 @@ -1043,34 +1049,6 @@ int set_page_dirty(struct page *page);
70242 int set_page_dirty_lock(struct page *page);
70243 int clear_page_dirty_for_io(struct page *page);
70244
70245 -/* Is the vma a continuation of the stack vma above it? */
70246 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70247 -{
70248 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70249 -}
70250 -
70251 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70252 - unsigned long addr)
70253 -{
70254 - return (vma->vm_flags & VM_GROWSDOWN) &&
70255 - (vma->vm_start == addr) &&
70256 - !vma_growsdown(vma->vm_prev, addr);
70257 -}
70258 -
70259 -/* Is the vma a continuation of the stack vma below it? */
70260 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70261 -{
70262 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70263 -}
70264 -
70265 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70266 - unsigned long addr)
70267 -{
70268 - return (vma->vm_flags & VM_GROWSUP) &&
70269 - (vma->vm_end == addr) &&
70270 - !vma_growsup(vma->vm_next, addr);
70271 -}
70272 -
70273 extern pid_t
70274 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70275
70276 @@ -1173,6 +1151,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70277 }
70278 #endif
70279
70280 +#ifdef CONFIG_MMU
70281 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70282 +#else
70283 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70284 +{
70285 + return __pgprot(0);
70286 +}
70287 +#endif
70288 +
70289 int vma_wants_writenotify(struct vm_area_struct *vma);
70290
70291 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70292 @@ -1191,8 +1178,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70293 {
70294 return 0;
70295 }
70296 +
70297 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70298 + unsigned long address)
70299 +{
70300 + return 0;
70301 +}
70302 #else
70303 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70304 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70305 #endif
70306
70307 #ifdef __PAGETABLE_PMD_FOLDED
70308 @@ -1201,8 +1195,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70309 {
70310 return 0;
70311 }
70312 +
70313 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70314 + unsigned long address)
70315 +{
70316 + return 0;
70317 +}
70318 #else
70319 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70320 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70321 #endif
70322
70323 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70324 @@ -1220,11 +1221,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70325 NULL: pud_offset(pgd, address);
70326 }
70327
70328 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70329 +{
70330 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70331 + NULL: pud_offset(pgd, address);
70332 +}
70333 +
70334 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70335 {
70336 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70337 NULL: pmd_offset(pud, address);
70338 }
70339 +
70340 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70341 +{
70342 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70343 + NULL: pmd_offset(pud, address);
70344 +}
70345 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70346
70347 #if USE_SPLIT_PTLOCKS
70348 @@ -1455,6 +1468,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
70349 unsigned long len, unsigned long prot, unsigned long flags,
70350 unsigned long pgoff, unsigned long *populate);
70351 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70352 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70353
70354 #ifdef CONFIG_MMU
70355 extern int __mm_populate(unsigned long addr, unsigned long len,
70356 @@ -1483,10 +1497,11 @@ struct vm_unmapped_area_info {
70357 unsigned long high_limit;
70358 unsigned long align_mask;
70359 unsigned long align_offset;
70360 + unsigned long threadstack_offset;
70361 };
70362
70363 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
70364 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
70365 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
70366 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
70367
70368 /*
70369 * Search for an unmapped address range.
70370 @@ -1498,7 +1513,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
70371 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
70372 */
70373 static inline unsigned long
70374 -vm_unmapped_area(struct vm_unmapped_area_info *info)
70375 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
70376 {
70377 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
70378 return unmapped_area(info);
70379 @@ -1561,6 +1576,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70380 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70381 struct vm_area_struct **pprev);
70382
70383 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70384 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70385 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70386 +
70387 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70388 NULL if none. Assume start_addr < end_addr. */
70389 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70390 @@ -1589,15 +1608,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70391 return vma;
70392 }
70393
70394 -#ifdef CONFIG_MMU
70395 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70396 -#else
70397 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70398 -{
70399 - return __pgprot(0);
70400 -}
70401 -#endif
70402 -
70403 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70404 unsigned long change_prot_numa(struct vm_area_struct *vma,
70405 unsigned long start, unsigned long end);
70406 @@ -1649,6 +1659,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70407 static inline void vm_stat_account(struct mm_struct *mm,
70408 unsigned long flags, struct file *file, long pages)
70409 {
70410 +
70411 +#ifdef CONFIG_PAX_RANDMMAP
70412 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70413 +#endif
70414 +
70415 mm->total_vm += pages;
70416 }
70417 #endif /* CONFIG_PROC_FS */
70418 @@ -1725,7 +1740,7 @@ extern int unpoison_memory(unsigned long pfn);
70419 extern int sysctl_memory_failure_early_kill;
70420 extern int sysctl_memory_failure_recovery;
70421 extern void shake_page(struct page *p, int access);
70422 -extern atomic_long_t num_poisoned_pages;
70423 +extern atomic_long_unchecked_t num_poisoned_pages;
70424 extern int soft_offline_page(struct page *page, int flags);
70425
70426 extern void dump_page(struct page *page);
70427 @@ -1756,5 +1771,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70428 static inline bool page_is_guard(struct page *page) { return false; }
70429 #endif /* CONFIG_DEBUG_PAGEALLOC */
70430
70431 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70432 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70433 +#else
70434 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70435 +#endif
70436 +
70437 #endif /* __KERNEL__ */
70438 #endif /* _LINUX_MM_H */
70439 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70440 index ace9a5f..81bdb59 100644
70441 --- a/include/linux/mm_types.h
70442 +++ b/include/linux/mm_types.h
70443 @@ -289,6 +289,8 @@ struct vm_area_struct {
70444 #ifdef CONFIG_NUMA
70445 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70446 #endif
70447 +
70448 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70449 };
70450
70451 struct core_thread {
70452 @@ -437,6 +439,24 @@ struct mm_struct {
70453 int first_nid;
70454 #endif
70455 struct uprobes_state uprobes_state;
70456 +
70457 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70458 + unsigned long pax_flags;
70459 +#endif
70460 +
70461 +#ifdef CONFIG_PAX_DLRESOLVE
70462 + unsigned long call_dl_resolve;
70463 +#endif
70464 +
70465 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70466 + unsigned long call_syscall;
70467 +#endif
70468 +
70469 +#ifdef CONFIG_PAX_ASLR
70470 + unsigned long delta_mmap; /* randomized offset */
70471 + unsigned long delta_stack; /* randomized offset */
70472 +#endif
70473 +
70474 };
70475
70476 /* first nid will either be a valid NID or one of these values */
70477 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70478 index c5d5278..f0b68c8 100644
70479 --- a/include/linux/mmiotrace.h
70480 +++ b/include/linux/mmiotrace.h
70481 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70482 /* Called from ioremap.c */
70483 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70484 void __iomem *addr);
70485 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70486 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70487
70488 /* For anyone to insert markers. Remember trailing newline. */
70489 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70490 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70491 {
70492 }
70493
70494 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70495 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70496 {
70497 }
70498
70499 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70500 index c74092e..b663967 100644
70501 --- a/include/linux/mmzone.h
70502 +++ b/include/linux/mmzone.h
70503 @@ -396,7 +396,7 @@ struct zone {
70504 unsigned long flags; /* zone flags, see below */
70505
70506 /* Zone statistics */
70507 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70508 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70509
70510 /*
70511 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70512 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70513 index 779cf7c..e6768240 100644
70514 --- a/include/linux/mod_devicetable.h
70515 +++ b/include/linux/mod_devicetable.h
70516 @@ -12,7 +12,7 @@
70517 typedef unsigned long kernel_ulong_t;
70518 #endif
70519
70520 -#define PCI_ANY_ID (~0)
70521 +#define PCI_ANY_ID ((__u16)~0)
70522
70523 struct pci_device_id {
70524 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70525 @@ -138,7 +138,7 @@ struct usb_device_id {
70526 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70527 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70528
70529 -#define HID_ANY_ID (~0)
70530 +#define HID_ANY_ID (~0U)
70531 #define HID_BUS_ANY 0xffff
70532 #define HID_GROUP_ANY 0x0000
70533
70534 @@ -464,7 +464,7 @@ struct dmi_system_id {
70535 const char *ident;
70536 struct dmi_strmatch matches[4];
70537 void *driver_data;
70538 -};
70539 +} __do_const;
70540 /*
70541 * struct dmi_device_id appears during expansion of
70542 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70543 diff --git a/include/linux/module.h b/include/linux/module.h
70544 index ead1b57..81a3b6c 100644
70545 --- a/include/linux/module.h
70546 +++ b/include/linux/module.h
70547 @@ -17,9 +17,11 @@
70548 #include <linux/moduleparam.h>
70549 #include <linux/tracepoint.h>
70550 #include <linux/export.h>
70551 +#include <linux/fs.h>
70552
70553 #include <linux/percpu.h>
70554 #include <asm/module.h>
70555 +#include <asm/pgtable.h>
70556
70557 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70558 #define MODULE_SIG_STRING "~Module signature appended~\n"
70559 @@ -54,12 +56,13 @@ struct module_attribute {
70560 int (*test)(struct module *);
70561 void (*free)(struct module *);
70562 };
70563 +typedef struct module_attribute __no_const module_attribute_no_const;
70564
70565 struct module_version_attribute {
70566 struct module_attribute mattr;
70567 const char *module_name;
70568 const char *version;
70569 -} __attribute__ ((__aligned__(sizeof(void *))));
70570 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70571
70572 extern ssize_t __modver_version_show(struct module_attribute *,
70573 struct module_kobject *, char *);
70574 @@ -232,7 +235,7 @@ struct module
70575
70576 /* Sysfs stuff. */
70577 struct module_kobject mkobj;
70578 - struct module_attribute *modinfo_attrs;
70579 + module_attribute_no_const *modinfo_attrs;
70580 const char *version;
70581 const char *srcversion;
70582 struct kobject *holders_dir;
70583 @@ -281,19 +284,16 @@ struct module
70584 int (*init)(void);
70585
70586 /* If this is non-NULL, vfree after init() returns */
70587 - void *module_init;
70588 + void *module_init_rx, *module_init_rw;
70589
70590 /* Here is the actual code + data, vfree'd on unload. */
70591 - void *module_core;
70592 + void *module_core_rx, *module_core_rw;
70593
70594 /* Here are the sizes of the init and core sections */
70595 - unsigned int init_size, core_size;
70596 + unsigned int init_size_rw, core_size_rw;
70597
70598 /* The size of the executable code in each section. */
70599 - unsigned int init_text_size, core_text_size;
70600 -
70601 - /* Size of RO sections of the module (text+rodata) */
70602 - unsigned int init_ro_size, core_ro_size;
70603 + unsigned int init_size_rx, core_size_rx;
70604
70605 /* Arch-specific module values */
70606 struct mod_arch_specific arch;
70607 @@ -349,6 +349,10 @@ struct module
70608 #ifdef CONFIG_EVENT_TRACING
70609 struct ftrace_event_call **trace_events;
70610 unsigned int num_trace_events;
70611 + struct file_operations trace_id;
70612 + struct file_operations trace_enable;
70613 + struct file_operations trace_format;
70614 + struct file_operations trace_filter;
70615 #endif
70616 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70617 unsigned int num_ftrace_callsites;
70618 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70619 bool is_module_percpu_address(unsigned long addr);
70620 bool is_module_text_address(unsigned long addr);
70621
70622 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70623 +{
70624 +
70625 +#ifdef CONFIG_PAX_KERNEXEC
70626 + if (ktla_ktva(addr) >= (unsigned long)start &&
70627 + ktla_ktva(addr) < (unsigned long)start + size)
70628 + return 1;
70629 +#endif
70630 +
70631 + return ((void *)addr >= start && (void *)addr < start + size);
70632 +}
70633 +
70634 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
70635 +{
70636 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70637 +}
70638 +
70639 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
70640 +{
70641 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70642 +}
70643 +
70644 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
70645 +{
70646 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70647 +}
70648 +
70649 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
70650 +{
70651 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70652 +}
70653 +
70654 static inline int within_module_core(unsigned long addr, const struct module *mod)
70655 {
70656 - return (unsigned long)mod->module_core <= addr &&
70657 - addr < (unsigned long)mod->module_core + mod->core_size;
70658 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70659 }
70660
70661 static inline int within_module_init(unsigned long addr, const struct module *mod)
70662 {
70663 - return (unsigned long)mod->module_init <= addr &&
70664 - addr < (unsigned long)mod->module_init + mod->init_size;
70665 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70666 }
70667
70668 /* Search for module by name: must hold module_mutex. */
70669 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70670 index 560ca53..ef621ef 100644
70671 --- a/include/linux/moduleloader.h
70672 +++ b/include/linux/moduleloader.h
70673 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70674 sections. Returns NULL on failure. */
70675 void *module_alloc(unsigned long size);
70676
70677 +#ifdef CONFIG_PAX_KERNEXEC
70678 +void *module_alloc_exec(unsigned long size);
70679 +#else
70680 +#define module_alloc_exec(x) module_alloc(x)
70681 +#endif
70682 +
70683 /* Free memory returned from module_alloc. */
70684 void module_free(struct module *mod, void *module_region);
70685
70686 +#ifdef CONFIG_PAX_KERNEXEC
70687 +void module_free_exec(struct module *mod, void *module_region);
70688 +#else
70689 +#define module_free_exec(x, y) module_free((x), (y))
70690 +#endif
70691 +
70692 /*
70693 * Apply the given relocation to the (simplified) ELF. Return -error
70694 * or 0.
70695 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70696 unsigned int relsec,
70697 struct module *me)
70698 {
70699 +#ifdef CONFIG_MODULES
70700 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70701 +#endif
70702 return -ENOEXEC;
70703 }
70704 #endif
70705 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70706 unsigned int relsec,
70707 struct module *me)
70708 {
70709 +#ifdef CONFIG_MODULES
70710 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70711 +#endif
70712 return -ENOEXEC;
70713 }
70714 #endif
70715 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70716 index 137b419..fe663ec 100644
70717 --- a/include/linux/moduleparam.h
70718 +++ b/include/linux/moduleparam.h
70719 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70720 * @len is usually just sizeof(string).
70721 */
70722 #define module_param_string(name, string, len, perm) \
70723 - static const struct kparam_string __param_string_##name \
70724 + static const struct kparam_string __param_string_##name __used \
70725 = { len, string }; \
70726 __module_param_call(MODULE_PARAM_PREFIX, name, \
70727 &param_ops_string, \
70728 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70729 */
70730 #define module_param_array_named(name, array, type, nump, perm) \
70731 param_check_##type(name, &(array)[0]); \
70732 - static const struct kparam_array __param_arr_##name \
70733 + static const struct kparam_array __param_arr_##name __used \
70734 = { .max = ARRAY_SIZE(array), .num = nump, \
70735 .ops = &param_ops_##type, \
70736 .elemsize = sizeof(array[0]), .elem = array }; \
70737 diff --git a/include/linux/namei.h b/include/linux/namei.h
70738 index 5a5ff57..5ae5070 100644
70739 --- a/include/linux/namei.h
70740 +++ b/include/linux/namei.h
70741 @@ -19,7 +19,7 @@ struct nameidata {
70742 unsigned seq;
70743 int last_type;
70744 unsigned depth;
70745 - char *saved_names[MAX_NESTED_LINKS + 1];
70746 + const char *saved_names[MAX_NESTED_LINKS + 1];
70747 };
70748
70749 /*
70750 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70751
70752 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70753
70754 -static inline void nd_set_link(struct nameidata *nd, char *path)
70755 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70756 {
70757 nd->saved_names[nd->depth] = path;
70758 }
70759
70760 -static inline char *nd_get_link(struct nameidata *nd)
70761 +static inline const char *nd_get_link(const struct nameidata *nd)
70762 {
70763 return nd->saved_names[nd->depth];
70764 }
70765 diff --git a/include/linux/net.h b/include/linux/net.h
70766 index aa16731..514b875 100644
70767 --- a/include/linux/net.h
70768 +++ b/include/linux/net.h
70769 @@ -183,7 +183,7 @@ struct net_proto_family {
70770 int (*create)(struct net *net, struct socket *sock,
70771 int protocol, int kern);
70772 struct module *owner;
70773 -};
70774 +} __do_const;
70775
70776 struct iovec;
70777 struct kvec;
70778 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70779 index 6151e90..2e0afb0 100644
70780 --- a/include/linux/netdevice.h
70781 +++ b/include/linux/netdevice.h
70782 @@ -1028,6 +1028,7 @@ struct net_device_ops {
70783 int (*ndo_change_carrier)(struct net_device *dev,
70784 bool new_carrier);
70785 };
70786 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70787
70788 /*
70789 * The DEVICE structure.
70790 @@ -1094,7 +1095,7 @@ struct net_device {
70791 int iflink;
70792
70793 struct net_device_stats stats;
70794 - atomic_long_t rx_dropped; /* dropped packets by core network
70795 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70796 * Do not use this in drivers.
70797 */
70798
70799 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70800 index ee14284..bc65d63 100644
70801 --- a/include/linux/netfilter.h
70802 +++ b/include/linux/netfilter.h
70803 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70804 #endif
70805 /* Use the module struct to lock set/get code in place */
70806 struct module *owner;
70807 -};
70808 +} __do_const;
70809
70810 /* Function to register/unregister hook points. */
70811 int nf_register_hook(struct nf_hook_ops *reg);
70812 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70813 index 7958e84..ed74d7a 100644
70814 --- a/include/linux/netfilter/ipset/ip_set.h
70815 +++ b/include/linux/netfilter/ipset/ip_set.h
70816 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70817 /* Return true if "b" set is the same as "a"
70818 * according to the create set parameters */
70819 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70820 -};
70821 +} __do_const;
70822
70823 /* The core set type structure */
70824 struct ip_set_type {
70825 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70826 index ecbb8e4..8a1c4e1 100644
70827 --- a/include/linux/netfilter/nfnetlink.h
70828 +++ b/include/linux/netfilter/nfnetlink.h
70829 @@ -16,7 +16,7 @@ struct nfnl_callback {
70830 const struct nlattr * const cda[]);
70831 const struct nla_policy *policy; /* netlink attribute policy */
70832 const u_int16_t attr_count; /* number of nlattr's */
70833 -};
70834 +} __do_const;
70835
70836 struct nfnetlink_subsystem {
70837 const char *name;
70838 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70839 new file mode 100644
70840 index 0000000..33f4af8
70841 --- /dev/null
70842 +++ b/include/linux/netfilter/xt_gradm.h
70843 @@ -0,0 +1,9 @@
70844 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70845 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70846 +
70847 +struct xt_gradm_mtinfo {
70848 + __u16 flags;
70849 + __u16 invflags;
70850 +};
70851 +
70852 +#endif
70853 diff --git a/include/linux/nls.h b/include/linux/nls.h
70854 index 5dc635f..35f5e11 100644
70855 --- a/include/linux/nls.h
70856 +++ b/include/linux/nls.h
70857 @@ -31,7 +31,7 @@ struct nls_table {
70858 const unsigned char *charset2upper;
70859 struct module *owner;
70860 struct nls_table *next;
70861 -};
70862 +} __do_const;
70863
70864 /* this value hold the maximum octet of charset */
70865 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70866 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70867 index d65746e..62e72c2 100644
70868 --- a/include/linux/notifier.h
70869 +++ b/include/linux/notifier.h
70870 @@ -51,7 +51,8 @@ struct notifier_block {
70871 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70872 struct notifier_block __rcu *next;
70873 int priority;
70874 -};
70875 +} __do_const;
70876 +typedef struct notifier_block __no_const notifier_block_no_const;
70877
70878 struct atomic_notifier_head {
70879 spinlock_t lock;
70880 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70881 index a4c5624..79d6d88 100644
70882 --- a/include/linux/oprofile.h
70883 +++ b/include/linux/oprofile.h
70884 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70885 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70886 char const * name, ulong * val);
70887
70888 -/** Create a file for read-only access to an atomic_t. */
70889 +/** Create a file for read-only access to an atomic_unchecked_t. */
70890 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70891 - char const * name, atomic_t * val);
70892 + char const * name, atomic_unchecked_t * val);
70893
70894 /** create a directory */
70895 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70896 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70897 index 45fc162..01a4068 100644
70898 --- a/include/linux/pci_hotplug.h
70899 +++ b/include/linux/pci_hotplug.h
70900 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70901 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70902 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70903 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70904 -};
70905 +} __do_const;
70906 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70907
70908 /**
70909 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70910 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70911 index 1d795df..b0a6449 100644
70912 --- a/include/linux/perf_event.h
70913 +++ b/include/linux/perf_event.h
70914 @@ -333,8 +333,8 @@ struct perf_event {
70915
70916 enum perf_event_active_state state;
70917 unsigned int attach_state;
70918 - local64_t count;
70919 - atomic64_t child_count;
70920 + local64_t count; /* PaX: fix it one day */
70921 + atomic64_unchecked_t child_count;
70922
70923 /*
70924 * These are the total time in nanoseconds that the event
70925 @@ -385,8 +385,8 @@ struct perf_event {
70926 * These accumulate total time (in nanoseconds) that children
70927 * events have been enabled and running, respectively.
70928 */
70929 - atomic64_t child_total_time_enabled;
70930 - atomic64_t child_total_time_running;
70931 + atomic64_unchecked_t child_total_time_enabled;
70932 + atomic64_unchecked_t child_total_time_running;
70933
70934 /*
70935 * Protect attach/detach and child_list:
70936 @@ -704,7 +704,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
70937 entry->ip[entry->nr++] = ip;
70938 }
70939
70940 -extern int sysctl_perf_event_paranoid;
70941 +extern int sysctl_perf_event_legitimately_concerned;
70942 extern int sysctl_perf_event_mlock;
70943 extern int sysctl_perf_event_sample_rate;
70944
70945 @@ -712,19 +712,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
70946 void __user *buffer, size_t *lenp,
70947 loff_t *ppos);
70948
70949 +static inline bool perf_paranoid_any(void)
70950 +{
70951 + return sysctl_perf_event_legitimately_concerned > 2;
70952 +}
70953 +
70954 static inline bool perf_paranoid_tracepoint_raw(void)
70955 {
70956 - return sysctl_perf_event_paranoid > -1;
70957 + return sysctl_perf_event_legitimately_concerned > -1;
70958 }
70959
70960 static inline bool perf_paranoid_cpu(void)
70961 {
70962 - return sysctl_perf_event_paranoid > 0;
70963 + return sysctl_perf_event_legitimately_concerned > 0;
70964 }
70965
70966 static inline bool perf_paranoid_kernel(void)
70967 {
70968 - return sysctl_perf_event_paranoid > 1;
70969 + return sysctl_perf_event_legitimately_concerned > 1;
70970 }
70971
70972 extern void perf_event_init(void);
70973 @@ -812,7 +817,7 @@ static inline void perf_restore_debug_store(void) { }
70974 */
70975 #define perf_cpu_notifier(fn) \
70976 do { \
70977 - static struct notifier_block fn##_nb __cpuinitdata = \
70978 + static struct notifier_block fn##_nb = \
70979 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70980 unsigned long cpu = smp_processor_id(); \
70981 unsigned long flags; \
70982 @@ -831,7 +836,7 @@ do { \
70983 struct perf_pmu_events_attr {
70984 struct device_attribute attr;
70985 u64 id;
70986 -};
70987 +} __do_const;
70988
70989 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
70990 static struct perf_pmu_events_attr _var = { \
70991 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70992 index ad1a427..6419649 100644
70993 --- a/include/linux/pipe_fs_i.h
70994 +++ b/include/linux/pipe_fs_i.h
70995 @@ -45,9 +45,9 @@ struct pipe_buffer {
70996 struct pipe_inode_info {
70997 wait_queue_head_t wait;
70998 unsigned int nrbufs, curbuf, buffers;
70999 - unsigned int readers;
71000 - unsigned int writers;
71001 - unsigned int waiting_writers;
71002 + atomic_t readers;
71003 + atomic_t writers;
71004 + atomic_t waiting_writers;
71005 unsigned int r_counter;
71006 unsigned int w_counter;
71007 struct page *tmp_page;
71008 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
71009 index 5f28cae..3d23723 100644
71010 --- a/include/linux/platform_data/usb-ehci-s5p.h
71011 +++ b/include/linux/platform_data/usb-ehci-s5p.h
71012 @@ -14,7 +14,7 @@
71013 struct s5p_ehci_platdata {
71014 int (*phy_init)(struct platform_device *pdev, int type);
71015 int (*phy_exit)(struct platform_device *pdev, int type);
71016 -};
71017 +} __no_const;
71018
71019 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
71020
71021 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
71022 index c256c59..8ea94c7 100644
71023 --- a/include/linux/platform_data/usb-exynos.h
71024 +++ b/include/linux/platform_data/usb-exynos.h
71025 @@ -14,7 +14,7 @@
71026 struct exynos4_ohci_platdata {
71027 int (*phy_init)(struct platform_device *pdev, int type);
71028 int (*phy_exit)(struct platform_device *pdev, int type);
71029 -};
71030 +} __no_const;
71031
71032 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
71033
71034 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
71035 index 7c1d252..c5c773e 100644
71036 --- a/include/linux/pm_domain.h
71037 +++ b/include/linux/pm_domain.h
71038 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
71039
71040 struct gpd_cpu_data {
71041 unsigned int saved_exit_latency;
71042 - struct cpuidle_state *idle_state;
71043 + cpuidle_state_no_const *idle_state;
71044 };
71045
71046 struct generic_pm_domain {
71047 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
71048 index 7d7e09e..8671ef8 100644
71049 --- a/include/linux/pm_runtime.h
71050 +++ b/include/linux/pm_runtime.h
71051 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
71052
71053 static inline void pm_runtime_mark_last_busy(struct device *dev)
71054 {
71055 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
71056 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
71057 }
71058
71059 #else /* !CONFIG_PM_RUNTIME */
71060 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
71061 index 195aafc..49a7bc2 100644
71062 --- a/include/linux/pnp.h
71063 +++ b/include/linux/pnp.h
71064 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
71065 struct pnp_fixup {
71066 char id[7];
71067 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
71068 -};
71069 +} __do_const;
71070
71071 /* config parameters */
71072 #define PNP_CONFIG_NORMAL 0x0001
71073 diff --git a/include/linux/poison.h b/include/linux/poison.h
71074 index 2110a81..13a11bb 100644
71075 --- a/include/linux/poison.h
71076 +++ b/include/linux/poison.h
71077 @@ -19,8 +19,8 @@
71078 * under normal circumstances, used to verify that nobody uses
71079 * non-initialized list entries.
71080 */
71081 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
71082 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
71083 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
71084 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
71085
71086 /********** include/linux/timer.h **********/
71087 /*
71088 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71089 index c0f44c2..1572583 100644
71090 --- a/include/linux/power/smartreflex.h
71091 +++ b/include/linux/power/smartreflex.h
71092 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71093 int (*notify)(struct omap_sr *sr, u32 status);
71094 u8 notify_flags;
71095 u8 class_type;
71096 -};
71097 +} __do_const;
71098
71099 /**
71100 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71101 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71102 index 4ea1d37..80f4b33 100644
71103 --- a/include/linux/ppp-comp.h
71104 +++ b/include/linux/ppp-comp.h
71105 @@ -84,7 +84,7 @@ struct compressor {
71106 struct module *owner;
71107 /* Extra skb space needed by the compressor algorithm */
71108 unsigned int comp_extra;
71109 -};
71110 +} __do_const;
71111
71112 /*
71113 * The return value from decompress routine is the length of the
71114 diff --git a/include/linux/printk.h b/include/linux/printk.h
71115 index 822171f..12b30e8 100644
71116 --- a/include/linux/printk.h
71117 +++ b/include/linux/printk.h
71118 @@ -98,6 +98,8 @@ int no_printk(const char *fmt, ...)
71119 extern asmlinkage __printf(1, 2)
71120 void early_printk(const char *fmt, ...);
71121
71122 +extern int kptr_restrict;
71123 +
71124 #ifdef CONFIG_PRINTK
71125 asmlinkage __printf(5, 0)
71126 int vprintk_emit(int facility, int level,
71127 @@ -132,7 +134,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71128
71129 extern int printk_delay_msec;
71130 extern int dmesg_restrict;
71131 -extern int kptr_restrict;
71132
71133 extern void wake_up_klogd(void);
71134
71135 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71136 index 94dfb2a..88b9d3b 100644
71137 --- a/include/linux/proc_fs.h
71138 +++ b/include/linux/proc_fs.h
71139 @@ -165,6 +165,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
71140 return proc_create_data(name, mode, parent, proc_fops, NULL);
71141 }
71142
71143 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71144 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71145 +{
71146 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71147 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71148 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71149 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71150 +#else
71151 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71152 +#endif
71153 +}
71154 +
71155 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
71156 umode_t mode, struct proc_dir_entry *base,
71157 read_proc_t *read_proc, void * data)
71158 @@ -266,7 +278,7 @@ struct proc_ns_operations {
71159 void (*put)(void *ns);
71160 int (*install)(struct nsproxy *nsproxy, void *ns);
71161 unsigned int (*inum)(void *ns);
71162 -};
71163 +} __do_const;
71164 extern const struct proc_ns_operations netns_operations;
71165 extern const struct proc_ns_operations utsns_operations;
71166 extern const struct proc_ns_operations ipcns_operations;
71167 diff --git a/include/linux/random.h b/include/linux/random.h
71168 index 347ce55..880f97c 100644
71169 --- a/include/linux/random.h
71170 +++ b/include/linux/random.h
71171 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
71172 u32 prandom_u32_state(struct rnd_state *);
71173 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71174
71175 +static inline unsigned long pax_get_random_long(void)
71176 +{
71177 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71178 +}
71179 +
71180 /*
71181 * Handle minimum values for seeds
71182 */
71183 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71184 index 8089e35..3a0d59a 100644
71185 --- a/include/linux/rculist.h
71186 +++ b/include/linux/rculist.h
71187 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71188 struct list_head *prev, struct list_head *next);
71189 #endif
71190
71191 +extern void __pax_list_add_rcu(struct list_head *new,
71192 + struct list_head *prev, struct list_head *next);
71193 +
71194 /**
71195 * list_add_rcu - add a new entry to rcu-protected list
71196 * @new: new entry to be added
71197 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71198 __list_add_rcu(new, head, head->next);
71199 }
71200
71201 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71202 +{
71203 + __pax_list_add_rcu(new, head, head->next);
71204 +}
71205 +
71206 /**
71207 * list_add_tail_rcu - add a new entry to rcu-protected list
71208 * @new: new entry to be added
71209 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71210 __list_add_rcu(new, head->prev, head);
71211 }
71212
71213 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71214 + struct list_head *head)
71215 +{
71216 + __pax_list_add_rcu(new, head->prev, head);
71217 +}
71218 +
71219 /**
71220 * list_del_rcu - deletes entry from list without re-initialization
71221 * @entry: the element to delete from the list.
71222 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71223 entry->prev = LIST_POISON2;
71224 }
71225
71226 +extern void pax_list_del_rcu(struct list_head *entry);
71227 +
71228 /**
71229 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71230 * @n: the element to delete from the hash list.
71231 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71232 index 23b3630..e1bc12b 100644
71233 --- a/include/linux/reboot.h
71234 +++ b/include/linux/reboot.h
71235 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71236 * Architecture-specific implementations of sys_reboot commands.
71237 */
71238
71239 -extern void machine_restart(char *cmd);
71240 -extern void machine_halt(void);
71241 -extern void machine_power_off(void);
71242 +extern void machine_restart(char *cmd) __noreturn;
71243 +extern void machine_halt(void) __noreturn;
71244 +extern void machine_power_off(void) __noreturn;
71245
71246 extern void machine_shutdown(void);
71247 struct pt_regs;
71248 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71249 */
71250
71251 extern void kernel_restart_prepare(char *cmd);
71252 -extern void kernel_restart(char *cmd);
71253 -extern void kernel_halt(void);
71254 -extern void kernel_power_off(void);
71255 +extern void kernel_restart(char *cmd) __noreturn;
71256 +extern void kernel_halt(void) __noreturn;
71257 +extern void kernel_power_off(void) __noreturn;
71258
71259 extern int C_A_D; /* for sysctl */
71260 void ctrl_alt_del(void);
71261 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71262 * Emergency restart, callable from an interrupt handler.
71263 */
71264
71265 -extern void emergency_restart(void);
71266 +extern void emergency_restart(void) __noreturn;
71267 #include <asm/emergency-restart.h>
71268
71269 #endif /* _LINUX_REBOOT_H */
71270 diff --git a/include/linux/regset.h b/include/linux/regset.h
71271 index 8e0c9fe..ac4d221 100644
71272 --- a/include/linux/regset.h
71273 +++ b/include/linux/regset.h
71274 @@ -161,7 +161,8 @@ struct user_regset {
71275 unsigned int align;
71276 unsigned int bias;
71277 unsigned int core_note_type;
71278 -};
71279 +} __do_const;
71280 +typedef struct user_regset __no_const user_regset_no_const;
71281
71282 /**
71283 * struct user_regset_view - available regsets
71284 diff --git a/include/linux/relay.h b/include/linux/relay.h
71285 index 91cacc3..b55ff74 100644
71286 --- a/include/linux/relay.h
71287 +++ b/include/linux/relay.h
71288 @@ -160,7 +160,7 @@ struct rchan_callbacks
71289 * The callback should return 0 if successful, negative if not.
71290 */
71291 int (*remove_buf_file)(struct dentry *dentry);
71292 -};
71293 +} __no_const;
71294
71295 /*
71296 * CONFIG_RELAY kernel API, kernel/relay.c
71297 diff --git a/include/linux/rio.h b/include/linux/rio.h
71298 index a3e7842..d973ca6 100644
71299 --- a/include/linux/rio.h
71300 +++ b/include/linux/rio.h
71301 @@ -339,7 +339,7 @@ struct rio_ops {
71302 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71303 u64 rstart, u32 size, u32 flags);
71304 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71305 -};
71306 +} __no_const;
71307
71308 #define RIO_RESOURCE_MEM 0x00000100
71309 #define RIO_RESOURCE_DOORBELL 0x00000200
71310 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71311 index 6dacb93..6174423 100644
71312 --- a/include/linux/rmap.h
71313 +++ b/include/linux/rmap.h
71314 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71315 void anon_vma_init(void); /* create anon_vma_cachep */
71316 int anon_vma_prepare(struct vm_area_struct *);
71317 void unlink_anon_vmas(struct vm_area_struct *);
71318 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71319 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71320 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71321 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71322
71323 static inline void anon_vma_merge(struct vm_area_struct *vma,
71324 struct vm_area_struct *next)
71325 diff --git a/include/linux/sched.h b/include/linux/sched.h
71326 index be4e742..7f9d593 100644
71327 --- a/include/linux/sched.h
71328 +++ b/include/linux/sched.h
71329 @@ -62,6 +62,7 @@ struct bio_list;
71330 struct fs_struct;
71331 struct perf_event_context;
71332 struct blk_plug;
71333 +struct linux_binprm;
71334
71335 /*
71336 * List of flags we want to share for kernel threads,
71337 @@ -315,7 +316,7 @@ extern char __sched_text_start[], __sched_text_end[];
71338 extern int in_sched_functions(unsigned long addr);
71339
71340 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71341 -extern signed long schedule_timeout(signed long timeout);
71342 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71343 extern signed long schedule_timeout_interruptible(signed long timeout);
71344 extern signed long schedule_timeout_killable(signed long timeout);
71345 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71346 @@ -329,6 +330,18 @@ struct user_namespace;
71347 #include <linux/aio.h>
71348
71349 #ifdef CONFIG_MMU
71350 +
71351 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71352 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71353 +#else
71354 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71355 +{
71356 + return 0;
71357 +}
71358 +#endif
71359 +
71360 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71361 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71362 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71363 extern unsigned long
71364 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71365 @@ -605,6 +618,17 @@ struct signal_struct {
71366 #ifdef CONFIG_TASKSTATS
71367 struct taskstats *stats;
71368 #endif
71369 +
71370 +#ifdef CONFIG_GRKERNSEC
71371 + u32 curr_ip;
71372 + u32 saved_ip;
71373 + u32 gr_saddr;
71374 + u32 gr_daddr;
71375 + u16 gr_sport;
71376 + u16 gr_dport;
71377 + u8 used_accept:1;
71378 +#endif
71379 +
71380 #ifdef CONFIG_AUDIT
71381 unsigned audit_tty;
71382 struct tty_audit_buf *tty_audit_buf;
71383 @@ -683,6 +707,11 @@ struct user_struct {
71384 struct key *session_keyring; /* UID's default session keyring */
71385 #endif
71386
71387 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71388 + unsigned int banned;
71389 + unsigned long ban_expires;
71390 +#endif
71391 +
71392 /* Hash table maintenance information */
71393 struct hlist_node uidhash_node;
71394 kuid_t uid;
71395 @@ -1082,7 +1111,7 @@ struct sched_class {
71396 #ifdef CONFIG_FAIR_GROUP_SCHED
71397 void (*task_move_group) (struct task_struct *p, int on_rq);
71398 #endif
71399 -};
71400 +} __do_const;
71401
71402 struct load_weight {
71403 unsigned long weight, inv_weight;
71404 @@ -1323,8 +1352,8 @@ struct task_struct {
71405 struct list_head thread_group;
71406
71407 struct completion *vfork_done; /* for vfork() */
71408 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71409 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71410 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71411 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71412
71413 cputime_t utime, stime, utimescaled, stimescaled;
71414 cputime_t gtime;
71415 @@ -1349,11 +1378,6 @@ struct task_struct {
71416 struct task_cputime cputime_expires;
71417 struct list_head cpu_timers[3];
71418
71419 -/* process credentials */
71420 - const struct cred __rcu *real_cred; /* objective and real subjective task
71421 - * credentials (COW) */
71422 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71423 - * credentials (COW) */
71424 char comm[TASK_COMM_LEN]; /* executable name excluding path
71425 - access with [gs]et_task_comm (which lock
71426 it with task_lock())
71427 @@ -1370,6 +1394,10 @@ struct task_struct {
71428 #endif
71429 /* CPU-specific state of this task */
71430 struct thread_struct thread;
71431 +/* thread_info moved to task_struct */
71432 +#ifdef CONFIG_X86
71433 + struct thread_info tinfo;
71434 +#endif
71435 /* filesystem information */
71436 struct fs_struct *fs;
71437 /* open file information */
71438 @@ -1443,6 +1471,10 @@ struct task_struct {
71439 gfp_t lockdep_reclaim_gfp;
71440 #endif
71441
71442 +/* process credentials */
71443 + const struct cred __rcu *real_cred; /* objective and real subjective task
71444 + * credentials (COW) */
71445 +
71446 /* journalling filesystem info */
71447 void *journal_info;
71448
71449 @@ -1481,6 +1513,10 @@ struct task_struct {
71450 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71451 struct list_head cg_list;
71452 #endif
71453 +
71454 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71455 + * credentials (COW) */
71456 +
71457 #ifdef CONFIG_FUTEX
71458 struct robust_list_head __user *robust_list;
71459 #ifdef CONFIG_COMPAT
71460 @@ -1577,8 +1613,74 @@ struct task_struct {
71461 #ifdef CONFIG_UPROBES
71462 struct uprobe_task *utask;
71463 #endif
71464 +
71465 +#ifdef CONFIG_GRKERNSEC
71466 + /* grsecurity */
71467 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71468 + u64 exec_id;
71469 +#endif
71470 +#ifdef CONFIG_GRKERNSEC_SETXID
71471 + const struct cred *delayed_cred;
71472 +#endif
71473 + struct dentry *gr_chroot_dentry;
71474 + struct acl_subject_label *acl;
71475 + struct acl_role_label *role;
71476 + struct file *exec_file;
71477 + unsigned long brute_expires;
71478 + u16 acl_role_id;
71479 + /* is this the task that authenticated to the special role */
71480 + u8 acl_sp_role;
71481 + u8 is_writable;
71482 + u8 brute;
71483 + u8 gr_is_chrooted;
71484 +#endif
71485 +
71486 };
71487
71488 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71489 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71490 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71491 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71492 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71493 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71494 +
71495 +#ifdef CONFIG_PAX_SOFTMODE
71496 +extern int pax_softmode;
71497 +#endif
71498 +
71499 +extern int pax_check_flags(unsigned long *);
71500 +
71501 +/* if tsk != current then task_lock must be held on it */
71502 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71503 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71504 +{
71505 + if (likely(tsk->mm))
71506 + return tsk->mm->pax_flags;
71507 + else
71508 + return 0UL;
71509 +}
71510 +
71511 +/* if tsk != current then task_lock must be held on it */
71512 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71513 +{
71514 + if (likely(tsk->mm)) {
71515 + tsk->mm->pax_flags = flags;
71516 + return 0;
71517 + }
71518 + return -EINVAL;
71519 +}
71520 +#endif
71521 +
71522 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71523 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71524 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71525 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71526 +#endif
71527 +
71528 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71529 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71530 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71531 +
71532 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71533 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71534
71535 @@ -1637,7 +1739,7 @@ struct pid_namespace;
71536 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71537 struct pid_namespace *ns);
71538
71539 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71540 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71541 {
71542 return tsk->pid;
71543 }
71544 @@ -2073,7 +2175,9 @@ void yield(void);
71545 extern struct exec_domain default_exec_domain;
71546
71547 union thread_union {
71548 +#ifndef CONFIG_X86
71549 struct thread_info thread_info;
71550 +#endif
71551 unsigned long stack[THREAD_SIZE/sizeof(long)];
71552 };
71553
71554 @@ -2106,6 +2210,7 @@ extern struct pid_namespace init_pid_ns;
71555 */
71556
71557 extern struct task_struct *find_task_by_vpid(pid_t nr);
71558 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71559 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71560 struct pid_namespace *ns);
71561
71562 @@ -2272,7 +2377,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71563 extern void exit_itimers(struct signal_struct *);
71564 extern void flush_itimer_signals(void);
71565
71566 -extern void do_group_exit(int);
71567 +extern __noreturn void do_group_exit(int);
71568
71569 extern int allow_signal(int);
71570 extern int disallow_signal(int);
71571 @@ -2463,9 +2568,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71572
71573 #endif
71574
71575 -static inline int object_is_on_stack(void *obj)
71576 +static inline int object_starts_on_stack(void *obj)
71577 {
71578 - void *stack = task_stack_page(current);
71579 + const void *stack = task_stack_page(current);
71580
71581 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71582 }
71583 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
71584 index bf8086b..962b035 100644
71585 --- a/include/linux/sched/sysctl.h
71586 +++ b/include/linux/sched/sysctl.h
71587 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
71588 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71589
71590 extern int sysctl_max_map_count;
71591 +extern unsigned long sysctl_heap_stack_gap;
71592
71593 extern unsigned int sysctl_sched_latency;
71594 extern unsigned int sysctl_sched_min_granularity;
71595 diff --git a/include/linux/security.h b/include/linux/security.h
71596 index 032c366..2c1c2dc2 100644
71597 --- a/include/linux/security.h
71598 +++ b/include/linux/security.h
71599 @@ -26,6 +26,7 @@
71600 #include <linux/capability.h>
71601 #include <linux/slab.h>
71602 #include <linux/err.h>
71603 +#include <linux/grsecurity.h>
71604
71605 struct linux_binprm;
71606 struct cred;
71607 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71608 index 68a04a3..866e6a1 100644
71609 --- a/include/linux/seq_file.h
71610 +++ b/include/linux/seq_file.h
71611 @@ -26,6 +26,9 @@ struct seq_file {
71612 struct mutex lock;
71613 const struct seq_operations *op;
71614 int poll_event;
71615 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71616 + u64 exec_id;
71617 +#endif
71618 #ifdef CONFIG_USER_NS
71619 struct user_namespace *user_ns;
71620 #endif
71621 @@ -38,6 +41,7 @@ struct seq_operations {
71622 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71623 int (*show) (struct seq_file *m, void *v);
71624 };
71625 +typedef struct seq_operations __no_const seq_operations_no_const;
71626
71627 #define SEQ_SKIP 1
71628
71629 diff --git a/include/linux/shm.h b/include/linux/shm.h
71630 index 429c199..4d42e38 100644
71631 --- a/include/linux/shm.h
71632 +++ b/include/linux/shm.h
71633 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71634
71635 /* The task created the shm object. NULL if the task is dead. */
71636 struct task_struct *shm_creator;
71637 +#ifdef CONFIG_GRKERNSEC
71638 + time_t shm_createtime;
71639 + pid_t shm_lapid;
71640 +#endif
71641 };
71642
71643 /* shm_mode upper byte flags */
71644 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71645 index b8292d8..96db310 100644
71646 --- a/include/linux/skbuff.h
71647 +++ b/include/linux/skbuff.h
71648 @@ -599,7 +599,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71649 extern struct sk_buff *__alloc_skb(unsigned int size,
71650 gfp_t priority, int flags, int node);
71651 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71652 -static inline struct sk_buff *alloc_skb(unsigned int size,
71653 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71654 gfp_t priority)
71655 {
71656 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71657 @@ -709,7 +709,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71658 */
71659 static inline int skb_queue_empty(const struct sk_buff_head *list)
71660 {
71661 - return list->next == (struct sk_buff *)list;
71662 + return list->next == (const struct sk_buff *)list;
71663 }
71664
71665 /**
71666 @@ -722,7 +722,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71667 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71668 const struct sk_buff *skb)
71669 {
71670 - return skb->next == (struct sk_buff *)list;
71671 + return skb->next == (const struct sk_buff *)list;
71672 }
71673
71674 /**
71675 @@ -735,7 +735,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71676 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71677 const struct sk_buff *skb)
71678 {
71679 - return skb->prev == (struct sk_buff *)list;
71680 + return skb->prev == (const struct sk_buff *)list;
71681 }
71682
71683 /**
71684 @@ -1756,7 +1756,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71685 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71686 */
71687 #ifndef NET_SKB_PAD
71688 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71689 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71690 #endif
71691
71692 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71693 @@ -2351,7 +2351,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71694 int noblock, int *err);
71695 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71696 struct poll_table_struct *wait);
71697 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71698 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71699 int offset, struct iovec *to,
71700 int size);
71701 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71702 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
71703 nf_bridge_put(skb->nf_bridge);
71704 skb->nf_bridge = NULL;
71705 #endif
71706 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71707 + skb->nf_trace = 0;
71708 +#endif
71709 }
71710
71711 static inline void nf_reset_trace(struct sk_buff *skb)
71712 diff --git a/include/linux/slab.h b/include/linux/slab.h
71713 index 5d168d7..720bff3 100644
71714 --- a/include/linux/slab.h
71715 +++ b/include/linux/slab.h
71716 @@ -12,13 +12,20 @@
71717 #include <linux/gfp.h>
71718 #include <linux/types.h>
71719 #include <linux/workqueue.h>
71720 -
71721 +#include <linux/err.h>
71722
71723 /*
71724 * Flags to pass to kmem_cache_create().
71725 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71726 */
71727 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71728 +
71729 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71730 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71731 +#else
71732 +#define SLAB_USERCOPY 0x00000000UL
71733 +#endif
71734 +
71735 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71736 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71737 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71738 @@ -89,10 +96,13 @@
71739 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71740 * Both make kfree a no-op.
71741 */
71742 -#define ZERO_SIZE_PTR ((void *)16)
71743 +#define ZERO_SIZE_PTR \
71744 +({ \
71745 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71746 + (void *)(-MAX_ERRNO-1L); \
71747 +})
71748
71749 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71750 - (unsigned long)ZERO_SIZE_PTR)
71751 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71752
71753 /*
71754 * Common fields provided in kmem_cache by all slab allocators
71755 @@ -112,7 +122,7 @@ struct kmem_cache {
71756 unsigned int align; /* Alignment as calculated */
71757 unsigned long flags; /* Active flags on the slab */
71758 const char *name; /* Slab name for sysfs */
71759 - int refcount; /* Use counter */
71760 + atomic_t refcount; /* Use counter */
71761 void (*ctor)(void *); /* Called on object slot creation */
71762 struct list_head list; /* List of all slab caches on the system */
71763 };
71764 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71765 void kfree(const void *);
71766 void kzfree(const void *);
71767 size_t ksize(const void *);
71768 +const char *check_heap_object(const void *ptr, unsigned long n);
71769 +bool is_usercopy_object(const void *ptr);
71770
71771 /*
71772 * Allocator specific definitions. These are mainly used to establish optimized
71773 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71774 * for general use, and so are not documented here. For a full list of
71775 * potential flags, always refer to linux/gfp.h.
71776 */
71777 +
71778 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71779 {
71780 if (size != 0 && n > SIZE_MAX / size)
71781 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71782 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71783 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71784 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71785 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71786 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71787 #define kmalloc_track_caller(size, flags) \
71788 __kmalloc_track_caller(size, flags, _RET_IP_)
71789 #else
71790 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71791 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71792 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71793 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71794 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71795 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71796 #define kmalloc_node_track_caller(size, flags, node) \
71797 __kmalloc_node_track_caller(size, flags, node, \
71798 _RET_IP_)
71799 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71800 index 8bb6e0e..8eb0dbe 100644
71801 --- a/include/linux/slab_def.h
71802 +++ b/include/linux/slab_def.h
71803 @@ -52,7 +52,7 @@ struct kmem_cache {
71804 /* 4) cache creation/removal */
71805 const char *name;
71806 struct list_head list;
71807 - int refcount;
71808 + atomic_t refcount;
71809 int object_size;
71810 int align;
71811
71812 @@ -68,10 +68,10 @@ struct kmem_cache {
71813 unsigned long node_allocs;
71814 unsigned long node_frees;
71815 unsigned long node_overflow;
71816 - atomic_t allochit;
71817 - atomic_t allocmiss;
71818 - atomic_t freehit;
71819 - atomic_t freemiss;
71820 + atomic_unchecked_t allochit;
71821 + atomic_unchecked_t allocmiss;
71822 + atomic_unchecked_t freehit;
71823 + atomic_unchecked_t freemiss;
71824
71825 /*
71826 * If debugging is enabled, then the allocator can add additional
71827 @@ -111,11 +111,16 @@ struct cache_sizes {
71828 #ifdef CONFIG_ZONE_DMA
71829 struct kmem_cache *cs_dmacachep;
71830 #endif
71831 +
71832 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71833 + struct kmem_cache *cs_usercopycachep;
71834 +#endif
71835 +
71836 };
71837 extern struct cache_sizes malloc_sizes[];
71838
71839 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71840 -void *__kmalloc(size_t size, gfp_t flags);
71841 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71842
71843 #ifdef CONFIG_TRACING
71844 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71845 @@ -152,6 +157,13 @@ found:
71846 cachep = malloc_sizes[i].cs_dmacachep;
71847 else
71848 #endif
71849 +
71850 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71851 + if (flags & GFP_USERCOPY)
71852 + cachep = malloc_sizes[i].cs_usercopycachep;
71853 + else
71854 +#endif
71855 +
71856 cachep = malloc_sizes[i].cs_cachep;
71857
71858 ret = kmem_cache_alloc_trace(cachep, flags, size);
71859 @@ -162,7 +174,7 @@ found:
71860 }
71861
71862 #ifdef CONFIG_NUMA
71863 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71864 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71865 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71866
71867 #ifdef CONFIG_TRACING
71868 @@ -205,6 +217,13 @@ found:
71869 cachep = malloc_sizes[i].cs_dmacachep;
71870 else
71871 #endif
71872 +
71873 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71874 + if (flags & GFP_USERCOPY)
71875 + cachep = malloc_sizes[i].cs_usercopycachep;
71876 + else
71877 +#endif
71878 +
71879 cachep = malloc_sizes[i].cs_cachep;
71880
71881 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71882 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71883 index f28e14a..7831211 100644
71884 --- a/include/linux/slob_def.h
71885 +++ b/include/linux/slob_def.h
71886 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71887 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71888 }
71889
71890 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71891 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71892
71893 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71894 {
71895 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71896 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71897 }
71898
71899 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71900 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71901 {
71902 return kmalloc(size, flags);
71903 }
71904 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71905 index 9db4825..ed42fb5 100644
71906 --- a/include/linux/slub_def.h
71907 +++ b/include/linux/slub_def.h
71908 @@ -91,7 +91,7 @@ struct kmem_cache {
71909 struct kmem_cache_order_objects max;
71910 struct kmem_cache_order_objects min;
71911 gfp_t allocflags; /* gfp flags to use on each alloc */
71912 - int refcount; /* Refcount for slab cache destroy */
71913 + atomic_t refcount; /* Refcount for slab cache destroy */
71914 void (*ctor)(void *);
71915 int inuse; /* Offset to metadata */
71916 int align; /* Alignment */
71917 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71918 * Sorry that the following has to be that ugly but some versions of GCC
71919 * have trouble with constant propagation and loops.
71920 */
71921 -static __always_inline int kmalloc_index(size_t size)
71922 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71923 {
71924 if (!size)
71925 return 0;
71926 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71927 }
71928
71929 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71930 -void *__kmalloc(size_t size, gfp_t flags);
71931 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71932
71933 static __always_inline void *
71934 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71935 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71936 }
71937 #endif
71938
71939 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71940 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71941 {
71942 unsigned int order = get_order(size);
71943 return kmalloc_order_trace(size, flags, order);
71944 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71945 }
71946
71947 #ifdef CONFIG_NUMA
71948 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71949 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71950 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71951
71952 #ifdef CONFIG_TRACING
71953 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71954 index e8d702e..0a56eb4 100644
71955 --- a/include/linux/sock_diag.h
71956 +++ b/include/linux/sock_diag.h
71957 @@ -10,7 +10,7 @@ struct sock;
71958 struct sock_diag_handler {
71959 __u8 family;
71960 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71961 -};
71962 +} __do_const;
71963
71964 int sock_diag_register(const struct sock_diag_handler *h);
71965 void sock_diag_unregister(const struct sock_diag_handler *h);
71966 diff --git a/include/linux/socket.h b/include/linux/socket.h
71967 index 2b9f74b..e897bdc 100644
71968 --- a/include/linux/socket.h
71969 +++ b/include/linux/socket.h
71970 @@ -321,6 +321,9 @@ extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
71971
71972 struct timespec;
71973
71974 +/* The __sys_...msg variants allow MSG_CMSG_COMPAT */
71975 +extern long __sys_recvmsg(int fd, struct msghdr __user *msg, unsigned flags);
71976 +extern long __sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
71977 extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
71978 unsigned int flags, struct timespec *timeout);
71979 extern int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg,
71980 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71981 index 680f9a3..f13aeb0 100644
71982 --- a/include/linux/sonet.h
71983 +++ b/include/linux/sonet.h
71984 @@ -7,7 +7,7 @@
71985 #include <uapi/linux/sonet.h>
71986
71987 struct k_sonet_stats {
71988 -#define __HANDLE_ITEM(i) atomic_t i
71989 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71990 __SONET_ITEMS
71991 #undef __HANDLE_ITEM
71992 };
71993 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
71994 index 07d8e53..dc934c9 100644
71995 --- a/include/linux/sunrpc/addr.h
71996 +++ b/include/linux/sunrpc/addr.h
71997 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71998 {
71999 switch (sap->sa_family) {
72000 case AF_INET:
72001 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
72002 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
72003 case AF_INET6:
72004 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
72005 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
72006 }
72007 return 0;
72008 }
72009 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
72010 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
72011 const struct sockaddr *src)
72012 {
72013 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
72014 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
72015 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
72016
72017 dsin->sin_family = ssin->sin_family;
72018 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
72019 if (sa->sa_family != AF_INET6)
72020 return 0;
72021
72022 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
72023 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
72024 }
72025
72026 #endif /* _LINUX_SUNRPC_ADDR_H */
72027 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
72028 index 2cf4ffa..470d140 100644
72029 --- a/include/linux/sunrpc/clnt.h
72030 +++ b/include/linux/sunrpc/clnt.h
72031 @@ -96,7 +96,7 @@ struct rpc_procinfo {
72032 unsigned int p_timer; /* Which RTT timer to use */
72033 u32 p_statidx; /* Which procedure to account */
72034 const char * p_name; /* name of procedure */
72035 -};
72036 +} __do_const;
72037
72038 #ifdef __KERNEL__
72039
72040 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
72041 index 1f0216b..6a4fa50 100644
72042 --- a/include/linux/sunrpc/svc.h
72043 +++ b/include/linux/sunrpc/svc.h
72044 @@ -411,7 +411,7 @@ struct svc_procedure {
72045 unsigned int pc_count; /* call count */
72046 unsigned int pc_cachetype; /* cache info (NFS) */
72047 unsigned int pc_xdrressize; /* maximum size of XDR reply */
72048 -};
72049 +} __do_const;
72050
72051 /*
72052 * Function prototypes.
72053 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
72054 index 0b8e3e6..33e0a01 100644
72055 --- a/include/linux/sunrpc/svc_rdma.h
72056 +++ b/include/linux/sunrpc/svc_rdma.h
72057 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
72058 extern unsigned int svcrdma_max_requests;
72059 extern unsigned int svcrdma_max_req_size;
72060
72061 -extern atomic_t rdma_stat_recv;
72062 -extern atomic_t rdma_stat_read;
72063 -extern atomic_t rdma_stat_write;
72064 -extern atomic_t rdma_stat_sq_starve;
72065 -extern atomic_t rdma_stat_rq_starve;
72066 -extern atomic_t rdma_stat_rq_poll;
72067 -extern atomic_t rdma_stat_rq_prod;
72068 -extern atomic_t rdma_stat_sq_poll;
72069 -extern atomic_t rdma_stat_sq_prod;
72070 +extern atomic_unchecked_t rdma_stat_recv;
72071 +extern atomic_unchecked_t rdma_stat_read;
72072 +extern atomic_unchecked_t rdma_stat_write;
72073 +extern atomic_unchecked_t rdma_stat_sq_starve;
72074 +extern atomic_unchecked_t rdma_stat_rq_starve;
72075 +extern atomic_unchecked_t rdma_stat_rq_poll;
72076 +extern atomic_unchecked_t rdma_stat_rq_prod;
72077 +extern atomic_unchecked_t rdma_stat_sq_poll;
72078 +extern atomic_unchecked_t rdma_stat_sq_prod;
72079
72080 #define RPCRDMA_VERSION 1
72081
72082 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
72083 index ff374ab..7fd2ecb 100644
72084 --- a/include/linux/sunrpc/svcauth.h
72085 +++ b/include/linux/sunrpc/svcauth.h
72086 @@ -109,7 +109,7 @@ struct auth_ops {
72087 int (*release)(struct svc_rqst *rq);
72088 void (*domain_release)(struct auth_domain *);
72089 int (*set_client)(struct svc_rqst *rq);
72090 -};
72091 +} __do_const;
72092
72093 #define SVC_GARBAGE 1
72094 #define SVC_SYSERR 2
72095 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
72096 index a5ffd32..0935dea 100644
72097 --- a/include/linux/swiotlb.h
72098 +++ b/include/linux/swiotlb.h
72099 @@ -60,7 +60,8 @@ extern void
72100
72101 extern void
72102 swiotlb_free_coherent(struct device *hwdev, size_t size,
72103 - void *vaddr, dma_addr_t dma_handle);
72104 + void *vaddr, dma_addr_t dma_handle,
72105 + struct dma_attrs *attrs);
72106
72107 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
72108 unsigned long offset, size_t size,
72109 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
72110 index 313a8e0..6b273a9 100644
72111 --- a/include/linux/syscalls.h
72112 +++ b/include/linux/syscalls.h
72113 @@ -418,11 +418,11 @@ asmlinkage long sys_sync(void);
72114 asmlinkage long sys_fsync(unsigned int fd);
72115 asmlinkage long sys_fdatasync(unsigned int fd);
72116 asmlinkage long sys_bdflush(int func, long data);
72117 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
72118 - char __user *type, unsigned long flags,
72119 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
72120 + const char __user *type, unsigned long flags,
72121 void __user *data);
72122 -asmlinkage long sys_umount(char __user *name, int flags);
72123 -asmlinkage long sys_oldumount(char __user *name);
72124 +asmlinkage long sys_umount(const char __user *name, int flags);
72125 +asmlinkage long sys_oldumount(const char __user *name);
72126 asmlinkage long sys_truncate(const char __user *path, long length);
72127 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
72128 asmlinkage long sys_stat(const char __user *filename,
72129 @@ -634,7 +634,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72130 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72131 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72132 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72133 - struct sockaddr __user *, int);
72134 + struct sockaddr __user *, int) __intentional_overflow(0);
72135 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72136 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72137 unsigned int vlen, unsigned flags);
72138 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72139 index 27b3b0b..e093dd9 100644
72140 --- a/include/linux/syscore_ops.h
72141 +++ b/include/linux/syscore_ops.h
72142 @@ -16,7 +16,7 @@ struct syscore_ops {
72143 int (*suspend)(void);
72144 void (*resume)(void);
72145 void (*shutdown)(void);
72146 -};
72147 +} __do_const;
72148
72149 extern void register_syscore_ops(struct syscore_ops *ops);
72150 extern void unregister_syscore_ops(struct syscore_ops *ops);
72151 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72152 index 14a8ff2..af52bad 100644
72153 --- a/include/linux/sysctl.h
72154 +++ b/include/linux/sysctl.h
72155 @@ -34,13 +34,13 @@ struct ctl_table_root;
72156 struct ctl_table_header;
72157 struct ctl_dir;
72158
72159 -typedef struct ctl_table ctl_table;
72160 -
72161 typedef int proc_handler (struct ctl_table *ctl, int write,
72162 void __user *buffer, size_t *lenp, loff_t *ppos);
72163
72164 extern int proc_dostring(struct ctl_table *, int,
72165 void __user *, size_t *, loff_t *);
72166 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72167 + void __user *, size_t *, loff_t *);
72168 extern int proc_dointvec(struct ctl_table *, int,
72169 void __user *, size_t *, loff_t *);
72170 extern int proc_dointvec_minmax(struct ctl_table *, int,
72171 @@ -115,7 +115,9 @@ struct ctl_table
72172 struct ctl_table_poll *poll;
72173 void *extra1;
72174 void *extra2;
72175 -};
72176 +} __do_const;
72177 +typedef struct ctl_table __no_const ctl_table_no_const;
72178 +typedef struct ctl_table ctl_table;
72179
72180 struct ctl_node {
72181 struct rb_node node;
72182 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72183 index e2cee22..3ddb921 100644
72184 --- a/include/linux/sysfs.h
72185 +++ b/include/linux/sysfs.h
72186 @@ -31,7 +31,8 @@ struct attribute {
72187 struct lock_class_key *key;
72188 struct lock_class_key skey;
72189 #endif
72190 -};
72191 +} __do_const;
72192 +typedef struct attribute __no_const attribute_no_const;
72193
72194 /**
72195 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72196 @@ -59,8 +60,8 @@ struct attribute_group {
72197 umode_t (*is_visible)(struct kobject *,
72198 struct attribute *, int);
72199 struct attribute **attrs;
72200 -};
72201 -
72202 +} __do_const;
72203 +typedef struct attribute_group __no_const attribute_group_no_const;
72204
72205
72206 /**
72207 @@ -107,7 +108,8 @@ struct bin_attribute {
72208 char *, loff_t, size_t);
72209 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72210 struct vm_area_struct *vma);
72211 -};
72212 +} __do_const;
72213 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72214
72215 /**
72216 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72217 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72218 index 7faf933..9b85a0c 100644
72219 --- a/include/linux/sysrq.h
72220 +++ b/include/linux/sysrq.h
72221 @@ -16,6 +16,7 @@
72222
72223 #include <linux/errno.h>
72224 #include <linux/types.h>
72225 +#include <linux/compiler.h>
72226
72227 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72228 #define SYSRQ_DEFAULT_ENABLE 1
72229 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72230 char *help_msg;
72231 char *action_msg;
72232 int enable_mask;
72233 -};
72234 +} __do_const;
72235
72236 #ifdef CONFIG_MAGIC_SYSRQ
72237
72238 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72239 index e7e0473..7989295 100644
72240 --- a/include/linux/thread_info.h
72241 +++ b/include/linux/thread_info.h
72242 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72243 #error "no set_restore_sigmask() provided and default one won't work"
72244 #endif
72245
72246 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72247 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72248 +{
72249 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72250 + if (!__builtin_constant_p(n))
72251 +#endif
72252 + __check_object_size(ptr, n, to_user);
72253 +}
72254 +
72255 #endif /* __KERNEL__ */
72256
72257 #endif /* _LINUX_THREAD_INFO_H */
72258 diff --git a/include/linux/tty.h b/include/linux/tty.h
72259 index c75d886..04cb148 100644
72260 --- a/include/linux/tty.h
72261 +++ b/include/linux/tty.h
72262 @@ -194,7 +194,7 @@ struct tty_port {
72263 const struct tty_port_operations *ops; /* Port operations */
72264 spinlock_t lock; /* Lock protecting tty field */
72265 int blocked_open; /* Waiting to open */
72266 - int count; /* Usage count */
72267 + atomic_t count; /* Usage count */
72268 wait_queue_head_t open_wait; /* Open waiters */
72269 wait_queue_head_t close_wait; /* Close waiters */
72270 wait_queue_head_t delta_msr_wait; /* Modem status change */
72271 @@ -515,7 +515,7 @@ extern int tty_port_open(struct tty_port *port,
72272 struct tty_struct *tty, struct file *filp);
72273 static inline int tty_port_users(struct tty_port *port)
72274 {
72275 - return port->count + port->blocked_open;
72276 + return atomic_read(&port->count) + port->blocked_open;
72277 }
72278
72279 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72280 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72281 index 756a609..b302dd6 100644
72282 --- a/include/linux/tty_driver.h
72283 +++ b/include/linux/tty_driver.h
72284 @@ -285,7 +285,7 @@ struct tty_operations {
72285 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72286 #endif
72287 const struct file_operations *proc_fops;
72288 -};
72289 +} __do_const;
72290
72291 struct tty_driver {
72292 int magic; /* magic number for this structure */
72293 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72294 index 455a0d7..bf97ff5 100644
72295 --- a/include/linux/tty_ldisc.h
72296 +++ b/include/linux/tty_ldisc.h
72297 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
72298
72299 struct module *owner;
72300
72301 - int refcount;
72302 + atomic_t refcount;
72303 };
72304
72305 struct tty_ldisc {
72306 diff --git a/include/linux/types.h b/include/linux/types.h
72307 index 4d118ba..c3ee9bf 100644
72308 --- a/include/linux/types.h
72309 +++ b/include/linux/types.h
72310 @@ -176,10 +176,26 @@ typedef struct {
72311 int counter;
72312 } atomic_t;
72313
72314 +#ifdef CONFIG_PAX_REFCOUNT
72315 +typedef struct {
72316 + int counter;
72317 +} atomic_unchecked_t;
72318 +#else
72319 +typedef atomic_t atomic_unchecked_t;
72320 +#endif
72321 +
72322 #ifdef CONFIG_64BIT
72323 typedef struct {
72324 long counter;
72325 } atomic64_t;
72326 +
72327 +#ifdef CONFIG_PAX_REFCOUNT
72328 +typedef struct {
72329 + long counter;
72330 +} atomic64_unchecked_t;
72331 +#else
72332 +typedef atomic64_t atomic64_unchecked_t;
72333 +#endif
72334 #endif
72335
72336 struct list_head {
72337 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72338 index 5ca0951..ab496a5 100644
72339 --- a/include/linux/uaccess.h
72340 +++ b/include/linux/uaccess.h
72341 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72342 long ret; \
72343 mm_segment_t old_fs = get_fs(); \
72344 \
72345 - set_fs(KERNEL_DS); \
72346 pagefault_disable(); \
72347 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72348 - pagefault_enable(); \
72349 + set_fs(KERNEL_DS); \
72350 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72351 set_fs(old_fs); \
72352 + pagefault_enable(); \
72353 ret; \
72354 })
72355
72356 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72357 index 8e522cbc..aa8572d 100644
72358 --- a/include/linux/uidgid.h
72359 +++ b/include/linux/uidgid.h
72360 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72361
72362 #endif /* CONFIG_USER_NS */
72363
72364 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72365 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72366 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72367 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72368 +
72369 #endif /* _LINUX_UIDGID_H */
72370 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72371 index 99c1b4d..562e6f3 100644
72372 --- a/include/linux/unaligned/access_ok.h
72373 +++ b/include/linux/unaligned/access_ok.h
72374 @@ -4,34 +4,34 @@
72375 #include <linux/kernel.h>
72376 #include <asm/byteorder.h>
72377
72378 -static inline u16 get_unaligned_le16(const void *p)
72379 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72380 {
72381 - return le16_to_cpup((__le16 *)p);
72382 + return le16_to_cpup((const __le16 *)p);
72383 }
72384
72385 -static inline u32 get_unaligned_le32(const void *p)
72386 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72387 {
72388 - return le32_to_cpup((__le32 *)p);
72389 + return le32_to_cpup((const __le32 *)p);
72390 }
72391
72392 -static inline u64 get_unaligned_le64(const void *p)
72393 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72394 {
72395 - return le64_to_cpup((__le64 *)p);
72396 + return le64_to_cpup((const __le64 *)p);
72397 }
72398
72399 -static inline u16 get_unaligned_be16(const void *p)
72400 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72401 {
72402 - return be16_to_cpup((__be16 *)p);
72403 + return be16_to_cpup((const __be16 *)p);
72404 }
72405
72406 -static inline u32 get_unaligned_be32(const void *p)
72407 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72408 {
72409 - return be32_to_cpup((__be32 *)p);
72410 + return be32_to_cpup((const __be32 *)p);
72411 }
72412
72413 -static inline u64 get_unaligned_be64(const void *p)
72414 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72415 {
72416 - return be64_to_cpup((__be64 *)p);
72417 + return be64_to_cpup((const __be64 *)p);
72418 }
72419
72420 static inline void put_unaligned_le16(u16 val, void *p)
72421 diff --git a/include/linux/usb.h b/include/linux/usb.h
72422 index 4d22d0f..8d0e8f8 100644
72423 --- a/include/linux/usb.h
72424 +++ b/include/linux/usb.h
72425 @@ -554,7 +554,7 @@ struct usb_device {
72426 int maxchild;
72427
72428 u32 quirks;
72429 - atomic_t urbnum;
72430 + atomic_unchecked_t urbnum;
72431
72432 unsigned long active_duration;
72433
72434 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72435
72436 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72437 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72438 - void *data, __u16 size, int timeout);
72439 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72440 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72441 void *data, int len, int *actual_length, int timeout);
72442 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72443 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72444 index c5d36c6..108f4f9 100644
72445 --- a/include/linux/usb/renesas_usbhs.h
72446 +++ b/include/linux/usb/renesas_usbhs.h
72447 @@ -39,7 +39,7 @@ enum {
72448 */
72449 struct renesas_usbhs_driver_callback {
72450 int (*notify_hotplug)(struct platform_device *pdev);
72451 -};
72452 +} __no_const;
72453
72454 /*
72455 * callback functions for platform
72456 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72457 index 6f8fbcf..8259001 100644
72458 --- a/include/linux/vermagic.h
72459 +++ b/include/linux/vermagic.h
72460 @@ -25,9 +25,35 @@
72461 #define MODULE_ARCH_VERMAGIC ""
72462 #endif
72463
72464 +#ifdef CONFIG_PAX_REFCOUNT
72465 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72466 +#else
72467 +#define MODULE_PAX_REFCOUNT ""
72468 +#endif
72469 +
72470 +#ifdef CONSTIFY_PLUGIN
72471 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72472 +#else
72473 +#define MODULE_CONSTIFY_PLUGIN ""
72474 +#endif
72475 +
72476 +#ifdef STACKLEAK_PLUGIN
72477 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72478 +#else
72479 +#define MODULE_STACKLEAK_PLUGIN ""
72480 +#endif
72481 +
72482 +#ifdef CONFIG_GRKERNSEC
72483 +#define MODULE_GRSEC "GRSEC "
72484 +#else
72485 +#define MODULE_GRSEC ""
72486 +#endif
72487 +
72488 #define VERMAGIC_STRING \
72489 UTS_RELEASE " " \
72490 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72491 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72492 - MODULE_ARCH_VERMAGIC
72493 + MODULE_ARCH_VERMAGIC \
72494 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72495 + MODULE_GRSEC
72496
72497 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72498 index 6071e91..4c73b47 100644
72499 --- a/include/linux/vmalloc.h
72500 +++ b/include/linux/vmalloc.h
72501 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72502 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72503 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72504 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72505 +
72506 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72507 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72508 +#endif
72509 +
72510 /* bits [20..32] reserved for arch specific ioremap internals */
72511
72512 /*
72513 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72514 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72515 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72516 unsigned long start, unsigned long end, gfp_t gfp_mask,
72517 - pgprot_t prot, int node, const void *caller);
72518 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72519 extern void vfree(const void *addr);
72520
72521 extern void *vmap(struct page **pages, unsigned int count,
72522 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72523 extern void free_vm_area(struct vm_struct *area);
72524
72525 /* for /dev/kmem */
72526 -extern long vread(char *buf, char *addr, unsigned long count);
72527 -extern long vwrite(char *buf, char *addr, unsigned long count);
72528 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72529 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72530
72531 /*
72532 * Internals. Dont't use..
72533 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72534 index 5fd71a7..e5ef9a9 100644
72535 --- a/include/linux/vmstat.h
72536 +++ b/include/linux/vmstat.h
72537 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72538 /*
72539 * Zone based page accounting with per cpu differentials.
72540 */
72541 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72542 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72543
72544 static inline void zone_page_state_add(long x, struct zone *zone,
72545 enum zone_stat_item item)
72546 {
72547 - atomic_long_add(x, &zone->vm_stat[item]);
72548 - atomic_long_add(x, &vm_stat[item]);
72549 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72550 + atomic_long_add_unchecked(x, &vm_stat[item]);
72551 }
72552
72553 static inline unsigned long global_page_state(enum zone_stat_item item)
72554 {
72555 - long x = atomic_long_read(&vm_stat[item]);
72556 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72557 #ifdef CONFIG_SMP
72558 if (x < 0)
72559 x = 0;
72560 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72561 static inline unsigned long zone_page_state(struct zone *zone,
72562 enum zone_stat_item item)
72563 {
72564 - long x = atomic_long_read(&zone->vm_stat[item]);
72565 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72566 #ifdef CONFIG_SMP
72567 if (x < 0)
72568 x = 0;
72569 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72570 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72571 enum zone_stat_item item)
72572 {
72573 - long x = atomic_long_read(&zone->vm_stat[item]);
72574 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72575
72576 #ifdef CONFIG_SMP
72577 int cpu;
72578 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72579
72580 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72581 {
72582 - atomic_long_inc(&zone->vm_stat[item]);
72583 - atomic_long_inc(&vm_stat[item]);
72584 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72585 + atomic_long_inc_unchecked(&vm_stat[item]);
72586 }
72587
72588 static inline void __inc_zone_page_state(struct page *page,
72589 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72590
72591 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72592 {
72593 - atomic_long_dec(&zone->vm_stat[item]);
72594 - atomic_long_dec(&vm_stat[item]);
72595 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72596 + atomic_long_dec_unchecked(&vm_stat[item]);
72597 }
72598
72599 static inline void __dec_zone_page_state(struct page *page,
72600 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72601 index fdbafc6..49dfe4f 100644
72602 --- a/include/linux/xattr.h
72603 +++ b/include/linux/xattr.h
72604 @@ -28,7 +28,7 @@ struct xattr_handler {
72605 size_t size, int handler_flags);
72606 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72607 size_t size, int flags, int handler_flags);
72608 -};
72609 +} __do_const;
72610
72611 struct xattr {
72612 char *name;
72613 @@ -37,6 +37,9 @@ struct xattr {
72614 };
72615
72616 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
72617 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
72618 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
72619 +#endif
72620 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
72621 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
72622 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
72623 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72624 index 9c5a6b4..09c9438 100644
72625 --- a/include/linux/zlib.h
72626 +++ b/include/linux/zlib.h
72627 @@ -31,6 +31,7 @@
72628 #define _ZLIB_H
72629
72630 #include <linux/zconf.h>
72631 +#include <linux/compiler.h>
72632
72633 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72634 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72635 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72636
72637 /* basic functions */
72638
72639 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72640 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72641 /*
72642 Returns the number of bytes that needs to be allocated for a per-
72643 stream workspace with the specified parameters. A pointer to this
72644 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72645 index 95d1c91..6798cca 100644
72646 --- a/include/media/v4l2-dev.h
72647 +++ b/include/media/v4l2-dev.h
72648 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72649 int (*mmap) (struct file *, struct vm_area_struct *);
72650 int (*open) (struct file *);
72651 int (*release) (struct file *);
72652 -};
72653 +} __do_const;
72654
72655 /*
72656 * Newer version of video_device, handled by videodev2.c
72657 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72658 index 4118ad1..cb7e25f 100644
72659 --- a/include/media/v4l2-ioctl.h
72660 +++ b/include/media/v4l2-ioctl.h
72661 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72662 bool valid_prio, int cmd, void *arg);
72663 };
72664
72665 -
72666 /* v4l debugging and diagnostics */
72667
72668 /* Debug bitmask flags to be used on V4L2 */
72669 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72670 index adcbb20..62c2559 100644
72671 --- a/include/net/9p/transport.h
72672 +++ b/include/net/9p/transport.h
72673 @@ -57,7 +57,7 @@ struct p9_trans_module {
72674 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72675 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72676 char *, char *, int , int, int, int);
72677 -};
72678 +} __do_const;
72679
72680 void v9fs_register_trans(struct p9_trans_module *m);
72681 void v9fs_unregister_trans(struct p9_trans_module *m);
72682 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72683 index cdd3302..76f8ede 100644
72684 --- a/include/net/bluetooth/l2cap.h
72685 +++ b/include/net/bluetooth/l2cap.h
72686 @@ -551,7 +551,7 @@ struct l2cap_ops {
72687 void (*defer) (struct l2cap_chan *chan);
72688 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72689 unsigned long len, int nb);
72690 -};
72691 +} __do_const;
72692
72693 struct l2cap_conn {
72694 struct hci_conn *hcon;
72695 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72696 index 9e5425b..8136ffc 100644
72697 --- a/include/net/caif/cfctrl.h
72698 +++ b/include/net/caif/cfctrl.h
72699 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72700 void (*radioset_rsp)(void);
72701 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72702 struct cflayer *client_layer);
72703 -};
72704 +} __no_const;
72705
72706 /* Link Setup Parameters for CAIF-Links. */
72707 struct cfctrl_link_param {
72708 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72709 struct cfctrl {
72710 struct cfsrvl serv;
72711 struct cfctrl_rsp res;
72712 - atomic_t req_seq_no;
72713 - atomic_t rsp_seq_no;
72714 + atomic_unchecked_t req_seq_no;
72715 + atomic_unchecked_t rsp_seq_no;
72716 struct list_head list;
72717 /* Protects from simultaneous access to first_req list */
72718 spinlock_t info_list_lock;
72719 diff --git a/include/net/flow.h b/include/net/flow.h
72720 index 628e11b..4c475df 100644
72721 --- a/include/net/flow.h
72722 +++ b/include/net/flow.h
72723 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72724
72725 extern void flow_cache_flush(void);
72726 extern void flow_cache_flush_deferred(void);
72727 -extern atomic_t flow_cache_genid;
72728 +extern atomic_unchecked_t flow_cache_genid;
72729
72730 #endif
72731 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72732 index bdfbe68..4402ebe 100644
72733 --- a/include/net/genetlink.h
72734 +++ b/include/net/genetlink.h
72735 @@ -118,7 +118,7 @@ struct genl_ops {
72736 struct netlink_callback *cb);
72737 int (*done)(struct netlink_callback *cb);
72738 struct list_head ops_list;
72739 -};
72740 +} __do_const;
72741
72742 extern int genl_register_family(struct genl_family *family);
72743 extern int genl_register_family_with_ops(struct genl_family *family,
72744 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72745 index 734d9b5..48a9a4b 100644
72746 --- a/include/net/gro_cells.h
72747 +++ b/include/net/gro_cells.h
72748 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72749 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72750
72751 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72752 - atomic_long_inc(&dev->rx_dropped);
72753 + atomic_long_inc_unchecked(&dev->rx_dropped);
72754 kfree_skb(skb);
72755 return;
72756 }
72757 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72758 index 1832927..ce39aea 100644
72759 --- a/include/net/inet_connection_sock.h
72760 +++ b/include/net/inet_connection_sock.h
72761 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72762 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72763 int (*bind_conflict)(const struct sock *sk,
72764 const struct inet_bind_bucket *tb, bool relax);
72765 -};
72766 +} __do_const;
72767
72768 /** inet_connection_sock - INET connection oriented sock
72769 *
72770 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72771 index 53f464d..ba76aaa 100644
72772 --- a/include/net/inetpeer.h
72773 +++ b/include/net/inetpeer.h
72774 @@ -47,8 +47,8 @@ struct inet_peer {
72775 */
72776 union {
72777 struct {
72778 - atomic_t rid; /* Frag reception counter */
72779 - atomic_t ip_id_count; /* IP ID for the next packet */
72780 + atomic_unchecked_t rid; /* Frag reception counter */
72781 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72782 };
72783 struct rcu_head rcu;
72784 struct inet_peer *gc_next;
72785 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72786 more++;
72787 inet_peer_refcheck(p);
72788 do {
72789 - old = atomic_read(&p->ip_id_count);
72790 + old = atomic_read_unchecked(&p->ip_id_count);
72791 new = old + more;
72792 if (!new)
72793 new = 1;
72794 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72795 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72796 return new;
72797 }
72798
72799 diff --git a/include/net/ip.h b/include/net/ip.h
72800 index a68f838..74518ab 100644
72801 --- a/include/net/ip.h
72802 +++ b/include/net/ip.h
72803 @@ -202,7 +202,7 @@ extern struct local_ports {
72804 } sysctl_local_ports;
72805 extern void inet_get_local_port_range(int *low, int *high);
72806
72807 -extern unsigned long *sysctl_local_reserved_ports;
72808 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72809 static inline int inet_is_reserved_local_port(int port)
72810 {
72811 return test_bit(port, sysctl_local_reserved_ports);
72812 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72813 index e49db91..76a81de 100644
72814 --- a/include/net/ip_fib.h
72815 +++ b/include/net/ip_fib.h
72816 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72817
72818 #define FIB_RES_SADDR(net, res) \
72819 ((FIB_RES_NH(res).nh_saddr_genid == \
72820 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72821 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72822 FIB_RES_NH(res).nh_saddr : \
72823 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72824 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72825 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72826 index fce8e6b..3ca4916 100644
72827 --- a/include/net/ip_vs.h
72828 +++ b/include/net/ip_vs.h
72829 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72830 struct ip_vs_conn *control; /* Master control connection */
72831 atomic_t n_control; /* Number of controlled ones */
72832 struct ip_vs_dest *dest; /* real server */
72833 - atomic_t in_pkts; /* incoming packet counter */
72834 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72835
72836 /* packet transmitter for different forwarding methods. If it
72837 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72838 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72839 __be16 port; /* port number of the server */
72840 union nf_inet_addr addr; /* IP address of the server */
72841 volatile unsigned int flags; /* dest status flags */
72842 - atomic_t conn_flags; /* flags to copy to conn */
72843 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72844 atomic_t weight; /* server weight */
72845
72846 atomic_t refcnt; /* reference counter */
72847 @@ -981,11 +981,11 @@ struct netns_ipvs {
72848 /* ip_vs_lblc */
72849 int sysctl_lblc_expiration;
72850 struct ctl_table_header *lblc_ctl_header;
72851 - struct ctl_table *lblc_ctl_table;
72852 + ctl_table_no_const *lblc_ctl_table;
72853 /* ip_vs_lblcr */
72854 int sysctl_lblcr_expiration;
72855 struct ctl_table_header *lblcr_ctl_header;
72856 - struct ctl_table *lblcr_ctl_table;
72857 + ctl_table_no_const *lblcr_ctl_table;
72858 /* ip_vs_est */
72859 struct list_head est_list; /* estimator list */
72860 spinlock_t est_lock;
72861 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72862 index 80ffde3..968b0f4 100644
72863 --- a/include/net/irda/ircomm_tty.h
72864 +++ b/include/net/irda/ircomm_tty.h
72865 @@ -35,6 +35,7 @@
72866 #include <linux/termios.h>
72867 #include <linux/timer.h>
72868 #include <linux/tty.h> /* struct tty_struct */
72869 +#include <asm/local.h>
72870
72871 #include <net/irda/irias_object.h>
72872 #include <net/irda/ircomm_core.h>
72873 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72874 index 714cc9a..ea05f3e 100644
72875 --- a/include/net/iucv/af_iucv.h
72876 +++ b/include/net/iucv/af_iucv.h
72877 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
72878 struct iucv_sock_list {
72879 struct hlist_head head;
72880 rwlock_t lock;
72881 - atomic_t autobind_name;
72882 + atomic_unchecked_t autobind_name;
72883 };
72884
72885 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72886 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72887 index df83f69..9b640b8 100644
72888 --- a/include/net/llc_c_ac.h
72889 +++ b/include/net/llc_c_ac.h
72890 @@ -87,7 +87,7 @@
72891 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72892 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72893
72894 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72895 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72896
72897 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72898 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72899 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72900 index 6ca3113..f8026dd 100644
72901 --- a/include/net/llc_c_ev.h
72902 +++ b/include/net/llc_c_ev.h
72903 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72904 return (struct llc_conn_state_ev *)skb->cb;
72905 }
72906
72907 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72908 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72909 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72910 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72911
72912 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72913 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72914 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72915 index 0e79cfb..f46db31 100644
72916 --- a/include/net/llc_c_st.h
72917 +++ b/include/net/llc_c_st.h
72918 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72919 u8 next_state;
72920 llc_conn_ev_qfyr_t *ev_qualifiers;
72921 llc_conn_action_t *ev_actions;
72922 -};
72923 +} __do_const;
72924
72925 struct llc_conn_state {
72926 u8 current_state;
72927 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72928 index 37a3bbd..55a4241 100644
72929 --- a/include/net/llc_s_ac.h
72930 +++ b/include/net/llc_s_ac.h
72931 @@ -23,7 +23,7 @@
72932 #define SAP_ACT_TEST_IND 9
72933
72934 /* All action functions must look like this */
72935 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72936 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72937
72938 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72939 struct sk_buff *skb);
72940 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72941 index 567c681..cd73ac0 100644
72942 --- a/include/net/llc_s_st.h
72943 +++ b/include/net/llc_s_st.h
72944 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72945 llc_sap_ev_t ev;
72946 u8 next_state;
72947 llc_sap_action_t *ev_actions;
72948 -};
72949 +} __do_const;
72950
72951 struct llc_sap_state {
72952 u8 curr_state;
72953 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72954 index f7eba13..91ed983 100644
72955 --- a/include/net/mac80211.h
72956 +++ b/include/net/mac80211.h
72957 @@ -4119,7 +4119,7 @@ struct rate_control_ops {
72958 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72959 struct dentry *dir);
72960 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72961 -};
72962 +} __do_const;
72963
72964 static inline int rate_supported(struct ieee80211_sta *sta,
72965 enum ieee80211_band band,
72966 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72967 index 7e748ad..5c6229b 100644
72968 --- a/include/net/neighbour.h
72969 +++ b/include/net/neighbour.h
72970 @@ -123,7 +123,7 @@ struct neigh_ops {
72971 void (*error_report)(struct neighbour *, struct sk_buff *);
72972 int (*output)(struct neighbour *, struct sk_buff *);
72973 int (*connected_output)(struct neighbour *, struct sk_buff *);
72974 -};
72975 +} __do_const;
72976
72977 struct pneigh_entry {
72978 struct pneigh_entry *next;
72979 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72980 index de644bc..dfbcc4c 100644
72981 --- a/include/net/net_namespace.h
72982 +++ b/include/net/net_namespace.h
72983 @@ -115,7 +115,7 @@ struct net {
72984 #endif
72985 struct netns_ipvs *ipvs;
72986 struct sock *diag_nlsk;
72987 - atomic_t rt_genid;
72988 + atomic_unchecked_t rt_genid;
72989 };
72990
72991 /*
72992 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72993 #define __net_init __init
72994 #define __net_exit __exit_refok
72995 #define __net_initdata __initdata
72996 +#ifdef CONSTIFY_PLUGIN
72997 #define __net_initconst __initconst
72998 +#else
72999 +#define __net_initconst __initdata
73000 +#endif
73001 #endif
73002
73003 struct pernet_operations {
73004 @@ -282,7 +286,7 @@ struct pernet_operations {
73005 void (*exit_batch)(struct list_head *net_exit_list);
73006 int *id;
73007 size_t size;
73008 -};
73009 +} __do_const;
73010
73011 /*
73012 * Use these carefully. If you implement a network device and it
73013 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
73014
73015 static inline int rt_genid(struct net *net)
73016 {
73017 - return atomic_read(&net->rt_genid);
73018 + return atomic_read_unchecked(&net->rt_genid);
73019 }
73020
73021 static inline void rt_genid_bump(struct net *net)
73022 {
73023 - atomic_inc(&net->rt_genid);
73024 + atomic_inc_unchecked(&net->rt_genid);
73025 }
73026
73027 #endif /* __NET_NET_NAMESPACE_H */
73028 diff --git a/include/net/netdma.h b/include/net/netdma.h
73029 index 8ba8ce2..99b7fff 100644
73030 --- a/include/net/netdma.h
73031 +++ b/include/net/netdma.h
73032 @@ -24,7 +24,7 @@
73033 #include <linux/dmaengine.h>
73034 #include <linux/skbuff.h>
73035
73036 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73037 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73038 struct sk_buff *skb, int offset, struct iovec *to,
73039 size_t len, struct dma_pinned_list *pinned_list);
73040
73041 diff --git a/include/net/netlink.h b/include/net/netlink.h
73042 index 9690b0f..87aded7 100644
73043 --- a/include/net/netlink.h
73044 +++ b/include/net/netlink.h
73045 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
73046 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
73047 {
73048 if (mark)
73049 - skb_trim(skb, (unsigned char *) mark - skb->data);
73050 + skb_trim(skb, (const unsigned char *) mark - skb->data);
73051 }
73052
73053 /**
73054 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
73055 index c9c0c53..53f24c3 100644
73056 --- a/include/net/netns/conntrack.h
73057 +++ b/include/net/netns/conntrack.h
73058 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
73059 struct nf_proto_net {
73060 #ifdef CONFIG_SYSCTL
73061 struct ctl_table_header *ctl_table_header;
73062 - struct ctl_table *ctl_table;
73063 + ctl_table_no_const *ctl_table;
73064 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
73065 struct ctl_table_header *ctl_compat_header;
73066 - struct ctl_table *ctl_compat_table;
73067 + ctl_table_no_const *ctl_compat_table;
73068 #endif
73069 #endif
73070 unsigned int users;
73071 @@ -58,7 +58,7 @@ struct nf_ip_net {
73072 struct nf_icmp_net icmpv6;
73073 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
73074 struct ctl_table_header *ctl_table_header;
73075 - struct ctl_table *ctl_table;
73076 + ctl_table_no_const *ctl_table;
73077 #endif
73078 };
73079
73080 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
73081 index 2ba9de8..47bd6c7 100644
73082 --- a/include/net/netns/ipv4.h
73083 +++ b/include/net/netns/ipv4.h
73084 @@ -67,7 +67,7 @@ struct netns_ipv4 {
73085 kgid_t sysctl_ping_group_range[2];
73086 long sysctl_tcp_mem[3];
73087
73088 - atomic_t dev_addr_genid;
73089 + atomic_unchecked_t dev_addr_genid;
73090
73091 #ifdef CONFIG_IP_MROUTE
73092 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73093 diff --git a/include/net/protocol.h b/include/net/protocol.h
73094 index 047c047..b9dad15 100644
73095 --- a/include/net/protocol.h
73096 +++ b/include/net/protocol.h
73097 @@ -44,7 +44,7 @@ struct net_protocol {
73098 void (*err_handler)(struct sk_buff *skb, u32 info);
73099 unsigned int no_policy:1,
73100 netns_ok:1;
73101 -};
73102 +} __do_const;
73103
73104 #if IS_ENABLED(CONFIG_IPV6)
73105 struct inet6_protocol {
73106 @@ -57,7 +57,7 @@ struct inet6_protocol {
73107 u8 type, u8 code, int offset,
73108 __be32 info);
73109 unsigned int flags; /* INET6_PROTO_xxx */
73110 -};
73111 +} __do_const;
73112
73113 #define INET6_PROTO_NOPOLICY 0x1
73114 #define INET6_PROTO_FINAL 0x2
73115 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73116 index 5a15fab..d799ea7 100644
73117 --- a/include/net/rtnetlink.h
73118 +++ b/include/net/rtnetlink.h
73119 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73120 const struct net_device *dev);
73121 unsigned int (*get_num_tx_queues)(void);
73122 unsigned int (*get_num_rx_queues)(void);
73123 -};
73124 +} __do_const;
73125
73126 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73127 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73128 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73129 index df85a0c..19ac300 100644
73130 --- a/include/net/sctp/sctp.h
73131 +++ b/include/net/sctp/sctp.h
73132 @@ -330,9 +330,9 @@ do { \
73133
73134 #else /* SCTP_DEBUG */
73135
73136 -#define SCTP_DEBUG_PRINTK(whatever...)
73137 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73138 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73139 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73140 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73141 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73142 #define SCTP_ENABLE_DEBUG
73143 #define SCTP_DISABLE_DEBUG
73144 #define SCTP_ASSERT(expr, str, func)
73145 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73146 index 2a82d13..62a31c2 100644
73147 --- a/include/net/sctp/sm.h
73148 +++ b/include/net/sctp/sm.h
73149 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73150 typedef struct {
73151 sctp_state_fn_t *fn;
73152 const char *name;
73153 -} sctp_sm_table_entry_t;
73154 +} __do_const sctp_sm_table_entry_t;
73155
73156 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73157 * currently in use.
73158 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73159 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73160
73161 /* Extern declarations for major data structures. */
73162 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73163 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73164
73165
73166 /* Get the size of a DATA chunk payload. */
73167 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73168 index 0e0f9d2..cd05ebb 100644
73169 --- a/include/net/sctp/structs.h
73170 +++ b/include/net/sctp/structs.h
73171 @@ -517,7 +517,7 @@ struct sctp_pf {
73172 struct sctp_association *asoc);
73173 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73174 struct sctp_af *af;
73175 -};
73176 +} __do_const;
73177
73178
73179 /* Structure to track chunk fragments that have been acked, but peer
73180 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
73181 index c2e542b..6ca975b 100644
73182 --- a/include/net/secure_seq.h
73183 +++ b/include/net/secure_seq.h
73184 @@ -3,6 +3,7 @@
73185
73186 #include <linux/types.h>
73187
73188 +extern void net_secret_init(void);
73189 extern __u32 secure_ip_id(__be32 daddr);
73190 extern __u32 secure_ipv6_id(const __be32 daddr[4]);
73191 extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
73192 diff --git a/include/net/sock.h b/include/net/sock.h
73193 index 0be480a..586232f 100644
73194 --- a/include/net/sock.h
73195 +++ b/include/net/sock.h
73196 @@ -325,7 +325,7 @@ struct sock {
73197 #ifdef CONFIG_RPS
73198 __u32 sk_rxhash;
73199 #endif
73200 - atomic_t sk_drops;
73201 + atomic_unchecked_t sk_drops;
73202 int sk_rcvbuf;
73203
73204 struct sk_filter __rcu *sk_filter;
73205 @@ -1796,7 +1796,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73206 }
73207
73208 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73209 - char __user *from, char *to,
73210 + char __user *from, unsigned char *to,
73211 int copy, int offset)
73212 {
73213 if (skb->ip_summed == CHECKSUM_NONE) {
73214 @@ -2055,7 +2055,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73215 }
73216 }
73217
73218 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73219 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73220
73221 /**
73222 * sk_page_frag - return an appropriate page_frag
73223 diff --git a/include/net/tcp.h b/include/net/tcp.h
73224 index a345480..3c65cf4 100644
73225 --- a/include/net/tcp.h
73226 +++ b/include/net/tcp.h
73227 @@ -529,7 +529,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73228 extern void tcp_xmit_retransmit_queue(struct sock *);
73229 extern void tcp_simple_retransmit(struct sock *);
73230 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73231 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73232 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73233
73234 extern void tcp_send_probe0(struct sock *);
73235 extern void tcp_send_partial(struct sock *);
73236 @@ -700,8 +700,8 @@ struct tcp_skb_cb {
73237 struct inet6_skb_parm h6;
73238 #endif
73239 } header; /* For incoming frames */
73240 - __u32 seq; /* Starting sequence number */
73241 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73242 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73243 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73244 __u32 when; /* used to compute rtt's */
73245 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73246
73247 @@ -715,7 +715,7 @@ struct tcp_skb_cb {
73248
73249 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73250 /* 1 byte hole */
73251 - __u32 ack_seq; /* Sequence number ACK'd */
73252 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73253 };
73254
73255 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73256 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73257 index 24c8886..e6fb816 100644
73258 --- a/include/net/xfrm.h
73259 +++ b/include/net/xfrm.h
73260 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73261 struct net_device *dev,
73262 const struct flowi *fl);
73263 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73264 -};
73265 +} __do_const;
73266
73267 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73268 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73269 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73270 struct sk_buff *skb);
73271 int (*transport_finish)(struct sk_buff *skb,
73272 int async);
73273 -};
73274 +} __do_const;
73275
73276 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73277 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73278 @@ -423,7 +423,7 @@ struct xfrm_mode {
73279 struct module *owner;
73280 unsigned int encap;
73281 int flags;
73282 -};
73283 +} __do_const;
73284
73285 /* Flags for xfrm_mode. */
73286 enum {
73287 @@ -520,7 +520,7 @@ struct xfrm_policy {
73288 struct timer_list timer;
73289
73290 struct flow_cache_object flo;
73291 - atomic_t genid;
73292 + atomic_unchecked_t genid;
73293 u32 priority;
73294 u32 index;
73295 struct xfrm_mark mark;
73296 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73297 index 1a046b1..ee0bef0 100644
73298 --- a/include/rdma/iw_cm.h
73299 +++ b/include/rdma/iw_cm.h
73300 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73301 int backlog);
73302
73303 int (*destroy_listen)(struct iw_cm_id *cm_id);
73304 -};
73305 +} __no_const;
73306
73307 /**
73308 * iw_create_cm_id - Create an IW CM identifier.
73309 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73310 index e1379b4..67eafbe 100644
73311 --- a/include/scsi/libfc.h
73312 +++ b/include/scsi/libfc.h
73313 @@ -762,6 +762,7 @@ struct libfc_function_template {
73314 */
73315 void (*disc_stop_final) (struct fc_lport *);
73316 };
73317 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73318
73319 /**
73320 * struct fc_disc - Discovery context
73321 @@ -866,7 +867,7 @@ struct fc_lport {
73322 struct fc_vport *vport;
73323
73324 /* Operational Information */
73325 - struct libfc_function_template tt;
73326 + libfc_function_template_no_const tt;
73327 u8 link_up;
73328 u8 qfull;
73329 enum fc_lport_state state;
73330 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73331 index a7f9cba..b1f44d0 100644
73332 --- a/include/scsi/scsi_device.h
73333 +++ b/include/scsi/scsi_device.h
73334 @@ -171,9 +171,9 @@ struct scsi_device {
73335 unsigned int max_device_blocked; /* what device_blocked counts down from */
73336 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73337
73338 - atomic_t iorequest_cnt;
73339 - atomic_t iodone_cnt;
73340 - atomic_t ioerr_cnt;
73341 + atomic_unchecked_t iorequest_cnt;
73342 + atomic_unchecked_t iodone_cnt;
73343 + atomic_unchecked_t ioerr_cnt;
73344
73345 struct device sdev_gendev,
73346 sdev_dev;
73347 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73348 index b797e8f..8e2c3aa 100644
73349 --- a/include/scsi/scsi_transport_fc.h
73350 +++ b/include/scsi/scsi_transport_fc.h
73351 @@ -751,7 +751,8 @@ struct fc_function_template {
73352 unsigned long show_host_system_hostname:1;
73353
73354 unsigned long disable_target_scan:1;
73355 -};
73356 +} __do_const;
73357 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73358
73359
73360 /**
73361 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
73362 index ff6c741..393815f 100644
73363 --- a/include/sound/compress_driver.h
73364 +++ b/include/sound/compress_driver.h
73365 @@ -130,7 +130,7 @@ struct snd_compr_ops {
73366 struct snd_compr_caps *caps);
73367 int (*get_codec_caps) (struct snd_compr_stream *stream,
73368 struct snd_compr_codec_caps *codec);
73369 -};
73370 +} __no_const;
73371
73372 /**
73373 * struct snd_compr: Compressed device
73374 diff --git a/include/sound/soc.h b/include/sound/soc.h
73375 index a6a059c..2243336 100644
73376 --- a/include/sound/soc.h
73377 +++ b/include/sound/soc.h
73378 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73379 /* probe ordering - for components with runtime dependencies */
73380 int probe_order;
73381 int remove_order;
73382 -};
73383 +} __do_const;
73384
73385 /* SoC platform interface */
73386 struct snd_soc_platform_driver {
73387 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73388 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73389 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73390 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73391 -};
73392 +} __do_const;
73393
73394 struct snd_soc_platform {
73395 const char *name;
73396 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73397 index f8640f3..b72d113 100644
73398 --- a/include/target/target_core_base.h
73399 +++ b/include/target/target_core_base.h
73400 @@ -658,7 +658,7 @@ struct se_device {
73401 spinlock_t stats_lock;
73402 /* Active commands on this virtual SE device */
73403 atomic_t simple_cmds;
73404 - atomic_t dev_ordered_id;
73405 + atomic_unchecked_t dev_ordered_id;
73406 atomic_t dev_ordered_sync;
73407 atomic_t dev_qf_count;
73408 int export_count;
73409 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73410 new file mode 100644
73411 index 0000000..fb634b7
73412 --- /dev/null
73413 +++ b/include/trace/events/fs.h
73414 @@ -0,0 +1,53 @@
73415 +#undef TRACE_SYSTEM
73416 +#define TRACE_SYSTEM fs
73417 +
73418 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73419 +#define _TRACE_FS_H
73420 +
73421 +#include <linux/fs.h>
73422 +#include <linux/tracepoint.h>
73423 +
73424 +TRACE_EVENT(do_sys_open,
73425 +
73426 + TP_PROTO(const char *filename, int flags, int mode),
73427 +
73428 + TP_ARGS(filename, flags, mode),
73429 +
73430 + TP_STRUCT__entry(
73431 + __string( filename, filename )
73432 + __field( int, flags )
73433 + __field( int, mode )
73434 + ),
73435 +
73436 + TP_fast_assign(
73437 + __assign_str(filename, filename);
73438 + __entry->flags = flags;
73439 + __entry->mode = mode;
73440 + ),
73441 +
73442 + TP_printk("\"%s\" %x %o",
73443 + __get_str(filename), __entry->flags, __entry->mode)
73444 +);
73445 +
73446 +TRACE_EVENT(open_exec,
73447 +
73448 + TP_PROTO(const char *filename),
73449 +
73450 + TP_ARGS(filename),
73451 +
73452 + TP_STRUCT__entry(
73453 + __string( filename, filename )
73454 + ),
73455 +
73456 + TP_fast_assign(
73457 + __assign_str(filename, filename);
73458 + ),
73459 +
73460 + TP_printk("\"%s\"",
73461 + __get_str(filename))
73462 +);
73463 +
73464 +#endif /* _TRACE_FS_H */
73465 +
73466 +/* This part must be outside protection */
73467 +#include <trace/define_trace.h>
73468 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73469 index 1c09820..7f5ec79 100644
73470 --- a/include/trace/events/irq.h
73471 +++ b/include/trace/events/irq.h
73472 @@ -36,7 +36,7 @@ struct softirq_action;
73473 */
73474 TRACE_EVENT(irq_handler_entry,
73475
73476 - TP_PROTO(int irq, struct irqaction *action),
73477 + TP_PROTO(int irq, const struct irqaction *action),
73478
73479 TP_ARGS(irq, action),
73480
73481 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73482 */
73483 TRACE_EVENT(irq_handler_exit,
73484
73485 - TP_PROTO(int irq, struct irqaction *action, int ret),
73486 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73487
73488 TP_ARGS(irq, action, ret),
73489
73490 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73491 index 7caf44c..23c6f27 100644
73492 --- a/include/uapi/linux/a.out.h
73493 +++ b/include/uapi/linux/a.out.h
73494 @@ -39,6 +39,14 @@ enum machine_type {
73495 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73496 };
73497
73498 +/* Constants for the N_FLAGS field */
73499 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73500 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73501 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73502 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73503 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73504 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73505 +
73506 #if !defined (N_MAGIC)
73507 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73508 #endif
73509 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73510 index d876736..ccce5c0 100644
73511 --- a/include/uapi/linux/byteorder/little_endian.h
73512 +++ b/include/uapi/linux/byteorder/little_endian.h
73513 @@ -42,51 +42,51 @@
73514
73515 static inline __le64 __cpu_to_le64p(const __u64 *p)
73516 {
73517 - return (__force __le64)*p;
73518 + return (__force const __le64)*p;
73519 }
73520 -static inline __u64 __le64_to_cpup(const __le64 *p)
73521 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73522 {
73523 - return (__force __u64)*p;
73524 + return (__force const __u64)*p;
73525 }
73526 static inline __le32 __cpu_to_le32p(const __u32 *p)
73527 {
73528 - return (__force __le32)*p;
73529 + return (__force const __le32)*p;
73530 }
73531 static inline __u32 __le32_to_cpup(const __le32 *p)
73532 {
73533 - return (__force __u32)*p;
73534 + return (__force const __u32)*p;
73535 }
73536 static inline __le16 __cpu_to_le16p(const __u16 *p)
73537 {
73538 - return (__force __le16)*p;
73539 + return (__force const __le16)*p;
73540 }
73541 static inline __u16 __le16_to_cpup(const __le16 *p)
73542 {
73543 - return (__force __u16)*p;
73544 + return (__force const __u16)*p;
73545 }
73546 static inline __be64 __cpu_to_be64p(const __u64 *p)
73547 {
73548 - return (__force __be64)__swab64p(p);
73549 + return (__force const __be64)__swab64p(p);
73550 }
73551 static inline __u64 __be64_to_cpup(const __be64 *p)
73552 {
73553 - return __swab64p((__u64 *)p);
73554 + return __swab64p((const __u64 *)p);
73555 }
73556 static inline __be32 __cpu_to_be32p(const __u32 *p)
73557 {
73558 - return (__force __be32)__swab32p(p);
73559 + return (__force const __be32)__swab32p(p);
73560 }
73561 -static inline __u32 __be32_to_cpup(const __be32 *p)
73562 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73563 {
73564 - return __swab32p((__u32 *)p);
73565 + return __swab32p((const __u32 *)p);
73566 }
73567 static inline __be16 __cpu_to_be16p(const __u16 *p)
73568 {
73569 - return (__force __be16)__swab16p(p);
73570 + return (__force const __be16)__swab16p(p);
73571 }
73572 static inline __u16 __be16_to_cpup(const __be16 *p)
73573 {
73574 - return __swab16p((__u16 *)p);
73575 + return __swab16p((const __u16 *)p);
73576 }
73577 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73578 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73579 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73580 index 8072d35..e77aeb8 100644
73581 --- a/include/uapi/linux/elf.h
73582 +++ b/include/uapi/linux/elf.h
73583 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73584 #define PT_GNU_EH_FRAME 0x6474e550
73585
73586 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73587 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73588 +
73589 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73590 +
73591 +/* Constants for the e_flags field */
73592 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73593 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73594 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73595 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73596 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73597 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73598
73599 /*
73600 * Extended Numbering
73601 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73602 #define DT_DEBUG 21
73603 #define DT_TEXTREL 22
73604 #define DT_JMPREL 23
73605 +#define DT_FLAGS 30
73606 + #define DF_TEXTREL 0x00000004
73607 #define DT_ENCODING 32
73608 #define OLD_DT_LOOS 0x60000000
73609 #define DT_LOOS 0x6000000d
73610 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73611 #define PF_W 0x2
73612 #define PF_X 0x1
73613
73614 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73615 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73616 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73617 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73618 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73619 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73620 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73621 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73622 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73623 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73624 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73625 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73626 +
73627 typedef struct elf32_phdr{
73628 Elf32_Word p_type;
73629 Elf32_Off p_offset;
73630 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73631 #define EI_OSABI 7
73632 #define EI_PAD 8
73633
73634 +#define EI_PAX 14
73635 +
73636 #define ELFMAG0 0x7f /* EI_MAG */
73637 #define ELFMAG1 'E'
73638 #define ELFMAG2 'L'
73639 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73640 index aa169c4..6a2771d 100644
73641 --- a/include/uapi/linux/personality.h
73642 +++ b/include/uapi/linux/personality.h
73643 @@ -30,6 +30,7 @@ enum {
73644 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73645 ADDR_NO_RANDOMIZE | \
73646 ADDR_COMPAT_LAYOUT | \
73647 + ADDR_LIMIT_3GB | \
73648 MMAP_PAGE_ZERO)
73649
73650 /*
73651 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73652 index 7530e74..e714828 100644
73653 --- a/include/uapi/linux/screen_info.h
73654 +++ b/include/uapi/linux/screen_info.h
73655 @@ -43,7 +43,8 @@ struct screen_info {
73656 __u16 pages; /* 0x32 */
73657 __u16 vesa_attributes; /* 0x34 */
73658 __u32 capabilities; /* 0x36 */
73659 - __u8 _reserved[6]; /* 0x3a */
73660 + __u16 vesapm_size; /* 0x3a */
73661 + __u8 _reserved[4]; /* 0x3c */
73662 } __attribute__((packed));
73663
73664 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73665 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73666 index 0e011eb..82681b1 100644
73667 --- a/include/uapi/linux/swab.h
73668 +++ b/include/uapi/linux/swab.h
73669 @@ -43,7 +43,7 @@
73670 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73671 */
73672
73673 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73674 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73675 {
73676 #ifdef __HAVE_BUILTIN_BSWAP16__
73677 return __builtin_bswap16(val);
73678 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73679 #endif
73680 }
73681
73682 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73683 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73684 {
73685 #ifdef __HAVE_BUILTIN_BSWAP32__
73686 return __builtin_bswap32(val);
73687 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73688 #endif
73689 }
73690
73691 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73692 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73693 {
73694 #ifdef __HAVE_BUILTIN_BSWAP64__
73695 return __builtin_bswap64(val);
73696 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73697 index 6d67213..8dab561 100644
73698 --- a/include/uapi/linux/sysctl.h
73699 +++ b/include/uapi/linux/sysctl.h
73700 @@ -155,7 +155,11 @@ enum
73701 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73702 };
73703
73704 -
73705 +#ifdef CONFIG_PAX_SOFTMODE
73706 +enum {
73707 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73708 +};
73709 +#endif
73710
73711 /* CTL_VM names: */
73712 enum
73713 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73714 index e4629b9..6958086 100644
73715 --- a/include/uapi/linux/xattr.h
73716 +++ b/include/uapi/linux/xattr.h
73717 @@ -63,5 +63,9 @@
73718 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73719 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73720
73721 +/* User namespace */
73722 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73723 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73724 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73725
73726 #endif /* _UAPI_LINUX_XATTR_H */
73727 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73728 index f9466fa..f4e2b81 100644
73729 --- a/include/video/udlfb.h
73730 +++ b/include/video/udlfb.h
73731 @@ -53,10 +53,10 @@ struct dlfb_data {
73732 u32 pseudo_palette[256];
73733 int blank_mode; /*one of FB_BLANK_ */
73734 /* blit-only rendering path metrics, exposed through sysfs */
73735 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73736 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73737 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73738 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73739 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73740 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73741 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73742 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73743 };
73744
73745 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73746 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73747 index 1a91850..28573f8 100644
73748 --- a/include/video/uvesafb.h
73749 +++ b/include/video/uvesafb.h
73750 @@ -122,6 +122,7 @@ struct uvesafb_par {
73751 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73752 u8 pmi_setpal; /* PMI for palette changes */
73753 u16 *pmi_base; /* protected mode interface location */
73754 + u8 *pmi_code; /* protected mode code location */
73755 void *pmi_start;
73756 void *pmi_pal;
73757 u8 *vbe_state_orig; /*
73758 diff --git a/init/Kconfig b/init/Kconfig
73759 index 5341d72..153f24f 100644
73760 --- a/init/Kconfig
73761 +++ b/init/Kconfig
73762 @@ -984,6 +984,7 @@ endif # CGROUPS
73763
73764 config CHECKPOINT_RESTORE
73765 bool "Checkpoint/restore support" if EXPERT
73766 + depends on !GRKERNSEC
73767 default n
73768 help
73769 Enables additional kernel features in a sake of checkpoint/restore.
73770 @@ -1471,7 +1472,7 @@ config SLUB_DEBUG
73771
73772 config COMPAT_BRK
73773 bool "Disable heap randomization"
73774 - default y
73775 + default n
73776 help
73777 Randomizing heap placement makes heap exploits harder, but it
73778 also breaks ancient binaries (including anything libc5 based).
73779 @@ -1734,7 +1735,7 @@ config INIT_ALL_POSSIBLE
73780 config STOP_MACHINE
73781 bool
73782 default y
73783 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73784 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73785 help
73786 Need stop_machine() primitive.
73787
73788 diff --git a/init/Makefile b/init/Makefile
73789 index 7bc47ee..6da2dc7 100644
73790 --- a/init/Makefile
73791 +++ b/init/Makefile
73792 @@ -2,6 +2,9 @@
73793 # Makefile for the linux kernel.
73794 #
73795
73796 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73797 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73798 +
73799 obj-y := main.o version.o mounts.o
73800 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73801 obj-y += noinitramfs.o
73802 diff --git a/init/do_mounts.c b/init/do_mounts.c
73803 index a2b49f2..03a0e17c 100644
73804 --- a/init/do_mounts.c
73805 +++ b/init/do_mounts.c
73806 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73807 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73808 {
73809 struct super_block *s;
73810 - int err = sys_mount(name, "/root", fs, flags, data);
73811 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73812 if (err)
73813 return err;
73814
73815 - sys_chdir("/root");
73816 + sys_chdir((const char __force_user *)"/root");
73817 s = current->fs->pwd.dentry->d_sb;
73818 ROOT_DEV = s->s_dev;
73819 printk(KERN_INFO
73820 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73821 va_start(args, fmt);
73822 vsprintf(buf, fmt, args);
73823 va_end(args);
73824 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73825 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73826 if (fd >= 0) {
73827 sys_ioctl(fd, FDEJECT, 0);
73828 sys_close(fd);
73829 }
73830 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73831 - fd = sys_open("/dev/console", O_RDWR, 0);
73832 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73833 if (fd >= 0) {
73834 sys_ioctl(fd, TCGETS, (long)&termios);
73835 termios.c_lflag &= ~ICANON;
73836 sys_ioctl(fd, TCSETSF, (long)&termios);
73837 - sys_read(fd, &c, 1);
73838 + sys_read(fd, (char __user *)&c, 1);
73839 termios.c_lflag |= ICANON;
73840 sys_ioctl(fd, TCSETSF, (long)&termios);
73841 sys_close(fd);
73842 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73843 mount_root();
73844 out:
73845 devtmpfs_mount("dev");
73846 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73847 - sys_chroot(".");
73848 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73849 + sys_chroot((const char __force_user *)".");
73850 }
73851 diff --git a/init/do_mounts.h b/init/do_mounts.h
73852 index f5b978a..69dbfe8 100644
73853 --- a/init/do_mounts.h
73854 +++ b/init/do_mounts.h
73855 @@ -15,15 +15,15 @@ extern int root_mountflags;
73856
73857 static inline int create_dev(char *name, dev_t dev)
73858 {
73859 - sys_unlink(name);
73860 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73861 + sys_unlink((char __force_user *)name);
73862 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73863 }
73864
73865 #if BITS_PER_LONG == 32
73866 static inline u32 bstat(char *name)
73867 {
73868 struct stat64 stat;
73869 - if (sys_stat64(name, &stat) != 0)
73870 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73871 return 0;
73872 if (!S_ISBLK(stat.st_mode))
73873 return 0;
73874 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73875 static inline u32 bstat(char *name)
73876 {
73877 struct stat stat;
73878 - if (sys_newstat(name, &stat) != 0)
73879 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73880 return 0;
73881 if (!S_ISBLK(stat.st_mode))
73882 return 0;
73883 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73884 index a32ec1c..60a6659 100644
73885 --- a/init/do_mounts_initrd.c
73886 +++ b/init/do_mounts_initrd.c
73887 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
73888 {
73889 sys_unshare(CLONE_FS | CLONE_FILES);
73890 /* stdin/stdout/stderr for /linuxrc */
73891 - sys_open("/dev/console", O_RDWR, 0);
73892 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
73893 sys_dup(0);
73894 sys_dup(0);
73895 /* move initrd over / and chdir/chroot in initrd root */
73896 - sys_chdir("/root");
73897 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73898 - sys_chroot(".");
73899 + sys_chdir((const char __force_user *)"/root");
73900 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73901 + sys_chroot((const char __force_user *)".");
73902 sys_setsid();
73903 return 0;
73904 }
73905 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73906 create_dev("/dev/root.old", Root_RAM0);
73907 /* mount initrd on rootfs' /root */
73908 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73909 - sys_mkdir("/old", 0700);
73910 - sys_chdir("/old");
73911 + sys_mkdir((const char __force_user *)"/old", 0700);
73912 + sys_chdir((const char __force_user *)"/old");
73913
73914 /* try loading default modules from initrd */
73915 load_default_modules();
73916 @@ -76,31 +76,31 @@ static void __init handle_initrd(void)
73917 current->flags &= ~PF_FREEZER_SKIP;
73918
73919 /* move initrd to rootfs' /old */
73920 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73921 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73922 /* switch root and cwd back to / of rootfs */
73923 - sys_chroot("..");
73924 + sys_chroot((const char __force_user *)"..");
73925
73926 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73927 - sys_chdir("/old");
73928 + sys_chdir((const char __force_user *)"/old");
73929 return;
73930 }
73931
73932 - sys_chdir("/");
73933 + sys_chdir((const char __force_user *)"/");
73934 ROOT_DEV = new_decode_dev(real_root_dev);
73935 mount_root();
73936
73937 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73938 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73939 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73940 if (!error)
73941 printk("okay\n");
73942 else {
73943 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73944 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73945 if (error == -ENOENT)
73946 printk("/initrd does not exist. Ignored.\n");
73947 else
73948 printk("failed\n");
73949 printk(KERN_NOTICE "Unmounting old root\n");
73950 - sys_umount("/old", MNT_DETACH);
73951 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73952 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73953 if (fd < 0) {
73954 error = fd;
73955 @@ -123,11 +123,11 @@ int __init initrd_load(void)
73956 * mounted in the normal path.
73957 */
73958 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73959 - sys_unlink("/initrd.image");
73960 + sys_unlink((const char __force_user *)"/initrd.image");
73961 handle_initrd();
73962 return 1;
73963 }
73964 }
73965 - sys_unlink("/initrd.image");
73966 + sys_unlink((const char __force_user *)"/initrd.image");
73967 return 0;
73968 }
73969 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73970 index 8cb6db5..d729f50 100644
73971 --- a/init/do_mounts_md.c
73972 +++ b/init/do_mounts_md.c
73973 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73974 partitioned ? "_d" : "", minor,
73975 md_setup_args[ent].device_names);
73976
73977 - fd = sys_open(name, 0, 0);
73978 + fd = sys_open((char __force_user *)name, 0, 0);
73979 if (fd < 0) {
73980 printk(KERN_ERR "md: open failed - cannot start "
73981 "array %s\n", name);
73982 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73983 * array without it
73984 */
73985 sys_close(fd);
73986 - fd = sys_open(name, 0, 0);
73987 + fd = sys_open((char __force_user *)name, 0, 0);
73988 sys_ioctl(fd, BLKRRPART, 0);
73989 }
73990 sys_close(fd);
73991 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73992
73993 wait_for_device_probe();
73994
73995 - fd = sys_open("/dev/md0", 0, 0);
73996 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73997 if (fd >= 0) {
73998 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73999 sys_close(fd);
74000 diff --git a/init/init_task.c b/init/init_task.c
74001 index ba0a7f36..2bcf1d5 100644
74002 --- a/init/init_task.c
74003 +++ b/init/init_task.c
74004 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
74005 * Initial thread structure. Alignment of this is handled by a special
74006 * linker map entry.
74007 */
74008 +#ifdef CONFIG_X86
74009 +union thread_union init_thread_union __init_task_data;
74010 +#else
74011 union thread_union init_thread_union __init_task_data =
74012 { INIT_THREAD_INFO(init_task) };
74013 +#endif
74014 diff --git a/init/initramfs.c b/init/initramfs.c
74015 index a67ef9d..2d17ed9 100644
74016 --- a/init/initramfs.c
74017 +++ b/init/initramfs.c
74018 @@ -84,7 +84,7 @@ static void __init free_hash(void)
74019 }
74020 }
74021
74022 -static long __init do_utime(char *filename, time_t mtime)
74023 +static long __init do_utime(char __force_user *filename, time_t mtime)
74024 {
74025 struct timespec t[2];
74026
74027 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
74028 struct dir_entry *de, *tmp;
74029 list_for_each_entry_safe(de, tmp, &dir_list, list) {
74030 list_del(&de->list);
74031 - do_utime(de->name, de->mtime);
74032 + do_utime((char __force_user *)de->name, de->mtime);
74033 kfree(de->name);
74034 kfree(de);
74035 }
74036 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
74037 if (nlink >= 2) {
74038 char *old = find_link(major, minor, ino, mode, collected);
74039 if (old)
74040 - return (sys_link(old, collected) < 0) ? -1 : 1;
74041 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
74042 }
74043 return 0;
74044 }
74045 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
74046 {
74047 struct stat st;
74048
74049 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
74050 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
74051 if (S_ISDIR(st.st_mode))
74052 - sys_rmdir(path);
74053 + sys_rmdir((char __force_user *)path);
74054 else
74055 - sys_unlink(path);
74056 + sys_unlink((char __force_user *)path);
74057 }
74058 }
74059
74060 @@ -315,7 +315,7 @@ static int __init do_name(void)
74061 int openflags = O_WRONLY|O_CREAT;
74062 if (ml != 1)
74063 openflags |= O_TRUNC;
74064 - wfd = sys_open(collected, openflags, mode);
74065 + wfd = sys_open((char __force_user *)collected, openflags, mode);
74066
74067 if (wfd >= 0) {
74068 sys_fchown(wfd, uid, gid);
74069 @@ -327,17 +327,17 @@ static int __init do_name(void)
74070 }
74071 }
74072 } else if (S_ISDIR(mode)) {
74073 - sys_mkdir(collected, mode);
74074 - sys_chown(collected, uid, gid);
74075 - sys_chmod(collected, mode);
74076 + sys_mkdir((char __force_user *)collected, mode);
74077 + sys_chown((char __force_user *)collected, uid, gid);
74078 + sys_chmod((char __force_user *)collected, mode);
74079 dir_add(collected, mtime);
74080 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
74081 S_ISFIFO(mode) || S_ISSOCK(mode)) {
74082 if (maybe_link() == 0) {
74083 - sys_mknod(collected, mode, rdev);
74084 - sys_chown(collected, uid, gid);
74085 - sys_chmod(collected, mode);
74086 - do_utime(collected, mtime);
74087 + sys_mknod((char __force_user *)collected, mode, rdev);
74088 + sys_chown((char __force_user *)collected, uid, gid);
74089 + sys_chmod((char __force_user *)collected, mode);
74090 + do_utime((char __force_user *)collected, mtime);
74091 }
74092 }
74093 return 0;
74094 @@ -346,15 +346,15 @@ static int __init do_name(void)
74095 static int __init do_copy(void)
74096 {
74097 if (count >= body_len) {
74098 - sys_write(wfd, victim, body_len);
74099 + sys_write(wfd, (char __force_user *)victim, body_len);
74100 sys_close(wfd);
74101 - do_utime(vcollected, mtime);
74102 + do_utime((char __force_user *)vcollected, mtime);
74103 kfree(vcollected);
74104 eat(body_len);
74105 state = SkipIt;
74106 return 0;
74107 } else {
74108 - sys_write(wfd, victim, count);
74109 + sys_write(wfd, (char __force_user *)victim, count);
74110 body_len -= count;
74111 eat(count);
74112 return 1;
74113 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
74114 {
74115 collected[N_ALIGN(name_len) + body_len] = '\0';
74116 clean_path(collected, 0);
74117 - sys_symlink(collected + N_ALIGN(name_len), collected);
74118 - sys_lchown(collected, uid, gid);
74119 - do_utime(collected, mtime);
74120 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
74121 + sys_lchown((char __force_user *)collected, uid, gid);
74122 + do_utime((char __force_user *)collected, mtime);
74123 state = SkipIt;
74124 next_state = Reset;
74125 return 0;
74126 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
74127 {
74128 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
74129 if (err)
74130 - panic(err); /* Failed to decompress INTERNAL initramfs */
74131 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
74132 if (initrd_start) {
74133 #ifdef CONFIG_BLK_DEV_RAM
74134 int fd;
74135 diff --git a/init/main.c b/init/main.c
74136 index 63534a1..85feae2 100644
74137 --- a/init/main.c
74138 +++ b/init/main.c
74139 @@ -98,6 +98,8 @@ static inline void mark_rodata_ro(void) { }
74140 extern void tc_init(void);
74141 #endif
74142
74143 +extern void grsecurity_init(void);
74144 +
74145 /*
74146 * Debug helper: via this flag we know that we are in 'early bootup code'
74147 * where only the boot processor is running with IRQ disabled. This means
74148 @@ -151,6 +153,64 @@ static int __init set_reset_devices(char *str)
74149
74150 __setup("reset_devices", set_reset_devices);
74151
74152 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74153 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74154 +static int __init setup_grsec_proc_gid(char *str)
74155 +{
74156 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74157 + return 1;
74158 +}
74159 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74160 +#endif
74161 +
74162 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74163 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
74164 +EXPORT_SYMBOL(pax_user_shadow_base);
74165 +extern char pax_enter_kernel_user[];
74166 +extern char pax_exit_kernel_user[];
74167 +extern pgdval_t clone_pgd_mask;
74168 +#endif
74169 +
74170 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74171 +static int __init setup_pax_nouderef(char *str)
74172 +{
74173 +#ifdef CONFIG_X86_32
74174 + unsigned int cpu;
74175 + struct desc_struct *gdt;
74176 +
74177 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74178 + gdt = get_cpu_gdt_table(cpu);
74179 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74180 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74181 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74182 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74183 + }
74184 + loadsegment(ds, __KERNEL_DS);
74185 + loadsegment(es, __KERNEL_DS);
74186 + loadsegment(ss, __KERNEL_DS);
74187 +#else
74188 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74189 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74190 + clone_pgd_mask = ~(pgdval_t)0UL;
74191 + pax_user_shadow_base = 0UL;
74192 +#endif
74193 +
74194 + return 0;
74195 +}
74196 +early_param("pax_nouderef", setup_pax_nouderef);
74197 +#endif
74198 +
74199 +#ifdef CONFIG_PAX_SOFTMODE
74200 +int pax_softmode;
74201 +
74202 +static int __init setup_pax_softmode(char *str)
74203 +{
74204 + get_option(&str, &pax_softmode);
74205 + return 1;
74206 +}
74207 +__setup("pax_softmode=", setup_pax_softmode);
74208 +#endif
74209 +
74210 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74211 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74212 static const char *panic_later, *panic_param;
74213 @@ -683,6 +743,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
74214 {
74215 int count = preempt_count();
74216 int ret;
74217 + const char *msg1 = "", *msg2 = "";
74218
74219 if (initcall_debug)
74220 ret = do_one_initcall_debug(fn);
74221 @@ -695,15 +756,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
74222 sprintf(msgbuf, "error code %d ", ret);
74223
74224 if (preempt_count() != count) {
74225 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
74226 + msg1 = " preemption imbalance";
74227 preempt_count() = count;
74228 }
74229 if (irqs_disabled()) {
74230 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74231 + msg2 = " disabled interrupts";
74232 local_irq_enable();
74233 }
74234 - if (msgbuf[0]) {
74235 - printk("initcall %pF returned with %s\n", fn, msgbuf);
74236 + if (msgbuf[0] || *msg1 || *msg2) {
74237 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
74238 }
74239
74240 return ret;
74241 @@ -757,8 +818,14 @@ static void __init do_initcall_level(int level)
74242 level, level,
74243 &repair_env_string);
74244
74245 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74246 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74247 do_one_initcall(*fn);
74248 +
74249 +#ifdef LATENT_ENTROPY_PLUGIN
74250 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74251 +#endif
74252 +
74253 + }
74254 }
74255
74256 static void __init do_initcalls(void)
74257 @@ -792,8 +859,14 @@ static void __init do_pre_smp_initcalls(void)
74258 {
74259 initcall_t *fn;
74260
74261 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74262 + for (fn = __initcall_start; fn < __initcall0_start; 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 /*
74273 @@ -811,8 +884,8 @@ static int run_init_process(const char *init_filename)
74274 {
74275 argv_init[0] = init_filename;
74276 return do_execve(init_filename,
74277 - (const char __user *const __user *)argv_init,
74278 - (const char __user *const __user *)envp_init);
74279 + (const char __user *const __force_user *)argv_init,
74280 + (const char __user *const __force_user *)envp_init);
74281 }
74282
74283 static noinline void __init kernel_init_freeable(void);
74284 @@ -890,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
74285 do_basic_setup();
74286
74287 /* Open the /dev/console on the rootfs, this should never fail */
74288 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74289 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74290 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74291
74292 (void) sys_dup(0);
74293 @@ -903,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
74294 if (!ramdisk_execute_command)
74295 ramdisk_execute_command = "/init";
74296
74297 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74298 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74299 ramdisk_execute_command = NULL;
74300 prepare_namespace();
74301 }
74302
74303 + grsecurity_init();
74304 +
74305 /*
74306 * Ok, we have completed the initial bootup, and
74307 * we're essentially up and running. Get rid of the
74308 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74309 index 130dfec..cc88451 100644
74310 --- a/ipc/ipc_sysctl.c
74311 +++ b/ipc/ipc_sysctl.c
74312 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74313 static int proc_ipc_dointvec(ctl_table *table, int write,
74314 void __user *buffer, size_t *lenp, loff_t *ppos)
74315 {
74316 - struct ctl_table ipc_table;
74317 + ctl_table_no_const ipc_table;
74318
74319 memcpy(&ipc_table, table, sizeof(ipc_table));
74320 ipc_table.data = get_ipc(table);
74321 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74322 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74323 void __user *buffer, size_t *lenp, loff_t *ppos)
74324 {
74325 - struct ctl_table ipc_table;
74326 + ctl_table_no_const ipc_table;
74327
74328 memcpy(&ipc_table, table, sizeof(ipc_table));
74329 ipc_table.data = get_ipc(table);
74330 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74331 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74332 void __user *buffer, size_t *lenp, loff_t *ppos)
74333 {
74334 - struct ctl_table ipc_table;
74335 + ctl_table_no_const ipc_table;
74336 size_t lenp_bef = *lenp;
74337 int rc;
74338
74339 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74340 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74341 void __user *buffer, size_t *lenp, loff_t *ppos)
74342 {
74343 - struct ctl_table ipc_table;
74344 + ctl_table_no_const ipc_table;
74345 memcpy(&ipc_table, table, sizeof(ipc_table));
74346 ipc_table.data = get_ipc(table);
74347
74348 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74349 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74350 void __user *buffer, size_t *lenp, loff_t *ppos)
74351 {
74352 - struct ctl_table ipc_table;
74353 + ctl_table_no_const ipc_table;
74354 size_t lenp_bef = *lenp;
74355 int oldval;
74356 int rc;
74357 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74358 index 383d638..943fdbb 100644
74359 --- a/ipc/mq_sysctl.c
74360 +++ b/ipc/mq_sysctl.c
74361 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74362 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74363 void __user *buffer, size_t *lenp, loff_t *ppos)
74364 {
74365 - struct ctl_table mq_table;
74366 + ctl_table_no_const mq_table;
74367 memcpy(&mq_table, table, sizeof(mq_table));
74368 mq_table.data = get_mq(table);
74369
74370 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74371 index e4e47f6..a85e0ad 100644
74372 --- a/ipc/mqueue.c
74373 +++ b/ipc/mqueue.c
74374 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74375 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74376 info->attr.mq_msgsize);
74377
74378 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74379 spin_lock(&mq_lock);
74380 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74381 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74382 diff --git a/ipc/msg.c b/ipc/msg.c
74383 index fede1d0..9778e0f8 100644
74384 --- a/ipc/msg.c
74385 +++ b/ipc/msg.c
74386 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74387 return security_msg_queue_associate(msq, msgflg);
74388 }
74389
74390 +static struct ipc_ops msg_ops = {
74391 + .getnew = newque,
74392 + .associate = msg_security,
74393 + .more_checks = NULL
74394 +};
74395 +
74396 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74397 {
74398 struct ipc_namespace *ns;
74399 - struct ipc_ops msg_ops;
74400 struct ipc_params msg_params;
74401
74402 ns = current->nsproxy->ipc_ns;
74403
74404 - msg_ops.getnew = newque;
74405 - msg_ops.associate = msg_security;
74406 - msg_ops.more_checks = NULL;
74407 -
74408 msg_params.key = key;
74409 msg_params.flg = msgflg;
74410
74411 diff --git a/ipc/sem.c b/ipc/sem.c
74412 index 58d31f1..cce7a55 100644
74413 --- a/ipc/sem.c
74414 +++ b/ipc/sem.c
74415 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74416 return 0;
74417 }
74418
74419 +static struct ipc_ops sem_ops = {
74420 + .getnew = newary,
74421 + .associate = sem_security,
74422 + .more_checks = sem_more_checks
74423 +};
74424 +
74425 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74426 {
74427 struct ipc_namespace *ns;
74428 - struct ipc_ops sem_ops;
74429 struct ipc_params sem_params;
74430
74431 ns = current->nsproxy->ipc_ns;
74432 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74433 if (nsems < 0 || nsems > ns->sc_semmsl)
74434 return -EINVAL;
74435
74436 - sem_ops.getnew = newary;
74437 - sem_ops.associate = sem_security;
74438 - sem_ops.more_checks = sem_more_checks;
74439 -
74440 sem_params.key = key;
74441 sem_params.flg = semflg;
74442 sem_params.u.nsems = nsems;
74443 diff --git a/ipc/shm.c b/ipc/shm.c
74444 index 7e199fa..180a1ca 100644
74445 --- a/ipc/shm.c
74446 +++ b/ipc/shm.c
74447 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74448 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74449 #endif
74450
74451 +#ifdef CONFIG_GRKERNSEC
74452 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74453 + const time_t shm_createtime, const kuid_t cuid,
74454 + const int shmid);
74455 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74456 + const time_t shm_createtime);
74457 +#endif
74458 +
74459 void shm_init_ns(struct ipc_namespace *ns)
74460 {
74461 ns->shm_ctlmax = SHMMAX;
74462 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74463 shp->shm_lprid = 0;
74464 shp->shm_atim = shp->shm_dtim = 0;
74465 shp->shm_ctim = get_seconds();
74466 +#ifdef CONFIG_GRKERNSEC
74467 + {
74468 + struct timespec timeval;
74469 + do_posix_clock_monotonic_gettime(&timeval);
74470 +
74471 + shp->shm_createtime = timeval.tv_sec;
74472 + }
74473 +#endif
74474 shp->shm_segsz = size;
74475 shp->shm_nattch = 0;
74476 shp->shm_file = file;
74477 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74478 return 0;
74479 }
74480
74481 +static struct ipc_ops shm_ops = {
74482 + .getnew = newseg,
74483 + .associate = shm_security,
74484 + .more_checks = shm_more_checks
74485 +};
74486 +
74487 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74488 {
74489 struct ipc_namespace *ns;
74490 - struct ipc_ops shm_ops;
74491 struct ipc_params shm_params;
74492
74493 ns = current->nsproxy->ipc_ns;
74494
74495 - shm_ops.getnew = newseg;
74496 - shm_ops.associate = shm_security;
74497 - shm_ops.more_checks = shm_more_checks;
74498 -
74499 shm_params.key = key;
74500 shm_params.flg = shmflg;
74501 shm_params.u.size = size;
74502 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74503 f_mode = FMODE_READ | FMODE_WRITE;
74504 }
74505 if (shmflg & SHM_EXEC) {
74506 +
74507 +#ifdef CONFIG_PAX_MPROTECT
74508 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74509 + goto out;
74510 +#endif
74511 +
74512 prot |= PROT_EXEC;
74513 acc_mode |= S_IXUGO;
74514 }
74515 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74516 if (err)
74517 goto out_unlock;
74518
74519 +#ifdef CONFIG_GRKERNSEC
74520 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74521 + shp->shm_perm.cuid, shmid) ||
74522 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74523 + err = -EACCES;
74524 + goto out_unlock;
74525 + }
74526 +#endif
74527 +
74528 path = shp->shm_file->f_path;
74529 path_get(&path);
74530 shp->shm_nattch++;
74531 +#ifdef CONFIG_GRKERNSEC
74532 + shp->shm_lapid = current->pid;
74533 +#endif
74534 size = i_size_read(path.dentry->d_inode);
74535 shm_unlock(shp);
74536
74537 diff --git a/kernel/acct.c b/kernel/acct.c
74538 index b9bd7f0..1762b4a 100644
74539 --- a/kernel/acct.c
74540 +++ b/kernel/acct.c
74541 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74542 */
74543 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74544 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74545 - file->f_op->write(file, (char *)&ac,
74546 + file->f_op->write(file, (char __force_user *)&ac,
74547 sizeof(acct_t), &file->f_pos);
74548 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74549 set_fs(fs);
74550 diff --git a/kernel/audit.c b/kernel/audit.c
74551 index 8a667f10..7375e3f 100644
74552 --- a/kernel/audit.c
74553 +++ b/kernel/audit.c
74554 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74555 3) suppressed due to audit_rate_limit
74556 4) suppressed due to audit_backlog_limit
74557 */
74558 -static atomic_t audit_lost = ATOMIC_INIT(0);
74559 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74560
74561 /* The netlink socket. */
74562 static struct sock *audit_sock;
74563 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74564 unsigned long now;
74565 int print;
74566
74567 - atomic_inc(&audit_lost);
74568 + atomic_inc_unchecked(&audit_lost);
74569
74570 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74571
74572 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74573 printk(KERN_WARNING
74574 "audit: audit_lost=%d audit_rate_limit=%d "
74575 "audit_backlog_limit=%d\n",
74576 - atomic_read(&audit_lost),
74577 + atomic_read_unchecked(&audit_lost),
74578 audit_rate_limit,
74579 audit_backlog_limit);
74580 audit_panic(message);
74581 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74582 status_set.pid = audit_pid;
74583 status_set.rate_limit = audit_rate_limit;
74584 status_set.backlog_limit = audit_backlog_limit;
74585 - status_set.lost = atomic_read(&audit_lost);
74586 + status_set.lost = atomic_read_unchecked(&audit_lost);
74587 status_set.backlog = skb_queue_len(&audit_skb_queue);
74588 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74589 &status_set, sizeof(status_set));
74590 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74591 index c4b72b0..8654c4e 100644
74592 --- a/kernel/auditsc.c
74593 +++ b/kernel/auditsc.c
74594 @@ -2295,7 +2295,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74595 }
74596
74597 /* global counter which is incremented every time something logs in */
74598 -static atomic_t session_id = ATOMIC_INIT(0);
74599 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74600
74601 /**
74602 * audit_set_loginuid - set current task's audit_context loginuid
74603 @@ -2319,7 +2319,7 @@ int audit_set_loginuid(kuid_t loginuid)
74604 return -EPERM;
74605 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74606
74607 - sessionid = atomic_inc_return(&session_id);
74608 + sessionid = atomic_inc_return_unchecked(&session_id);
74609 if (context && context->in_syscall) {
74610 struct audit_buffer *ab;
74611
74612 diff --git a/kernel/capability.c b/kernel/capability.c
74613 index f6c2ce5..982c0f9 100644
74614 --- a/kernel/capability.c
74615 +++ b/kernel/capability.c
74616 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74617 * before modification is attempted and the application
74618 * fails.
74619 */
74620 + if (tocopy > ARRAY_SIZE(kdata))
74621 + return -EFAULT;
74622 +
74623 if (copy_to_user(dataptr, kdata, tocopy
74624 * sizeof(struct __user_cap_data_struct))) {
74625 return -EFAULT;
74626 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74627 int ret;
74628
74629 rcu_read_lock();
74630 - ret = security_capable(__task_cred(t), ns, cap);
74631 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74632 + gr_task_is_capable(t, __task_cred(t), cap);
74633 rcu_read_unlock();
74634
74635 - return (ret == 0);
74636 + return ret;
74637 }
74638
74639 /**
74640 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74641 int ret;
74642
74643 rcu_read_lock();
74644 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74645 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74646 rcu_read_unlock();
74647
74648 - return (ret == 0);
74649 + return ret;
74650 }
74651
74652 /**
74653 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74654 BUG();
74655 }
74656
74657 - if (security_capable(current_cred(), ns, cap) == 0) {
74658 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74659 current->flags |= PF_SUPERPRIV;
74660 return true;
74661 }
74662 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74663 }
74664 EXPORT_SYMBOL(ns_capable);
74665
74666 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74667 +{
74668 + if (unlikely(!cap_valid(cap))) {
74669 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74670 + BUG();
74671 + }
74672 +
74673 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74674 + current->flags |= PF_SUPERPRIV;
74675 + return true;
74676 + }
74677 + return false;
74678 +}
74679 +EXPORT_SYMBOL(ns_capable_nolog);
74680 +
74681 /**
74682 * file_ns_capable - Determine if the file's opener had a capability in effect
74683 * @file: The file we want to check
74684 @@ -432,6 +451,12 @@ bool capable(int cap)
74685 }
74686 EXPORT_SYMBOL(capable);
74687
74688 +bool capable_nolog(int cap)
74689 +{
74690 + return ns_capable_nolog(&init_user_ns, cap);
74691 +}
74692 +EXPORT_SYMBOL(capable_nolog);
74693 +
74694 /**
74695 * nsown_capable - Check superior capability to one's own user_ns
74696 * @cap: The capability in question
74697 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74698
74699 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74700 }
74701 +
74702 +bool inode_capable_nolog(const struct inode *inode, int cap)
74703 +{
74704 + struct user_namespace *ns = current_user_ns();
74705 +
74706 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74707 +}
74708 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74709 index a48de6a..df24bfe 100644
74710 --- a/kernel/cgroup.c
74711 +++ b/kernel/cgroup.c
74712 @@ -5567,7 +5567,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74713 struct css_set *cg = link->cg;
74714 struct task_struct *task;
74715 int count = 0;
74716 - seq_printf(seq, "css_set %p\n", cg);
74717 + seq_printf(seq, "css_set %pK\n", cg);
74718 list_for_each_entry(task, &cg->tasks, cg_list) {
74719 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74720 seq_puts(seq, " ...\n");
74721 diff --git a/kernel/compat.c b/kernel/compat.c
74722 index 19971d8..02fe2df 100644
74723 --- a/kernel/compat.c
74724 +++ b/kernel/compat.c
74725 @@ -13,6 +13,7 @@
74726
74727 #include <linux/linkage.h>
74728 #include <linux/compat.h>
74729 +#include <linux/module.h>
74730 #include <linux/errno.h>
74731 #include <linux/time.h>
74732 #include <linux/signal.h>
74733 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74734 mm_segment_t oldfs;
74735 long ret;
74736
74737 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74738 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74739 oldfs = get_fs();
74740 set_fs(KERNEL_DS);
74741 ret = hrtimer_nanosleep_restart(restart);
74742 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74743 oldfs = get_fs();
74744 set_fs(KERNEL_DS);
74745 ret = hrtimer_nanosleep(&tu,
74746 - rmtp ? (struct timespec __user *)&rmt : NULL,
74747 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74748 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74749 set_fs(oldfs);
74750
74751 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74752 mm_segment_t old_fs = get_fs();
74753
74754 set_fs(KERNEL_DS);
74755 - ret = sys_sigpending((old_sigset_t __user *) &s);
74756 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74757 set_fs(old_fs);
74758 if (ret == 0)
74759 ret = put_user(s, set);
74760 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74761 mm_segment_t old_fs = get_fs();
74762
74763 set_fs(KERNEL_DS);
74764 - ret = sys_old_getrlimit(resource, &r);
74765 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74766 set_fs(old_fs);
74767
74768 if (!ret) {
74769 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74770 mm_segment_t old_fs = get_fs();
74771
74772 set_fs(KERNEL_DS);
74773 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74774 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74775 set_fs(old_fs);
74776
74777 if (ret)
74778 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74779 set_fs (KERNEL_DS);
74780 ret = sys_wait4(pid,
74781 (stat_addr ?
74782 - (unsigned int __user *) &status : NULL),
74783 - options, (struct rusage __user *) &r);
74784 + (unsigned int __force_user *) &status : NULL),
74785 + options, (struct rusage __force_user *) &r);
74786 set_fs (old_fs);
74787
74788 if (ret > 0) {
74789 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74790 memset(&info, 0, sizeof(info));
74791
74792 set_fs(KERNEL_DS);
74793 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74794 - uru ? (struct rusage __user *)&ru : NULL);
74795 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74796 + uru ? (struct rusage __force_user *)&ru : NULL);
74797 set_fs(old_fs);
74798
74799 if ((ret < 0) || (info.si_signo == 0))
74800 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74801 oldfs = get_fs();
74802 set_fs(KERNEL_DS);
74803 err = sys_timer_settime(timer_id, flags,
74804 - (struct itimerspec __user *) &newts,
74805 - (struct itimerspec __user *) &oldts);
74806 + (struct itimerspec __force_user *) &newts,
74807 + (struct itimerspec __force_user *) &oldts);
74808 set_fs(oldfs);
74809 if (!err && old && put_compat_itimerspec(old, &oldts))
74810 return -EFAULT;
74811 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74812 oldfs = get_fs();
74813 set_fs(KERNEL_DS);
74814 err = sys_timer_gettime(timer_id,
74815 - (struct itimerspec __user *) &ts);
74816 + (struct itimerspec __force_user *) &ts);
74817 set_fs(oldfs);
74818 if (!err && put_compat_itimerspec(setting, &ts))
74819 return -EFAULT;
74820 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74821 oldfs = get_fs();
74822 set_fs(KERNEL_DS);
74823 err = sys_clock_settime(which_clock,
74824 - (struct timespec __user *) &ts);
74825 + (struct timespec __force_user *) &ts);
74826 set_fs(oldfs);
74827 return err;
74828 }
74829 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74830 oldfs = get_fs();
74831 set_fs(KERNEL_DS);
74832 err = sys_clock_gettime(which_clock,
74833 - (struct timespec __user *) &ts);
74834 + (struct timespec __force_user *) &ts);
74835 set_fs(oldfs);
74836 if (!err && put_compat_timespec(&ts, tp))
74837 return -EFAULT;
74838 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74839
74840 oldfs = get_fs();
74841 set_fs(KERNEL_DS);
74842 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74843 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74844 set_fs(oldfs);
74845
74846 err = compat_put_timex(utp, &txc);
74847 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74848 oldfs = get_fs();
74849 set_fs(KERNEL_DS);
74850 err = sys_clock_getres(which_clock,
74851 - (struct timespec __user *) &ts);
74852 + (struct timespec __force_user *) &ts);
74853 set_fs(oldfs);
74854 if (!err && tp && put_compat_timespec(&ts, tp))
74855 return -EFAULT;
74856 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74857 long err;
74858 mm_segment_t oldfs;
74859 struct timespec tu;
74860 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74861 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74862
74863 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74864 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74865 oldfs = get_fs();
74866 set_fs(KERNEL_DS);
74867 err = clock_nanosleep_restart(restart);
74868 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74869 oldfs = get_fs();
74870 set_fs(KERNEL_DS);
74871 err = sys_clock_nanosleep(which_clock, flags,
74872 - (struct timespec __user *) &in,
74873 - (struct timespec __user *) &out);
74874 + (struct timespec __force_user *) &in,
74875 + (struct timespec __force_user *) &out);
74876 set_fs(oldfs);
74877
74878 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74879 diff --git a/kernel/configs.c b/kernel/configs.c
74880 index 42e8fa0..9e7406b 100644
74881 --- a/kernel/configs.c
74882 +++ b/kernel/configs.c
74883 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74884 struct proc_dir_entry *entry;
74885
74886 /* create the current config file */
74887 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74888 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74889 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74890 + &ikconfig_file_ops);
74891 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74892 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74893 + &ikconfig_file_ops);
74894 +#endif
74895 +#else
74896 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74897 &ikconfig_file_ops);
74898 +#endif
74899 +
74900 if (!entry)
74901 return -ENOMEM;
74902
74903 diff --git a/kernel/cred.c b/kernel/cred.c
74904 index e0573a4..3874e41 100644
74905 --- a/kernel/cred.c
74906 +++ b/kernel/cred.c
74907 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74908 validate_creds(cred);
74909 alter_cred_subscribers(cred, -1);
74910 put_cred(cred);
74911 +
74912 +#ifdef CONFIG_GRKERNSEC_SETXID
74913 + cred = (struct cred *) tsk->delayed_cred;
74914 + if (cred != NULL) {
74915 + tsk->delayed_cred = NULL;
74916 + validate_creds(cred);
74917 + alter_cred_subscribers(cred, -1);
74918 + put_cred(cred);
74919 + }
74920 +#endif
74921 }
74922
74923 /**
74924 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74925 * Always returns 0 thus allowing this function to be tail-called at the end
74926 * of, say, sys_setgid().
74927 */
74928 -int commit_creds(struct cred *new)
74929 +static int __commit_creds(struct cred *new)
74930 {
74931 struct task_struct *task = current;
74932 const struct cred *old = task->real_cred;
74933 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74934
74935 get_cred(new); /* we will require a ref for the subj creds too */
74936
74937 + gr_set_role_label(task, new->uid, new->gid);
74938 +
74939 /* dumpability changes */
74940 if (!uid_eq(old->euid, new->euid) ||
74941 !gid_eq(old->egid, new->egid) ||
74942 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74943 put_cred(old);
74944 return 0;
74945 }
74946 +#ifdef CONFIG_GRKERNSEC_SETXID
74947 +extern int set_user(struct cred *new);
74948 +
74949 +void gr_delayed_cred_worker(void)
74950 +{
74951 + const struct cred *new = current->delayed_cred;
74952 + struct cred *ncred;
74953 +
74954 + current->delayed_cred = NULL;
74955 +
74956 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74957 + // from doing get_cred on it when queueing this
74958 + put_cred(new);
74959 + return;
74960 + } else if (new == NULL)
74961 + return;
74962 +
74963 + ncred = prepare_creds();
74964 + if (!ncred)
74965 + goto die;
74966 + // uids
74967 + ncred->uid = new->uid;
74968 + ncred->euid = new->euid;
74969 + ncred->suid = new->suid;
74970 + ncred->fsuid = new->fsuid;
74971 + // gids
74972 + ncred->gid = new->gid;
74973 + ncred->egid = new->egid;
74974 + ncred->sgid = new->sgid;
74975 + ncred->fsgid = new->fsgid;
74976 + // groups
74977 + if (set_groups(ncred, new->group_info) < 0) {
74978 + abort_creds(ncred);
74979 + goto die;
74980 + }
74981 + // caps
74982 + ncred->securebits = new->securebits;
74983 + ncred->cap_inheritable = new->cap_inheritable;
74984 + ncred->cap_permitted = new->cap_permitted;
74985 + ncred->cap_effective = new->cap_effective;
74986 + ncred->cap_bset = new->cap_bset;
74987 +
74988 + if (set_user(ncred)) {
74989 + abort_creds(ncred);
74990 + goto die;
74991 + }
74992 +
74993 + // from doing get_cred on it when queueing this
74994 + put_cred(new);
74995 +
74996 + __commit_creds(ncred);
74997 + return;
74998 +die:
74999 + // from doing get_cred on it when queueing this
75000 + put_cred(new);
75001 + do_group_exit(SIGKILL);
75002 +}
75003 +#endif
75004 +
75005 +int commit_creds(struct cred *new)
75006 +{
75007 +#ifdef CONFIG_GRKERNSEC_SETXID
75008 + int ret;
75009 + int schedule_it = 0;
75010 + struct task_struct *t;
75011 +
75012 + /* we won't get called with tasklist_lock held for writing
75013 + and interrupts disabled as the cred struct in that case is
75014 + init_cred
75015 + */
75016 + if (grsec_enable_setxid && !current_is_single_threaded() &&
75017 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
75018 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
75019 + schedule_it = 1;
75020 + }
75021 + ret = __commit_creds(new);
75022 + if (schedule_it) {
75023 + rcu_read_lock();
75024 + read_lock(&tasklist_lock);
75025 + for (t = next_thread(current); t != current;
75026 + t = next_thread(t)) {
75027 + if (t->delayed_cred == NULL) {
75028 + t->delayed_cred = get_cred(new);
75029 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
75030 + set_tsk_need_resched(t);
75031 + }
75032 + }
75033 + read_unlock(&tasklist_lock);
75034 + rcu_read_unlock();
75035 + }
75036 + return ret;
75037 +#else
75038 + return __commit_creds(new);
75039 +#endif
75040 +}
75041 +
75042 EXPORT_SYMBOL(commit_creds);
75043
75044 /**
75045 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
75046 index c26278f..e323fb8 100644
75047 --- a/kernel/debug/debug_core.c
75048 +++ b/kernel/debug/debug_core.c
75049 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
75050 */
75051 static atomic_t masters_in_kgdb;
75052 static atomic_t slaves_in_kgdb;
75053 -static atomic_t kgdb_break_tasklet_var;
75054 +static atomic_unchecked_t kgdb_break_tasklet_var;
75055 atomic_t kgdb_setting_breakpoint;
75056
75057 struct task_struct *kgdb_usethread;
75058 @@ -133,7 +133,7 @@ int kgdb_single_step;
75059 static pid_t kgdb_sstep_pid;
75060
75061 /* to keep track of the CPU which is doing the single stepping*/
75062 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75063 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75064
75065 /*
75066 * If you are debugging a problem where roundup (the collection of
75067 @@ -541,7 +541,7 @@ return_normal:
75068 * kernel will only try for the value of sstep_tries before
75069 * giving up and continuing on.
75070 */
75071 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
75072 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
75073 (kgdb_info[cpu].task &&
75074 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
75075 atomic_set(&kgdb_active, -1);
75076 @@ -635,8 +635,8 @@ cpu_master_loop:
75077 }
75078
75079 kgdb_restore:
75080 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
75081 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
75082 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
75083 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
75084 if (kgdb_info[sstep_cpu].task)
75085 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
75086 else
75087 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
75088 static void kgdb_tasklet_bpt(unsigned long ing)
75089 {
75090 kgdb_breakpoint();
75091 - atomic_set(&kgdb_break_tasklet_var, 0);
75092 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
75093 }
75094
75095 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
75096
75097 void kgdb_schedule_breakpoint(void)
75098 {
75099 - if (atomic_read(&kgdb_break_tasklet_var) ||
75100 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
75101 atomic_read(&kgdb_active) != -1 ||
75102 atomic_read(&kgdb_setting_breakpoint))
75103 return;
75104 - atomic_inc(&kgdb_break_tasklet_var);
75105 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
75106 tasklet_schedule(&kgdb_tasklet_breakpoint);
75107 }
75108 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
75109 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
75110 index 00eb8f7..d7e3244 100644
75111 --- a/kernel/debug/kdb/kdb_main.c
75112 +++ b/kernel/debug/kdb/kdb_main.c
75113 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
75114 continue;
75115
75116 kdb_printf("%-20s%8u 0x%p ", mod->name,
75117 - mod->core_size, (void *)mod);
75118 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
75119 #ifdef CONFIG_MODULE_UNLOAD
75120 kdb_printf("%4ld ", module_refcount(mod));
75121 #endif
75122 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
75123 kdb_printf(" (Loading)");
75124 else
75125 kdb_printf(" (Live)");
75126 - kdb_printf(" 0x%p", mod->module_core);
75127 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
75128
75129 #ifdef CONFIG_MODULE_UNLOAD
75130 {
75131 diff --git a/kernel/events/core.c b/kernel/events/core.c
75132 index 9fcb094..353baaaf 100644
75133 --- a/kernel/events/core.c
75134 +++ b/kernel/events/core.c
75135 @@ -154,8 +154,15 @@ static struct srcu_struct pmus_srcu;
75136 * 0 - disallow raw tracepoint access for unpriv
75137 * 1 - disallow cpu events for unpriv
75138 * 2 - disallow kernel profiling for unpriv
75139 + * 3 - disallow all unpriv perf event use
75140 */
75141 -int sysctl_perf_event_paranoid __read_mostly = 1;
75142 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75143 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
75144 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
75145 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
75146 +#else
75147 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
75148 +#endif
75149
75150 /* Minimum for 512 kiB + 1 user control page */
75151 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
75152 @@ -182,7 +189,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
75153 return 0;
75154 }
75155
75156 -static atomic64_t perf_event_id;
75157 +static atomic64_unchecked_t perf_event_id;
75158
75159 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
75160 enum event_type_t event_type);
75161 @@ -2677,7 +2684,7 @@ static void __perf_event_read(void *info)
75162
75163 static inline u64 perf_event_count(struct perf_event *event)
75164 {
75165 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75166 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75167 }
75168
75169 static u64 perf_event_read(struct perf_event *event)
75170 @@ -3007,9 +3014,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75171 mutex_lock(&event->child_mutex);
75172 total += perf_event_read(event);
75173 *enabled += event->total_time_enabled +
75174 - atomic64_read(&event->child_total_time_enabled);
75175 + atomic64_read_unchecked(&event->child_total_time_enabled);
75176 *running += event->total_time_running +
75177 - atomic64_read(&event->child_total_time_running);
75178 + atomic64_read_unchecked(&event->child_total_time_running);
75179
75180 list_for_each_entry(child, &event->child_list, child_list) {
75181 total += perf_event_read(child);
75182 @@ -3412,10 +3419,10 @@ void perf_event_update_userpage(struct perf_event *event)
75183 userpg->offset -= local64_read(&event->hw.prev_count);
75184
75185 userpg->time_enabled = enabled +
75186 - atomic64_read(&event->child_total_time_enabled);
75187 + atomic64_read_unchecked(&event->child_total_time_enabled);
75188
75189 userpg->time_running = running +
75190 - atomic64_read(&event->child_total_time_running);
75191 + atomic64_read_unchecked(&event->child_total_time_running);
75192
75193 arch_perf_update_userpage(userpg, now);
75194
75195 @@ -3886,7 +3893,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
75196
75197 /* Data. */
75198 sp = perf_user_stack_pointer(regs);
75199 - rem = __output_copy_user(handle, (void *) sp, dump_size);
75200 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
75201 dyn_size = dump_size - rem;
75202
75203 perf_output_skip(handle, rem);
75204 @@ -3974,11 +3981,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75205 values[n++] = perf_event_count(event);
75206 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75207 values[n++] = enabled +
75208 - atomic64_read(&event->child_total_time_enabled);
75209 + atomic64_read_unchecked(&event->child_total_time_enabled);
75210 }
75211 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75212 values[n++] = running +
75213 - atomic64_read(&event->child_total_time_running);
75214 + atomic64_read_unchecked(&event->child_total_time_running);
75215 }
75216 if (read_format & PERF_FORMAT_ID)
75217 values[n++] = primary_event_id(event);
75218 @@ -4726,12 +4733,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75219 * need to add enough zero bytes after the string to handle
75220 * the 64bit alignment we do later.
75221 */
75222 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75223 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75224 if (!buf) {
75225 name = strncpy(tmp, "//enomem", sizeof(tmp));
75226 goto got_name;
75227 }
75228 - name = d_path(&file->f_path, buf, PATH_MAX);
75229 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75230 if (IS_ERR(name)) {
75231 name = strncpy(tmp, "//toolong", sizeof(tmp));
75232 goto got_name;
75233 @@ -6167,7 +6174,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75234 event->parent = parent_event;
75235
75236 event->ns = get_pid_ns(task_active_pid_ns(current));
75237 - event->id = atomic64_inc_return(&perf_event_id);
75238 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75239
75240 event->state = PERF_EVENT_STATE_INACTIVE;
75241
75242 @@ -6463,6 +6470,11 @@ SYSCALL_DEFINE5(perf_event_open,
75243 if (flags & ~PERF_FLAG_ALL)
75244 return -EINVAL;
75245
75246 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75247 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
75248 + return -EACCES;
75249 +#endif
75250 +
75251 err = perf_copy_attr(attr_uptr, &attr);
75252 if (err)
75253 return err;
75254 @@ -6795,10 +6807,10 @@ static void sync_child_event(struct perf_event *child_event,
75255 /*
75256 * Add back the child's count to the parent's count:
75257 */
75258 - atomic64_add(child_val, &parent_event->child_count);
75259 - atomic64_add(child_event->total_time_enabled,
75260 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75261 + atomic64_add_unchecked(child_event->total_time_enabled,
75262 &parent_event->child_total_time_enabled);
75263 - atomic64_add(child_event->total_time_running,
75264 + atomic64_add_unchecked(child_event->total_time_running,
75265 &parent_event->child_total_time_running);
75266
75267 /*
75268 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
75269 index eb675c4..54912ff 100644
75270 --- a/kernel/events/internal.h
75271 +++ b/kernel/events/internal.h
75272 @@ -77,10 +77,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
75273 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
75274 }
75275
75276 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
75277 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
75278 static inline unsigned int \
75279 func_name(struct perf_output_handle *handle, \
75280 - const void *buf, unsigned int len) \
75281 + const void user *buf, unsigned int len) \
75282 { \
75283 unsigned long size, written; \
75284 \
75285 @@ -112,17 +112,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
75286 return n;
75287 }
75288
75289 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
75290 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
75291
75292 #define MEMCPY_SKIP(dst, src, n) (n)
75293
75294 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
75295 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
75296
75297 #ifndef arch_perf_out_copy_user
75298 #define arch_perf_out_copy_user __copy_from_user_inatomic
75299 #endif
75300
75301 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
75302 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
75303
75304 /* Callchain handling */
75305 extern struct perf_callchain_entry *
75306 diff --git a/kernel/exit.c b/kernel/exit.c
75307 index 60bc027..ca6d727 100644
75308 --- a/kernel/exit.c
75309 +++ b/kernel/exit.c
75310 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
75311 struct task_struct *leader;
75312 int zap_leader;
75313 repeat:
75314 +#ifdef CONFIG_NET
75315 + gr_del_task_from_ip_table(p);
75316 +#endif
75317 +
75318 /* don't need to get the RCU readlock here - the process is dead and
75319 * can't be modifying its own credentials. But shut RCU-lockdep up */
75320 rcu_read_lock();
75321 @@ -340,7 +344,7 @@ int allow_signal(int sig)
75322 * know it'll be handled, so that they don't get converted to
75323 * SIGKILL or just silently dropped.
75324 */
75325 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75326 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75327 recalc_sigpending();
75328 spin_unlock_irq(&current->sighand->siglock);
75329 return 0;
75330 @@ -710,6 +714,8 @@ void do_exit(long code)
75331 struct task_struct *tsk = current;
75332 int group_dead;
75333
75334 + set_fs(USER_DS);
75335 +
75336 profile_task_exit(tsk);
75337
75338 WARN_ON(blk_needs_flush_plug(tsk));
75339 @@ -726,7 +732,6 @@ void do_exit(long code)
75340 * mm_release()->clear_child_tid() from writing to a user-controlled
75341 * kernel address.
75342 */
75343 - set_fs(USER_DS);
75344
75345 ptrace_event(PTRACE_EVENT_EXIT, code);
75346
75347 @@ -785,6 +790,9 @@ void do_exit(long code)
75348 tsk->exit_code = code;
75349 taskstats_exit(tsk, group_dead);
75350
75351 + gr_acl_handle_psacct(tsk, code);
75352 + gr_acl_handle_exit();
75353 +
75354 exit_mm(tsk);
75355
75356 if (group_dead)
75357 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75358 * Take down every thread in the group. This is called by fatal signals
75359 * as well as by sys_exit_group (below).
75360 */
75361 -void
75362 +__noreturn void
75363 do_group_exit(int exit_code)
75364 {
75365 struct signal_struct *sig = current->signal;
75366 diff --git a/kernel/fork.c b/kernel/fork.c
75367 index 1766d32..c0e44e2 100644
75368 --- a/kernel/fork.c
75369 +++ b/kernel/fork.c
75370 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75371 *stackend = STACK_END_MAGIC; /* for overflow detection */
75372
75373 #ifdef CONFIG_CC_STACKPROTECTOR
75374 - tsk->stack_canary = get_random_int();
75375 + tsk->stack_canary = pax_get_random_long();
75376 #endif
75377
75378 /*
75379 @@ -344,13 +344,81 @@ free_tsk:
75380 }
75381
75382 #ifdef CONFIG_MMU
75383 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75384 +{
75385 + struct vm_area_struct *tmp;
75386 + unsigned long charge;
75387 + struct mempolicy *pol;
75388 + struct file *file;
75389 +
75390 + charge = 0;
75391 + if (mpnt->vm_flags & VM_ACCOUNT) {
75392 + unsigned long len = vma_pages(mpnt);
75393 +
75394 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75395 + goto fail_nomem;
75396 + charge = len;
75397 + }
75398 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75399 + if (!tmp)
75400 + goto fail_nomem;
75401 + *tmp = *mpnt;
75402 + tmp->vm_mm = mm;
75403 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75404 + pol = mpol_dup(vma_policy(mpnt));
75405 + if (IS_ERR(pol))
75406 + goto fail_nomem_policy;
75407 + vma_set_policy(tmp, pol);
75408 + if (anon_vma_fork(tmp, mpnt))
75409 + goto fail_nomem_anon_vma_fork;
75410 + tmp->vm_flags &= ~VM_LOCKED;
75411 + tmp->vm_next = tmp->vm_prev = NULL;
75412 + tmp->vm_mirror = NULL;
75413 + file = tmp->vm_file;
75414 + if (file) {
75415 + struct inode *inode = file_inode(file);
75416 + struct address_space *mapping = file->f_mapping;
75417 +
75418 + get_file(file);
75419 + if (tmp->vm_flags & VM_DENYWRITE)
75420 + atomic_dec(&inode->i_writecount);
75421 + mutex_lock(&mapping->i_mmap_mutex);
75422 + if (tmp->vm_flags & VM_SHARED)
75423 + mapping->i_mmap_writable++;
75424 + flush_dcache_mmap_lock(mapping);
75425 + /* insert tmp into the share list, just after mpnt */
75426 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75427 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75428 + else
75429 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75430 + flush_dcache_mmap_unlock(mapping);
75431 + mutex_unlock(&mapping->i_mmap_mutex);
75432 + }
75433 +
75434 + /*
75435 + * Clear hugetlb-related page reserves for children. This only
75436 + * affects MAP_PRIVATE mappings. Faults generated by the child
75437 + * are not guaranteed to succeed, even if read-only
75438 + */
75439 + if (is_vm_hugetlb_page(tmp))
75440 + reset_vma_resv_huge_pages(tmp);
75441 +
75442 + return tmp;
75443 +
75444 +fail_nomem_anon_vma_fork:
75445 + mpol_put(pol);
75446 +fail_nomem_policy:
75447 + kmem_cache_free(vm_area_cachep, tmp);
75448 +fail_nomem:
75449 + vm_unacct_memory(charge);
75450 + return NULL;
75451 +}
75452 +
75453 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75454 {
75455 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75456 struct rb_node **rb_link, *rb_parent;
75457 int retval;
75458 - unsigned long charge;
75459 - struct mempolicy *pol;
75460
75461 uprobe_start_dup_mmap();
75462 down_write(&oldmm->mmap_sem);
75463 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75464 mm->locked_vm = 0;
75465 mm->mmap = NULL;
75466 mm->mmap_cache = NULL;
75467 - mm->free_area_cache = oldmm->mmap_base;
75468 - mm->cached_hole_size = ~0UL;
75469 + mm->free_area_cache = oldmm->free_area_cache;
75470 + mm->cached_hole_size = oldmm->cached_hole_size;
75471 mm->map_count = 0;
75472 cpumask_clear(mm_cpumask(mm));
75473 mm->mm_rb = RB_ROOT;
75474 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75475
75476 prev = NULL;
75477 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75478 - struct file *file;
75479 -
75480 if (mpnt->vm_flags & VM_DONTCOPY) {
75481 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75482 -vma_pages(mpnt));
75483 continue;
75484 }
75485 - charge = 0;
75486 - if (mpnt->vm_flags & VM_ACCOUNT) {
75487 - unsigned long len = vma_pages(mpnt);
75488 -
75489 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75490 - goto fail_nomem;
75491 - charge = len;
75492 - }
75493 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75494 - if (!tmp)
75495 - goto fail_nomem;
75496 - *tmp = *mpnt;
75497 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75498 - pol = mpol_dup(vma_policy(mpnt));
75499 - retval = PTR_ERR(pol);
75500 - if (IS_ERR(pol))
75501 - goto fail_nomem_policy;
75502 - vma_set_policy(tmp, pol);
75503 - tmp->vm_mm = mm;
75504 - if (anon_vma_fork(tmp, mpnt))
75505 - goto fail_nomem_anon_vma_fork;
75506 - tmp->vm_flags &= ~VM_LOCKED;
75507 - tmp->vm_next = tmp->vm_prev = NULL;
75508 - file = tmp->vm_file;
75509 - if (file) {
75510 - struct inode *inode = file_inode(file);
75511 - struct address_space *mapping = file->f_mapping;
75512 -
75513 - get_file(file);
75514 - if (tmp->vm_flags & VM_DENYWRITE)
75515 - atomic_dec(&inode->i_writecount);
75516 - mutex_lock(&mapping->i_mmap_mutex);
75517 - if (tmp->vm_flags & VM_SHARED)
75518 - mapping->i_mmap_writable++;
75519 - flush_dcache_mmap_lock(mapping);
75520 - /* insert tmp into the share list, just after mpnt */
75521 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75522 - vma_nonlinear_insert(tmp,
75523 - &mapping->i_mmap_nonlinear);
75524 - else
75525 - vma_interval_tree_insert_after(tmp, mpnt,
75526 - &mapping->i_mmap);
75527 - flush_dcache_mmap_unlock(mapping);
75528 - mutex_unlock(&mapping->i_mmap_mutex);
75529 + tmp = dup_vma(mm, oldmm, mpnt);
75530 + if (!tmp) {
75531 + retval = -ENOMEM;
75532 + goto out;
75533 }
75534
75535 /*
75536 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75537 if (retval)
75538 goto out;
75539 }
75540 +
75541 +#ifdef CONFIG_PAX_SEGMEXEC
75542 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75543 + struct vm_area_struct *mpnt_m;
75544 +
75545 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75546 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75547 +
75548 + if (!mpnt->vm_mirror)
75549 + continue;
75550 +
75551 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75552 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75553 + mpnt->vm_mirror = mpnt_m;
75554 + } else {
75555 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75556 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75557 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75558 + mpnt->vm_mirror->vm_mirror = mpnt;
75559 + }
75560 + }
75561 + BUG_ON(mpnt_m);
75562 + }
75563 +#endif
75564 +
75565 /* a new mm has just been created */
75566 arch_dup_mmap(oldmm, mm);
75567 retval = 0;
75568 @@ -472,14 +523,6 @@ out:
75569 up_write(&oldmm->mmap_sem);
75570 uprobe_end_dup_mmap();
75571 return retval;
75572 -fail_nomem_anon_vma_fork:
75573 - mpol_put(pol);
75574 -fail_nomem_policy:
75575 - kmem_cache_free(vm_area_cachep, tmp);
75576 -fail_nomem:
75577 - retval = -ENOMEM;
75578 - vm_unacct_memory(charge);
75579 - goto out;
75580 }
75581
75582 static inline int mm_alloc_pgd(struct mm_struct *mm)
75583 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75584 return ERR_PTR(err);
75585
75586 mm = get_task_mm(task);
75587 - if (mm && mm != current->mm &&
75588 - !ptrace_may_access(task, mode)) {
75589 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75590 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75591 mmput(mm);
75592 mm = ERR_PTR(-EACCES);
75593 }
75594 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75595 spin_unlock(&fs->lock);
75596 return -EAGAIN;
75597 }
75598 - fs->users++;
75599 + atomic_inc(&fs->users);
75600 spin_unlock(&fs->lock);
75601 return 0;
75602 }
75603 tsk->fs = copy_fs_struct(fs);
75604 if (!tsk->fs)
75605 return -ENOMEM;
75606 + /* Carry through gr_chroot_dentry and is_chrooted instead
75607 + of recomputing it here. Already copied when the task struct
75608 + is duplicated. This allows pivot_root to not be treated as
75609 + a chroot
75610 + */
75611 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75612 +
75613 return 0;
75614 }
75615
75616 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75617 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75618 #endif
75619 retval = -EAGAIN;
75620 +
75621 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75622 +
75623 if (atomic_read(&p->real_cred->user->processes) >=
75624 task_rlimit(p, RLIMIT_NPROC)) {
75625 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75626 @@ -1441,6 +1494,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75627 goto bad_fork_free_pid;
75628 }
75629
75630 + /* synchronizes with gr_set_acls()
75631 + we need to call this past the point of no return for fork()
75632 + */
75633 + gr_copy_label(p);
75634 +
75635 if (clone_flags & CLONE_THREAD) {
75636 current->signal->nr_threads++;
75637 atomic_inc(&current->signal->live);
75638 @@ -1524,6 +1582,8 @@ bad_fork_cleanup_count:
75639 bad_fork_free:
75640 free_task(p);
75641 fork_out:
75642 + gr_log_forkfail(retval);
75643 +
75644 return ERR_PTR(retval);
75645 }
75646
75647 @@ -1574,6 +1634,23 @@ long do_fork(unsigned long clone_flags,
75648 return -EINVAL;
75649 }
75650
75651 +#ifdef CONFIG_GRKERNSEC
75652 + if (clone_flags & CLONE_NEWUSER) {
75653 + /*
75654 + * This doesn't really inspire confidence:
75655 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75656 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75657 + * Increases kernel attack surface in areas developers
75658 + * previously cared little about ("low importance due
75659 + * to requiring "root" capability")
75660 + * To be removed when this code receives *proper* review
75661 + */
75662 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75663 + !capable(CAP_SETGID))
75664 + return -EPERM;
75665 + }
75666 +#endif
75667 +
75668 /*
75669 * Determine whether and which event to report to ptracer. When
75670 * called from kernel_thread or CLONE_UNTRACED is explicitly
75671 @@ -1608,6 +1685,8 @@ long do_fork(unsigned long clone_flags,
75672 if (clone_flags & CLONE_PARENT_SETTID)
75673 put_user(nr, parent_tidptr);
75674
75675 + gr_handle_brute_check();
75676 +
75677 if (clone_flags & CLONE_VFORK) {
75678 p->vfork_done = &vfork;
75679 init_completion(&vfork);
75680 @@ -1761,7 +1840,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75681 return 0;
75682
75683 /* don't need lock here; in the worst case we'll do useless copy */
75684 - if (fs->users == 1)
75685 + if (atomic_read(&fs->users) == 1)
75686 return 0;
75687
75688 *new_fsp = copy_fs_struct(fs);
75689 @@ -1873,7 +1952,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75690 fs = current->fs;
75691 spin_lock(&fs->lock);
75692 current->fs = new_fs;
75693 - if (--fs->users)
75694 + gr_set_chroot_entries(current, &current->fs->root);
75695 + if (atomic_dec_return(&fs->users))
75696 new_fs = NULL;
75697 else
75698 new_fs = fs;
75699 diff --git a/kernel/futex.c b/kernel/futex.c
75700 index b26dcfc..39e266a 100644
75701 --- a/kernel/futex.c
75702 +++ b/kernel/futex.c
75703 @@ -54,6 +54,7 @@
75704 #include <linux/mount.h>
75705 #include <linux/pagemap.h>
75706 #include <linux/syscalls.h>
75707 +#include <linux/ptrace.h>
75708 #include <linux/signal.h>
75709 #include <linux/export.h>
75710 #include <linux/magic.h>
75711 @@ -241,6 +242,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75712 struct page *page, *page_head;
75713 int err, ro = 0;
75714
75715 +#ifdef CONFIG_PAX_SEGMEXEC
75716 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75717 + return -EFAULT;
75718 +#endif
75719 +
75720 /*
75721 * The futex address must be "naturally" aligned.
75722 */
75723 @@ -2732,6 +2738,7 @@ static int __init futex_init(void)
75724 {
75725 u32 curval;
75726 int i;
75727 + mm_segment_t oldfs;
75728
75729 /*
75730 * This will fail and we want it. Some arch implementations do
75731 @@ -2743,8 +2750,11 @@ static int __init futex_init(void)
75732 * implementation, the non-functional ones will return
75733 * -ENOSYS.
75734 */
75735 + oldfs = get_fs();
75736 + set_fs(USER_DS);
75737 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75738 futex_cmpxchg_enabled = 1;
75739 + set_fs(oldfs);
75740
75741 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75742 plist_head_init(&futex_queues[i].chain);
75743 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75744 index f9f44fd..29885e4 100644
75745 --- a/kernel/futex_compat.c
75746 +++ b/kernel/futex_compat.c
75747 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75748 return 0;
75749 }
75750
75751 -static void __user *futex_uaddr(struct robust_list __user *entry,
75752 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75753 compat_long_t futex_offset)
75754 {
75755 compat_uptr_t base = ptr_to_compat(entry);
75756 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75757 index 9b22d03..6295b62 100644
75758 --- a/kernel/gcov/base.c
75759 +++ b/kernel/gcov/base.c
75760 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75761 }
75762
75763 #ifdef CONFIG_MODULES
75764 -static inline int within(void *addr, void *start, unsigned long size)
75765 -{
75766 - return ((addr >= start) && (addr < start + size));
75767 -}
75768 -
75769 /* Update list and generate events when modules are unloaded. */
75770 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75771 void *data)
75772 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75773 prev = NULL;
75774 /* Remove entries located in module from linked list. */
75775 for (info = gcov_info_head; info; info = info->next) {
75776 - if (within(info, mod->module_core, mod->core_size)) {
75777 + if (within_module_core_rw((unsigned long)info, mod)) {
75778 if (prev)
75779 prev->next = info->next;
75780 else
75781 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75782 index 7ef5556..8247f11 100644
75783 --- a/kernel/hrtimer.c
75784 +++ b/kernel/hrtimer.c
75785 @@ -1416,7 +1416,7 @@ void hrtimer_peek_ahead_timers(void)
75786 local_irq_restore(flags);
75787 }
75788
75789 -static void run_hrtimer_softirq(struct softirq_action *h)
75790 +static void run_hrtimer_softirq(void)
75791 {
75792 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75793
75794 @@ -1758,7 +1758,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75795 return NOTIFY_OK;
75796 }
75797
75798 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75799 +static struct notifier_block hrtimers_nb = {
75800 .notifier_call = hrtimer_cpu_notify,
75801 };
75802
75803 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
75804 index 55fcce6..0e4cf34 100644
75805 --- a/kernel/irq_work.c
75806 +++ b/kernel/irq_work.c
75807 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
75808 return NOTIFY_OK;
75809 }
75810
75811 -static struct notifier_block cpu_notify;
75812 +static struct notifier_block cpu_notify = {
75813 + .notifier_call = irq_work_cpu_notify,
75814 + .priority = 0,
75815 +};
75816
75817 static __init int irq_work_init_cpu_notifier(void)
75818 {
75819 - cpu_notify.notifier_call = irq_work_cpu_notify;
75820 - cpu_notify.priority = 0;
75821 register_cpu_notifier(&cpu_notify);
75822 return 0;
75823 }
75824 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75825 index 60f48fa..7f3a770 100644
75826 --- a/kernel/jump_label.c
75827 +++ b/kernel/jump_label.c
75828 @@ -13,6 +13,7 @@
75829 #include <linux/sort.h>
75830 #include <linux/err.h>
75831 #include <linux/static_key.h>
75832 +#include <linux/mm.h>
75833
75834 #ifdef HAVE_JUMP_LABEL
75835
75836 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75837
75838 size = (((unsigned long)stop - (unsigned long)start)
75839 / sizeof(struct jump_entry));
75840 + pax_open_kernel();
75841 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75842 + pax_close_kernel();
75843 }
75844
75845 static void jump_label_update(struct static_key *key, int enable);
75846 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75847 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75848 struct jump_entry *iter;
75849
75850 + pax_open_kernel();
75851 for (iter = iter_start; iter < iter_stop; iter++) {
75852 if (within_module_init(iter->code, mod))
75853 iter->code = 0;
75854 }
75855 + pax_close_kernel();
75856 }
75857
75858 static int
75859 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75860 index 2169fee..706ccca 100644
75861 --- a/kernel/kallsyms.c
75862 +++ b/kernel/kallsyms.c
75863 @@ -11,6 +11,9 @@
75864 * Changed the compression method from stem compression to "table lookup"
75865 * compression (see scripts/kallsyms.c for a more complete description)
75866 */
75867 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75868 +#define __INCLUDED_BY_HIDESYM 1
75869 +#endif
75870 #include <linux/kallsyms.h>
75871 #include <linux/module.h>
75872 #include <linux/init.h>
75873 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75874
75875 static inline int is_kernel_inittext(unsigned long addr)
75876 {
75877 + if (system_state != SYSTEM_BOOTING)
75878 + return 0;
75879 +
75880 if (addr >= (unsigned long)_sinittext
75881 && addr <= (unsigned long)_einittext)
75882 return 1;
75883 return 0;
75884 }
75885
75886 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75887 +#ifdef CONFIG_MODULES
75888 +static inline int is_module_text(unsigned long addr)
75889 +{
75890 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75891 + return 1;
75892 +
75893 + addr = ktla_ktva(addr);
75894 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75895 +}
75896 +#else
75897 +static inline int is_module_text(unsigned long addr)
75898 +{
75899 + return 0;
75900 +}
75901 +#endif
75902 +#endif
75903 +
75904 static inline int is_kernel_text(unsigned long addr)
75905 {
75906 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75907 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75908
75909 static inline int is_kernel(unsigned long addr)
75910 {
75911 +
75912 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75913 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75914 + return 1;
75915 +
75916 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75917 +#else
75918 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75919 +#endif
75920 +
75921 return 1;
75922 return in_gate_area_no_mm(addr);
75923 }
75924
75925 static int is_ksym_addr(unsigned long addr)
75926 {
75927 +
75928 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75929 + if (is_module_text(addr))
75930 + return 0;
75931 +#endif
75932 +
75933 if (all_var)
75934 return is_kernel(addr);
75935
75936 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75937
75938 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75939 {
75940 - iter->name[0] = '\0';
75941 iter->nameoff = get_symbol_offset(new_pos);
75942 iter->pos = new_pos;
75943 }
75944 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75945 {
75946 struct kallsym_iter *iter = m->private;
75947
75948 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75949 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75950 + return 0;
75951 +#endif
75952 +
75953 /* Some debugging symbols have no name. Ignore them. */
75954 if (!iter->name[0])
75955 return 0;
75956 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75957 */
75958 type = iter->exported ? toupper(iter->type) :
75959 tolower(iter->type);
75960 +
75961 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75962 type, iter->name, iter->module_name);
75963 } else
75964 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75965 struct kallsym_iter *iter;
75966 int ret;
75967
75968 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75969 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75970 if (!iter)
75971 return -ENOMEM;
75972 reset_iter(iter, 0);
75973 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75974 index e30ac0f..3528cac 100644
75975 --- a/kernel/kcmp.c
75976 +++ b/kernel/kcmp.c
75977 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75978 struct task_struct *task1, *task2;
75979 int ret;
75980
75981 +#ifdef CONFIG_GRKERNSEC
75982 + return -ENOSYS;
75983 +#endif
75984 +
75985 rcu_read_lock();
75986
75987 /*
75988 diff --git a/kernel/kexec.c b/kernel/kexec.c
75989 index ffd4e11..c3ff6bf 100644
75990 --- a/kernel/kexec.c
75991 +++ b/kernel/kexec.c
75992 @@ -1048,7 +1048,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75993 unsigned long flags)
75994 {
75995 struct compat_kexec_segment in;
75996 - struct kexec_segment out, __user *ksegments;
75997 + struct kexec_segment out;
75998 + struct kexec_segment __user *ksegments;
75999 unsigned long i, result;
76000
76001 /* Don't allow clients that don't understand the native
76002 diff --git a/kernel/kmod.c b/kernel/kmod.c
76003 index 8985c87..f539dbe 100644
76004 --- a/kernel/kmod.c
76005 +++ b/kernel/kmod.c
76006 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
76007 kfree(info->argv);
76008 }
76009
76010 -static int call_modprobe(char *module_name, int wait)
76011 +static int call_modprobe(char *module_name, char *module_param, int wait)
76012 {
76013 static char *envp[] = {
76014 "HOME=/",
76015 @@ -84,7 +84,7 @@ static int call_modprobe(char *module_name, int wait)
76016 NULL
76017 };
76018
76019 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
76020 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
76021 if (!argv)
76022 goto out;
76023
76024 @@ -96,7 +96,8 @@ static int call_modprobe(char *module_name, int wait)
76025 argv[1] = "-q";
76026 argv[2] = "--";
76027 argv[3] = module_name; /* check free_modprobe_argv() */
76028 - argv[4] = NULL;
76029 + argv[4] = module_param;
76030 + argv[5] = NULL;
76031
76032 return call_usermodehelper_fns(modprobe_path, argv, envp,
76033 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
76034 @@ -121,9 +122,8 @@ out:
76035 * If module auto-loading support is disabled then this function
76036 * becomes a no-operation.
76037 */
76038 -int __request_module(bool wait, const char *fmt, ...)
76039 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
76040 {
76041 - va_list args;
76042 char module_name[MODULE_NAME_LEN];
76043 unsigned int max_modprobes;
76044 int ret;
76045 @@ -139,9 +139,7 @@ int __request_module(bool wait, const char *fmt, ...)
76046 */
76047 WARN_ON_ONCE(wait && current_is_async());
76048
76049 - va_start(args, fmt);
76050 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
76051 - va_end(args);
76052 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
76053 if (ret >= MODULE_NAME_LEN)
76054 return -ENAMETOOLONG;
76055
76056 @@ -149,6 +147,20 @@ int __request_module(bool wait, const char *fmt, ...)
76057 if (ret)
76058 return ret;
76059
76060 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76061 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76062 + /* hack to workaround consolekit/udisks stupidity */
76063 + read_lock(&tasklist_lock);
76064 + if (!strcmp(current->comm, "mount") &&
76065 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
76066 + read_unlock(&tasklist_lock);
76067 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
76068 + return -EPERM;
76069 + }
76070 + read_unlock(&tasklist_lock);
76071 + }
76072 +#endif
76073 +
76074 /* If modprobe needs a service that is in a module, we get a recursive
76075 * loop. Limit the number of running kmod threads to max_threads/2 or
76076 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
76077 @@ -177,11 +189,52 @@ int __request_module(bool wait, const char *fmt, ...)
76078
76079 trace_module_request(module_name, wait, _RET_IP_);
76080
76081 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76082 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76083
76084 atomic_dec(&kmod_concurrent);
76085 return ret;
76086 }
76087 +
76088 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
76089 +{
76090 + va_list args;
76091 + int ret;
76092 +
76093 + va_start(args, fmt);
76094 + ret = ____request_module(wait, module_param, fmt, args);
76095 + va_end(args);
76096 +
76097 + return ret;
76098 +}
76099 +
76100 +int __request_module(bool wait, const char *fmt, ...)
76101 +{
76102 + va_list args;
76103 + int ret;
76104 +
76105 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76106 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76107 + char module_param[MODULE_NAME_LEN];
76108 +
76109 + memset(module_param, 0, sizeof(module_param));
76110 +
76111 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
76112 +
76113 + va_start(args, fmt);
76114 + ret = ____request_module(wait, module_param, fmt, args);
76115 + va_end(args);
76116 +
76117 + return ret;
76118 + }
76119 +#endif
76120 +
76121 + va_start(args, fmt);
76122 + ret = ____request_module(wait, NULL, fmt, args);
76123 + va_end(args);
76124 +
76125 + return ret;
76126 +}
76127 +
76128 EXPORT_SYMBOL(__request_module);
76129 #endif /* CONFIG_MODULES */
76130
76131 @@ -292,7 +345,7 @@ static int wait_for_helper(void *data)
76132 *
76133 * Thus the __user pointer cast is valid here.
76134 */
76135 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
76136 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
76137
76138 /*
76139 * If ret is 0, either ____call_usermodehelper failed and the
76140 @@ -649,7 +702,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
76141 static int proc_cap_handler(struct ctl_table *table, int write,
76142 void __user *buffer, size_t *lenp, loff_t *ppos)
76143 {
76144 - struct ctl_table t;
76145 + ctl_table_no_const t;
76146 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
76147 kernel_cap_t new_cap;
76148 int err, i;
76149 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
76150 index 3fed7f0..a3f95ed 100644
76151 --- a/kernel/kprobes.c
76152 +++ b/kernel/kprobes.c
76153 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
76154 * kernel image and loaded module images reside. This is required
76155 * so x86_64 can correctly handle the %rip-relative fixups.
76156 */
76157 - kip->insns = module_alloc(PAGE_SIZE);
76158 + kip->insns = module_alloc_exec(PAGE_SIZE);
76159 if (!kip->insns) {
76160 kfree(kip);
76161 return NULL;
76162 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
76163 */
76164 if (!list_is_singular(&kip->list)) {
76165 list_del(&kip->list);
76166 - module_free(NULL, kip->insns);
76167 + module_free_exec(NULL, kip->insns);
76168 kfree(kip);
76169 }
76170 return 1;
76171 @@ -2073,7 +2073,7 @@ static int __init init_kprobes(void)
76172 {
76173 int i, err = 0;
76174 unsigned long offset = 0, size = 0;
76175 - char *modname, namebuf[128];
76176 + char *modname, namebuf[KSYM_NAME_LEN];
76177 const char *symbol_name;
76178 void *addr;
76179 struct kprobe_blackpoint *kb;
76180 @@ -2158,11 +2158,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
76181 kprobe_type = "k";
76182
76183 if (sym)
76184 - seq_printf(pi, "%p %s %s+0x%x %s ",
76185 + seq_printf(pi, "%pK %s %s+0x%x %s ",
76186 p->addr, kprobe_type, sym, offset,
76187 (modname ? modname : " "));
76188 else
76189 - seq_printf(pi, "%p %s %p ",
76190 + seq_printf(pi, "%pK %s %pK ",
76191 p->addr, kprobe_type, p->addr);
76192
76193 if (!pp)
76194 @@ -2199,7 +2199,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
76195 const char *sym = NULL;
76196 unsigned int i = *(loff_t *) v;
76197 unsigned long offset = 0;
76198 - char *modname, namebuf[128];
76199 + char *modname, namebuf[KSYM_NAME_LEN];
76200
76201 head = &kprobe_table[i];
76202 preempt_disable();
76203 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
76204 index 6ada93c..dce7d5d 100644
76205 --- a/kernel/ksysfs.c
76206 +++ b/kernel/ksysfs.c
76207 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
76208 {
76209 if (count+1 > UEVENT_HELPER_PATH_LEN)
76210 return -ENOENT;
76211 + if (!capable(CAP_SYS_ADMIN))
76212 + return -EPERM;
76213 memcpy(uevent_helper, buf, count);
76214 uevent_helper[count] = '\0';
76215 if (count && uevent_helper[count-1] == '\n')
76216 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
76217 return count;
76218 }
76219
76220 -static struct bin_attribute notes_attr = {
76221 +static bin_attribute_no_const notes_attr __read_only = {
76222 .attr = {
76223 .name = "notes",
76224 .mode = S_IRUGO,
76225 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
76226 index 8a0efac..56f1e2d 100644
76227 --- a/kernel/lockdep.c
76228 +++ b/kernel/lockdep.c
76229 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
76230 end = (unsigned long) &_end,
76231 addr = (unsigned long) obj;
76232
76233 +#ifdef CONFIG_PAX_KERNEXEC
76234 + start = ktla_ktva(start);
76235 +#endif
76236 +
76237 /*
76238 * static variable?
76239 */
76240 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
76241 if (!static_obj(lock->key)) {
76242 debug_locks_off();
76243 printk("INFO: trying to register non-static key.\n");
76244 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76245 printk("the code is fine but needs lockdep annotation.\n");
76246 printk("turning off the locking correctness validator.\n");
76247 dump_stack();
76248 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76249 if (!class)
76250 return 0;
76251 }
76252 - atomic_inc((atomic_t *)&class->ops);
76253 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76254 if (very_verbose(class)) {
76255 printk("\nacquire class [%p] %s", class->key, class->name);
76256 if (class->name_version > 1)
76257 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76258 index b2c71c5..7b88d63 100644
76259 --- a/kernel/lockdep_proc.c
76260 +++ b/kernel/lockdep_proc.c
76261 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76262 return 0;
76263 }
76264
76265 - seq_printf(m, "%p", class->key);
76266 + seq_printf(m, "%pK", class->key);
76267 #ifdef CONFIG_DEBUG_LOCKDEP
76268 seq_printf(m, " OPS:%8ld", class->ops);
76269 #endif
76270 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76271
76272 list_for_each_entry(entry, &class->locks_after, entry) {
76273 if (entry->distance == 1) {
76274 - seq_printf(m, " -> [%p] ", entry->class->key);
76275 + seq_printf(m, " -> [%pK] ", entry->class->key);
76276 print_name(m, entry->class);
76277 seq_puts(m, "\n");
76278 }
76279 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76280 if (!class->key)
76281 continue;
76282
76283 - seq_printf(m, "[%p] ", class->key);
76284 + seq_printf(m, "[%pK] ", class->key);
76285 print_name(m, class);
76286 seq_puts(m, "\n");
76287 }
76288 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76289 if (!i)
76290 seq_line(m, '-', 40-namelen, namelen);
76291
76292 - snprintf(ip, sizeof(ip), "[<%p>]",
76293 + snprintf(ip, sizeof(ip), "[<%pK>]",
76294 (void *)class->contention_point[i]);
76295 seq_printf(m, "%40s %14lu %29s %pS\n",
76296 name, stats->contention_point[i],
76297 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76298 if (!i)
76299 seq_line(m, '-', 40-namelen, namelen);
76300
76301 - snprintf(ip, sizeof(ip), "[<%p>]",
76302 + snprintf(ip, sizeof(ip), "[<%pK>]",
76303 (void *)class->contending_point[i]);
76304 seq_printf(m, "%40s %14lu %29s %pS\n",
76305 name, stats->contending_point[i],
76306 diff --git a/kernel/module.c b/kernel/module.c
76307 index 97f202c..109575f 100644
76308 --- a/kernel/module.c
76309 +++ b/kernel/module.c
76310 @@ -61,6 +61,7 @@
76311 #include <linux/pfn.h>
76312 #include <linux/bsearch.h>
76313 #include <linux/fips.h>
76314 +#include <linux/grsecurity.h>
76315 #include <uapi/linux/module.h>
76316 #include "module-internal.h"
76317
76318 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76319
76320 /* Bounds of module allocation, for speeding __module_address.
76321 * Protected by module_mutex. */
76322 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76323 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76324 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76325
76326 int register_module_notifier(struct notifier_block * nb)
76327 {
76328 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76329 return true;
76330
76331 list_for_each_entry_rcu(mod, &modules, list) {
76332 - struct symsearch arr[] = {
76333 + struct symsearch modarr[] = {
76334 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76335 NOT_GPL_ONLY, false },
76336 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76337 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76338 if (mod->state == MODULE_STATE_UNFORMED)
76339 continue;
76340
76341 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76342 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76343 return true;
76344 }
76345 return false;
76346 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76347 static int percpu_modalloc(struct module *mod,
76348 unsigned long size, unsigned long align)
76349 {
76350 - if (align > PAGE_SIZE) {
76351 + if (align-1 >= PAGE_SIZE) {
76352 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76353 mod->name, align, PAGE_SIZE);
76354 align = PAGE_SIZE;
76355 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
76356 static ssize_t show_coresize(struct module_attribute *mattr,
76357 struct module_kobject *mk, char *buffer)
76358 {
76359 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76360 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76361 }
76362
76363 static struct module_attribute modinfo_coresize =
76364 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
76365 static ssize_t show_initsize(struct module_attribute *mattr,
76366 struct module_kobject *mk, char *buffer)
76367 {
76368 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76369 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76370 }
76371
76372 static struct module_attribute modinfo_initsize =
76373 @@ -1312,7 +1314,7 @@ resolve_symbol_wait(struct module *mod,
76374 */
76375 #ifdef CONFIG_SYSFS
76376
76377 -#ifdef CONFIG_KALLSYMS
76378 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76379 static inline bool sect_empty(const Elf_Shdr *sect)
76380 {
76381 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76382 @@ -1452,7 +1454,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76383 {
76384 unsigned int notes, loaded, i;
76385 struct module_notes_attrs *notes_attrs;
76386 - struct bin_attribute *nattr;
76387 + bin_attribute_no_const *nattr;
76388
76389 /* failed to create section attributes, so can't create notes */
76390 if (!mod->sect_attrs)
76391 @@ -1564,7 +1566,7 @@ static void del_usage_links(struct module *mod)
76392 static int module_add_modinfo_attrs(struct module *mod)
76393 {
76394 struct module_attribute *attr;
76395 - struct module_attribute *temp_attr;
76396 + module_attribute_no_const *temp_attr;
76397 int error = 0;
76398 int i;
76399
76400 @@ -1778,21 +1780,21 @@ static void set_section_ro_nx(void *base,
76401
76402 static void unset_module_core_ro_nx(struct module *mod)
76403 {
76404 - set_page_attributes(mod->module_core + mod->core_text_size,
76405 - mod->module_core + mod->core_size,
76406 + set_page_attributes(mod->module_core_rw,
76407 + mod->module_core_rw + mod->core_size_rw,
76408 set_memory_x);
76409 - set_page_attributes(mod->module_core,
76410 - mod->module_core + mod->core_ro_size,
76411 + set_page_attributes(mod->module_core_rx,
76412 + mod->module_core_rx + mod->core_size_rx,
76413 set_memory_rw);
76414 }
76415
76416 static void unset_module_init_ro_nx(struct module *mod)
76417 {
76418 - set_page_attributes(mod->module_init + mod->init_text_size,
76419 - mod->module_init + mod->init_size,
76420 + set_page_attributes(mod->module_init_rw,
76421 + mod->module_init_rw + mod->init_size_rw,
76422 set_memory_x);
76423 - set_page_attributes(mod->module_init,
76424 - mod->module_init + mod->init_ro_size,
76425 + set_page_attributes(mod->module_init_rx,
76426 + mod->module_init_rx + mod->init_size_rx,
76427 set_memory_rw);
76428 }
76429
76430 @@ -1805,14 +1807,14 @@ void set_all_modules_text_rw(void)
76431 list_for_each_entry_rcu(mod, &modules, list) {
76432 if (mod->state == MODULE_STATE_UNFORMED)
76433 continue;
76434 - if ((mod->module_core) && (mod->core_text_size)) {
76435 - set_page_attributes(mod->module_core,
76436 - mod->module_core + mod->core_text_size,
76437 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76438 + set_page_attributes(mod->module_core_rx,
76439 + mod->module_core_rx + mod->core_size_rx,
76440 set_memory_rw);
76441 }
76442 - if ((mod->module_init) && (mod->init_text_size)) {
76443 - set_page_attributes(mod->module_init,
76444 - mod->module_init + mod->init_text_size,
76445 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76446 + set_page_attributes(mod->module_init_rx,
76447 + mod->module_init_rx + mod->init_size_rx,
76448 set_memory_rw);
76449 }
76450 }
76451 @@ -1828,14 +1830,14 @@ void set_all_modules_text_ro(void)
76452 list_for_each_entry_rcu(mod, &modules, list) {
76453 if (mod->state == MODULE_STATE_UNFORMED)
76454 continue;
76455 - if ((mod->module_core) && (mod->core_text_size)) {
76456 - set_page_attributes(mod->module_core,
76457 - mod->module_core + mod->core_text_size,
76458 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76459 + set_page_attributes(mod->module_core_rx,
76460 + mod->module_core_rx + mod->core_size_rx,
76461 set_memory_ro);
76462 }
76463 - if ((mod->module_init) && (mod->init_text_size)) {
76464 - set_page_attributes(mod->module_init,
76465 - mod->module_init + mod->init_text_size,
76466 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76467 + set_page_attributes(mod->module_init_rx,
76468 + mod->module_init_rx + mod->init_size_rx,
76469 set_memory_ro);
76470 }
76471 }
76472 @@ -1886,16 +1888,19 @@ static void free_module(struct module *mod)
76473
76474 /* This may be NULL, but that's OK */
76475 unset_module_init_ro_nx(mod);
76476 - module_free(mod, mod->module_init);
76477 + module_free(mod, mod->module_init_rw);
76478 + module_free_exec(mod, mod->module_init_rx);
76479 kfree(mod->args);
76480 percpu_modfree(mod);
76481
76482 /* Free lock-classes: */
76483 - lockdep_free_key_range(mod->module_core, mod->core_size);
76484 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76485 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76486
76487 /* Finally, free the core (containing the module structure) */
76488 unset_module_core_ro_nx(mod);
76489 - module_free(mod, mod->module_core);
76490 + module_free_exec(mod, mod->module_core_rx);
76491 + module_free(mod, mod->module_core_rw);
76492
76493 #ifdef CONFIG_MPU
76494 update_protections(current->mm);
76495 @@ -1965,9 +1970,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76496 int ret = 0;
76497 const struct kernel_symbol *ksym;
76498
76499 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76500 + int is_fs_load = 0;
76501 + int register_filesystem_found = 0;
76502 + char *p;
76503 +
76504 + p = strstr(mod->args, "grsec_modharden_fs");
76505 + if (p) {
76506 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76507 + /* copy \0 as well */
76508 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76509 + is_fs_load = 1;
76510 + }
76511 +#endif
76512 +
76513 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76514 const char *name = info->strtab + sym[i].st_name;
76515
76516 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76517 + /* it's a real shame this will never get ripped and copied
76518 + upstream! ;(
76519 + */
76520 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76521 + register_filesystem_found = 1;
76522 +#endif
76523 +
76524 switch (sym[i].st_shndx) {
76525 case SHN_COMMON:
76526 /* We compiled with -fno-common. These are not
76527 @@ -1988,7 +2015,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76528 ksym = resolve_symbol_wait(mod, info, name);
76529 /* Ok if resolved. */
76530 if (ksym && !IS_ERR(ksym)) {
76531 + pax_open_kernel();
76532 sym[i].st_value = ksym->value;
76533 + pax_close_kernel();
76534 break;
76535 }
76536
76537 @@ -2007,11 +2036,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76538 secbase = (unsigned long)mod_percpu(mod);
76539 else
76540 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76541 + pax_open_kernel();
76542 sym[i].st_value += secbase;
76543 + pax_close_kernel();
76544 break;
76545 }
76546 }
76547
76548 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76549 + if (is_fs_load && !register_filesystem_found) {
76550 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76551 + ret = -EPERM;
76552 + }
76553 +#endif
76554 +
76555 return ret;
76556 }
76557
76558 @@ -2095,22 +2133,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76559 || s->sh_entsize != ~0UL
76560 || strstarts(sname, ".init"))
76561 continue;
76562 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76563 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76564 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76565 + else
76566 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76567 pr_debug("\t%s\n", sname);
76568 }
76569 - switch (m) {
76570 - case 0: /* executable */
76571 - mod->core_size = debug_align(mod->core_size);
76572 - mod->core_text_size = mod->core_size;
76573 - break;
76574 - case 1: /* RO: text and ro-data */
76575 - mod->core_size = debug_align(mod->core_size);
76576 - mod->core_ro_size = mod->core_size;
76577 - break;
76578 - case 3: /* whole core */
76579 - mod->core_size = debug_align(mod->core_size);
76580 - break;
76581 - }
76582 }
76583
76584 pr_debug("Init section allocation order:\n");
76585 @@ -2124,23 +2152,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76586 || s->sh_entsize != ~0UL
76587 || !strstarts(sname, ".init"))
76588 continue;
76589 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76590 - | INIT_OFFSET_MASK);
76591 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76592 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76593 + else
76594 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76595 + s->sh_entsize |= INIT_OFFSET_MASK;
76596 pr_debug("\t%s\n", sname);
76597 }
76598 - switch (m) {
76599 - case 0: /* executable */
76600 - mod->init_size = debug_align(mod->init_size);
76601 - mod->init_text_size = mod->init_size;
76602 - break;
76603 - case 1: /* RO: text and ro-data */
76604 - mod->init_size = debug_align(mod->init_size);
76605 - mod->init_ro_size = mod->init_size;
76606 - break;
76607 - case 3: /* whole init */
76608 - mod->init_size = debug_align(mod->init_size);
76609 - break;
76610 - }
76611 }
76612 }
76613
76614 @@ -2313,7 +2331,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76615
76616 /* Put symbol section at end of init part of module. */
76617 symsect->sh_flags |= SHF_ALLOC;
76618 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76619 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76620 info->index.sym) | INIT_OFFSET_MASK;
76621 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76622
76623 @@ -2330,13 +2348,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76624 }
76625
76626 /* Append room for core symbols at end of core part. */
76627 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76628 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76629 - mod->core_size += strtab_size;
76630 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76631 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76632 + mod->core_size_rx += strtab_size;
76633
76634 /* Put string table section at end of init part of module. */
76635 strsect->sh_flags |= SHF_ALLOC;
76636 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76637 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76638 info->index.str) | INIT_OFFSET_MASK;
76639 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76640 }
76641 @@ -2354,12 +2372,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76642 /* Make sure we get permanent strtab: don't use info->strtab. */
76643 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76644
76645 + pax_open_kernel();
76646 +
76647 /* Set types up while we still have access to sections. */
76648 for (i = 0; i < mod->num_symtab; i++)
76649 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76650
76651 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76652 - mod->core_strtab = s = mod->module_core + info->stroffs;
76653 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76654 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76655 src = mod->symtab;
76656 for (ndst = i = 0; i < mod->num_symtab; i++) {
76657 if (i == 0 ||
76658 @@ -2371,6 +2391,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76659 }
76660 }
76661 mod->core_num_syms = ndst;
76662 +
76663 + pax_close_kernel();
76664 }
76665 #else
76666 static inline void layout_symtab(struct module *mod, struct load_info *info)
76667 @@ -2404,17 +2426,33 @@ void * __weak module_alloc(unsigned long size)
76668 return vmalloc_exec(size);
76669 }
76670
76671 -static void *module_alloc_update_bounds(unsigned long size)
76672 +static void *module_alloc_update_bounds_rw(unsigned long size)
76673 {
76674 void *ret = module_alloc(size);
76675
76676 if (ret) {
76677 mutex_lock(&module_mutex);
76678 /* Update module bounds. */
76679 - if ((unsigned long)ret < module_addr_min)
76680 - module_addr_min = (unsigned long)ret;
76681 - if ((unsigned long)ret + size > module_addr_max)
76682 - module_addr_max = (unsigned long)ret + size;
76683 + if ((unsigned long)ret < module_addr_min_rw)
76684 + module_addr_min_rw = (unsigned long)ret;
76685 + if ((unsigned long)ret + size > module_addr_max_rw)
76686 + module_addr_max_rw = (unsigned long)ret + size;
76687 + mutex_unlock(&module_mutex);
76688 + }
76689 + return ret;
76690 +}
76691 +
76692 +static void *module_alloc_update_bounds_rx(unsigned long size)
76693 +{
76694 + void *ret = module_alloc_exec(size);
76695 +
76696 + if (ret) {
76697 + mutex_lock(&module_mutex);
76698 + /* Update module bounds. */
76699 + if ((unsigned long)ret < module_addr_min_rx)
76700 + module_addr_min_rx = (unsigned long)ret;
76701 + if ((unsigned long)ret + size > module_addr_max_rx)
76702 + module_addr_max_rx = (unsigned long)ret + size;
76703 mutex_unlock(&module_mutex);
76704 }
76705 return ret;
76706 @@ -2690,8 +2728,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76707 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76708 {
76709 const char *modmagic = get_modinfo(info, "vermagic");
76710 + const char *license = get_modinfo(info, "license");
76711 int err;
76712
76713 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76714 + if (!license || !license_is_gpl_compatible(license))
76715 + return -ENOEXEC;
76716 +#endif
76717 +
76718 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76719 modmagic = NULL;
76720
76721 @@ -2717,7 +2761,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76722 }
76723
76724 /* Set up license info based on the info section */
76725 - set_license(mod, get_modinfo(info, "license"));
76726 + set_license(mod, license);
76727
76728 return 0;
76729 }
76730 @@ -2811,7 +2855,7 @@ static int move_module(struct module *mod, struct load_info *info)
76731 void *ptr;
76732
76733 /* Do the allocs. */
76734 - ptr = module_alloc_update_bounds(mod->core_size);
76735 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76736 /*
76737 * The pointer to this block is stored in the module structure
76738 * which is inside the block. Just mark it as not being a
76739 @@ -2821,11 +2865,11 @@ static int move_module(struct module *mod, struct load_info *info)
76740 if (!ptr)
76741 return -ENOMEM;
76742
76743 - memset(ptr, 0, mod->core_size);
76744 - mod->module_core = ptr;
76745 + memset(ptr, 0, mod->core_size_rw);
76746 + mod->module_core_rw = ptr;
76747
76748 - if (mod->init_size) {
76749 - ptr = module_alloc_update_bounds(mod->init_size);
76750 + if (mod->init_size_rw) {
76751 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76752 /*
76753 * The pointer to this block is stored in the module structure
76754 * which is inside the block. This block doesn't need to be
76755 @@ -2834,13 +2878,45 @@ static int move_module(struct module *mod, struct load_info *info)
76756 */
76757 kmemleak_ignore(ptr);
76758 if (!ptr) {
76759 - module_free(mod, mod->module_core);
76760 + module_free(mod, mod->module_core_rw);
76761 return -ENOMEM;
76762 }
76763 - memset(ptr, 0, mod->init_size);
76764 - mod->module_init = ptr;
76765 + memset(ptr, 0, mod->init_size_rw);
76766 + mod->module_init_rw = ptr;
76767 } else
76768 - mod->module_init = NULL;
76769 + mod->module_init_rw = NULL;
76770 +
76771 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76772 + kmemleak_not_leak(ptr);
76773 + if (!ptr) {
76774 + if (mod->module_init_rw)
76775 + module_free(mod, mod->module_init_rw);
76776 + module_free(mod, mod->module_core_rw);
76777 + return -ENOMEM;
76778 + }
76779 +
76780 + pax_open_kernel();
76781 + memset(ptr, 0, mod->core_size_rx);
76782 + pax_close_kernel();
76783 + mod->module_core_rx = ptr;
76784 +
76785 + if (mod->init_size_rx) {
76786 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76787 + kmemleak_ignore(ptr);
76788 + if (!ptr && mod->init_size_rx) {
76789 + module_free_exec(mod, mod->module_core_rx);
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->init_size_rx);
76798 + pax_close_kernel();
76799 + mod->module_init_rx = ptr;
76800 + } else
76801 + mod->module_init_rx = NULL;
76802
76803 /* Transfer each section which specifies SHF_ALLOC */
76804 pr_debug("final section addresses:\n");
76805 @@ -2851,16 +2927,45 @@ static int move_module(struct module *mod, struct load_info *info)
76806 if (!(shdr->sh_flags & SHF_ALLOC))
76807 continue;
76808
76809 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76810 - dest = mod->module_init
76811 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76812 - else
76813 - dest = mod->module_core + shdr->sh_entsize;
76814 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76815 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76816 + dest = mod->module_init_rw
76817 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76818 + else
76819 + dest = mod->module_init_rx
76820 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76821 + } else {
76822 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76823 + dest = mod->module_core_rw + shdr->sh_entsize;
76824 + else
76825 + dest = mod->module_core_rx + shdr->sh_entsize;
76826 + }
76827 +
76828 + if (shdr->sh_type != SHT_NOBITS) {
76829 +
76830 +#ifdef CONFIG_PAX_KERNEXEC
76831 +#ifdef CONFIG_X86_64
76832 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76833 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76834 +#endif
76835 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76836 + pax_open_kernel();
76837 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76838 + pax_close_kernel();
76839 + } else
76840 +#endif
76841
76842 - if (shdr->sh_type != SHT_NOBITS)
76843 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76844 + }
76845 /* Update sh_addr to point to copy in image. */
76846 - shdr->sh_addr = (unsigned long)dest;
76847 +
76848 +#ifdef CONFIG_PAX_KERNEXEC
76849 + if (shdr->sh_flags & SHF_EXECINSTR)
76850 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76851 + else
76852 +#endif
76853 +
76854 + shdr->sh_addr = (unsigned long)dest;
76855 pr_debug("\t0x%lx %s\n",
76856 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76857 }
76858 @@ -2917,12 +3022,12 @@ static void flush_module_icache(const struct module *mod)
76859 * Do it before processing of module parameters, so the module
76860 * can provide parameter accessor functions of its own.
76861 */
76862 - if (mod->module_init)
76863 - flush_icache_range((unsigned long)mod->module_init,
76864 - (unsigned long)mod->module_init
76865 - + mod->init_size);
76866 - flush_icache_range((unsigned long)mod->module_core,
76867 - (unsigned long)mod->module_core + mod->core_size);
76868 + if (mod->module_init_rx)
76869 + flush_icache_range((unsigned long)mod->module_init_rx,
76870 + (unsigned long)mod->module_init_rx
76871 + + mod->init_size_rx);
76872 + flush_icache_range((unsigned long)mod->module_core_rx,
76873 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76874
76875 set_fs(old_fs);
76876 }
76877 @@ -2992,8 +3097,10 @@ out:
76878 static void module_deallocate(struct module *mod, struct load_info *info)
76879 {
76880 percpu_modfree(mod);
76881 - module_free(mod, mod->module_init);
76882 - module_free(mod, mod->module_core);
76883 + module_free_exec(mod, mod->module_init_rx);
76884 + module_free_exec(mod, mod->module_core_rx);
76885 + module_free(mod, mod->module_init_rw);
76886 + module_free(mod, mod->module_core_rw);
76887 }
76888
76889 int __weak module_finalize(const Elf_Ehdr *hdr,
76890 @@ -3006,7 +3113,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76891 static int post_relocation(struct module *mod, const struct load_info *info)
76892 {
76893 /* Sort exception table now relocations are done. */
76894 + pax_open_kernel();
76895 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76896 + pax_close_kernel();
76897
76898 /* Copy relocated percpu area over. */
76899 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76900 @@ -3060,16 +3169,16 @@ static int do_init_module(struct module *mod)
76901 MODULE_STATE_COMING, mod);
76902
76903 /* Set RO and NX regions for core */
76904 - set_section_ro_nx(mod->module_core,
76905 - mod->core_text_size,
76906 - mod->core_ro_size,
76907 - mod->core_size);
76908 + set_section_ro_nx(mod->module_core_rx,
76909 + mod->core_size_rx,
76910 + mod->core_size_rx,
76911 + mod->core_size_rx);
76912
76913 /* Set RO and NX regions for init */
76914 - set_section_ro_nx(mod->module_init,
76915 - mod->init_text_size,
76916 - mod->init_ro_size,
76917 - mod->init_size);
76918 + set_section_ro_nx(mod->module_init_rx,
76919 + mod->init_size_rx,
76920 + mod->init_size_rx,
76921 + mod->init_size_rx);
76922
76923 do_mod_ctors(mod);
76924 /* Start the module */
76925 @@ -3131,11 +3240,12 @@ static int do_init_module(struct module *mod)
76926 mod->strtab = mod->core_strtab;
76927 #endif
76928 unset_module_init_ro_nx(mod);
76929 - module_free(mod, mod->module_init);
76930 - mod->module_init = NULL;
76931 - mod->init_size = 0;
76932 - mod->init_ro_size = 0;
76933 - mod->init_text_size = 0;
76934 + module_free(mod, mod->module_init_rw);
76935 + module_free_exec(mod, mod->module_init_rx);
76936 + mod->module_init_rw = NULL;
76937 + mod->module_init_rx = NULL;
76938 + mod->init_size_rw = 0;
76939 + mod->init_size_rx = 0;
76940 mutex_unlock(&module_mutex);
76941 wake_up_all(&module_wq);
76942
76943 @@ -3262,9 +3372,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
76944 if (err)
76945 goto free_unload;
76946
76947 + /* Now copy in args */
76948 + mod->args = strndup_user(uargs, ~0UL >> 1);
76949 + if (IS_ERR(mod->args)) {
76950 + err = PTR_ERR(mod->args);
76951 + goto free_unload;
76952 + }
76953 +
76954 /* Set up MODINFO_ATTR fields */
76955 setup_modinfo(mod, info);
76956
76957 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76958 + {
76959 + char *p, *p2;
76960 +
76961 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76962 + 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);
76963 + err = -EPERM;
76964 + goto free_modinfo;
76965 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76966 + p += sizeof("grsec_modharden_normal") - 1;
76967 + p2 = strstr(p, "_");
76968 + if (p2) {
76969 + *p2 = '\0';
76970 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76971 + *p2 = '_';
76972 + }
76973 + err = -EPERM;
76974 + goto free_modinfo;
76975 + }
76976 + }
76977 +#endif
76978 +
76979 /* Fix up syms, so that st_value is a pointer to location. */
76980 err = simplify_symbols(mod, info);
76981 if (err < 0)
76982 @@ -3280,13 +3419,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
76983
76984 flush_module_icache(mod);
76985
76986 - /* Now copy in args */
76987 - mod->args = strndup_user(uargs, ~0UL >> 1);
76988 - if (IS_ERR(mod->args)) {
76989 - err = PTR_ERR(mod->args);
76990 - goto free_arch_cleanup;
76991 - }
76992 -
76993 dynamic_debug_setup(info->debug, info->num_debug);
76994
76995 /* Finally it's fully formed, ready to start executing. */
76996 @@ -3321,11 +3453,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
76997 ddebug_cleanup:
76998 dynamic_debug_remove(info->debug);
76999 synchronize_sched();
77000 - kfree(mod->args);
77001 - free_arch_cleanup:
77002 module_arch_cleanup(mod);
77003 free_modinfo:
77004 free_modinfo(mod);
77005 + kfree(mod->args);
77006 free_unload:
77007 module_unload_free(mod);
77008 unlink_mod:
77009 @@ -3408,10 +3539,16 @@ static const char *get_ksymbol(struct module *mod,
77010 unsigned long nextval;
77011
77012 /* At worse, next value is at end of module */
77013 - if (within_module_init(addr, mod))
77014 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
77015 + if (within_module_init_rx(addr, mod))
77016 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
77017 + else if (within_module_init_rw(addr, mod))
77018 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
77019 + else if (within_module_core_rx(addr, mod))
77020 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
77021 + else if (within_module_core_rw(addr, mod))
77022 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
77023 else
77024 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
77025 + return NULL;
77026
77027 /* Scan for closest preceding symbol, and next symbol. (ELF
77028 starts real symbols at 1). */
77029 @@ -3664,7 +3801,7 @@ static int m_show(struct seq_file *m, void *p)
77030 return 0;
77031
77032 seq_printf(m, "%s %u",
77033 - mod->name, mod->init_size + mod->core_size);
77034 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
77035 print_unload_info(m, mod);
77036
77037 /* Informative for users. */
77038 @@ -3673,7 +3810,7 @@ static int m_show(struct seq_file *m, void *p)
77039 mod->state == MODULE_STATE_COMING ? "Loading":
77040 "Live");
77041 /* Used by oprofile and other similar tools. */
77042 - seq_printf(m, " 0x%pK", mod->module_core);
77043 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
77044
77045 /* Taints info */
77046 if (mod->taints)
77047 @@ -3709,7 +3846,17 @@ static const struct file_operations proc_modules_operations = {
77048
77049 static int __init proc_modules_init(void)
77050 {
77051 +#ifndef CONFIG_GRKERNSEC_HIDESYM
77052 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77053 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77054 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77055 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
77056 +#else
77057 proc_create("modules", 0, NULL, &proc_modules_operations);
77058 +#endif
77059 +#else
77060 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77061 +#endif
77062 return 0;
77063 }
77064 module_init(proc_modules_init);
77065 @@ -3770,14 +3917,14 @@ struct module *__module_address(unsigned long addr)
77066 {
77067 struct module *mod;
77068
77069 - if (addr < module_addr_min || addr > module_addr_max)
77070 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
77071 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
77072 return NULL;
77073
77074 list_for_each_entry_rcu(mod, &modules, list) {
77075 if (mod->state == MODULE_STATE_UNFORMED)
77076 continue;
77077 - if (within_module_core(addr, mod)
77078 - || within_module_init(addr, mod))
77079 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
77080 return mod;
77081 }
77082 return NULL;
77083 @@ -3812,11 +3959,20 @@ bool is_module_text_address(unsigned long addr)
77084 */
77085 struct module *__module_text_address(unsigned long addr)
77086 {
77087 - struct module *mod = __module_address(addr);
77088 + struct module *mod;
77089 +
77090 +#ifdef CONFIG_X86_32
77091 + addr = ktla_ktva(addr);
77092 +#endif
77093 +
77094 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
77095 + return NULL;
77096 +
77097 + mod = __module_address(addr);
77098 +
77099 if (mod) {
77100 /* Make sure it's within the text section. */
77101 - if (!within(addr, mod->module_init, mod->init_text_size)
77102 - && !within(addr, mod->module_core, mod->core_text_size))
77103 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
77104 mod = NULL;
77105 }
77106 return mod;
77107 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
77108 index 7e3443f..b2a1e6b 100644
77109 --- a/kernel/mutex-debug.c
77110 +++ b/kernel/mutex-debug.c
77111 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
77112 }
77113
77114 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77115 - struct thread_info *ti)
77116 + struct task_struct *task)
77117 {
77118 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
77119
77120 /* Mark the current thread as blocked on the lock: */
77121 - ti->task->blocked_on = waiter;
77122 + task->blocked_on = waiter;
77123 }
77124
77125 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77126 - struct thread_info *ti)
77127 + struct task_struct *task)
77128 {
77129 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
77130 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
77131 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
77132 - ti->task->blocked_on = NULL;
77133 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
77134 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
77135 + task->blocked_on = NULL;
77136
77137 list_del_init(&waiter->list);
77138 waiter->task = NULL;
77139 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
77140 index 0799fd3..d06ae3b 100644
77141 --- a/kernel/mutex-debug.h
77142 +++ b/kernel/mutex-debug.h
77143 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
77144 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
77145 extern void debug_mutex_add_waiter(struct mutex *lock,
77146 struct mutex_waiter *waiter,
77147 - struct thread_info *ti);
77148 + struct task_struct *task);
77149 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77150 - struct thread_info *ti);
77151 + struct task_struct *task);
77152 extern void debug_mutex_unlock(struct mutex *lock);
77153 extern void debug_mutex_init(struct mutex *lock, const char *name,
77154 struct lock_class_key *key);
77155 diff --git a/kernel/mutex.c b/kernel/mutex.c
77156 index 52f2301..73f7528 100644
77157 --- a/kernel/mutex.c
77158 +++ b/kernel/mutex.c
77159 @@ -199,7 +199,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77160 spin_lock_mutex(&lock->wait_lock, flags);
77161
77162 debug_mutex_lock_common(lock, &waiter);
77163 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
77164 + debug_mutex_add_waiter(lock, &waiter, task);
77165
77166 /* add waiting tasks to the end of the waitqueue (FIFO): */
77167 list_add_tail(&waiter.list, &lock->wait_list);
77168 @@ -228,8 +228,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77169 * TASK_UNINTERRUPTIBLE case.)
77170 */
77171 if (unlikely(signal_pending_state(state, task))) {
77172 - mutex_remove_waiter(lock, &waiter,
77173 - task_thread_info(task));
77174 + mutex_remove_waiter(lock, &waiter, task);
77175 mutex_release(&lock->dep_map, 1, ip);
77176 spin_unlock_mutex(&lock->wait_lock, flags);
77177
77178 @@ -248,7 +247,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77179 done:
77180 lock_acquired(&lock->dep_map, ip);
77181 /* got the lock - rejoice! */
77182 - mutex_remove_waiter(lock, &waiter, current_thread_info());
77183 + mutex_remove_waiter(lock, &waiter, task);
77184 mutex_set_owner(lock);
77185
77186 /* set it to 0 if there are no waiters left: */
77187 diff --git a/kernel/notifier.c b/kernel/notifier.c
77188 index 2d5cc4c..d9ea600 100644
77189 --- a/kernel/notifier.c
77190 +++ b/kernel/notifier.c
77191 @@ -5,6 +5,7 @@
77192 #include <linux/rcupdate.h>
77193 #include <linux/vmalloc.h>
77194 #include <linux/reboot.h>
77195 +#include <linux/mm.h>
77196
77197 /*
77198 * Notifier list for kernel code which wants to be called
77199 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
77200 while ((*nl) != NULL) {
77201 if (n->priority > (*nl)->priority)
77202 break;
77203 - nl = &((*nl)->next);
77204 + nl = (struct notifier_block **)&((*nl)->next);
77205 }
77206 - n->next = *nl;
77207 + pax_open_kernel();
77208 + *(const void **)&n->next = *nl;
77209 rcu_assign_pointer(*nl, n);
77210 + pax_close_kernel();
77211 return 0;
77212 }
77213
77214 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
77215 return 0;
77216 if (n->priority > (*nl)->priority)
77217 break;
77218 - nl = &((*nl)->next);
77219 + nl = (struct notifier_block **)&((*nl)->next);
77220 }
77221 - n->next = *nl;
77222 + pax_open_kernel();
77223 + *(const void **)&n->next = *nl;
77224 rcu_assign_pointer(*nl, n);
77225 + pax_close_kernel();
77226 return 0;
77227 }
77228
77229 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
77230 {
77231 while ((*nl) != NULL) {
77232 if ((*nl) == n) {
77233 + pax_open_kernel();
77234 rcu_assign_pointer(*nl, n->next);
77235 + pax_close_kernel();
77236 return 0;
77237 }
77238 - nl = &((*nl)->next);
77239 + nl = (struct notifier_block **)&((*nl)->next);
77240 }
77241 return -ENOENT;
77242 }
77243 diff --git a/kernel/panic.c b/kernel/panic.c
77244 index 7c57cc9..28f1b3f 100644
77245 --- a/kernel/panic.c
77246 +++ b/kernel/panic.c
77247 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77248 const char *board;
77249
77250 printk(KERN_WARNING "------------[ cut here ]------------\n");
77251 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77252 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77253 board = dmi_get_system_info(DMI_PRODUCT_NAME);
77254 if (board)
77255 printk(KERN_WARNING "Hardware name: %s\n", board);
77256 @@ -459,7 +459,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77257 */
77258 void __stack_chk_fail(void)
77259 {
77260 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77261 + dump_stack();
77262 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77263 __builtin_return_address(0));
77264 }
77265 EXPORT_SYMBOL(__stack_chk_fail);
77266 diff --git a/kernel/pid.c b/kernel/pid.c
77267 index 047dc62..418d74b 100644
77268 --- a/kernel/pid.c
77269 +++ b/kernel/pid.c
77270 @@ -33,6 +33,7 @@
77271 #include <linux/rculist.h>
77272 #include <linux/bootmem.h>
77273 #include <linux/hash.h>
77274 +#include <linux/security.h>
77275 #include <linux/pid_namespace.h>
77276 #include <linux/init_task.h>
77277 #include <linux/syscalls.h>
77278 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77279
77280 int pid_max = PID_MAX_DEFAULT;
77281
77282 -#define RESERVED_PIDS 300
77283 +#define RESERVED_PIDS 500
77284
77285 int pid_max_min = RESERVED_PIDS + 1;
77286 int pid_max_max = PID_MAX_LIMIT;
77287 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
77288 */
77289 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77290 {
77291 + struct task_struct *task;
77292 +
77293 rcu_lockdep_assert(rcu_read_lock_held(),
77294 "find_task_by_pid_ns() needs rcu_read_lock()"
77295 " protection");
77296 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77297 +
77298 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77299 +
77300 + if (gr_pid_is_chrooted(task))
77301 + return NULL;
77302 +
77303 + return task;
77304 }
77305
77306 struct task_struct *find_task_by_vpid(pid_t vnr)
77307 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77308 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77309 }
77310
77311 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77312 +{
77313 + rcu_lockdep_assert(rcu_read_lock_held(),
77314 + "find_task_by_pid_ns() needs rcu_read_lock()"
77315 + " protection");
77316 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77317 +}
77318 +
77319 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77320 {
77321 struct pid *pid;
77322 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77323 index bea15bd..789f3d0 100644
77324 --- a/kernel/pid_namespace.c
77325 +++ b/kernel/pid_namespace.c
77326 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77327 void __user *buffer, size_t *lenp, loff_t *ppos)
77328 {
77329 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77330 - struct ctl_table tmp = *table;
77331 + ctl_table_no_const tmp = *table;
77332
77333 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77334 return -EPERM;
77335 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77336 index 8fd709c..542bf4b 100644
77337 --- a/kernel/posix-cpu-timers.c
77338 +++ b/kernel/posix-cpu-timers.c
77339 @@ -1592,14 +1592,14 @@ struct k_clock clock_posix_cpu = {
77340
77341 static __init int init_posix_cpu_timers(void)
77342 {
77343 - struct k_clock process = {
77344 + static struct k_clock process = {
77345 .clock_getres = process_cpu_clock_getres,
77346 .clock_get = process_cpu_clock_get,
77347 .timer_create = process_cpu_timer_create,
77348 .nsleep = process_cpu_nsleep,
77349 .nsleep_restart = process_cpu_nsleep_restart,
77350 };
77351 - struct k_clock thread = {
77352 + static struct k_clock thread = {
77353 .clock_getres = thread_cpu_clock_getres,
77354 .clock_get = thread_cpu_clock_get,
77355 .timer_create = thread_cpu_timer_create,
77356 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77357 index 6edbb2c..334f085 100644
77358 --- a/kernel/posix-timers.c
77359 +++ b/kernel/posix-timers.c
77360 @@ -43,6 +43,7 @@
77361 #include <linux/idr.h>
77362 #include <linux/posix-clock.h>
77363 #include <linux/posix-timers.h>
77364 +#include <linux/grsecurity.h>
77365 #include <linux/syscalls.h>
77366 #include <linux/wait.h>
77367 #include <linux/workqueue.h>
77368 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77369 * which we beg off on and pass to do_sys_settimeofday().
77370 */
77371
77372 -static struct k_clock posix_clocks[MAX_CLOCKS];
77373 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77374
77375 /*
77376 * These ones are defined below.
77377 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77378 */
77379 static __init int init_posix_timers(void)
77380 {
77381 - struct k_clock clock_realtime = {
77382 + static struct k_clock clock_realtime = {
77383 .clock_getres = hrtimer_get_res,
77384 .clock_get = posix_clock_realtime_get,
77385 .clock_set = posix_clock_realtime_set,
77386 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
77387 .timer_get = common_timer_get,
77388 .timer_del = common_timer_del,
77389 };
77390 - struct k_clock clock_monotonic = {
77391 + static struct k_clock clock_monotonic = {
77392 .clock_getres = hrtimer_get_res,
77393 .clock_get = posix_ktime_get_ts,
77394 .nsleep = common_nsleep,
77395 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77396 .timer_get = common_timer_get,
77397 .timer_del = common_timer_del,
77398 };
77399 - struct k_clock clock_monotonic_raw = {
77400 + static struct k_clock clock_monotonic_raw = {
77401 .clock_getres = hrtimer_get_res,
77402 .clock_get = posix_get_monotonic_raw,
77403 };
77404 - struct k_clock clock_realtime_coarse = {
77405 + static struct k_clock clock_realtime_coarse = {
77406 .clock_getres = posix_get_coarse_res,
77407 .clock_get = posix_get_realtime_coarse,
77408 };
77409 - struct k_clock clock_monotonic_coarse = {
77410 + static struct k_clock clock_monotonic_coarse = {
77411 .clock_getres = posix_get_coarse_res,
77412 .clock_get = posix_get_monotonic_coarse,
77413 };
77414 - struct k_clock clock_boottime = {
77415 + static struct k_clock clock_boottime = {
77416 .clock_getres = hrtimer_get_res,
77417 .clock_get = posix_get_boottime,
77418 .nsleep = common_nsleep,
77419 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77420 return;
77421 }
77422
77423 - posix_clocks[clock_id] = *new_clock;
77424 + posix_clocks[clock_id] = new_clock;
77425 }
77426 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77427
77428 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77429 return (id & CLOCKFD_MASK) == CLOCKFD ?
77430 &clock_posix_dynamic : &clock_posix_cpu;
77431
77432 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77433 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77434 return NULL;
77435 - return &posix_clocks[id];
77436 + return posix_clocks[id];
77437 }
77438
77439 static int common_timer_create(struct k_itimer *new_timer)
77440 @@ -964,6 +965,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77441 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77442 return -EFAULT;
77443
77444 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77445 + have their clock_set fptr set to a nosettime dummy function
77446 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77447 + call common_clock_set, which calls do_sys_settimeofday, which
77448 + we hook
77449 + */
77450 +
77451 return kc->clock_set(which_clock, &new_tp);
77452 }
77453
77454 diff --git a/kernel/power/process.c b/kernel/power/process.c
77455 index 98088e0..aaf95c0 100644
77456 --- a/kernel/power/process.c
77457 +++ b/kernel/power/process.c
77458 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77459 u64 elapsed_csecs64;
77460 unsigned int elapsed_csecs;
77461 bool wakeup = false;
77462 + bool timedout = false;
77463
77464 do_gettimeofday(&start);
77465
77466 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77467
77468 while (true) {
77469 todo = 0;
77470 + if (time_after(jiffies, end_time))
77471 + timedout = true;
77472 read_lock(&tasklist_lock);
77473 do_each_thread(g, p) {
77474 if (p == current || !freeze_task(p))
77475 continue;
77476
77477 - if (!freezer_should_skip(p))
77478 + if (!freezer_should_skip(p)) {
77479 todo++;
77480 + if (timedout) {
77481 + printk(KERN_ERR "Task refusing to freeze:\n");
77482 + sched_show_task(p);
77483 + }
77484 + }
77485 } while_each_thread(g, p);
77486 read_unlock(&tasklist_lock);
77487
77488 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77489 todo += wq_busy;
77490 }
77491
77492 - if (!todo || time_after(jiffies, end_time))
77493 + if (!todo || timedout)
77494 break;
77495
77496 if (pm_wakeup_pending()) {
77497 diff --git a/kernel/printk.c b/kernel/printk.c
77498 index 0e4eba6a..d58ebf0 100644
77499 --- a/kernel/printk.c
77500 +++ b/kernel/printk.c
77501 @@ -395,6 +395,11 @@ static int check_syslog_permissions(int type, bool from_file)
77502 if (from_file && type != SYSLOG_ACTION_OPEN)
77503 return 0;
77504
77505 +#ifdef CONFIG_GRKERNSEC_DMESG
77506 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77507 + return -EPERM;
77508 +#endif
77509 +
77510 if (syslog_action_restricted(type)) {
77511 if (capable(CAP_SYSLOG))
77512 return 0;
77513 diff --git a/kernel/profile.c b/kernel/profile.c
77514 index dc3384e..0de5b49 100644
77515 --- a/kernel/profile.c
77516 +++ b/kernel/profile.c
77517 @@ -37,7 +37,7 @@ struct profile_hit {
77518 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
77519 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
77520
77521 -static atomic_t *prof_buffer;
77522 +static atomic_unchecked_t *prof_buffer;
77523 static unsigned long prof_len, prof_shift;
77524
77525 int prof_on __read_mostly;
77526 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
77527 hits[i].pc = 0;
77528 continue;
77529 }
77530 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77531 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77532 hits[i].hits = hits[i].pc = 0;
77533 }
77534 }
77535 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77536 * Add the current hit(s) and flush the write-queue out
77537 * to the global buffer:
77538 */
77539 - atomic_add(nr_hits, &prof_buffer[pc]);
77540 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77541 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77542 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77543 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77544 hits[i].pc = hits[i].hits = 0;
77545 }
77546 out:
77547 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77548 {
77549 unsigned long pc;
77550 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77551 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77552 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77553 }
77554 #endif /* !CONFIG_SMP */
77555
77556 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77557 return -EFAULT;
77558 buf++; p++; count--; read++;
77559 }
77560 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77561 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77562 if (copy_to_user(buf, (void *)pnt, count))
77563 return -EFAULT;
77564 read += count;
77565 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77566 }
77567 #endif
77568 profile_discard_flip_buffers();
77569 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77570 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77571 return count;
77572 }
77573
77574 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77575 index acbd284..00bb0c9 100644
77576 --- a/kernel/ptrace.c
77577 +++ b/kernel/ptrace.c
77578 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77579 if (seize)
77580 flags |= PT_SEIZED;
77581 rcu_read_lock();
77582 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77583 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77584 flags |= PT_PTRACE_CAP;
77585 rcu_read_unlock();
77586 task->ptrace = flags;
77587 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77588 break;
77589 return -EIO;
77590 }
77591 - if (copy_to_user(dst, buf, retval))
77592 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77593 return -EFAULT;
77594 copied += retval;
77595 src += retval;
77596 @@ -726,7 +726,7 @@ int ptrace_request(struct task_struct *child, long request,
77597 bool seized = child->ptrace & PT_SEIZED;
77598 int ret = -EIO;
77599 siginfo_t siginfo, *si;
77600 - void __user *datavp = (void __user *) data;
77601 + void __user *datavp = (__force void __user *) data;
77602 unsigned long __user *datalp = datavp;
77603 unsigned long flags;
77604
77605 @@ -928,14 +928,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77606 goto out;
77607 }
77608
77609 + if (gr_handle_ptrace(child, request)) {
77610 + ret = -EPERM;
77611 + goto out_put_task_struct;
77612 + }
77613 +
77614 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77615 ret = ptrace_attach(child, request, addr, data);
77616 /*
77617 * Some architectures need to do book-keeping after
77618 * a ptrace attach.
77619 */
77620 - if (!ret)
77621 + if (!ret) {
77622 arch_ptrace_attach(child);
77623 + gr_audit_ptrace(child);
77624 + }
77625 goto out_put_task_struct;
77626 }
77627
77628 @@ -963,7 +970,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77629 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77630 if (copied != sizeof(tmp))
77631 return -EIO;
77632 - return put_user(tmp, (unsigned long __user *)data);
77633 + return put_user(tmp, (__force unsigned long __user *)data);
77634 }
77635
77636 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77637 @@ -1057,7 +1064,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77638 }
77639
77640 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77641 - compat_long_t addr, compat_long_t data)
77642 + compat_ulong_t addr, compat_ulong_t data)
77643 {
77644 struct task_struct *child;
77645 long ret;
77646 @@ -1073,14 +1080,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77647 goto out;
77648 }
77649
77650 + if (gr_handle_ptrace(child, request)) {
77651 + ret = -EPERM;
77652 + goto out_put_task_struct;
77653 + }
77654 +
77655 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77656 ret = ptrace_attach(child, request, addr, data);
77657 /*
77658 * Some architectures need to do book-keeping after
77659 * a ptrace attach.
77660 */
77661 - if (!ret)
77662 + if (!ret) {
77663 arch_ptrace_attach(child);
77664 + gr_audit_ptrace(child);
77665 + }
77666 goto out_put_task_struct;
77667 }
77668
77669 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
77670 index 48ab703..07561d4 100644
77671 --- a/kernel/rcupdate.c
77672 +++ b/kernel/rcupdate.c
77673 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
77674 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77675 */
77676 if (till_stall_check < 3) {
77677 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77678 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77679 till_stall_check = 3;
77680 } else if (till_stall_check > 300) {
77681 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77682 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77683 till_stall_check = 300;
77684 }
77685 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77686 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77687 index a0714a5..2ab5e34 100644
77688 --- a/kernel/rcutiny.c
77689 +++ b/kernel/rcutiny.c
77690 @@ -46,7 +46,7 @@
77691 struct rcu_ctrlblk;
77692 static void invoke_rcu_callbacks(void);
77693 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77694 -static void rcu_process_callbacks(struct softirq_action *unused);
77695 +static void rcu_process_callbacks(void);
77696 static void __call_rcu(struct rcu_head *head,
77697 void (*func)(struct rcu_head *rcu),
77698 struct rcu_ctrlblk *rcp);
77699 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77700 rcu_is_callbacks_kthread()));
77701 }
77702
77703 -static void rcu_process_callbacks(struct softirq_action *unused)
77704 +static void rcu_process_callbacks(void)
77705 {
77706 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77707 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77708 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77709 index 8a23300..4255818 100644
77710 --- a/kernel/rcutiny_plugin.h
77711 +++ b/kernel/rcutiny_plugin.h
77712 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
77713 have_rcu_kthread_work = morework;
77714 local_irq_restore(flags);
77715 if (work)
77716 - rcu_process_callbacks(NULL);
77717 + rcu_process_callbacks();
77718 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77719 }
77720
77721 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77722 index e1f3a8c..42c94a2 100644
77723 --- a/kernel/rcutorture.c
77724 +++ b/kernel/rcutorture.c
77725 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77726 { 0 };
77727 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77728 { 0 };
77729 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77730 -static atomic_t n_rcu_torture_alloc;
77731 -static atomic_t n_rcu_torture_alloc_fail;
77732 -static atomic_t n_rcu_torture_free;
77733 -static atomic_t n_rcu_torture_mberror;
77734 -static atomic_t n_rcu_torture_error;
77735 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77736 +static atomic_unchecked_t n_rcu_torture_alloc;
77737 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77738 +static atomic_unchecked_t n_rcu_torture_free;
77739 +static atomic_unchecked_t n_rcu_torture_mberror;
77740 +static atomic_unchecked_t n_rcu_torture_error;
77741 static long n_rcu_torture_barrier_error;
77742 static long n_rcu_torture_boost_ktrerror;
77743 static long n_rcu_torture_boost_rterror;
77744 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
77745
77746 spin_lock_bh(&rcu_torture_lock);
77747 if (list_empty(&rcu_torture_freelist)) {
77748 - atomic_inc(&n_rcu_torture_alloc_fail);
77749 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77750 spin_unlock_bh(&rcu_torture_lock);
77751 return NULL;
77752 }
77753 - atomic_inc(&n_rcu_torture_alloc);
77754 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77755 p = rcu_torture_freelist.next;
77756 list_del_init(p);
77757 spin_unlock_bh(&rcu_torture_lock);
77758 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
77759 static void
77760 rcu_torture_free(struct rcu_torture *p)
77761 {
77762 - atomic_inc(&n_rcu_torture_free);
77763 + atomic_inc_unchecked(&n_rcu_torture_free);
77764 spin_lock_bh(&rcu_torture_lock);
77765 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77766 spin_unlock_bh(&rcu_torture_lock);
77767 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
77768 i = rp->rtort_pipe_count;
77769 if (i > RCU_TORTURE_PIPE_LEN)
77770 i = RCU_TORTURE_PIPE_LEN;
77771 - atomic_inc(&rcu_torture_wcount[i]);
77772 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77773 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77774 rp->rtort_mbtest = 0;
77775 rcu_torture_free(rp);
77776 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77777 i = rp->rtort_pipe_count;
77778 if (i > RCU_TORTURE_PIPE_LEN)
77779 i = RCU_TORTURE_PIPE_LEN;
77780 - atomic_inc(&rcu_torture_wcount[i]);
77781 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77782 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77783 rp->rtort_mbtest = 0;
77784 list_del(&rp->rtort_free);
77785 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
77786 i = old_rp->rtort_pipe_count;
77787 if (i > RCU_TORTURE_PIPE_LEN)
77788 i = RCU_TORTURE_PIPE_LEN;
77789 - atomic_inc(&rcu_torture_wcount[i]);
77790 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77791 old_rp->rtort_pipe_count++;
77792 cur_ops->deferred_free(old_rp);
77793 }
77794 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
77795 return;
77796 }
77797 if (p->rtort_mbtest == 0)
77798 - atomic_inc(&n_rcu_torture_mberror);
77799 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77800 spin_lock(&rand_lock);
77801 cur_ops->read_delay(&rand);
77802 n_rcu_torture_timers++;
77803 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
77804 continue;
77805 }
77806 if (p->rtort_mbtest == 0)
77807 - atomic_inc(&n_rcu_torture_mberror);
77808 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77809 cur_ops->read_delay(&rand);
77810 preempt_disable();
77811 pipe_count = p->rtort_pipe_count;
77812 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
77813 rcu_torture_current,
77814 rcu_torture_current_version,
77815 list_empty(&rcu_torture_freelist),
77816 - atomic_read(&n_rcu_torture_alloc),
77817 - atomic_read(&n_rcu_torture_alloc_fail),
77818 - atomic_read(&n_rcu_torture_free));
77819 + atomic_read_unchecked(&n_rcu_torture_alloc),
77820 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77821 + atomic_read_unchecked(&n_rcu_torture_free));
77822 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77823 - atomic_read(&n_rcu_torture_mberror),
77824 + atomic_read_unchecked(&n_rcu_torture_mberror),
77825 n_rcu_torture_boost_ktrerror,
77826 n_rcu_torture_boost_rterror);
77827 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77828 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
77829 n_barrier_attempts,
77830 n_rcu_torture_barrier_error);
77831 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77832 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77833 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77834 n_rcu_torture_barrier_error != 0 ||
77835 n_rcu_torture_boost_ktrerror != 0 ||
77836 n_rcu_torture_boost_rterror != 0 ||
77837 n_rcu_torture_boost_failure != 0 ||
77838 i > 1) {
77839 cnt += sprintf(&page[cnt], "!!! ");
77840 - atomic_inc(&n_rcu_torture_error);
77841 + atomic_inc_unchecked(&n_rcu_torture_error);
77842 WARN_ON_ONCE(1);
77843 }
77844 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77845 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
77846 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77847 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77848 cnt += sprintf(&page[cnt], " %d",
77849 - atomic_read(&rcu_torture_wcount[i]));
77850 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77851 }
77852 cnt += sprintf(&page[cnt], "\n");
77853 if (cur_ops->stats)
77854 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
77855
77856 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77857
77858 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77859 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77860 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77861 else if (n_online_successes != n_online_attempts ||
77862 n_offline_successes != n_offline_attempts)
77863 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
77864
77865 rcu_torture_current = NULL;
77866 rcu_torture_current_version = 0;
77867 - atomic_set(&n_rcu_torture_alloc, 0);
77868 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77869 - atomic_set(&n_rcu_torture_free, 0);
77870 - atomic_set(&n_rcu_torture_mberror, 0);
77871 - atomic_set(&n_rcu_torture_error, 0);
77872 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77873 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77874 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77875 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77876 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77877 n_rcu_torture_barrier_error = 0;
77878 n_rcu_torture_boost_ktrerror = 0;
77879 n_rcu_torture_boost_rterror = 0;
77880 n_rcu_torture_boost_failure = 0;
77881 n_rcu_torture_boosts = 0;
77882 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77883 - atomic_set(&rcu_torture_wcount[i], 0);
77884 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77885 for_each_possible_cpu(cpu) {
77886 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77887 per_cpu(rcu_torture_count, cpu)[i] = 0;
77888 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77889 index 5b8ad82..59e1f64 100644
77890 --- a/kernel/rcutree.c
77891 +++ b/kernel/rcutree.c
77892 @@ -353,9 +353,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77893 rcu_prepare_for_idle(smp_processor_id());
77894 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77895 smp_mb__before_atomic_inc(); /* See above. */
77896 - atomic_inc(&rdtp->dynticks);
77897 + atomic_inc_unchecked(&rdtp->dynticks);
77898 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77899 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77900 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77901
77902 /*
77903 * It is illegal to enter an extended quiescent state while
77904 @@ -491,10 +491,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77905 int user)
77906 {
77907 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77908 - atomic_inc(&rdtp->dynticks);
77909 + atomic_inc_unchecked(&rdtp->dynticks);
77910 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77911 smp_mb__after_atomic_inc(); /* See above. */
77912 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77913 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77914 rcu_cleanup_after_idle(smp_processor_id());
77915 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77916 if (!user && !is_idle_task(current)) {
77917 @@ -633,14 +633,14 @@ void rcu_nmi_enter(void)
77918 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77919
77920 if (rdtp->dynticks_nmi_nesting == 0 &&
77921 - (atomic_read(&rdtp->dynticks) & 0x1))
77922 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77923 return;
77924 rdtp->dynticks_nmi_nesting++;
77925 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77926 - atomic_inc(&rdtp->dynticks);
77927 + atomic_inc_unchecked(&rdtp->dynticks);
77928 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77929 smp_mb__after_atomic_inc(); /* See above. */
77930 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77931 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77932 }
77933
77934 /**
77935 @@ -659,9 +659,9 @@ void rcu_nmi_exit(void)
77936 return;
77937 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77938 smp_mb__before_atomic_inc(); /* See above. */
77939 - atomic_inc(&rdtp->dynticks);
77940 + atomic_inc_unchecked(&rdtp->dynticks);
77941 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77942 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77943 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77944 }
77945
77946 /**
77947 @@ -675,7 +675,7 @@ int rcu_is_cpu_idle(void)
77948 int ret;
77949
77950 preempt_disable();
77951 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77952 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77953 preempt_enable();
77954 return ret;
77955 }
77956 @@ -743,7 +743,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
77957 */
77958 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77959 {
77960 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77961 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77962 return (rdp->dynticks_snap & 0x1) == 0;
77963 }
77964
77965 @@ -758,7 +758,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77966 unsigned int curr;
77967 unsigned int snap;
77968
77969 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77970 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77971 snap = (unsigned int)rdp->dynticks_snap;
77972
77973 /*
77974 @@ -1698,7 +1698,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77975 rsp->qlen += rdp->qlen;
77976 rdp->n_cbs_orphaned += rdp->qlen;
77977 rdp->qlen_lazy = 0;
77978 - ACCESS_ONCE(rdp->qlen) = 0;
77979 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77980 }
77981
77982 /*
77983 @@ -1944,7 +1944,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77984 }
77985 smp_mb(); /* List handling before counting for rcu_barrier(). */
77986 rdp->qlen_lazy -= count_lazy;
77987 - ACCESS_ONCE(rdp->qlen) -= count;
77988 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77989 rdp->n_cbs_invoked += count;
77990
77991 /* Reinstate batch limit if we have worked down the excess. */
77992 @@ -2137,7 +2137,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77993 /*
77994 * Do RCU core processing for the current CPU.
77995 */
77996 -static void rcu_process_callbacks(struct softirq_action *unused)
77997 +static void rcu_process_callbacks(void)
77998 {
77999 struct rcu_state *rsp;
78000
78001 @@ -2260,7 +2260,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
78002 local_irq_restore(flags);
78003 return;
78004 }
78005 - ACCESS_ONCE(rdp->qlen)++;
78006 + ACCESS_ONCE_RW(rdp->qlen)++;
78007 if (lazy)
78008 rdp->qlen_lazy++;
78009 else
78010 @@ -2469,11 +2469,11 @@ void synchronize_sched_expedited(void)
78011 * counter wrap on a 32-bit system. Quite a few more CPUs would of
78012 * course be required on a 64-bit system.
78013 */
78014 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
78015 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
78016 (ulong)atomic_long_read(&rsp->expedited_done) +
78017 ULONG_MAX / 8)) {
78018 synchronize_sched();
78019 - atomic_long_inc(&rsp->expedited_wrap);
78020 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
78021 return;
78022 }
78023
78024 @@ -2481,7 +2481,7 @@ void synchronize_sched_expedited(void)
78025 * Take a ticket. Note that atomic_inc_return() implies a
78026 * full memory barrier.
78027 */
78028 - snap = atomic_long_inc_return(&rsp->expedited_start);
78029 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
78030 firstsnap = snap;
78031 get_online_cpus();
78032 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
78033 @@ -2494,14 +2494,14 @@ void synchronize_sched_expedited(void)
78034 synchronize_sched_expedited_cpu_stop,
78035 NULL) == -EAGAIN) {
78036 put_online_cpus();
78037 - atomic_long_inc(&rsp->expedited_tryfail);
78038 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
78039
78040 /* Check to see if someone else did our work for us. */
78041 s = atomic_long_read(&rsp->expedited_done);
78042 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78043 /* ensure test happens before caller kfree */
78044 smp_mb__before_atomic_inc(); /* ^^^ */
78045 - atomic_long_inc(&rsp->expedited_workdone1);
78046 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
78047 return;
78048 }
78049
78050 @@ -2510,7 +2510,7 @@ void synchronize_sched_expedited(void)
78051 udelay(trycount * num_online_cpus());
78052 } else {
78053 wait_rcu_gp(call_rcu_sched);
78054 - atomic_long_inc(&rsp->expedited_normal);
78055 + atomic_long_inc_unchecked(&rsp->expedited_normal);
78056 return;
78057 }
78058
78059 @@ -2519,7 +2519,7 @@ void synchronize_sched_expedited(void)
78060 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78061 /* ensure test happens before caller kfree */
78062 smp_mb__before_atomic_inc(); /* ^^^ */
78063 - atomic_long_inc(&rsp->expedited_workdone2);
78064 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
78065 return;
78066 }
78067
78068 @@ -2531,10 +2531,10 @@ void synchronize_sched_expedited(void)
78069 * period works for us.
78070 */
78071 get_online_cpus();
78072 - snap = atomic_long_read(&rsp->expedited_start);
78073 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
78074 smp_mb(); /* ensure read is before try_stop_cpus(). */
78075 }
78076 - atomic_long_inc(&rsp->expedited_stoppedcpus);
78077 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
78078
78079 /*
78080 * Everyone up to our most recent fetch is covered by our grace
78081 @@ -2543,16 +2543,16 @@ void synchronize_sched_expedited(void)
78082 * than we did already did their update.
78083 */
78084 do {
78085 - atomic_long_inc(&rsp->expedited_done_tries);
78086 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
78087 s = atomic_long_read(&rsp->expedited_done);
78088 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
78089 /* ensure test happens before caller kfree */
78090 smp_mb__before_atomic_inc(); /* ^^^ */
78091 - atomic_long_inc(&rsp->expedited_done_lost);
78092 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
78093 break;
78094 }
78095 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
78096 - atomic_long_inc(&rsp->expedited_done_exit);
78097 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
78098
78099 put_online_cpus();
78100 }
78101 @@ -2726,7 +2726,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78102 * ACCESS_ONCE() to prevent the compiler from speculating
78103 * the increment to precede the early-exit check.
78104 */
78105 - ACCESS_ONCE(rsp->n_barrier_done)++;
78106 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78107 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
78108 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
78109 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
78110 @@ -2776,7 +2776,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78111
78112 /* Increment ->n_barrier_done to prevent duplicate work. */
78113 smp_mb(); /* Keep increment after above mechanism. */
78114 - ACCESS_ONCE(rsp->n_barrier_done)++;
78115 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78116 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
78117 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
78118 smp_mb(); /* Keep increment before caller's subsequent code. */
78119 @@ -2821,10 +2821,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
78120 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
78121 init_callback_list(rdp);
78122 rdp->qlen_lazy = 0;
78123 - ACCESS_ONCE(rdp->qlen) = 0;
78124 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78125 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
78126 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
78127 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
78128 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
78129 rdp->cpu = cpu;
78130 rdp->rsp = rsp;
78131 rcu_boot_init_nocb_percpu_data(rdp);
78132 @@ -2857,8 +2857,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
78133 rdp->blimit = blimit;
78134 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
78135 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
78136 - atomic_set(&rdp->dynticks->dynticks,
78137 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
78138 + atomic_set_unchecked(&rdp->dynticks->dynticks,
78139 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
78140 rcu_prepare_for_idle_init(cpu);
78141 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
78142
78143 @@ -2964,7 +2964,7 @@ static int __init rcu_spawn_gp_kthread(void)
78144 struct task_struct *t;
78145
78146 for_each_rcu_flavor(rsp) {
78147 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
78148 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
78149 BUG_ON(IS_ERR(t));
78150 rnp = rcu_get_root(rsp);
78151 raw_spin_lock_irqsave(&rnp->lock, flags);
78152 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
78153 index c896b50..c357252 100644
78154 --- a/kernel/rcutree.h
78155 +++ b/kernel/rcutree.h
78156 @@ -86,7 +86,7 @@ struct rcu_dynticks {
78157 long long dynticks_nesting; /* Track irq/process nesting level. */
78158 /* Process level is worth LLONG_MAX/2. */
78159 int dynticks_nmi_nesting; /* Track NMI nesting level. */
78160 - atomic_t dynticks; /* Even value for idle, else odd. */
78161 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
78162 #ifdef CONFIG_RCU_FAST_NO_HZ
78163 int dyntick_drain; /* Prepare-for-idle state variable. */
78164 unsigned long dyntick_holdoff;
78165 @@ -416,17 +416,17 @@ struct rcu_state {
78166 /* _rcu_barrier(). */
78167 /* End of fields guarded by barrier_mutex. */
78168
78169 - atomic_long_t expedited_start; /* Starting ticket. */
78170 - atomic_long_t expedited_done; /* Done ticket. */
78171 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
78172 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
78173 - atomic_long_t expedited_workdone1; /* # done by others #1. */
78174 - atomic_long_t expedited_workdone2; /* # done by others #2. */
78175 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
78176 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
78177 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
78178 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
78179 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
78180 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
78181 + atomic_long_t expedited_done; /* Done ticket. */
78182 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
78183 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
78184 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
78185 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
78186 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
78187 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
78188 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
78189 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
78190 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
78191
78192 unsigned long jiffies_force_qs; /* Time at which to invoke */
78193 /* force_quiescent_state(). */
78194 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
78195 index c1cc7e1..f62e436 100644
78196 --- a/kernel/rcutree_plugin.h
78197 +++ b/kernel/rcutree_plugin.h
78198 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
78199
78200 /* Clean up and exit. */
78201 smp_mb(); /* ensure expedited GP seen before counter increment. */
78202 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
78203 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
78204 unlock_mb_ret:
78205 mutex_unlock(&sync_rcu_preempt_exp_mutex);
78206 mb_ret:
78207 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
78208 free_cpumask_var(cm);
78209 }
78210
78211 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
78212 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
78213 .store = &rcu_cpu_kthread_task,
78214 .thread_should_run = rcu_cpu_kthread_should_run,
78215 .thread_fn = rcu_cpu_kthread,
78216 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
78217 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
78218 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
78219 cpu, ticks_value, ticks_title,
78220 - atomic_read(&rdtp->dynticks) & 0xfff,
78221 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
78222 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
78223 fast_no_hz);
78224 }
78225 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
78226
78227 /* Enqueue the callback on the nocb list and update counts. */
78228 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78229 - ACCESS_ONCE(*old_rhpp) = rhp;
78230 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78231 atomic_long_add(rhcount, &rdp->nocb_q_count);
78232 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78233
78234 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
78235 * Extract queued callbacks, update counts, and wait
78236 * for a grace period to elapse.
78237 */
78238 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78239 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78240 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78241 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78242 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78243 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78244 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78245 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78246 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78247 wait_rcu_gp(rdp->rsp->call_remote);
78248
78249 /* Each pass through the following loop invokes a callback. */
78250 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
78251 list = next;
78252 }
78253 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78254 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78255 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78256 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78257 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78258 rdp->n_nocbs_invoked += c;
78259 }
78260 return 0;
78261 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78262 rdp = per_cpu_ptr(rsp->rda, cpu);
78263 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
78264 BUG_ON(IS_ERR(t));
78265 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78266 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78267 }
78268 }
78269
78270 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78271 index 93f8e8f..cf812ae 100644
78272 --- a/kernel/rcutree_trace.c
78273 +++ b/kernel/rcutree_trace.c
78274 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78275 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78276 rdp->passed_quiesce, rdp->qs_pending);
78277 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78278 - atomic_read(&rdp->dynticks->dynticks),
78279 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78280 rdp->dynticks->dynticks_nesting,
78281 rdp->dynticks->dynticks_nmi_nesting,
78282 rdp->dynticks_fqs);
78283 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78284 struct rcu_state *rsp = (struct rcu_state *)m->private;
78285
78286 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",
78287 - atomic_long_read(&rsp->expedited_start),
78288 + atomic_long_read_unchecked(&rsp->expedited_start),
78289 atomic_long_read(&rsp->expedited_done),
78290 - atomic_long_read(&rsp->expedited_wrap),
78291 - atomic_long_read(&rsp->expedited_tryfail),
78292 - atomic_long_read(&rsp->expedited_workdone1),
78293 - atomic_long_read(&rsp->expedited_workdone2),
78294 - atomic_long_read(&rsp->expedited_normal),
78295 - atomic_long_read(&rsp->expedited_stoppedcpus),
78296 - atomic_long_read(&rsp->expedited_done_tries),
78297 - atomic_long_read(&rsp->expedited_done_lost),
78298 - atomic_long_read(&rsp->expedited_done_exit));
78299 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78300 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78301 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78302 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78303 + atomic_long_read_unchecked(&rsp->expedited_normal),
78304 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78305 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78306 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78307 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78308 return 0;
78309 }
78310
78311 diff --git a/kernel/resource.c b/kernel/resource.c
78312 index 73f35d4..4684fc4 100644
78313 --- a/kernel/resource.c
78314 +++ b/kernel/resource.c
78315 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78316
78317 static int __init ioresources_init(void)
78318 {
78319 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78320 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78321 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78322 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78323 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78324 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78325 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78326 +#endif
78327 +#else
78328 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78329 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78330 +#endif
78331 return 0;
78332 }
78333 __initcall(ioresources_init);
78334 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78335 index 7890b10..8b68605f 100644
78336 --- a/kernel/rtmutex-tester.c
78337 +++ b/kernel/rtmutex-tester.c
78338 @@ -21,7 +21,7 @@
78339 #define MAX_RT_TEST_MUTEXES 8
78340
78341 static spinlock_t rttest_lock;
78342 -static atomic_t rttest_event;
78343 +static atomic_unchecked_t rttest_event;
78344
78345 struct test_thread_data {
78346 int opcode;
78347 @@ -62,7 +62,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78348
78349 case RTTEST_LOCKCONT:
78350 td->mutexes[td->opdata] = 1;
78351 - td->event = atomic_add_return(1, &rttest_event);
78352 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78353 return 0;
78354
78355 case RTTEST_RESET:
78356 @@ -75,7 +75,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78357 return 0;
78358
78359 case RTTEST_RESETEVENT:
78360 - atomic_set(&rttest_event, 0);
78361 + atomic_set_unchecked(&rttest_event, 0);
78362 return 0;
78363
78364 default:
78365 @@ -92,9 +92,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78366 return ret;
78367
78368 td->mutexes[id] = 1;
78369 - td->event = atomic_add_return(1, &rttest_event);
78370 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78371 rt_mutex_lock(&mutexes[id]);
78372 - td->event = atomic_add_return(1, &rttest_event);
78373 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78374 td->mutexes[id] = 4;
78375 return 0;
78376
78377 @@ -105,9 +105,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78378 return ret;
78379
78380 td->mutexes[id] = 1;
78381 - td->event = atomic_add_return(1, &rttest_event);
78382 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78383 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78384 - td->event = atomic_add_return(1, &rttest_event);
78385 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78386 td->mutexes[id] = ret ? 0 : 4;
78387 return ret ? -EINTR : 0;
78388
78389 @@ -116,9 +116,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78390 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78391 return ret;
78392
78393 - td->event = atomic_add_return(1, &rttest_event);
78394 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78395 rt_mutex_unlock(&mutexes[id]);
78396 - td->event = atomic_add_return(1, &rttest_event);
78397 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78398 td->mutexes[id] = 0;
78399 return 0;
78400
78401 @@ -165,7 +165,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78402 break;
78403
78404 td->mutexes[dat] = 2;
78405 - td->event = atomic_add_return(1, &rttest_event);
78406 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78407 break;
78408
78409 default:
78410 @@ -185,7 +185,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78411 return;
78412
78413 td->mutexes[dat] = 3;
78414 - td->event = atomic_add_return(1, &rttest_event);
78415 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78416 break;
78417
78418 case RTTEST_LOCKNOWAIT:
78419 @@ -197,7 +197,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78420 return;
78421
78422 td->mutexes[dat] = 1;
78423 - td->event = atomic_add_return(1, &rttest_event);
78424 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78425 return;
78426
78427 default:
78428 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78429 index 64de5f8..7735e12 100644
78430 --- a/kernel/sched/auto_group.c
78431 +++ b/kernel/sched/auto_group.c
78432 @@ -11,7 +11,7 @@
78433
78434 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78435 static struct autogroup autogroup_default;
78436 -static atomic_t autogroup_seq_nr;
78437 +static atomic_unchecked_t autogroup_seq_nr;
78438
78439 void __init autogroup_init(struct task_struct *init_task)
78440 {
78441 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
78442
78443 kref_init(&ag->kref);
78444 init_rwsem(&ag->lock);
78445 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78446 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78447 ag->tg = tg;
78448 #ifdef CONFIG_RT_GROUP_SCHED
78449 /*
78450 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78451 index 67d0465..4cf9361 100644
78452 --- a/kernel/sched/core.c
78453 +++ b/kernel/sched/core.c
78454 @@ -3406,7 +3406,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78455 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78456 * positive (at least 1, or number of jiffies left till timeout) if completed.
78457 */
78458 -long __sched
78459 +long __sched __intentional_overflow(-1)
78460 wait_for_completion_interruptible_timeout(struct completion *x,
78461 unsigned long timeout)
78462 {
78463 @@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78464 *
78465 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78466 */
78467 -int __sched wait_for_completion_killable(struct completion *x)
78468 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78469 {
78470 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78471 if (t == -ERESTARTSYS)
78472 @@ -3444,7 +3444,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78473 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78474 * positive (at least 1, or number of jiffies left till timeout) if completed.
78475 */
78476 -long __sched
78477 +long __sched __intentional_overflow(-1)
78478 wait_for_completion_killable_timeout(struct completion *x,
78479 unsigned long timeout)
78480 {
78481 @@ -3670,6 +3670,8 @@ int can_nice(const struct task_struct *p, const int nice)
78482 /* convert nice value [19,-20] to rlimit style value [1,40] */
78483 int nice_rlim = 20 - nice;
78484
78485 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78486 +
78487 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78488 capable(CAP_SYS_NICE));
78489 }
78490 @@ -3703,7 +3705,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78491 if (nice > 19)
78492 nice = 19;
78493
78494 - if (increment < 0 && !can_nice(current, nice))
78495 + if (increment < 0 && (!can_nice(current, nice) ||
78496 + gr_handle_chroot_nice()))
78497 return -EPERM;
78498
78499 retval = security_task_setnice(current, nice);
78500 @@ -3857,6 +3860,7 @@ recheck:
78501 unsigned long rlim_rtprio =
78502 task_rlimit(p, RLIMIT_RTPRIO);
78503
78504 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78505 /* can't set/change the rt policy */
78506 if (policy != p->policy && !rlim_rtprio)
78507 return -EPERM;
78508 @@ -4954,7 +4958,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78509
78510 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78511
78512 -static struct ctl_table sd_ctl_dir[] = {
78513 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78514 {
78515 .procname = "sched_domain",
78516 .mode = 0555,
78517 @@ -4971,17 +4975,17 @@ static struct ctl_table sd_ctl_root[] = {
78518 {}
78519 };
78520
78521 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78522 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78523 {
78524 - struct ctl_table *entry =
78525 + ctl_table_no_const *entry =
78526 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78527
78528 return entry;
78529 }
78530
78531 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78532 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78533 {
78534 - struct ctl_table *entry;
78535 + ctl_table_no_const *entry;
78536
78537 /*
78538 * In the intermediate directories, both the child directory and
78539 @@ -4989,22 +4993,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78540 * will always be set. In the lowest directory the names are
78541 * static strings and all have proc handlers.
78542 */
78543 - for (entry = *tablep; entry->mode; entry++) {
78544 - if (entry->child)
78545 - sd_free_ctl_entry(&entry->child);
78546 + for (entry = tablep; entry->mode; entry++) {
78547 + if (entry->child) {
78548 + sd_free_ctl_entry(entry->child);
78549 + pax_open_kernel();
78550 + entry->child = NULL;
78551 + pax_close_kernel();
78552 + }
78553 if (entry->proc_handler == NULL)
78554 kfree(entry->procname);
78555 }
78556
78557 - kfree(*tablep);
78558 - *tablep = NULL;
78559 + kfree(tablep);
78560 }
78561
78562 static int min_load_idx = 0;
78563 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78564
78565 static void
78566 -set_table_entry(struct ctl_table *entry,
78567 +set_table_entry(ctl_table_no_const *entry,
78568 const char *procname, void *data, int maxlen,
78569 umode_t mode, proc_handler *proc_handler,
78570 bool load_idx)
78571 @@ -5024,7 +5031,7 @@ set_table_entry(struct ctl_table *entry,
78572 static struct ctl_table *
78573 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78574 {
78575 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78576 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78577
78578 if (table == NULL)
78579 return NULL;
78580 @@ -5059,9 +5066,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78581 return table;
78582 }
78583
78584 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78585 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78586 {
78587 - struct ctl_table *entry, *table;
78588 + ctl_table_no_const *entry, *table;
78589 struct sched_domain *sd;
78590 int domain_num = 0, i;
78591 char buf[32];
78592 @@ -5088,11 +5095,13 @@ static struct ctl_table_header *sd_sysctl_header;
78593 static void register_sched_domain_sysctl(void)
78594 {
78595 int i, cpu_num = num_possible_cpus();
78596 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78597 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78598 char buf[32];
78599
78600 WARN_ON(sd_ctl_dir[0].child);
78601 + pax_open_kernel();
78602 sd_ctl_dir[0].child = entry;
78603 + pax_close_kernel();
78604
78605 if (entry == NULL)
78606 return;
78607 @@ -5115,8 +5124,12 @@ static void unregister_sched_domain_sysctl(void)
78608 if (sd_sysctl_header)
78609 unregister_sysctl_table(sd_sysctl_header);
78610 sd_sysctl_header = NULL;
78611 - if (sd_ctl_dir[0].child)
78612 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78613 + if (sd_ctl_dir[0].child) {
78614 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78615 + pax_open_kernel();
78616 + sd_ctl_dir[0].child = NULL;
78617 + pax_close_kernel();
78618 + }
78619 }
78620 #else
78621 static void register_sched_domain_sysctl(void)
78622 @@ -5215,7 +5228,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78623 * happens before everything else. This has to be lower priority than
78624 * the notifier in the perf_event subsystem, though.
78625 */
78626 -static struct notifier_block __cpuinitdata migration_notifier = {
78627 +static struct notifier_block migration_notifier = {
78628 .notifier_call = migration_call,
78629 .priority = CPU_PRI_MIGRATION,
78630 };
78631 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78632 index 7a33e59..2f7730c 100644
78633 --- a/kernel/sched/fair.c
78634 +++ b/kernel/sched/fair.c
78635 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78636
78637 static void reset_ptenuma_scan(struct task_struct *p)
78638 {
78639 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78640 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78641 p->mm->numa_scan_offset = 0;
78642 }
78643
78644 @@ -5654,7 +5654,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78645 * run_rebalance_domains is triggered when needed from the scheduler tick.
78646 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78647 */
78648 -static void run_rebalance_domains(struct softirq_action *h)
78649 +static void run_rebalance_domains(void)
78650 {
78651 int this_cpu = smp_processor_id();
78652 struct rq *this_rq = cpu_rq(this_cpu);
78653 diff --git a/kernel/signal.c b/kernel/signal.c
78654 index 598dc06..471310a 100644
78655 --- a/kernel/signal.c
78656 +++ b/kernel/signal.c
78657 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78658
78659 int print_fatal_signals __read_mostly;
78660
78661 -static void __user *sig_handler(struct task_struct *t, int sig)
78662 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78663 {
78664 return t->sighand->action[sig - 1].sa.sa_handler;
78665 }
78666
78667 -static int sig_handler_ignored(void __user *handler, int sig)
78668 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78669 {
78670 /* Is it explicitly or implicitly ignored? */
78671 return handler == SIG_IGN ||
78672 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78673
78674 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78675 {
78676 - void __user *handler;
78677 + __sighandler_t handler;
78678
78679 handler = sig_handler(t, sig);
78680
78681 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78682 atomic_inc(&user->sigpending);
78683 rcu_read_unlock();
78684
78685 + if (!override_rlimit)
78686 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78687 +
78688 if (override_rlimit ||
78689 atomic_read(&user->sigpending) <=
78690 task_rlimit(t, RLIMIT_SIGPENDING)) {
78691 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78692
78693 int unhandled_signal(struct task_struct *tsk, int sig)
78694 {
78695 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78696 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78697 if (is_global_init(tsk))
78698 return 1;
78699 if (handler != SIG_IGN && handler != SIG_DFL)
78700 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78701 }
78702 }
78703
78704 + /* allow glibc communication via tgkill to other threads in our
78705 + thread group */
78706 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78707 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78708 + && gr_handle_signal(t, sig))
78709 + return -EPERM;
78710 +
78711 return security_task_kill(t, info, sig, 0);
78712 }
78713
78714 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78715 return send_signal(sig, info, p, 1);
78716 }
78717
78718 -static int
78719 +int
78720 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78721 {
78722 return send_signal(sig, info, t, 0);
78723 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78724 unsigned long int flags;
78725 int ret, blocked, ignored;
78726 struct k_sigaction *action;
78727 + int is_unhandled = 0;
78728
78729 spin_lock_irqsave(&t->sighand->siglock, flags);
78730 action = &t->sighand->action[sig-1];
78731 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78732 }
78733 if (action->sa.sa_handler == SIG_DFL)
78734 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78735 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78736 + is_unhandled = 1;
78737 ret = specific_send_sig_info(sig, info, t);
78738 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78739
78740 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78741 + normal operation */
78742 + if (is_unhandled) {
78743 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78744 + gr_handle_crash(t, sig);
78745 + }
78746 +
78747 return ret;
78748 }
78749
78750 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78751 ret = check_kill_permission(sig, info, p);
78752 rcu_read_unlock();
78753
78754 - if (!ret && sig)
78755 + if (!ret && sig) {
78756 ret = do_send_sig_info(sig, info, p, true);
78757 + if (!ret)
78758 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78759 + }
78760
78761 return ret;
78762 }
78763 @@ -2923,7 +2946,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78764 int error = -ESRCH;
78765
78766 rcu_read_lock();
78767 - p = find_task_by_vpid(pid);
78768 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78769 + /* allow glibc communication via tgkill to other threads in our
78770 + thread group */
78771 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78772 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78773 + p = find_task_by_vpid_unrestricted(pid);
78774 + else
78775 +#endif
78776 + p = find_task_by_vpid(pid);
78777 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78778 error = check_kill_permission(sig, info, p);
78779 /*
78780 @@ -3237,8 +3268,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78781 }
78782 seg = get_fs();
78783 set_fs(KERNEL_DS);
78784 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78785 - (stack_t __force __user *) &uoss,
78786 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78787 + (stack_t __force_user *) &uoss,
78788 compat_user_stack_pointer());
78789 set_fs(seg);
78790 if (ret >= 0 && uoss_ptr) {
78791 diff --git a/kernel/smp.c b/kernel/smp.c
78792 index 8e451f3..8322029 100644
78793 --- a/kernel/smp.c
78794 +++ b/kernel/smp.c
78795 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78796 return NOTIFY_OK;
78797 }
78798
78799 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78800 +static struct notifier_block hotplug_cfd_notifier = {
78801 .notifier_call = hotplug_cfd,
78802 };
78803
78804 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78805 index 02fc5c9..e54c335 100644
78806 --- a/kernel/smpboot.c
78807 +++ b/kernel/smpboot.c
78808 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78809 }
78810 smpboot_unpark_thread(plug_thread, cpu);
78811 }
78812 - list_add(&plug_thread->list, &hotplug_threads);
78813 + pax_list_add(&plug_thread->list, &hotplug_threads);
78814 out:
78815 mutex_unlock(&smpboot_threads_lock);
78816 return ret;
78817 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78818 {
78819 get_online_cpus();
78820 mutex_lock(&smpboot_threads_lock);
78821 - list_del(&plug_thread->list);
78822 + pax_list_del(&plug_thread->list);
78823 smpboot_destroy_threads(plug_thread);
78824 mutex_unlock(&smpboot_threads_lock);
78825 put_online_cpus();
78826 diff --git a/kernel/softirq.c b/kernel/softirq.c
78827 index d93dcb1..1cd8a71 100644
78828 --- a/kernel/softirq.c
78829 +++ b/kernel/softirq.c
78830 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78831 EXPORT_SYMBOL(irq_stat);
78832 #endif
78833
78834 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78835 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78836
78837 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78838
78839 -char *softirq_to_name[NR_SOFTIRQS] = {
78840 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78841 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78842 "TASKLET", "SCHED", "HRTIMER", "RCU"
78843 };
78844 @@ -250,7 +250,7 @@ restart:
78845 kstat_incr_softirqs_this_cpu(vec_nr);
78846
78847 trace_softirq_entry(vec_nr);
78848 - h->action(h);
78849 + h->action();
78850 trace_softirq_exit(vec_nr);
78851 if (unlikely(prev_count != preempt_count())) {
78852 printk(KERN_ERR "huh, entered softirq %u %s %p"
78853 @@ -396,7 +396,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78854 or_softirq_pending(1UL << nr);
78855 }
78856
78857 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78858 +void __init open_softirq(int nr, void (*action)(void))
78859 {
78860 softirq_vec[nr].action = action;
78861 }
78862 @@ -452,7 +452,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78863
78864 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78865
78866 -static void tasklet_action(struct softirq_action *a)
78867 +static void tasklet_action(void)
78868 {
78869 struct tasklet_struct *list;
78870
78871 @@ -487,7 +487,7 @@ static void tasklet_action(struct softirq_action *a)
78872 }
78873 }
78874
78875 -static void tasklet_hi_action(struct softirq_action *a)
78876 +static void tasklet_hi_action(void)
78877 {
78878 struct tasklet_struct *list;
78879
78880 @@ -723,7 +723,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78881 return NOTIFY_OK;
78882 }
78883
78884 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78885 +static struct notifier_block remote_softirq_cpu_notifier = {
78886 .notifier_call = remote_softirq_cpu_notify,
78887 };
78888
78889 @@ -840,11 +840,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78890 return NOTIFY_OK;
78891 }
78892
78893 -static struct notifier_block __cpuinitdata cpu_nfb = {
78894 +static struct notifier_block cpu_nfb = {
78895 .notifier_call = cpu_callback
78896 };
78897
78898 -static struct smp_hotplug_thread softirq_threads = {
78899 +static struct smp_hotplug_thread softirq_threads __read_only = {
78900 .store = &ksoftirqd,
78901 .thread_should_run = ksoftirqd_should_run,
78902 .thread_fn = run_ksoftirqd,
78903 diff --git a/kernel/srcu.c b/kernel/srcu.c
78904 index 01d5ccb..cdcbee6 100644
78905 --- a/kernel/srcu.c
78906 +++ b/kernel/srcu.c
78907 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78908
78909 idx = ACCESS_ONCE(sp->completed) & 0x1;
78910 preempt_disable();
78911 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78912 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78913 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78914 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78915 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78916 preempt_enable();
78917 return idx;
78918 }
78919 diff --git a/kernel/sys.c b/kernel/sys.c
78920 index e5f0aca..8d58b1f 100644
78921 --- a/kernel/sys.c
78922 +++ b/kernel/sys.c
78923 @@ -158,6 +158,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78924 error = -EACCES;
78925 goto out;
78926 }
78927 +
78928 + if (gr_handle_chroot_setpriority(p, niceval)) {
78929 + error = -EACCES;
78930 + goto out;
78931 + }
78932 +
78933 no_nice = security_task_setnice(p, niceval);
78934 if (no_nice) {
78935 error = no_nice;
78936 @@ -621,6 +627,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78937 goto error;
78938 }
78939
78940 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78941 + goto error;
78942 +
78943 if (rgid != (gid_t) -1 ||
78944 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78945 new->sgid = new->egid;
78946 @@ -656,6 +665,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78947 old = current_cred();
78948
78949 retval = -EPERM;
78950 +
78951 + if (gr_check_group_change(kgid, kgid, kgid))
78952 + goto error;
78953 +
78954 if (nsown_capable(CAP_SETGID))
78955 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78956 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78957 @@ -673,7 +686,7 @@ error:
78958 /*
78959 * change the user struct in a credentials set to match the new UID
78960 */
78961 -static int set_user(struct cred *new)
78962 +int set_user(struct cred *new)
78963 {
78964 struct user_struct *new_user;
78965
78966 @@ -753,6 +766,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78967 goto error;
78968 }
78969
78970 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78971 + goto error;
78972 +
78973 if (!uid_eq(new->uid, old->uid)) {
78974 retval = set_user(new);
78975 if (retval < 0)
78976 @@ -803,6 +819,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78977 old = current_cred();
78978
78979 retval = -EPERM;
78980 +
78981 + if (gr_check_crash_uid(kuid))
78982 + goto error;
78983 + if (gr_check_user_change(kuid, kuid, kuid))
78984 + goto error;
78985 +
78986 if (nsown_capable(CAP_SETUID)) {
78987 new->suid = new->uid = kuid;
78988 if (!uid_eq(kuid, old->uid)) {
78989 @@ -872,6 +894,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78990 goto error;
78991 }
78992
78993 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78994 + goto error;
78995 +
78996 if (ruid != (uid_t) -1) {
78997 new->uid = kruid;
78998 if (!uid_eq(kruid, old->uid)) {
78999 @@ -954,6 +979,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
79000 goto error;
79001 }
79002
79003 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
79004 + goto error;
79005 +
79006 if (rgid != (gid_t) -1)
79007 new->gid = krgid;
79008 if (egid != (gid_t) -1)
79009 @@ -1015,12 +1043,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
79010 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
79011 nsown_capable(CAP_SETUID)) {
79012 if (!uid_eq(kuid, old->fsuid)) {
79013 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
79014 + goto error;
79015 +
79016 new->fsuid = kuid;
79017 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
79018 goto change_okay;
79019 }
79020 }
79021
79022 +error:
79023 abort_creds(new);
79024 return old_fsuid;
79025
79026 @@ -1053,12 +1085,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
79027 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
79028 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
79029 nsown_capable(CAP_SETGID)) {
79030 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
79031 + goto error;
79032 +
79033 if (!gid_eq(kgid, old->fsgid)) {
79034 new->fsgid = kgid;
79035 goto change_okay;
79036 }
79037 }
79038
79039 +error:
79040 abort_creds(new);
79041 return old_fsgid;
79042
79043 @@ -1366,19 +1402,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
79044 return -EFAULT;
79045
79046 down_read(&uts_sem);
79047 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
79048 + error = __copy_to_user(name->sysname, &utsname()->sysname,
79049 __OLD_UTS_LEN);
79050 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
79051 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
79052 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
79053 __OLD_UTS_LEN);
79054 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
79055 - error |= __copy_to_user(&name->release, &utsname()->release,
79056 + error |= __copy_to_user(name->release, &utsname()->release,
79057 __OLD_UTS_LEN);
79058 error |= __put_user(0, name->release + __OLD_UTS_LEN);
79059 - error |= __copy_to_user(&name->version, &utsname()->version,
79060 + error |= __copy_to_user(name->version, &utsname()->version,
79061 __OLD_UTS_LEN);
79062 error |= __put_user(0, name->version + __OLD_UTS_LEN);
79063 - error |= __copy_to_user(&name->machine, &utsname()->machine,
79064 + error |= __copy_to_user(name->machine, &utsname()->machine,
79065 __OLD_UTS_LEN);
79066 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
79067 up_read(&uts_sem);
79068 @@ -1580,6 +1616,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
79069 */
79070 new_rlim->rlim_cur = 1;
79071 }
79072 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
79073 + is changed to a lower value. Since tasks can be created by the same
79074 + user in between this limit change and an execve by this task, force
79075 + a recheck only for this task by setting PF_NPROC_EXCEEDED
79076 + */
79077 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
79078 + tsk->flags |= PF_NPROC_EXCEEDED;
79079 }
79080 if (!retval) {
79081 if (old_rlim)
79082 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
79083 index afc1dc6..f6cf355 100644
79084 --- a/kernel/sysctl.c
79085 +++ b/kernel/sysctl.c
79086 @@ -93,7 +93,6 @@
79087
79088
79089 #if defined(CONFIG_SYSCTL)
79090 -
79091 /* External variables not in a header file. */
79092 extern int sysctl_overcommit_memory;
79093 extern int sysctl_overcommit_ratio;
79094 @@ -120,18 +119,18 @@ extern int blk_iopoll_enabled;
79095
79096 /* Constants used for minimum and maximum */
79097 #ifdef CONFIG_LOCKUP_DETECTOR
79098 -static int sixty = 60;
79099 -static int neg_one = -1;
79100 +static int sixty __read_only = 60;
79101 #endif
79102
79103 -static int zero;
79104 -static int __maybe_unused one = 1;
79105 -static int __maybe_unused two = 2;
79106 -static int __maybe_unused three = 3;
79107 -static unsigned long one_ul = 1;
79108 -static int one_hundred = 100;
79109 +static int neg_one __read_only = -1;
79110 +static int zero __read_only = 0;
79111 +static int __maybe_unused one __read_only = 1;
79112 +static int __maybe_unused two __read_only = 2;
79113 +static int __maybe_unused three __read_only = 3;
79114 +static unsigned long one_ul __read_only = 1;
79115 +static int one_hundred __read_only = 100;
79116 #ifdef CONFIG_PRINTK
79117 -static int ten_thousand = 10000;
79118 +static int ten_thousand __read_only = 10000;
79119 #endif
79120
79121 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
79122 @@ -178,10 +177,8 @@ static int proc_taint(struct ctl_table *table, int write,
79123 void __user *buffer, size_t *lenp, loff_t *ppos);
79124 #endif
79125
79126 -#ifdef CONFIG_PRINTK
79127 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79128 void __user *buffer, size_t *lenp, loff_t *ppos);
79129 -#endif
79130
79131 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
79132 void __user *buffer, size_t *lenp, loff_t *ppos);
79133 @@ -212,6 +209,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
79134
79135 #endif
79136
79137 +extern struct ctl_table grsecurity_table[];
79138 +
79139 static struct ctl_table kern_table[];
79140 static struct ctl_table vm_table[];
79141 static struct ctl_table fs_table[];
79142 @@ -226,6 +225,20 @@ extern struct ctl_table epoll_table[];
79143 int sysctl_legacy_va_layout;
79144 #endif
79145
79146 +#ifdef CONFIG_PAX_SOFTMODE
79147 +static ctl_table pax_table[] = {
79148 + {
79149 + .procname = "softmode",
79150 + .data = &pax_softmode,
79151 + .maxlen = sizeof(unsigned int),
79152 + .mode = 0600,
79153 + .proc_handler = &proc_dointvec,
79154 + },
79155 +
79156 + { }
79157 +};
79158 +#endif
79159 +
79160 /* The default sysctl tables: */
79161
79162 static struct ctl_table sysctl_base_table[] = {
79163 @@ -274,6 +287,22 @@ static int max_extfrag_threshold = 1000;
79164 #endif
79165
79166 static struct ctl_table kern_table[] = {
79167 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
79168 + {
79169 + .procname = "grsecurity",
79170 + .mode = 0500,
79171 + .child = grsecurity_table,
79172 + },
79173 +#endif
79174 +
79175 +#ifdef CONFIG_PAX_SOFTMODE
79176 + {
79177 + .procname = "pax",
79178 + .mode = 0500,
79179 + .child = pax_table,
79180 + },
79181 +#endif
79182 +
79183 {
79184 .procname = "sched_child_runs_first",
79185 .data = &sysctl_sched_child_runs_first,
79186 @@ -608,7 +637,7 @@ static struct ctl_table kern_table[] = {
79187 .data = &modprobe_path,
79188 .maxlen = KMOD_PATH_LEN,
79189 .mode = 0644,
79190 - .proc_handler = proc_dostring,
79191 + .proc_handler = proc_dostring_modpriv,
79192 },
79193 {
79194 .procname = "modules_disabled",
79195 @@ -775,16 +804,20 @@ static struct ctl_table kern_table[] = {
79196 .extra1 = &zero,
79197 .extra2 = &one,
79198 },
79199 +#endif
79200 {
79201 .procname = "kptr_restrict",
79202 .data = &kptr_restrict,
79203 .maxlen = sizeof(int),
79204 .mode = 0644,
79205 .proc_handler = proc_dointvec_minmax_sysadmin,
79206 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79207 + .extra1 = &two,
79208 +#else
79209 .extra1 = &zero,
79210 +#endif
79211 .extra2 = &two,
79212 },
79213 -#endif
79214 {
79215 .procname = "ngroups_max",
79216 .data = &ngroups_max,
79217 @@ -1026,10 +1059,17 @@ static struct ctl_table kern_table[] = {
79218 */
79219 {
79220 .procname = "perf_event_paranoid",
79221 - .data = &sysctl_perf_event_paranoid,
79222 - .maxlen = sizeof(sysctl_perf_event_paranoid),
79223 + .data = &sysctl_perf_event_legitimately_concerned,
79224 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
79225 .mode = 0644,
79226 - .proc_handler = proc_dointvec,
79227 + /* go ahead, be a hero */
79228 + .proc_handler = proc_dointvec_minmax_sysadmin,
79229 + .extra1 = &neg_one,
79230 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
79231 + .extra2 = &three,
79232 +#else
79233 + .extra2 = &two,
79234 +#endif
79235 },
79236 {
79237 .procname = "perf_event_mlock_kb",
79238 @@ -1283,6 +1323,13 @@ static struct ctl_table vm_table[] = {
79239 .proc_handler = proc_dointvec_minmax,
79240 .extra1 = &zero,
79241 },
79242 + {
79243 + .procname = "heap_stack_gap",
79244 + .data = &sysctl_heap_stack_gap,
79245 + .maxlen = sizeof(sysctl_heap_stack_gap),
79246 + .mode = 0644,
79247 + .proc_handler = proc_doulongvec_minmax,
79248 + },
79249 #else
79250 {
79251 .procname = "nr_trim_pages",
79252 @@ -1733,6 +1780,16 @@ int proc_dostring(struct ctl_table *table, int write,
79253 buffer, lenp, ppos);
79254 }
79255
79256 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79257 + void __user *buffer, size_t *lenp, loff_t *ppos)
79258 +{
79259 + if (write && !capable(CAP_SYS_MODULE))
79260 + return -EPERM;
79261 +
79262 + return _proc_do_string(table->data, table->maxlen, write,
79263 + buffer, lenp, ppos);
79264 +}
79265 +
79266 static size_t proc_skip_spaces(char **buf)
79267 {
79268 size_t ret;
79269 @@ -1838,6 +1895,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79270 len = strlen(tmp);
79271 if (len > *size)
79272 len = *size;
79273 + if (len > sizeof(tmp))
79274 + len = sizeof(tmp);
79275 if (copy_to_user(*buf, tmp, len))
79276 return -EFAULT;
79277 *size -= len;
79278 @@ -2002,7 +2061,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79279 static int proc_taint(struct ctl_table *table, int write,
79280 void __user *buffer, size_t *lenp, loff_t *ppos)
79281 {
79282 - struct ctl_table t;
79283 + ctl_table_no_const t;
79284 unsigned long tmptaint = get_taint();
79285 int err;
79286
79287 @@ -2030,7 +2089,6 @@ static int proc_taint(struct ctl_table *table, int write,
79288 return err;
79289 }
79290
79291 -#ifdef CONFIG_PRINTK
79292 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79293 void __user *buffer, size_t *lenp, loff_t *ppos)
79294 {
79295 @@ -2039,7 +2097,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79296
79297 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79298 }
79299 -#endif
79300
79301 struct do_proc_dointvec_minmax_conv_param {
79302 int *min;
79303 @@ -2186,8 +2243,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79304 *i = val;
79305 } else {
79306 val = convdiv * (*i) / convmul;
79307 - if (!first)
79308 + if (!first) {
79309 err = proc_put_char(&buffer, &left, '\t');
79310 + if (err)
79311 + break;
79312 + }
79313 err = proc_put_long(&buffer, &left, val, false);
79314 if (err)
79315 break;
79316 @@ -2579,6 +2639,12 @@ int proc_dostring(struct ctl_table *table, int write,
79317 return -ENOSYS;
79318 }
79319
79320 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79321 + void __user *buffer, size_t *lenp, loff_t *ppos)
79322 +{
79323 + return -ENOSYS;
79324 +}
79325 +
79326 int proc_dointvec(struct ctl_table *table, int write,
79327 void __user *buffer, size_t *lenp, loff_t *ppos)
79328 {
79329 @@ -2635,5 +2701,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79330 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79331 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79332 EXPORT_SYMBOL(proc_dostring);
79333 +EXPORT_SYMBOL(proc_dostring_modpriv);
79334 EXPORT_SYMBOL(proc_doulongvec_minmax);
79335 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79336 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79337 index 145bb4d..b2aa969 100644
79338 --- a/kernel/taskstats.c
79339 +++ b/kernel/taskstats.c
79340 @@ -28,9 +28,12 @@
79341 #include <linux/fs.h>
79342 #include <linux/file.h>
79343 #include <linux/pid_namespace.h>
79344 +#include <linux/grsecurity.h>
79345 #include <net/genetlink.h>
79346 #include <linux/atomic.h>
79347
79348 +extern int gr_is_taskstats_denied(int pid);
79349 +
79350 /*
79351 * Maximum length of a cpumask that can be specified in
79352 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79353 @@ -570,6 +573,9 @@ err:
79354
79355 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79356 {
79357 + if (gr_is_taskstats_denied(current->pid))
79358 + return -EACCES;
79359 +
79360 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79361 return cmd_attr_register_cpumask(info);
79362 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79363 diff --git a/kernel/time.c b/kernel/time.c
79364 index f8342a4..288f13b 100644
79365 --- a/kernel/time.c
79366 +++ b/kernel/time.c
79367 @@ -171,6 +171,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79368 return error;
79369
79370 if (tz) {
79371 + /* we log in do_settimeofday called below, so don't log twice
79372 + */
79373 + if (!tv)
79374 + gr_log_timechange();
79375 +
79376 sys_tz = *tz;
79377 update_vsyscall_tz();
79378 if (firsttime) {
79379 @@ -501,7 +506,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79380 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79381 * value to a scaled second value.
79382 */
79383 -unsigned long
79384 +unsigned long __intentional_overflow(-1)
79385 timespec_to_jiffies(const struct timespec *value)
79386 {
79387 unsigned long sec = value->tv_sec;
79388 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79389 index f11d83b..d016d91 100644
79390 --- a/kernel/time/alarmtimer.c
79391 +++ b/kernel/time/alarmtimer.c
79392 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79393 struct platform_device *pdev;
79394 int error = 0;
79395 int i;
79396 - struct k_clock alarm_clock = {
79397 + static struct k_clock alarm_clock = {
79398 .clock_getres = alarm_clock_getres,
79399 .clock_get = alarm_clock_get,
79400 .timer_create = alarm_timer_create,
79401 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79402 index 90ad470..1814e9a 100644
79403 --- a/kernel/time/tick-broadcast.c
79404 +++ b/kernel/time/tick-broadcast.c
79405 @@ -138,7 +138,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79406 * then clear the broadcast bit.
79407 */
79408 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79409 - int cpu = smp_processor_id();
79410 + cpu = smp_processor_id();
79411 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79412 tick_broadcast_clear_oneshot(cpu);
79413 } else {
79414 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79415 index 183df62..59b1442 100644
79416 --- a/kernel/time/timekeeping.c
79417 +++ b/kernel/time/timekeeping.c
79418 @@ -15,6 +15,7 @@
79419 #include <linux/init.h>
79420 #include <linux/mm.h>
79421 #include <linux/sched.h>
79422 +#include <linux/grsecurity.h>
79423 #include <linux/syscore_ops.h>
79424 #include <linux/clocksource.h>
79425 #include <linux/jiffies.h>
79426 @@ -448,6 +449,8 @@ int do_settimeofday(const struct timespec *tv)
79427 if (!timespec_valid_strict(tv))
79428 return -EINVAL;
79429
79430 + gr_log_timechange();
79431 +
79432 write_seqlock_irqsave(&tk->lock, flags);
79433
79434 timekeeping_forward_now(tk);
79435 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79436 index af5a7e9..715611a 100644
79437 --- a/kernel/time/timer_list.c
79438 +++ b/kernel/time/timer_list.c
79439 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79440
79441 static void print_name_offset(struct seq_file *m, void *sym)
79442 {
79443 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79444 + SEQ_printf(m, "<%p>", NULL);
79445 +#else
79446 char symname[KSYM_NAME_LEN];
79447
79448 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79449 SEQ_printf(m, "<%pK>", sym);
79450 else
79451 SEQ_printf(m, "%s", symname);
79452 +#endif
79453 }
79454
79455 static void
79456 @@ -112,7 +116,11 @@ next_one:
79457 static void
79458 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79459 {
79460 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79461 + SEQ_printf(m, " .base: %p\n", NULL);
79462 +#else
79463 SEQ_printf(m, " .base: %pK\n", base);
79464 +#endif
79465 SEQ_printf(m, " .index: %d\n",
79466 base->index);
79467 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79468 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79469 {
79470 struct proc_dir_entry *pe;
79471
79472 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79473 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79474 +#else
79475 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79476 +#endif
79477 if (!pe)
79478 return -ENOMEM;
79479 return 0;
79480 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79481 index 0b537f2..40d6c20 100644
79482 --- a/kernel/time/timer_stats.c
79483 +++ b/kernel/time/timer_stats.c
79484 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79485 static unsigned long nr_entries;
79486 static struct entry entries[MAX_ENTRIES];
79487
79488 -static atomic_t overflow_count;
79489 +static atomic_unchecked_t overflow_count;
79490
79491 /*
79492 * The entries are in a hash-table, for fast lookup:
79493 @@ -140,7 +140,7 @@ static void reset_entries(void)
79494 nr_entries = 0;
79495 memset(entries, 0, sizeof(entries));
79496 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79497 - atomic_set(&overflow_count, 0);
79498 + atomic_set_unchecked(&overflow_count, 0);
79499 }
79500
79501 static struct entry *alloc_entry(void)
79502 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79503 if (likely(entry))
79504 entry->count++;
79505 else
79506 - atomic_inc(&overflow_count);
79507 + atomic_inc_unchecked(&overflow_count);
79508
79509 out_unlock:
79510 raw_spin_unlock_irqrestore(lock, flags);
79511 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79512
79513 static void print_name_offset(struct seq_file *m, unsigned long addr)
79514 {
79515 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79516 + seq_printf(m, "<%p>", NULL);
79517 +#else
79518 char symname[KSYM_NAME_LEN];
79519
79520 if (lookup_symbol_name(addr, symname) < 0)
79521 - seq_printf(m, "<%p>", (void *)addr);
79522 + seq_printf(m, "<%pK>", (void *)addr);
79523 else
79524 seq_printf(m, "%s", symname);
79525 +#endif
79526 }
79527
79528 static int tstats_show(struct seq_file *m, void *v)
79529 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79530
79531 seq_puts(m, "Timer Stats Version: v0.2\n");
79532 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79533 - if (atomic_read(&overflow_count))
79534 + if (atomic_read_unchecked(&overflow_count))
79535 seq_printf(m, "Overflow: %d entries\n",
79536 - atomic_read(&overflow_count));
79537 + atomic_read_unchecked(&overflow_count));
79538
79539 for (i = 0; i < nr_entries; i++) {
79540 entry = entries + i;
79541 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79542 {
79543 struct proc_dir_entry *pe;
79544
79545 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79546 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79547 +#else
79548 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79549 +#endif
79550 if (!pe)
79551 return -ENOMEM;
79552 return 0;
79553 diff --git a/kernel/timer.c b/kernel/timer.c
79554 index 1b399c8..90e1849 100644
79555 --- a/kernel/timer.c
79556 +++ b/kernel/timer.c
79557 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79558 /*
79559 * This function runs timers and the timer-tq in bottom half context.
79560 */
79561 -static void run_timer_softirq(struct softirq_action *h)
79562 +static void run_timer_softirq(void)
79563 {
79564 struct tvec_base *base = __this_cpu_read(tvec_bases);
79565
79566 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79567 *
79568 * In all cases the return value is guaranteed to be non-negative.
79569 */
79570 -signed long __sched schedule_timeout(signed long timeout)
79571 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79572 {
79573 struct timer_list timer;
79574 unsigned long expire;
79575 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79576 return NOTIFY_OK;
79577 }
79578
79579 -static struct notifier_block __cpuinitdata timers_nb = {
79580 +static struct notifier_block timers_nb = {
79581 .notifier_call = timer_cpu_notify,
79582 };
79583
79584 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79585 index 5a0f781..1497f95 100644
79586 --- a/kernel/trace/blktrace.c
79587 +++ b/kernel/trace/blktrace.c
79588 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79589 struct blk_trace *bt = filp->private_data;
79590 char buf[16];
79591
79592 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79593 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79594
79595 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79596 }
79597 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79598 return 1;
79599
79600 bt = buf->chan->private_data;
79601 - atomic_inc(&bt->dropped);
79602 + atomic_inc_unchecked(&bt->dropped);
79603 return 0;
79604 }
79605
79606 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79607
79608 bt->dir = dir;
79609 bt->dev = dev;
79610 - atomic_set(&bt->dropped, 0);
79611 + atomic_set_unchecked(&bt->dropped, 0);
79612
79613 ret = -EIO;
79614 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79615 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79616 index 0a0e2a6..943495e 100644
79617 --- a/kernel/trace/ftrace.c
79618 +++ b/kernel/trace/ftrace.c
79619 @@ -1909,12 +1909,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79620 if (unlikely(ftrace_disabled))
79621 return 0;
79622
79623 + ret = ftrace_arch_code_modify_prepare();
79624 + FTRACE_WARN_ON(ret);
79625 + if (ret)
79626 + return 0;
79627 +
79628 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79629 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79630 if (ret) {
79631 ftrace_bug(ret, ip);
79632 - return 0;
79633 }
79634 - return 1;
79635 + return ret ? 0 : 1;
79636 }
79637
79638 /*
79639 @@ -2986,7 +2991,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79640
79641 int
79642 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79643 - void *data)
79644 + void *data)
79645 {
79646 struct ftrace_func_probe *entry;
79647 struct ftrace_page *pg;
79648 @@ -3854,8 +3859,10 @@ static int ftrace_process_locs(struct module *mod,
79649 if (!count)
79650 return 0;
79651
79652 + pax_open_kernel();
79653 sort(start, count, sizeof(*start),
79654 ftrace_cmp_ips, ftrace_swap_ips);
79655 + pax_close_kernel();
79656
79657 start_pg = ftrace_allocate_pages(count);
79658 if (!start_pg)
79659 @@ -4574,8 +4581,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79660 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79661
79662 static int ftrace_graph_active;
79663 -static struct notifier_block ftrace_suspend_notifier;
79664 -
79665 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79666 {
79667 return 0;
79668 @@ -4719,6 +4724,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79669 return NOTIFY_DONE;
79670 }
79671
79672 +static struct notifier_block ftrace_suspend_notifier = {
79673 + .notifier_call = ftrace_suspend_notifier_call
79674 +};
79675 +
79676 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79677 trace_func_graph_ent_t entryfunc)
79678 {
79679 @@ -4732,7 +4741,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79680 goto out;
79681 }
79682
79683 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79684 register_pm_notifier(&ftrace_suspend_notifier);
79685
79686 ftrace_graph_active++;
79687 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79688 index 6989df2..c2265cf 100644
79689 --- a/kernel/trace/ring_buffer.c
79690 +++ b/kernel/trace/ring_buffer.c
79691 @@ -349,9 +349,9 @@ struct buffer_data_page {
79692 */
79693 struct buffer_page {
79694 struct list_head list; /* list of buffer pages */
79695 - local_t write; /* index for next write */
79696 + local_unchecked_t write; /* index for next write */
79697 unsigned read; /* index for next read */
79698 - local_t entries; /* entries on this page */
79699 + local_unchecked_t entries; /* entries on this page */
79700 unsigned long real_end; /* real end of data */
79701 struct buffer_data_page *page; /* Actual data page */
79702 };
79703 @@ -464,8 +464,8 @@ struct ring_buffer_per_cpu {
79704 unsigned long last_overrun;
79705 local_t entries_bytes;
79706 local_t entries;
79707 - local_t overrun;
79708 - local_t commit_overrun;
79709 + local_unchecked_t overrun;
79710 + local_unchecked_t commit_overrun;
79711 local_t dropped_events;
79712 local_t committing;
79713 local_t commits;
79714 @@ -864,8 +864,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79715 *
79716 * We add a counter to the write field to denote this.
79717 */
79718 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79719 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79720 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79721 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79722
79723 /*
79724 * Just make sure we have seen our old_write and synchronize
79725 @@ -893,8 +893,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79726 * cmpxchg to only update if an interrupt did not already
79727 * do it for us. If the cmpxchg fails, we don't care.
79728 */
79729 - (void)local_cmpxchg(&next_page->write, old_write, val);
79730 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79731 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79732 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79733
79734 /*
79735 * No need to worry about races with clearing out the commit.
79736 @@ -1253,12 +1253,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79737
79738 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79739 {
79740 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79741 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79742 }
79743
79744 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79745 {
79746 - return local_read(&bpage->write) & RB_WRITE_MASK;
79747 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79748 }
79749
79750 static int
79751 @@ -1353,7 +1353,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79752 * bytes consumed in ring buffer from here.
79753 * Increment overrun to account for the lost events.
79754 */
79755 - local_add(page_entries, &cpu_buffer->overrun);
79756 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79757 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79758 }
79759
79760 @@ -1909,7 +1909,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79761 * it is our responsibility to update
79762 * the counters.
79763 */
79764 - local_add(entries, &cpu_buffer->overrun);
79765 + local_add_unchecked(entries, &cpu_buffer->overrun);
79766 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79767
79768 /*
79769 @@ -2059,7 +2059,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79770 if (tail == BUF_PAGE_SIZE)
79771 tail_page->real_end = 0;
79772
79773 - local_sub(length, &tail_page->write);
79774 + local_sub_unchecked(length, &tail_page->write);
79775 return;
79776 }
79777
79778 @@ -2094,7 +2094,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79779 rb_event_set_padding(event);
79780
79781 /* Set the write back to the previous setting */
79782 - local_sub(length, &tail_page->write);
79783 + local_sub_unchecked(length, &tail_page->write);
79784 return;
79785 }
79786
79787 @@ -2106,7 +2106,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79788
79789 /* Set write to end of buffer */
79790 length = (tail + length) - BUF_PAGE_SIZE;
79791 - local_sub(length, &tail_page->write);
79792 + local_sub_unchecked(length, &tail_page->write);
79793 }
79794
79795 /*
79796 @@ -2132,7 +2132,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79797 * about it.
79798 */
79799 if (unlikely(next_page == commit_page)) {
79800 - local_inc(&cpu_buffer->commit_overrun);
79801 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79802 goto out_reset;
79803 }
79804
79805 @@ -2188,7 +2188,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79806 cpu_buffer->tail_page) &&
79807 (cpu_buffer->commit_page ==
79808 cpu_buffer->reader_page))) {
79809 - local_inc(&cpu_buffer->commit_overrun);
79810 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79811 goto out_reset;
79812 }
79813 }
79814 @@ -2236,7 +2236,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79815 length += RB_LEN_TIME_EXTEND;
79816
79817 tail_page = cpu_buffer->tail_page;
79818 - write = local_add_return(length, &tail_page->write);
79819 + write = local_add_return_unchecked(length, &tail_page->write);
79820
79821 /* set write to only the index of the write */
79822 write &= RB_WRITE_MASK;
79823 @@ -2253,7 +2253,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79824 kmemcheck_annotate_bitfield(event, bitfield);
79825 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79826
79827 - local_inc(&tail_page->entries);
79828 + local_inc_unchecked(&tail_page->entries);
79829
79830 /*
79831 * If this is the first commit on the page, then update
79832 @@ -2286,7 +2286,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79833
79834 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79835 unsigned long write_mask =
79836 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79837 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79838 unsigned long event_length = rb_event_length(event);
79839 /*
79840 * This is on the tail page. It is possible that
79841 @@ -2296,7 +2296,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79842 */
79843 old_index += write_mask;
79844 new_index += write_mask;
79845 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79846 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79847 if (index == old_index) {
79848 /* update counters */
79849 local_sub(event_length, &cpu_buffer->entries_bytes);
79850 @@ -2670,7 +2670,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79851
79852 /* Do the likely case first */
79853 if (likely(bpage->page == (void *)addr)) {
79854 - local_dec(&bpage->entries);
79855 + local_dec_unchecked(&bpage->entries);
79856 return;
79857 }
79858
79859 @@ -2682,7 +2682,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79860 start = bpage;
79861 do {
79862 if (bpage->page == (void *)addr) {
79863 - local_dec(&bpage->entries);
79864 + local_dec_unchecked(&bpage->entries);
79865 return;
79866 }
79867 rb_inc_page(cpu_buffer, &bpage);
79868 @@ -2964,7 +2964,7 @@ static inline unsigned long
79869 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79870 {
79871 return local_read(&cpu_buffer->entries) -
79872 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79873 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79874 }
79875
79876 /**
79877 @@ -3053,7 +3053,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79878 return 0;
79879
79880 cpu_buffer = buffer->buffers[cpu];
79881 - ret = local_read(&cpu_buffer->overrun);
79882 + ret = local_read_unchecked(&cpu_buffer->overrun);
79883
79884 return ret;
79885 }
79886 @@ -3076,7 +3076,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79887 return 0;
79888
79889 cpu_buffer = buffer->buffers[cpu];
79890 - ret = local_read(&cpu_buffer->commit_overrun);
79891 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79892
79893 return ret;
79894 }
79895 @@ -3161,7 +3161,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79896 /* if you care about this being correct, lock the buffer */
79897 for_each_buffer_cpu(buffer, cpu) {
79898 cpu_buffer = buffer->buffers[cpu];
79899 - overruns += local_read(&cpu_buffer->overrun);
79900 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79901 }
79902
79903 return overruns;
79904 @@ -3337,8 +3337,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79905 /*
79906 * Reset the reader page to size zero.
79907 */
79908 - local_set(&cpu_buffer->reader_page->write, 0);
79909 - local_set(&cpu_buffer->reader_page->entries, 0);
79910 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79911 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79912 local_set(&cpu_buffer->reader_page->page->commit, 0);
79913 cpu_buffer->reader_page->real_end = 0;
79914
79915 @@ -3372,7 +3372,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79916 * want to compare with the last_overrun.
79917 */
79918 smp_mb();
79919 - overwrite = local_read(&(cpu_buffer->overrun));
79920 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79921
79922 /*
79923 * Here's the tricky part.
79924 @@ -3942,8 +3942,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79925
79926 cpu_buffer->head_page
79927 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79928 - local_set(&cpu_buffer->head_page->write, 0);
79929 - local_set(&cpu_buffer->head_page->entries, 0);
79930 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79931 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79932 local_set(&cpu_buffer->head_page->page->commit, 0);
79933
79934 cpu_buffer->head_page->read = 0;
79935 @@ -3953,14 +3953,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79936
79937 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79938 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79939 - local_set(&cpu_buffer->reader_page->write, 0);
79940 - local_set(&cpu_buffer->reader_page->entries, 0);
79941 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79942 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79943 local_set(&cpu_buffer->reader_page->page->commit, 0);
79944 cpu_buffer->reader_page->read = 0;
79945
79946 local_set(&cpu_buffer->entries_bytes, 0);
79947 - local_set(&cpu_buffer->overrun, 0);
79948 - local_set(&cpu_buffer->commit_overrun, 0);
79949 + local_set_unchecked(&cpu_buffer->overrun, 0);
79950 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79951 local_set(&cpu_buffer->dropped_events, 0);
79952 local_set(&cpu_buffer->entries, 0);
79953 local_set(&cpu_buffer->committing, 0);
79954 @@ -4364,8 +4364,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79955 rb_init_page(bpage);
79956 bpage = reader->page;
79957 reader->page = *data_page;
79958 - local_set(&reader->write, 0);
79959 - local_set(&reader->entries, 0);
79960 + local_set_unchecked(&reader->write, 0);
79961 + local_set_unchecked(&reader->entries, 0);
79962 reader->read = 0;
79963 *data_page = bpage;
79964
79965 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79966 index 3f28192..a29e8b0 100644
79967 --- a/kernel/trace/trace.c
79968 +++ b/kernel/trace/trace.c
79969 @@ -2893,7 +2893,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
79970 return 0;
79971 }
79972
79973 -int set_tracer_flag(unsigned int mask, int enabled)
79974 +int set_tracer_flag(unsigned long mask, int enabled)
79975 {
79976 /* do nothing if flag is already set */
79977 if (!!(trace_flags & mask) == !!enabled)
79978 @@ -4637,10 +4637,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79979 };
79980 #endif
79981
79982 -static struct dentry *d_tracer;
79983 -
79984 struct dentry *tracing_init_dentry(void)
79985 {
79986 + static struct dentry *d_tracer;
79987 static int once;
79988
79989 if (d_tracer)
79990 @@ -4660,10 +4659,9 @@ struct dentry *tracing_init_dentry(void)
79991 return d_tracer;
79992 }
79993
79994 -static struct dentry *d_percpu;
79995 -
79996 static struct dentry *tracing_dentry_percpu(void)
79997 {
79998 + static struct dentry *d_percpu;
79999 static int once;
80000 struct dentry *d_tracer;
80001
80002 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
80003 index 2081971..09f861e 100644
80004 --- a/kernel/trace/trace.h
80005 +++ b/kernel/trace/trace.h
80006 @@ -948,7 +948,7 @@ extern const char *__stop___trace_bprintk_fmt[];
80007 void trace_printk_init_buffers(void);
80008 void trace_printk_start_comm(void);
80009 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
80010 -int set_tracer_flag(unsigned int mask, int enabled);
80011 +int set_tracer_flag(unsigned long mask, int enabled);
80012
80013 #undef FTRACE_ENTRY
80014 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
80015 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
80016 index 57e9b28..eebe41c 100644
80017 --- a/kernel/trace/trace_events.c
80018 +++ b/kernel/trace/trace_events.c
80019 @@ -1329,10 +1329,6 @@ static LIST_HEAD(ftrace_module_file_list);
80020 struct ftrace_module_file_ops {
80021 struct list_head list;
80022 struct module *mod;
80023 - struct file_operations id;
80024 - struct file_operations enable;
80025 - struct file_operations format;
80026 - struct file_operations filter;
80027 };
80028
80029 static struct ftrace_module_file_ops *
80030 @@ -1353,17 +1349,12 @@ trace_create_file_ops(struct module *mod)
80031
80032 file_ops->mod = mod;
80033
80034 - file_ops->id = ftrace_event_id_fops;
80035 - file_ops->id.owner = mod;
80036 -
80037 - file_ops->enable = ftrace_enable_fops;
80038 - file_ops->enable.owner = mod;
80039 -
80040 - file_ops->filter = ftrace_event_filter_fops;
80041 - file_ops->filter.owner = mod;
80042 -
80043 - file_ops->format = ftrace_event_format_fops;
80044 - file_ops->format.owner = mod;
80045 + pax_open_kernel();
80046 + mod->trace_id.owner = mod;
80047 + mod->trace_enable.owner = mod;
80048 + mod->trace_filter.owner = mod;
80049 + mod->trace_format.owner = mod;
80050 + pax_close_kernel();
80051
80052 list_add(&file_ops->list, &ftrace_module_file_list);
80053
80054 @@ -1387,8 +1378,8 @@ static void trace_module_add_events(struct module *mod)
80055
80056 for_each_event(call, start, end) {
80057 __trace_add_event_call(*call, mod,
80058 - &file_ops->id, &file_ops->enable,
80059 - &file_ops->filter, &file_ops->format);
80060 + &mod->trace_id, &mod->trace_enable,
80061 + &mod->trace_filter, &mod->trace_format);
80062 }
80063 }
80064
80065 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
80066 index fd3c8aa..5f324a6 100644
80067 --- a/kernel/trace/trace_mmiotrace.c
80068 +++ b/kernel/trace/trace_mmiotrace.c
80069 @@ -24,7 +24,7 @@ struct header_iter {
80070 static struct trace_array *mmio_trace_array;
80071 static bool overrun_detected;
80072 static unsigned long prev_overruns;
80073 -static atomic_t dropped_count;
80074 +static atomic_unchecked_t dropped_count;
80075
80076 static void mmio_reset_data(struct trace_array *tr)
80077 {
80078 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
80079
80080 static unsigned long count_overruns(struct trace_iterator *iter)
80081 {
80082 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
80083 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
80084 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
80085
80086 if (over > prev_overruns)
80087 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
80088 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
80089 sizeof(*entry), 0, pc);
80090 if (!event) {
80091 - atomic_inc(&dropped_count);
80092 + atomic_inc_unchecked(&dropped_count);
80093 return;
80094 }
80095 entry = ring_buffer_event_data(event);
80096 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
80097 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
80098 sizeof(*entry), 0, pc);
80099 if (!event) {
80100 - atomic_inc(&dropped_count);
80101 + atomic_inc_unchecked(&dropped_count);
80102 return;
80103 }
80104 entry = ring_buffer_event_data(event);
80105 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
80106 index 697e88d..1a79993 100644
80107 --- a/kernel/trace/trace_output.c
80108 +++ b/kernel/trace/trace_output.c
80109 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
80110
80111 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
80112 if (!IS_ERR(p)) {
80113 - p = mangle_path(s->buffer + s->len, p, "\n");
80114 + p = mangle_path(s->buffer + s->len, p, "\n\\");
80115 if (p) {
80116 s->len = p - s->buffer;
80117 return 1;
80118 @@ -851,14 +851,16 @@ int register_ftrace_event(struct trace_event *event)
80119 goto out;
80120 }
80121
80122 + pax_open_kernel();
80123 if (event->funcs->trace == NULL)
80124 - event->funcs->trace = trace_nop_print;
80125 + *(void **)&event->funcs->trace = trace_nop_print;
80126 if (event->funcs->raw == NULL)
80127 - event->funcs->raw = trace_nop_print;
80128 + *(void **)&event->funcs->raw = trace_nop_print;
80129 if (event->funcs->hex == NULL)
80130 - event->funcs->hex = trace_nop_print;
80131 + *(void **)&event->funcs->hex = trace_nop_print;
80132 if (event->funcs->binary == NULL)
80133 - event->funcs->binary = trace_nop_print;
80134 + *(void **)&event->funcs->binary = trace_nop_print;
80135 + pax_close_kernel();
80136
80137 key = event->type & (EVENT_HASHSIZE - 1);
80138
80139 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
80140 index b20428c..4845a10 100644
80141 --- a/kernel/trace/trace_stack.c
80142 +++ b/kernel/trace/trace_stack.c
80143 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
80144 return;
80145
80146 /* we do not handle interrupt stacks yet */
80147 - if (!object_is_on_stack(stack))
80148 + if (!object_starts_on_stack(stack))
80149 return;
80150
80151 local_irq_save(flags);
80152 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
80153 index e134d8f..a018cdd 100644
80154 --- a/kernel/user_namespace.c
80155 +++ b/kernel/user_namespace.c
80156 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80157 if (atomic_read(&current->mm->mm_users) > 1)
80158 return -EINVAL;
80159
80160 - if (current->fs->users != 1)
80161 + if (atomic_read(&current->fs->users) != 1)
80162 return -EINVAL;
80163
80164 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80165 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80166 index 4f69f9a..7c6f8f8 100644
80167 --- a/kernel/utsname_sysctl.c
80168 +++ b/kernel/utsname_sysctl.c
80169 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80170 static int proc_do_uts_string(ctl_table *table, int write,
80171 void __user *buffer, size_t *lenp, loff_t *ppos)
80172 {
80173 - struct ctl_table uts_table;
80174 + ctl_table_no_const uts_table;
80175 int r;
80176 memcpy(&uts_table, table, sizeof(uts_table));
80177 uts_table.data = get_uts(table, write);
80178 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80179 index 4a94467..80a6f9c 100644
80180 --- a/kernel/watchdog.c
80181 +++ b/kernel/watchdog.c
80182 @@ -526,7 +526,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80183 }
80184 #endif /* CONFIG_SYSCTL */
80185
80186 -static struct smp_hotplug_thread watchdog_threads = {
80187 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80188 .store = &softlockup_watchdog,
80189 .thread_should_run = watchdog_should_run,
80190 .thread_fn = watchdog,
80191 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80192 index 28be08c..47bab92 100644
80193 --- a/lib/Kconfig.debug
80194 +++ b/lib/Kconfig.debug
80195 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
80196
80197 config DEBUG_LOCK_ALLOC
80198 bool "Lock debugging: detect incorrect freeing of live locks"
80199 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80200 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80201 select DEBUG_SPINLOCK
80202 select DEBUG_MUTEXES
80203 select LOCKDEP
80204 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
80205
80206 config PROVE_LOCKING
80207 bool "Lock debugging: prove locking correctness"
80208 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80209 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80210 select LOCKDEP
80211 select DEBUG_SPINLOCK
80212 select DEBUG_MUTEXES
80213 @@ -614,7 +614,7 @@ config LOCKDEP
80214
80215 config LOCK_STAT
80216 bool "Lock usage statistics"
80217 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80218 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80219 select LOCKDEP
80220 select DEBUG_SPINLOCK
80221 select DEBUG_MUTEXES
80222 @@ -1282,6 +1282,7 @@ config LATENCYTOP
80223 depends on DEBUG_KERNEL
80224 depends on STACKTRACE_SUPPORT
80225 depends on PROC_FS
80226 + depends on !GRKERNSEC_HIDESYM
80227 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80228 select KALLSYMS
80229 select KALLSYMS_ALL
80230 @@ -1310,7 +1311,7 @@ config INTERVAL_TREE_TEST
80231
80232 config PROVIDE_OHCI1394_DMA_INIT
80233 bool "Remote debugging over FireWire early on boot"
80234 - depends on PCI && X86
80235 + depends on PCI && X86 && !GRKERNSEC
80236 help
80237 If you want to debug problems which hang or crash the kernel early
80238 on boot and the crashing machine has a FireWire port, you can use
80239 @@ -1339,7 +1340,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80240
80241 config FIREWIRE_OHCI_REMOTE_DMA
80242 bool "Remote debugging over FireWire with firewire-ohci"
80243 - depends on FIREWIRE_OHCI
80244 + depends on FIREWIRE_OHCI && !GRKERNSEC
80245 help
80246 This option lets you use the FireWire bus for remote debugging
80247 with help of the firewire-ohci driver. It enables unfiltered
80248 diff --git a/lib/Makefile b/lib/Makefile
80249 index 6e2cc56..9b13738 100644
80250 --- a/lib/Makefile
80251 +++ b/lib/Makefile
80252 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80253
80254 obj-$(CONFIG_BTREE) += btree.o
80255 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80256 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80257 +obj-y += list_debug.o
80258 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80259
80260 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80261 diff --git a/lib/bitmap.c b/lib/bitmap.c
80262 index 06f7e4f..f3cf2b0 100644
80263 --- a/lib/bitmap.c
80264 +++ b/lib/bitmap.c
80265 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80266 {
80267 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80268 u32 chunk;
80269 - const char __user __force *ubuf = (const char __user __force *)buf;
80270 + const char __user *ubuf = (const char __force_user *)buf;
80271
80272 bitmap_zero(maskp, nmaskbits);
80273
80274 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80275 {
80276 if (!access_ok(VERIFY_READ, ubuf, ulen))
80277 return -EFAULT;
80278 - return __bitmap_parse((const char __force *)ubuf,
80279 + return __bitmap_parse((const char __force_kernel *)ubuf,
80280 ulen, 1, maskp, nmaskbits);
80281
80282 }
80283 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80284 {
80285 unsigned a, b;
80286 int c, old_c, totaldigits;
80287 - const char __user __force *ubuf = (const char __user __force *)buf;
80288 + const char __user *ubuf = (const char __force_user *)buf;
80289 int exp_digit, in_range;
80290
80291 totaldigits = c = 0;
80292 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80293 {
80294 if (!access_ok(VERIFY_READ, ubuf, ulen))
80295 return -EFAULT;
80296 - return __bitmap_parselist((const char __force *)ubuf,
80297 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80298 ulen, 1, maskp, nmaskbits);
80299 }
80300 EXPORT_SYMBOL(bitmap_parselist_user);
80301 diff --git a/lib/bug.c b/lib/bug.c
80302 index 1686034..a9c00c8 100644
80303 --- a/lib/bug.c
80304 +++ b/lib/bug.c
80305 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80306 return BUG_TRAP_TYPE_NONE;
80307
80308 bug = find_bug(bugaddr);
80309 + if (!bug)
80310 + return BUG_TRAP_TYPE_NONE;
80311
80312 file = NULL;
80313 line = 0;
80314 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80315 index 37061ed..da83f48 100644
80316 --- a/lib/debugobjects.c
80317 +++ b/lib/debugobjects.c
80318 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80319 if (limit > 4)
80320 return;
80321
80322 - is_on_stack = object_is_on_stack(addr);
80323 + is_on_stack = object_starts_on_stack(addr);
80324 if (is_on_stack == onstack)
80325 return;
80326
80327 diff --git a/lib/devres.c b/lib/devres.c
80328 index 8235331..5881053 100644
80329 --- a/lib/devres.c
80330 +++ b/lib/devres.c
80331 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80332 void devm_iounmap(struct device *dev, void __iomem *addr)
80333 {
80334 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80335 - (void *)addr));
80336 + (void __force *)addr));
80337 iounmap(addr);
80338 }
80339 EXPORT_SYMBOL(devm_iounmap);
80340 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80341 {
80342 ioport_unmap(addr);
80343 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80344 - devm_ioport_map_match, (void *)addr));
80345 + devm_ioport_map_match, (void __force *)addr));
80346 }
80347 EXPORT_SYMBOL(devm_ioport_unmap);
80348 #endif /* CONFIG_HAS_IOPORT */
80349 diff --git a/lib/div64.c b/lib/div64.c
80350 index a163b6c..9618fa5 100644
80351 --- a/lib/div64.c
80352 +++ b/lib/div64.c
80353 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80354 EXPORT_SYMBOL(__div64_32);
80355
80356 #ifndef div_s64_rem
80357 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80358 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80359 {
80360 u64 quotient;
80361
80362 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80363 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80364 */
80365 #ifndef div64_u64
80366 -u64 div64_u64(u64 dividend, u64 divisor)
80367 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80368 {
80369 u32 high = divisor >> 32;
80370 u64 quot;
80371 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80372 index d87a17a..ac0d79a 100644
80373 --- a/lib/dma-debug.c
80374 +++ b/lib/dma-debug.c
80375 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80376
80377 void dma_debug_add_bus(struct bus_type *bus)
80378 {
80379 - struct notifier_block *nb;
80380 + notifier_block_no_const *nb;
80381
80382 if (global_disable)
80383 return;
80384 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
80385
80386 static void check_for_stack(struct device *dev, void *addr)
80387 {
80388 - if (object_is_on_stack(addr))
80389 + if (object_starts_on_stack(addr))
80390 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80391 "stack [addr=%p]\n", addr);
80392 }
80393 diff --git a/lib/inflate.c b/lib/inflate.c
80394 index 013a761..c28f3fc 100644
80395 --- a/lib/inflate.c
80396 +++ b/lib/inflate.c
80397 @@ -269,7 +269,7 @@ static void free(void *where)
80398 malloc_ptr = free_mem_ptr;
80399 }
80400 #else
80401 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80402 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80403 #define free(a) kfree(a)
80404 #endif
80405
80406 diff --git a/lib/ioremap.c b/lib/ioremap.c
80407 index 0c9216c..863bd89 100644
80408 --- a/lib/ioremap.c
80409 +++ b/lib/ioremap.c
80410 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80411 unsigned long next;
80412
80413 phys_addr -= addr;
80414 - pmd = pmd_alloc(&init_mm, pud, addr);
80415 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80416 if (!pmd)
80417 return -ENOMEM;
80418 do {
80419 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80420 unsigned long next;
80421
80422 phys_addr -= addr;
80423 - pud = pud_alloc(&init_mm, pgd, addr);
80424 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80425 if (!pud)
80426 return -ENOMEM;
80427 do {
80428 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80429 index bd2bea9..6b3c95e 100644
80430 --- a/lib/is_single_threaded.c
80431 +++ b/lib/is_single_threaded.c
80432 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80433 struct task_struct *p, *t;
80434 bool ret;
80435
80436 + if (!mm)
80437 + return true;
80438 +
80439 if (atomic_read(&task->signal->live) != 1)
80440 return false;
80441
80442 diff --git a/lib/kobject.c b/lib/kobject.c
80443 index a654866..d8bb115 100644
80444 --- a/lib/kobject.c
80445 +++ b/lib/kobject.c
80446 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
80447 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
80448 if (!kset)
80449 return NULL;
80450 - retval = kobject_set_name(&kset->kobj, name);
80451 + retval = kobject_set_name(&kset->kobj, "%s", name);
80452 if (retval) {
80453 kfree(kset);
80454 return NULL;
80455 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80456
80457
80458 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80459 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80460 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80461
80462 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80463 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80464 {
80465 enum kobj_ns_type type = ops->type;
80466 int error;
80467 diff --git a/lib/list_debug.c b/lib/list_debug.c
80468 index c24c2f7..06e070b 100644
80469 --- a/lib/list_debug.c
80470 +++ b/lib/list_debug.c
80471 @@ -11,7 +11,9 @@
80472 #include <linux/bug.h>
80473 #include <linux/kernel.h>
80474 #include <linux/rculist.h>
80475 +#include <linux/mm.h>
80476
80477 +#ifdef CONFIG_DEBUG_LIST
80478 /*
80479 * Insert a new entry between two known consecutive entries.
80480 *
80481 @@ -19,21 +21,32 @@
80482 * the prev/next entries already!
80483 */
80484
80485 -void __list_add(struct list_head *new,
80486 - struct list_head *prev,
80487 - struct list_head *next)
80488 +static bool __list_add_debug(struct list_head *new,
80489 + struct list_head *prev,
80490 + struct list_head *next)
80491 {
80492 - WARN(next->prev != prev,
80493 + if (WARN(next->prev != prev,
80494 "list_add corruption. next->prev should be "
80495 "prev (%p), but was %p. (next=%p).\n",
80496 - prev, next->prev, next);
80497 - WARN(prev->next != next,
80498 + prev, next->prev, next) ||
80499 + WARN(prev->next != next,
80500 "list_add corruption. prev->next should be "
80501 "next (%p), but was %p. (prev=%p).\n",
80502 - next, prev->next, prev);
80503 - WARN(new == prev || new == next,
80504 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80505 - new, prev, next);
80506 + next, prev->next, prev) ||
80507 + WARN(new == prev || new == next,
80508 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80509 + new, prev, next))
80510 + return false;
80511 + return true;
80512 +}
80513 +
80514 +void __list_add(struct list_head *new,
80515 + struct list_head *prev,
80516 + struct list_head *next)
80517 +{
80518 + if (!__list_add_debug(new, prev, next))
80519 + return;
80520 +
80521 next->prev = new;
80522 new->next = next;
80523 new->prev = prev;
80524 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80525 }
80526 EXPORT_SYMBOL(__list_add);
80527
80528 -void __list_del_entry(struct list_head *entry)
80529 +static bool __list_del_entry_debug(struct list_head *entry)
80530 {
80531 struct list_head *prev, *next;
80532
80533 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80534 WARN(next->prev != entry,
80535 "list_del corruption. next->prev should be %p, "
80536 "but was %p\n", entry, next->prev))
80537 + return false;
80538 + return true;
80539 +}
80540 +
80541 +void __list_del_entry(struct list_head *entry)
80542 +{
80543 + if (!__list_del_entry_debug(entry))
80544 return;
80545
80546 - __list_del(prev, next);
80547 + __list_del(entry->prev, entry->next);
80548 }
80549 EXPORT_SYMBOL(__list_del_entry);
80550
80551 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80552 void __list_add_rcu(struct list_head *new,
80553 struct list_head *prev, struct list_head *next)
80554 {
80555 - WARN(next->prev != prev,
80556 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80557 - prev, next->prev, next);
80558 - WARN(prev->next != next,
80559 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80560 - next, prev->next, prev);
80561 + if (!__list_add_debug(new, prev, next))
80562 + return;
80563 +
80564 new->next = next;
80565 new->prev = prev;
80566 rcu_assign_pointer(list_next_rcu(prev), new);
80567 next->prev = new;
80568 }
80569 EXPORT_SYMBOL(__list_add_rcu);
80570 +#endif
80571 +
80572 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80573 +{
80574 +#ifdef CONFIG_DEBUG_LIST
80575 + if (!__list_add_debug(new, prev, next))
80576 + return;
80577 +#endif
80578 +
80579 + pax_open_kernel();
80580 + next->prev = new;
80581 + new->next = next;
80582 + new->prev = prev;
80583 + prev->next = new;
80584 + pax_close_kernel();
80585 +}
80586 +EXPORT_SYMBOL(__pax_list_add);
80587 +
80588 +void pax_list_del(struct list_head *entry)
80589 +{
80590 +#ifdef CONFIG_DEBUG_LIST
80591 + if (!__list_del_entry_debug(entry))
80592 + return;
80593 +#endif
80594 +
80595 + pax_open_kernel();
80596 + __list_del(entry->prev, entry->next);
80597 + entry->next = LIST_POISON1;
80598 + entry->prev = LIST_POISON2;
80599 + pax_close_kernel();
80600 +}
80601 +EXPORT_SYMBOL(pax_list_del);
80602 +
80603 +void pax_list_del_init(struct list_head *entry)
80604 +{
80605 + pax_open_kernel();
80606 + __list_del(entry->prev, entry->next);
80607 + INIT_LIST_HEAD(entry);
80608 + pax_close_kernel();
80609 +}
80610 +EXPORT_SYMBOL(pax_list_del_init);
80611 +
80612 +void __pax_list_add_rcu(struct list_head *new,
80613 + struct list_head *prev, struct list_head *next)
80614 +{
80615 +#ifdef CONFIG_DEBUG_LIST
80616 + if (!__list_add_debug(new, prev, next))
80617 + return;
80618 +#endif
80619 +
80620 + pax_open_kernel();
80621 + new->next = next;
80622 + new->prev = prev;
80623 + rcu_assign_pointer(list_next_rcu(prev), new);
80624 + next->prev = new;
80625 + pax_close_kernel();
80626 +}
80627 +EXPORT_SYMBOL(__pax_list_add_rcu);
80628 +
80629 +void pax_list_del_rcu(struct list_head *entry)
80630 +{
80631 +#ifdef CONFIG_DEBUG_LIST
80632 + if (!__list_del_entry_debug(entry))
80633 + return;
80634 +#endif
80635 +
80636 + pax_open_kernel();
80637 + __list_del(entry->prev, entry->next);
80638 + entry->next = LIST_POISON1;
80639 + entry->prev = LIST_POISON2;
80640 + pax_close_kernel();
80641 +}
80642 +EXPORT_SYMBOL(pax_list_del_rcu);
80643 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80644 index e796429..6e38f9f 100644
80645 --- a/lib/radix-tree.c
80646 +++ b/lib/radix-tree.c
80647 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80648 int nr;
80649 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80650 };
80651 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80652 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80653
80654 static inline void *ptr_to_indirect(void *ptr)
80655 {
80656 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80657 index bb2b201..46abaf9 100644
80658 --- a/lib/strncpy_from_user.c
80659 +++ b/lib/strncpy_from_user.c
80660 @@ -21,7 +21,7 @@
80661 */
80662 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80663 {
80664 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80665 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80666 long res = 0;
80667
80668 /*
80669 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80670 index a28df52..3d55877 100644
80671 --- a/lib/strnlen_user.c
80672 +++ b/lib/strnlen_user.c
80673 @@ -26,7 +26,7 @@
80674 */
80675 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80676 {
80677 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80678 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80679 long align, res = 0;
80680 unsigned long c;
80681
80682 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80683 index d23762e..e21eab2 100644
80684 --- a/lib/swiotlb.c
80685 +++ b/lib/swiotlb.c
80686 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80687
80688 void
80689 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80690 - dma_addr_t dev_addr)
80691 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80692 {
80693 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80694
80695 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80696 index 0d62fd7..b7bc911 100644
80697 --- a/lib/vsprintf.c
80698 +++ b/lib/vsprintf.c
80699 @@ -16,6 +16,9 @@
80700 * - scnprintf and vscnprintf
80701 */
80702
80703 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80704 +#define __INCLUDED_BY_HIDESYM 1
80705 +#endif
80706 #include <stdarg.h>
80707 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80708 #include <linux/types.h>
80709 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80710 return number(buf, end, *(const netdev_features_t *)addr, spec);
80711 }
80712
80713 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80714 +int kptr_restrict __read_mostly = 2;
80715 +#else
80716 int kptr_restrict __read_mostly;
80717 +#endif
80718
80719 /*
80720 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80721 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80722 * - 'S' For symbolic direct pointers with offset
80723 * - 's' For symbolic direct pointers without offset
80724 * - 'B' For backtraced symbolic direct pointers with offset
80725 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80726 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80727 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80728 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80729 * - 'M' For a 6-byte MAC address, it prints the address in the
80730 @@ -1044,12 +1053,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80731
80732 if (!ptr && *fmt != 'K') {
80733 /*
80734 - * Print (null) with the same width as a pointer so it makes
80735 + * Print (nil) with the same width as a pointer so it makes
80736 * tabular output look nice.
80737 */
80738 if (spec.field_width == -1)
80739 spec.field_width = default_width;
80740 - return string(buf, end, "(null)", spec);
80741 + return string(buf, end, "(nil)", spec);
80742 }
80743
80744 switch (*fmt) {
80745 @@ -1059,6 +1068,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80746 /* Fallthrough */
80747 case 'S':
80748 case 's':
80749 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80750 + break;
80751 +#else
80752 + return symbol_string(buf, end, ptr, spec, *fmt);
80753 +#endif
80754 + case 'A':
80755 case 'B':
80756 return symbol_string(buf, end, ptr, spec, *fmt);
80757 case 'R':
80758 @@ -1099,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80759 va_end(va);
80760 return buf;
80761 }
80762 + case 'P':
80763 + break;
80764 case 'K':
80765 /*
80766 * %pK cannot be used in IRQ context because its test
80767 @@ -1128,6 +1145,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80768 return number(buf, end,
80769 (unsigned long long) *((phys_addr_t *)ptr), spec);
80770 }
80771 +
80772 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80773 + /* 'P' = approved pointers to copy to userland,
80774 + as in the /proc/kallsyms case, as we make it display nothing
80775 + for non-root users, and the real contents for root users
80776 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80777 + above
80778 + */
80779 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80780 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80781 + dump_stack();
80782 + ptr = NULL;
80783 + }
80784 +#endif
80785 +
80786 spec.flags |= SMALL;
80787 if (spec.field_width == -1) {
80788 spec.field_width = default_width;
80789 @@ -1849,11 +1881,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80790 typeof(type) value; \
80791 if (sizeof(type) == 8) { \
80792 args = PTR_ALIGN(args, sizeof(u32)); \
80793 - *(u32 *)&value = *(u32 *)args; \
80794 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80795 + *(u32 *)&value = *(const u32 *)args; \
80796 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80797 } else { \
80798 args = PTR_ALIGN(args, sizeof(type)); \
80799 - value = *(typeof(type) *)args; \
80800 + value = *(const typeof(type) *)args; \
80801 } \
80802 args += sizeof(type); \
80803 value; \
80804 @@ -1916,7 +1948,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80805 case FORMAT_TYPE_STR: {
80806 const char *str_arg = args;
80807 args += strlen(str_arg) + 1;
80808 - str = string(str, end, (char *)str_arg, spec);
80809 + str = string(str, end, str_arg, spec);
80810 break;
80811 }
80812
80813 diff --git a/localversion-grsec b/localversion-grsec
80814 new file mode 100644
80815 index 0000000..7cd6065
80816 --- /dev/null
80817 +++ b/localversion-grsec
80818 @@ -0,0 +1 @@
80819 +-grsec
80820 diff --git a/mm/Kconfig b/mm/Kconfig
80821 index 3bea74f..e821c99 100644
80822 --- a/mm/Kconfig
80823 +++ b/mm/Kconfig
80824 @@ -311,10 +311,10 @@ config KSM
80825 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80826
80827 config DEFAULT_MMAP_MIN_ADDR
80828 - int "Low address space to protect from user allocation"
80829 + int "Low address space to protect from user allocation"
80830 depends on MMU
80831 - default 4096
80832 - help
80833 + default 65536
80834 + help
80835 This is the portion of low virtual memory which should be protected
80836 from userspace allocation. Keeping a user from writing to low pages
80837 can help reduce the impact of kernel NULL pointer bugs.
80838 @@ -345,7 +345,7 @@ config MEMORY_FAILURE
80839
80840 config HWPOISON_INJECT
80841 tristate "HWPoison pages injector"
80842 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80843 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80844 select PROC_PAGE_MONITOR
80845
80846 config NOMMU_INITIAL_TRIM_EXCESS
80847 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
80848 index 41733c5..d80d7a9 100644
80849 --- a/mm/backing-dev.c
80850 +++ b/mm/backing-dev.c
80851 @@ -716,7 +716,6 @@ EXPORT_SYMBOL(bdi_destroy);
80852 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
80853 unsigned int cap)
80854 {
80855 - char tmp[32];
80856 int err;
80857
80858 bdi->name = name;
80859 @@ -725,8 +724,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
80860 if (err)
80861 return err;
80862
80863 - sprintf(tmp, "%.28s%s", name, "-%d");
80864 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
80865 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return(&bdi_seq));
80866 if (err) {
80867 bdi_destroy(bdi);
80868 return err;
80869 diff --git a/mm/filemap.c b/mm/filemap.c
80870 index e1979fd..dda5120 100644
80871 --- a/mm/filemap.c
80872 +++ b/mm/filemap.c
80873 @@ -1748,7 +1748,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80874 struct address_space *mapping = file->f_mapping;
80875
80876 if (!mapping->a_ops->readpage)
80877 - return -ENOEXEC;
80878 + return -ENODEV;
80879 file_accessed(file);
80880 vma->vm_ops = &generic_file_vm_ops;
80881 return 0;
80882 @@ -2088,6 +2088,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80883 *pos = i_size_read(inode);
80884
80885 if (limit != RLIM_INFINITY) {
80886 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80887 if (*pos >= limit) {
80888 send_sig(SIGXFSZ, current, 0);
80889 return -EFBIG;
80890 diff --git a/mm/fremap.c b/mm/fremap.c
80891 index 87da359..3f41cb1 100644
80892 --- a/mm/fremap.c
80893 +++ b/mm/fremap.c
80894 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80895 retry:
80896 vma = find_vma(mm, start);
80897
80898 +#ifdef CONFIG_PAX_SEGMEXEC
80899 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80900 + goto out;
80901 +#endif
80902 +
80903 /*
80904 * Make sure the vma is shared, that it supports prefaulting,
80905 * and that the remapped range is valid and fully within
80906 diff --git a/mm/highmem.c b/mm/highmem.c
80907 index b32b70c..e512eb0 100644
80908 --- a/mm/highmem.c
80909 +++ b/mm/highmem.c
80910 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80911 * So no dangers, even with speculative execution.
80912 */
80913 page = pte_page(pkmap_page_table[i]);
80914 + pax_open_kernel();
80915 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80916 -
80917 + pax_close_kernel();
80918 set_page_address(page, NULL);
80919 need_flush = 1;
80920 }
80921 @@ -198,9 +199,11 @@ start:
80922 }
80923 }
80924 vaddr = PKMAP_ADDR(last_pkmap_nr);
80925 +
80926 + pax_open_kernel();
80927 set_pte_at(&init_mm, vaddr,
80928 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80929 -
80930 + pax_close_kernel();
80931 pkmap_count[last_pkmap_nr] = 1;
80932 set_page_address(page, (void *)vaddr);
80933
80934 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80935 index ce4cb19..93899ef 100644
80936 --- a/mm/hugetlb.c
80937 +++ b/mm/hugetlb.c
80938 @@ -2005,15 +2005,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80939 struct hstate *h = &default_hstate;
80940 unsigned long tmp;
80941 int ret;
80942 + ctl_table_no_const hugetlb_table;
80943
80944 tmp = h->max_huge_pages;
80945
80946 if (write && h->order >= MAX_ORDER)
80947 return -EINVAL;
80948
80949 - table->data = &tmp;
80950 - table->maxlen = sizeof(unsigned long);
80951 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80952 + hugetlb_table = *table;
80953 + hugetlb_table.data = &tmp;
80954 + hugetlb_table.maxlen = sizeof(unsigned long);
80955 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80956 if (ret)
80957 goto out;
80958
80959 @@ -2070,15 +2072,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80960 struct hstate *h = &default_hstate;
80961 unsigned long tmp;
80962 int ret;
80963 + ctl_table_no_const hugetlb_table;
80964
80965 tmp = h->nr_overcommit_huge_pages;
80966
80967 if (write && h->order >= MAX_ORDER)
80968 return -EINVAL;
80969
80970 - table->data = &tmp;
80971 - table->maxlen = sizeof(unsigned long);
80972 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80973 + hugetlb_table = *table;
80974 + hugetlb_table.data = &tmp;
80975 + hugetlb_table.maxlen = sizeof(unsigned long);
80976 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80977 if (ret)
80978 goto out;
80979
80980 @@ -2512,6 +2516,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80981 return 1;
80982 }
80983
80984 +#ifdef CONFIG_PAX_SEGMEXEC
80985 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80986 +{
80987 + struct mm_struct *mm = vma->vm_mm;
80988 + struct vm_area_struct *vma_m;
80989 + unsigned long address_m;
80990 + pte_t *ptep_m;
80991 +
80992 + vma_m = pax_find_mirror_vma(vma);
80993 + if (!vma_m)
80994 + return;
80995 +
80996 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80997 + address_m = address + SEGMEXEC_TASK_SIZE;
80998 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80999 + get_page(page_m);
81000 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
81001 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
81002 +}
81003 +#endif
81004 +
81005 /*
81006 * Hugetlb_cow() should be called with page lock of the original hugepage held.
81007 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
81008 @@ -2630,6 +2655,11 @@ retry_avoidcopy:
81009 make_huge_pte(vma, new_page, 1));
81010 page_remove_rmap(old_page);
81011 hugepage_add_new_anon_rmap(new_page, vma, address);
81012 +
81013 +#ifdef CONFIG_PAX_SEGMEXEC
81014 + pax_mirror_huge_pte(vma, address, new_page);
81015 +#endif
81016 +
81017 /* Make the old page be freed below */
81018 new_page = old_page;
81019 }
81020 @@ -2788,6 +2818,10 @@ retry:
81021 && (vma->vm_flags & VM_SHARED)));
81022 set_huge_pte_at(mm, address, ptep, new_pte);
81023
81024 +#ifdef CONFIG_PAX_SEGMEXEC
81025 + pax_mirror_huge_pte(vma, address, page);
81026 +#endif
81027 +
81028 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
81029 /* Optimization, do the COW without a second fault */
81030 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
81031 @@ -2817,6 +2851,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81032 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
81033 struct hstate *h = hstate_vma(vma);
81034
81035 +#ifdef CONFIG_PAX_SEGMEXEC
81036 + struct vm_area_struct *vma_m;
81037 +#endif
81038 +
81039 address &= huge_page_mask(h);
81040
81041 ptep = huge_pte_offset(mm, address);
81042 @@ -2830,6 +2868,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81043 VM_FAULT_SET_HINDEX(hstate_index(h));
81044 }
81045
81046 +#ifdef CONFIG_PAX_SEGMEXEC
81047 + vma_m = pax_find_mirror_vma(vma);
81048 + if (vma_m) {
81049 + unsigned long address_m;
81050 +
81051 + if (vma->vm_start > vma_m->vm_start) {
81052 + address_m = address;
81053 + address -= SEGMEXEC_TASK_SIZE;
81054 + vma = vma_m;
81055 + h = hstate_vma(vma);
81056 + } else
81057 + address_m = address + SEGMEXEC_TASK_SIZE;
81058 +
81059 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
81060 + return VM_FAULT_OOM;
81061 + address_m &= HPAGE_MASK;
81062 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
81063 + }
81064 +#endif
81065 +
81066 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
81067 if (!ptep)
81068 return VM_FAULT_OOM;
81069 diff --git a/mm/internal.h b/mm/internal.h
81070 index 8562de0..7fdfe92 100644
81071 --- a/mm/internal.h
81072 +++ b/mm/internal.h
81073 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
81074 * in mm/page_alloc.c
81075 */
81076 extern void __free_pages_bootmem(struct page *page, unsigned int order);
81077 +extern void free_compound_page(struct page *page);
81078 extern void prep_compound_page(struct page *page, unsigned long order);
81079 #ifdef CONFIG_MEMORY_FAILURE
81080 extern bool is_free_buddy_page(struct page *page);
81081 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
81082 index c8d7f31..2dbeffd 100644
81083 --- a/mm/kmemleak.c
81084 +++ b/mm/kmemleak.c
81085 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
81086
81087 for (i = 0; i < object->trace_len; i++) {
81088 void *ptr = (void *)object->trace[i];
81089 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
81090 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
81091 }
81092 }
81093
81094 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
81095 return -ENOMEM;
81096 }
81097
81098 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
81099 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
81100 &kmemleak_fops);
81101 if (!dentry)
81102 pr_warning("Failed to create the debugfs kmemleak file\n");
81103 diff --git a/mm/maccess.c b/mm/maccess.c
81104 index d53adf9..03a24bf 100644
81105 --- a/mm/maccess.c
81106 +++ b/mm/maccess.c
81107 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
81108 set_fs(KERNEL_DS);
81109 pagefault_disable();
81110 ret = __copy_from_user_inatomic(dst,
81111 - (__force const void __user *)src, size);
81112 + (const void __force_user *)src, size);
81113 pagefault_enable();
81114 set_fs(old_fs);
81115
81116 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
81117
81118 set_fs(KERNEL_DS);
81119 pagefault_disable();
81120 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81121 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81122 pagefault_enable();
81123 set_fs(old_fs);
81124
81125 diff --git a/mm/madvise.c b/mm/madvise.c
81126 index c58c94b..86ec14e 100644
81127 --- a/mm/madvise.c
81128 +++ b/mm/madvise.c
81129 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81130 pgoff_t pgoff;
81131 unsigned long new_flags = vma->vm_flags;
81132
81133 +#ifdef CONFIG_PAX_SEGMEXEC
81134 + struct vm_area_struct *vma_m;
81135 +#endif
81136 +
81137 switch (behavior) {
81138 case MADV_NORMAL:
81139 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81140 @@ -126,6 +130,13 @@ success:
81141 /*
81142 * vm_flags is protected by the mmap_sem held in write mode.
81143 */
81144 +
81145 +#ifdef CONFIG_PAX_SEGMEXEC
81146 + vma_m = pax_find_mirror_vma(vma);
81147 + if (vma_m)
81148 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81149 +#endif
81150 +
81151 vma->vm_flags = new_flags;
81152
81153 out:
81154 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81155 struct vm_area_struct ** prev,
81156 unsigned long start, unsigned long end)
81157 {
81158 +
81159 +#ifdef CONFIG_PAX_SEGMEXEC
81160 + struct vm_area_struct *vma_m;
81161 +#endif
81162 +
81163 *prev = vma;
81164 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81165 return -EINVAL;
81166 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81167 zap_page_range(vma, start, end - start, &details);
81168 } else
81169 zap_page_range(vma, start, end - start, NULL);
81170 +
81171 +#ifdef CONFIG_PAX_SEGMEXEC
81172 + vma_m = pax_find_mirror_vma(vma);
81173 + if (vma_m) {
81174 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81175 + struct zap_details details = {
81176 + .nonlinear_vma = vma_m,
81177 + .last_index = ULONG_MAX,
81178 + };
81179 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81180 + } else
81181 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81182 + }
81183 +#endif
81184 +
81185 return 0;
81186 }
81187
81188 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81189 if (end < start)
81190 goto out;
81191
81192 +#ifdef CONFIG_PAX_SEGMEXEC
81193 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81194 + if (end > SEGMEXEC_TASK_SIZE)
81195 + goto out;
81196 + } else
81197 +#endif
81198 +
81199 + if (end > TASK_SIZE)
81200 + goto out;
81201 +
81202 error = 0;
81203 if (end == start)
81204 goto out;
81205 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81206 index df0694c..bc95539 100644
81207 --- a/mm/memory-failure.c
81208 +++ b/mm/memory-failure.c
81209 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81210
81211 int sysctl_memory_failure_recovery __read_mostly = 1;
81212
81213 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
81214 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
81215
81216 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81217
81218 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81219 pfn, t->comm, t->pid);
81220 si.si_signo = SIGBUS;
81221 si.si_errno = 0;
81222 - si.si_addr = (void *)addr;
81223 + si.si_addr = (void __user *)addr;
81224 #ifdef __ARCH_SI_TRAPNO
81225 si.si_trapno = trapno;
81226 #endif
81227 @@ -760,7 +760,7 @@ static struct page_state {
81228 unsigned long res;
81229 char *msg;
81230 int (*action)(struct page *p, unsigned long pfn);
81231 -} error_states[] = {
81232 +} __do_const error_states[] = {
81233 { reserved, reserved, "reserved kernel", me_kernel },
81234 /*
81235 * free pages are specially detected outside this table:
81236 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81237 nr_pages = 1 << compound_order(hpage);
81238 else /* normal page or thp */
81239 nr_pages = 1;
81240 - atomic_long_add(nr_pages, &num_poisoned_pages);
81241 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
81242
81243 /*
81244 * We need/can do nothing about count=0 pages.
81245 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81246 if (!PageHWPoison(hpage)
81247 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81248 || (p != hpage && TestSetPageHWPoison(hpage))) {
81249 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81250 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81251 return 0;
81252 }
81253 set_page_hwpoison_huge_page(hpage);
81254 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81255 }
81256 if (hwpoison_filter(p)) {
81257 if (TestClearPageHWPoison(p))
81258 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81259 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81260 unlock_page(hpage);
81261 put_page(hpage);
81262 return 0;
81263 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
81264 return 0;
81265 }
81266 if (TestClearPageHWPoison(p))
81267 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81268 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81269 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81270 return 0;
81271 }
81272 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
81273 */
81274 if (TestClearPageHWPoison(page)) {
81275 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81276 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81277 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81278 freeit = 1;
81279 if (PageHuge(page))
81280 clear_page_hwpoison_huge_page(page);
81281 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81282 } else {
81283 set_page_hwpoison_huge_page(hpage);
81284 dequeue_hwpoisoned_huge_page(hpage);
81285 - atomic_long_add(1 << compound_trans_order(hpage),
81286 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81287 &num_poisoned_pages);
81288 }
81289 /* keep elevated page count for bad page */
81290 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
81291 if (PageHuge(page)) {
81292 set_page_hwpoison_huge_page(hpage);
81293 dequeue_hwpoisoned_huge_page(hpage);
81294 - atomic_long_add(1 << compound_trans_order(hpage),
81295 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81296 &num_poisoned_pages);
81297 } else {
81298 SetPageHWPoison(page);
81299 - atomic_long_inc(&num_poisoned_pages);
81300 + atomic_long_inc_unchecked(&num_poisoned_pages);
81301 }
81302 }
81303 /* keep elevated page count for bad page */
81304 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
81305 put_page(page);
81306 pr_info("soft_offline: %#lx: invalidated\n", pfn);
81307 SetPageHWPoison(page);
81308 - atomic_long_inc(&num_poisoned_pages);
81309 + atomic_long_inc_unchecked(&num_poisoned_pages);
81310 return 0;
81311 }
81312
81313 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
81314 ret = -EIO;
81315 } else {
81316 SetPageHWPoison(page);
81317 - atomic_long_inc(&num_poisoned_pages);
81318 + atomic_long_inc_unchecked(&num_poisoned_pages);
81319 }
81320 } else {
81321 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
81322 diff --git a/mm/memory.c b/mm/memory.c
81323 index ba94dec..08ffe0d 100644
81324 --- a/mm/memory.c
81325 +++ b/mm/memory.c
81326 @@ -438,6 +438,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81327 free_pte_range(tlb, pmd, addr);
81328 } while (pmd++, addr = next, addr != end);
81329
81330 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81331 start &= PUD_MASK;
81332 if (start < floor)
81333 return;
81334 @@ -452,6 +453,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81335 pmd = pmd_offset(pud, start);
81336 pud_clear(pud);
81337 pmd_free_tlb(tlb, pmd, start);
81338 +#endif
81339 +
81340 }
81341
81342 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81343 @@ -471,6 +474,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81344 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81345 } while (pud++, addr = next, addr != end);
81346
81347 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81348 start &= PGDIR_MASK;
81349 if (start < floor)
81350 return;
81351 @@ -485,6 +489,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81352 pud = pud_offset(pgd, start);
81353 pgd_clear(pgd);
81354 pud_free_tlb(tlb, pud, start);
81355 +#endif
81356 +
81357 }
81358
81359 /*
81360 @@ -1644,12 +1650,6 @@ no_page_table:
81361 return page;
81362 }
81363
81364 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81365 -{
81366 - return stack_guard_page_start(vma, addr) ||
81367 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81368 -}
81369 -
81370 /**
81371 * __get_user_pages() - pin user pages in memory
81372 * @tsk: task_struct of target task
81373 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81374
81375 i = 0;
81376
81377 - do {
81378 + while (nr_pages) {
81379 struct vm_area_struct *vma;
81380
81381 - vma = find_extend_vma(mm, start);
81382 + vma = find_vma(mm, start);
81383 if (!vma && in_gate_area(mm, start)) {
81384 unsigned long pg = start & PAGE_MASK;
81385 pgd_t *pgd;
81386 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81387 goto next_page;
81388 }
81389
81390 - if (!vma ||
81391 + if (!vma || start < vma->vm_start ||
81392 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81393 !(vm_flags & vma->vm_flags))
81394 return i ? : -EFAULT;
81395 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81396 int ret;
81397 unsigned int fault_flags = 0;
81398
81399 - /* For mlock, just skip the stack guard page. */
81400 - if (foll_flags & FOLL_MLOCK) {
81401 - if (stack_guard_page(vma, start))
81402 - goto next_page;
81403 - }
81404 if (foll_flags & FOLL_WRITE)
81405 fault_flags |= FAULT_FLAG_WRITE;
81406 if (nonblocking)
81407 @@ -1901,7 +1896,7 @@ next_page:
81408 start += page_increm * PAGE_SIZE;
81409 nr_pages -= page_increm;
81410 } while (nr_pages && start < vma->vm_end);
81411 - } while (nr_pages);
81412 + }
81413 return i;
81414 }
81415 EXPORT_SYMBOL(__get_user_pages);
81416 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81417 page_add_file_rmap(page);
81418 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81419
81420 +#ifdef CONFIG_PAX_SEGMEXEC
81421 + pax_mirror_file_pte(vma, addr, page, ptl);
81422 +#endif
81423 +
81424 retval = 0;
81425 pte_unmap_unlock(pte, ptl);
81426 return retval;
81427 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81428 if (!page_count(page))
81429 return -EINVAL;
81430 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81431 +
81432 +#ifdef CONFIG_PAX_SEGMEXEC
81433 + struct vm_area_struct *vma_m;
81434 +#endif
81435 +
81436 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81437 BUG_ON(vma->vm_flags & VM_PFNMAP);
81438 vma->vm_flags |= VM_MIXEDMAP;
81439 +
81440 +#ifdef CONFIG_PAX_SEGMEXEC
81441 + vma_m = pax_find_mirror_vma(vma);
81442 + if (vma_m)
81443 + vma_m->vm_flags |= VM_MIXEDMAP;
81444 +#endif
81445 +
81446 }
81447 return insert_page(vma, addr, page, vma->vm_page_prot);
81448 }
81449 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81450 unsigned long pfn)
81451 {
81452 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81453 + BUG_ON(vma->vm_mirror);
81454
81455 if (addr < vma->vm_start || addr >= vma->vm_end)
81456 return -EFAULT;
81457 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81458
81459 BUG_ON(pud_huge(*pud));
81460
81461 - pmd = pmd_alloc(mm, pud, addr);
81462 + pmd = (mm == &init_mm) ?
81463 + pmd_alloc_kernel(mm, pud, addr) :
81464 + pmd_alloc(mm, pud, addr);
81465 if (!pmd)
81466 return -ENOMEM;
81467 do {
81468 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81469 unsigned long next;
81470 int err;
81471
81472 - pud = pud_alloc(mm, pgd, addr);
81473 + pud = (mm == &init_mm) ?
81474 + pud_alloc_kernel(mm, pgd, addr) :
81475 + pud_alloc(mm, pgd, addr);
81476 if (!pud)
81477 return -ENOMEM;
81478 do {
81479 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81480 copy_user_highpage(dst, src, va, vma);
81481 }
81482
81483 +#ifdef CONFIG_PAX_SEGMEXEC
81484 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81485 +{
81486 + struct mm_struct *mm = vma->vm_mm;
81487 + spinlock_t *ptl;
81488 + pte_t *pte, entry;
81489 +
81490 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81491 + entry = *pte;
81492 + if (!pte_present(entry)) {
81493 + if (!pte_none(entry)) {
81494 + BUG_ON(pte_file(entry));
81495 + free_swap_and_cache(pte_to_swp_entry(entry));
81496 + pte_clear_not_present_full(mm, address, pte, 0);
81497 + }
81498 + } else {
81499 + struct page *page;
81500 +
81501 + flush_cache_page(vma, address, pte_pfn(entry));
81502 + entry = ptep_clear_flush(vma, address, pte);
81503 + BUG_ON(pte_dirty(entry));
81504 + page = vm_normal_page(vma, address, entry);
81505 + if (page) {
81506 + update_hiwater_rss(mm);
81507 + if (PageAnon(page))
81508 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81509 + else
81510 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81511 + page_remove_rmap(page);
81512 + page_cache_release(page);
81513 + }
81514 + }
81515 + pte_unmap_unlock(pte, ptl);
81516 +}
81517 +
81518 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81519 + *
81520 + * the ptl of the lower mapped page is held on entry and is not released on exit
81521 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81522 + */
81523 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81524 +{
81525 + struct mm_struct *mm = vma->vm_mm;
81526 + unsigned long address_m;
81527 + spinlock_t *ptl_m;
81528 + struct vm_area_struct *vma_m;
81529 + pmd_t *pmd_m;
81530 + pte_t *pte_m, entry_m;
81531 +
81532 + BUG_ON(!page_m || !PageAnon(page_m));
81533 +
81534 + vma_m = pax_find_mirror_vma(vma);
81535 + if (!vma_m)
81536 + return;
81537 +
81538 + BUG_ON(!PageLocked(page_m));
81539 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81540 + address_m = address + SEGMEXEC_TASK_SIZE;
81541 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81542 + pte_m = pte_offset_map(pmd_m, address_m);
81543 + ptl_m = pte_lockptr(mm, pmd_m);
81544 + if (ptl != ptl_m) {
81545 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81546 + if (!pte_none(*pte_m))
81547 + goto out;
81548 + }
81549 +
81550 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81551 + page_cache_get(page_m);
81552 + page_add_anon_rmap(page_m, vma_m, address_m);
81553 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81554 + set_pte_at(mm, address_m, pte_m, entry_m);
81555 + update_mmu_cache(vma_m, address_m, pte_m);
81556 +out:
81557 + if (ptl != ptl_m)
81558 + spin_unlock(ptl_m);
81559 + pte_unmap(pte_m);
81560 + unlock_page(page_m);
81561 +}
81562 +
81563 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81564 +{
81565 + struct mm_struct *mm = vma->vm_mm;
81566 + unsigned long address_m;
81567 + spinlock_t *ptl_m;
81568 + struct vm_area_struct *vma_m;
81569 + pmd_t *pmd_m;
81570 + pte_t *pte_m, entry_m;
81571 +
81572 + BUG_ON(!page_m || PageAnon(page_m));
81573 +
81574 + vma_m = pax_find_mirror_vma(vma);
81575 + if (!vma_m)
81576 + return;
81577 +
81578 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81579 + address_m = address + SEGMEXEC_TASK_SIZE;
81580 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81581 + pte_m = pte_offset_map(pmd_m, address_m);
81582 + ptl_m = pte_lockptr(mm, pmd_m);
81583 + if (ptl != ptl_m) {
81584 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81585 + if (!pte_none(*pte_m))
81586 + goto out;
81587 + }
81588 +
81589 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81590 + page_cache_get(page_m);
81591 + page_add_file_rmap(page_m);
81592 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81593 + set_pte_at(mm, address_m, pte_m, entry_m);
81594 + update_mmu_cache(vma_m, address_m, pte_m);
81595 +out:
81596 + if (ptl != ptl_m)
81597 + spin_unlock(ptl_m);
81598 + pte_unmap(pte_m);
81599 +}
81600 +
81601 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81602 +{
81603 + struct mm_struct *mm = vma->vm_mm;
81604 + unsigned long address_m;
81605 + spinlock_t *ptl_m;
81606 + struct vm_area_struct *vma_m;
81607 + pmd_t *pmd_m;
81608 + pte_t *pte_m, entry_m;
81609 +
81610 + vma_m = pax_find_mirror_vma(vma);
81611 + if (!vma_m)
81612 + return;
81613 +
81614 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81615 + address_m = address + SEGMEXEC_TASK_SIZE;
81616 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81617 + pte_m = pte_offset_map(pmd_m, address_m);
81618 + ptl_m = pte_lockptr(mm, pmd_m);
81619 + if (ptl != ptl_m) {
81620 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81621 + if (!pte_none(*pte_m))
81622 + goto out;
81623 + }
81624 +
81625 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81626 + set_pte_at(mm, address_m, pte_m, entry_m);
81627 +out:
81628 + if (ptl != ptl_m)
81629 + spin_unlock(ptl_m);
81630 + pte_unmap(pte_m);
81631 +}
81632 +
81633 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81634 +{
81635 + struct page *page_m;
81636 + pte_t entry;
81637 +
81638 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81639 + goto out;
81640 +
81641 + entry = *pte;
81642 + page_m = vm_normal_page(vma, address, entry);
81643 + if (!page_m)
81644 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81645 + else if (PageAnon(page_m)) {
81646 + if (pax_find_mirror_vma(vma)) {
81647 + pte_unmap_unlock(pte, ptl);
81648 + lock_page(page_m);
81649 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81650 + if (pte_same(entry, *pte))
81651 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81652 + else
81653 + unlock_page(page_m);
81654 + }
81655 + } else
81656 + pax_mirror_file_pte(vma, address, page_m, ptl);
81657 +
81658 +out:
81659 + pte_unmap_unlock(pte, ptl);
81660 +}
81661 +#endif
81662 +
81663 /*
81664 * This routine handles present pages, when users try to write
81665 * to a shared page. It is done by copying the page to a new address
81666 @@ -2808,6 +3004,12 @@ gotten:
81667 */
81668 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81669 if (likely(pte_same(*page_table, orig_pte))) {
81670 +
81671 +#ifdef CONFIG_PAX_SEGMEXEC
81672 + if (pax_find_mirror_vma(vma))
81673 + BUG_ON(!trylock_page(new_page));
81674 +#endif
81675 +
81676 if (old_page) {
81677 if (!PageAnon(old_page)) {
81678 dec_mm_counter_fast(mm, MM_FILEPAGES);
81679 @@ -2859,6 +3061,10 @@ gotten:
81680 page_remove_rmap(old_page);
81681 }
81682
81683 +#ifdef CONFIG_PAX_SEGMEXEC
81684 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81685 +#endif
81686 +
81687 /* Free the old page.. */
81688 new_page = old_page;
81689 ret |= VM_FAULT_WRITE;
81690 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81691 swap_free(entry);
81692 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81693 try_to_free_swap(page);
81694 +
81695 +#ifdef CONFIG_PAX_SEGMEXEC
81696 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81697 +#endif
81698 +
81699 unlock_page(page);
81700 if (page != swapcache) {
81701 /*
81702 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81703
81704 /* No need to invalidate - it was non-present before */
81705 update_mmu_cache(vma, address, page_table);
81706 +
81707 +#ifdef CONFIG_PAX_SEGMEXEC
81708 + pax_mirror_anon_pte(vma, address, page, ptl);
81709 +#endif
81710 +
81711 unlock:
81712 pte_unmap_unlock(page_table, ptl);
81713 out:
81714 @@ -3176,40 +3392,6 @@ out_release:
81715 }
81716
81717 /*
81718 - * This is like a special single-page "expand_{down|up}wards()",
81719 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81720 - * doesn't hit another vma.
81721 - */
81722 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81723 -{
81724 - address &= PAGE_MASK;
81725 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81726 - struct vm_area_struct *prev = vma->vm_prev;
81727 -
81728 - /*
81729 - * Is there a mapping abutting this one below?
81730 - *
81731 - * That's only ok if it's the same stack mapping
81732 - * that has gotten split..
81733 - */
81734 - if (prev && prev->vm_end == address)
81735 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81736 -
81737 - expand_downwards(vma, address - PAGE_SIZE);
81738 - }
81739 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81740 - struct vm_area_struct *next = vma->vm_next;
81741 -
81742 - /* As VM_GROWSDOWN but s/below/above/ */
81743 - if (next && next->vm_start == address + PAGE_SIZE)
81744 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81745 -
81746 - expand_upwards(vma, address + PAGE_SIZE);
81747 - }
81748 - return 0;
81749 -}
81750 -
81751 -/*
81752 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81753 * but allow concurrent faults), and pte mapped but not yet locked.
81754 * We return with mmap_sem still held, but pte unmapped and unlocked.
81755 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81756 unsigned long address, pte_t *page_table, pmd_t *pmd,
81757 unsigned int flags)
81758 {
81759 - struct page *page;
81760 + struct page *page = NULL;
81761 spinlock_t *ptl;
81762 pte_t entry;
81763
81764 - pte_unmap(page_table);
81765 -
81766 - /* Check if we need to add a guard page to the stack */
81767 - if (check_stack_guard_page(vma, address) < 0)
81768 - return VM_FAULT_SIGBUS;
81769 -
81770 - /* Use the zero-page for reads */
81771 if (!(flags & FAULT_FLAG_WRITE)) {
81772 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81773 vma->vm_page_prot));
81774 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81775 + ptl = pte_lockptr(mm, pmd);
81776 + spin_lock(ptl);
81777 if (!pte_none(*page_table))
81778 goto unlock;
81779 goto setpte;
81780 }
81781
81782 /* Allocate our own private page. */
81783 + pte_unmap(page_table);
81784 +
81785 if (unlikely(anon_vma_prepare(vma)))
81786 goto oom;
81787 page = alloc_zeroed_user_highpage_movable(vma, address);
81788 @@ -3257,6 +3435,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81789 if (!pte_none(*page_table))
81790 goto release;
81791
81792 +#ifdef CONFIG_PAX_SEGMEXEC
81793 + if (pax_find_mirror_vma(vma))
81794 + BUG_ON(!trylock_page(page));
81795 +#endif
81796 +
81797 inc_mm_counter_fast(mm, MM_ANONPAGES);
81798 page_add_new_anon_rmap(page, vma, address);
81799 setpte:
81800 @@ -3264,6 +3447,12 @@ setpte:
81801
81802 /* No need to invalidate - it was non-present before */
81803 update_mmu_cache(vma, address, page_table);
81804 +
81805 +#ifdef CONFIG_PAX_SEGMEXEC
81806 + if (page)
81807 + pax_mirror_anon_pte(vma, address, page, ptl);
81808 +#endif
81809 +
81810 unlock:
81811 pte_unmap_unlock(page_table, ptl);
81812 return 0;
81813 @@ -3407,6 +3596,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81814 */
81815 /* Only go through if we didn't race with anybody else... */
81816 if (likely(pte_same(*page_table, orig_pte))) {
81817 +
81818 +#ifdef CONFIG_PAX_SEGMEXEC
81819 + if (anon && pax_find_mirror_vma(vma))
81820 + BUG_ON(!trylock_page(page));
81821 +#endif
81822 +
81823 flush_icache_page(vma, page);
81824 entry = mk_pte(page, vma->vm_page_prot);
81825 if (flags & FAULT_FLAG_WRITE)
81826 @@ -3426,6 +3621,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81827
81828 /* no need to invalidate: a not-present page won't be cached */
81829 update_mmu_cache(vma, address, page_table);
81830 +
81831 +#ifdef CONFIG_PAX_SEGMEXEC
81832 + if (anon)
81833 + pax_mirror_anon_pte(vma, address, page, ptl);
81834 + else
81835 + pax_mirror_file_pte(vma, address, page, ptl);
81836 +#endif
81837 +
81838 } else {
81839 if (cow_page)
81840 mem_cgroup_uncharge_page(cow_page);
81841 @@ -3747,6 +3950,12 @@ int handle_pte_fault(struct mm_struct *mm,
81842 if (flags & FAULT_FLAG_WRITE)
81843 flush_tlb_fix_spurious_fault(vma, address);
81844 }
81845 +
81846 +#ifdef CONFIG_PAX_SEGMEXEC
81847 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81848 + return 0;
81849 +#endif
81850 +
81851 unlock:
81852 pte_unmap_unlock(pte, ptl);
81853 return 0;
81854 @@ -3763,6 +3972,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81855 pmd_t *pmd;
81856 pte_t *pte;
81857
81858 +#ifdef CONFIG_PAX_SEGMEXEC
81859 + struct vm_area_struct *vma_m;
81860 +#endif
81861 +
81862 __set_current_state(TASK_RUNNING);
81863
81864 count_vm_event(PGFAULT);
81865 @@ -3774,6 +3987,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81866 if (unlikely(is_vm_hugetlb_page(vma)))
81867 return hugetlb_fault(mm, vma, address, flags);
81868
81869 +#ifdef CONFIG_PAX_SEGMEXEC
81870 + vma_m = pax_find_mirror_vma(vma);
81871 + if (vma_m) {
81872 + unsigned long address_m;
81873 + pgd_t *pgd_m;
81874 + pud_t *pud_m;
81875 + pmd_t *pmd_m;
81876 +
81877 + if (vma->vm_start > vma_m->vm_start) {
81878 + address_m = address;
81879 + address -= SEGMEXEC_TASK_SIZE;
81880 + vma = vma_m;
81881 + } else
81882 + address_m = address + SEGMEXEC_TASK_SIZE;
81883 +
81884 + pgd_m = pgd_offset(mm, address_m);
81885 + pud_m = pud_alloc(mm, pgd_m, address_m);
81886 + if (!pud_m)
81887 + return VM_FAULT_OOM;
81888 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81889 + if (!pmd_m)
81890 + return VM_FAULT_OOM;
81891 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81892 + return VM_FAULT_OOM;
81893 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81894 + }
81895 +#endif
81896 +
81897 retry:
81898 pgd = pgd_offset(mm, address);
81899 pud = pud_alloc(mm, pgd, address);
81900 @@ -3872,6 +4113,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81901 spin_unlock(&mm->page_table_lock);
81902 return 0;
81903 }
81904 +
81905 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81906 +{
81907 + pud_t *new = pud_alloc_one(mm, address);
81908 + if (!new)
81909 + return -ENOMEM;
81910 +
81911 + smp_wmb(); /* See comment in __pte_alloc */
81912 +
81913 + spin_lock(&mm->page_table_lock);
81914 + if (pgd_present(*pgd)) /* Another has populated it */
81915 + pud_free(mm, new);
81916 + else
81917 + pgd_populate_kernel(mm, pgd, new);
81918 + spin_unlock(&mm->page_table_lock);
81919 + return 0;
81920 +}
81921 #endif /* __PAGETABLE_PUD_FOLDED */
81922
81923 #ifndef __PAGETABLE_PMD_FOLDED
81924 @@ -3902,6 +4160,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81925 spin_unlock(&mm->page_table_lock);
81926 return 0;
81927 }
81928 +
81929 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81930 +{
81931 + pmd_t *new = pmd_alloc_one(mm, address);
81932 + if (!new)
81933 + return -ENOMEM;
81934 +
81935 + smp_wmb(); /* See comment in __pte_alloc */
81936 +
81937 + spin_lock(&mm->page_table_lock);
81938 +#ifndef __ARCH_HAS_4LEVEL_HACK
81939 + if (pud_present(*pud)) /* Another has populated it */
81940 + pmd_free(mm, new);
81941 + else
81942 + pud_populate_kernel(mm, pud, new);
81943 +#else
81944 + if (pgd_present(*pud)) /* Another has populated it */
81945 + pmd_free(mm, new);
81946 + else
81947 + pgd_populate_kernel(mm, pud, new);
81948 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81949 + spin_unlock(&mm->page_table_lock);
81950 + return 0;
81951 +}
81952 #endif /* __PAGETABLE_PMD_FOLDED */
81953
81954 #if !defined(__HAVE_ARCH_GATE_AREA)
81955 @@ -3915,7 +4197,7 @@ static int __init gate_vma_init(void)
81956 gate_vma.vm_start = FIXADDR_USER_START;
81957 gate_vma.vm_end = FIXADDR_USER_END;
81958 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81959 - gate_vma.vm_page_prot = __P101;
81960 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81961
81962 return 0;
81963 }
81964 @@ -4049,8 +4331,8 @@ out:
81965 return ret;
81966 }
81967
81968 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81969 - void *buf, int len, int write)
81970 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81971 + void *buf, size_t len, int write)
81972 {
81973 resource_size_t phys_addr;
81974 unsigned long prot = 0;
81975 @@ -4075,8 +4357,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81976 * Access another process' address space as given in mm. If non-NULL, use the
81977 * given task for page fault accounting.
81978 */
81979 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81980 - unsigned long addr, void *buf, int len, int write)
81981 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81982 + unsigned long addr, void *buf, size_t len, int write)
81983 {
81984 struct vm_area_struct *vma;
81985 void *old_buf = buf;
81986 @@ -4084,7 +4366,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81987 down_read(&mm->mmap_sem);
81988 /* ignore errors, just check how much was successfully transferred */
81989 while (len) {
81990 - int bytes, ret, offset;
81991 + ssize_t bytes, ret, offset;
81992 void *maddr;
81993 struct page *page = NULL;
81994
81995 @@ -4143,8 +4425,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81996 *
81997 * The caller must hold a reference on @mm.
81998 */
81999 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82000 - void *buf, int len, int write)
82001 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
82002 + void *buf, size_t len, int write)
82003 {
82004 return __access_remote_vm(NULL, mm, addr, buf, len, write);
82005 }
82006 @@ -4154,11 +4436,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82007 * Source/target buffer must be kernel space,
82008 * Do not walk the page table directly, use get_user_pages
82009 */
82010 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
82011 - void *buf, int len, int write)
82012 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
82013 + void *buf, size_t len, int write)
82014 {
82015 struct mm_struct *mm;
82016 - int ret;
82017 + ssize_t ret;
82018
82019 mm = get_task_mm(tsk);
82020 if (!mm)
82021 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
82022 index 7431001..0f8344e 100644
82023 --- a/mm/mempolicy.c
82024 +++ b/mm/mempolicy.c
82025 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82026 unsigned long vmstart;
82027 unsigned long vmend;
82028
82029 +#ifdef CONFIG_PAX_SEGMEXEC
82030 + struct vm_area_struct *vma_m;
82031 +#endif
82032 +
82033 vma = find_vma(mm, start);
82034 if (!vma || vma->vm_start > start)
82035 return -EFAULT;
82036 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82037 if (err)
82038 goto out;
82039 }
82040 +
82041 err = vma_replace_policy(vma, new_pol);
82042 if (err)
82043 goto out;
82044 +
82045 +#ifdef CONFIG_PAX_SEGMEXEC
82046 + vma_m = pax_find_mirror_vma(vma);
82047 + if (vma_m) {
82048 + err = vma_replace_policy(vma_m, new_pol);
82049 + if (err)
82050 + goto out;
82051 + }
82052 +#endif
82053 +
82054 }
82055
82056 out:
82057 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
82058
82059 if (end < start)
82060 return -EINVAL;
82061 +
82062 +#ifdef CONFIG_PAX_SEGMEXEC
82063 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82064 + if (end > SEGMEXEC_TASK_SIZE)
82065 + return -EINVAL;
82066 + } else
82067 +#endif
82068 +
82069 + if (end > TASK_SIZE)
82070 + return -EINVAL;
82071 +
82072 if (end == start)
82073 return 0;
82074
82075 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82076 */
82077 tcred = __task_cred(task);
82078 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82079 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82080 - !capable(CAP_SYS_NICE)) {
82081 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82082 rcu_read_unlock();
82083 err = -EPERM;
82084 goto out_put;
82085 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82086 goto out;
82087 }
82088
82089 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82090 + if (mm != current->mm &&
82091 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
82092 + mmput(mm);
82093 + err = -EPERM;
82094 + goto out;
82095 + }
82096 +#endif
82097 +
82098 err = do_migrate_pages(mm, old, new,
82099 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
82100
82101 diff --git a/mm/migrate.c b/mm/migrate.c
82102 index c04d9af..0b41805 100644
82103 --- a/mm/migrate.c
82104 +++ b/mm/migrate.c
82105 @@ -1395,8 +1395,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
82106 */
82107 tcred = __task_cred(task);
82108 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82109 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82110 - !capable(CAP_SYS_NICE)) {
82111 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82112 rcu_read_unlock();
82113 err = -EPERM;
82114 goto out;
82115 diff --git a/mm/mlock.c b/mm/mlock.c
82116 index 79b7cf7..9944291 100644
82117 --- a/mm/mlock.c
82118 +++ b/mm/mlock.c
82119 @@ -13,6 +13,7 @@
82120 #include <linux/pagemap.h>
82121 #include <linux/mempolicy.h>
82122 #include <linux/syscalls.h>
82123 +#include <linux/security.h>
82124 #include <linux/sched.h>
82125 #include <linux/export.h>
82126 #include <linux/rmap.h>
82127 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82128 {
82129 unsigned long nstart, end, tmp;
82130 struct vm_area_struct * vma, * prev;
82131 - int error;
82132 + int error = 0;
82133
82134 VM_BUG_ON(start & ~PAGE_MASK);
82135 VM_BUG_ON(len != PAGE_ALIGN(len));
82136 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82137 return -EINVAL;
82138 if (end == start)
82139 return 0;
82140 + if (end > TASK_SIZE)
82141 + return -EINVAL;
82142 +
82143 vma = find_vma(current->mm, start);
82144 if (!vma || vma->vm_start > start)
82145 return -ENOMEM;
82146 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82147 for (nstart = start ; ; ) {
82148 vm_flags_t newflags;
82149
82150 +#ifdef CONFIG_PAX_SEGMEXEC
82151 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82152 + break;
82153 +#endif
82154 +
82155 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82156
82157 newflags = vma->vm_flags & ~VM_LOCKED;
82158 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82159 lock_limit >>= PAGE_SHIFT;
82160
82161 /* check against resource limits */
82162 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82163 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82164 error = do_mlock(start, len, 1);
82165 up_write(&current->mm->mmap_sem);
82166 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
82167 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82168 vm_flags_t newflags;
82169
82170 +#ifdef CONFIG_PAX_SEGMEXEC
82171 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82172 + break;
82173 +#endif
82174 +
82175 newflags = vma->vm_flags & ~VM_LOCKED;
82176 if (flags & MCL_CURRENT)
82177 newflags |= VM_LOCKED;
82178 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82179 lock_limit >>= PAGE_SHIFT;
82180
82181 ret = -ENOMEM;
82182 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82183 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82184 capable(CAP_IPC_LOCK))
82185 ret = do_mlockall(flags);
82186 diff --git a/mm/mmap.c b/mm/mmap.c
82187 index 0dceed8..bfcaf45 100644
82188 --- a/mm/mmap.c
82189 +++ b/mm/mmap.c
82190 @@ -33,6 +33,7 @@
82191 #include <linux/uprobes.h>
82192 #include <linux/rbtree_augmented.h>
82193 #include <linux/sched/sysctl.h>
82194 +#include <linux/random.h>
82195
82196 #include <asm/uaccess.h>
82197 #include <asm/cacheflush.h>
82198 @@ -49,6 +50,16 @@
82199 #define arch_rebalance_pgtables(addr, len) (addr)
82200 #endif
82201
82202 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82203 +{
82204 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82205 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82206 + up_read(&mm->mmap_sem);
82207 + BUG();
82208 + }
82209 +#endif
82210 +}
82211 +
82212 static void unmap_region(struct mm_struct *mm,
82213 struct vm_area_struct *vma, struct vm_area_struct *prev,
82214 unsigned long start, unsigned long end);
82215 @@ -68,22 +79,32 @@ static void unmap_region(struct mm_struct *mm,
82216 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82217 *
82218 */
82219 -pgprot_t protection_map[16] = {
82220 +pgprot_t protection_map[16] __read_only = {
82221 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82222 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82223 };
82224
82225 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82226 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82227 {
82228 - return __pgprot(pgprot_val(protection_map[vm_flags &
82229 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82230 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82231 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82232 +
82233 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82234 + if (!(__supported_pte_mask & _PAGE_NX) &&
82235 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82236 + (vm_flags & (VM_READ | VM_WRITE)))
82237 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82238 +#endif
82239 +
82240 + return prot;
82241 }
82242 EXPORT_SYMBOL(vm_get_page_prot);
82243
82244 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
82245 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82246 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82247 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82248 /*
82249 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82250 * other variables. It can be updated by several CPUs frequently.
82251 @@ -239,6 +260,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82252 struct vm_area_struct *next = vma->vm_next;
82253
82254 might_sleep();
82255 + BUG_ON(vma->vm_mirror);
82256 if (vma->vm_ops && vma->vm_ops->close)
82257 vma->vm_ops->close(vma);
82258 if (vma->vm_file)
82259 @@ -283,6 +305,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82260 * not page aligned -Ram Gupta
82261 */
82262 rlim = rlimit(RLIMIT_DATA);
82263 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82264 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82265 (mm->end_data - mm->start_data) > rlim)
82266 goto out;
82267 @@ -897,6 +920,12 @@ static int
82268 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82269 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82270 {
82271 +
82272 +#ifdef CONFIG_PAX_SEGMEXEC
82273 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82274 + return 0;
82275 +#endif
82276 +
82277 if (is_mergeable_vma(vma, file, vm_flags) &&
82278 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82279 if (vma->vm_pgoff == vm_pgoff)
82280 @@ -916,6 +945,12 @@ static int
82281 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82282 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82283 {
82284 +
82285 +#ifdef CONFIG_PAX_SEGMEXEC
82286 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82287 + return 0;
82288 +#endif
82289 +
82290 if (is_mergeable_vma(vma, file, vm_flags) &&
82291 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82292 pgoff_t vm_pglen;
82293 @@ -958,13 +993,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82294 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82295 struct vm_area_struct *prev, unsigned long addr,
82296 unsigned long end, unsigned long vm_flags,
82297 - struct anon_vma *anon_vma, struct file *file,
82298 + struct anon_vma *anon_vma, struct file *file,
82299 pgoff_t pgoff, struct mempolicy *policy)
82300 {
82301 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82302 struct vm_area_struct *area, *next;
82303 int err;
82304
82305 +#ifdef CONFIG_PAX_SEGMEXEC
82306 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82307 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82308 +
82309 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82310 +#endif
82311 +
82312 /*
82313 * We later require that vma->vm_flags == vm_flags,
82314 * so this tests vma->vm_flags & VM_SPECIAL, too.
82315 @@ -980,6 +1022,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82316 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82317 next = next->vm_next;
82318
82319 +#ifdef CONFIG_PAX_SEGMEXEC
82320 + if (prev)
82321 + prev_m = pax_find_mirror_vma(prev);
82322 + if (area)
82323 + area_m = pax_find_mirror_vma(area);
82324 + if (next)
82325 + next_m = pax_find_mirror_vma(next);
82326 +#endif
82327 +
82328 /*
82329 * Can it merge with the predecessor?
82330 */
82331 @@ -999,9 +1050,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82332 /* cases 1, 6 */
82333 err = vma_adjust(prev, prev->vm_start,
82334 next->vm_end, prev->vm_pgoff, NULL);
82335 - } else /* cases 2, 5, 7 */
82336 +
82337 +#ifdef CONFIG_PAX_SEGMEXEC
82338 + if (!err && prev_m)
82339 + err = vma_adjust(prev_m, prev_m->vm_start,
82340 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82341 +#endif
82342 +
82343 + } else { /* cases 2, 5, 7 */
82344 err = vma_adjust(prev, prev->vm_start,
82345 end, prev->vm_pgoff, NULL);
82346 +
82347 +#ifdef CONFIG_PAX_SEGMEXEC
82348 + if (!err && prev_m)
82349 + err = vma_adjust(prev_m, prev_m->vm_start,
82350 + end_m, prev_m->vm_pgoff, NULL);
82351 +#endif
82352 +
82353 + }
82354 if (err)
82355 return NULL;
82356 khugepaged_enter_vma_merge(prev);
82357 @@ -1015,12 +1081,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82358 mpol_equal(policy, vma_policy(next)) &&
82359 can_vma_merge_before(next, vm_flags,
82360 anon_vma, file, pgoff+pglen)) {
82361 - if (prev && addr < prev->vm_end) /* case 4 */
82362 + if (prev && addr < prev->vm_end) { /* case 4 */
82363 err = vma_adjust(prev, prev->vm_start,
82364 addr, prev->vm_pgoff, NULL);
82365 - else /* cases 3, 8 */
82366 +
82367 +#ifdef CONFIG_PAX_SEGMEXEC
82368 + if (!err && prev_m)
82369 + err = vma_adjust(prev_m, prev_m->vm_start,
82370 + addr_m, prev_m->vm_pgoff, NULL);
82371 +#endif
82372 +
82373 + } else { /* cases 3, 8 */
82374 err = vma_adjust(area, addr, next->vm_end,
82375 next->vm_pgoff - pglen, NULL);
82376 +
82377 +#ifdef CONFIG_PAX_SEGMEXEC
82378 + if (!err && area_m)
82379 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82380 + next_m->vm_pgoff - pglen, NULL);
82381 +#endif
82382 +
82383 + }
82384 if (err)
82385 return NULL;
82386 khugepaged_enter_vma_merge(area);
82387 @@ -1129,8 +1210,10 @@ none:
82388 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82389 struct file *file, long pages)
82390 {
82391 - const unsigned long stack_flags
82392 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82393 +
82394 +#ifdef CONFIG_PAX_RANDMMAP
82395 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82396 +#endif
82397
82398 mm->total_vm += pages;
82399
82400 @@ -1138,7 +1221,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82401 mm->shared_vm += pages;
82402 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82403 mm->exec_vm += pages;
82404 - } else if (flags & stack_flags)
82405 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82406 mm->stack_vm += pages;
82407 }
82408 #endif /* CONFIG_PROC_FS */
82409 @@ -1177,7 +1260,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82410 * (the exception is when the underlying filesystem is noexec
82411 * mounted, in which case we dont add PROT_EXEC.)
82412 */
82413 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82414 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82415 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82416 prot |= PROT_EXEC;
82417
82418 @@ -1203,7 +1286,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82419 /* Obtain the address to map to. we verify (or select) it and ensure
82420 * that it represents a valid section of the address space.
82421 */
82422 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82423 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82424 if (addr & ~PAGE_MASK)
82425 return addr;
82426
82427 @@ -1214,6 +1297,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82428 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82429 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82430
82431 +#ifdef CONFIG_PAX_MPROTECT
82432 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82433 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82434 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82435 + gr_log_rwxmmap(file);
82436 +
82437 +#ifdef CONFIG_PAX_EMUPLT
82438 + vm_flags &= ~VM_EXEC;
82439 +#else
82440 + return -EPERM;
82441 +#endif
82442 +
82443 + }
82444 +
82445 + if (!(vm_flags & VM_EXEC))
82446 + vm_flags &= ~VM_MAYEXEC;
82447 +#else
82448 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82449 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82450 +#endif
82451 + else
82452 + vm_flags &= ~VM_MAYWRITE;
82453 + }
82454 +#endif
82455 +
82456 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82457 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82458 + vm_flags &= ~VM_PAGEEXEC;
82459 +#endif
82460 +
82461 if (flags & MAP_LOCKED)
82462 if (!can_do_mlock())
82463 return -EPERM;
82464 @@ -1225,6 +1338,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82465 locked += mm->locked_vm;
82466 lock_limit = rlimit(RLIMIT_MEMLOCK);
82467 lock_limit >>= PAGE_SHIFT;
82468 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82469 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82470 return -EAGAIN;
82471 }
82472 @@ -1305,6 +1419,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82473 vm_flags |= VM_NORESERVE;
82474 }
82475
82476 + if (!gr_acl_handle_mmap(file, prot))
82477 + return -EACCES;
82478 +
82479 addr = mmap_region(file, addr, len, vm_flags, pgoff);
82480 if (!IS_ERR_VALUE(addr) &&
82481 ((vm_flags & VM_LOCKED) ||
82482 @@ -1396,7 +1513,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82483 vm_flags_t vm_flags = vma->vm_flags;
82484
82485 /* If it was private or non-writable, the write bit is already clear */
82486 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82487 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82488 return 0;
82489
82490 /* The backer wishes to know when pages are first written to? */
82491 @@ -1444,16 +1561,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82492 unsigned long charged = 0;
82493 struct inode *inode = file ? file_inode(file) : NULL;
82494
82495 +#ifdef CONFIG_PAX_SEGMEXEC
82496 + struct vm_area_struct *vma_m = NULL;
82497 +#endif
82498 +
82499 + /*
82500 + * mm->mmap_sem is required to protect against another thread
82501 + * changing the mappings in case we sleep.
82502 + */
82503 + verify_mm_writelocked(mm);
82504 +
82505 /* Clear old maps */
82506 error = -ENOMEM;
82507 -munmap_back:
82508 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82509 if (do_munmap(mm, addr, len))
82510 return -ENOMEM;
82511 - goto munmap_back;
82512 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82513 }
82514
82515 /* Check against address space limit. */
82516 +
82517 +#ifdef CONFIG_PAX_RANDMMAP
82518 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82519 +#endif
82520 +
82521 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82522 return -ENOMEM;
82523
82524 @@ -1485,6 +1616,16 @@ munmap_back:
82525 goto unacct_error;
82526 }
82527
82528 +#ifdef CONFIG_PAX_SEGMEXEC
82529 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82530 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82531 + if (!vma_m) {
82532 + error = -ENOMEM;
82533 + goto free_vma;
82534 + }
82535 + }
82536 +#endif
82537 +
82538 vma->vm_mm = mm;
82539 vma->vm_start = addr;
82540 vma->vm_end = addr + len;
82541 @@ -1509,6 +1650,13 @@ munmap_back:
82542 if (error)
82543 goto unmap_and_free_vma;
82544
82545 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82546 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82547 + vma->vm_flags |= VM_PAGEEXEC;
82548 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82549 + }
82550 +#endif
82551 +
82552 /* Can addr have changed??
82553 *
82554 * Answer: Yes, several device drivers can do it in their
82555 @@ -1547,6 +1695,11 @@ munmap_back:
82556 vma_link(mm, vma, prev, rb_link, rb_parent);
82557 file = vma->vm_file;
82558
82559 +#ifdef CONFIG_PAX_SEGMEXEC
82560 + if (vma_m)
82561 + BUG_ON(pax_mirror_vma(vma_m, vma));
82562 +#endif
82563 +
82564 /* Once vma denies write, undo our temporary denial count */
82565 if (correct_wcount)
82566 atomic_inc(&inode->i_writecount);
82567 @@ -1554,6 +1707,7 @@ out:
82568 perf_event_mmap(vma);
82569
82570 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82571 + track_exec_limit(mm, addr, addr + len, vm_flags);
82572 if (vm_flags & VM_LOCKED) {
82573 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
82574 vma == get_gate_vma(current->mm)))
82575 @@ -1577,6 +1731,12 @@ unmap_and_free_vma:
82576 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82577 charged = 0;
82578 free_vma:
82579 +
82580 +#ifdef CONFIG_PAX_SEGMEXEC
82581 + if (vma_m)
82582 + kmem_cache_free(vm_area_cachep, vma_m);
82583 +#endif
82584 +
82585 kmem_cache_free(vm_area_cachep, vma);
82586 unacct_error:
82587 if (charged)
82588 @@ -1584,7 +1744,63 @@ unacct_error:
82589 return error;
82590 }
82591
82592 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82593 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82594 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82595 +{
82596 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82597 + return (random32() & 0xFF) << PAGE_SHIFT;
82598 +
82599 + return 0;
82600 +}
82601 +#endif
82602 +
82603 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82604 +{
82605 + if (!vma) {
82606 +#ifdef CONFIG_STACK_GROWSUP
82607 + if (addr > sysctl_heap_stack_gap)
82608 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82609 + else
82610 + vma = find_vma(current->mm, 0);
82611 + if (vma && (vma->vm_flags & VM_GROWSUP))
82612 + return false;
82613 +#endif
82614 + return true;
82615 + }
82616 +
82617 + if (addr + len > vma->vm_start)
82618 + return false;
82619 +
82620 + if (vma->vm_flags & VM_GROWSDOWN)
82621 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82622 +#ifdef CONFIG_STACK_GROWSUP
82623 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82624 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82625 +#endif
82626 + else if (offset)
82627 + return offset <= vma->vm_start - addr - len;
82628 +
82629 + return true;
82630 +}
82631 +
82632 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82633 +{
82634 + if (vma->vm_start < len)
82635 + return -ENOMEM;
82636 +
82637 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82638 + if (offset <= vma->vm_start - len)
82639 + return vma->vm_start - len - offset;
82640 + else
82641 + return -ENOMEM;
82642 + }
82643 +
82644 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82645 + return vma->vm_start - len - sysctl_heap_stack_gap;
82646 + return -ENOMEM;
82647 +}
82648 +
82649 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
82650 {
82651 /*
82652 * We implement the search by looking for an rbtree node that
82653 @@ -1632,11 +1848,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82654 }
82655 }
82656
82657 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
82658 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
82659 check_current:
82660 /* Check if current node has a suitable gap */
82661 if (gap_start > high_limit)
82662 return -ENOMEM;
82663 +
82664 + if (gap_end - gap_start > info->threadstack_offset)
82665 + gap_start += info->threadstack_offset;
82666 + else
82667 + gap_start = gap_end;
82668 +
82669 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
82670 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82671 + gap_start += sysctl_heap_stack_gap;
82672 + else
82673 + gap_start = gap_end;
82674 + }
82675 + if (vma->vm_flags & VM_GROWSDOWN) {
82676 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82677 + gap_end -= sysctl_heap_stack_gap;
82678 + else
82679 + gap_end = gap_start;
82680 + }
82681 if (gap_end >= low_limit && gap_end - gap_start >= length)
82682 goto found;
82683
82684 @@ -1686,7 +1920,7 @@ found:
82685 return gap_start;
82686 }
82687
82688 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
82689 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
82690 {
82691 struct mm_struct *mm = current->mm;
82692 struct vm_area_struct *vma;
82693 @@ -1740,6 +1974,24 @@ check_current:
82694 gap_end = vma->vm_start;
82695 if (gap_end < low_limit)
82696 return -ENOMEM;
82697 +
82698 + if (gap_end - gap_start > info->threadstack_offset)
82699 + gap_end -= info->threadstack_offset;
82700 + else
82701 + gap_end = gap_start;
82702 +
82703 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
82704 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82705 + gap_start += sysctl_heap_stack_gap;
82706 + else
82707 + gap_start = gap_end;
82708 + }
82709 + if (vma->vm_flags & VM_GROWSDOWN) {
82710 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82711 + gap_end -= sysctl_heap_stack_gap;
82712 + else
82713 + gap_end = gap_start;
82714 + }
82715 if (gap_start <= high_limit && gap_end - gap_start >= length)
82716 goto found;
82717
82718 @@ -1803,6 +2055,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82719 struct mm_struct *mm = current->mm;
82720 struct vm_area_struct *vma;
82721 struct vm_unmapped_area_info info;
82722 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82723
82724 if (len > TASK_SIZE)
82725 return -ENOMEM;
82726 @@ -1810,29 +2063,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82727 if (flags & MAP_FIXED)
82728 return addr;
82729
82730 +#ifdef CONFIG_PAX_RANDMMAP
82731 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82732 +#endif
82733 +
82734 if (addr) {
82735 addr = PAGE_ALIGN(addr);
82736 vma = find_vma(mm, addr);
82737 - if (TASK_SIZE - len >= addr &&
82738 - (!vma || addr + len <= vma->vm_start))
82739 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82740 return addr;
82741 }
82742
82743 info.flags = 0;
82744 info.length = len;
82745 info.low_limit = TASK_UNMAPPED_BASE;
82746 +
82747 +#ifdef CONFIG_PAX_RANDMMAP
82748 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82749 + info.low_limit += mm->delta_mmap;
82750 +#endif
82751 +
82752 info.high_limit = TASK_SIZE;
82753 info.align_mask = 0;
82754 + info.threadstack_offset = offset;
82755 return vm_unmapped_area(&info);
82756 }
82757 #endif
82758
82759 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82760 {
82761 +
82762 +#ifdef CONFIG_PAX_SEGMEXEC
82763 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82764 + return;
82765 +#endif
82766 +
82767 /*
82768 * Is this a new hole at the lowest possible address?
82769 */
82770 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82771 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82772 mm->free_area_cache = addr;
82773 }
82774
82775 @@ -1850,6 +2119,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82776 struct mm_struct *mm = current->mm;
82777 unsigned long addr = addr0;
82778 struct vm_unmapped_area_info info;
82779 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82780
82781 /* requested length too big for entire address space */
82782 if (len > TASK_SIZE)
82783 @@ -1858,12 +2128,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82784 if (flags & MAP_FIXED)
82785 return addr;
82786
82787 +#ifdef CONFIG_PAX_RANDMMAP
82788 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82789 +#endif
82790 +
82791 /* requesting a specific address */
82792 if (addr) {
82793 addr = PAGE_ALIGN(addr);
82794 vma = find_vma(mm, addr);
82795 - if (TASK_SIZE - len >= addr &&
82796 - (!vma || addr + len <= vma->vm_start))
82797 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82798 return addr;
82799 }
82800
82801 @@ -1872,6 +2145,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82802 info.low_limit = PAGE_SIZE;
82803 info.high_limit = mm->mmap_base;
82804 info.align_mask = 0;
82805 + info.threadstack_offset = offset;
82806 addr = vm_unmapped_area(&info);
82807
82808 /*
82809 @@ -1884,6 +2158,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82810 VM_BUG_ON(addr != -ENOMEM);
82811 info.flags = 0;
82812 info.low_limit = TASK_UNMAPPED_BASE;
82813 +
82814 +#ifdef CONFIG_PAX_RANDMMAP
82815 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82816 + info.low_limit += mm->delta_mmap;
82817 +#endif
82818 +
82819 info.high_limit = TASK_SIZE;
82820 addr = vm_unmapped_area(&info);
82821 }
82822 @@ -1894,6 +2174,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82823
82824 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82825 {
82826 +
82827 +#ifdef CONFIG_PAX_SEGMEXEC
82828 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82829 + return;
82830 +#endif
82831 +
82832 /*
82833 * Is this a new hole at the highest possible address?
82834 */
82835 @@ -1901,8 +2187,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82836 mm->free_area_cache = addr;
82837
82838 /* dont allow allocations above current base */
82839 - if (mm->free_area_cache > mm->mmap_base)
82840 + if (mm->free_area_cache > mm->mmap_base) {
82841 mm->free_area_cache = mm->mmap_base;
82842 + mm->cached_hole_size = ~0UL;
82843 + }
82844 }
82845
82846 unsigned long
82847 @@ -2001,6 +2289,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82848 return vma;
82849 }
82850
82851 +#ifdef CONFIG_PAX_SEGMEXEC
82852 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82853 +{
82854 + struct vm_area_struct *vma_m;
82855 +
82856 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82857 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82858 + BUG_ON(vma->vm_mirror);
82859 + return NULL;
82860 + }
82861 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82862 + vma_m = vma->vm_mirror;
82863 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82864 + BUG_ON(vma->vm_file != vma_m->vm_file);
82865 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82866 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82867 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82868 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82869 + return vma_m;
82870 +}
82871 +#endif
82872 +
82873 /*
82874 * Verify that the stack growth is acceptable and
82875 * update accounting. This is shared with both the
82876 @@ -2017,6 +2327,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82877 return -ENOMEM;
82878
82879 /* Stack limit test */
82880 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82881 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82882 return -ENOMEM;
82883
82884 @@ -2027,6 +2338,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82885 locked = mm->locked_vm + grow;
82886 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82887 limit >>= PAGE_SHIFT;
82888 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82889 if (locked > limit && !capable(CAP_IPC_LOCK))
82890 return -ENOMEM;
82891 }
82892 @@ -2056,37 +2368,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82893 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82894 * vma is the last one with address > vma->vm_end. Have to extend vma.
82895 */
82896 +#ifndef CONFIG_IA64
82897 +static
82898 +#endif
82899 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82900 {
82901 int error;
82902 + bool locknext;
82903
82904 if (!(vma->vm_flags & VM_GROWSUP))
82905 return -EFAULT;
82906
82907 + /* Also guard against wrapping around to address 0. */
82908 + if (address < PAGE_ALIGN(address+1))
82909 + address = PAGE_ALIGN(address+1);
82910 + else
82911 + return -ENOMEM;
82912 +
82913 /*
82914 * We must make sure the anon_vma is allocated
82915 * so that the anon_vma locking is not a noop.
82916 */
82917 if (unlikely(anon_vma_prepare(vma)))
82918 return -ENOMEM;
82919 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82920 + if (locknext && anon_vma_prepare(vma->vm_next))
82921 + return -ENOMEM;
82922 vma_lock_anon_vma(vma);
82923 + if (locknext)
82924 + vma_lock_anon_vma(vma->vm_next);
82925
82926 /*
82927 * vma->vm_start/vm_end cannot change under us because the caller
82928 * is required to hold the mmap_sem in read mode. We need the
82929 - * anon_vma lock to serialize against concurrent expand_stacks.
82930 - * Also guard against wrapping around to address 0.
82931 + * anon_vma locks to serialize against concurrent expand_stacks
82932 + * and expand_upwards.
82933 */
82934 - if (address < PAGE_ALIGN(address+4))
82935 - address = PAGE_ALIGN(address+4);
82936 - else {
82937 - vma_unlock_anon_vma(vma);
82938 - return -ENOMEM;
82939 - }
82940 error = 0;
82941
82942 /* Somebody else might have raced and expanded it already */
82943 - if (address > vma->vm_end) {
82944 + 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)
82945 + error = -ENOMEM;
82946 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82947 unsigned long size, grow;
82948
82949 size = address - vma->vm_start;
82950 @@ -2121,6 +2444,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82951 }
82952 }
82953 }
82954 + if (locknext)
82955 + vma_unlock_anon_vma(vma->vm_next);
82956 vma_unlock_anon_vma(vma);
82957 khugepaged_enter_vma_merge(vma);
82958 validate_mm(vma->vm_mm);
82959 @@ -2135,6 +2460,8 @@ int expand_downwards(struct vm_area_struct *vma,
82960 unsigned long address)
82961 {
82962 int error;
82963 + bool lockprev = false;
82964 + struct vm_area_struct *prev;
82965
82966 /*
82967 * We must make sure the anon_vma is allocated
82968 @@ -2148,6 +2475,15 @@ int expand_downwards(struct vm_area_struct *vma,
82969 if (error)
82970 return error;
82971
82972 + prev = vma->vm_prev;
82973 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82974 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82975 +#endif
82976 + if (lockprev && anon_vma_prepare(prev))
82977 + return -ENOMEM;
82978 + if (lockprev)
82979 + vma_lock_anon_vma(prev);
82980 +
82981 vma_lock_anon_vma(vma);
82982
82983 /*
82984 @@ -2157,9 +2493,17 @@ int expand_downwards(struct vm_area_struct *vma,
82985 */
82986
82987 /* Somebody else might have raced and expanded it already */
82988 - if (address < vma->vm_start) {
82989 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82990 + error = -ENOMEM;
82991 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82992 unsigned long size, grow;
82993
82994 +#ifdef CONFIG_PAX_SEGMEXEC
82995 + struct vm_area_struct *vma_m;
82996 +
82997 + vma_m = pax_find_mirror_vma(vma);
82998 +#endif
82999 +
83000 size = vma->vm_end - address;
83001 grow = (vma->vm_start - address) >> PAGE_SHIFT;
83002
83003 @@ -2184,13 +2528,27 @@ int expand_downwards(struct vm_area_struct *vma,
83004 vma->vm_pgoff -= grow;
83005 anon_vma_interval_tree_post_update_vma(vma);
83006 vma_gap_update(vma);
83007 +
83008 +#ifdef CONFIG_PAX_SEGMEXEC
83009 + if (vma_m) {
83010 + anon_vma_interval_tree_pre_update_vma(vma_m);
83011 + vma_m->vm_start -= grow << PAGE_SHIFT;
83012 + vma_m->vm_pgoff -= grow;
83013 + anon_vma_interval_tree_post_update_vma(vma_m);
83014 + vma_gap_update(vma_m);
83015 + }
83016 +#endif
83017 +
83018 spin_unlock(&vma->vm_mm->page_table_lock);
83019
83020 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
83021 perf_event_mmap(vma);
83022 }
83023 }
83024 }
83025 vma_unlock_anon_vma(vma);
83026 + if (lockprev)
83027 + vma_unlock_anon_vma(prev);
83028 khugepaged_enter_vma_merge(vma);
83029 validate_mm(vma->vm_mm);
83030 return error;
83031 @@ -2288,6 +2646,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
83032 do {
83033 long nrpages = vma_pages(vma);
83034
83035 +#ifdef CONFIG_PAX_SEGMEXEC
83036 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
83037 + vma = remove_vma(vma);
83038 + continue;
83039 + }
83040 +#endif
83041 +
83042 if (vma->vm_flags & VM_ACCOUNT)
83043 nr_accounted += nrpages;
83044 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
83045 @@ -2333,6 +2698,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
83046 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
83047 vma->vm_prev = NULL;
83048 do {
83049 +
83050 +#ifdef CONFIG_PAX_SEGMEXEC
83051 + if (vma->vm_mirror) {
83052 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
83053 + vma->vm_mirror->vm_mirror = NULL;
83054 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
83055 + vma->vm_mirror = NULL;
83056 + }
83057 +#endif
83058 +
83059 vma_rb_erase(vma, &mm->mm_rb);
83060 mm->map_count--;
83061 tail_vma = vma;
83062 @@ -2364,14 +2739,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83063 struct vm_area_struct *new;
83064 int err = -ENOMEM;
83065
83066 +#ifdef CONFIG_PAX_SEGMEXEC
83067 + struct vm_area_struct *vma_m, *new_m = NULL;
83068 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
83069 +#endif
83070 +
83071 if (is_vm_hugetlb_page(vma) && (addr &
83072 ~(huge_page_mask(hstate_vma(vma)))))
83073 return -EINVAL;
83074
83075 +#ifdef CONFIG_PAX_SEGMEXEC
83076 + vma_m = pax_find_mirror_vma(vma);
83077 +#endif
83078 +
83079 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83080 if (!new)
83081 goto out_err;
83082
83083 +#ifdef CONFIG_PAX_SEGMEXEC
83084 + if (vma_m) {
83085 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83086 + if (!new_m) {
83087 + kmem_cache_free(vm_area_cachep, new);
83088 + goto out_err;
83089 + }
83090 + }
83091 +#endif
83092 +
83093 /* most fields are the same, copy all, and then fixup */
83094 *new = *vma;
83095
83096 @@ -2384,6 +2778,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83097 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
83098 }
83099
83100 +#ifdef CONFIG_PAX_SEGMEXEC
83101 + if (vma_m) {
83102 + *new_m = *vma_m;
83103 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
83104 + new_m->vm_mirror = new;
83105 + new->vm_mirror = new_m;
83106 +
83107 + if (new_below)
83108 + new_m->vm_end = addr_m;
83109 + else {
83110 + new_m->vm_start = addr_m;
83111 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
83112 + }
83113 + }
83114 +#endif
83115 +
83116 pol = mpol_dup(vma_policy(vma));
83117 if (IS_ERR(pol)) {
83118 err = PTR_ERR(pol);
83119 @@ -2406,6 +2816,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83120 else
83121 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
83122
83123 +#ifdef CONFIG_PAX_SEGMEXEC
83124 + if (!err && vma_m) {
83125 + if (anon_vma_clone(new_m, vma_m))
83126 + goto out_free_mpol;
83127 +
83128 + mpol_get(pol);
83129 + vma_set_policy(new_m, pol);
83130 +
83131 + if (new_m->vm_file)
83132 + get_file(new_m->vm_file);
83133 +
83134 + if (new_m->vm_ops && new_m->vm_ops->open)
83135 + new_m->vm_ops->open(new_m);
83136 +
83137 + if (new_below)
83138 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
83139 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
83140 + else
83141 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
83142 +
83143 + if (err) {
83144 + if (new_m->vm_ops && new_m->vm_ops->close)
83145 + new_m->vm_ops->close(new_m);
83146 + if (new_m->vm_file)
83147 + fput(new_m->vm_file);
83148 + mpol_put(pol);
83149 + }
83150 + }
83151 +#endif
83152 +
83153 /* Success. */
83154 if (!err)
83155 return 0;
83156 @@ -2415,10 +2855,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83157 new->vm_ops->close(new);
83158 if (new->vm_file)
83159 fput(new->vm_file);
83160 - unlink_anon_vmas(new);
83161 out_free_mpol:
83162 mpol_put(pol);
83163 out_free_vma:
83164 +
83165 +#ifdef CONFIG_PAX_SEGMEXEC
83166 + if (new_m) {
83167 + unlink_anon_vmas(new_m);
83168 + kmem_cache_free(vm_area_cachep, new_m);
83169 + }
83170 +#endif
83171 +
83172 + unlink_anon_vmas(new);
83173 kmem_cache_free(vm_area_cachep, new);
83174 out_err:
83175 return err;
83176 @@ -2431,6 +2879,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83177 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83178 unsigned long addr, int new_below)
83179 {
83180 +
83181 +#ifdef CONFIG_PAX_SEGMEXEC
83182 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83183 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
83184 + if (mm->map_count >= sysctl_max_map_count-1)
83185 + return -ENOMEM;
83186 + } else
83187 +#endif
83188 +
83189 if (mm->map_count >= sysctl_max_map_count)
83190 return -ENOMEM;
83191
83192 @@ -2442,11 +2899,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83193 * work. This now handles partial unmappings.
83194 * Jeremy Fitzhardinge <jeremy@goop.org>
83195 */
83196 +#ifdef CONFIG_PAX_SEGMEXEC
83197 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83198 {
83199 + int ret = __do_munmap(mm, start, len);
83200 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
83201 + return ret;
83202 +
83203 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
83204 +}
83205 +
83206 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83207 +#else
83208 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83209 +#endif
83210 +{
83211 unsigned long end;
83212 struct vm_area_struct *vma, *prev, *last;
83213
83214 + /*
83215 + * mm->mmap_sem is required to protect against another thread
83216 + * changing the mappings in case we sleep.
83217 + */
83218 + verify_mm_writelocked(mm);
83219 +
83220 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83221 return -EINVAL;
83222
83223 @@ -2521,6 +2997,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83224 /* Fix up all other VM information */
83225 remove_vma_list(mm, vma);
83226
83227 + track_exec_limit(mm, start, end, 0UL);
83228 +
83229 return 0;
83230 }
83231
83232 @@ -2529,6 +3007,13 @@ int vm_munmap(unsigned long start, size_t len)
83233 int ret;
83234 struct mm_struct *mm = current->mm;
83235
83236 +
83237 +#ifdef CONFIG_PAX_SEGMEXEC
83238 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83239 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83240 + return -EINVAL;
83241 +#endif
83242 +
83243 down_write(&mm->mmap_sem);
83244 ret = do_munmap(mm, start, len);
83245 up_write(&mm->mmap_sem);
83246 @@ -2542,16 +3027,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83247 return vm_munmap(addr, len);
83248 }
83249
83250 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83251 -{
83252 -#ifdef CONFIG_DEBUG_VM
83253 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83254 - WARN_ON(1);
83255 - up_read(&mm->mmap_sem);
83256 - }
83257 -#endif
83258 -}
83259 -
83260 /*
83261 * this is really a simplified "do_mmap". it only handles
83262 * anonymous maps. eventually we may be able to do some
83263 @@ -2565,6 +3040,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83264 struct rb_node ** rb_link, * rb_parent;
83265 pgoff_t pgoff = addr >> PAGE_SHIFT;
83266 int error;
83267 + unsigned long charged;
83268
83269 len = PAGE_ALIGN(len);
83270 if (!len)
83271 @@ -2572,16 +3048,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83272
83273 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83274
83275 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83276 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83277 + flags &= ~VM_EXEC;
83278 +
83279 +#ifdef CONFIG_PAX_MPROTECT
83280 + if (mm->pax_flags & MF_PAX_MPROTECT)
83281 + flags &= ~VM_MAYEXEC;
83282 +#endif
83283 +
83284 + }
83285 +#endif
83286 +
83287 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83288 if (error & ~PAGE_MASK)
83289 return error;
83290
83291 + charged = len >> PAGE_SHIFT;
83292 +
83293 /*
83294 * mlock MCL_FUTURE?
83295 */
83296 if (mm->def_flags & VM_LOCKED) {
83297 unsigned long locked, lock_limit;
83298 - locked = len >> PAGE_SHIFT;
83299 + locked = charged;
83300 locked += mm->locked_vm;
83301 lock_limit = rlimit(RLIMIT_MEMLOCK);
83302 lock_limit >>= PAGE_SHIFT;
83303 @@ -2598,21 +3088,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83304 /*
83305 * Clear old maps. this also does some error checking for us
83306 */
83307 - munmap_back:
83308 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83309 if (do_munmap(mm, addr, len))
83310 return -ENOMEM;
83311 - goto munmap_back;
83312 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83313 }
83314
83315 /* Check against address space limits *after* clearing old maps... */
83316 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83317 + if (!may_expand_vm(mm, charged))
83318 return -ENOMEM;
83319
83320 if (mm->map_count > sysctl_max_map_count)
83321 return -ENOMEM;
83322
83323 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83324 + if (security_vm_enough_memory_mm(mm, charged))
83325 return -ENOMEM;
83326
83327 /* Can we just expand an old private anonymous mapping? */
83328 @@ -2626,7 +3115,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83329 */
83330 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83331 if (!vma) {
83332 - vm_unacct_memory(len >> PAGE_SHIFT);
83333 + vm_unacct_memory(charged);
83334 return -ENOMEM;
83335 }
83336
83337 @@ -2640,9 +3129,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83338 vma_link(mm, vma, prev, rb_link, rb_parent);
83339 out:
83340 perf_event_mmap(vma);
83341 - mm->total_vm += len >> PAGE_SHIFT;
83342 + mm->total_vm += charged;
83343 if (flags & VM_LOCKED)
83344 - mm->locked_vm += (len >> PAGE_SHIFT);
83345 + mm->locked_vm += charged;
83346 + track_exec_limit(mm, addr, addr + len, flags);
83347 return addr;
83348 }
83349
83350 @@ -2704,6 +3194,7 @@ void exit_mmap(struct mm_struct *mm)
83351 while (vma) {
83352 if (vma->vm_flags & VM_ACCOUNT)
83353 nr_accounted += vma_pages(vma);
83354 + vma->vm_mirror = NULL;
83355 vma = remove_vma(vma);
83356 }
83357 vm_unacct_memory(nr_accounted);
83358 @@ -2720,6 +3211,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83359 struct vm_area_struct *prev;
83360 struct rb_node **rb_link, *rb_parent;
83361
83362 +#ifdef CONFIG_PAX_SEGMEXEC
83363 + struct vm_area_struct *vma_m = NULL;
83364 +#endif
83365 +
83366 + if (security_mmap_addr(vma->vm_start))
83367 + return -EPERM;
83368 +
83369 /*
83370 * The vm_pgoff of a purely anonymous vma should be irrelevant
83371 * until its first write fault, when page's anon_vma and index
83372 @@ -2743,7 +3241,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83373 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83374 return -ENOMEM;
83375
83376 +#ifdef CONFIG_PAX_SEGMEXEC
83377 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83378 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83379 + if (!vma_m)
83380 + return -ENOMEM;
83381 + }
83382 +#endif
83383 +
83384 vma_link(mm, vma, prev, rb_link, rb_parent);
83385 +
83386 +#ifdef CONFIG_PAX_SEGMEXEC
83387 + if (vma_m)
83388 + BUG_ON(pax_mirror_vma(vma_m, vma));
83389 +#endif
83390 +
83391 return 0;
83392 }
83393
83394 @@ -2763,6 +3275,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83395 struct mempolicy *pol;
83396 bool faulted_in_anon_vma = true;
83397
83398 + BUG_ON(vma->vm_mirror);
83399 +
83400 /*
83401 * If anonymous vma has not yet been faulted, update new pgoff
83402 * to match new location, to increase its chance of merging.
83403 @@ -2829,6 +3343,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83404 return NULL;
83405 }
83406
83407 +#ifdef CONFIG_PAX_SEGMEXEC
83408 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83409 +{
83410 + struct vm_area_struct *prev_m;
83411 + struct rb_node **rb_link_m, *rb_parent_m;
83412 + struct mempolicy *pol_m;
83413 +
83414 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83415 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83416 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83417 + *vma_m = *vma;
83418 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83419 + if (anon_vma_clone(vma_m, vma))
83420 + return -ENOMEM;
83421 + pol_m = vma_policy(vma_m);
83422 + mpol_get(pol_m);
83423 + vma_set_policy(vma_m, pol_m);
83424 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83425 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83426 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83427 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83428 + if (vma_m->vm_file)
83429 + get_file(vma_m->vm_file);
83430 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83431 + vma_m->vm_ops->open(vma_m);
83432 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83433 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83434 + vma_m->vm_mirror = vma;
83435 + vma->vm_mirror = vma_m;
83436 + return 0;
83437 +}
83438 +#endif
83439 +
83440 /*
83441 * Return true if the calling process may expand its vm space by the passed
83442 * number of pages
83443 @@ -2840,6 +3387,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83444
83445 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83446
83447 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83448 if (cur + npages > lim)
83449 return 0;
83450 return 1;
83451 @@ -2910,6 +3458,22 @@ int install_special_mapping(struct mm_struct *mm,
83452 vma->vm_start = addr;
83453 vma->vm_end = addr + len;
83454
83455 +#ifdef CONFIG_PAX_MPROTECT
83456 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83457 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83458 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83459 + return -EPERM;
83460 + if (!(vm_flags & VM_EXEC))
83461 + vm_flags &= ~VM_MAYEXEC;
83462 +#else
83463 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83464 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83465 +#endif
83466 + else
83467 + vm_flags &= ~VM_MAYWRITE;
83468 + }
83469 +#endif
83470 +
83471 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83472 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83473
83474 diff --git a/mm/mprotect.c b/mm/mprotect.c
83475 index 94722a4..07d9926 100644
83476 --- a/mm/mprotect.c
83477 +++ b/mm/mprotect.c
83478 @@ -23,10 +23,18 @@
83479 #include <linux/mmu_notifier.h>
83480 #include <linux/migrate.h>
83481 #include <linux/perf_event.h>
83482 +#include <linux/sched/sysctl.h>
83483 +
83484 +#ifdef CONFIG_PAX_MPROTECT
83485 +#include <linux/elf.h>
83486 +#include <linux/binfmts.h>
83487 +#endif
83488 +
83489 #include <asm/uaccess.h>
83490 #include <asm/pgtable.h>
83491 #include <asm/cacheflush.h>
83492 #include <asm/tlbflush.h>
83493 +#include <asm/mmu_context.h>
83494
83495 #ifndef pgprot_modify
83496 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83497 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83498 return pages;
83499 }
83500
83501 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83502 +/* called while holding the mmap semaphor for writing except stack expansion */
83503 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83504 +{
83505 + unsigned long oldlimit, newlimit = 0UL;
83506 +
83507 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83508 + return;
83509 +
83510 + spin_lock(&mm->page_table_lock);
83511 + oldlimit = mm->context.user_cs_limit;
83512 + if ((prot & VM_EXEC) && oldlimit < end)
83513 + /* USER_CS limit moved up */
83514 + newlimit = end;
83515 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83516 + /* USER_CS limit moved down */
83517 + newlimit = start;
83518 +
83519 + if (newlimit) {
83520 + mm->context.user_cs_limit = newlimit;
83521 +
83522 +#ifdef CONFIG_SMP
83523 + wmb();
83524 + cpus_clear(mm->context.cpu_user_cs_mask);
83525 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83526 +#endif
83527 +
83528 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83529 + }
83530 + spin_unlock(&mm->page_table_lock);
83531 + if (newlimit == end) {
83532 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83533 +
83534 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83535 + if (is_vm_hugetlb_page(vma))
83536 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83537 + else
83538 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83539 + }
83540 +}
83541 +#endif
83542 +
83543 int
83544 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83545 unsigned long start, unsigned long end, unsigned long newflags)
83546 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83547 int error;
83548 int dirty_accountable = 0;
83549
83550 +#ifdef CONFIG_PAX_SEGMEXEC
83551 + struct vm_area_struct *vma_m = NULL;
83552 + unsigned long start_m, end_m;
83553 +
83554 + start_m = start + SEGMEXEC_TASK_SIZE;
83555 + end_m = end + SEGMEXEC_TASK_SIZE;
83556 +#endif
83557 +
83558 if (newflags == oldflags) {
83559 *pprev = vma;
83560 return 0;
83561 }
83562
83563 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83564 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83565 +
83566 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83567 + return -ENOMEM;
83568 +
83569 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83570 + return -ENOMEM;
83571 + }
83572 +
83573 /*
83574 * If we make a private mapping writable we increase our commit;
83575 * but (without finer accounting) cannot reduce our commit if we
83576 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83577 }
83578 }
83579
83580 +#ifdef CONFIG_PAX_SEGMEXEC
83581 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83582 + if (start != vma->vm_start) {
83583 + error = split_vma(mm, vma, start, 1);
83584 + if (error)
83585 + goto fail;
83586 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83587 + *pprev = (*pprev)->vm_next;
83588 + }
83589 +
83590 + if (end != vma->vm_end) {
83591 + error = split_vma(mm, vma, end, 0);
83592 + if (error)
83593 + goto fail;
83594 + }
83595 +
83596 + if (pax_find_mirror_vma(vma)) {
83597 + error = __do_munmap(mm, start_m, end_m - start_m);
83598 + if (error)
83599 + goto fail;
83600 + } else {
83601 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83602 + if (!vma_m) {
83603 + error = -ENOMEM;
83604 + goto fail;
83605 + }
83606 + vma->vm_flags = newflags;
83607 + error = pax_mirror_vma(vma_m, vma);
83608 + if (error) {
83609 + vma->vm_flags = oldflags;
83610 + goto fail;
83611 + }
83612 + }
83613 + }
83614 +#endif
83615 +
83616 /*
83617 * First try to merge with previous and/or next vma.
83618 */
83619 @@ -296,9 +400,21 @@ success:
83620 * vm_flags and vm_page_prot are protected by the mmap_sem
83621 * held in write mode.
83622 */
83623 +
83624 +#ifdef CONFIG_PAX_SEGMEXEC
83625 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83626 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83627 +#endif
83628 +
83629 vma->vm_flags = newflags;
83630 +
83631 +#ifdef CONFIG_PAX_MPROTECT
83632 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83633 + mm->binfmt->handle_mprotect(vma, newflags);
83634 +#endif
83635 +
83636 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83637 - vm_get_page_prot(newflags));
83638 + vm_get_page_prot(vma->vm_flags));
83639
83640 if (vma_wants_writenotify(vma)) {
83641 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83642 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83643 end = start + len;
83644 if (end <= start)
83645 return -ENOMEM;
83646 +
83647 +#ifdef CONFIG_PAX_SEGMEXEC
83648 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83649 + if (end > SEGMEXEC_TASK_SIZE)
83650 + return -EINVAL;
83651 + } else
83652 +#endif
83653 +
83654 + if (end > TASK_SIZE)
83655 + return -EINVAL;
83656 +
83657 if (!arch_validate_prot(prot))
83658 return -EINVAL;
83659
83660 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83661 /*
83662 * Does the application expect PROT_READ to imply PROT_EXEC:
83663 */
83664 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83665 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83666 prot |= PROT_EXEC;
83667
83668 vm_flags = calc_vm_prot_bits(prot);
83669 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83670 if (start > vma->vm_start)
83671 prev = vma;
83672
83673 +#ifdef CONFIG_PAX_MPROTECT
83674 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83675 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83676 +#endif
83677 +
83678 for (nstart = start ; ; ) {
83679 unsigned long newflags;
83680
83681 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83682
83683 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83684 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83685 + if (prot & (PROT_WRITE | PROT_EXEC))
83686 + gr_log_rwxmprotect(vma->vm_file);
83687 +
83688 + error = -EACCES;
83689 + goto out;
83690 + }
83691 +
83692 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83693 error = -EACCES;
83694 goto out;
83695 }
83696 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83697 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83698 if (error)
83699 goto out;
83700 +
83701 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83702 +
83703 nstart = tmp;
83704
83705 if (nstart < prev->vm_end)
83706 diff --git a/mm/mremap.c b/mm/mremap.c
83707 index 463a257..c0c7a92 100644
83708 --- a/mm/mremap.c
83709 +++ b/mm/mremap.c
83710 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83711 continue;
83712 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83713 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83714 +
83715 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83716 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83717 + pte = pte_exprotect(pte);
83718 +#endif
83719 +
83720 set_pte_at(mm, new_addr, new_pte, pte);
83721 }
83722
83723 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83724 if (is_vm_hugetlb_page(vma))
83725 goto Einval;
83726
83727 +#ifdef CONFIG_PAX_SEGMEXEC
83728 + if (pax_find_mirror_vma(vma))
83729 + goto Einval;
83730 +#endif
83731 +
83732 /* We can't remap across vm area boundaries */
83733 if (old_len > vma->vm_end - addr)
83734 goto Efault;
83735 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
83736 unsigned long ret = -EINVAL;
83737 unsigned long charged = 0;
83738 unsigned long map_flags;
83739 + unsigned long pax_task_size = TASK_SIZE;
83740
83741 if (new_addr & ~PAGE_MASK)
83742 goto out;
83743
83744 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83745 +#ifdef CONFIG_PAX_SEGMEXEC
83746 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83747 + pax_task_size = SEGMEXEC_TASK_SIZE;
83748 +#endif
83749 +
83750 + pax_task_size -= PAGE_SIZE;
83751 +
83752 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83753 goto out;
83754
83755 /* Check if the location we're moving into overlaps the
83756 * old location at all, and fail if it does.
83757 */
83758 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83759 - goto out;
83760 -
83761 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83762 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83763 goto out;
83764
83765 ret = do_munmap(mm, new_addr, new_len);
83766 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83767 unsigned long ret = -EINVAL;
83768 unsigned long charged = 0;
83769 bool locked = false;
83770 + unsigned long pax_task_size = TASK_SIZE;
83771
83772 down_write(&current->mm->mmap_sem);
83773
83774 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83775 if (!new_len)
83776 goto out;
83777
83778 +#ifdef CONFIG_PAX_SEGMEXEC
83779 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83780 + pax_task_size = SEGMEXEC_TASK_SIZE;
83781 +#endif
83782 +
83783 + pax_task_size -= PAGE_SIZE;
83784 +
83785 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83786 + old_len > pax_task_size || addr > pax_task_size-old_len)
83787 + goto out;
83788 +
83789 if (flags & MREMAP_FIXED) {
83790 if (flags & MREMAP_MAYMOVE)
83791 ret = mremap_to(addr, old_len, new_addr, new_len,
83792 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83793 new_addr = addr;
83794 }
83795 ret = addr;
83796 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83797 goto out;
83798 }
83799 }
83800 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83801 goto out;
83802 }
83803
83804 + map_flags = vma->vm_flags;
83805 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
83806 + if (!(ret & ~PAGE_MASK)) {
83807 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83808 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83809 + }
83810 }
83811 out:
83812 if (ret & ~PAGE_MASK)
83813 diff --git a/mm/nommu.c b/mm/nommu.c
83814 index e001768..9b52b30 100644
83815 --- a/mm/nommu.c
83816 +++ b/mm/nommu.c
83817 @@ -63,7 +63,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83818 int sysctl_overcommit_ratio = 50; /* default is 50% */
83819 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83820 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83821 -int heap_stack_gap = 0;
83822
83823 atomic_long_t mmap_pages_allocated;
83824
83825 @@ -841,15 +840,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83826 EXPORT_SYMBOL(find_vma);
83827
83828 /*
83829 - * find a VMA
83830 - * - we don't extend stack VMAs under NOMMU conditions
83831 - */
83832 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83833 -{
83834 - return find_vma(mm, addr);
83835 -}
83836 -
83837 -/*
83838 * expand a stack to a given address
83839 * - not supported under NOMMU conditions
83840 */
83841 @@ -1560,6 +1550,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83842
83843 /* most fields are the same, copy all, and then fixup */
83844 *new = *vma;
83845 + INIT_LIST_HEAD(&new->anon_vma_chain);
83846 *region = *vma->vm_region;
83847 new->vm_region = region;
83848
83849 @@ -1992,8 +1983,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83850 }
83851 EXPORT_SYMBOL(generic_file_remap_pages);
83852
83853 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83854 - unsigned long addr, void *buf, int len, int write)
83855 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83856 + unsigned long addr, void *buf, size_t len, int write)
83857 {
83858 struct vm_area_struct *vma;
83859
83860 @@ -2034,8 +2025,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83861 *
83862 * The caller must hold a reference on @mm.
83863 */
83864 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83865 - void *buf, int len, int write)
83866 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83867 + void *buf, size_t len, int write)
83868 {
83869 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83870 }
83871 @@ -2044,7 +2035,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83872 * Access another process' address space.
83873 * - source/target buffer must be kernel space
83874 */
83875 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83876 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83877 {
83878 struct mm_struct *mm;
83879
83880 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83881 index efe6814..64b4701 100644
83882 --- a/mm/page-writeback.c
83883 +++ b/mm/page-writeback.c
83884 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83885 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83886 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83887 */
83888 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83889 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83890 unsigned long thresh,
83891 unsigned long bg_thresh,
83892 unsigned long dirty,
83893 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83894 }
83895 }
83896
83897 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83898 +static struct notifier_block ratelimit_nb = {
83899 .notifier_call = ratelimit_handler,
83900 .next = NULL,
83901 };
83902 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83903 index 0d4fef2..8870335 100644
83904 --- a/mm/page_alloc.c
83905 +++ b/mm/page_alloc.c
83906 @@ -59,6 +59,7 @@
83907 #include <linux/migrate.h>
83908 #include <linux/page-debug-flags.h>
83909 #include <linux/sched/rt.h>
83910 +#include <linux/random.h>
83911
83912 #include <asm/tlbflush.h>
83913 #include <asm/div64.h>
83914 @@ -344,7 +345,7 @@ out:
83915 * This usage means that zero-order pages may not be compound.
83916 */
83917
83918 -static void free_compound_page(struct page *page)
83919 +void free_compound_page(struct page *page)
83920 {
83921 __free_pages_ok(page, compound_order(page));
83922 }
83923 @@ -701,6 +702,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83924 int i;
83925 int bad = 0;
83926
83927 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83928 + unsigned long index = 1UL << order;
83929 +#endif
83930 +
83931 trace_mm_page_free(page, order);
83932 kmemcheck_free_shadow(page, order);
83933
83934 @@ -716,6 +721,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83935 debug_check_no_obj_freed(page_address(page),
83936 PAGE_SIZE << order);
83937 }
83938 +
83939 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83940 + for (; index; --index)
83941 + sanitize_highpage(page + index - 1);
83942 +#endif
83943 +
83944 arch_free_page(page, order);
83945 kernel_map_pages(page, 1 << order, 0);
83946
83947 @@ -738,6 +749,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83948 local_irq_restore(flags);
83949 }
83950
83951 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83952 +bool __meminitdata extra_latent_entropy;
83953 +
83954 +static int __init setup_pax_extra_latent_entropy(char *str)
83955 +{
83956 + extra_latent_entropy = true;
83957 + return 0;
83958 +}
83959 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83960 +
83961 +volatile u64 latent_entropy;
83962 +#endif
83963 +
83964 /*
83965 * Read access to zone->managed_pages is safe because it's unsigned long,
83966 * but we still need to serialize writers. Currently all callers of
83967 @@ -760,6 +784,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83968 set_page_count(p, 0);
83969 }
83970
83971 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83972 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83973 + u64 hash = 0;
83974 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83975 + const u64 *data = lowmem_page_address(page);
83976 +
83977 + for (index = 0; index < end; index++)
83978 + hash ^= hash + data[index];
83979 + latent_entropy ^= hash;
83980 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83981 + }
83982 +#endif
83983 +
83984 page_zone(page)->managed_pages += 1 << order;
83985 set_page_refcounted(page);
83986 __free_pages(page, order);
83987 @@ -869,8 +906,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83988 arch_alloc_page(page, order);
83989 kernel_map_pages(page, 1 << order, 1);
83990
83991 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83992 if (gfp_flags & __GFP_ZERO)
83993 prep_zero_page(page, order, gfp_flags);
83994 +#endif
83995
83996 if (order && (gfp_flags & __GFP_COMP))
83997 prep_compound_page(page, order);
83998 diff --git a/mm/page_io.c b/mm/page_io.c
83999 index 6182870..4bba6a2 100644
84000 --- a/mm/page_io.c
84001 +++ b/mm/page_io.c
84002 @@ -205,7 +205,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
84003 struct file *swap_file = sis->swap_file;
84004 struct address_space *mapping = swap_file->f_mapping;
84005 struct iovec iov = {
84006 - .iov_base = kmap(page),
84007 + .iov_base = (void __force_user *)kmap(page),
84008 .iov_len = PAGE_SIZE,
84009 };
84010
84011 diff --git a/mm/percpu.c b/mm/percpu.c
84012 index 8c8e08f..73a5cda 100644
84013 --- a/mm/percpu.c
84014 +++ b/mm/percpu.c
84015 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
84016 static unsigned int pcpu_high_unit_cpu __read_mostly;
84017
84018 /* the address of the first chunk which starts with the kernel static area */
84019 -void *pcpu_base_addr __read_mostly;
84020 +void *pcpu_base_addr __read_only;
84021 EXPORT_SYMBOL_GPL(pcpu_base_addr);
84022
84023 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
84024 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
84025 index fd26d04..0cea1b0 100644
84026 --- a/mm/process_vm_access.c
84027 +++ b/mm/process_vm_access.c
84028 @@ -13,6 +13,7 @@
84029 #include <linux/uio.h>
84030 #include <linux/sched.h>
84031 #include <linux/highmem.h>
84032 +#include <linux/security.h>
84033 #include <linux/ptrace.h>
84034 #include <linux/slab.h>
84035 #include <linux/syscalls.h>
84036 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84037 size_t iov_l_curr_offset = 0;
84038 ssize_t iov_len;
84039
84040 + return -ENOSYS; // PaX: until properly audited
84041 +
84042 /*
84043 * Work out how many pages of struct pages we're going to need
84044 * when eventually calling get_user_pages
84045 */
84046 for (i = 0; i < riovcnt; i++) {
84047 iov_len = rvec[i].iov_len;
84048 - if (iov_len > 0) {
84049 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
84050 - + iov_len)
84051 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
84052 - / PAGE_SIZE + 1;
84053 - nr_pages = max(nr_pages, nr_pages_iov);
84054 - }
84055 + if (iov_len <= 0)
84056 + continue;
84057 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
84058 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
84059 + nr_pages = max(nr_pages, nr_pages_iov);
84060 }
84061
84062 if (nr_pages == 0)
84063 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84064 goto free_proc_pages;
84065 }
84066
84067 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
84068 + rc = -EPERM;
84069 + goto put_task_struct;
84070 + }
84071 +
84072 mm = mm_access(task, PTRACE_MODE_ATTACH);
84073 if (!mm || IS_ERR(mm)) {
84074 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
84075 diff --git a/mm/rmap.c b/mm/rmap.c
84076 index 807c96b..0e05279 100644
84077 --- a/mm/rmap.c
84078 +++ b/mm/rmap.c
84079 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84080 struct anon_vma *anon_vma = vma->anon_vma;
84081 struct anon_vma_chain *avc;
84082
84083 +#ifdef CONFIG_PAX_SEGMEXEC
84084 + struct anon_vma_chain *avc_m = NULL;
84085 +#endif
84086 +
84087 might_sleep();
84088 if (unlikely(!anon_vma)) {
84089 struct mm_struct *mm = vma->vm_mm;
84090 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84091 if (!avc)
84092 goto out_enomem;
84093
84094 +#ifdef CONFIG_PAX_SEGMEXEC
84095 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
84096 + if (!avc_m)
84097 + goto out_enomem_free_avc;
84098 +#endif
84099 +
84100 anon_vma = find_mergeable_anon_vma(vma);
84101 allocated = NULL;
84102 if (!anon_vma) {
84103 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84104 /* page_table_lock to protect against threads */
84105 spin_lock(&mm->page_table_lock);
84106 if (likely(!vma->anon_vma)) {
84107 +
84108 +#ifdef CONFIG_PAX_SEGMEXEC
84109 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
84110 +
84111 + if (vma_m) {
84112 + BUG_ON(vma_m->anon_vma);
84113 + vma_m->anon_vma = anon_vma;
84114 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
84115 + avc_m = NULL;
84116 + }
84117 +#endif
84118 +
84119 vma->anon_vma = anon_vma;
84120 anon_vma_chain_link(vma, avc, anon_vma);
84121 allocated = NULL;
84122 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84123
84124 if (unlikely(allocated))
84125 put_anon_vma(allocated);
84126 +
84127 +#ifdef CONFIG_PAX_SEGMEXEC
84128 + if (unlikely(avc_m))
84129 + anon_vma_chain_free(avc_m);
84130 +#endif
84131 +
84132 if (unlikely(avc))
84133 anon_vma_chain_free(avc);
84134 }
84135 return 0;
84136
84137 out_enomem_free_avc:
84138 +
84139 +#ifdef CONFIG_PAX_SEGMEXEC
84140 + if (avc_m)
84141 + anon_vma_chain_free(avc_m);
84142 +#endif
84143 +
84144 anon_vma_chain_free(avc);
84145 out_enomem:
84146 return -ENOMEM;
84147 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
84148 * Attach the anon_vmas from src to dst.
84149 * Returns 0 on success, -ENOMEM on failure.
84150 */
84151 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84152 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
84153 {
84154 struct anon_vma_chain *avc, *pavc;
84155 struct anon_vma *root = NULL;
84156 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84157 * the corresponding VMA in the parent process is attached to.
84158 * Returns 0 on success, non-zero on failure.
84159 */
84160 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
84161 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
84162 {
84163 struct anon_vma_chain *avc;
84164 struct anon_vma *anon_vma;
84165 diff --git a/mm/shmem.c b/mm/shmem.c
84166 index 1c44af7..cefe9a6 100644
84167 --- a/mm/shmem.c
84168 +++ b/mm/shmem.c
84169 @@ -31,7 +31,7 @@
84170 #include <linux/export.h>
84171 #include <linux/swap.h>
84172
84173 -static struct vfsmount *shm_mnt;
84174 +struct vfsmount *shm_mnt;
84175
84176 #ifdef CONFIG_SHMEM
84177 /*
84178 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
84179 #define BOGO_DIRENT_SIZE 20
84180
84181 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
84182 -#define SHORT_SYMLINK_LEN 128
84183 +#define SHORT_SYMLINK_LEN 64
84184
84185 /*
84186 * shmem_fallocate and shmem_writepage communicate via inode->i_private
84187 @@ -2201,6 +2201,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
84188 static int shmem_xattr_validate(const char *name)
84189 {
84190 struct { const char *prefix; size_t len; } arr[] = {
84191 +
84192 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84193 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
84194 +#endif
84195 +
84196 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
84197 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
84198 };
84199 @@ -2256,6 +2261,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
84200 if (err)
84201 return err;
84202
84203 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84204 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
84205 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
84206 + return -EOPNOTSUPP;
84207 + if (size > 8)
84208 + return -EINVAL;
84209 + }
84210 +#endif
84211 +
84212 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84213 }
84214
84215 @@ -2568,8 +2582,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84216 int err = -ENOMEM;
84217
84218 /* Round up to L1_CACHE_BYTES to resist false sharing */
84219 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84220 - L1_CACHE_BYTES), GFP_KERNEL);
84221 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84222 if (!sbinfo)
84223 return -ENOMEM;
84224
84225 diff --git a/mm/slab.c b/mm/slab.c
84226 index 856e4a1..fafb820 100644
84227 --- a/mm/slab.c
84228 +++ b/mm/slab.c
84229 @@ -306,7 +306,7 @@ struct kmem_list3 {
84230 * Need this for bootstrapping a per node allocator.
84231 */
84232 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
84233 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
84234 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
84235 #define CACHE_CACHE 0
84236 #define SIZE_AC MAX_NUMNODES
84237 #define SIZE_L3 (2 * MAX_NUMNODES)
84238 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
84239 if ((x)->max_freeable < i) \
84240 (x)->max_freeable = i; \
84241 } while (0)
84242 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84243 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84244 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84245 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84246 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84247 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84248 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84249 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84250 #else
84251 #define STATS_INC_ACTIVE(x) do { } while (0)
84252 #define STATS_DEC_ACTIVE(x) do { } while (0)
84253 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84254 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84255 */
84256 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84257 - const struct slab *slab, void *obj)
84258 + const struct slab *slab, const void *obj)
84259 {
84260 u32 offset = (obj - slab->s_mem);
84261 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84262 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
84263 struct cache_names {
84264 char *name;
84265 char *name_dma;
84266 + char *name_usercopy;
84267 };
84268
84269 static struct cache_names __initdata cache_names[] = {
84270 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
84271 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
84272 #include <linux/kmalloc_sizes.h>
84273 - {NULL,}
84274 + {NULL}
84275 #undef CACHE
84276 };
84277
84278 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
84279 if (unlikely(gfpflags & GFP_DMA))
84280 return csizep->cs_dmacachep;
84281 #endif
84282 +
84283 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84284 + if (unlikely(gfpflags & GFP_USERCOPY))
84285 + return csizep->cs_usercopycachep;
84286 +#endif
84287 +
84288 return csizep->cs_cachep;
84289 }
84290
84291 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84292 return notifier_from_errno(err);
84293 }
84294
84295 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84296 +static struct notifier_block cpucache_notifier = {
84297 &cpuup_callback, NULL, 0
84298 };
84299
84300 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
84301 */
84302
84303 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
84304 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
84305 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84306
84307 if (INDEX_AC != INDEX_L3)
84308 sizes[INDEX_L3].cs_cachep =
84309 create_kmalloc_cache(names[INDEX_L3].name,
84310 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
84311 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84312
84313 slab_early_init = 0;
84314
84315 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
84316 */
84317 if (!sizes->cs_cachep)
84318 sizes->cs_cachep = create_kmalloc_cache(names->name,
84319 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
84320 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84321
84322 #ifdef CONFIG_ZONE_DMA
84323 sizes->cs_dmacachep = create_kmalloc_cache(
84324 names->name_dma, sizes->cs_size,
84325 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84326 #endif
84327 +
84328 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84329 + sizes->cs_usercopycachep = create_kmalloc_cache(
84330 + names->name_usercopy, sizes->cs_size,
84331 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84332 +#endif
84333 +
84334 sizes++;
84335 names++;
84336 }
84337 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84338
84339 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84340 return;
84341 + VM_BUG_ON(!virt_addr_valid(objp));
84342 local_irq_save(flags);
84343 kfree_debugcheck(objp);
84344 c = virt_to_cache(objp);
84345 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84346 }
84347 /* cpu stats */
84348 {
84349 - unsigned long allochit = atomic_read(&cachep->allochit);
84350 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84351 - unsigned long freehit = atomic_read(&cachep->freehit);
84352 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84353 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84354 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84355 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84356 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84357
84358 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84359 allochit, allocmiss, freehit, freemiss);
84360 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84361 static int __init slab_proc_init(void)
84362 {
84363 #ifdef CONFIG_DEBUG_SLAB_LEAK
84364 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84365 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84366 #endif
84367 return 0;
84368 }
84369 module_init(slab_proc_init);
84370 #endif
84371
84372 +bool is_usercopy_object(const void *ptr)
84373 +{
84374 + struct page *page;
84375 + struct kmem_cache *cachep;
84376 +
84377 + if (ZERO_OR_NULL_PTR(ptr))
84378 + return false;
84379 +
84380 + if (!slab_is_available())
84381 + return false;
84382 +
84383 + if (!virt_addr_valid(ptr))
84384 + return false;
84385 +
84386 + page = virt_to_head_page(ptr);
84387 +
84388 + if (!PageSlab(page))
84389 + return false;
84390 +
84391 + cachep = page->slab_cache;
84392 + return cachep->flags & SLAB_USERCOPY;
84393 +}
84394 +
84395 +#ifdef CONFIG_PAX_USERCOPY
84396 +const char *check_heap_object(const void *ptr, unsigned long n)
84397 +{
84398 + struct page *page;
84399 + struct kmem_cache *cachep;
84400 + struct slab *slabp;
84401 + unsigned int objnr;
84402 + unsigned long offset;
84403 +
84404 + if (ZERO_OR_NULL_PTR(ptr))
84405 + return "<null>";
84406 +
84407 + if (!virt_addr_valid(ptr))
84408 + return NULL;
84409 +
84410 + page = virt_to_head_page(ptr);
84411 +
84412 + if (!PageSlab(page))
84413 + return NULL;
84414 +
84415 + cachep = page->slab_cache;
84416 + if (!(cachep->flags & SLAB_USERCOPY))
84417 + return cachep->name;
84418 +
84419 + slabp = page->slab_page;
84420 + objnr = obj_to_index(cachep, slabp, ptr);
84421 + BUG_ON(objnr >= cachep->num);
84422 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84423 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84424 + return NULL;
84425 +
84426 + return cachep->name;
84427 +}
84428 +#endif
84429 +
84430 /**
84431 * ksize - get the actual amount of memory allocated for a given object
84432 * @objp: Pointer to the object
84433 diff --git a/mm/slab.h b/mm/slab.h
84434 index 34a98d6..73633d1 100644
84435 --- a/mm/slab.h
84436 +++ b/mm/slab.h
84437 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84438
84439 /* Legal flag mask for kmem_cache_create(), for various configurations */
84440 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84441 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84442 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84443
84444 #if defined(CONFIG_DEBUG_SLAB)
84445 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84446 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84447 return s;
84448
84449 page = virt_to_head_page(x);
84450 +
84451 + BUG_ON(!PageSlab(page));
84452 +
84453 cachep = page->slab_cache;
84454 if (slab_equal_or_root(cachep, s))
84455 return cachep;
84456 diff --git a/mm/slab_common.c b/mm/slab_common.c
84457 index 3f3cd97..93b0236 100644
84458 --- a/mm/slab_common.c
84459 +++ b/mm/slab_common.c
84460 @@ -22,7 +22,7 @@
84461
84462 #include "slab.h"
84463
84464 -enum slab_state slab_state;
84465 +enum slab_state slab_state __read_only;
84466 LIST_HEAD(slab_caches);
84467 DEFINE_MUTEX(slab_mutex);
84468 struct kmem_cache *kmem_cache;
84469 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84470
84471 err = __kmem_cache_create(s, flags);
84472 if (!err) {
84473 - s->refcount = 1;
84474 + atomic_set(&s->refcount, 1);
84475 list_add(&s->list, &slab_caches);
84476 memcg_cache_list_add(memcg, s);
84477 } else {
84478 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84479
84480 get_online_cpus();
84481 mutex_lock(&slab_mutex);
84482 - s->refcount--;
84483 - if (!s->refcount) {
84484 + if (atomic_dec_and_test(&s->refcount)) {
84485 list_del(&s->list);
84486
84487 if (!__kmem_cache_shutdown(s)) {
84488 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84489 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84490 name, size, err);
84491
84492 - s->refcount = -1; /* Exempt from merging for now */
84493 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84494 }
84495
84496 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84497 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84498
84499 create_boot_cache(s, name, size, flags);
84500 list_add(&s->list, &slab_caches);
84501 - s->refcount = 1;
84502 + atomic_set(&s->refcount, 1);
84503 return s;
84504 }
84505
84506 diff --git a/mm/slob.c b/mm/slob.c
84507 index eeed4a0..6ee34ec 100644
84508 --- a/mm/slob.c
84509 +++ b/mm/slob.c
84510 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84511 /*
84512 * Return the size of a slob block.
84513 */
84514 -static slobidx_t slob_units(slob_t *s)
84515 +static slobidx_t slob_units(const slob_t *s)
84516 {
84517 if (s->units > 0)
84518 return s->units;
84519 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84520 /*
84521 * Return the next free slob block pointer after this one.
84522 */
84523 -static slob_t *slob_next(slob_t *s)
84524 +static slob_t *slob_next(const slob_t *s)
84525 {
84526 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84527 slobidx_t next;
84528 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84529 /*
84530 * Returns true if s is the last free block in its page.
84531 */
84532 -static int slob_last(slob_t *s)
84533 +static int slob_last(const slob_t *s)
84534 {
84535 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84536 }
84537
84538 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84539 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84540 {
84541 - void *page;
84542 + struct page *page;
84543
84544 #ifdef CONFIG_NUMA
84545 if (node != NUMA_NO_NODE)
84546 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84547 if (!page)
84548 return NULL;
84549
84550 - return page_address(page);
84551 + __SetPageSlab(page);
84552 + return page;
84553 }
84554
84555 -static void slob_free_pages(void *b, int order)
84556 +static void slob_free_pages(struct page *sp, int order)
84557 {
84558 if (current->reclaim_state)
84559 current->reclaim_state->reclaimed_slab += 1 << order;
84560 - free_pages((unsigned long)b, order);
84561 + __ClearPageSlab(sp);
84562 + reset_page_mapcount(sp);
84563 + sp->private = 0;
84564 + __free_pages(sp, order);
84565 }
84566
84567 /*
84568 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84569
84570 /* Not enough space: must allocate a new page */
84571 if (!b) {
84572 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84573 - if (!b)
84574 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84575 + if (!sp)
84576 return NULL;
84577 - sp = virt_to_page(b);
84578 - __SetPageSlab(sp);
84579 + b = page_address(sp);
84580
84581 spin_lock_irqsave(&slob_lock, flags);
84582 sp->units = SLOB_UNITS(PAGE_SIZE);
84583 sp->freelist = b;
84584 + sp->private = 0;
84585 INIT_LIST_HEAD(&sp->list);
84586 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84587 set_slob_page_free(sp, slob_list);
84588 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84589 if (slob_page_free(sp))
84590 clear_slob_page_free(sp);
84591 spin_unlock_irqrestore(&slob_lock, flags);
84592 - __ClearPageSlab(sp);
84593 - page_mapcount_reset(sp);
84594 - slob_free_pages(b, 0);
84595 + slob_free_pages(sp, 0);
84596 return;
84597 }
84598
84599 @@ -424,11 +426,10 @@ out:
84600 */
84601
84602 static __always_inline void *
84603 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84604 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84605 {
84606 - unsigned int *m;
84607 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84608 - void *ret;
84609 + slob_t *m;
84610 + void *ret = NULL;
84611
84612 gfp &= gfp_allowed_mask;
84613
84614 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84615
84616 if (!m)
84617 return NULL;
84618 - *m = size;
84619 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84620 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84621 + m[0].units = size;
84622 + m[1].units = align;
84623 ret = (void *)m + align;
84624
84625 trace_kmalloc_node(caller, ret,
84626 size, size + align, gfp, node);
84627 } else {
84628 unsigned int order = get_order(size);
84629 + struct page *page;
84630
84631 if (likely(order))
84632 gfp |= __GFP_COMP;
84633 - ret = slob_new_pages(gfp, order, node);
84634 + page = slob_new_pages(gfp, order, node);
84635 + if (page) {
84636 + ret = page_address(page);
84637 + page->private = size;
84638 + }
84639
84640 trace_kmalloc_node(caller, ret,
84641 size, PAGE_SIZE << order, gfp, node);
84642 }
84643
84644 - kmemleak_alloc(ret, size, 1, gfp);
84645 + return ret;
84646 +}
84647 +
84648 +static __always_inline void *
84649 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84650 +{
84651 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84652 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84653 +
84654 + if (!ZERO_OR_NULL_PTR(ret))
84655 + kmemleak_alloc(ret, size, 1, gfp);
84656 return ret;
84657 }
84658
84659 @@ -493,34 +512,112 @@ void kfree(const void *block)
84660 return;
84661 kmemleak_free(block);
84662
84663 + VM_BUG_ON(!virt_addr_valid(block));
84664 sp = virt_to_page(block);
84665 - if (PageSlab(sp)) {
84666 + VM_BUG_ON(!PageSlab(sp));
84667 + if (!sp->private) {
84668 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84669 - unsigned int *m = (unsigned int *)(block - align);
84670 - slob_free(m, *m + align);
84671 - } else
84672 + slob_t *m = (slob_t *)(block - align);
84673 + slob_free(m, m[0].units + align);
84674 + } else {
84675 + __ClearPageSlab(sp);
84676 + reset_page_mapcount(sp);
84677 + sp->private = 0;
84678 __free_pages(sp, compound_order(sp));
84679 + }
84680 }
84681 EXPORT_SYMBOL(kfree);
84682
84683 +bool is_usercopy_object(const void *ptr)
84684 +{
84685 + if (!slab_is_available())
84686 + return false;
84687 +
84688 + // PAX: TODO
84689 +
84690 + return false;
84691 +}
84692 +
84693 +#ifdef CONFIG_PAX_USERCOPY
84694 +const char *check_heap_object(const void *ptr, unsigned long n)
84695 +{
84696 + struct page *page;
84697 + const slob_t *free;
84698 + const void *base;
84699 + unsigned long flags;
84700 +
84701 + if (ZERO_OR_NULL_PTR(ptr))
84702 + return "<null>";
84703 +
84704 + if (!virt_addr_valid(ptr))
84705 + return NULL;
84706 +
84707 + page = virt_to_head_page(ptr);
84708 + if (!PageSlab(page))
84709 + return NULL;
84710 +
84711 + if (page->private) {
84712 + base = page;
84713 + if (base <= ptr && n <= page->private - (ptr - base))
84714 + return NULL;
84715 + return "<slob>";
84716 + }
84717 +
84718 + /* some tricky double walking to find the chunk */
84719 + spin_lock_irqsave(&slob_lock, flags);
84720 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84721 + free = page->freelist;
84722 +
84723 + while (!slob_last(free) && (void *)free <= ptr) {
84724 + base = free + slob_units(free);
84725 + free = slob_next(free);
84726 + }
84727 +
84728 + while (base < (void *)free) {
84729 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84730 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84731 + int offset;
84732 +
84733 + if (ptr < base + align)
84734 + break;
84735 +
84736 + offset = ptr - base - align;
84737 + if (offset >= m) {
84738 + base += size;
84739 + continue;
84740 + }
84741 +
84742 + if (n > m - offset)
84743 + break;
84744 +
84745 + spin_unlock_irqrestore(&slob_lock, flags);
84746 + return NULL;
84747 + }
84748 +
84749 + spin_unlock_irqrestore(&slob_lock, flags);
84750 + return "<slob>";
84751 +}
84752 +#endif
84753 +
84754 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84755 size_t ksize(const void *block)
84756 {
84757 struct page *sp;
84758 int align;
84759 - unsigned int *m;
84760 + slob_t *m;
84761
84762 BUG_ON(!block);
84763 if (unlikely(block == ZERO_SIZE_PTR))
84764 return 0;
84765
84766 sp = virt_to_page(block);
84767 - if (unlikely(!PageSlab(sp)))
84768 - return PAGE_SIZE << compound_order(sp);
84769 + VM_BUG_ON(!PageSlab(sp));
84770 + if (sp->private)
84771 + return sp->private;
84772
84773 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84774 - m = (unsigned int *)(block - align);
84775 - return SLOB_UNITS(*m) * SLOB_UNIT;
84776 + m = (slob_t *)(block - align);
84777 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84778 }
84779 EXPORT_SYMBOL(ksize);
84780
84781 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84782
84783 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84784 {
84785 - void *b;
84786 + void *b = NULL;
84787
84788 flags &= gfp_allowed_mask;
84789
84790 lockdep_trace_alloc(flags);
84791
84792 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84793 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84794 +#else
84795 if (c->size < PAGE_SIZE) {
84796 b = slob_alloc(c->size, flags, c->align, node);
84797 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84798 SLOB_UNITS(c->size) * SLOB_UNIT,
84799 flags, node);
84800 } else {
84801 - b = slob_new_pages(flags, get_order(c->size), node);
84802 + struct page *sp;
84803 +
84804 + sp = slob_new_pages(flags, get_order(c->size), node);
84805 + if (sp) {
84806 + b = page_address(sp);
84807 + sp->private = c->size;
84808 + }
84809 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84810 PAGE_SIZE << get_order(c->size),
84811 flags, node);
84812 }
84813 +#endif
84814
84815 if (c->ctor)
84816 c->ctor(b);
84817 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84818
84819 static void __kmem_cache_free(void *b, int size)
84820 {
84821 - if (size < PAGE_SIZE)
84822 + struct page *sp;
84823 +
84824 + sp = virt_to_page(b);
84825 + BUG_ON(!PageSlab(sp));
84826 + if (!sp->private)
84827 slob_free(b, size);
84828 else
84829 - slob_free_pages(b, get_order(size));
84830 + slob_free_pages(sp, get_order(size));
84831 }
84832
84833 static void kmem_rcu_free(struct rcu_head *head)
84834 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84835
84836 void kmem_cache_free(struct kmem_cache *c, void *b)
84837 {
84838 + int size = c->size;
84839 +
84840 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84841 + if (size + c->align < PAGE_SIZE) {
84842 + size += c->align;
84843 + b -= c->align;
84844 + }
84845 +#endif
84846 +
84847 kmemleak_free_recursive(b, c->flags);
84848 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84849 struct slob_rcu *slob_rcu;
84850 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84851 - slob_rcu->size = c->size;
84852 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84853 + slob_rcu->size = size;
84854 call_rcu(&slob_rcu->head, kmem_rcu_free);
84855 } else {
84856 - __kmem_cache_free(b, c->size);
84857 + __kmem_cache_free(b, size);
84858 }
84859
84860 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84861 + trace_kfree(_RET_IP_, b);
84862 +#else
84863 trace_kmem_cache_free(_RET_IP_, b);
84864 +#endif
84865 +
84866 }
84867 EXPORT_SYMBOL(kmem_cache_free);
84868
84869 diff --git a/mm/slub.c b/mm/slub.c
84870 index 4aec537..8043df1 100644
84871 --- a/mm/slub.c
84872 +++ b/mm/slub.c
84873 @@ -197,7 +197,7 @@ struct track {
84874
84875 enum track_item { TRACK_ALLOC, TRACK_FREE };
84876
84877 -#ifdef CONFIG_SYSFS
84878 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84879 static int sysfs_slab_add(struct kmem_cache *);
84880 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84881 static void sysfs_slab_remove(struct kmem_cache *);
84882 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84883 if (!t->addr)
84884 return;
84885
84886 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84887 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84888 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84889 #ifdef CONFIG_STACKTRACE
84890 {
84891 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84892 * Merge control. If this is set then no merging of slab caches will occur.
84893 * (Could be removed. This was introduced to pacify the merge skeptics.)
84894 */
84895 -static int slub_nomerge;
84896 +static int slub_nomerge = 1;
84897
84898 /*
84899 * Calculate the order of allocation given an slab object size.
84900 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84901 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84902 #endif
84903
84904 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84905 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84906 +#endif
84907 +
84908 static int __init setup_slub_min_order(char *str)
84909 {
84910 get_option(&str, &slub_min_order);
84911 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84912 return kmalloc_dma_caches[index];
84913
84914 #endif
84915 +
84916 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84917 + if (flags & SLAB_USERCOPY)
84918 + return kmalloc_usercopy_caches[index];
84919 +
84920 +#endif
84921 +
84922 return kmalloc_caches[index];
84923 }
84924
84925 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84926 EXPORT_SYMBOL(__kmalloc_node);
84927 #endif
84928
84929 +bool is_usercopy_object(const void *ptr)
84930 +{
84931 + struct page *page;
84932 + struct kmem_cache *s;
84933 +
84934 + if (ZERO_OR_NULL_PTR(ptr))
84935 + return false;
84936 +
84937 + if (!slab_is_available())
84938 + return false;
84939 +
84940 + if (!virt_addr_valid(ptr))
84941 + return false;
84942 +
84943 + page = virt_to_head_page(ptr);
84944 +
84945 + if (!PageSlab(page))
84946 + return false;
84947 +
84948 + s = page->slab_cache;
84949 + return s->flags & SLAB_USERCOPY;
84950 +}
84951 +
84952 +#ifdef CONFIG_PAX_USERCOPY
84953 +const char *check_heap_object(const void *ptr, unsigned long n)
84954 +{
84955 + struct page *page;
84956 + struct kmem_cache *s;
84957 + unsigned long offset;
84958 +
84959 + if (ZERO_OR_NULL_PTR(ptr))
84960 + return "<null>";
84961 +
84962 + if (!virt_addr_valid(ptr))
84963 + return NULL;
84964 +
84965 + page = virt_to_head_page(ptr);
84966 +
84967 + if (!PageSlab(page))
84968 + return NULL;
84969 +
84970 + s = page->slab_cache;
84971 + if (!(s->flags & SLAB_USERCOPY))
84972 + return s->name;
84973 +
84974 + offset = (ptr - page_address(page)) % s->size;
84975 + if (offset <= s->object_size && n <= s->object_size - offset)
84976 + return NULL;
84977 +
84978 + return s->name;
84979 +}
84980 +#endif
84981 +
84982 size_t ksize(const void *object)
84983 {
84984 struct page *page;
84985 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84986 if (unlikely(ZERO_OR_NULL_PTR(x)))
84987 return;
84988
84989 + VM_BUG_ON(!virt_addr_valid(x));
84990 page = virt_to_head_page(x);
84991 if (unlikely(!PageSlab(page))) {
84992 BUG_ON(!PageCompound(page));
84993 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84994
84995 /* Caches that are not of the two-to-the-power-of size */
84996 if (KMALLOC_MIN_SIZE <= 32) {
84997 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84998 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84999 caches++;
85000 }
85001
85002 if (KMALLOC_MIN_SIZE <= 64) {
85003 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
85004 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
85005 caches++;
85006 }
85007
85008 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
85009 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
85010 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
85011 caches++;
85012 }
85013
85014 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
85015 }
85016 }
85017 #endif
85018 +
85019 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85020 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
85021 + struct kmem_cache *s = kmalloc_caches[i];
85022 +
85023 + if (s && s->size) {
85024 + char *name = kasprintf(GFP_NOWAIT,
85025 + "usercopy-kmalloc-%d", s->object_size);
85026 +
85027 + BUG_ON(!name);
85028 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
85029 + s->object_size, SLAB_USERCOPY);
85030 + }
85031 + }
85032 +#endif
85033 +
85034 printk(KERN_INFO
85035 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
85036 " CPUs=%d, Nodes=%d\n",
85037 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
85038 /*
85039 * We may have set a slab to be unmergeable during bootstrap.
85040 */
85041 - if (s->refcount < 0)
85042 + if (atomic_read(&s->refcount) < 0)
85043 return 1;
85044
85045 return 0;
85046 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85047
85048 s = find_mergeable(memcg, size, align, flags, name, ctor);
85049 if (s) {
85050 - s->refcount++;
85051 + atomic_inc(&s->refcount);
85052 /*
85053 * Adjust the object sizes so that we clear
85054 * the complete object on kzalloc.
85055 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85056 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
85057
85058 if (sysfs_slab_alias(s, name)) {
85059 - s->refcount--;
85060 + atomic_dec(&s->refcount);
85061 s = NULL;
85062 }
85063 }
85064 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
85065 return NOTIFY_OK;
85066 }
85067
85068 -static struct notifier_block __cpuinitdata slab_notifier = {
85069 +static struct notifier_block slab_notifier = {
85070 .notifier_call = slab_cpuup_callback
85071 };
85072
85073 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
85074 }
85075 #endif
85076
85077 -#ifdef CONFIG_SYSFS
85078 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85079 static int count_inuse(struct page *page)
85080 {
85081 return page->inuse;
85082 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
85083 validate_slab_cache(kmalloc_caches[9]);
85084 }
85085 #else
85086 -#ifdef CONFIG_SYSFS
85087 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85088 static void resiliency_test(void) {};
85089 #endif
85090 #endif
85091
85092 -#ifdef CONFIG_SYSFS
85093 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85094 enum slab_stat_type {
85095 SL_ALL, /* All slabs */
85096 SL_PARTIAL, /* Only partially allocated slabs */
85097 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
85098
85099 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
85100 {
85101 - return sprintf(buf, "%d\n", s->refcount - 1);
85102 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
85103 }
85104 SLAB_ATTR_RO(aliases);
85105
85106 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
85107 return name;
85108 }
85109
85110 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85111 static int sysfs_slab_add(struct kmem_cache *s)
85112 {
85113 int err;
85114 @@ -5289,7 +5371,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
85115 }
85116
85117 s->kobj.kset = slab_kset;
85118 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
85119 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
85120 if (err) {
85121 kobject_put(&s->kobj);
85122 return err;
85123 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
85124 kobject_del(&s->kobj);
85125 kobject_put(&s->kobj);
85126 }
85127 +#endif
85128
85129 /*
85130 * Need to buffer aliases during bootup until sysfs becomes
85131 @@ -5336,6 +5419,7 @@ struct saved_alias {
85132
85133 static struct saved_alias *alias_list;
85134
85135 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85136 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85137 {
85138 struct saved_alias *al;
85139 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85140 alias_list = al;
85141 return 0;
85142 }
85143 +#endif
85144
85145 static int __init slab_sysfs_init(void)
85146 {
85147 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
85148 index 1b7e22a..3fcd4f3 100644
85149 --- a/mm/sparse-vmemmap.c
85150 +++ b/mm/sparse-vmemmap.c
85151 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
85152 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85153 if (!p)
85154 return NULL;
85155 - pud_populate(&init_mm, pud, p);
85156 + pud_populate_kernel(&init_mm, pud, p);
85157 }
85158 return pud;
85159 }
85160 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
85161 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85162 if (!p)
85163 return NULL;
85164 - pgd_populate(&init_mm, pgd, p);
85165 + pgd_populate_kernel(&init_mm, pgd, p);
85166 }
85167 return pgd;
85168 }
85169 diff --git a/mm/sparse.c b/mm/sparse.c
85170 index 7ca6dc8..6472aa1 100644
85171 --- a/mm/sparse.c
85172 +++ b/mm/sparse.c
85173 @@ -783,7 +783,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
85174
85175 for (i = 0; i < PAGES_PER_SECTION; i++) {
85176 if (PageHWPoison(&memmap[i])) {
85177 - atomic_long_sub(1, &num_poisoned_pages);
85178 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
85179 ClearPageHWPoison(&memmap[i]);
85180 }
85181 }
85182 diff --git a/mm/swap.c b/mm/swap.c
85183 index 8a529a0..154ef26 100644
85184 --- a/mm/swap.c
85185 +++ b/mm/swap.c
85186 @@ -30,6 +30,7 @@
85187 #include <linux/backing-dev.h>
85188 #include <linux/memcontrol.h>
85189 #include <linux/gfp.h>
85190 +#include <linux/hugetlb.h>
85191
85192 #include "internal.h"
85193
85194 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
85195
85196 __page_cache_release(page);
85197 dtor = get_compound_page_dtor(page);
85198 + if (!PageHuge(page))
85199 + BUG_ON(dtor != free_compound_page);
85200 (*dtor)(page);
85201 }
85202
85203 diff --git a/mm/swapfile.c b/mm/swapfile.c
85204 index a1f7772..9e982ac 100644
85205 --- a/mm/swapfile.c
85206 +++ b/mm/swapfile.c
85207 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
85208
85209 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
85210 /* Activity counter to indicate that a swapon or swapoff has occurred */
85211 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
85212 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
85213
85214 static inline unsigned char swap_count(unsigned char ent)
85215 {
85216 @@ -1683,7 +1683,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
85217 }
85218 filp_close(swap_file, NULL);
85219 err = 0;
85220 - atomic_inc(&proc_poll_event);
85221 + atomic_inc_unchecked(&proc_poll_event);
85222 wake_up_interruptible(&proc_poll_wait);
85223
85224 out_dput:
85225 @@ -1700,8 +1700,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85226
85227 poll_wait(file, &proc_poll_wait, wait);
85228
85229 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85230 - seq->poll_event = atomic_read(&proc_poll_event);
85231 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85232 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85233 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85234 }
85235
85236 @@ -1799,7 +1799,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85237 return ret;
85238
85239 seq = file->private_data;
85240 - seq->poll_event = atomic_read(&proc_poll_event);
85241 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85242 return 0;
85243 }
85244
85245 @@ -2142,7 +2142,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85246 (frontswap_map) ? "FS" : "");
85247
85248 mutex_unlock(&swapon_mutex);
85249 - atomic_inc(&proc_poll_event);
85250 + atomic_inc_unchecked(&proc_poll_event);
85251 wake_up_interruptible(&proc_poll_wait);
85252
85253 if (S_ISREG(inode->i_mode))
85254 diff --git a/mm/util.c b/mm/util.c
85255 index ab1424d..7c5bd5a 100644
85256 --- a/mm/util.c
85257 +++ b/mm/util.c
85258 @@ -294,6 +294,12 @@ done:
85259 void arch_pick_mmap_layout(struct mm_struct *mm)
85260 {
85261 mm->mmap_base = TASK_UNMAPPED_BASE;
85262 +
85263 +#ifdef CONFIG_PAX_RANDMMAP
85264 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85265 + mm->mmap_base += mm->delta_mmap;
85266 +#endif
85267 +
85268 mm->get_unmapped_area = arch_get_unmapped_area;
85269 mm->unmap_area = arch_unmap_area;
85270 }
85271 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85272 index 0f751f2..2bc3bd1 100644
85273 --- a/mm/vmalloc.c
85274 +++ b/mm/vmalloc.c
85275 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85276
85277 pte = pte_offset_kernel(pmd, addr);
85278 do {
85279 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85280 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85281 +
85282 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85283 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85284 + BUG_ON(!pte_exec(*pte));
85285 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85286 + continue;
85287 + }
85288 +#endif
85289 +
85290 + {
85291 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85292 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85293 + }
85294 } while (pte++, addr += PAGE_SIZE, addr != end);
85295 }
85296
85297 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85298 pte = pte_alloc_kernel(pmd, addr);
85299 if (!pte)
85300 return -ENOMEM;
85301 +
85302 + pax_open_kernel();
85303 do {
85304 struct page *page = pages[*nr];
85305
85306 - if (WARN_ON(!pte_none(*pte)))
85307 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85308 + if (pgprot_val(prot) & _PAGE_NX)
85309 +#endif
85310 +
85311 + if (!pte_none(*pte)) {
85312 + pax_close_kernel();
85313 + WARN_ON(1);
85314 return -EBUSY;
85315 - if (WARN_ON(!page))
85316 + }
85317 + if (!page) {
85318 + pax_close_kernel();
85319 + WARN_ON(1);
85320 return -ENOMEM;
85321 + }
85322 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85323 (*nr)++;
85324 } while (pte++, addr += PAGE_SIZE, addr != end);
85325 + pax_close_kernel();
85326 return 0;
85327 }
85328
85329 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85330 pmd_t *pmd;
85331 unsigned long next;
85332
85333 - pmd = pmd_alloc(&init_mm, pud, addr);
85334 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85335 if (!pmd)
85336 return -ENOMEM;
85337 do {
85338 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85339 pud_t *pud;
85340 unsigned long next;
85341
85342 - pud = pud_alloc(&init_mm, pgd, addr);
85343 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85344 if (!pud)
85345 return -ENOMEM;
85346 do {
85347 @@ -196,6 +220,12 @@ int is_vmalloc_or_module_addr(const void *x)
85348 if (addr >= MODULES_VADDR && addr < MODULES_END)
85349 return 1;
85350 #endif
85351 +
85352 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85353 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85354 + return 1;
85355 +#endif
85356 +
85357 return is_vmalloc_addr(x);
85358 }
85359
85360 @@ -216,8 +246,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85361
85362 if (!pgd_none(*pgd)) {
85363 pud_t *pud = pud_offset(pgd, addr);
85364 +#ifdef CONFIG_X86
85365 + if (!pud_large(*pud))
85366 +#endif
85367 if (!pud_none(*pud)) {
85368 pmd_t *pmd = pmd_offset(pud, addr);
85369 +#ifdef CONFIG_X86
85370 + if (!pmd_large(*pmd))
85371 +#endif
85372 if (!pmd_none(*pmd)) {
85373 pte_t *ptep, pte;
85374
85375 @@ -329,7 +365,7 @@ static void purge_vmap_area_lazy(void);
85376 * Allocate a region of KVA of the specified size and alignment, within the
85377 * vstart and vend.
85378 */
85379 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85380 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85381 unsigned long align,
85382 unsigned long vstart, unsigned long vend,
85383 int node, gfp_t gfp_mask)
85384 @@ -1328,6 +1364,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85385 struct vm_struct *area;
85386
85387 BUG_ON(in_interrupt());
85388 +
85389 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85390 + if (flags & VM_KERNEXEC) {
85391 + if (start != VMALLOC_START || end != VMALLOC_END)
85392 + return NULL;
85393 + start = (unsigned long)MODULES_EXEC_VADDR;
85394 + end = (unsigned long)MODULES_EXEC_END;
85395 + }
85396 +#endif
85397 +
85398 if (flags & VM_IOREMAP) {
85399 int bit = fls(size);
85400
85401 @@ -1569,6 +1615,11 @@ void *vmap(struct page **pages, unsigned int count,
85402 if (count > totalram_pages)
85403 return NULL;
85404
85405 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85406 + if (!(pgprot_val(prot) & _PAGE_NX))
85407 + flags |= VM_KERNEXEC;
85408 +#endif
85409 +
85410 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85411 __builtin_return_address(0));
85412 if (!area)
85413 @@ -1670,6 +1721,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85414 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85415 goto fail;
85416
85417 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85418 + if (!(pgprot_val(prot) & _PAGE_NX))
85419 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85420 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85421 + else
85422 +#endif
85423 +
85424 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85425 start, end, node, gfp_mask, caller);
85426 if (!area)
85427 @@ -1845,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
85428 * For tight control over page level allocator and protection flags
85429 * use __vmalloc() instead.
85430 */
85431 -
85432 void *vmalloc_exec(unsigned long size)
85433 {
85434 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85435 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85436 NUMA_NO_NODE, __builtin_return_address(0));
85437 }
85438
85439 @@ -2139,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85440 unsigned long uaddr = vma->vm_start;
85441 unsigned long usize = vma->vm_end - vma->vm_start;
85442
85443 + BUG_ON(vma->vm_mirror);
85444 +
85445 if ((PAGE_SIZE-1) & (unsigned long)addr)
85446 return -EINVAL;
85447
85448 @@ -2578,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
85449 v->addr, v->addr + v->size, v->size);
85450
85451 if (v->caller)
85452 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85453 + seq_printf(m, " %pK", v->caller);
85454 +#else
85455 seq_printf(m, " %pS", v->caller);
85456 +#endif
85457
85458 if (v->nr_pages)
85459 seq_printf(m, " pages=%d", v->nr_pages);
85460 diff --git a/mm/vmstat.c b/mm/vmstat.c
85461 index e1d8ed1..253fa3c 100644
85462 --- a/mm/vmstat.c
85463 +++ b/mm/vmstat.c
85464 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85465 *
85466 * vm_stat contains the global counters
85467 */
85468 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85469 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85470 EXPORT_SYMBOL(vm_stat);
85471
85472 #ifdef CONFIG_SMP
85473 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85474 v = p->vm_stat_diff[i];
85475 p->vm_stat_diff[i] = 0;
85476 local_irq_restore(flags);
85477 - atomic_long_add(v, &zone->vm_stat[i]);
85478 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85479 global_diff[i] += v;
85480 #ifdef CONFIG_NUMA
85481 /* 3 seconds idle till flush */
85482 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85483
85484 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85485 if (global_diff[i])
85486 - atomic_long_add(global_diff[i], &vm_stat[i]);
85487 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85488 }
85489
85490 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85491 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85492 if (pset->vm_stat_diff[i]) {
85493 int v = pset->vm_stat_diff[i];
85494 pset->vm_stat_diff[i] = 0;
85495 - atomic_long_add(v, &zone->vm_stat[i]);
85496 - atomic_long_add(v, &vm_stat[i]);
85497 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85498 + atomic_long_add_unchecked(v, &vm_stat[i]);
85499 }
85500 }
85501 #endif
85502 @@ -1224,7 +1224,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85503 return NOTIFY_OK;
85504 }
85505
85506 -static struct notifier_block __cpuinitdata vmstat_notifier =
85507 +static struct notifier_block vmstat_notifier =
85508 { &vmstat_cpuup_callback, NULL, 0 };
85509 #endif
85510
85511 @@ -1239,10 +1239,20 @@ static int __init setup_vmstat(void)
85512 start_cpu_timer(cpu);
85513 #endif
85514 #ifdef CONFIG_PROC_FS
85515 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85516 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85517 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85518 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85519 + {
85520 + mode_t gr_mode = S_IRUGO;
85521 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85522 + gr_mode = S_IRUSR;
85523 +#endif
85524 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85525 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85526 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85527 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85528 +#else
85529 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85530 +#endif
85531 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85532 + }
85533 #endif
85534 return 0;
85535 }
85536 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85537 index 85addcd..c429a13 100644
85538 --- a/net/8021q/vlan.c
85539 +++ b/net/8021q/vlan.c
85540 @@ -114,6 +114,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85541 if (vlan_id)
85542 vlan_vid_del(real_dev, vlan_id);
85543
85544 + /* Take it out of our own structures, but be sure to interlock with
85545 + * HW accelerating devices or SW vlan input packet processing if
85546 + * VLAN is not 0 (leave it there for 802.1p).
85547 + */
85548 + if (vlan_id)
85549 + vlan_vid_del(real_dev, vlan_id);
85550 +
85551 /* Get rid of the vlan's reference to real_dev */
85552 dev_put(real_dev);
85553 }
85554 @@ -496,7 +503,7 @@ out:
85555 return NOTIFY_DONE;
85556 }
85557
85558 -static struct notifier_block vlan_notifier_block __read_mostly = {
85559 +static struct notifier_block vlan_notifier_block = {
85560 .notifier_call = vlan_device_event,
85561 };
85562
85563 @@ -571,8 +578,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85564 err = -EPERM;
85565 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85566 break;
85567 - if ((args.u.name_type >= 0) &&
85568 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85569 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85570 struct vlan_net *vn;
85571
85572 vn = net_generic(net, vlan_net_id);
85573 diff --git a/net/9p/mod.c b/net/9p/mod.c
85574 index 6ab36ae..6f1841b 100644
85575 --- a/net/9p/mod.c
85576 +++ b/net/9p/mod.c
85577 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85578 void v9fs_register_trans(struct p9_trans_module *m)
85579 {
85580 spin_lock(&v9fs_trans_lock);
85581 - list_add_tail(&m->list, &v9fs_trans_list);
85582 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85583 spin_unlock(&v9fs_trans_lock);
85584 }
85585 EXPORT_SYMBOL(v9fs_register_trans);
85586 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85587 void v9fs_unregister_trans(struct p9_trans_module *m)
85588 {
85589 spin_lock(&v9fs_trans_lock);
85590 - list_del_init(&m->list);
85591 + pax_list_del_init((struct list_head *)&m->list);
85592 spin_unlock(&v9fs_trans_lock);
85593 }
85594 EXPORT_SYMBOL(v9fs_unregister_trans);
85595 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85596 index 02efb25..41541a9 100644
85597 --- a/net/9p/trans_fd.c
85598 +++ b/net/9p/trans_fd.c
85599 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85600 oldfs = get_fs();
85601 set_fs(get_ds());
85602 /* The cast to a user pointer is valid due to the set_fs() */
85603 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85604 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85605 set_fs(oldfs);
85606
85607 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85608 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85609 index 876fbe8..8bbea9f 100644
85610 --- a/net/atm/atm_misc.c
85611 +++ b/net/atm/atm_misc.c
85612 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85613 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85614 return 1;
85615 atm_return(vcc, truesize);
85616 - atomic_inc(&vcc->stats->rx_drop);
85617 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85618 return 0;
85619 }
85620 EXPORT_SYMBOL(atm_charge);
85621 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85622 }
85623 }
85624 atm_return(vcc, guess);
85625 - atomic_inc(&vcc->stats->rx_drop);
85626 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85627 return NULL;
85628 }
85629 EXPORT_SYMBOL(atm_alloc_charge);
85630 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85631
85632 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85633 {
85634 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85635 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85636 __SONET_ITEMS
85637 #undef __HANDLE_ITEM
85638 }
85639 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85640
85641 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85642 {
85643 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85644 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85645 __SONET_ITEMS
85646 #undef __HANDLE_ITEM
85647 }
85648 diff --git a/net/atm/lec.h b/net/atm/lec.h
85649 index a86aff9..3a0d6f6 100644
85650 --- a/net/atm/lec.h
85651 +++ b/net/atm/lec.h
85652 @@ -48,7 +48,7 @@ struct lane2_ops {
85653 const u8 *tlvs, u32 sizeoftlvs);
85654 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85655 const u8 *tlvs, u32 sizeoftlvs);
85656 -};
85657 +} __no_const;
85658
85659 /*
85660 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85661 diff --git a/net/atm/proc.c b/net/atm/proc.c
85662 index 6ac35ff..ac0e136 100644
85663 --- a/net/atm/proc.c
85664 +++ b/net/atm/proc.c
85665 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85666 const struct k_atm_aal_stats *stats)
85667 {
85668 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85669 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85670 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85671 - atomic_read(&stats->rx_drop));
85672 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85673 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85674 + atomic_read_unchecked(&stats->rx_drop));
85675 }
85676
85677 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85678 diff --git a/net/atm/resources.c b/net/atm/resources.c
85679 index 0447d5d..3cf4728 100644
85680 --- a/net/atm/resources.c
85681 +++ b/net/atm/resources.c
85682 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85683 static void copy_aal_stats(struct k_atm_aal_stats *from,
85684 struct atm_aal_stats *to)
85685 {
85686 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85687 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85688 __AAL_STAT_ITEMS
85689 #undef __HANDLE_ITEM
85690 }
85691 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85692 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85693 struct atm_aal_stats *to)
85694 {
85695 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85696 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85697 __AAL_STAT_ITEMS
85698 #undef __HANDLE_ITEM
85699 }
85700 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85701 index d5744b7..506bae3 100644
85702 --- a/net/ax25/sysctl_net_ax25.c
85703 +++ b/net/ax25/sysctl_net_ax25.c
85704 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85705 {
85706 char path[sizeof("net/ax25/") + IFNAMSIZ];
85707 int k;
85708 - struct ctl_table *table;
85709 + ctl_table_no_const *table;
85710
85711 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85712 if (!table)
85713 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85714 index a5bb0a7..e1d8b97 100644
85715 --- a/net/batman-adv/bat_iv_ogm.c
85716 +++ b/net/batman-adv/bat_iv_ogm.c
85717 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85718
85719 /* randomize initial seqno to avoid collision */
85720 get_random_bytes(&random_seqno, sizeof(random_seqno));
85721 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85722 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85723
85724 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85725 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85726 @@ -611,9 +611,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85727 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85728
85729 /* change sequence number to network order */
85730 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85731 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85732 batadv_ogm_packet->seqno = htonl(seqno);
85733 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85734 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85735
85736 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85737 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85738 @@ -1013,7 +1013,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85739 return;
85740
85741 /* could be changed by schedule_own_packet() */
85742 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85743 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85744
85745 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85746 has_directlink_flag = 1;
85747 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85748 index 368219e..53f56f9 100644
85749 --- a/net/batman-adv/hard-interface.c
85750 +++ b/net/batman-adv/hard-interface.c
85751 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85752 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85753 dev_add_pack(&hard_iface->batman_adv_ptype);
85754
85755 - atomic_set(&hard_iface->frag_seqno, 1);
85756 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85757 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85758 hard_iface->net_dev->name);
85759
85760 @@ -514,7 +514,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85761 /* This can't be called via a bat_priv callback because
85762 * we have no bat_priv yet.
85763 */
85764 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85765 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85766 hard_iface->bat_iv.ogm_buff = NULL;
85767
85768 return hard_iface;
85769 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85770 index 2711e87..4ca48fa 100644
85771 --- a/net/batman-adv/soft-interface.c
85772 +++ b/net/batman-adv/soft-interface.c
85773 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85774 primary_if->net_dev->dev_addr, ETH_ALEN);
85775
85776 /* set broadcast sequence number */
85777 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85778 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85779 bcast_packet->seqno = htonl(seqno);
85780
85781 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85782 @@ -527,7 +527,7 @@ struct net_device *batadv_softif_create(const char *name)
85783 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85784
85785 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85786 - atomic_set(&bat_priv->bcast_seqno, 1);
85787 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85788 atomic_set(&bat_priv->tt.vn, 0);
85789 atomic_set(&bat_priv->tt.local_changes, 0);
85790 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85791 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85792 index 4cd87a0..348e705 100644
85793 --- a/net/batman-adv/types.h
85794 +++ b/net/batman-adv/types.h
85795 @@ -51,7 +51,7 @@
85796 struct batadv_hard_iface_bat_iv {
85797 unsigned char *ogm_buff;
85798 int ogm_buff_len;
85799 - atomic_t ogm_seqno;
85800 + atomic_unchecked_t ogm_seqno;
85801 };
85802
85803 /**
85804 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
85805 int16_t if_num;
85806 char if_status;
85807 struct net_device *net_dev;
85808 - atomic_t frag_seqno;
85809 + atomic_unchecked_t frag_seqno;
85810 struct kobject *hardif_obj;
85811 atomic_t refcount;
85812 struct packet_type batman_adv_ptype;
85813 @@ -495,7 +495,7 @@ struct batadv_priv {
85814 #ifdef CONFIG_BATMAN_ADV_DEBUG
85815 atomic_t log_level;
85816 #endif
85817 - atomic_t bcast_seqno;
85818 + atomic_unchecked_t bcast_seqno;
85819 atomic_t bcast_queue_left;
85820 atomic_t batman_queue_left;
85821 char num_ifaces;
85822 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85823 index 50e079f..49ce2d2 100644
85824 --- a/net/batman-adv/unicast.c
85825 +++ b/net/batman-adv/unicast.c
85826 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85827 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85828 frag2->flags = large_tail;
85829
85830 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85831 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85832 frag1->seqno = htons(seqno - 1);
85833 frag2->seqno = htons(seqno);
85834
85835 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
85836 index b88605f..958e3e2 100644
85837 --- a/net/bluetooth/hci_core.c
85838 +++ b/net/bluetooth/hci_core.c
85839 @@ -1793,16 +1793,16 @@ int hci_register_dev(struct hci_dev *hdev)
85840 list_add(&hdev->list, &hci_dev_list);
85841 write_unlock(&hci_dev_list_lock);
85842
85843 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
85844 - WQ_MEM_RECLAIM, 1);
85845 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
85846 + WQ_MEM_RECLAIM, 1, hdev->name);
85847 if (!hdev->workqueue) {
85848 error = -ENOMEM;
85849 goto err;
85850 }
85851
85852 - hdev->req_workqueue = alloc_workqueue(hdev->name,
85853 + hdev->req_workqueue = alloc_workqueue("%s",
85854 WQ_HIGHPRI | WQ_UNBOUND |
85855 - WQ_MEM_RECLAIM, 1);
85856 + WQ_MEM_RECLAIM, 1, hdev->name);
85857 if (!hdev->req_workqueue) {
85858 destroy_workqueue(hdev->workqueue);
85859 error = -ENOMEM;
85860 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85861 index 6a93614..1415549 100644
85862 --- a/net/bluetooth/hci_sock.c
85863 +++ b/net/bluetooth/hci_sock.c
85864 @@ -929,7 +929,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85865 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85866 }
85867
85868 - len = min_t(unsigned int, len, sizeof(uf));
85869 + len = min((size_t)len, sizeof(uf));
85870 if (copy_from_user(&uf, optval, len)) {
85871 err = -EFAULT;
85872 break;
85873 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85874 index c5f9cd6..8d23158 100644
85875 --- a/net/bluetooth/l2cap_core.c
85876 +++ b/net/bluetooth/l2cap_core.c
85877 @@ -3395,8 +3395,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85878 break;
85879
85880 case L2CAP_CONF_RFC:
85881 - if (olen == sizeof(rfc))
85882 - memcpy(&rfc, (void *)val, olen);
85883 + if (olen != sizeof(rfc))
85884 + break;
85885 +
85886 + memcpy(&rfc, (void *)val, olen);
85887
85888 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85889 rfc.mode != chan->mode)
85890 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85891 index 1bcfb84..dad9f98 100644
85892 --- a/net/bluetooth/l2cap_sock.c
85893 +++ b/net/bluetooth/l2cap_sock.c
85894 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85895 struct sock *sk = sock->sk;
85896 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85897 struct l2cap_options opts;
85898 - int len, err = 0;
85899 + int err = 0;
85900 + size_t len = optlen;
85901 u32 opt;
85902
85903 BT_DBG("sk %p", sk);
85904 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85905 opts.max_tx = chan->max_tx;
85906 opts.txwin_size = chan->tx_win;
85907
85908 - len = min_t(unsigned int, sizeof(opts), optlen);
85909 + len = min(sizeof(opts), len);
85910 if (copy_from_user((char *) &opts, optval, len)) {
85911 err = -EFAULT;
85912 break;
85913 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85914 struct bt_security sec;
85915 struct bt_power pwr;
85916 struct l2cap_conn *conn;
85917 - int len, err = 0;
85918 + int err = 0;
85919 + size_t len = optlen;
85920 u32 opt;
85921
85922 BT_DBG("sk %p", sk);
85923 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85924
85925 sec.level = BT_SECURITY_LOW;
85926
85927 - len = min_t(unsigned int, sizeof(sec), optlen);
85928 + len = min(sizeof(sec), len);
85929 if (copy_from_user((char *) &sec, optval, len)) {
85930 err = -EFAULT;
85931 break;
85932 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85933
85934 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85935
85936 - len = min_t(unsigned int, sizeof(pwr), optlen);
85937 + len = min(sizeof(pwr), len);
85938 if (copy_from_user((char *) &pwr, optval, len)) {
85939 err = -EFAULT;
85940 break;
85941 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85942 index 7c9224b..381009e 100644
85943 --- a/net/bluetooth/rfcomm/sock.c
85944 +++ b/net/bluetooth/rfcomm/sock.c
85945 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85946 struct sock *sk = sock->sk;
85947 struct bt_security sec;
85948 int err = 0;
85949 - size_t len;
85950 + size_t len = optlen;
85951 u32 opt;
85952
85953 BT_DBG("sk %p", sk);
85954 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85955
85956 sec.level = BT_SECURITY_LOW;
85957
85958 - len = min_t(unsigned int, sizeof(sec), optlen);
85959 + len = min(sizeof(sec), len);
85960 if (copy_from_user((char *) &sec, optval, len)) {
85961 err = -EFAULT;
85962 break;
85963 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85964 index b6e44ad..5b0d514 100644
85965 --- a/net/bluetooth/rfcomm/tty.c
85966 +++ b/net/bluetooth/rfcomm/tty.c
85967 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85968 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85969
85970 spin_lock_irqsave(&dev->port.lock, flags);
85971 - if (dev->port.count > 0) {
85972 + if (atomic_read(&dev->port.count) > 0) {
85973 spin_unlock_irqrestore(&dev->port.lock, flags);
85974 return;
85975 }
85976 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85977 return -ENODEV;
85978
85979 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85980 - dev->channel, dev->port.count);
85981 + dev->channel, atomic_read(&dev->port.count));
85982
85983 spin_lock_irqsave(&dev->port.lock, flags);
85984 - if (++dev->port.count > 1) {
85985 + if (atomic_inc_return(&dev->port.count) > 1) {
85986 spin_unlock_irqrestore(&dev->port.lock, flags);
85987 return 0;
85988 }
85989 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85990 return;
85991
85992 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85993 - dev->port.count);
85994 + atomic_read(&dev->port.count));
85995
85996 spin_lock_irqsave(&dev->port.lock, flags);
85997 - if (!--dev->port.count) {
85998 + if (!atomic_dec_return(&dev->port.count)) {
85999 spin_unlock_irqrestore(&dev->port.lock, flags);
86000 if (dev->tty_dev->parent)
86001 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
86002 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
86003 index 8d493c9..3849e49 100644
86004 --- a/net/bridge/netfilter/ebtables.c
86005 +++ b/net/bridge/netfilter/ebtables.c
86006 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86007 tmp.valid_hooks = t->table->valid_hooks;
86008 }
86009 mutex_unlock(&ebt_mutex);
86010 - if (copy_to_user(user, &tmp, *len) != 0){
86011 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
86012 BUGPRINT("c2u Didn't work\n");
86013 ret = -EFAULT;
86014 break;
86015 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86016 goto out;
86017 tmp.valid_hooks = t->valid_hooks;
86018
86019 - if (copy_to_user(user, &tmp, *len) != 0) {
86020 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86021 ret = -EFAULT;
86022 break;
86023 }
86024 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86025 tmp.entries_size = t->table->entries_size;
86026 tmp.valid_hooks = t->table->valid_hooks;
86027
86028 - if (copy_to_user(user, &tmp, *len) != 0) {
86029 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86030 ret = -EFAULT;
86031 break;
86032 }
86033 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
86034 index a376ec1..1fbd6be 100644
86035 --- a/net/caif/cfctrl.c
86036 +++ b/net/caif/cfctrl.c
86037 @@ -10,6 +10,7 @@
86038 #include <linux/spinlock.h>
86039 #include <linux/slab.h>
86040 #include <linux/pkt_sched.h>
86041 +#include <linux/sched.h>
86042 #include <net/caif/caif_layer.h>
86043 #include <net/caif/cfpkt.h>
86044 #include <net/caif/cfctrl.h>
86045 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
86046 memset(&dev_info, 0, sizeof(dev_info));
86047 dev_info.id = 0xff;
86048 cfsrvl_init(&this->serv, 0, &dev_info, false);
86049 - atomic_set(&this->req_seq_no, 1);
86050 - atomic_set(&this->rsp_seq_no, 1);
86051 + atomic_set_unchecked(&this->req_seq_no, 1);
86052 + atomic_set_unchecked(&this->rsp_seq_no, 1);
86053 this->serv.layer.receive = cfctrl_recv;
86054 sprintf(this->serv.layer.name, "ctrl");
86055 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
86056 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
86057 struct cfctrl_request_info *req)
86058 {
86059 spin_lock_bh(&ctrl->info_list_lock);
86060 - atomic_inc(&ctrl->req_seq_no);
86061 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
86062 + atomic_inc_unchecked(&ctrl->req_seq_no);
86063 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
86064 list_add_tail(&req->list, &ctrl->list);
86065 spin_unlock_bh(&ctrl->info_list_lock);
86066 }
86067 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
86068 if (p != first)
86069 pr_warn("Requests are not received in order\n");
86070
86071 - atomic_set(&ctrl->rsp_seq_no,
86072 + atomic_set_unchecked(&ctrl->rsp_seq_no,
86073 p->sequence_no);
86074 list_del(&p->list);
86075 goto out;
86076 diff --git a/net/can/af_can.c b/net/can/af_can.c
86077 index c48e522..1223690 100644
86078 --- a/net/can/af_can.c
86079 +++ b/net/can/af_can.c
86080 @@ -870,7 +870,7 @@ static const struct net_proto_family can_family_ops = {
86081 };
86082
86083 /* notifier block for netdevice event */
86084 -static struct notifier_block can_netdev_notifier __read_mostly = {
86085 +static struct notifier_block can_netdev_notifier = {
86086 .notifier_call = can_notifier,
86087 };
86088
86089 diff --git a/net/can/gw.c b/net/can/gw.c
86090 index 117814a..ad4fb73 100644
86091 --- a/net/can/gw.c
86092 +++ b/net/can/gw.c
86093 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
86094 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
86095
86096 static HLIST_HEAD(cgw_list);
86097 -static struct notifier_block notifier;
86098
86099 static struct kmem_cache *cgw_cache __read_mostly;
86100
86101 @@ -928,6 +927,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
86102 return err;
86103 }
86104
86105 +static struct notifier_block notifier = {
86106 + .notifier_call = cgw_notifier
86107 +};
86108 +
86109 static __init int cgw_module_init(void)
86110 {
86111 /* sanitize given module parameter */
86112 @@ -943,7 +946,6 @@ static __init int cgw_module_init(void)
86113 return -ENOMEM;
86114
86115 /* set notifier */
86116 - notifier.notifier_call = cgw_notifier;
86117 register_netdevice_notifier(&notifier);
86118
86119 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
86120 diff --git a/net/compat.c b/net/compat.c
86121 index 79ae884..0541331 100644
86122 --- a/net/compat.c
86123 +++ b/net/compat.c
86124 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
86125 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
86126 __get_user(kmsg->msg_flags, &umsg->msg_flags))
86127 return -EFAULT;
86128 - kmsg->msg_name = compat_ptr(tmp1);
86129 - kmsg->msg_iov = compat_ptr(tmp2);
86130 - kmsg->msg_control = compat_ptr(tmp3);
86131 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
86132 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
86133 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
86134 return 0;
86135 }
86136
86137 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86138
86139 if (kern_msg->msg_namelen) {
86140 if (mode == VERIFY_READ) {
86141 - int err = move_addr_to_kernel(kern_msg->msg_name,
86142 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
86143 kern_msg->msg_namelen,
86144 kern_address);
86145 if (err < 0)
86146 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86147 kern_msg->msg_name = NULL;
86148
86149 tot_len = iov_from_user_compat_to_kern(kern_iov,
86150 - (struct compat_iovec __user *)kern_msg->msg_iov,
86151 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
86152 kern_msg->msg_iovlen);
86153 if (tot_len >= 0)
86154 kern_msg->msg_iov = kern_iov;
86155 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86156
86157 #define CMSG_COMPAT_FIRSTHDR(msg) \
86158 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
86159 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
86160 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
86161 (struct compat_cmsghdr __user *)NULL)
86162
86163 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
86164 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
86165 (ucmlen) <= (unsigned long) \
86166 ((mhdr)->msg_controllen - \
86167 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
86168 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
86169
86170 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
86171 struct compat_cmsghdr __user *cmsg, int cmsg_len)
86172 {
86173 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
86174 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
86175 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
86176 msg->msg_controllen)
86177 return NULL;
86178 return (struct compat_cmsghdr __user *)ptr;
86179 @@ -219,7 +219,7 @@ Efault:
86180
86181 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
86182 {
86183 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86184 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86185 struct compat_cmsghdr cmhdr;
86186 struct compat_timeval ctv;
86187 struct compat_timespec cts[3];
86188 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
86189
86190 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
86191 {
86192 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86193 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86194 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
86195 int fdnum = scm->fp->count;
86196 struct file **fp = scm->fp->fp;
86197 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
86198 return -EFAULT;
86199 old_fs = get_fs();
86200 set_fs(KERNEL_DS);
86201 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
86202 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
86203 set_fs(old_fs);
86204
86205 return err;
86206 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
86207 len = sizeof(ktime);
86208 old_fs = get_fs();
86209 set_fs(KERNEL_DS);
86210 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
86211 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
86212 set_fs(old_fs);
86213
86214 if (!err) {
86215 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86216 case MCAST_JOIN_GROUP:
86217 case MCAST_LEAVE_GROUP:
86218 {
86219 - struct compat_group_req __user *gr32 = (void *)optval;
86220 + struct compat_group_req __user *gr32 = (void __user *)optval;
86221 struct group_req __user *kgr =
86222 compat_alloc_user_space(sizeof(struct group_req));
86223 u32 interface;
86224 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86225 case MCAST_BLOCK_SOURCE:
86226 case MCAST_UNBLOCK_SOURCE:
86227 {
86228 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86229 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86230 struct group_source_req __user *kgsr = compat_alloc_user_space(
86231 sizeof(struct group_source_req));
86232 u32 interface;
86233 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86234 }
86235 case MCAST_MSFILTER:
86236 {
86237 - struct compat_group_filter __user *gf32 = (void *)optval;
86238 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86239 struct group_filter __user *kgf;
86240 u32 interface, fmode, numsrc;
86241
86242 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86243 char __user *optval, int __user *optlen,
86244 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86245 {
86246 - struct compat_group_filter __user *gf32 = (void *)optval;
86247 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86248 struct group_filter __user *kgf;
86249 int __user *koptlen;
86250 u32 interface, fmode, numsrc;
86251 @@ -734,19 +734,25 @@ static unsigned char nas[21] = {
86252
86253 asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags)
86254 {
86255 - return sys_sendmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
86256 + if (flags & MSG_CMSG_COMPAT)
86257 + return -EINVAL;
86258 + return __sys_sendmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
86259 }
86260
86261 asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
86262 unsigned int vlen, unsigned int flags)
86263 {
86264 + if (flags & MSG_CMSG_COMPAT)
86265 + return -EINVAL;
86266 return __sys_sendmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
86267 flags | MSG_CMSG_COMPAT);
86268 }
86269
86270 asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags)
86271 {
86272 - return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
86273 + if (flags & MSG_CMSG_COMPAT)
86274 + return -EINVAL;
86275 + return __sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
86276 }
86277
86278 asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len, unsigned int flags)
86279 @@ -768,6 +774,9 @@ asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
86280 int datagrams;
86281 struct timespec ktspec;
86282
86283 + if (flags & MSG_CMSG_COMPAT)
86284 + return -EINVAL;
86285 +
86286 if (COMPAT_USE_64BIT_TIME)
86287 return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
86288 flags | MSG_CMSG_COMPAT,
86289 @@ -796,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86290
86291 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86292 return -EINVAL;
86293 - if (copy_from_user(a, args, nas[call]))
86294 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86295 return -EFAULT;
86296 a0 = a[0];
86297 a1 = a[1];
86298 diff --git a/net/core/datagram.c b/net/core/datagram.c
86299 index 368f9c3..f82d4a3 100644
86300 --- a/net/core/datagram.c
86301 +++ b/net/core/datagram.c
86302 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86303 }
86304
86305 kfree_skb(skb);
86306 - atomic_inc(&sk->sk_drops);
86307 + atomic_inc_unchecked(&sk->sk_drops);
86308 sk_mem_reclaim_partial(sk);
86309
86310 return err;
86311 diff --git a/net/core/dev.c b/net/core/dev.c
86312 index 9a278e9..15f2b9e 100644
86313 --- a/net/core/dev.c
86314 +++ b/net/core/dev.c
86315 @@ -1617,7 +1617,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86316 {
86317 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86318 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86319 - atomic_long_inc(&dev->rx_dropped);
86320 + atomic_long_inc_unchecked(&dev->rx_dropped);
86321 kfree_skb(skb);
86322 return NET_RX_DROP;
86323 }
86324 @@ -1626,7 +1626,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86325 skb_orphan(skb);
86326
86327 if (unlikely(!is_skb_forwardable(dev, skb))) {
86328 - atomic_long_inc(&dev->rx_dropped);
86329 + atomic_long_inc_unchecked(&dev->rx_dropped);
86330 kfree_skb(skb);
86331 return NET_RX_DROP;
86332 }
86333 @@ -2351,7 +2351,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86334
86335 struct dev_gso_cb {
86336 void (*destructor)(struct sk_buff *skb);
86337 -};
86338 +} __no_const;
86339
86340 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86341
86342 @@ -3093,7 +3093,7 @@ enqueue:
86343
86344 local_irq_restore(flags);
86345
86346 - atomic_long_inc(&skb->dev->rx_dropped);
86347 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86348 kfree_skb(skb);
86349 return NET_RX_DROP;
86350 }
86351 @@ -3165,7 +3165,7 @@ int netif_rx_ni(struct sk_buff *skb)
86352 }
86353 EXPORT_SYMBOL(netif_rx_ni);
86354
86355 -static void net_tx_action(struct softirq_action *h)
86356 +static void net_tx_action(void)
86357 {
86358 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86359
86360 @@ -3490,7 +3490,7 @@ ncls:
86361 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86362 } else {
86363 drop:
86364 - atomic_long_inc(&skb->dev->rx_dropped);
86365 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86366 kfree_skb(skb);
86367 /* Jamal, now you will not able to escape explaining
86368 * me how you were going to use this. :-)
86369 @@ -4095,7 +4095,7 @@ void netif_napi_del(struct napi_struct *napi)
86370 }
86371 EXPORT_SYMBOL(netif_napi_del);
86372
86373 -static void net_rx_action(struct softirq_action *h)
86374 +static void net_rx_action(void)
86375 {
86376 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86377 unsigned long time_limit = jiffies + 2;
86378 @@ -5522,7 +5522,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86379 } else {
86380 netdev_stats_to_stats64(storage, &dev->stats);
86381 }
86382 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86383 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86384 return storage;
86385 }
86386 EXPORT_SYMBOL(dev_get_stats);
86387 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
86388 index 6cc0481..59cfb00 100644
86389 --- a/net/core/dev_ioctl.c
86390 +++ b/net/core/dev_ioctl.c
86391 @@ -376,9 +376,13 @@ void dev_load(struct net *net, const char *name)
86392 if (no_module && capable(CAP_NET_ADMIN))
86393 no_module = request_module("netdev-%s", name);
86394 if (no_module && capable(CAP_SYS_MODULE)) {
86395 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86396 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86397 +#else
86398 if (!request_module("%s", name))
86399 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86400 name);
86401 +#endif
86402 }
86403 }
86404 EXPORT_SYMBOL(dev_load);
86405 diff --git a/net/core/flow.c b/net/core/flow.c
86406 index 2bfd081..53c6058 100644
86407 --- a/net/core/flow.c
86408 +++ b/net/core/flow.c
86409 @@ -61,7 +61,7 @@ struct flow_cache {
86410 struct timer_list rnd_timer;
86411 };
86412
86413 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86414 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86415 EXPORT_SYMBOL(flow_cache_genid);
86416 static struct flow_cache flow_cache_global;
86417 static struct kmem_cache *flow_cachep __read_mostly;
86418 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86419
86420 static int flow_entry_valid(struct flow_cache_entry *fle)
86421 {
86422 - if (atomic_read(&flow_cache_genid) != fle->genid)
86423 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86424 return 0;
86425 if (fle->object && !fle->object->ops->check(fle->object))
86426 return 0;
86427 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86428 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86429 fcp->hash_count++;
86430 }
86431 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86432 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86433 flo = fle->object;
86434 if (!flo)
86435 goto ret_object;
86436 @@ -279,7 +279,7 @@ nocache:
86437 }
86438 flo = resolver(net, key, family, dir, flo, ctx);
86439 if (fle) {
86440 - fle->genid = atomic_read(&flow_cache_genid);
86441 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86442 if (!IS_ERR(flo))
86443 fle->object = flo;
86444 else
86445 diff --git a/net/core/iovec.c b/net/core/iovec.c
86446 index 7e7aeb0..2a998cb 100644
86447 --- a/net/core/iovec.c
86448 +++ b/net/core/iovec.c
86449 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86450 if (m->msg_namelen) {
86451 if (mode == VERIFY_READ) {
86452 void __user *namep;
86453 - namep = (void __user __force *) m->msg_name;
86454 + namep = (void __force_user *) m->msg_name;
86455 err = move_addr_to_kernel(namep, m->msg_namelen,
86456 address);
86457 if (err < 0)
86458 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86459 }
86460
86461 size = m->msg_iovlen * sizeof(struct iovec);
86462 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86463 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86464 return -EFAULT;
86465
86466 m->msg_iov = iov;
86467 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86468 index 3863b8f..85c99a6 100644
86469 --- a/net/core/neighbour.c
86470 +++ b/net/core/neighbour.c
86471 @@ -2778,7 +2778,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86472 size_t *lenp, loff_t *ppos)
86473 {
86474 int size, ret;
86475 - ctl_table tmp = *ctl;
86476 + ctl_table_no_const tmp = *ctl;
86477
86478 tmp.extra1 = &zero;
86479 tmp.extra2 = &unres_qlen_max;
86480 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
86481 index 3174f19..5810985 100644
86482 --- a/net/core/net-procfs.c
86483 +++ b/net/core/net-procfs.c
86484 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86485 else
86486 seq_printf(seq, "%04x", ntohs(pt->type));
86487
86488 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86489 + seq_printf(seq, " %-8s %pF\n",
86490 + pt->dev ? pt->dev->name : "", NULL);
86491 +#else
86492 seq_printf(seq, " %-8s %pF\n",
86493 pt->dev ? pt->dev->name : "", pt->func);
86494 +#endif
86495 }
86496
86497 return 0;
86498 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86499 index 7427ab5..389f411 100644
86500 --- a/net/core/net-sysfs.c
86501 +++ b/net/core/net-sysfs.c
86502 @@ -1321,7 +1321,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86503 }
86504 EXPORT_SYMBOL(netdev_class_remove_file);
86505
86506 -int netdev_kobject_init(void)
86507 +int __init netdev_kobject_init(void)
86508 {
86509 kobj_ns_type_register(&net_ns_type_operations);
86510 return class_register(&net_class);
86511 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86512 index 80e271d..2980cc2 100644
86513 --- a/net/core/net_namespace.c
86514 +++ b/net/core/net_namespace.c
86515 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86516 int error;
86517 LIST_HEAD(net_exit_list);
86518
86519 - list_add_tail(&ops->list, list);
86520 + pax_list_add_tail((struct list_head *)&ops->list, list);
86521 if (ops->init || (ops->id && ops->size)) {
86522 for_each_net(net) {
86523 error = ops_init(ops, net);
86524 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86525
86526 out_undo:
86527 /* If I have an error cleanup all namespaces I initialized */
86528 - list_del(&ops->list);
86529 + pax_list_del((struct list_head *)&ops->list);
86530 ops_exit_list(ops, &net_exit_list);
86531 ops_free_list(ops, &net_exit_list);
86532 return error;
86533 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86534 struct net *net;
86535 LIST_HEAD(net_exit_list);
86536
86537 - list_del(&ops->list);
86538 + pax_list_del((struct list_head *)&ops->list);
86539 for_each_net(net)
86540 list_add_tail(&net->exit_list, &net_exit_list);
86541 ops_exit_list(ops, &net_exit_list);
86542 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86543 mutex_lock(&net_mutex);
86544 error = register_pernet_operations(&pernet_list, ops);
86545 if (!error && (first_device == &pernet_list))
86546 - first_device = &ops->list;
86547 + first_device = (struct list_head *)&ops->list;
86548 mutex_unlock(&net_mutex);
86549 return error;
86550 }
86551 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86552 index 23854b5..ff4fda4 100644
86553 --- a/net/core/rtnetlink.c
86554 +++ b/net/core/rtnetlink.c
86555 @@ -58,7 +58,7 @@ struct rtnl_link {
86556 rtnl_doit_func doit;
86557 rtnl_dumpit_func dumpit;
86558 rtnl_calcit_func calcit;
86559 -};
86560 +} __no_const;
86561
86562 static DEFINE_MUTEX(rtnl_mutex);
86563
86564 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86565 if (rtnl_link_ops_get(ops->kind))
86566 return -EEXIST;
86567
86568 - if (!ops->dellink)
86569 - ops->dellink = unregister_netdevice_queue;
86570 + if (!ops->dellink) {
86571 + pax_open_kernel();
86572 + *(void **)&ops->dellink = unregister_netdevice_queue;
86573 + pax_close_kernel();
86574 + }
86575
86576 - list_add_tail(&ops->list, &link_ops);
86577 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86578 return 0;
86579 }
86580 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86581 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86582 for_each_net(net) {
86583 __rtnl_kill_links(net, ops);
86584 }
86585 - list_del(&ops->list);
86586 + pax_list_del((struct list_head *)&ops->list);
86587 }
86588 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86589
86590 diff --git a/net/core/scm.c b/net/core/scm.c
86591 index 2dc6cda..2159524 100644
86592 --- a/net/core/scm.c
86593 +++ b/net/core/scm.c
86594 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86595 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86596 {
86597 struct cmsghdr __user *cm
86598 - = (__force struct cmsghdr __user *)msg->msg_control;
86599 + = (struct cmsghdr __force_user *)msg->msg_control;
86600 struct cmsghdr cmhdr;
86601 int cmlen = CMSG_LEN(len);
86602 int err;
86603 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86604 err = -EFAULT;
86605 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86606 goto out;
86607 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86608 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86609 goto out;
86610 cmlen = CMSG_SPACE(len);
86611 if (msg->msg_controllen < cmlen)
86612 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86613 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86614 {
86615 struct cmsghdr __user *cm
86616 - = (__force struct cmsghdr __user*)msg->msg_control;
86617 + = (struct cmsghdr __force_user *)msg->msg_control;
86618
86619 int fdmax = 0;
86620 int fdnum = scm->fp->count;
86621 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86622 if (fdnum < fdmax)
86623 fdmax = fdnum;
86624
86625 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86626 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86627 i++, cmfptr++)
86628 {
86629 struct socket *sock;
86630 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
86631 index e61a8bb..6a2f13c 100644
86632 --- a/net/core/secure_seq.c
86633 +++ b/net/core/secure_seq.c
86634 @@ -12,12 +12,10 @@
86635
86636 static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
86637
86638 -static int __init net_secret_init(void)
86639 +void net_secret_init(void)
86640 {
86641 get_random_bytes(net_secret, sizeof(net_secret));
86642 - return 0;
86643 }
86644 -late_initcall(net_secret_init);
86645
86646 #ifdef CONFIG_INET
86647 static u32 seq_scale(u32 seq)
86648 diff --git a/net/core/sock.c b/net/core/sock.c
86649 index 1432266..1a0d4a1 100644
86650 --- a/net/core/sock.c
86651 +++ b/net/core/sock.c
86652 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86653 struct sk_buff_head *list = &sk->sk_receive_queue;
86654
86655 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86656 - atomic_inc(&sk->sk_drops);
86657 + atomic_inc_unchecked(&sk->sk_drops);
86658 trace_sock_rcvqueue_full(sk, skb);
86659 return -ENOMEM;
86660 }
86661 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86662 return err;
86663
86664 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86665 - atomic_inc(&sk->sk_drops);
86666 + atomic_inc_unchecked(&sk->sk_drops);
86667 return -ENOBUFS;
86668 }
86669
86670 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86671 skb_dst_force(skb);
86672
86673 spin_lock_irqsave(&list->lock, flags);
86674 - skb->dropcount = atomic_read(&sk->sk_drops);
86675 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86676 __skb_queue_tail(list, skb);
86677 spin_unlock_irqrestore(&list->lock, flags);
86678
86679 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86680 skb->dev = NULL;
86681
86682 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86683 - atomic_inc(&sk->sk_drops);
86684 + atomic_inc_unchecked(&sk->sk_drops);
86685 goto discard_and_relse;
86686 }
86687 if (nested)
86688 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86689 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86690 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86691 bh_unlock_sock(sk);
86692 - atomic_inc(&sk->sk_drops);
86693 + atomic_inc_unchecked(&sk->sk_drops);
86694 goto discard_and_relse;
86695 }
86696
86697 @@ -942,12 +942,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86698 struct timeval tm;
86699 } v;
86700
86701 - int lv = sizeof(int);
86702 - int len;
86703 + unsigned int lv = sizeof(int);
86704 + unsigned int len;
86705
86706 if (get_user(len, optlen))
86707 return -EFAULT;
86708 - if (len < 0)
86709 + if (len > INT_MAX)
86710 return -EINVAL;
86711
86712 memset(&v, 0, sizeof(v));
86713 @@ -1099,11 +1099,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86714
86715 case SO_PEERNAME:
86716 {
86717 - char address[128];
86718 + char address[_K_SS_MAXSIZE];
86719
86720 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86721 return -ENOTCONN;
86722 - if (lv < len)
86723 + if (lv < len || sizeof address < len)
86724 return -EINVAL;
86725 if (copy_to_user(optval, address, len))
86726 return -EFAULT;
86727 @@ -1166,7 +1166,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86728
86729 if (len > lv)
86730 len = lv;
86731 - if (copy_to_user(optval, &v, len))
86732 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86733 return -EFAULT;
86734 lenout:
86735 if (put_user(len, optlen))
86736 @@ -2284,7 +2284,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86737 */
86738 smp_wmb();
86739 atomic_set(&sk->sk_refcnt, 1);
86740 - atomic_set(&sk->sk_drops, 0);
86741 + atomic_set_unchecked(&sk->sk_drops, 0);
86742 }
86743 EXPORT_SYMBOL(sock_init_data);
86744
86745 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86746 index a29e90c..922399c 100644
86747 --- a/net/core/sock_diag.c
86748 +++ b/net/core/sock_diag.c
86749 @@ -9,26 +9,33 @@
86750 #include <linux/inet_diag.h>
86751 #include <linux/sock_diag.h>
86752
86753 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86754 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86755 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86756 static DEFINE_MUTEX(sock_diag_table_mutex);
86757
86758 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86759 {
86760 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86761 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86762 cookie[1] != INET_DIAG_NOCOOKIE) &&
86763 ((u32)(unsigned long)sk != cookie[0] ||
86764 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86765 return -ESTALE;
86766 else
86767 +#endif
86768 return 0;
86769 }
86770 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86771
86772 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86773 {
86774 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86775 + cookie[0] = 0;
86776 + cookie[1] = 0;
86777 +#else
86778 cookie[0] = (u32)(unsigned long)sk;
86779 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86780 +#endif
86781 }
86782 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86783
86784 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86785 mutex_lock(&sock_diag_table_mutex);
86786 if (sock_diag_handlers[hndl->family])
86787 err = -EBUSY;
86788 - else
86789 + else {
86790 + pax_open_kernel();
86791 sock_diag_handlers[hndl->family] = hndl;
86792 + pax_close_kernel();
86793 + }
86794 mutex_unlock(&sock_diag_table_mutex);
86795
86796 return err;
86797 @@ -92,7 +102,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86798
86799 mutex_lock(&sock_diag_table_mutex);
86800 BUG_ON(sock_diag_handlers[family] != hnld);
86801 + pax_open_kernel();
86802 sock_diag_handlers[family] = NULL;
86803 + pax_close_kernel();
86804 mutex_unlock(&sock_diag_table_mutex);
86805 }
86806 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86807 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86808 index cfdb46a..cef55e1 100644
86809 --- a/net/core/sysctl_net_core.c
86810 +++ b/net/core/sysctl_net_core.c
86811 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86812 {
86813 unsigned int orig_size, size;
86814 int ret, i;
86815 - ctl_table tmp = {
86816 + ctl_table_no_const tmp = {
86817 .data = &size,
86818 .maxlen = sizeof(size),
86819 .mode = table->mode
86820 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
86821
86822 static __net_init int sysctl_core_net_init(struct net *net)
86823 {
86824 - struct ctl_table *tbl;
86825 + ctl_table_no_const *tbl = NULL;
86826
86827 net->core.sysctl_somaxconn = SOMAXCONN;
86828
86829 - tbl = netns_core_table;
86830 if (!net_eq(net, &init_net)) {
86831 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86832 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86833 if (tbl == NULL)
86834 goto err_dup;
86835
86836 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86837 if (net->user_ns != &init_user_ns) {
86838 tbl[0].procname = NULL;
86839 }
86840 - }
86841 -
86842 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86843 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86844 + } else
86845 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86846 if (net->core.sysctl_hdr == NULL)
86847 goto err_reg;
86848
86849 return 0;
86850
86851 err_reg:
86852 - if (tbl != netns_core_table)
86853 - kfree(tbl);
86854 + kfree(tbl);
86855 err_dup:
86856 return -ENOMEM;
86857 }
86858 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86859 kfree(tbl);
86860 }
86861
86862 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86863 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86864 .init = sysctl_core_net_init,
86865 .exit = sysctl_core_net_exit,
86866 };
86867 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86868 index c21f200..bc4565b 100644
86869 --- a/net/decnet/af_decnet.c
86870 +++ b/net/decnet/af_decnet.c
86871 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
86872 .sysctl_rmem = sysctl_decnet_rmem,
86873 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86874 .obj_size = sizeof(struct dn_sock),
86875 + .slab_flags = SLAB_USERCOPY,
86876 };
86877
86878 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86879 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86880 index a55eecc..dd8428c 100644
86881 --- a/net/decnet/sysctl_net_decnet.c
86882 +++ b/net/decnet/sysctl_net_decnet.c
86883 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86884
86885 if (len > *lenp) len = *lenp;
86886
86887 - if (copy_to_user(buffer, addr, len))
86888 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86889 return -EFAULT;
86890
86891 *lenp = len;
86892 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86893
86894 if (len > *lenp) len = *lenp;
86895
86896 - if (copy_to_user(buffer, devname, len))
86897 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86898 return -EFAULT;
86899
86900 *lenp = len;
86901 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86902 index c929d9c..df10cde 100644
86903 --- a/net/ipv4/af_inet.c
86904 +++ b/net/ipv4/af_inet.c
86905 @@ -115,6 +115,7 @@
86906 #include <net/inet_common.h>
86907 #include <net/xfrm.h>
86908 #include <net/net_namespace.h>
86909 +#include <net/secure_seq.h>
86910 #ifdef CONFIG_IP_MROUTE
86911 #include <linux/mroute.h>
86912 #endif
86913 @@ -263,8 +264,10 @@ void build_ehash_secret(void)
86914 get_random_bytes(&rnd, sizeof(rnd));
86915 } while (rnd == 0);
86916
86917 - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
86918 + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
86919 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
86920 + net_secret_init();
86921 + }
86922 }
86923 EXPORT_SYMBOL(build_ehash_secret);
86924
86925 @@ -1699,13 +1702,9 @@ static int __init inet_init(void)
86926
86927 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
86928
86929 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86930 - if (!sysctl_local_reserved_ports)
86931 - goto out;
86932 -
86933 rc = proto_register(&tcp_prot, 1);
86934 if (rc)
86935 - goto out_free_reserved_ports;
86936 + goto out;
86937
86938 rc = proto_register(&udp_prot, 1);
86939 if (rc)
86940 @@ -1814,8 +1813,6 @@ out_unregister_udp_proto:
86941 proto_unregister(&udp_prot);
86942 out_unregister_tcp_proto:
86943 proto_unregister(&tcp_prot);
86944 -out_free_reserved_ports:
86945 - kfree(sysctl_local_reserved_ports);
86946 goto out;
86947 }
86948
86949 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86950 index 2e7f194..0fa4d6d 100644
86951 --- a/net/ipv4/ah4.c
86952 +++ b/net/ipv4/ah4.c
86953 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86954 return;
86955
86956 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86957 - atomic_inc(&flow_cache_genid);
86958 + atomic_inc_unchecked(&flow_cache_genid);
86959 rt_genid_bump(net);
86960
86961 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86962 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86963 index c6287cd..e9bc96a 100644
86964 --- a/net/ipv4/devinet.c
86965 +++ b/net/ipv4/devinet.c
86966 @@ -1992,7 +1992,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86967 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86968 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86969
86970 -static struct devinet_sysctl_table {
86971 +static const struct devinet_sysctl_table {
86972 struct ctl_table_header *sysctl_header;
86973 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86974 } devinet_sysctl = {
86975 @@ -2110,7 +2110,7 @@ static __net_init int devinet_init_net(struct net *net)
86976 int err;
86977 struct ipv4_devconf *all, *dflt;
86978 #ifdef CONFIG_SYSCTL
86979 - struct ctl_table *tbl = ctl_forward_entry;
86980 + ctl_table_no_const *tbl = NULL;
86981 struct ctl_table_header *forw_hdr;
86982 #endif
86983
86984 @@ -2128,7 +2128,7 @@ static __net_init int devinet_init_net(struct net *net)
86985 goto err_alloc_dflt;
86986
86987 #ifdef CONFIG_SYSCTL
86988 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86989 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86990 if (tbl == NULL)
86991 goto err_alloc_ctl;
86992
86993 @@ -2148,7 +2148,10 @@ static __net_init int devinet_init_net(struct net *net)
86994 goto err_reg_dflt;
86995
86996 err = -ENOMEM;
86997 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86998 + if (!net_eq(net, &init_net))
86999 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
87000 + else
87001 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
87002 if (forw_hdr == NULL)
87003 goto err_reg_ctl;
87004 net->ipv4.forw_hdr = forw_hdr;
87005 @@ -2164,8 +2167,7 @@ err_reg_ctl:
87006 err_reg_dflt:
87007 __devinet_sysctl_unregister(all);
87008 err_reg_all:
87009 - if (tbl != ctl_forward_entry)
87010 - kfree(tbl);
87011 + kfree(tbl);
87012 err_alloc_ctl:
87013 #endif
87014 if (dflt != &ipv4_devconf_dflt)
87015 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
87016 index 4cfe34d..a6ba66e 100644
87017 --- a/net/ipv4/esp4.c
87018 +++ b/net/ipv4/esp4.c
87019 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
87020 return;
87021
87022 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87023 - atomic_inc(&flow_cache_genid);
87024 + atomic_inc_unchecked(&flow_cache_genid);
87025 rt_genid_bump(net);
87026
87027 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
87028 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
87029 index eb4bb12..ee4ec7d 100644
87030 --- a/net/ipv4/fib_frontend.c
87031 +++ b/net/ipv4/fib_frontend.c
87032 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
87033 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87034 fib_sync_up(dev);
87035 #endif
87036 - atomic_inc(&net->ipv4.dev_addr_genid);
87037 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87038 rt_cache_flush(dev_net(dev));
87039 break;
87040 case NETDEV_DOWN:
87041 fib_del_ifaddr(ifa, NULL);
87042 - atomic_inc(&net->ipv4.dev_addr_genid);
87043 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87044 if (ifa->ifa_dev->ifa_list == NULL) {
87045 /* Last address was deleted from this interface.
87046 * Disable IP.
87047 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
87048 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87049 fib_sync_up(dev);
87050 #endif
87051 - atomic_inc(&net->ipv4.dev_addr_genid);
87052 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87053 rt_cache_flush(net);
87054 break;
87055 case NETDEV_DOWN:
87056 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
87057 index 8f6cb7a..34507f9 100644
87058 --- a/net/ipv4/fib_semantics.c
87059 +++ b/net/ipv4/fib_semantics.c
87060 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
87061 nh->nh_saddr = inet_select_addr(nh->nh_dev,
87062 nh->nh_gw,
87063 nh->nh_parent->fib_scope);
87064 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
87065 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
87066
87067 return nh->nh_saddr;
87068 }
87069 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
87070 index 786d97a..1889c0d 100644
87071 --- a/net/ipv4/inet_connection_sock.c
87072 +++ b/net/ipv4/inet_connection_sock.c
87073 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
87074 .range = { 32768, 61000 },
87075 };
87076
87077 -unsigned long *sysctl_local_reserved_ports;
87078 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
87079 EXPORT_SYMBOL(sysctl_local_reserved_ports);
87080
87081 void inet_get_local_port_range(int *low, int *high)
87082 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
87083 index 6af375a..c493c74 100644
87084 --- a/net/ipv4/inet_hashtables.c
87085 +++ b/net/ipv4/inet_hashtables.c
87086 @@ -18,12 +18,15 @@
87087 #include <linux/sched.h>
87088 #include <linux/slab.h>
87089 #include <linux/wait.h>
87090 +#include <linux/security.h>
87091
87092 #include <net/inet_connection_sock.h>
87093 #include <net/inet_hashtables.h>
87094 #include <net/secure_seq.h>
87095 #include <net/ip.h>
87096
87097 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
87098 +
87099 /*
87100 * Allocate and initialize a new local port bind bucket.
87101 * The bindhash mutex for snum's hash chain must be held here.
87102 @@ -554,6 +557,8 @@ ok:
87103 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
87104 spin_unlock(&head->lock);
87105
87106 + gr_update_task_in_ip_table(current, inet_sk(sk));
87107 +
87108 if (tw) {
87109 inet_twsk_deschedule(tw, death_row);
87110 while (twrefcnt) {
87111 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
87112 index 000e3d2..5472da3 100644
87113 --- a/net/ipv4/inetpeer.c
87114 +++ b/net/ipv4/inetpeer.c
87115 @@ -503,8 +503,8 @@ relookup:
87116 if (p) {
87117 p->daddr = *daddr;
87118 atomic_set(&p->refcnt, 1);
87119 - atomic_set(&p->rid, 0);
87120 - atomic_set(&p->ip_id_count,
87121 + atomic_set_unchecked(&p->rid, 0);
87122 + atomic_set_unchecked(&p->ip_id_count,
87123 (daddr->family == AF_INET) ?
87124 secure_ip_id(daddr->addr.a4) :
87125 secure_ipv6_id(daddr->addr.a6));
87126 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
87127 index 52c273e..579060b 100644
87128 --- a/net/ipv4/ip_fragment.c
87129 +++ b/net/ipv4/ip_fragment.c
87130 @@ -311,7 +311,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
87131 return 0;
87132
87133 start = qp->rid;
87134 - end = atomic_inc_return(&peer->rid);
87135 + end = atomic_inc_return_unchecked(&peer->rid);
87136 qp->rid = end;
87137
87138 rc = qp->q.fragments && (end - start) > max;
87139 @@ -788,12 +788,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
87140
87141 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87142 {
87143 - struct ctl_table *table;
87144 + ctl_table_no_const *table = NULL;
87145 struct ctl_table_header *hdr;
87146
87147 - table = ip4_frags_ns_ctl_table;
87148 if (!net_eq(net, &init_net)) {
87149 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87150 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87151 if (table == NULL)
87152 goto err_alloc;
87153
87154 @@ -804,9 +803,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87155 /* Don't export sysctls to unprivileged users */
87156 if (net->user_ns != &init_user_ns)
87157 table[0].procname = NULL;
87158 - }
87159 + hdr = register_net_sysctl(net, "net/ipv4", table);
87160 + } else
87161 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
87162
87163 - hdr = register_net_sysctl(net, "net/ipv4", table);
87164 if (hdr == NULL)
87165 goto err_reg;
87166
87167 @@ -814,8 +814,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87168 return 0;
87169
87170 err_reg:
87171 - if (!net_eq(net, &init_net))
87172 - kfree(table);
87173 + kfree(table);
87174 err_alloc:
87175 return -ENOMEM;
87176 }
87177 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
87178 index 91d66db..4af7d99 100644
87179 --- a/net/ipv4/ip_gre.c
87180 +++ b/net/ipv4/ip_gre.c
87181 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
87182 module_param(log_ecn_error, bool, 0644);
87183 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87184
87185 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
87186 +static struct rtnl_link_ops ipgre_link_ops;
87187 static int ipgre_tunnel_init(struct net_device *dev);
87188 static void ipgre_tunnel_setup(struct net_device *dev);
87189 static int ipgre_tunnel_bind_dev(struct net_device *dev);
87190 @@ -1823,7 +1823,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
87191 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
87192 };
87193
87194 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87195 +static struct rtnl_link_ops ipgre_link_ops = {
87196 .kind = "gre",
87197 .maxtype = IFLA_GRE_MAX,
87198 .policy = ipgre_policy,
87199 @@ -1836,7 +1836,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87200 .fill_info = ipgre_fill_info,
87201 };
87202
87203 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
87204 +static struct rtnl_link_ops ipgre_tap_ops = {
87205 .kind = "gretap",
87206 .maxtype = IFLA_GRE_MAX,
87207 .policy = ipgre_policy,
87208 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
87209 index d9c4f11..02b82dbc 100644
87210 --- a/net/ipv4/ip_sockglue.c
87211 +++ b/net/ipv4/ip_sockglue.c
87212 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87213 len = min_t(unsigned int, len, opt->optlen);
87214 if (put_user(len, optlen))
87215 return -EFAULT;
87216 - if (copy_to_user(optval, opt->__data, len))
87217 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
87218 + copy_to_user(optval, opt->__data, len))
87219 return -EFAULT;
87220 return 0;
87221 }
87222 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87223 if (sk->sk_type != SOCK_STREAM)
87224 return -ENOPROTOOPT;
87225
87226 - msg.msg_control = optval;
87227 + msg.msg_control = (void __force_kernel *)optval;
87228 msg.msg_controllen = len;
87229 msg.msg_flags = flags;
87230
87231 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
87232 index c3a4233..7df5626 100644
87233 --- a/net/ipv4/ip_vti.c
87234 +++ b/net/ipv4/ip_vti.c
87235 @@ -47,7 +47,7 @@
87236 #define HASH_SIZE 16
87237 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
87238
87239 -static struct rtnl_link_ops vti_link_ops __read_mostly;
87240 +static struct rtnl_link_ops vti_link_ops;
87241
87242 static int vti_net_id __read_mostly;
87243 struct vti_net {
87244 @@ -399,8 +399,7 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
87245 tunnel->err_count = 0;
87246 }
87247
87248 - IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
87249 - IPSKB_REROUTED);
87250 + memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
87251 skb_dst_drop(skb);
87252 skb_dst_set(skb, &rt->dst);
87253 nf_reset(skb);
87254 @@ -886,7 +885,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
87255 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
87256 };
87257
87258 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
87259 +static struct rtnl_link_ops vti_link_ops = {
87260 .kind = "vti",
87261 .maxtype = IFLA_VTI_MAX,
87262 .policy = vti_policy,
87263 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87264 index f01d1b1..8fe03ad 100644
87265 --- a/net/ipv4/ipcomp.c
87266 +++ b/net/ipv4/ipcomp.c
87267 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87268 return;
87269
87270 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87271 - atomic_inc(&flow_cache_genid);
87272 + atomic_inc_unchecked(&flow_cache_genid);
87273 rt_genid_bump(net);
87274
87275 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87276 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87277 index bf6c5cf..ab2e9c6 100644
87278 --- a/net/ipv4/ipconfig.c
87279 +++ b/net/ipv4/ipconfig.c
87280 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87281
87282 mm_segment_t oldfs = get_fs();
87283 set_fs(get_ds());
87284 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87285 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87286 set_fs(oldfs);
87287 return res;
87288 }
87289 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87290
87291 mm_segment_t oldfs = get_fs();
87292 set_fs(get_ds());
87293 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87294 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87295 set_fs(oldfs);
87296 return res;
87297 }
87298 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87299
87300 mm_segment_t oldfs = get_fs();
87301 set_fs(get_ds());
87302 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87303 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87304 set_fs(oldfs);
87305 return res;
87306 }
87307 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87308 index 8f024d4..8b3500c 100644
87309 --- a/net/ipv4/ipip.c
87310 +++ b/net/ipv4/ipip.c
87311 @@ -138,7 +138,7 @@ struct ipip_net {
87312 static int ipip_tunnel_init(struct net_device *dev);
87313 static void ipip_tunnel_setup(struct net_device *dev);
87314 static void ipip_dev_free(struct net_device *dev);
87315 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87316 +static struct rtnl_link_ops ipip_link_ops;
87317
87318 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
87319 struct rtnl_link_stats64 *tot)
87320 @@ -974,7 +974,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87321 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87322 };
87323
87324 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87325 +static struct rtnl_link_ops ipip_link_ops = {
87326 .kind = "ipip",
87327 .maxtype = IFLA_IPTUN_MAX,
87328 .policy = ipip_policy,
87329 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87330 index 7dc6a97..229c61b 100644
87331 --- a/net/ipv4/netfilter/arp_tables.c
87332 +++ b/net/ipv4/netfilter/arp_tables.c
87333 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
87334 #endif
87335
87336 static int get_info(struct net *net, void __user *user,
87337 - const int *len, int compat)
87338 + int len, int compat)
87339 {
87340 char name[XT_TABLE_MAXNAMELEN];
87341 struct xt_table *t;
87342 int ret;
87343
87344 - if (*len != sizeof(struct arpt_getinfo)) {
87345 - duprintf("length %u != %Zu\n", *len,
87346 + if (len != sizeof(struct arpt_getinfo)) {
87347 + duprintf("length %u != %Zu\n", len,
87348 sizeof(struct arpt_getinfo));
87349 return -EINVAL;
87350 }
87351 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
87352 info.size = private->size;
87353 strcpy(info.name, name);
87354
87355 - if (copy_to_user(user, &info, *len) != 0)
87356 + if (copy_to_user(user, &info, len) != 0)
87357 ret = -EFAULT;
87358 else
87359 ret = 0;
87360 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87361
87362 switch (cmd) {
87363 case ARPT_SO_GET_INFO:
87364 - ret = get_info(sock_net(sk), user, len, 1);
87365 + ret = get_info(sock_net(sk), user, *len, 1);
87366 break;
87367 case ARPT_SO_GET_ENTRIES:
87368 ret = compat_get_entries(sock_net(sk), user, len);
87369 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87370
87371 switch (cmd) {
87372 case ARPT_SO_GET_INFO:
87373 - ret = get_info(sock_net(sk), user, len, 0);
87374 + ret = get_info(sock_net(sk), user, *len, 0);
87375 break;
87376
87377 case ARPT_SO_GET_ENTRIES:
87378 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87379 index 3efcf87..5247916 100644
87380 --- a/net/ipv4/netfilter/ip_tables.c
87381 +++ b/net/ipv4/netfilter/ip_tables.c
87382 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87383 #endif
87384
87385 static int get_info(struct net *net, void __user *user,
87386 - const int *len, int compat)
87387 + int len, int compat)
87388 {
87389 char name[XT_TABLE_MAXNAMELEN];
87390 struct xt_table *t;
87391 int ret;
87392
87393 - if (*len != sizeof(struct ipt_getinfo)) {
87394 - duprintf("length %u != %zu\n", *len,
87395 + if (len != sizeof(struct ipt_getinfo)) {
87396 + duprintf("length %u != %zu\n", len,
87397 sizeof(struct ipt_getinfo));
87398 return -EINVAL;
87399 }
87400 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87401 info.size = private->size;
87402 strcpy(info.name, name);
87403
87404 - if (copy_to_user(user, &info, *len) != 0)
87405 + if (copy_to_user(user, &info, len) != 0)
87406 ret = -EFAULT;
87407 else
87408 ret = 0;
87409 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87410
87411 switch (cmd) {
87412 case IPT_SO_GET_INFO:
87413 - ret = get_info(sock_net(sk), user, len, 1);
87414 + ret = get_info(sock_net(sk), user, *len, 1);
87415 break;
87416 case IPT_SO_GET_ENTRIES:
87417 ret = compat_get_entries(sock_net(sk), user, len);
87418 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87419
87420 switch (cmd) {
87421 case IPT_SO_GET_INFO:
87422 - ret = get_info(sock_net(sk), user, len, 0);
87423 + ret = get_info(sock_net(sk), user, *len, 0);
87424 break;
87425
87426 case IPT_SO_GET_ENTRIES:
87427 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87428 index 2e91006..f084394 100644
87429 --- a/net/ipv4/ping.c
87430 +++ b/net/ipv4/ping.c
87431 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87432 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87433 0, sock_i_ino(sp),
87434 atomic_read(&sp->sk_refcnt), sp,
87435 - atomic_read(&sp->sk_drops), len);
87436 + atomic_read_unchecked(&sp->sk_drops), len);
87437 }
87438
87439 static int ping_seq_show(struct seq_file *seq, void *v)
87440 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87441 index dd44e0a..06dcca4 100644
87442 --- a/net/ipv4/raw.c
87443 +++ b/net/ipv4/raw.c
87444 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87445 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87446 {
87447 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87448 - atomic_inc(&sk->sk_drops);
87449 + atomic_inc_unchecked(&sk->sk_drops);
87450 kfree_skb(skb);
87451 return NET_RX_DROP;
87452 }
87453 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
87454
87455 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87456 {
87457 + struct icmp_filter filter;
87458 +
87459 if (optlen > sizeof(struct icmp_filter))
87460 optlen = sizeof(struct icmp_filter);
87461 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87462 + if (copy_from_user(&filter, optval, optlen))
87463 return -EFAULT;
87464 + raw_sk(sk)->filter = filter;
87465 return 0;
87466 }
87467
87468 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87469 {
87470 int len, ret = -EFAULT;
87471 + struct icmp_filter filter;
87472
87473 if (get_user(len, optlen))
87474 goto out;
87475 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87476 if (len > sizeof(struct icmp_filter))
87477 len = sizeof(struct icmp_filter);
87478 ret = -EFAULT;
87479 - if (put_user(len, optlen) ||
87480 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87481 + filter = raw_sk(sk)->filter;
87482 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87483 goto out;
87484 ret = 0;
87485 out: return ret;
87486 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87487 0, 0L, 0,
87488 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87489 0, sock_i_ino(sp),
87490 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87491 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87492 }
87493
87494 static int raw_seq_show(struct seq_file *seq, void *v)
87495 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87496 index 6e28514..5e1b055 100644
87497 --- a/net/ipv4/route.c
87498 +++ b/net/ipv4/route.c
87499 @@ -2553,34 +2553,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87500 .maxlen = sizeof(int),
87501 .mode = 0200,
87502 .proc_handler = ipv4_sysctl_rtcache_flush,
87503 + .extra1 = &init_net,
87504 },
87505 { },
87506 };
87507
87508 static __net_init int sysctl_route_net_init(struct net *net)
87509 {
87510 - struct ctl_table *tbl;
87511 + ctl_table_no_const *tbl = NULL;
87512
87513 - tbl = ipv4_route_flush_table;
87514 if (!net_eq(net, &init_net)) {
87515 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87516 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87517 if (tbl == NULL)
87518 goto err_dup;
87519
87520 /* Don't export sysctls to unprivileged users */
87521 if (net->user_ns != &init_user_ns)
87522 tbl[0].procname = NULL;
87523 - }
87524 - tbl[0].extra1 = net;
87525 + tbl[0].extra1 = net;
87526 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87527 + } else
87528 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87529
87530 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87531 if (net->ipv4.route_hdr == NULL)
87532 goto err_reg;
87533 return 0;
87534
87535 err_reg:
87536 - if (tbl != ipv4_route_flush_table)
87537 - kfree(tbl);
87538 + kfree(tbl);
87539 err_dup:
87540 return -ENOMEM;
87541 }
87542 @@ -2603,7 +2603,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87543
87544 static __net_init int rt_genid_init(struct net *net)
87545 {
87546 - atomic_set(&net->rt_genid, 0);
87547 + atomic_set_unchecked(&net->rt_genid, 0);
87548 get_random_bytes(&net->ipv4.dev_addr_genid,
87549 sizeof(net->ipv4.dev_addr_genid));
87550 return 0;
87551 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87552 index 960fd29..d55bf64 100644
87553 --- a/net/ipv4/sysctl_net_ipv4.c
87554 +++ b/net/ipv4/sysctl_net_ipv4.c
87555 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87556 {
87557 int ret;
87558 int range[2];
87559 - ctl_table tmp = {
87560 + ctl_table_no_const tmp = {
87561 .data = &range,
87562 .maxlen = sizeof(range),
87563 .mode = table->mode,
87564 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87565 int ret;
87566 gid_t urange[2];
87567 kgid_t low, high;
87568 - ctl_table tmp = {
87569 + ctl_table_no_const tmp = {
87570 .data = &urange,
87571 .maxlen = sizeof(urange),
87572 .mode = table->mode,
87573 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87574 void __user *buffer, size_t *lenp, loff_t *ppos)
87575 {
87576 char val[TCP_CA_NAME_MAX];
87577 - ctl_table tbl = {
87578 + ctl_table_no_const tbl = {
87579 .data = val,
87580 .maxlen = TCP_CA_NAME_MAX,
87581 };
87582 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87583 void __user *buffer, size_t *lenp,
87584 loff_t *ppos)
87585 {
87586 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87587 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87588 int ret;
87589
87590 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87591 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87592 void __user *buffer, size_t *lenp,
87593 loff_t *ppos)
87594 {
87595 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87596 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87597 int ret;
87598
87599 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87600 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87601 struct mem_cgroup *memcg;
87602 #endif
87603
87604 - ctl_table tmp = {
87605 + ctl_table_no_const tmp = {
87606 .data = &vec,
87607 .maxlen = sizeof(vec),
87608 .mode = ctl->mode,
87609 };
87610
87611 if (!write) {
87612 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87613 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87614 + ctl_table_no_const tcp_mem = *ctl;
87615 +
87616 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87617 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87618 }
87619
87620 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87621 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87622 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87623 size_t *lenp, loff_t *ppos)
87624 {
87625 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87626 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87627 struct tcp_fastopen_context *ctxt;
87628 int ret;
87629 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87630 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
87631 },
87632 {
87633 .procname = "ip_local_reserved_ports",
87634 - .data = NULL, /* initialized in sysctl_ipv4_init */
87635 + .data = sysctl_local_reserved_ports,
87636 .maxlen = 65536,
87637 .mode = 0644,
87638 .proc_handler = proc_do_large_bitmap,
87639 @@ -856,11 +858,10 @@ static struct ctl_table ipv4_net_table[] = {
87640
87641 static __net_init int ipv4_sysctl_init_net(struct net *net)
87642 {
87643 - struct ctl_table *table;
87644 + ctl_table_no_const *table = NULL;
87645
87646 - table = ipv4_net_table;
87647 if (!net_eq(net, &init_net)) {
87648 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87649 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87650 if (table == NULL)
87651 goto err_alloc;
87652
87653 @@ -895,15 +896,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87654
87655 tcp_init_mem(net);
87656
87657 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87658 + if (!net_eq(net, &init_net))
87659 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87660 + else
87661 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87662 if (net->ipv4.ipv4_hdr == NULL)
87663 goto err_reg;
87664
87665 return 0;
87666
87667 err_reg:
87668 - if (!net_eq(net, &init_net))
87669 - kfree(table);
87670 + kfree(table);
87671 err_alloc:
87672 return -ENOMEM;
87673 }
87674 @@ -925,16 +928,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87675 static __init int sysctl_ipv4_init(void)
87676 {
87677 struct ctl_table_header *hdr;
87678 - struct ctl_table *i;
87679 -
87680 - for (i = ipv4_table; i->procname; i++) {
87681 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87682 - i->data = sysctl_local_reserved_ports;
87683 - break;
87684 - }
87685 - }
87686 - if (!i->procname)
87687 - return -EINVAL;
87688
87689 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87690 if (hdr == NULL)
87691 diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
87692 index e220207..cdeb839 100644
87693 --- a/net/ipv4/tcp.c
87694 +++ b/net/ipv4/tcp.c
87695 @@ -3383,8 +3383,11 @@ int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,
87696
87697 for (i = 0; i < shi->nr_frags; ++i) {
87698 const struct skb_frag_struct *f = &shi->frags[i];
87699 - struct page *page = skb_frag_page(f);
87700 - sg_set_page(&sg, page, skb_frag_size(f), f->page_offset);
87701 + unsigned int offset = f->page_offset;
87702 + struct page *page = skb_frag_page(f) + (offset >> PAGE_SHIFT);
87703 +
87704 + sg_set_page(&sg, page, skb_frag_size(f),
87705 + offset_in_page(offset));
87706 if (crypto_hash_update(desc, &sg, skb_frag_size(f)))
87707 return 1;
87708 }
87709 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87710 index 13b9c08..d33a8d0 100644
87711 --- a/net/ipv4/tcp_input.c
87712 +++ b/net/ipv4/tcp_input.c
87713 @@ -4724,7 +4724,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87714 * simplifies code)
87715 */
87716 static void
87717 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87718 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87719 struct sk_buff *head, struct sk_buff *tail,
87720 u32 start, u32 end)
87721 {
87722 @@ -5838,6 +5838,7 @@ discard:
87723 tcp_paws_reject(&tp->rx_opt, 0))
87724 goto discard_and_undo;
87725
87726 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87727 if (th->syn) {
87728 /* We see SYN without ACK. It is attempt of
87729 * simultaneous connect with crossed SYNs.
87730 @@ -5888,6 +5889,7 @@ discard:
87731 goto discard;
87732 #endif
87733 }
87734 +#endif
87735 /* "fifth, if neither of the SYN or RST bits is set then
87736 * drop the segment and return."
87737 */
87738 @@ -5932,7 +5934,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87739 goto discard;
87740
87741 if (th->syn) {
87742 - if (th->fin)
87743 + if (th->fin || th->urg || th->psh)
87744 goto discard;
87745 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87746 return 1;
87747 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87748 index d09203c..fd5cc91 100644
87749 --- a/net/ipv4/tcp_ipv4.c
87750 +++ b/net/ipv4/tcp_ipv4.c
87751 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87752 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87753
87754
87755 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87756 +extern int grsec_enable_blackhole;
87757 +#endif
87758 +
87759 #ifdef CONFIG_TCP_MD5SIG
87760 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87761 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87762 @@ -1897,6 +1901,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87763 return 0;
87764
87765 reset:
87766 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87767 + if (!grsec_enable_blackhole)
87768 +#endif
87769 tcp_v4_send_reset(rsk, skb);
87770 discard:
87771 kfree_skb(skb);
87772 @@ -1996,12 +2003,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87773 TCP_SKB_CB(skb)->sacked = 0;
87774
87775 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87776 - if (!sk)
87777 + if (!sk) {
87778 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87779 + ret = 1;
87780 +#endif
87781 goto no_tcp_socket;
87782 -
87783 + }
87784 process:
87785 - if (sk->sk_state == TCP_TIME_WAIT)
87786 + if (sk->sk_state == TCP_TIME_WAIT) {
87787 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87788 + ret = 2;
87789 +#endif
87790 goto do_time_wait;
87791 + }
87792
87793 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87794 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87795 @@ -2052,6 +2066,10 @@ no_tcp_socket:
87796 bad_packet:
87797 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87798 } else {
87799 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87800 + if (!grsec_enable_blackhole || (ret == 1 &&
87801 + (skb->dev->flags & IFF_LOOPBACK)))
87802 +#endif
87803 tcp_v4_send_reset(NULL, skb);
87804 }
87805
87806 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87807 index 2f672e7..b8895e9 100644
87808 --- a/net/ipv4/tcp_minisocks.c
87809 +++ b/net/ipv4/tcp_minisocks.c
87810 @@ -27,6 +27,10 @@
87811 #include <net/inet_common.h>
87812 #include <net/xfrm.h>
87813
87814 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87815 +extern int grsec_enable_blackhole;
87816 +#endif
87817 +
87818 int sysctl_tcp_syncookies __read_mostly = 1;
87819 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87820
87821 @@ -749,7 +753,10 @@ embryonic_reset:
87822 * avoid becoming vulnerable to outside attack aiming at
87823 * resetting legit local connections.
87824 */
87825 - req->rsk_ops->send_reset(sk, skb);
87826 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87827 + if (!grsec_enable_blackhole)
87828 +#endif
87829 + req->rsk_ops->send_reset(sk, skb);
87830 } else if (fastopen) { /* received a valid RST pkt */
87831 reqsk_fastopen_remove(sk, req, true);
87832 tcp_reset(sk);
87833 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87834 index d4943f6..e7a74a5 100644
87835 --- a/net/ipv4/tcp_probe.c
87836 +++ b/net/ipv4/tcp_probe.c
87837 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87838 if (cnt + width >= len)
87839 break;
87840
87841 - if (copy_to_user(buf + cnt, tbuf, width))
87842 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87843 return -EFAULT;
87844 cnt += width;
87845 }
87846 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87847 index b78aac3..e18230b 100644
87848 --- a/net/ipv4/tcp_timer.c
87849 +++ b/net/ipv4/tcp_timer.c
87850 @@ -22,6 +22,10 @@
87851 #include <linux/gfp.h>
87852 #include <net/tcp.h>
87853
87854 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87855 +extern int grsec_lastack_retries;
87856 +#endif
87857 +
87858 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87859 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87860 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87861 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87862 }
87863 }
87864
87865 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87866 + if ((sk->sk_state == TCP_LAST_ACK) &&
87867 + (grsec_lastack_retries > 0) &&
87868 + (grsec_lastack_retries < retry_until))
87869 + retry_until = grsec_lastack_retries;
87870 +#endif
87871 +
87872 if (retransmits_timed_out(sk, retry_until,
87873 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87874 /* Has it gone just too far? */
87875 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87876 index 0a073a2..ddf6279 100644
87877 --- a/net/ipv4/udp.c
87878 +++ b/net/ipv4/udp.c
87879 @@ -87,6 +87,7 @@
87880 #include <linux/types.h>
87881 #include <linux/fcntl.h>
87882 #include <linux/module.h>
87883 +#include <linux/security.h>
87884 #include <linux/socket.h>
87885 #include <linux/sockios.h>
87886 #include <linux/igmp.h>
87887 @@ -111,6 +112,10 @@
87888 #include <trace/events/skb.h>
87889 #include "udp_impl.h"
87890
87891 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87892 +extern int grsec_enable_blackhole;
87893 +#endif
87894 +
87895 struct udp_table udp_table __read_mostly;
87896 EXPORT_SYMBOL(udp_table);
87897
87898 @@ -594,6 +599,9 @@ found:
87899 return s;
87900 }
87901
87902 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87903 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87904 +
87905 /*
87906 * This routine is called by the ICMP module when it gets some
87907 * sort of error condition. If err < 0 then the socket should
87908 @@ -889,9 +897,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87909 dport = usin->sin_port;
87910 if (dport == 0)
87911 return -EINVAL;
87912 +
87913 + err = gr_search_udp_sendmsg(sk, usin);
87914 + if (err)
87915 + return err;
87916 } else {
87917 if (sk->sk_state != TCP_ESTABLISHED)
87918 return -EDESTADDRREQ;
87919 +
87920 + err = gr_search_udp_sendmsg(sk, NULL);
87921 + if (err)
87922 + return err;
87923 +
87924 daddr = inet->inet_daddr;
87925 dport = inet->inet_dport;
87926 /* Open fast path for connected socket.
87927 @@ -1133,7 +1150,7 @@ static unsigned int first_packet_length(struct sock *sk)
87928 udp_lib_checksum_complete(skb)) {
87929 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87930 IS_UDPLITE(sk));
87931 - atomic_inc(&sk->sk_drops);
87932 + atomic_inc_unchecked(&sk->sk_drops);
87933 __skb_unlink(skb, rcvq);
87934 __skb_queue_tail(&list_kill, skb);
87935 }
87936 @@ -1219,6 +1236,10 @@ try_again:
87937 if (!skb)
87938 goto out;
87939
87940 + err = gr_search_udp_recvmsg(sk, skb);
87941 + if (err)
87942 + goto out_free;
87943 +
87944 ulen = skb->len - sizeof(struct udphdr);
87945 copied = len;
87946 if (copied > ulen)
87947 @@ -1252,7 +1273,7 @@ try_again:
87948 if (unlikely(err)) {
87949 trace_kfree_skb(skb, udp_recvmsg);
87950 if (!peeked) {
87951 - atomic_inc(&sk->sk_drops);
87952 + atomic_inc_unchecked(&sk->sk_drops);
87953 UDP_INC_STATS_USER(sock_net(sk),
87954 UDP_MIB_INERRORS, is_udplite);
87955 }
87956 @@ -1535,7 +1556,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87957
87958 drop:
87959 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87960 - atomic_inc(&sk->sk_drops);
87961 + atomic_inc_unchecked(&sk->sk_drops);
87962 kfree_skb(skb);
87963 return -1;
87964 }
87965 @@ -1554,7 +1575,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87966 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87967
87968 if (!skb1) {
87969 - atomic_inc(&sk->sk_drops);
87970 + atomic_inc_unchecked(&sk->sk_drops);
87971 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87972 IS_UDPLITE(sk));
87973 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87974 @@ -1723,6 +1744,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87975 goto csum_error;
87976
87977 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87978 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87979 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87980 +#endif
87981 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87982
87983 /*
87984 @@ -2152,7 +2176,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87985 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87986 0, sock_i_ino(sp),
87987 atomic_read(&sp->sk_refcnt), sp,
87988 - atomic_read(&sp->sk_drops), len);
87989 + atomic_read_unchecked(&sp->sk_drops), len);
87990 }
87991
87992 int udp4_seq_show(struct seq_file *seq, void *v)
87993 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
87994 index 9a459be..086b866 100644
87995 --- a/net/ipv4/xfrm4_policy.c
87996 +++ b/net/ipv4/xfrm4_policy.c
87997 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
87998
87999 static int __net_init xfrm4_net_init(struct net *net)
88000 {
88001 - struct ctl_table *table;
88002 + ctl_table_no_const *table = NULL;
88003 struct ctl_table_header *hdr;
88004
88005 - table = xfrm4_policy_table;
88006 if (!net_eq(net, &init_net)) {
88007 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
88008 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
88009 if (!table)
88010 goto err_alloc;
88011
88012 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
88013 - }
88014 -
88015 - hdr = register_net_sysctl(net, "net/ipv4", table);
88016 + hdr = register_net_sysctl(net, "net/ipv4", table);
88017 + } else
88018 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
88019 if (!hdr)
88020 goto err_reg;
88021
88022 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
88023 return 0;
88024
88025 err_reg:
88026 - if (!net_eq(net, &init_net))
88027 - kfree(table);
88028 + kfree(table);
88029 err_alloc:
88030 return -ENOMEM;
88031 }
88032 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
88033 index dae802c..bfa4baa 100644
88034 --- a/net/ipv6/addrconf.c
88035 +++ b/net/ipv6/addrconf.c
88036 @@ -2274,7 +2274,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
88037 p.iph.ihl = 5;
88038 p.iph.protocol = IPPROTO_IPV6;
88039 p.iph.ttl = 64;
88040 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
88041 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
88042
88043 if (ops->ndo_do_ioctl) {
88044 mm_segment_t oldfs = get_fs();
88045 @@ -4410,7 +4410,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
88046 int *valp = ctl->data;
88047 int val = *valp;
88048 loff_t pos = *ppos;
88049 - ctl_table lctl;
88050 + ctl_table_no_const lctl;
88051 int ret;
88052
88053 /*
88054 @@ -4492,7 +4492,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
88055 int *valp = ctl->data;
88056 int val = *valp;
88057 loff_t pos = *ppos;
88058 - ctl_table lctl;
88059 + ctl_table_no_const lctl;
88060 int ret;
88061
88062 /*
88063 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
88064 index fff5bdd..15194fb 100644
88065 --- a/net/ipv6/icmp.c
88066 +++ b/net/ipv6/icmp.c
88067 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
88068
88069 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
88070 {
88071 - struct ctl_table *table;
88072 + ctl_table_no_const *table;
88073
88074 table = kmemdup(ipv6_icmp_table_template,
88075 sizeof(ipv6_icmp_table_template),
88076 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
88077 index 95d13c7..791fe2f 100644
88078 --- a/net/ipv6/ip6_gre.c
88079 +++ b/net/ipv6/ip6_gre.c
88080 @@ -73,7 +73,7 @@ struct ip6gre_net {
88081 struct net_device *fb_tunnel_dev;
88082 };
88083
88084 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
88085 +static struct rtnl_link_ops ip6gre_link_ops;
88086 static int ip6gre_tunnel_init(struct net_device *dev);
88087 static void ip6gre_tunnel_setup(struct net_device *dev);
88088 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
88089 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
88090 }
88091
88092
88093 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
88094 +static struct inet6_protocol ip6gre_protocol = {
88095 .handler = ip6gre_rcv,
88096 .err_handler = ip6gre_err,
88097 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
88098 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
88099 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
88100 };
88101
88102 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88103 +static struct rtnl_link_ops ip6gre_link_ops = {
88104 .kind = "ip6gre",
88105 .maxtype = IFLA_GRE_MAX,
88106 .policy = ip6gre_policy,
88107 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88108 .fill_info = ip6gre_fill_info,
88109 };
88110
88111 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
88112 +static struct rtnl_link_ops ip6gre_tap_ops = {
88113 .kind = "ip6gretap",
88114 .maxtype = IFLA_GRE_MAX,
88115 .policy = ip6gre_policy,
88116 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
88117 index 155eccf..851fdae 100644
88118 --- a/net/ipv6/ip6_output.c
88119 +++ b/net/ipv6/ip6_output.c
88120 @@ -1147,7 +1147,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
88121 if (WARN_ON(np->cork.opt))
88122 return -EINVAL;
88123
88124 - np->cork.opt = kmalloc(opt->tot_len, sk->sk_allocation);
88125 + np->cork.opt = kzalloc(opt->tot_len, sk->sk_allocation);
88126 if (unlikely(np->cork.opt == NULL))
88127 return -ENOBUFS;
88128
88129 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
88130 index fff83cb..82d49dd 100644
88131 --- a/net/ipv6/ip6_tunnel.c
88132 +++ b/net/ipv6/ip6_tunnel.c
88133 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
88134
88135 static int ip6_tnl_dev_init(struct net_device *dev);
88136 static void ip6_tnl_dev_setup(struct net_device *dev);
88137 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
88138 +static struct rtnl_link_ops ip6_link_ops;
88139
88140 static int ip6_tnl_net_id __read_mostly;
88141 struct ip6_tnl_net {
88142 @@ -1684,7 +1684,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
88143 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
88144 };
88145
88146 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
88147 +static struct rtnl_link_ops ip6_link_ops = {
88148 .kind = "ip6tnl",
88149 .maxtype = IFLA_IPTUN_MAX,
88150 .policy = ip6_tnl_policy,
88151 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
88152 index d1e2e8e..51c19ae 100644
88153 --- a/net/ipv6/ipv6_sockglue.c
88154 +++ b/net/ipv6/ipv6_sockglue.c
88155 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
88156 if (sk->sk_type != SOCK_STREAM)
88157 return -ENOPROTOOPT;
88158
88159 - msg.msg_control = optval;
88160 + msg.msg_control = (void __force_kernel *)optval;
88161 msg.msg_controllen = len;
88162 msg.msg_flags = flags;
88163
88164 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
88165 index 341b54a..591e8ed 100644
88166 --- a/net/ipv6/netfilter/ip6_tables.c
88167 +++ b/net/ipv6/netfilter/ip6_tables.c
88168 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
88169 #endif
88170
88171 static int get_info(struct net *net, void __user *user,
88172 - const int *len, int compat)
88173 + int len, int compat)
88174 {
88175 char name[XT_TABLE_MAXNAMELEN];
88176 struct xt_table *t;
88177 int ret;
88178
88179 - if (*len != sizeof(struct ip6t_getinfo)) {
88180 - duprintf("length %u != %zu\n", *len,
88181 + if (len != sizeof(struct ip6t_getinfo)) {
88182 + duprintf("length %u != %zu\n", len,
88183 sizeof(struct ip6t_getinfo));
88184 return -EINVAL;
88185 }
88186 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
88187 info.size = private->size;
88188 strcpy(info.name, name);
88189
88190 - if (copy_to_user(user, &info, *len) != 0)
88191 + if (copy_to_user(user, &info, len) != 0)
88192 ret = -EFAULT;
88193 else
88194 ret = 0;
88195 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88196
88197 switch (cmd) {
88198 case IP6T_SO_GET_INFO:
88199 - ret = get_info(sock_net(sk), user, len, 1);
88200 + ret = get_info(sock_net(sk), user, *len, 1);
88201 break;
88202 case IP6T_SO_GET_ENTRIES:
88203 ret = compat_get_entries(sock_net(sk), user, len);
88204 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88205
88206 switch (cmd) {
88207 case IP6T_SO_GET_INFO:
88208 - ret = get_info(sock_net(sk), user, len, 0);
88209 + ret = get_info(sock_net(sk), user, *len, 0);
88210 break;
88211
88212 case IP6T_SO_GET_ENTRIES:
88213 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
88214 index 6700069..1e50f42 100644
88215 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
88216 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
88217 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
88218
88219 static int nf_ct_frag6_sysctl_register(struct net *net)
88220 {
88221 - struct ctl_table *table;
88222 + ctl_table_no_const *table = NULL;
88223 struct ctl_table_header *hdr;
88224
88225 - table = nf_ct_frag6_sysctl_table;
88226 if (!net_eq(net, &init_net)) {
88227 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
88228 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
88229 GFP_KERNEL);
88230 if (table == NULL)
88231 goto err_alloc;
88232 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88233 table[0].data = &net->nf_frag.frags.timeout;
88234 table[1].data = &net->nf_frag.frags.low_thresh;
88235 table[2].data = &net->nf_frag.frags.high_thresh;
88236 - }
88237 -
88238 - hdr = register_net_sysctl(net, "net/netfilter", table);
88239 + hdr = register_net_sysctl(net, "net/netfilter", table);
88240 + } else
88241 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
88242 if (hdr == NULL)
88243 goto err_reg;
88244
88245 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88246 return 0;
88247
88248 err_reg:
88249 - if (!net_eq(net, &init_net))
88250 - kfree(table);
88251 + kfree(table);
88252 err_alloc:
88253 return -ENOMEM;
88254 }
88255 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
88256 index 330b5e7..796fbf1 100644
88257 --- a/net/ipv6/raw.c
88258 +++ b/net/ipv6/raw.c
88259 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
88260 {
88261 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
88262 skb_checksum_complete(skb)) {
88263 - atomic_inc(&sk->sk_drops);
88264 + atomic_inc_unchecked(&sk->sk_drops);
88265 kfree_skb(skb);
88266 return NET_RX_DROP;
88267 }
88268 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88269 struct raw6_sock *rp = raw6_sk(sk);
88270
88271 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
88272 - atomic_inc(&sk->sk_drops);
88273 + atomic_inc_unchecked(&sk->sk_drops);
88274 kfree_skb(skb);
88275 return NET_RX_DROP;
88276 }
88277 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88278
88279 if (inet->hdrincl) {
88280 if (skb_checksum_complete(skb)) {
88281 - atomic_inc(&sk->sk_drops);
88282 + atomic_inc_unchecked(&sk->sk_drops);
88283 kfree_skb(skb);
88284 return NET_RX_DROP;
88285 }
88286 @@ -603,7 +603,7 @@ out:
88287 return err;
88288 }
88289
88290 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
88291 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
88292 struct flowi6 *fl6, struct dst_entry **dstp,
88293 unsigned int flags)
88294 {
88295 @@ -915,12 +915,15 @@ do_confirm:
88296 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
88297 char __user *optval, int optlen)
88298 {
88299 + struct icmp6_filter filter;
88300 +
88301 switch (optname) {
88302 case ICMPV6_FILTER:
88303 if (optlen > sizeof(struct icmp6_filter))
88304 optlen = sizeof(struct icmp6_filter);
88305 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
88306 + if (copy_from_user(&filter, optval, optlen))
88307 return -EFAULT;
88308 + raw6_sk(sk)->filter = filter;
88309 return 0;
88310 default:
88311 return -ENOPROTOOPT;
88312 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88313 char __user *optval, int __user *optlen)
88314 {
88315 int len;
88316 + struct icmp6_filter filter;
88317
88318 switch (optname) {
88319 case ICMPV6_FILTER:
88320 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88321 len = sizeof(struct icmp6_filter);
88322 if (put_user(len, optlen))
88323 return -EFAULT;
88324 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88325 + filter = raw6_sk(sk)->filter;
88326 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88327 return -EFAULT;
88328 return 0;
88329 default:
88330 @@ -1252,7 +1257,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88331 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88332 0,
88333 sock_i_ino(sp),
88334 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88335 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88336 }
88337
88338 static int raw6_seq_show(struct seq_file *seq, void *v)
88339 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88340 index 0ba10e5..c14a4f6 100644
88341 --- a/net/ipv6/reassembly.c
88342 +++ b/net/ipv6/reassembly.c
88343 @@ -602,12 +602,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88344
88345 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88346 {
88347 - struct ctl_table *table;
88348 + ctl_table_no_const *table = NULL;
88349 struct ctl_table_header *hdr;
88350
88351 - table = ip6_frags_ns_ctl_table;
88352 if (!net_eq(net, &init_net)) {
88353 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88354 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88355 if (table == NULL)
88356 goto err_alloc;
88357
88358 @@ -618,9 +617,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88359 /* Don't export sysctls to unprivileged users */
88360 if (net->user_ns != &init_user_ns)
88361 table[0].procname = NULL;
88362 - }
88363 + hdr = register_net_sysctl(net, "net/ipv6", table);
88364 + } else
88365 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88366
88367 - hdr = register_net_sysctl(net, "net/ipv6", table);
88368 if (hdr == NULL)
88369 goto err_reg;
88370
88371 @@ -628,8 +628,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88372 return 0;
88373
88374 err_reg:
88375 - if (!net_eq(net, &init_net))
88376 - kfree(table);
88377 + kfree(table);
88378 err_alloc:
88379 return -ENOMEM;
88380 }
88381 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88382 index e5fe004..9fe3e8e 100644
88383 --- a/net/ipv6/route.c
88384 +++ b/net/ipv6/route.c
88385 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
88386
88387 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88388 {
88389 - struct ctl_table *table;
88390 + ctl_table_no_const *table;
88391
88392 table = kmemdup(ipv6_route_table_template,
88393 sizeof(ipv6_route_table_template),
88394 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88395 index 02f96dc..4a5a6e5 100644
88396 --- a/net/ipv6/sit.c
88397 +++ b/net/ipv6/sit.c
88398 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
88399 static void ipip6_dev_free(struct net_device *dev);
88400 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
88401 __be32 *v4dst);
88402 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88403 +static struct rtnl_link_ops sit_link_ops;
88404
88405 static int sit_net_id __read_mostly;
88406 struct sit_net {
88407 @@ -1486,7 +1486,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88408 #endif
88409 };
88410
88411 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88412 +static struct rtnl_link_ops sit_link_ops = {
88413 .kind = "sit",
88414 .maxtype = IFLA_IPTUN_MAX,
88415 .policy = ipip6_policy,
88416 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88417 index e85c48b..b8268d3 100644
88418 --- a/net/ipv6/sysctl_net_ipv6.c
88419 +++ b/net/ipv6/sysctl_net_ipv6.c
88420 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88421
88422 static int __net_init ipv6_sysctl_net_init(struct net *net)
88423 {
88424 - struct ctl_table *ipv6_table;
88425 + ctl_table_no_const *ipv6_table;
88426 struct ctl_table *ipv6_route_table;
88427 struct ctl_table *ipv6_icmp_table;
88428 int err;
88429 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88430 index 0fce928..c52a518 100644
88431 --- a/net/ipv6/tcp_ipv6.c
88432 +++ b/net/ipv6/tcp_ipv6.c
88433 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88434 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88435 }
88436
88437 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88438 +extern int grsec_enable_blackhole;
88439 +#endif
88440 +
88441 static void tcp_v6_hash(struct sock *sk)
88442 {
88443 if (sk->sk_state != TCP_CLOSE) {
88444 @@ -1446,6 +1450,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88445 return 0;
88446
88447 reset:
88448 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88449 + if (!grsec_enable_blackhole)
88450 +#endif
88451 tcp_v6_send_reset(sk, skb);
88452 discard:
88453 if (opt_skb)
88454 @@ -1527,12 +1534,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88455 TCP_SKB_CB(skb)->sacked = 0;
88456
88457 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88458 - if (!sk)
88459 + if (!sk) {
88460 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88461 + ret = 1;
88462 +#endif
88463 goto no_tcp_socket;
88464 + }
88465
88466 process:
88467 - if (sk->sk_state == TCP_TIME_WAIT)
88468 + if (sk->sk_state == TCP_TIME_WAIT) {
88469 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88470 + ret = 2;
88471 +#endif
88472 goto do_time_wait;
88473 + }
88474
88475 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88476 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88477 @@ -1581,6 +1596,10 @@ no_tcp_socket:
88478 bad_packet:
88479 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88480 } else {
88481 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88482 + if (!grsec_enable_blackhole || (ret == 1 &&
88483 + (skb->dev->flags & IFF_LOOPBACK)))
88484 +#endif
88485 tcp_v6_send_reset(NULL, skb);
88486 }
88487
88488 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88489 index 27f0f8e..949e7ee 100644
88490 --- a/net/ipv6/udp.c
88491 +++ b/net/ipv6/udp.c
88492 @@ -52,6 +52,10 @@
88493 #include <trace/events/skb.h>
88494 #include "udp_impl.h"
88495
88496 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88497 +extern int grsec_enable_blackhole;
88498 +#endif
88499 +
88500 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88501 {
88502 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88503 @@ -419,7 +423,7 @@ try_again:
88504 if (unlikely(err)) {
88505 trace_kfree_skb(skb, udpv6_recvmsg);
88506 if (!peeked) {
88507 - atomic_inc(&sk->sk_drops);
88508 + atomic_inc_unchecked(&sk->sk_drops);
88509 if (is_udp4)
88510 UDP_INC_STATS_USER(sock_net(sk),
88511 UDP_MIB_INERRORS,
88512 @@ -657,7 +661,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88513 return rc;
88514 drop:
88515 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88516 - atomic_inc(&sk->sk_drops);
88517 + atomic_inc_unchecked(&sk->sk_drops);
88518 kfree_skb(skb);
88519 return -1;
88520 }
88521 @@ -715,7 +719,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88522 if (likely(skb1 == NULL))
88523 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88524 if (!skb1) {
88525 - atomic_inc(&sk->sk_drops);
88526 + atomic_inc_unchecked(&sk->sk_drops);
88527 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88528 IS_UDPLITE(sk));
88529 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88530 @@ -852,6 +856,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88531 goto discard;
88532
88533 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88534 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88535 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88536 +#endif
88537 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88538
88539 kfree_skb(skb);
88540 @@ -1377,7 +1384,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88541 0,
88542 sock_i_ino(sp),
88543 atomic_read(&sp->sk_refcnt), sp,
88544 - atomic_read(&sp->sk_drops));
88545 + atomic_read_unchecked(&sp->sk_drops));
88546 }
88547
88548 int udp6_seq_show(struct seq_file *seq, void *v)
88549 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
88550 index 23ed03d..465a71d 100644
88551 --- a/net/ipv6/xfrm6_policy.c
88552 +++ b/net/ipv6/xfrm6_policy.c
88553 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
88554
88555 static int __net_init xfrm6_net_init(struct net *net)
88556 {
88557 - struct ctl_table *table;
88558 + ctl_table_no_const *table = NULL;
88559 struct ctl_table_header *hdr;
88560
88561 - table = xfrm6_policy_table;
88562 if (!net_eq(net, &init_net)) {
88563 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
88564 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
88565 if (!table)
88566 goto err_alloc;
88567
88568 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
88569 - }
88570 + hdr = register_net_sysctl(net, "net/ipv6", table);
88571 + } else
88572 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
88573
88574 - hdr = register_net_sysctl(net, "net/ipv6", table);
88575 if (!hdr)
88576 goto err_reg;
88577
88578 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
88579 return 0;
88580
88581 err_reg:
88582 - if (!net_eq(net, &init_net))
88583 - kfree(table);
88584 + kfree(table);
88585 err_alloc:
88586 return -ENOMEM;
88587 }
88588 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88589 index 362ba47..66196f4 100644
88590 --- a/net/irda/ircomm/ircomm_tty.c
88591 +++ b/net/irda/ircomm/ircomm_tty.c
88592 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88593 add_wait_queue(&port->open_wait, &wait);
88594
88595 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88596 - __FILE__, __LINE__, tty->driver->name, port->count);
88597 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88598
88599 spin_lock_irqsave(&port->lock, flags);
88600 if (!tty_hung_up_p(filp))
88601 - port->count--;
88602 + atomic_dec(&port->count);
88603 port->blocked_open++;
88604 spin_unlock_irqrestore(&port->lock, flags);
88605
88606 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88607 }
88608
88609 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88610 - __FILE__, __LINE__, tty->driver->name, port->count);
88611 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88612
88613 schedule();
88614 }
88615 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88616
88617 spin_lock_irqsave(&port->lock, flags);
88618 if (!tty_hung_up_p(filp))
88619 - port->count++;
88620 + atomic_inc(&port->count);
88621 port->blocked_open--;
88622 spin_unlock_irqrestore(&port->lock, flags);
88623
88624 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88625 - __FILE__, __LINE__, tty->driver->name, port->count);
88626 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88627
88628 if (!retval)
88629 port->flags |= ASYNC_NORMAL_ACTIVE;
88630 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88631
88632 /* ++ is not atomic, so this should be protected - Jean II */
88633 spin_lock_irqsave(&self->port.lock, flags);
88634 - self->port.count++;
88635 + atomic_inc(&self->port.count);
88636 spin_unlock_irqrestore(&self->port.lock, flags);
88637 tty_port_tty_set(&self->port, tty);
88638
88639 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88640 - self->line, self->port.count);
88641 + self->line, atomic_read(&self->port.count));
88642
88643 /* Not really used by us, but lets do it anyway */
88644 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88645 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88646 tty_kref_put(port->tty);
88647 }
88648 port->tty = NULL;
88649 - port->count = 0;
88650 + atomic_set(&port->count, 0);
88651 spin_unlock_irqrestore(&port->lock, flags);
88652
88653 wake_up_interruptible(&port->open_wait);
88654 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88655 seq_putc(m, '\n');
88656
88657 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88658 - seq_printf(m, "Open count: %d\n", self->port.count);
88659 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88660 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88661 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88662
88663 diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c
88664 index 8c00416..9ea0c93 100644
88665 --- a/net/irda/irlap_frame.c
88666 +++ b/net/irda/irlap_frame.c
88667 @@ -544,7 +544,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
88668 /*
88669 * We now have some discovery info to deliver!
88670 */
88671 - discovery = kmalloc(sizeof(discovery_t), GFP_ATOMIC);
88672 + discovery = kzalloc(sizeof(discovery_t), GFP_ATOMIC);
88673 if (!discovery) {
88674 IRDA_WARNING("%s: unable to malloc!\n", __func__);
88675 return;
88676 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88677 index 206ce6d..cfb27cd 100644
88678 --- a/net/iucv/af_iucv.c
88679 +++ b/net/iucv/af_iucv.c
88680 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
88681
88682 write_lock_bh(&iucv_sk_list.lock);
88683
88684 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88685 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88686 while (__iucv_get_sock_by_name(name)) {
88687 sprintf(name, "%08x",
88688 - atomic_inc_return(&iucv_sk_list.autobind_name));
88689 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88690 }
88691
88692 write_unlock_bh(&iucv_sk_list.lock);
88693 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88694 index 4fe76ff..426a904 100644
88695 --- a/net/iucv/iucv.c
88696 +++ b/net/iucv/iucv.c
88697 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88698 return NOTIFY_OK;
88699 }
88700
88701 -static struct notifier_block __refdata iucv_cpu_notifier = {
88702 +static struct notifier_block iucv_cpu_notifier = {
88703 .notifier_call = iucv_cpu_notify,
88704 };
88705
88706 diff --git a/net/key/af_key.c b/net/key/af_key.c
88707 index 5b1e5af..1b929e7 100644
88708 --- a/net/key/af_key.c
88709 +++ b/net/key/af_key.c
88710 @@ -1710,6 +1710,7 @@ static int key_notify_sa_flush(const struct km_event *c)
88711 hdr->sadb_msg_version = PF_KEY_V2;
88712 hdr->sadb_msg_errno = (uint8_t) 0;
88713 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
88714 + hdr->sadb_msg_reserved = 0;
88715
88716 pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
88717
88718 @@ -2695,6 +2696,7 @@ static int key_notify_policy_flush(const struct km_event *c)
88719 hdr->sadb_msg_errno = (uint8_t) 0;
88720 hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC;
88721 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
88722 + hdr->sadb_msg_reserved = 0;
88723 pfkey_broadcast(skb_out, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
88724 return 0;
88725
88726 @@ -3041,10 +3043,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88727 static u32 get_acqseq(void)
88728 {
88729 u32 res;
88730 - static atomic_t acqseq;
88731 + static atomic_unchecked_t acqseq;
88732
88733 do {
88734 - res = atomic_inc_return(&acqseq);
88735 + res = atomic_inc_return_unchecked(&acqseq);
88736 } while (!res);
88737 return res;
88738 }
88739 diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
88740 index 637a341..8dec687 100644
88741 --- a/net/l2tp/l2tp_ppp.c
88742 +++ b/net/l2tp/l2tp_ppp.c
88743 @@ -346,19 +346,19 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
88744 skb_put(skb, 2);
88745
88746 /* Copy user data into skb */
88747 - error = memcpy_fromiovec(skb->data, m->msg_iov, total_len);
88748 + error = memcpy_fromiovec(skb_put(skb, total_len), m->msg_iov,
88749 + total_len);
88750 if (error < 0) {
88751 kfree_skb(skb);
88752 goto error_put_sess_tun;
88753 }
88754 - skb_put(skb, total_len);
88755
88756 l2tp_xmit_skb(session, skb, session->hdr_len);
88757
88758 sock_put(ps->tunnel_sock);
88759 sock_put(sk);
88760
88761 - return error;
88762 + return total_len;
88763
88764 error_put_sess_tun:
88765 sock_put(ps->tunnel_sock);
88766 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88767 index 843d8c4..cb04fa1 100644
88768 --- a/net/mac80211/cfg.c
88769 +++ b/net/mac80211/cfg.c
88770 @@ -799,7 +799,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88771 ret = ieee80211_vif_use_channel(sdata, chandef,
88772 IEEE80211_CHANCTX_EXCLUSIVE);
88773 }
88774 - } else if (local->open_count == local->monitors) {
88775 + } else if (local_read(&local->open_count) == local->monitors) {
88776 local->_oper_channel = chandef->chan;
88777 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88778 ieee80211_hw_config(local, 0);
88779 @@ -2834,7 +2834,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88780 else
88781 local->probe_req_reg--;
88782
88783 - if (!local->open_count)
88784 + if (!local_read(&local->open_count))
88785 break;
88786
88787 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88788 @@ -3297,8 +3297,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
88789 if (chanctx_conf) {
88790 *chandef = chanctx_conf->def;
88791 ret = 0;
88792 - } else if (local->open_count > 0 &&
88793 - local->open_count == local->monitors &&
88794 + } else if (local_read(&local->open_count) > 0 &&
88795 + local_read(&local->open_count) == local->monitors &&
88796 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
88797 if (local->use_chanctx)
88798 *chandef = local->monitor_chandef;
88799 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88800 index 5672533..6738c93 100644
88801 --- a/net/mac80211/ieee80211_i.h
88802 +++ b/net/mac80211/ieee80211_i.h
88803 @@ -28,6 +28,7 @@
88804 #include <net/ieee80211_radiotap.h>
88805 #include <net/cfg80211.h>
88806 #include <net/mac80211.h>
88807 +#include <asm/local.h>
88808 #include "key.h"
88809 #include "sta_info.h"
88810 #include "debug.h"
88811 @@ -897,7 +898,7 @@ struct ieee80211_local {
88812 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88813 spinlock_t queue_stop_reason_lock;
88814
88815 - int open_count;
88816 + local_t open_count;
88817 int monitors, cooked_mntrs;
88818 /* number of interfaces with corresponding FIF_ flags */
88819 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88820 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88821 index 9cbebc2..14879bb 100644
88822 --- a/net/mac80211/iface.c
88823 +++ b/net/mac80211/iface.c
88824 @@ -495,7 +495,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88825 break;
88826 }
88827
88828 - if (local->open_count == 0) {
88829 + if (local_read(&local->open_count) == 0) {
88830 res = drv_start(local);
88831 if (res)
88832 goto err_del_bss;
88833 @@ -540,7 +540,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88834 break;
88835 }
88836
88837 - if (local->monitors == 0 && local->open_count == 0) {
88838 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88839 res = ieee80211_add_virtual_monitor(local);
88840 if (res)
88841 goto err_stop;
88842 @@ -649,7 +649,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88843 atomic_inc(&local->iff_promiscs);
88844
88845 if (coming_up)
88846 - local->open_count++;
88847 + local_inc(&local->open_count);
88848
88849 if (hw_reconf_flags)
88850 ieee80211_hw_config(local, hw_reconf_flags);
88851 @@ -663,7 +663,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88852 err_del_interface:
88853 drv_remove_interface(local, sdata);
88854 err_stop:
88855 - if (!local->open_count)
88856 + if (!local_read(&local->open_count))
88857 drv_stop(local);
88858 err_del_bss:
88859 sdata->bss = NULL;
88860 @@ -806,7 +806,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88861 }
88862
88863 if (going_down)
88864 - local->open_count--;
88865 + local_dec(&local->open_count);
88866
88867 switch (sdata->vif.type) {
88868 case NL80211_IFTYPE_AP_VLAN:
88869 @@ -871,7 +871,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88870
88871 ieee80211_recalc_ps(local, -1);
88872
88873 - if (local->open_count == 0) {
88874 + if (local_read(&local->open_count) == 0) {
88875 if (local->ops->napi_poll)
88876 napi_disable(&local->napi);
88877 ieee80211_clear_tx_pending(local);
88878 @@ -897,7 +897,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88879 }
88880 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88881
88882 - if (local->monitors == local->open_count && local->monitors > 0)
88883 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88884 ieee80211_add_virtual_monitor(local);
88885 }
88886
88887 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88888 index 1a8591b..ef5db54 100644
88889 --- a/net/mac80211/main.c
88890 +++ b/net/mac80211/main.c
88891 @@ -180,7 +180,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88892 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88893 IEEE80211_CONF_CHANGE_POWER);
88894
88895 - if (changed && local->open_count) {
88896 + if (changed && local_read(&local->open_count)) {
88897 ret = drv_config(local, changed);
88898 /*
88899 * Goal:
88900 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88901 index 835584c..be46e67 100644
88902 --- a/net/mac80211/pm.c
88903 +++ b/net/mac80211/pm.c
88904 @@ -33,7 +33,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88905 struct sta_info *sta;
88906 struct ieee80211_chanctx *ctx;
88907
88908 - if (!local->open_count)
88909 + if (!local_read(&local->open_count))
88910 goto suspend;
88911
88912 ieee80211_scan_cancel(local);
88913 @@ -75,7 +75,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88914 cancel_work_sync(&local->dynamic_ps_enable_work);
88915 del_timer_sync(&local->dynamic_ps_timer);
88916
88917 - local->wowlan = wowlan && local->open_count;
88918 + local->wowlan = wowlan && local_read(&local->open_count);
88919 if (local->wowlan) {
88920 int err = drv_suspend(local, wowlan);
88921 if (err < 0) {
88922 @@ -214,7 +214,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88923 mutex_unlock(&local->chanctx_mtx);
88924
88925 /* stop hardware - this must stop RX */
88926 - if (local->open_count)
88927 + if (local_read(&local->open_count))
88928 ieee80211_stop_device(local);
88929
88930 suspend:
88931 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88932 index dd88381..eef4dd6 100644
88933 --- a/net/mac80211/rate.c
88934 +++ b/net/mac80211/rate.c
88935 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88936
88937 ASSERT_RTNL();
88938
88939 - if (local->open_count)
88940 + if (local_read(&local->open_count))
88941 return -EBUSY;
88942
88943 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88944 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88945 index c97a065..ff61928 100644
88946 --- a/net/mac80211/rc80211_pid_debugfs.c
88947 +++ b/net/mac80211/rc80211_pid_debugfs.c
88948 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88949
88950 spin_unlock_irqrestore(&events->lock, status);
88951
88952 - if (copy_to_user(buf, pb, p))
88953 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88954 return -EFAULT;
88955
88956 return p;
88957 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88958 index 0f38f43..e53d4a8 100644
88959 --- a/net/mac80211/util.c
88960 +++ b/net/mac80211/util.c
88961 @@ -1388,7 +1388,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88962 }
88963 #endif
88964 /* everything else happens only if HW was up & running */
88965 - if (!local->open_count)
88966 + if (!local_read(&local->open_count))
88967 goto wake_up;
88968
88969 /*
88970 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88971 index 56d22ca..87c778f 100644
88972 --- a/net/netfilter/Kconfig
88973 +++ b/net/netfilter/Kconfig
88974 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
88975
88976 To compile it as a module, choose M here. If unsure, say N.
88977
88978 +config NETFILTER_XT_MATCH_GRADM
88979 + tristate '"gradm" match support'
88980 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88981 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88982 + ---help---
88983 + The gradm match allows to match on grsecurity RBAC being enabled.
88984 + It is useful when iptables rules are applied early on bootup to
88985 + prevent connections to the machine (except from a trusted host)
88986 + while the RBAC system is disabled.
88987 +
88988 config NETFILTER_XT_MATCH_HASHLIMIT
88989 tristate '"hashlimit" match support'
88990 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88991 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88992 index a1abf87..dbcb7ee 100644
88993 --- a/net/netfilter/Makefile
88994 +++ b/net/netfilter/Makefile
88995 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88996 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88997 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88998 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88999 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
89000 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
89001 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
89002 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
89003 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
89004 index 1ba9dbc..e39f4ca 100644
89005 --- a/net/netfilter/ipset/ip_set_core.c
89006 +++ b/net/netfilter/ipset/ip_set_core.c
89007 @@ -1801,7 +1801,7 @@ done:
89008 return ret;
89009 }
89010
89011 -static struct nf_sockopt_ops so_set __read_mostly = {
89012 +static struct nf_sockopt_ops so_set = {
89013 .pf = PF_INET,
89014 .get_optmin = SO_IP_SET,
89015 .get_optmax = SO_IP_SET + 1,
89016 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
89017 index 704e514..d644cc2 100644
89018 --- a/net/netfilter/ipvs/ip_vs_conn.c
89019 +++ b/net/netfilter/ipvs/ip_vs_conn.c
89020 @@ -551,7 +551,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
89021 /* Increase the refcnt counter of the dest */
89022 atomic_inc(&dest->refcnt);
89023
89024 - conn_flags = atomic_read(&dest->conn_flags);
89025 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
89026 if (cp->protocol != IPPROTO_UDP)
89027 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
89028 flags = cp->flags;
89029 @@ -895,7 +895,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
89030 atomic_set(&cp->refcnt, 1);
89031
89032 atomic_set(&cp->n_control, 0);
89033 - atomic_set(&cp->in_pkts, 0);
89034 + atomic_set_unchecked(&cp->in_pkts, 0);
89035
89036 atomic_inc(&ipvs->conn_count);
89037 if (flags & IP_VS_CONN_F_NO_CPORT)
89038 @@ -1174,7 +1174,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
89039
89040 /* Don't drop the entry if its number of incoming packets is not
89041 located in [0, 8] */
89042 - i = atomic_read(&cp->in_pkts);
89043 + i = atomic_read_unchecked(&cp->in_pkts);
89044 if (i > 8 || i < 0) return 0;
89045
89046 if (!todrop_rate[i]) return 0;
89047 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
89048 index 61f49d2..6c8c5bc 100644
89049 --- a/net/netfilter/ipvs/ip_vs_core.c
89050 +++ b/net/netfilter/ipvs/ip_vs_core.c
89051 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
89052 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
89053 /* do not touch skb anymore */
89054
89055 - atomic_inc(&cp->in_pkts);
89056 + atomic_inc_unchecked(&cp->in_pkts);
89057 ip_vs_conn_put(cp);
89058 return ret;
89059 }
89060 @@ -1689,7 +1689,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
89061 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
89062 pkts = sysctl_sync_threshold(ipvs);
89063 else
89064 - pkts = atomic_add_return(1, &cp->in_pkts);
89065 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89066
89067 if (ipvs->sync_state & IP_VS_STATE_MASTER)
89068 ip_vs_sync_conn(net, cp, pkts);
89069 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
89070 index 9e2d1cc..6ed0748 100644
89071 --- a/net/netfilter/ipvs/ip_vs_ctl.c
89072 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
89073 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
89074 ip_vs_rs_hash(ipvs, dest);
89075 write_unlock_bh(&ipvs->rs_lock);
89076 }
89077 - atomic_set(&dest->conn_flags, conn_flags);
89078 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
89079
89080 /* bind the service */
89081 if (!dest->svc) {
89082 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
89083 * align with netns init in ip_vs_control_net_init()
89084 */
89085
89086 -static struct ctl_table vs_vars[] = {
89087 +static ctl_table_no_const vs_vars[] __read_only = {
89088 {
89089 .procname = "amemthresh",
89090 .maxlen = sizeof(int),
89091 @@ -2087,7 +2087,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89092 " %-7s %-6d %-10d %-10d\n",
89093 &dest->addr.in6,
89094 ntohs(dest->port),
89095 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89096 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89097 atomic_read(&dest->weight),
89098 atomic_read(&dest->activeconns),
89099 atomic_read(&dest->inactconns));
89100 @@ -2098,7 +2098,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89101 "%-7s %-6d %-10d %-10d\n",
89102 ntohl(dest->addr.ip),
89103 ntohs(dest->port),
89104 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89105 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89106 atomic_read(&dest->weight),
89107 atomic_read(&dest->activeconns),
89108 atomic_read(&dest->inactconns));
89109 @@ -2562,13 +2562,14 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
89110 struct ip_vs_dest *dest;
89111 struct ip_vs_dest_entry entry;
89112
89113 + memset(&entry, 0, sizeof(entry));
89114 list_for_each_entry(dest, &svc->destinations, n_list) {
89115 if (count >= get->num_dests)
89116 break;
89117
89118 entry.addr = dest->addr.ip;
89119 entry.port = dest->port;
89120 - entry.conn_flags = atomic_read(&dest->conn_flags);
89121 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
89122 entry.weight = atomic_read(&dest->weight);
89123 entry.u_threshold = dest->u_threshold;
89124 entry.l_threshold = dest->l_threshold;
89125 @@ -3104,7 +3105,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
89126 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
89127 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
89128 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
89129 - (atomic_read(&dest->conn_flags) &
89130 + (atomic_read_unchecked(&dest->conn_flags) &
89131 IP_VS_CONN_F_FWD_MASK)) ||
89132 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
89133 atomic_read(&dest->weight)) ||
89134 @@ -3694,7 +3695,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
89135 {
89136 int idx;
89137 struct netns_ipvs *ipvs = net_ipvs(net);
89138 - struct ctl_table *tbl;
89139 + ctl_table_no_const *tbl;
89140
89141 atomic_set(&ipvs->dropentry, 0);
89142 spin_lock_init(&ipvs->dropentry_lock);
89143 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
89144 index fdd89b9..bd96aa9 100644
89145 --- a/net/netfilter/ipvs/ip_vs_lblc.c
89146 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
89147 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
89148 * IPVS LBLC sysctl table
89149 */
89150 #ifdef CONFIG_SYSCTL
89151 -static ctl_table vs_vars_table[] = {
89152 +static ctl_table_no_const vs_vars_table[] __read_only = {
89153 {
89154 .procname = "lblc_expiration",
89155 .data = NULL,
89156 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
89157 index c03b6a3..8ce3681 100644
89158 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
89159 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
89160 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
89161 * IPVS LBLCR sysctl table
89162 */
89163
89164 -static ctl_table vs_vars_table[] = {
89165 +static ctl_table_no_const vs_vars_table[] __read_only = {
89166 {
89167 .procname = "lblcr_expiration",
89168 .data = NULL,
89169 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
89170 index 44fd10c..2a163b3 100644
89171 --- a/net/netfilter/ipvs/ip_vs_sync.c
89172 +++ b/net/netfilter/ipvs/ip_vs_sync.c
89173 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
89174 cp = cp->control;
89175 if (cp) {
89176 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89177 - pkts = atomic_add_return(1, &cp->in_pkts);
89178 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89179 else
89180 pkts = sysctl_sync_threshold(ipvs);
89181 ip_vs_sync_conn(net, cp->control, pkts);
89182 @@ -758,7 +758,7 @@ control:
89183 if (!cp)
89184 return;
89185 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89186 - pkts = atomic_add_return(1, &cp->in_pkts);
89187 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89188 else
89189 pkts = sysctl_sync_threshold(ipvs);
89190 goto sloop;
89191 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
89192
89193 if (opt)
89194 memcpy(&cp->in_seq, opt, sizeof(*opt));
89195 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89196 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89197 cp->state = state;
89198 cp->old_state = cp->state;
89199 /*
89200 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
89201 index ee6b7a9..f9a89f6 100644
89202 --- a/net/netfilter/ipvs/ip_vs_xmit.c
89203 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
89204 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
89205 else
89206 rc = NF_ACCEPT;
89207 /* do not touch skb anymore */
89208 - atomic_inc(&cp->in_pkts);
89209 + atomic_inc_unchecked(&cp->in_pkts);
89210 goto out;
89211 }
89212
89213 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
89214 else
89215 rc = NF_ACCEPT;
89216 /* do not touch skb anymore */
89217 - atomic_inc(&cp->in_pkts);
89218 + atomic_inc_unchecked(&cp->in_pkts);
89219 goto out;
89220 }
89221
89222 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
89223 index 2d3030a..7ba1c0a 100644
89224 --- a/net/netfilter/nf_conntrack_acct.c
89225 +++ b/net/netfilter/nf_conntrack_acct.c
89226 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
89227 #ifdef CONFIG_SYSCTL
89228 static int nf_conntrack_acct_init_sysctl(struct net *net)
89229 {
89230 - struct ctl_table *table;
89231 + ctl_table_no_const *table;
89232
89233 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
89234 GFP_KERNEL);
89235 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
89236 index c8e001a..f842a8b 100644
89237 --- a/net/netfilter/nf_conntrack_core.c
89238 +++ b/net/netfilter/nf_conntrack_core.c
89239 @@ -1594,6 +1594,10 @@ void nf_conntrack_init_end(void)
89240 #define DYING_NULLS_VAL ((1<<30)+1)
89241 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
89242
89243 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89244 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
89245 +#endif
89246 +
89247 int nf_conntrack_init_net(struct net *net)
89248 {
89249 int ret;
89250 @@ -1608,7 +1612,11 @@ int nf_conntrack_init_net(struct net *net)
89251 goto err_stat;
89252 }
89253
89254 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89255 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
89256 +#else
89257 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
89258 +#endif
89259 if (!net->ct.slabname) {
89260 ret = -ENOMEM;
89261 goto err_slabname;
89262 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
89263 index b5d2eb8..61ef19a 100644
89264 --- a/net/netfilter/nf_conntrack_ecache.c
89265 +++ b/net/netfilter/nf_conntrack_ecache.c
89266 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
89267 #ifdef CONFIG_SYSCTL
89268 static int nf_conntrack_event_init_sysctl(struct net *net)
89269 {
89270 - struct ctl_table *table;
89271 + ctl_table_no_const *table;
89272
89273 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
89274 GFP_KERNEL);
89275 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
89276 index 94b4b98..97cf0ad 100644
89277 --- a/net/netfilter/nf_conntrack_helper.c
89278 +++ b/net/netfilter/nf_conntrack_helper.c
89279 @@ -56,7 +56,7 @@ static struct ctl_table helper_sysctl_table[] = {
89280
89281 static int nf_conntrack_helper_init_sysctl(struct net *net)
89282 {
89283 - struct ctl_table *table;
89284 + ctl_table_no_const *table;
89285
89286 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
89287 GFP_KERNEL);
89288 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
89289 index 58ab405..50eb8d3 100644
89290 --- a/net/netfilter/nf_conntrack_proto.c
89291 +++ b/net/netfilter/nf_conntrack_proto.c
89292 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
89293
89294 static void
89295 nf_ct_unregister_sysctl(struct ctl_table_header **header,
89296 - struct ctl_table **table,
89297 + ctl_table_no_const **table,
89298 unsigned int users)
89299 {
89300 if (users > 0)
89301 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
89302 index ba65b20..2a4d937 100644
89303 --- a/net/netfilter/nf_conntrack_proto_dccp.c
89304 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
89305 @@ -456,7 +456,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
89306
89307 out_invalid:
89308 if (LOG_INVALID(net, IPPROTO_DCCP))
89309 - nf_log_packet(nf_ct_l3num(ct), 0, skb, NULL, NULL, NULL, msg);
89310 + nf_log_packet(nf_ct_l3num(ct), 0, skb, NULL, NULL, NULL, "%s", msg);
89311 return false;
89312 }
89313
89314 @@ -613,7 +613,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
89315
89316 out_invalid:
89317 if (LOG_INVALID(net, IPPROTO_DCCP))
89318 - nf_log_packet(pf, 0, skb, NULL, NULL, NULL, msg);
89319 + nf_log_packet(pf, 0, skb, NULL, NULL, NULL, "%s", msg);
89320 return -NF_ACCEPT;
89321 }
89322
89323 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
89324 index fedee39..d62a93d 100644
89325 --- a/net/netfilter/nf_conntrack_standalone.c
89326 +++ b/net/netfilter/nf_conntrack_standalone.c
89327 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
89328
89329 static int nf_conntrack_standalone_init_sysctl(struct net *net)
89330 {
89331 - struct ctl_table *table;
89332 + ctl_table_no_const *table;
89333
89334 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
89335 GFP_KERNEL);
89336 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
89337 index 902fb0a..87f7fdb 100644
89338 --- a/net/netfilter/nf_conntrack_timestamp.c
89339 +++ b/net/netfilter/nf_conntrack_timestamp.c
89340 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
89341 #ifdef CONFIG_SYSCTL
89342 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
89343 {
89344 - struct ctl_table *table;
89345 + ctl_table_no_const *table;
89346
89347 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
89348 GFP_KERNEL);
89349 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
89350 index 9e31269..bc4c1b7 100644
89351 --- a/net/netfilter/nf_log.c
89352 +++ b/net/netfilter/nf_log.c
89353 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
89354
89355 #ifdef CONFIG_SYSCTL
89356 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
89357 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
89358 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
89359 static struct ctl_table_header *nf_log_dir_header;
89360
89361 static int nf_log_proc_dostring(ctl_table *table, int write,
89362 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
89363 rcu_assign_pointer(nf_loggers[tindex], logger);
89364 mutex_unlock(&nf_log_mutex);
89365 } else {
89366 + ctl_table_no_const nf_log_table = *table;
89367 +
89368 mutex_lock(&nf_log_mutex);
89369 logger = rcu_dereference_protected(nf_loggers[tindex],
89370 lockdep_is_held(&nf_log_mutex));
89371 if (!logger)
89372 - table->data = "NONE";
89373 + nf_log_table.data = "NONE";
89374 else
89375 - table->data = logger->name;
89376 - r = proc_dostring(table, write, buffer, lenp, ppos);
89377 + nf_log_table.data = logger->name;
89378 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
89379 mutex_unlock(&nf_log_mutex);
89380 }
89381
89382 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
89383 index f042ae5..30ea486 100644
89384 --- a/net/netfilter/nf_sockopt.c
89385 +++ b/net/netfilter/nf_sockopt.c
89386 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
89387 }
89388 }
89389
89390 - list_add(&reg->list, &nf_sockopts);
89391 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
89392 out:
89393 mutex_unlock(&nf_sockopt_mutex);
89394 return ret;
89395 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
89396 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
89397 {
89398 mutex_lock(&nf_sockopt_mutex);
89399 - list_del(&reg->list);
89400 + pax_list_del((struct list_head *)&reg->list);
89401 mutex_unlock(&nf_sockopt_mutex);
89402 }
89403 EXPORT_SYMBOL(nf_unregister_sockopt);
89404 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
89405 index f248db5..3778ad9 100644
89406 --- a/net/netfilter/nfnetlink_log.c
89407 +++ b/net/netfilter/nfnetlink_log.c
89408 @@ -72,7 +72,7 @@ struct nfulnl_instance {
89409 };
89410
89411 static DEFINE_SPINLOCK(instances_lock);
89412 -static atomic_t global_seq;
89413 +static atomic_unchecked_t global_seq;
89414
89415 #define INSTANCE_BUCKETS 16
89416 static struct hlist_head instance_table[INSTANCE_BUCKETS];
89417 @@ -536,7 +536,7 @@ __build_packet_message(struct nfulnl_instance *inst,
89418 /* global sequence number */
89419 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89420 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89421 - htonl(atomic_inc_return(&global_seq))))
89422 + htonl(atomic_inc_return_unchecked(&global_seq))))
89423 goto nla_put_failure;
89424
89425 if (data_len) {
89426 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89427 new file mode 100644
89428 index 0000000..c566332
89429 --- /dev/null
89430 +++ b/net/netfilter/xt_gradm.c
89431 @@ -0,0 +1,51 @@
89432 +/*
89433 + * gradm match for netfilter
89434 + * Copyright © Zbigniew Krzystolik, 2010
89435 + *
89436 + * This program is free software; you can redistribute it and/or modify
89437 + * it under the terms of the GNU General Public License; either version
89438 + * 2 or 3 as published by the Free Software Foundation.
89439 + */
89440 +#include <linux/module.h>
89441 +#include <linux/moduleparam.h>
89442 +#include <linux/skbuff.h>
89443 +#include <linux/netfilter/x_tables.h>
89444 +#include <linux/grsecurity.h>
89445 +#include <linux/netfilter/xt_gradm.h>
89446 +
89447 +static bool
89448 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89449 +{
89450 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89451 + bool retval = false;
89452 + if (gr_acl_is_enabled())
89453 + retval = true;
89454 + return retval ^ info->invflags;
89455 +}
89456 +
89457 +static struct xt_match gradm_mt_reg __read_mostly = {
89458 + .name = "gradm",
89459 + .revision = 0,
89460 + .family = NFPROTO_UNSPEC,
89461 + .match = gradm_mt,
89462 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89463 + .me = THIS_MODULE,
89464 +};
89465 +
89466 +static int __init gradm_mt_init(void)
89467 +{
89468 + return xt_register_match(&gradm_mt_reg);
89469 +}
89470 +
89471 +static void __exit gradm_mt_exit(void)
89472 +{
89473 + xt_unregister_match(&gradm_mt_reg);
89474 +}
89475 +
89476 +module_init(gradm_mt_init);
89477 +module_exit(gradm_mt_exit);
89478 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89479 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89480 +MODULE_LICENSE("GPL");
89481 +MODULE_ALIAS("ipt_gradm");
89482 +MODULE_ALIAS("ip6t_gradm");
89483 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89484 index 4fe4fb4..87a89e5 100644
89485 --- a/net/netfilter/xt_statistic.c
89486 +++ b/net/netfilter/xt_statistic.c
89487 @@ -19,7 +19,7 @@
89488 #include <linux/module.h>
89489
89490 struct xt_statistic_priv {
89491 - atomic_t count;
89492 + atomic_unchecked_t count;
89493 } ____cacheline_aligned_in_smp;
89494
89495 MODULE_LICENSE("GPL");
89496 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89497 break;
89498 case XT_STATISTIC_MODE_NTH:
89499 do {
89500 - oval = atomic_read(&info->master->count);
89501 + oval = atomic_read_unchecked(&info->master->count);
89502 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89503 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89504 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89505 if (nval == 0)
89506 ret = !ret;
89507 break;
89508 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89509 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89510 if (info->master == NULL)
89511 return -ENOMEM;
89512 - atomic_set(&info->master->count, info->u.nth.count);
89513 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89514
89515 return 0;
89516 }
89517 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89518 index 1e3fd5b..ad397ea 100644
89519 --- a/net/netlink/af_netlink.c
89520 +++ b/net/netlink/af_netlink.c
89521 @@ -781,7 +781,7 @@ static void netlink_overrun(struct sock *sk)
89522 sk->sk_error_report(sk);
89523 }
89524 }
89525 - atomic_inc(&sk->sk_drops);
89526 + atomic_inc_unchecked(&sk->sk_drops);
89527 }
89528
89529 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89530 @@ -2063,7 +2063,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89531 sk_wmem_alloc_get(s),
89532 nlk->cb,
89533 atomic_read(&s->sk_refcnt),
89534 - atomic_read(&s->sk_drops),
89535 + atomic_read_unchecked(&s->sk_drops),
89536 sock_i_ino(s)
89537 );
89538
89539 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89540 index 5a55be3..7630745 100644
89541 --- a/net/netlink/genetlink.c
89542 +++ b/net/netlink/genetlink.c
89543 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89544 goto errout;
89545 }
89546
89547 + pax_open_kernel();
89548 if (ops->dumpit)
89549 - ops->flags |= GENL_CMD_CAP_DUMP;
89550 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89551 if (ops->doit)
89552 - ops->flags |= GENL_CMD_CAP_DO;
89553 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89554 if (ops->policy)
89555 - ops->flags |= GENL_CMD_CAP_HASPOL;
89556 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89557 + pax_close_kernel();
89558
89559 genl_lock();
89560 - list_add_tail(&ops->ops_list, &family->ops_list);
89561 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89562 genl_unlock();
89563
89564 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89565 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89566 err = 0;
89567 errout:
89568 return err;
89569 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89570 genl_lock();
89571 list_for_each_entry(rc, &family->ops_list, ops_list) {
89572 if (rc == ops) {
89573 - list_del(&ops->ops_list);
89574 + pax_list_del((struct list_head *)&ops->ops_list);
89575 genl_unlock();
89576 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89577 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89578 return 0;
89579 }
89580 }
89581 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89582 index 103bd70..f21aad3 100644
89583 --- a/net/netrom/af_netrom.c
89584 +++ b/net/netrom/af_netrom.c
89585 @@ -834,6 +834,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89586 struct sock *sk = sock->sk;
89587 struct nr_sock *nr = nr_sk(sk);
89588
89589 + memset(sax, 0, sizeof(*sax));
89590 lock_sock(sk);
89591 if (peer != 0) {
89592 if (sk->sk_state != TCP_ESTABLISHED) {
89593 @@ -848,7 +849,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89594 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89595 } else {
89596 sax->fsa_ax25.sax25_family = AF_NETROM;
89597 - sax->fsa_ax25.sax25_ndigis = 0;
89598 sax->fsa_ax25.sax25_call = nr->source_addr;
89599 *uaddr_len = sizeof(struct sockaddr_ax25);
89600 }
89601 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89602 index f83e172..223ffe1 100644
89603 --- a/net/packet/af_packet.c
89604 +++ b/net/packet/af_packet.c
89605 @@ -1571,7 +1571,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89606
89607 spin_lock(&sk->sk_receive_queue.lock);
89608 po->stats.tp_packets++;
89609 - skb->dropcount = atomic_read(&sk->sk_drops);
89610 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89611 __skb_queue_tail(&sk->sk_receive_queue, skb);
89612 spin_unlock(&sk->sk_receive_queue.lock);
89613 sk->sk_data_ready(sk, skb->len);
89614 @@ -1580,7 +1580,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89615 drop_n_acct:
89616 spin_lock(&sk->sk_receive_queue.lock);
89617 po->stats.tp_drops++;
89618 - atomic_inc(&sk->sk_drops);
89619 + atomic_inc_unchecked(&sk->sk_drops);
89620 spin_unlock(&sk->sk_receive_queue.lock);
89621
89622 drop_n_restore:
89623 @@ -2558,6 +2558,7 @@ out:
89624
89625 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89626 {
89627 + struct sock_extended_err ee;
89628 struct sock_exterr_skb *serr;
89629 struct sk_buff *skb, *skb2;
89630 int copied, err;
89631 @@ -2579,8 +2580,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89632 sock_recv_timestamp(msg, sk, skb);
89633
89634 serr = SKB_EXT_ERR(skb);
89635 + ee = serr->ee;
89636 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89637 - sizeof(serr->ee), &serr->ee);
89638 + sizeof ee, &ee);
89639
89640 msg->msg_flags |= MSG_ERRQUEUE;
89641 err = copied;
89642 @@ -2769,12 +2771,11 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr,
89643 return -EOPNOTSUPP;
89644
89645 uaddr->sa_family = AF_PACKET;
89646 + memset(uaddr->sa_data, 0, sizeof(uaddr->sa_data));
89647 rcu_read_lock();
89648 dev = dev_get_by_index_rcu(sock_net(sk), pkt_sk(sk)->ifindex);
89649 if (dev)
89650 - strncpy(uaddr->sa_data, dev->name, 14);
89651 - else
89652 - memset(uaddr->sa_data, 0, 14);
89653 + strlcpy(uaddr->sa_data, dev->name, sizeof(uaddr->sa_data));
89654 rcu_read_unlock();
89655 *uaddr_len = sizeof(*uaddr);
89656
89657 @@ -3205,7 +3206,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89658 case PACKET_HDRLEN:
89659 if (len > sizeof(int))
89660 len = sizeof(int);
89661 - if (copy_from_user(&val, optval, len))
89662 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89663 return -EFAULT;
89664 switch (val) {
89665 case TPACKET_V1:
89666 @@ -3247,7 +3248,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89667 len = lv;
89668 if (put_user(len, optlen))
89669 return -EFAULT;
89670 - if (copy_to_user(optval, data, len))
89671 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89672 return -EFAULT;
89673 return 0;
89674 }
89675 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89676 index 5a940db..d6a502d 100644
89677 --- a/net/phonet/af_phonet.c
89678 +++ b/net/phonet/af_phonet.c
89679 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89680 {
89681 int err = 0;
89682
89683 - if (protocol >= PHONET_NPROTO)
89684 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89685 return -EINVAL;
89686
89687 err = proto_register(pp->prot, 1);
89688 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89689 index e774117..900b8b7 100644
89690 --- a/net/phonet/pep.c
89691 +++ b/net/phonet/pep.c
89692 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89693
89694 case PNS_PEP_CTRL_REQ:
89695 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89696 - atomic_inc(&sk->sk_drops);
89697 + atomic_inc_unchecked(&sk->sk_drops);
89698 break;
89699 }
89700 __skb_pull(skb, 4);
89701 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89702 }
89703
89704 if (pn->rx_credits == 0) {
89705 - atomic_inc(&sk->sk_drops);
89706 + atomic_inc_unchecked(&sk->sk_drops);
89707 err = -ENOBUFS;
89708 break;
89709 }
89710 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89711 }
89712
89713 if (pn->rx_credits == 0) {
89714 - atomic_inc(&sk->sk_drops);
89715 + atomic_inc_unchecked(&sk->sk_drops);
89716 err = NET_RX_DROP;
89717 break;
89718 }
89719 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89720 index 1afd138..0b42453 100644
89721 --- a/net/phonet/socket.c
89722 +++ b/net/phonet/socket.c
89723 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89724 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89725 sock_i_ino(sk),
89726 atomic_read(&sk->sk_refcnt), sk,
89727 - atomic_read(&sk->sk_drops), &len);
89728 + atomic_read_unchecked(&sk->sk_drops), &len);
89729 }
89730 seq_printf(seq, "%*s\n", 127 - len, "");
89731 return 0;
89732 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89733 index d6bbbbd..61561e4 100644
89734 --- a/net/phonet/sysctl.c
89735 +++ b/net/phonet/sysctl.c
89736 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89737 {
89738 int ret;
89739 int range[2] = {local_port_range[0], local_port_range[1]};
89740 - ctl_table tmp = {
89741 + ctl_table_no_const tmp = {
89742 .data = &range,
89743 .maxlen = sizeof(range),
89744 .mode = table->mode,
89745 diff --git a/net/rds/cong.c b/net/rds/cong.c
89746 index e5b65ac..f3b6fb7 100644
89747 --- a/net/rds/cong.c
89748 +++ b/net/rds/cong.c
89749 @@ -78,7 +78,7 @@
89750 * finds that the saved generation number is smaller than the global generation
89751 * number, it wakes up the process.
89752 */
89753 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89754 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89755
89756 /*
89757 * Congestion monitoring
89758 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89759 rdsdebug("waking map %p for %pI4\n",
89760 map, &map->m_addr);
89761 rds_stats_inc(s_cong_update_received);
89762 - atomic_inc(&rds_cong_generation);
89763 + atomic_inc_unchecked(&rds_cong_generation);
89764 if (waitqueue_active(&map->m_waitq))
89765 wake_up(&map->m_waitq);
89766 if (waitqueue_active(&rds_poll_waitq))
89767 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89768
89769 int rds_cong_updated_since(unsigned long *recent)
89770 {
89771 - unsigned long gen = atomic_read(&rds_cong_generation);
89772 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89773
89774 if (likely(*recent == gen))
89775 return 0;
89776 diff --git a/net/rds/ib.h b/net/rds/ib.h
89777 index 7280ab8..e04f4ea 100644
89778 --- a/net/rds/ib.h
89779 +++ b/net/rds/ib.h
89780 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89781 /* sending acks */
89782 unsigned long i_ack_flags;
89783 #ifdef KERNEL_HAS_ATOMIC64
89784 - atomic64_t i_ack_next; /* next ACK to send */
89785 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89786 #else
89787 spinlock_t i_ack_lock; /* protect i_ack_next */
89788 u64 i_ack_next; /* next ACK to send */
89789 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89790 index 31b74f5..dc1fbfa 100644
89791 --- a/net/rds/ib_cm.c
89792 +++ b/net/rds/ib_cm.c
89793 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89794 /* Clear the ACK state */
89795 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89796 #ifdef KERNEL_HAS_ATOMIC64
89797 - atomic64_set(&ic->i_ack_next, 0);
89798 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89799 #else
89800 ic->i_ack_next = 0;
89801 #endif
89802 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89803 index 8eb9501..0c386ff 100644
89804 --- a/net/rds/ib_recv.c
89805 +++ b/net/rds/ib_recv.c
89806 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89807 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89808 int ack_required)
89809 {
89810 - atomic64_set(&ic->i_ack_next, seq);
89811 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89812 if (ack_required) {
89813 smp_mb__before_clear_bit();
89814 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89815 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89816 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89817 smp_mb__after_clear_bit();
89818
89819 - return atomic64_read(&ic->i_ack_next);
89820 + return atomic64_read_unchecked(&ic->i_ack_next);
89821 }
89822 #endif
89823
89824 diff --git a/net/rds/iw.h b/net/rds/iw.h
89825 index 04ce3b1..48119a6 100644
89826 --- a/net/rds/iw.h
89827 +++ b/net/rds/iw.h
89828 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89829 /* sending acks */
89830 unsigned long i_ack_flags;
89831 #ifdef KERNEL_HAS_ATOMIC64
89832 - atomic64_t i_ack_next; /* next ACK to send */
89833 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89834 #else
89835 spinlock_t i_ack_lock; /* protect i_ack_next */
89836 u64 i_ack_next; /* next ACK to send */
89837 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89838 index a91e1db..cf3053f 100644
89839 --- a/net/rds/iw_cm.c
89840 +++ b/net/rds/iw_cm.c
89841 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89842 /* Clear the ACK state */
89843 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89844 #ifdef KERNEL_HAS_ATOMIC64
89845 - atomic64_set(&ic->i_ack_next, 0);
89846 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89847 #else
89848 ic->i_ack_next = 0;
89849 #endif
89850 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89851 index 4503335..db566b4 100644
89852 --- a/net/rds/iw_recv.c
89853 +++ b/net/rds/iw_recv.c
89854 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89855 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89856 int ack_required)
89857 {
89858 - atomic64_set(&ic->i_ack_next, seq);
89859 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89860 if (ack_required) {
89861 smp_mb__before_clear_bit();
89862 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89863 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89864 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89865 smp_mb__after_clear_bit();
89866
89867 - return atomic64_read(&ic->i_ack_next);
89868 + return atomic64_read_unchecked(&ic->i_ack_next);
89869 }
89870 #endif
89871
89872 diff --git a/net/rds/rds.h b/net/rds/rds.h
89873 index ec1d731..90a3a8d 100644
89874 --- a/net/rds/rds.h
89875 +++ b/net/rds/rds.h
89876 @@ -449,7 +449,7 @@ struct rds_transport {
89877 void (*sync_mr)(void *trans_private, int direction);
89878 void (*free_mr)(void *trans_private, int invalidate);
89879 void (*flush_mrs)(void);
89880 -};
89881 +} __do_const;
89882
89883 struct rds_sock {
89884 struct sock rs_sk;
89885 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89886 index edac9ef..16bcb98 100644
89887 --- a/net/rds/tcp.c
89888 +++ b/net/rds/tcp.c
89889 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89890 int val = 1;
89891
89892 set_fs(KERNEL_DS);
89893 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89894 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89895 sizeof(val));
89896 set_fs(oldfs);
89897 }
89898 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89899 index 81cf5a4..b5826ff 100644
89900 --- a/net/rds/tcp_send.c
89901 +++ b/net/rds/tcp_send.c
89902 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89903
89904 oldfs = get_fs();
89905 set_fs(KERNEL_DS);
89906 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89907 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89908 sizeof(val));
89909 set_fs(oldfs);
89910 }
89911 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89912 index e61aa60..f07cc89 100644
89913 --- a/net/rxrpc/af_rxrpc.c
89914 +++ b/net/rxrpc/af_rxrpc.c
89915 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89916 __be32 rxrpc_epoch;
89917
89918 /* current debugging ID */
89919 -atomic_t rxrpc_debug_id;
89920 +atomic_unchecked_t rxrpc_debug_id;
89921
89922 /* count of skbs currently in use */
89923 atomic_t rxrpc_n_skbs;
89924 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89925 index e4d9cbc..b229649 100644
89926 --- a/net/rxrpc/ar-ack.c
89927 +++ b/net/rxrpc/ar-ack.c
89928 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89929
89930 _enter("{%d,%d,%d,%d},",
89931 call->acks_hard, call->acks_unacked,
89932 - atomic_read(&call->sequence),
89933 + atomic_read_unchecked(&call->sequence),
89934 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89935
89936 stop = 0;
89937 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89938
89939 /* each Tx packet has a new serial number */
89940 sp->hdr.serial =
89941 - htonl(atomic_inc_return(&call->conn->serial));
89942 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89943
89944 hdr = (struct rxrpc_header *) txb->head;
89945 hdr->serial = sp->hdr.serial;
89946 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89947 */
89948 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89949 {
89950 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89951 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89952 }
89953
89954 /*
89955 @@ -629,7 +629,7 @@ process_further:
89956
89957 latest = ntohl(sp->hdr.serial);
89958 hard = ntohl(ack.firstPacket);
89959 - tx = atomic_read(&call->sequence);
89960 + tx = atomic_read_unchecked(&call->sequence);
89961
89962 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89963 latest,
89964 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89965 goto maybe_reschedule;
89966
89967 send_ACK_with_skew:
89968 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89969 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89970 ntohl(ack.serial));
89971 send_ACK:
89972 mtu = call->conn->trans->peer->if_mtu;
89973 @@ -1173,7 +1173,7 @@ send_ACK:
89974 ackinfo.rxMTU = htonl(5692);
89975 ackinfo.jumbo_max = htonl(4);
89976
89977 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89978 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89979 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89980 ntohl(hdr.serial),
89981 ntohs(ack.maxSkew),
89982 @@ -1191,7 +1191,7 @@ send_ACK:
89983 send_message:
89984 _debug("send message");
89985
89986 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89987 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89988 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89989 send_message_2:
89990
89991 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89992 index a3bbb36..3341fb9 100644
89993 --- a/net/rxrpc/ar-call.c
89994 +++ b/net/rxrpc/ar-call.c
89995 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89996 spin_lock_init(&call->lock);
89997 rwlock_init(&call->state_lock);
89998 atomic_set(&call->usage, 1);
89999 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
90000 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90001 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
90002
90003 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
90004 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
90005 index 4106ca9..a338d7a 100644
90006 --- a/net/rxrpc/ar-connection.c
90007 +++ b/net/rxrpc/ar-connection.c
90008 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
90009 rwlock_init(&conn->lock);
90010 spin_lock_init(&conn->state_lock);
90011 atomic_set(&conn->usage, 1);
90012 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
90013 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90014 conn->avail_calls = RXRPC_MAXCALLS;
90015 conn->size_align = 4;
90016 conn->header_size = sizeof(struct rxrpc_header);
90017 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
90018 index e7ed43a..6afa140 100644
90019 --- a/net/rxrpc/ar-connevent.c
90020 +++ b/net/rxrpc/ar-connevent.c
90021 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
90022
90023 len = iov[0].iov_len + iov[1].iov_len;
90024
90025 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90026 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90027 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
90028
90029 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90030 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
90031 index 529572f..c758ca7 100644
90032 --- a/net/rxrpc/ar-input.c
90033 +++ b/net/rxrpc/ar-input.c
90034 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
90035 /* track the latest serial number on this connection for ACK packet
90036 * information */
90037 serial = ntohl(sp->hdr.serial);
90038 - hi_serial = atomic_read(&call->conn->hi_serial);
90039 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
90040 while (serial > hi_serial)
90041 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
90042 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
90043 serial);
90044
90045 /* request ACK generation for any ACK or DATA packet that requests
90046 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
90047 index a693aca..81e7293 100644
90048 --- a/net/rxrpc/ar-internal.h
90049 +++ b/net/rxrpc/ar-internal.h
90050 @@ -272,8 +272,8 @@ struct rxrpc_connection {
90051 int error; /* error code for local abort */
90052 int debug_id; /* debug ID for printks */
90053 unsigned int call_counter; /* call ID counter */
90054 - atomic_t serial; /* packet serial number counter */
90055 - atomic_t hi_serial; /* highest serial number received */
90056 + atomic_unchecked_t serial; /* packet serial number counter */
90057 + atomic_unchecked_t hi_serial; /* highest serial number received */
90058 u8 avail_calls; /* number of calls available */
90059 u8 size_align; /* data size alignment (for security) */
90060 u8 header_size; /* rxrpc + security header size */
90061 @@ -346,7 +346,7 @@ struct rxrpc_call {
90062 spinlock_t lock;
90063 rwlock_t state_lock; /* lock for state transition */
90064 atomic_t usage;
90065 - atomic_t sequence; /* Tx data packet sequence counter */
90066 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
90067 u32 abort_code; /* local/remote abort code */
90068 enum { /* current state of call */
90069 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
90070 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
90071 */
90072 extern atomic_t rxrpc_n_skbs;
90073 extern __be32 rxrpc_epoch;
90074 -extern atomic_t rxrpc_debug_id;
90075 +extern atomic_unchecked_t rxrpc_debug_id;
90076 extern struct workqueue_struct *rxrpc_workqueue;
90077
90078 /*
90079 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
90080 index 87f7135..74d3703 100644
90081 --- a/net/rxrpc/ar-local.c
90082 +++ b/net/rxrpc/ar-local.c
90083 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
90084 spin_lock_init(&local->lock);
90085 rwlock_init(&local->services_lock);
90086 atomic_set(&local->usage, 1);
90087 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
90088 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90089 memcpy(&local->srx, srx, sizeof(*srx));
90090 }
90091
90092 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
90093 index e1ac183..b43e10e 100644
90094 --- a/net/rxrpc/ar-output.c
90095 +++ b/net/rxrpc/ar-output.c
90096 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
90097 sp->hdr.cid = call->cid;
90098 sp->hdr.callNumber = call->call_id;
90099 sp->hdr.seq =
90100 - htonl(atomic_inc_return(&call->sequence));
90101 + htonl(atomic_inc_return_unchecked(&call->sequence));
90102 sp->hdr.serial =
90103 - htonl(atomic_inc_return(&conn->serial));
90104 + htonl(atomic_inc_return_unchecked(&conn->serial));
90105 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
90106 sp->hdr.userStatus = 0;
90107 sp->hdr.securityIndex = conn->security_ix;
90108 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
90109 index bebaa43..2644591 100644
90110 --- a/net/rxrpc/ar-peer.c
90111 +++ b/net/rxrpc/ar-peer.c
90112 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
90113 INIT_LIST_HEAD(&peer->error_targets);
90114 spin_lock_init(&peer->lock);
90115 atomic_set(&peer->usage, 1);
90116 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
90117 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90118 memcpy(&peer->srx, srx, sizeof(*srx));
90119
90120 rxrpc_assess_MTU_size(peer);
90121 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
90122 index 38047f7..9f48511 100644
90123 --- a/net/rxrpc/ar-proc.c
90124 +++ b/net/rxrpc/ar-proc.c
90125 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
90126 atomic_read(&conn->usage),
90127 rxrpc_conn_states[conn->state],
90128 key_serial(conn->key),
90129 - atomic_read(&conn->serial),
90130 - atomic_read(&conn->hi_serial));
90131 + atomic_read_unchecked(&conn->serial),
90132 + atomic_read_unchecked(&conn->hi_serial));
90133
90134 return 0;
90135 }
90136 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
90137 index 92df566..87ec1bf 100644
90138 --- a/net/rxrpc/ar-transport.c
90139 +++ b/net/rxrpc/ar-transport.c
90140 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
90141 spin_lock_init(&trans->client_lock);
90142 rwlock_init(&trans->conn_lock);
90143 atomic_set(&trans->usage, 1);
90144 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
90145 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90146
90147 if (peer->srx.transport.family == AF_INET) {
90148 switch (peer->srx.transport_type) {
90149 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
90150 index f226709..0e735a8 100644
90151 --- a/net/rxrpc/rxkad.c
90152 +++ b/net/rxrpc/rxkad.c
90153 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
90154
90155 len = iov[0].iov_len + iov[1].iov_len;
90156
90157 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90158 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90159 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
90160
90161 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90162 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
90163
90164 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
90165
90166 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
90167 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90168 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
90169
90170 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
90171 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
90172 index 391a245..296b3d7 100644
90173 --- a/net/sctp/ipv6.c
90174 +++ b/net/sctp/ipv6.c
90175 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
90176 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
90177 };
90178
90179 -static struct sctp_af sctp_af_inet6 = {
90180 +static struct sctp_af sctp_af_inet6 __read_only = {
90181 .sa_family = AF_INET6,
90182 .sctp_xmit = sctp_v6_xmit,
90183 .setsockopt = ipv6_setsockopt,
90184 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
90185 #endif
90186 };
90187
90188 -static struct sctp_pf sctp_pf_inet6 = {
90189 +static struct sctp_pf sctp_pf_inet6 __read_only = {
90190 .event_msgname = sctp_inet6_event_msgname,
90191 .skb_msgname = sctp_inet6_skb_msgname,
90192 .af_supported = sctp_inet6_af_supported,
90193 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
90194
90195 void sctp_v6_pf_exit(void)
90196 {
90197 - list_del(&sctp_af_inet6.list);
90198 + pax_list_del(&sctp_af_inet6.list);
90199 }
90200
90201 /* Initialize IPv6 support and register with socket layer. */
90202 diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
90203 index 01dca75..e9426bb 100644
90204 --- a/net/sctp/outqueue.c
90205 +++ b/net/sctp/outqueue.c
90206 @@ -206,6 +206,8 @@ static inline int sctp_cacc_skip(struct sctp_transport *primary,
90207 */
90208 void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
90209 {
90210 + memset(q, 0, sizeof(struct sctp_outq));
90211 +
90212 q->asoc = asoc;
90213 INIT_LIST_HEAD(&q->out_chunk_list);
90214 INIT_LIST_HEAD(&q->control_chunk_list);
90215 @@ -213,13 +215,7 @@ void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
90216 INIT_LIST_HEAD(&q->sacked);
90217 INIT_LIST_HEAD(&q->abandoned);
90218
90219 - q->fast_rtx = 0;
90220 - q->outstanding_bytes = 0;
90221 q->empty = 1;
90222 - q->cork = 0;
90223 -
90224 - q->malloced = 0;
90225 - q->out_qlen = 0;
90226 }
90227
90228 /* Free the outqueue structure and any related pending chunks.
90229 diff --git a/net/sctp/probe.c b/net/sctp/probe.c
90230 index ad0dba8..e62c225 100644
90231 --- a/net/sctp/probe.c
90232 +++ b/net/sctp/probe.c
90233 @@ -63,7 +63,7 @@ static struct {
90234 struct timespec tstart;
90235 } sctpw;
90236
90237 -static void printl(const char *fmt, ...)
90238 +static __printf(1, 2) void printl(const char *fmt, ...)
90239 {
90240 va_list args;
90241 int len;
90242 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
90243 index ab3bba8..2fbab4e 100644
90244 --- a/net/sctp/proc.c
90245 +++ b/net/sctp/proc.c
90246 @@ -336,7 +336,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
90247 seq_printf(seq,
90248 "%8pK %8pK %-3d %-3d %-2d %-4d "
90249 "%4d %8d %8d %7d %5lu %-5d %5d ",
90250 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
90251 + assoc, sk,
90252 + sctp_sk(sk)->type, sk->sk_state,
90253 assoc->state, hash,
90254 assoc->assoc_id,
90255 assoc->sndbuf_used,
90256 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
90257 index 1c2e46c..f91cf5e 100644
90258 --- a/net/sctp/protocol.c
90259 +++ b/net/sctp/protocol.c
90260 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
90261 return 0;
90262 }
90263
90264 + pax_open_kernel();
90265 INIT_LIST_HEAD(&af->list);
90266 - list_add_tail(&af->list, &sctp_address_families);
90267 + pax_close_kernel();
90268 + pax_list_add_tail(&af->list, &sctp_address_families);
90269 return 1;
90270 }
90271
90272 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
90273
90274 static struct sctp_af sctp_af_inet;
90275
90276 -static struct sctp_pf sctp_pf_inet = {
90277 +static struct sctp_pf sctp_pf_inet __read_only = {
90278 .event_msgname = sctp_inet_event_msgname,
90279 .skb_msgname = sctp_inet_skb_msgname,
90280 .af_supported = sctp_inet_af_supported,
90281 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
90282 };
90283
90284 /* IPv4 address related functions. */
90285 -static struct sctp_af sctp_af_inet = {
90286 +static struct sctp_af sctp_af_inet __read_only = {
90287 .sa_family = AF_INET,
90288 .sctp_xmit = sctp_v4_xmit,
90289 .setsockopt = ip_setsockopt,
90290 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
90291
90292 static void sctp_v4_pf_exit(void)
90293 {
90294 - list_del(&sctp_af_inet.list);
90295 + pax_list_del(&sctp_af_inet.list);
90296 }
90297
90298 static int sctp_v4_protosw_init(void)
90299 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
90300 index 8aab894..f6b7e7d 100644
90301 --- a/net/sctp/sm_sideeffect.c
90302 +++ b/net/sctp/sm_sideeffect.c
90303 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
90304 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
90305 }
90306
90307 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90308 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90309 NULL,
90310 sctp_generate_t1_cookie_event,
90311 sctp_generate_t1_init_event,
90312 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
90313 index b907073..7bea2ca 100644
90314 --- a/net/sctp/socket.c
90315 +++ b/net/sctp/socket.c
90316 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
90317 {
90318 struct sctp_association *asoc;
90319 struct sctp_ulpevent *event;
90320 + struct sctp_event_subscribe subscribe;
90321
90322 if (optlen > sizeof(struct sctp_event_subscribe))
90323 return -EINVAL;
90324 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
90325 + if (copy_from_user(&subscribe, optval, optlen))
90326 return -EFAULT;
90327 + sctp_sk(sk)->subscribe = subscribe;
90328
90329 /*
90330 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
90331 @@ -4002,6 +4004,12 @@ SCTP_STATIC void sctp_destroy_sock(struct sock *sk)
90332
90333 /* Release our hold on the endpoint. */
90334 sp = sctp_sk(sk);
90335 + /* This could happen during socket init, thus we bail out
90336 + * early, since the rest of the below is not setup either.
90337 + */
90338 + if (sp->ep == NULL)
90339 + return;
90340 +
90341 if (sp->do_auto_asconf) {
90342 sp->do_auto_asconf = 0;
90343 list_del(&sp->auto_asconf_list);
90344 @@ -4215,13 +4223,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
90345 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90346 int __user *optlen)
90347 {
90348 + struct sctp_event_subscribe subscribe;
90349 +
90350 if (len <= 0)
90351 return -EINVAL;
90352 if (len > sizeof(struct sctp_event_subscribe))
90353 len = sizeof(struct sctp_event_subscribe);
90354 if (put_user(len, optlen))
90355 return -EFAULT;
90356 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
90357 + subscribe = sctp_sk(sk)->subscribe;
90358 + if (copy_to_user(optval, &subscribe, len))
90359 return -EFAULT;
90360 return 0;
90361 }
90362 @@ -4239,6 +4250,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90363 */
90364 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
90365 {
90366 + __u32 autoclose;
90367 +
90368 /* Applicable to UDP-style socket only */
90369 if (sctp_style(sk, TCP))
90370 return -EOPNOTSUPP;
90371 @@ -4247,7 +4260,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
90372 len = sizeof(int);
90373 if (put_user(len, optlen))
90374 return -EFAULT;
90375 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
90376 + autoclose = sctp_sk(sk)->autoclose;
90377 + if (copy_to_user(optval, &autoclose, sizeof(int)))
90378 return -EFAULT;
90379 return 0;
90380 }
90381 @@ -4619,12 +4633,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
90382 */
90383 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
90384 {
90385 + struct sctp_initmsg initmsg;
90386 +
90387 if (len < sizeof(struct sctp_initmsg))
90388 return -EINVAL;
90389 len = sizeof(struct sctp_initmsg);
90390 if (put_user(len, optlen))
90391 return -EFAULT;
90392 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
90393 + initmsg = sctp_sk(sk)->initmsg;
90394 + if (copy_to_user(optval, &initmsg, len))
90395 return -EFAULT;
90396 return 0;
90397 }
90398 @@ -4665,6 +4682,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
90399 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
90400 if (space_left < addrlen)
90401 return -ENOMEM;
90402 + if (addrlen > sizeof(temp) || addrlen < 0)
90403 + return -EFAULT;
90404 if (copy_to_user(to, &temp, addrlen))
90405 return -EFAULT;
90406 to += addrlen;
90407 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
90408 index bf3c6e8..376d8d0 100644
90409 --- a/net/sctp/sysctl.c
90410 +++ b/net/sctp/sysctl.c
90411 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90412 {
90413 struct net *net = current->nsproxy->net_ns;
90414 char tmp[8];
90415 - ctl_table tbl;
90416 + ctl_table_no_const tbl;
90417 int ret;
90418 int changed = 0;
90419 char *none = "none";
90420 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90421
90422 int sctp_sysctl_net_register(struct net *net)
90423 {
90424 - struct ctl_table *table;
90425 + ctl_table_no_const *table;
90426 int i;
90427
90428 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90429 diff --git a/net/socket.c b/net/socket.c
90430 index 88f759a..74be616 100644
90431 --- a/net/socket.c
90432 +++ b/net/socket.c
90433 @@ -88,6 +88,7 @@
90434 #include <linux/magic.h>
90435 #include <linux/slab.h>
90436 #include <linux/xattr.h>
90437 +#include <linux/in.h>
90438
90439 #include <asm/uaccess.h>
90440 #include <asm/unistd.h>
90441 @@ -105,6 +106,8 @@
90442 #include <linux/sockios.h>
90443 #include <linux/atalk.h>
90444
90445 +#include <linux/grsock.h>
90446 +
90447 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90448 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90449 unsigned long nr_segs, loff_t pos);
90450 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90451 &sockfs_dentry_operations, SOCKFS_MAGIC);
90452 }
90453
90454 -static struct vfsmount *sock_mnt __read_mostly;
90455 +struct vfsmount *sock_mnt __read_mostly;
90456
90457 static struct file_system_type sock_fs_type = {
90458 .name = "sockfs",
90459 @@ -1268,6 +1271,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90460 return -EAFNOSUPPORT;
90461 if (type < 0 || type >= SOCK_MAX)
90462 return -EINVAL;
90463 + if (protocol < 0)
90464 + return -EINVAL;
90465
90466 /* Compatibility.
90467
90468 @@ -1399,6 +1404,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90469 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90470 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90471
90472 + if(!gr_search_socket(family, type, protocol)) {
90473 + retval = -EACCES;
90474 + goto out;
90475 + }
90476 +
90477 + if (gr_handle_sock_all(family, type, protocol)) {
90478 + retval = -EACCES;
90479 + goto out;
90480 + }
90481 +
90482 retval = sock_create(family, type, protocol, &sock);
90483 if (retval < 0)
90484 goto out;
90485 @@ -1526,6 +1541,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90486 if (sock) {
90487 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90488 if (err >= 0) {
90489 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90490 + err = -EACCES;
90491 + goto error;
90492 + }
90493 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90494 + if (err)
90495 + goto error;
90496 +
90497 err = security_socket_bind(sock,
90498 (struct sockaddr *)&address,
90499 addrlen);
90500 @@ -1534,6 +1557,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90501 (struct sockaddr *)
90502 &address, addrlen);
90503 }
90504 +error:
90505 fput_light(sock->file, fput_needed);
90506 }
90507 return err;
90508 @@ -1557,10 +1581,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90509 if ((unsigned int)backlog > somaxconn)
90510 backlog = somaxconn;
90511
90512 + if (gr_handle_sock_server_other(sock->sk)) {
90513 + err = -EPERM;
90514 + goto error;
90515 + }
90516 +
90517 + err = gr_search_listen(sock);
90518 + if (err)
90519 + goto error;
90520 +
90521 err = security_socket_listen(sock, backlog);
90522 if (!err)
90523 err = sock->ops->listen(sock, backlog);
90524
90525 +error:
90526 fput_light(sock->file, fput_needed);
90527 }
90528 return err;
90529 @@ -1604,6 +1638,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90530 newsock->type = sock->type;
90531 newsock->ops = sock->ops;
90532
90533 + if (gr_handle_sock_server_other(sock->sk)) {
90534 + err = -EPERM;
90535 + sock_release(newsock);
90536 + goto out_put;
90537 + }
90538 +
90539 + err = gr_search_accept(sock);
90540 + if (err) {
90541 + sock_release(newsock);
90542 + goto out_put;
90543 + }
90544 +
90545 /*
90546 * We don't need try_module_get here, as the listening socket (sock)
90547 * has the protocol module (sock->ops->owner) held.
90548 @@ -1649,6 +1695,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90549 fd_install(newfd, newfile);
90550 err = newfd;
90551
90552 + gr_attach_curr_ip(newsock->sk);
90553 +
90554 out_put:
90555 fput_light(sock->file, fput_needed);
90556 out:
90557 @@ -1681,6 +1729,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90558 int, addrlen)
90559 {
90560 struct socket *sock;
90561 + struct sockaddr *sck;
90562 struct sockaddr_storage address;
90563 int err, fput_needed;
90564
90565 @@ -1691,6 +1740,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90566 if (err < 0)
90567 goto out_put;
90568
90569 + sck = (struct sockaddr *)&address;
90570 +
90571 + if (gr_handle_sock_client(sck)) {
90572 + err = -EACCES;
90573 + goto out_put;
90574 + }
90575 +
90576 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90577 + if (err)
90578 + goto out_put;
90579 +
90580 err =
90581 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90582 if (err)
90583 @@ -1772,6 +1832,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90584 * the protocol.
90585 */
90586
90587 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90588 +
90589 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90590 unsigned int, flags, struct sockaddr __user *, addr,
90591 int, addr_len)
90592 @@ -1838,7 +1900,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90593 struct socket *sock;
90594 struct iovec iov;
90595 struct msghdr msg;
90596 - struct sockaddr_storage address;
90597 + struct sockaddr_storage address = { };
90598 int err, err2;
90599 int fput_needed;
90600
90601 @@ -1978,7 +2040,7 @@ struct used_address {
90602 unsigned int name_len;
90603 };
90604
90605 -static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90606 +static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90607 struct msghdr *msg_sys, unsigned int flags,
90608 struct used_address *used_address)
90609 {
90610 @@ -2045,7 +2107,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90611 * checking falls down on this.
90612 */
90613 if (copy_from_user(ctl_buf,
90614 - (void __user __force *)msg_sys->msg_control,
90615 + (void __force_user *)msg_sys->msg_control,
90616 ctl_len))
90617 goto out_freectl;
90618 msg_sys->msg_control = ctl_buf;
90619 @@ -2093,20 +2155,28 @@ out:
90620 * BSD sendmsg interface
90621 */
90622
90623 +long __sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags)
90624 +{
90625 + int fput_needed, err;
90626 + struct msghdr msg_sys;
90627 + struct socket *sock;
90628 +
90629 + sock = sockfd_lookup_light(fd, &err, &fput_needed);
90630 + if (!sock)
90631 + goto out;
90632 +
90633 + err = ___sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
90634 +
90635 + fput_light(sock->file, fput_needed);
90636 +out:
90637 + return err;
90638 +}
90639 +
90640 SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned int, flags)
90641 {
90642 - int fput_needed, err;
90643 - struct msghdr msg_sys;
90644 - struct socket *sock = sockfd_lookup_light(fd, &err, &fput_needed);
90645 -
90646 - if (!sock)
90647 - goto out;
90648 -
90649 - err = __sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
90650 -
90651 - fput_light(sock->file, fput_needed);
90652 -out:
90653 - return err;
90654 + if (flags & MSG_CMSG_COMPAT)
90655 + return -EINVAL;
90656 + return __sys_sendmsg(fd, msg, flags);
90657 }
90658
90659 /*
90660 @@ -2139,15 +2209,16 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
90661
90662 while (datagrams < vlen) {
90663 if (MSG_CMSG_COMPAT & flags) {
90664 - err = __sys_sendmsg(sock, (struct msghdr __user *)compat_entry,
90665 - &msg_sys, flags, &used_address);
90666 + err = ___sys_sendmsg(sock, (struct msghdr __user *)compat_entry,
90667 + &msg_sys, flags, &used_address);
90668 if (err < 0)
90669 break;
90670 err = __put_user(err, &compat_entry->msg_len);
90671 ++compat_entry;
90672 } else {
90673 - err = __sys_sendmsg(sock, (struct msghdr __user *)entry,
90674 - &msg_sys, flags, &used_address);
90675 + err = ___sys_sendmsg(sock,
90676 + (struct msghdr __user *)entry,
90677 + &msg_sys, flags, &used_address);
90678 if (err < 0)
90679 break;
90680 err = put_user(err, &entry->msg_len);
90681 @@ -2171,10 +2242,12 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
90682 SYSCALL_DEFINE4(sendmmsg, int, fd, struct mmsghdr __user *, mmsg,
90683 unsigned int, vlen, unsigned int, flags)
90684 {
90685 + if (flags & MSG_CMSG_COMPAT)
90686 + return -EINVAL;
90687 return __sys_sendmmsg(fd, mmsg, vlen, flags);
90688 }
90689
90690 -static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90691 +static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90692 struct msghdr *msg_sys, unsigned int flags, int nosec)
90693 {
90694 struct compat_msghdr __user *msg_compat =
90695 @@ -2185,7 +2258,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90696 int err, total_len, len;
90697
90698 /* kernel mode address */
90699 - struct sockaddr_storage addr;
90700 + struct sockaddr_storage addr = { };
90701
90702 /* user mode address pointers */
90703 struct sockaddr __user *uaddr;
90704 @@ -2213,7 +2286,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90705 * kernel msghdr to use the kernel address space)
90706 */
90707
90708 - uaddr = (__force void __user *)msg_sys->msg_name;
90709 + uaddr = (void __force_user *)msg_sys->msg_name;
90710 uaddr_len = COMPAT_NAMELEN(msg);
90711 if (MSG_CMSG_COMPAT & flags) {
90712 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90713 @@ -2266,21 +2339,29 @@ out:
90714 * BSD recvmsg interface
90715 */
90716
90717 +long __sys_recvmsg(int fd, struct msghdr __user *msg, unsigned flags)
90718 +{
90719 + int fput_needed, err;
90720 + struct msghdr msg_sys;
90721 + struct socket *sock;
90722 +
90723 + sock = sockfd_lookup_light(fd, &err, &fput_needed);
90724 + if (!sock)
90725 + goto out;
90726 +
90727 + err = ___sys_recvmsg(sock, msg, &msg_sys, flags, 0);
90728 +
90729 + fput_light(sock->file, fput_needed);
90730 +out:
90731 + return err;
90732 +}
90733 +
90734 SYSCALL_DEFINE3(recvmsg, int, fd, struct msghdr __user *, msg,
90735 unsigned int, flags)
90736 {
90737 - int fput_needed, err;
90738 - struct msghdr msg_sys;
90739 - struct socket *sock = sockfd_lookup_light(fd, &err, &fput_needed);
90740 -
90741 - if (!sock)
90742 - goto out;
90743 -
90744 - err = __sys_recvmsg(sock, msg, &msg_sys, flags, 0);
90745 -
90746 - fput_light(sock->file, fput_needed);
90747 -out:
90748 - return err;
90749 + if (flags & MSG_CMSG_COMPAT)
90750 + return -EINVAL;
90751 + return __sys_recvmsg(fd, msg, flags);
90752 }
90753
90754 /*
90755 @@ -2320,17 +2401,18 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
90756 * No need to ask LSM for more than the first datagram.
90757 */
90758 if (MSG_CMSG_COMPAT & flags) {
90759 - err = __sys_recvmsg(sock, (struct msghdr __user *)compat_entry,
90760 - &msg_sys, flags & ~MSG_WAITFORONE,
90761 - datagrams);
90762 + err = ___sys_recvmsg(sock, (struct msghdr __user *)compat_entry,
90763 + &msg_sys, flags & ~MSG_WAITFORONE,
90764 + datagrams);
90765 if (err < 0)
90766 break;
90767 err = __put_user(err, &compat_entry->msg_len);
90768 ++compat_entry;
90769 } else {
90770 - err = __sys_recvmsg(sock, (struct msghdr __user *)entry,
90771 - &msg_sys, flags & ~MSG_WAITFORONE,
90772 - datagrams);
90773 + err = ___sys_recvmsg(sock,
90774 + (struct msghdr __user *)entry,
90775 + &msg_sys, flags & ~MSG_WAITFORONE,
90776 + datagrams);
90777 if (err < 0)
90778 break;
90779 err = put_user(err, &entry->msg_len);
90780 @@ -2397,6 +2479,9 @@ SYSCALL_DEFINE5(recvmmsg, int, fd, struct mmsghdr __user *, mmsg,
90781 int datagrams;
90782 struct timespec timeout_sys;
90783
90784 + if (flags & MSG_CMSG_COMPAT)
90785 + return -EINVAL;
90786 +
90787 if (!timeout)
90788 return __sys_recvmmsg(fd, mmsg, vlen, flags, NULL);
90789
90790 @@ -2952,7 +3037,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90791 old_fs = get_fs();
90792 set_fs(KERNEL_DS);
90793 err = dev_ioctl(net, cmd,
90794 - (struct ifreq __user __force *) &kifr);
90795 + (struct ifreq __force_user *) &kifr);
90796 set_fs(old_fs);
90797
90798 return err;
90799 @@ -3061,7 +3146,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90800
90801 old_fs = get_fs();
90802 set_fs(KERNEL_DS);
90803 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90804 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90805 set_fs(old_fs);
90806
90807 if (cmd == SIOCGIFMAP && !err) {
90808 @@ -3166,7 +3251,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90809 ret |= __get_user(rtdev, &(ur4->rt_dev));
90810 if (rtdev) {
90811 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90812 - r4.rt_dev = (char __user __force *)devname;
90813 + r4.rt_dev = (char __force_user *)devname;
90814 devname[15] = 0;
90815 } else
90816 r4.rt_dev = NULL;
90817 @@ -3392,8 +3477,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90818 int __user *uoptlen;
90819 int err;
90820
90821 - uoptval = (char __user __force *) optval;
90822 - uoptlen = (int __user __force *) optlen;
90823 + uoptval = (char __force_user *) optval;
90824 + uoptlen = (int __force_user *) optlen;
90825
90826 set_fs(KERNEL_DS);
90827 if (level == SOL_SOCKET)
90828 @@ -3413,7 +3498,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90829 char __user *uoptval;
90830 int err;
90831
90832 - uoptval = (char __user __force *) optval;
90833 + uoptval = (char __force_user *) optval;
90834
90835 set_fs(KERNEL_DS);
90836 if (level == SOL_SOCKET)
90837 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90838 index d5f35f1..da2680b5 100644
90839 --- a/net/sunrpc/clnt.c
90840 +++ b/net/sunrpc/clnt.c
90841 @@ -1283,7 +1283,9 @@ call_start(struct rpc_task *task)
90842 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90843
90844 /* Increment call count */
90845 - task->tk_msg.rpc_proc->p_count++;
90846 + pax_open_kernel();
90847 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90848 + pax_close_kernel();
90849 clnt->cl_stats->rpccnt++;
90850 task->tk_action = call_reserve;
90851 }
90852 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90853 index 5356b12..c0f4c29 100644
90854 --- a/net/sunrpc/sched.c
90855 +++ b/net/sunrpc/sched.c
90856 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90857 #ifdef RPC_DEBUG
90858 static void rpc_task_set_debuginfo(struct rpc_task *task)
90859 {
90860 - static atomic_t rpc_pid;
90861 + static atomic_unchecked_t rpc_pid;
90862
90863 - task->tk_pid = atomic_inc_return(&rpc_pid);
90864 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90865 }
90866 #else
90867 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90868 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90869 index 89a588b..678ed90 100644
90870 --- a/net/sunrpc/svc.c
90871 +++ b/net/sunrpc/svc.c
90872 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
90873
90874 __module_get(serv->sv_module);
90875 task = kthread_create_on_node(serv->sv_function, rqstp,
90876 - node, serv->sv_name);
90877 + node, "%s", serv->sv_name);
90878 if (IS_ERR(task)) {
90879 error = PTR_ERR(task);
90880 module_put(serv->sv_module);
90881 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90882 svc_putnl(resv, RPC_SUCCESS);
90883
90884 /* Bump per-procedure stats counter */
90885 - procp->pc_count++;
90886 + pax_open_kernel();
90887 + (*(unsigned int *)&procp->pc_count)++;
90888 + pax_close_kernel();
90889
90890 /* Initialize storage for argp and resp */
90891 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90892 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90893 index 8343737..677025e 100644
90894 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90895 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90896 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90897 static unsigned int min_max_inline = 4096;
90898 static unsigned int max_max_inline = 65536;
90899
90900 -atomic_t rdma_stat_recv;
90901 -atomic_t rdma_stat_read;
90902 -atomic_t rdma_stat_write;
90903 -atomic_t rdma_stat_sq_starve;
90904 -atomic_t rdma_stat_rq_starve;
90905 -atomic_t rdma_stat_rq_poll;
90906 -atomic_t rdma_stat_rq_prod;
90907 -atomic_t rdma_stat_sq_poll;
90908 -atomic_t rdma_stat_sq_prod;
90909 +atomic_unchecked_t rdma_stat_recv;
90910 +atomic_unchecked_t rdma_stat_read;
90911 +atomic_unchecked_t rdma_stat_write;
90912 +atomic_unchecked_t rdma_stat_sq_starve;
90913 +atomic_unchecked_t rdma_stat_rq_starve;
90914 +atomic_unchecked_t rdma_stat_rq_poll;
90915 +atomic_unchecked_t rdma_stat_rq_prod;
90916 +atomic_unchecked_t rdma_stat_sq_poll;
90917 +atomic_unchecked_t rdma_stat_sq_prod;
90918
90919 /* Temporary NFS request map and context caches */
90920 struct kmem_cache *svc_rdma_map_cachep;
90921 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90922 len -= *ppos;
90923 if (len > *lenp)
90924 len = *lenp;
90925 - if (len && copy_to_user(buffer, str_buf, len))
90926 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90927 return -EFAULT;
90928 *lenp = len;
90929 *ppos += len;
90930 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90931 {
90932 .procname = "rdma_stat_read",
90933 .data = &rdma_stat_read,
90934 - .maxlen = sizeof(atomic_t),
90935 + .maxlen = sizeof(atomic_unchecked_t),
90936 .mode = 0644,
90937 .proc_handler = read_reset_stat,
90938 },
90939 {
90940 .procname = "rdma_stat_recv",
90941 .data = &rdma_stat_recv,
90942 - .maxlen = sizeof(atomic_t),
90943 + .maxlen = sizeof(atomic_unchecked_t),
90944 .mode = 0644,
90945 .proc_handler = read_reset_stat,
90946 },
90947 {
90948 .procname = "rdma_stat_write",
90949 .data = &rdma_stat_write,
90950 - .maxlen = sizeof(atomic_t),
90951 + .maxlen = sizeof(atomic_unchecked_t),
90952 .mode = 0644,
90953 .proc_handler = read_reset_stat,
90954 },
90955 {
90956 .procname = "rdma_stat_sq_starve",
90957 .data = &rdma_stat_sq_starve,
90958 - .maxlen = sizeof(atomic_t),
90959 + .maxlen = sizeof(atomic_unchecked_t),
90960 .mode = 0644,
90961 .proc_handler = read_reset_stat,
90962 },
90963 {
90964 .procname = "rdma_stat_rq_starve",
90965 .data = &rdma_stat_rq_starve,
90966 - .maxlen = sizeof(atomic_t),
90967 + .maxlen = sizeof(atomic_unchecked_t),
90968 .mode = 0644,
90969 .proc_handler = read_reset_stat,
90970 },
90971 {
90972 .procname = "rdma_stat_rq_poll",
90973 .data = &rdma_stat_rq_poll,
90974 - .maxlen = sizeof(atomic_t),
90975 + .maxlen = sizeof(atomic_unchecked_t),
90976 .mode = 0644,
90977 .proc_handler = read_reset_stat,
90978 },
90979 {
90980 .procname = "rdma_stat_rq_prod",
90981 .data = &rdma_stat_rq_prod,
90982 - .maxlen = sizeof(atomic_t),
90983 + .maxlen = sizeof(atomic_unchecked_t),
90984 .mode = 0644,
90985 .proc_handler = read_reset_stat,
90986 },
90987 {
90988 .procname = "rdma_stat_sq_poll",
90989 .data = &rdma_stat_sq_poll,
90990 - .maxlen = sizeof(atomic_t),
90991 + .maxlen = sizeof(atomic_unchecked_t),
90992 .mode = 0644,
90993 .proc_handler = read_reset_stat,
90994 },
90995 {
90996 .procname = "rdma_stat_sq_prod",
90997 .data = &rdma_stat_sq_prod,
90998 - .maxlen = sizeof(atomic_t),
90999 + .maxlen = sizeof(atomic_unchecked_t),
91000 .mode = 0644,
91001 .proc_handler = read_reset_stat,
91002 },
91003 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91004 index 0ce7552..d074459 100644
91005 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91006 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91007 @@ -501,7 +501,7 @@ next_sge:
91008 svc_rdma_put_context(ctxt, 0);
91009 goto out;
91010 }
91011 - atomic_inc(&rdma_stat_read);
91012 + atomic_inc_unchecked(&rdma_stat_read);
91013
91014 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
91015 chl_map->ch[ch_no].count -= read_wr.num_sge;
91016 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91017 dto_q);
91018 list_del_init(&ctxt->dto_q);
91019 } else {
91020 - atomic_inc(&rdma_stat_rq_starve);
91021 + atomic_inc_unchecked(&rdma_stat_rq_starve);
91022 clear_bit(XPT_DATA, &xprt->xpt_flags);
91023 ctxt = NULL;
91024 }
91025 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91026 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
91027 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
91028 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
91029 - atomic_inc(&rdma_stat_recv);
91030 + atomic_inc_unchecked(&rdma_stat_recv);
91031
91032 /* Build up the XDR from the receive buffers. */
91033 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
91034 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91035 index c1d124d..acfc59e 100644
91036 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91037 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91038 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
91039 write_wr.wr.rdma.remote_addr = to;
91040
91041 /* Post It */
91042 - atomic_inc(&rdma_stat_write);
91043 + atomic_inc_unchecked(&rdma_stat_write);
91044 if (svc_rdma_send(xprt, &write_wr))
91045 goto err;
91046 return 0;
91047 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
91048 index 62e4f9b..dd3f2d7 100644
91049 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
91050 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
91051 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
91052 return;
91053
91054 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
91055 - atomic_inc(&rdma_stat_rq_poll);
91056 + atomic_inc_unchecked(&rdma_stat_rq_poll);
91057
91058 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
91059 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
91060 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
91061 }
91062
91063 if (ctxt)
91064 - atomic_inc(&rdma_stat_rq_prod);
91065 + atomic_inc_unchecked(&rdma_stat_rq_prod);
91066
91067 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
91068 /*
91069 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
91070 return;
91071
91072 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
91073 - atomic_inc(&rdma_stat_sq_poll);
91074 + atomic_inc_unchecked(&rdma_stat_sq_poll);
91075 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
91076 if (wc.status != IB_WC_SUCCESS)
91077 /* Close the transport */
91078 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
91079 }
91080
91081 if (ctxt)
91082 - atomic_inc(&rdma_stat_sq_prod);
91083 + atomic_inc_unchecked(&rdma_stat_sq_prod);
91084 }
91085
91086 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
91087 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
91088 spin_lock_bh(&xprt->sc_lock);
91089 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
91090 spin_unlock_bh(&xprt->sc_lock);
91091 - atomic_inc(&rdma_stat_sq_starve);
91092 + atomic_inc_unchecked(&rdma_stat_sq_starve);
91093
91094 /* See if we can opportunistically reap SQ WR to make room */
91095 sq_cq_reap(xprt);
91096 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
91097 index 9bc6db0..47ac8c0 100644
91098 --- a/net/sysctl_net.c
91099 +++ b/net/sysctl_net.c
91100 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
91101 kgid_t root_gid = make_kgid(net->user_ns, 0);
91102
91103 /* Allow network administrator to have same access as root. */
91104 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
91105 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
91106 uid_eq(root_uid, current_uid())) {
91107 int mode = (table->mode >> 6) & 7;
91108 return (mode << 6) | (mode << 3) | mode;
91109 diff --git a/net/tipc/link.c b/net/tipc/link.c
91110 index daa6080..2bbbe70 100644
91111 --- a/net/tipc/link.c
91112 +++ b/net/tipc/link.c
91113 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
91114 struct tipc_msg fragm_hdr;
91115 struct sk_buff *buf, *buf_chain, *prev;
91116 u32 fragm_crs, fragm_rest, hsz, sect_rest;
91117 - const unchar *sect_crs;
91118 + const unchar __user *sect_crs;
91119 int curr_sect;
91120 u32 fragm_no;
91121
91122 @@ -1242,7 +1242,7 @@ again:
91123
91124 if (!sect_rest) {
91125 sect_rest = msg_sect[++curr_sect].iov_len;
91126 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
91127 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
91128 }
91129
91130 if (sect_rest < fragm_rest)
91131 @@ -1261,7 +1261,7 @@ error:
91132 }
91133 } else
91134 skb_copy_to_linear_data_offset(buf, fragm_crs,
91135 - sect_crs, sz);
91136 + (const void __force_kernel *)sect_crs, sz);
91137 sect_crs += sz;
91138 sect_rest -= sz;
91139 fragm_crs += sz;
91140 @@ -2306,8 +2306,11 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
91141 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
91142 u32 msg_typ = msg_type(tunnel_msg);
91143 u32 msg_count = msg_msgcnt(tunnel_msg);
91144 + u32 bearer_id = msg_bearer_id(tunnel_msg);
91145
91146 - dest_link = (*l_ptr)->owner->links[msg_bearer_id(tunnel_msg)];
91147 + if (bearer_id >= MAX_BEARERS)
91148 + goto exit;
91149 + dest_link = (*l_ptr)->owner->links[bearer_id];
91150 if (!dest_link)
91151 goto exit;
91152 if (dest_link == *l_ptr) {
91153 @@ -2521,14 +2524,16 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
91154 struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm);
91155 u32 msg_sz = msg_size(imsg);
91156 u32 fragm_sz = msg_data_sz(fragm);
91157 - u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
91158 + u32 exp_fragm_cnt;
91159 u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE;
91160 +
91161 if (msg_type(imsg) == TIPC_MCAST_MSG)
91162 max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE;
91163 - if (msg_size(imsg) > max) {
91164 + if (fragm_sz == 0 || msg_size(imsg) > max) {
91165 kfree_skb(fbuf);
91166 return 0;
91167 }
91168 + exp_fragm_cnt = msg_sz / fragm_sz + !!(msg_sz % fragm_sz);
91169 pbuf = tipc_buf_acquire(msg_size(imsg));
91170 if (pbuf != NULL) {
91171 pbuf->next = *pending;
91172 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
91173 index f2db8a8..9245aa4 100644
91174 --- a/net/tipc/msg.c
91175 +++ b/net/tipc/msg.c
91176 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
91177 msg_sect[cnt].iov_len);
91178 else
91179 skb_copy_to_linear_data_offset(*buf, pos,
91180 - msg_sect[cnt].iov_base,
91181 + (const void __force_kernel *)msg_sect[cnt].iov_base,
91182 msg_sect[cnt].iov_len);
91183 pos += msg_sect[cnt].iov_len;
91184 }
91185 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
91186 index 6b42d47..2ac24d5 100644
91187 --- a/net/tipc/subscr.c
91188 +++ b/net/tipc/subscr.c
91189 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
91190 {
91191 struct iovec msg_sect;
91192
91193 - msg_sect.iov_base = (void *)&sub->evt;
91194 + msg_sect.iov_base = (void __force_user *)&sub->evt;
91195 msg_sect.iov_len = sizeof(struct tipc_event);
91196
91197 sub->evt.event = htohl(event, sub->swap);
91198 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
91199 index 2db702d..09a77488 100644
91200 --- a/net/unix/af_unix.c
91201 +++ b/net/unix/af_unix.c
91202 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
91203 err = -ECONNREFUSED;
91204 if (!S_ISSOCK(inode->i_mode))
91205 goto put_fail;
91206 +
91207 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
91208 + err = -EACCES;
91209 + goto put_fail;
91210 + }
91211 +
91212 u = unix_find_socket_byinode(inode);
91213 if (!u)
91214 goto put_fail;
91215 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
91216 if (u) {
91217 struct dentry *dentry;
91218 dentry = unix_sk(u)->path.dentry;
91219 +
91220 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
91221 + err = -EPERM;
91222 + sock_put(u);
91223 + goto fail;
91224 + }
91225 +
91226 if (dentry)
91227 touch_atime(&unix_sk(u)->path);
91228 } else
91229 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
91230 */
91231 err = security_path_mknod(&path, dentry, mode, 0);
91232 if (!err) {
91233 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
91234 + err = -EACCES;
91235 + goto out;
91236 + }
91237 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
91238 if (!err) {
91239 res->mnt = mntget(path.mnt);
91240 res->dentry = dget(dentry);
91241 + gr_handle_create(dentry, path.mnt);
91242 }
91243 }
91244 +out:
91245 done_path_create(&path, dentry);
91246 return err;
91247 }
91248 @@ -2323,9 +2342,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91249 seq_puts(seq, "Num RefCount Protocol Flags Type St "
91250 "Inode Path\n");
91251 else {
91252 - struct sock *s = v;
91253 + struct sock *s = v, *peer;
91254 struct unix_sock *u = unix_sk(s);
91255 unix_state_lock(s);
91256 + peer = unix_peer(s);
91257 + unix_state_unlock(s);
91258 +
91259 + unix_state_double_lock(s, peer);
91260
91261 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
91262 s,
91263 @@ -2352,8 +2375,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91264 }
91265 for ( ; i < len; i++)
91266 seq_putc(seq, u->addr->name->sun_path[i]);
91267 - }
91268 - unix_state_unlock(s);
91269 + } else if (peer)
91270 + seq_printf(seq, " P%lu", sock_i_ino(peer));
91271 +
91272 + unix_state_double_unlock(s, peer);
91273 seq_putc(seq, '\n');
91274 }
91275
91276 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
91277 index 8800604..0526440 100644
91278 --- a/net/unix/sysctl_net_unix.c
91279 +++ b/net/unix/sysctl_net_unix.c
91280 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
91281
91282 int __net_init unix_sysctl_register(struct net *net)
91283 {
91284 - struct ctl_table *table;
91285 + ctl_table_no_const *table;
91286
91287 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
91288 if (table == NULL)
91289 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
91290 index c8717c1..08539f5 100644
91291 --- a/net/wireless/wext-core.c
91292 +++ b/net/wireless/wext-core.c
91293 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91294 */
91295
91296 /* Support for very large requests */
91297 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
91298 - (user_length > descr->max_tokens)) {
91299 + if (user_length > descr->max_tokens) {
91300 /* Allow userspace to GET more than max so
91301 * we can support any size GET requests.
91302 * There is still a limit : -ENOMEM.
91303 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91304 }
91305 }
91306
91307 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
91308 - /*
91309 - * If this is a GET, but not NOMAX, it means that the extra
91310 - * data is not bounded by userspace, but by max_tokens. Thus
91311 - * set the length to max_tokens. This matches the extra data
91312 - * allocation.
91313 - * The driver should fill it with the number of tokens it
91314 - * provided, and it may check iwp->length rather than having
91315 - * knowledge of max_tokens. If the driver doesn't change the
91316 - * iwp->length, this ioctl just copies back max_token tokens
91317 - * filled with zeroes. Hopefully the driver isn't claiming
91318 - * them to be valid data.
91319 - */
91320 - iwp->length = descr->max_tokens;
91321 - }
91322 -
91323 err = handler(dev, info, (union iwreq_data *) iwp, extra);
91324
91325 iwp->length += essid_compat;
91326 diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
91327 index bcfda89..0cf003d 100644
91328 --- a/net/xfrm/xfrm_output.c
91329 +++ b/net/xfrm/xfrm_output.c
91330 @@ -64,6 +64,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
91331
91332 if (unlikely(x->km.state != XFRM_STATE_VALID)) {
91333 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEINVALID);
91334 + err = -EINVAL;
91335 goto error;
91336 }
91337
91338 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
91339 index 167c67d..3f2ae427 100644
91340 --- a/net/xfrm/xfrm_policy.c
91341 +++ b/net/xfrm/xfrm_policy.c
91342 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
91343 {
91344 policy->walk.dead = 1;
91345
91346 - atomic_inc(&policy->genid);
91347 + atomic_inc_unchecked(&policy->genid);
91348
91349 del_timer(&policy->polq.hold_timer);
91350 xfrm_queue_purge(&policy->polq.hold_queue);
91351 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
91352 hlist_add_head(&policy->bydst, chain);
91353 xfrm_pol_hold(policy);
91354 net->xfrm.policy_count[dir]++;
91355 - atomic_inc(&flow_cache_genid);
91356 + atomic_inc_unchecked(&flow_cache_genid);
91357 rt_genid_bump(net);
91358 if (delpol) {
91359 xfrm_policy_requeue(delpol, policy);
91360 @@ -1611,7 +1611,7 @@ free_dst:
91361 goto out;
91362 }
91363
91364 -static int inline
91365 +static inline int
91366 xfrm_dst_alloc_copy(void **target, const void *src, int size)
91367 {
91368 if (!*target) {
91369 @@ -1623,7 +1623,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
91370 return 0;
91371 }
91372
91373 -static int inline
91374 +static inline int
91375 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91376 {
91377 #ifdef CONFIG_XFRM_SUB_POLICY
91378 @@ -1635,7 +1635,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91379 #endif
91380 }
91381
91382 -static int inline
91383 +static inline int
91384 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
91385 {
91386 #ifdef CONFIG_XFRM_SUB_POLICY
91387 @@ -1729,7 +1729,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
91388
91389 xdst->num_pols = num_pols;
91390 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
91391 - xdst->policy_genid = atomic_read(&pols[0]->genid);
91392 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
91393
91394 return xdst;
91395 }
91396 @@ -2598,7 +2598,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
91397 if (xdst->xfrm_genid != dst->xfrm->genid)
91398 return 0;
91399 if (xdst->num_pols > 0 &&
91400 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
91401 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
91402 return 0;
91403
91404 mtu = dst_mtu(dst->child);
91405 @@ -2686,8 +2686,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
91406 dst_ops->link_failure = xfrm_link_failure;
91407 if (likely(dst_ops->neigh_lookup == NULL))
91408 dst_ops->neigh_lookup = xfrm_neigh_lookup;
91409 - if (likely(afinfo->garbage_collect == NULL))
91410 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91411 + if (likely(afinfo->garbage_collect == NULL)) {
91412 + pax_open_kernel();
91413 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91414 + pax_close_kernel();
91415 + }
91416 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
91417 }
91418 spin_unlock(&xfrm_policy_afinfo_lock);
91419 @@ -2741,7 +2744,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
91420 dst_ops->check = NULL;
91421 dst_ops->negative_advice = NULL;
91422 dst_ops->link_failure = NULL;
91423 - afinfo->garbage_collect = NULL;
91424 + pax_open_kernel();
91425 + *(void **)&afinfo->garbage_collect = NULL;
91426 + pax_close_kernel();
91427 }
91428 return err;
91429 }
91430 @@ -3124,7 +3129,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
91431 sizeof(pol->xfrm_vec[i].saddr));
91432 pol->xfrm_vec[i].encap_family = mp->new_family;
91433 /* flush bundles */
91434 - atomic_inc(&pol->genid);
91435 + atomic_inc_unchecked(&pol->genid);
91436 }
91437 }
91438
91439 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
91440 index 2c341bd..4404211 100644
91441 --- a/net/xfrm/xfrm_state.c
91442 +++ b/net/xfrm/xfrm_state.c
91443 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
91444
91445 if (unlikely(afinfo == NULL))
91446 return -EAFNOSUPPORT;
91447 - typemap = afinfo->type_map;
91448 + typemap = (const struct xfrm_type **)afinfo->type_map;
91449 spin_lock_bh(&xfrm_type_lock);
91450
91451 - if (likely(typemap[type->proto] == NULL))
91452 + if (likely(typemap[type->proto] == NULL)) {
91453 + pax_open_kernel();
91454 typemap[type->proto] = type;
91455 - else
91456 + pax_close_kernel();
91457 + } else
91458 err = -EEXIST;
91459 spin_unlock_bh(&xfrm_type_lock);
91460 xfrm_state_put_afinfo(afinfo);
91461 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
91462
91463 if (unlikely(afinfo == NULL))
91464 return -EAFNOSUPPORT;
91465 - typemap = afinfo->type_map;
91466 + typemap = (const struct xfrm_type **)afinfo->type_map;
91467 spin_lock_bh(&xfrm_type_lock);
91468
91469 if (unlikely(typemap[type->proto] != type))
91470 err = -ENOENT;
91471 - else
91472 + else {
91473 + pax_open_kernel();
91474 typemap[type->proto] = NULL;
91475 + pax_close_kernel();
91476 + }
91477 spin_unlock_bh(&xfrm_type_lock);
91478 xfrm_state_put_afinfo(afinfo);
91479 return err;
91480 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
91481 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
91482 {
91483 struct xfrm_state_afinfo *afinfo;
91484 - const struct xfrm_type **typemap;
91485 const struct xfrm_type *type;
91486 int modload_attempted = 0;
91487
91488 @@ -222,9 +226,8 @@ retry:
91489 afinfo = xfrm_state_get_afinfo(family);
91490 if (unlikely(afinfo == NULL))
91491 return NULL;
91492 - typemap = afinfo->type_map;
91493
91494 - type = typemap[proto];
91495 + type = afinfo->type_map[proto];
91496 if (unlikely(type && !try_module_get(type->owner)))
91497 type = NULL;
91498 if (!type && !modload_attempted) {
91499 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91500 return -EAFNOSUPPORT;
91501
91502 err = -EEXIST;
91503 - modemap = afinfo->mode_map;
91504 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91505 spin_lock_bh(&xfrm_mode_lock);
91506 if (modemap[mode->encap])
91507 goto out;
91508 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91509 if (!try_module_get(afinfo->owner))
91510 goto out;
91511
91512 - mode->afinfo = afinfo;
91513 + pax_open_kernel();
91514 + *(const void **)&mode->afinfo = afinfo;
91515 modemap[mode->encap] = mode;
91516 + pax_close_kernel();
91517 err = 0;
91518
91519 out:
91520 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
91521 return -EAFNOSUPPORT;
91522
91523 err = -ENOENT;
91524 - modemap = afinfo->mode_map;
91525 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91526 spin_lock_bh(&xfrm_mode_lock);
91527 if (likely(modemap[mode->encap] == mode)) {
91528 + pax_open_kernel();
91529 modemap[mode->encap] = NULL;
91530 + pax_close_kernel();
91531 module_put(mode->afinfo->owner);
91532 err = 0;
91533 }
91534 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
91535 index 05a6e3d..6716ec9 100644
91536 --- a/net/xfrm/xfrm_sysctl.c
91537 +++ b/net/xfrm/xfrm_sysctl.c
91538 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
91539
91540 int __net_init xfrm_sysctl_init(struct net *net)
91541 {
91542 - struct ctl_table *table;
91543 + ctl_table_no_const *table;
91544
91545 __xfrm_sysctl_init(net);
91546
91547 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
91548 index 0e801c3..5c8ad3b 100644
91549 --- a/scripts/Makefile.build
91550 +++ b/scripts/Makefile.build
91551 @@ -111,7 +111,7 @@ endif
91552 endif
91553
91554 # Do not include host rules unless needed
91555 -ifneq ($(hostprogs-y)$(hostprogs-m),)
91556 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
91557 include scripts/Makefile.host
91558 endif
91559
91560 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
91561 index 686cb0d..9d653bf 100644
91562 --- a/scripts/Makefile.clean
91563 +++ b/scripts/Makefile.clean
91564 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91565 __clean-files := $(extra-y) $(always) \
91566 $(targets) $(clean-files) \
91567 $(host-progs) \
91568 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91569 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91570 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91571
91572 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91573
91574 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91575 index 1ac414f..38575f7 100644
91576 --- a/scripts/Makefile.host
91577 +++ b/scripts/Makefile.host
91578 @@ -31,6 +31,8 @@
91579 # Note: Shared libraries consisting of C++ files are not supported
91580
91581 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91582 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91583 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91584
91585 # C code
91586 # Executables compiled from a single .c file
91587 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91588 # Shared libaries (only .c supported)
91589 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91590 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91591 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91592 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91593 # Remove .so files from "xxx-objs"
91594 host-cobjs := $(filter-out %.so,$(host-cobjs))
91595 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91596
91597 -#Object (.o) files used by the shared libaries
91598 +# Object (.o) files used by the shared libaries
91599 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91600 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91601
91602 # output directory for programs/.o files
91603 # hostprogs-y := tools/build may have been specified. Retrieve directory
91604 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91605 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91606 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91607 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91608 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91609 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91610 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91611 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91612
91613 obj-dirs += $(host-objdirs)
91614 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91615 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91616 $(call if_changed_dep,host-cshobjs)
91617
91618 +# Compile .c file, create position independent .o file
91619 +# host-cxxshobjs -> .o
91620 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91621 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91622 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91623 + $(call if_changed_dep,host-cxxshobjs)
91624 +
91625 # Link a shared library, based on position independent .o files
91626 # *.o -> .so shared library (host-cshlib)
91627 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91628 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91629 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91630 $(call if_changed,host-cshlib)
91631
91632 +# Link a shared library, based on position independent .o files
91633 +# *.o -> .so shared library (host-cxxshlib)
91634 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91635 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91636 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91637 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91638 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91639 + $(call if_changed,host-cxxshlib)
91640 +
91641 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91642 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91643 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91644
91645 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91646 index 7f6425e..9864506 100644
91647 --- a/scripts/basic/fixdep.c
91648 +++ b/scripts/basic/fixdep.c
91649 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91650 /*
91651 * Lookup a value in the configuration string.
91652 */
91653 -static int is_defined_config(const char *name, int len, unsigned int hash)
91654 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91655 {
91656 struct item *aux;
91657
91658 @@ -211,10 +211,10 @@ static void clear_config(void)
91659 /*
91660 * Record the use of a CONFIG_* word.
91661 */
91662 -static void use_config(const char *m, int slen)
91663 +static void use_config(const char *m, unsigned int slen)
91664 {
91665 unsigned int hash = strhash(m, slen);
91666 - int c, i;
91667 + unsigned int c, i;
91668
91669 if (is_defined_config(m, slen, hash))
91670 return;
91671 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91672
91673 static void parse_config_file(const char *map, size_t len)
91674 {
91675 - const int *end = (const int *) (map + len);
91676 + const unsigned int *end = (const unsigned int *) (map + len);
91677 /* start at +1, so that p can never be < map */
91678 - const int *m = (const int *) map + 1;
91679 + const unsigned int *m = (const unsigned int *) map + 1;
91680 const char *p, *q;
91681
91682 for (; m < end; m++) {
91683 @@ -406,7 +406,7 @@ static void print_deps(void)
91684 static void traps(void)
91685 {
91686 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91687 - int *p = (int *)test;
91688 + unsigned int *p = (unsigned int *)test;
91689
91690 if (*p != INT_CONF) {
91691 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
91692 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91693 new file mode 100644
91694 index 0000000..5e0222d
91695 --- /dev/null
91696 +++ b/scripts/gcc-plugin.sh
91697 @@ -0,0 +1,17 @@
91698 +#!/bin/bash
91699 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91700 +#include "gcc-plugin.h"
91701 +#include "tree.h"
91702 +#include "tm.h"
91703 +#include "rtl.h"
91704 +#ifdef ENABLE_BUILD_WITH_CXX
91705 +#warning $2
91706 +#else
91707 +#warning $1
91708 +#endif
91709 +EOF`
91710 +if [ $? -eq 0 ]
91711 +then
91712 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91713 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91714 +fi
91715 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91716 index 581ca99..a6ff02e 100644
91717 --- a/scripts/headers_install.pl
91718 +++ b/scripts/headers_install.pl
91719 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91720 $line =~ s/([\s(])__user\s/$1/g;
91721 $line =~ s/([\s(])__force\s/$1/g;
91722 $line =~ s/([\s(])__iomem\s/$1/g;
91723 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91724 $line =~ s/\s__attribute_const__\s/ /g;
91725 $line =~ s/\s__attribute_const__$//g;
91726 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91727 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91728 index 3d569d6..0c09522 100644
91729 --- a/scripts/link-vmlinux.sh
91730 +++ b/scripts/link-vmlinux.sh
91731 @@ -159,7 +159,7 @@ else
91732 fi;
91733
91734 # final build of init/
91735 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91736 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91737
91738 kallsymso=""
91739 kallsyms_vmlinux=""
91740 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91741 index 771ac17..9f0d3ee 100644
91742 --- a/scripts/mod/file2alias.c
91743 +++ b/scripts/mod/file2alias.c
91744 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
91745 unsigned long size, unsigned long id_size,
91746 void *symval)
91747 {
91748 - int i;
91749 + unsigned int i;
91750
91751 if (size % id_size || size < id_size) {
91752 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
91753 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
91754 /* USB is special because the bcdDevice can be matched against a numeric range */
91755 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91756 static void do_usb_entry(void *symval,
91757 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91758 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91759 unsigned char range_lo, unsigned char range_hi,
91760 unsigned char max, struct module *mod)
91761 {
91762 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
91763 {
91764 unsigned int devlo, devhi;
91765 unsigned char chi, clo, max;
91766 - int ndigits;
91767 + unsigned int ndigits;
91768
91769 DEF_FIELD(symval, usb_device_id, match_flags);
91770 DEF_FIELD(symval, usb_device_id, idVendor);
91771 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91772 for (i = 0; i < count; i++) {
91773 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
91774 char acpi_id[sizeof(*id)];
91775 - int j;
91776 + unsigned int j;
91777
91778 buf_printf(&mod->dev_table_buf,
91779 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
91780 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91781
91782 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91783 const char *id = (char *)(*devs)[j].id;
91784 - int i2, j2;
91785 + unsigned int i2, j2;
91786 int dup = 0;
91787
91788 if (!id[0])
91789 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91790 /* add an individual alias for every device entry */
91791 if (!dup) {
91792 char acpi_id[PNP_ID_LEN];
91793 - int k;
91794 + unsigned int k;
91795
91796 buf_printf(&mod->dev_table_buf,
91797 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91798 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91799 static int do_dmi_entry(const char *filename, void *symval,
91800 char *alias)
91801 {
91802 - int i, j;
91803 + unsigned int i, j;
91804 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
91805 sprintf(alias, "dmi*");
91806
91807 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91808 index 78b30c1..536850d 100644
91809 --- a/scripts/mod/modpost.c
91810 +++ b/scripts/mod/modpost.c
91811 @@ -931,6 +931,7 @@ enum mismatch {
91812 ANY_INIT_TO_ANY_EXIT,
91813 ANY_EXIT_TO_ANY_INIT,
91814 EXPORT_TO_INIT_EXIT,
91815 + DATA_TO_TEXT
91816 };
91817
91818 struct sectioncheck {
91819 @@ -1045,6 +1046,12 @@ const struct sectioncheck sectioncheck[] = {
91820 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91821 .mismatch = EXPORT_TO_INIT_EXIT,
91822 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91823 +},
91824 +/* Do not reference code from writable data */
91825 +{
91826 + .fromsec = { DATA_SECTIONS, NULL },
91827 + .tosec = { TEXT_SECTIONS, NULL },
91828 + .mismatch = DATA_TO_TEXT
91829 }
91830 };
91831
91832 @@ -1167,10 +1174,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91833 continue;
91834 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91835 continue;
91836 - if (sym->st_value == addr)
91837 - return sym;
91838 /* Find a symbol nearby - addr are maybe negative */
91839 d = sym->st_value - addr;
91840 + if (d == 0)
91841 + return sym;
91842 if (d < 0)
91843 d = addr - sym->st_value;
91844 if (d < distance) {
91845 @@ -1449,6 +1456,14 @@ static void report_sec_mismatch(const char *modname,
91846 tosym, prl_to, prl_to, tosym);
91847 free(prl_to);
91848 break;
91849 + case DATA_TO_TEXT:
91850 +#if 0
91851 + fprintf(stderr,
91852 + "The %s %s:%s references\n"
91853 + "the %s %s:%s%s\n",
91854 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91855 +#endif
91856 + break;
91857 }
91858 fprintf(stderr, "\n");
91859 }
91860 @@ -1683,7 +1698,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91861 static void check_sec_ref(struct module *mod, const char *modname,
91862 struct elf_info *elf)
91863 {
91864 - int i;
91865 + unsigned int i;
91866 Elf_Shdr *sechdrs = elf->sechdrs;
91867
91868 /* Walk through all sections */
91869 @@ -1781,7 +1796,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91870 va_end(ap);
91871 }
91872
91873 -void buf_write(struct buffer *buf, const char *s, int len)
91874 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91875 {
91876 if (buf->size - buf->pos < len) {
91877 buf->size += len + SZ;
91878 @@ -1999,7 +2014,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91879 if (fstat(fileno(file), &st) < 0)
91880 goto close_write;
91881
91882 - if (st.st_size != b->pos)
91883 + if (st.st_size != (off_t)b->pos)
91884 goto close_write;
91885
91886 tmp = NOFAIL(malloc(b->pos));
91887 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91888 index 51207e4..f7d603d 100644
91889 --- a/scripts/mod/modpost.h
91890 +++ b/scripts/mod/modpost.h
91891 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91892
91893 struct buffer {
91894 char *p;
91895 - int pos;
91896 - int size;
91897 + unsigned int pos;
91898 + unsigned int size;
91899 };
91900
91901 void __attribute__((format(printf, 2, 3)))
91902 buf_printf(struct buffer *buf, const char *fmt, ...);
91903
91904 void
91905 -buf_write(struct buffer *buf, const char *s, int len);
91906 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91907
91908 struct module {
91909 struct module *next;
91910 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91911 index 9dfcd6d..099068e 100644
91912 --- a/scripts/mod/sumversion.c
91913 +++ b/scripts/mod/sumversion.c
91914 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91915 goto out;
91916 }
91917
91918 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91919 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91920 warn("writing sum in %s failed: %s\n",
91921 filename, strerror(errno));
91922 goto out;
91923 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91924 index acb8650..b8c5f02 100644
91925 --- a/scripts/package/builddeb
91926 +++ b/scripts/package/builddeb
91927 @@ -246,6 +246,7 @@ fi
91928 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91929 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91930 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91931 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91932 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91933 mkdir -p "$destdir"
91934 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91935 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91936 index 68bb4ef..2f419e1 100644
91937 --- a/scripts/pnmtologo.c
91938 +++ b/scripts/pnmtologo.c
91939 @@ -244,14 +244,14 @@ static void write_header(void)
91940 fprintf(out, " * Linux logo %s\n", logoname);
91941 fputs(" */\n\n", out);
91942 fputs("#include <linux/linux_logo.h>\n\n", out);
91943 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91944 + fprintf(out, "static unsigned char %s_data[] = {\n",
91945 logoname);
91946 }
91947
91948 static void write_footer(void)
91949 {
91950 fputs("\n};\n\n", out);
91951 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91952 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91953 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91954 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91955 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91956 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91957 fputs("\n};\n\n", out);
91958
91959 /* write logo clut */
91960 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91961 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91962 logoname);
91963 write_hex_cnt = 0;
91964 for (i = 0; i < logo_clutsize; i++) {
91965 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91966 index f5eb43d..1814de8 100644
91967 --- a/scripts/sortextable.h
91968 +++ b/scripts/sortextable.h
91969 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91970 const char *secstrtab;
91971 const char *strtab;
91972 char *extab_image;
91973 - int extab_index = 0;
91974 - int i;
91975 - int idx;
91976 + unsigned int extab_index = 0;
91977 + unsigned int i;
91978 + unsigned int idx;
91979
91980 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91981 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91982 diff --git a/security/Kconfig b/security/Kconfig
91983 index e9c6ac7..66bf8e9 100644
91984 --- a/security/Kconfig
91985 +++ b/security/Kconfig
91986 @@ -4,6 +4,945 @@
91987
91988 menu "Security options"
91989
91990 +menu "Grsecurity"
91991 +
91992 + config ARCH_TRACK_EXEC_LIMIT
91993 + bool
91994 +
91995 + config PAX_KERNEXEC_PLUGIN
91996 + bool
91997 +
91998 + config PAX_PER_CPU_PGD
91999 + bool
92000 +
92001 + config TASK_SIZE_MAX_SHIFT
92002 + int
92003 + depends on X86_64
92004 + default 47 if !PAX_PER_CPU_PGD
92005 + default 42 if PAX_PER_CPU_PGD
92006 +
92007 + config PAX_ENABLE_PAE
92008 + bool
92009 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
92010 +
92011 + config PAX_USERCOPY_SLABS
92012 + bool
92013 +
92014 +config GRKERNSEC
92015 + bool "Grsecurity"
92016 + select CRYPTO
92017 + select CRYPTO_SHA256
92018 + select PROC_FS
92019 + select STOP_MACHINE
92020 + select TTY
92021 + help
92022 + If you say Y here, you will be able to configure many features
92023 + that will enhance the security of your system. It is highly
92024 + recommended that you say Y here and read through the help
92025 + for each option so that you fully understand the features and
92026 + can evaluate their usefulness for your machine.
92027 +
92028 +choice
92029 + prompt "Configuration Method"
92030 + depends on GRKERNSEC
92031 + default GRKERNSEC_CONFIG_CUSTOM
92032 + help
92033 +
92034 +config GRKERNSEC_CONFIG_AUTO
92035 + bool "Automatic"
92036 + help
92037 + If you choose this configuration method, you'll be able to answer a small
92038 + number of simple questions about how you plan to use this kernel.
92039 + The settings of grsecurity and PaX will be automatically configured for
92040 + the highest commonly-used settings within the provided constraints.
92041 +
92042 + If you require additional configuration, custom changes can still be made
92043 + from the "custom configuration" menu.
92044 +
92045 +config GRKERNSEC_CONFIG_CUSTOM
92046 + bool "Custom"
92047 + help
92048 + If you choose this configuration method, you'll be able to configure all
92049 + grsecurity and PaX settings manually. Via this method, no options are
92050 + automatically enabled.
92051 +
92052 +endchoice
92053 +
92054 +choice
92055 + prompt "Usage Type"
92056 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92057 + default GRKERNSEC_CONFIG_SERVER
92058 + help
92059 +
92060 +config GRKERNSEC_CONFIG_SERVER
92061 + bool "Server"
92062 + help
92063 + Choose this option if you plan to use this kernel on a server.
92064 +
92065 +config GRKERNSEC_CONFIG_DESKTOP
92066 + bool "Desktop"
92067 + help
92068 + Choose this option if you plan to use this kernel on a desktop.
92069 +
92070 +endchoice
92071 +
92072 +choice
92073 + prompt "Virtualization Type"
92074 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
92075 + default GRKERNSEC_CONFIG_VIRT_NONE
92076 + help
92077 +
92078 +config GRKERNSEC_CONFIG_VIRT_NONE
92079 + bool "None"
92080 + help
92081 + Choose this option if this kernel will be run on bare metal.
92082 +
92083 +config GRKERNSEC_CONFIG_VIRT_GUEST
92084 + bool "Guest"
92085 + help
92086 + Choose this option if this kernel will be run as a VM guest.
92087 +
92088 +config GRKERNSEC_CONFIG_VIRT_HOST
92089 + bool "Host"
92090 + help
92091 + Choose this option if this kernel will be run as a VM host.
92092 +
92093 +endchoice
92094 +
92095 +choice
92096 + prompt "Virtualization Hardware"
92097 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
92098 + help
92099 +
92100 +config GRKERNSEC_CONFIG_VIRT_EPT
92101 + bool "EPT/RVI Processor Support"
92102 + depends on X86
92103 + help
92104 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
92105 + hardware virtualization. This allows for additional kernel hardening protections
92106 + to operate without additional performance impact.
92107 +
92108 + To see if your Intel processor supports EPT, see:
92109 + http://ark.intel.com/Products/VirtualizationTechnology
92110 + (Most Core i3/5/7 support EPT)
92111 +
92112 + To see if your AMD processor supports RVI, see:
92113 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
92114 +
92115 +config GRKERNSEC_CONFIG_VIRT_SOFT
92116 + bool "First-gen/No Hardware Virtualization"
92117 + help
92118 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
92119 + support hardware virtualization or doesn't support the EPT/RVI extensions.
92120 +
92121 +endchoice
92122 +
92123 +choice
92124 + prompt "Virtualization Software"
92125 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
92126 + help
92127 +
92128 +config GRKERNSEC_CONFIG_VIRT_XEN
92129 + bool "Xen"
92130 + help
92131 + Choose this option if this kernel is running as a Xen guest or host.
92132 +
92133 +config GRKERNSEC_CONFIG_VIRT_VMWARE
92134 + bool "VMWare"
92135 + help
92136 + Choose this option if this kernel is running as a VMWare guest or host.
92137 +
92138 +config GRKERNSEC_CONFIG_VIRT_KVM
92139 + bool "KVM"
92140 + help
92141 + Choose this option if this kernel is running as a KVM guest or host.
92142 +
92143 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
92144 + bool "VirtualBox"
92145 + help
92146 + Choose this option if this kernel is running as a VirtualBox guest or host.
92147 +
92148 +endchoice
92149 +
92150 +choice
92151 + prompt "Required Priorities"
92152 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92153 + default GRKERNSEC_CONFIG_PRIORITY_PERF
92154 + help
92155 +
92156 +config GRKERNSEC_CONFIG_PRIORITY_PERF
92157 + bool "Performance"
92158 + help
92159 + Choose this option if performance is of highest priority for this deployment
92160 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
92161 + clearing of structures intended for userland, and freed memory sanitizing will
92162 + be disabled.
92163 +
92164 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
92165 + bool "Security"
92166 + help
92167 + Choose this option if security is of highest priority for this deployment of
92168 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
92169 + for userland, and freed memory sanitizing will be enabled for this kernel.
92170 + In a worst-case scenario, these features can introduce a 20% performance hit
92171 + (UDEREF on x64 contributing half of this hit).
92172 +
92173 +endchoice
92174 +
92175 +menu "Default Special Groups"
92176 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92177 +
92178 +config GRKERNSEC_PROC_GID
92179 + int "GID exempted from /proc restrictions"
92180 + default 1001
92181 + help
92182 + Setting this GID determines which group will be exempted from
92183 + grsecurity's /proc restrictions, allowing users of the specified
92184 + group to view network statistics and the existence of other users'
92185 + processes on the system. This GID may also be chosen at boot time
92186 + via "grsec_proc_gid=" on the kernel commandline.
92187 +
92188 +config GRKERNSEC_TPE_UNTRUSTED_GID
92189 + int "GID for TPE-untrusted users"
92190 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
92191 + default 1005
92192 + help
92193 + Setting this GID determines which group untrusted users should
92194 + be added to. These users will be placed under grsecurity's Trusted Path
92195 + Execution mechanism, preventing them from executing their own binaries.
92196 + The users will only be able to execute binaries in directories owned and
92197 + writable only by the root user. If the sysctl option is enabled, a sysctl
92198 + option with name "tpe_gid" is created.
92199 +
92200 +config GRKERNSEC_TPE_TRUSTED_GID
92201 + int "GID for TPE-trusted users"
92202 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
92203 + default 1005
92204 + help
92205 + Setting this GID determines what group TPE restrictions will be
92206 + *disabled* for. If the sysctl option is enabled, a sysctl option
92207 + with name "tpe_gid" is created.
92208 +
92209 +config GRKERNSEC_SYMLINKOWN_GID
92210 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
92211 + depends on GRKERNSEC_CONFIG_SERVER
92212 + default 1006
92213 + help
92214 + Setting this GID determines what group kernel-enforced
92215 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
92216 + is enabled, a sysctl option with name "symlinkown_gid" is created.
92217 +
92218 +
92219 +endmenu
92220 +
92221 +menu "Customize Configuration"
92222 +depends on GRKERNSEC
92223 +
92224 +menu "PaX"
92225 +
92226 +config PAX
92227 + bool "Enable various PaX features"
92228 + default y if GRKERNSEC_CONFIG_AUTO
92229 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
92230 + help
92231 + This allows you to enable various PaX features. PaX adds
92232 + intrusion prevention mechanisms to the kernel that reduce
92233 + the risks posed by exploitable memory corruption bugs.
92234 +
92235 +menu "PaX Control"
92236 + depends on PAX
92237 +
92238 +config PAX_SOFTMODE
92239 + bool 'Support soft mode'
92240 + help
92241 + Enabling this option will allow you to run PaX in soft mode, that
92242 + is, PaX features will not be enforced by default, only on executables
92243 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
92244 + support as they are the only way to mark executables for soft mode use.
92245 +
92246 + Soft mode can be activated by using the "pax_softmode=1" kernel command
92247 + line option on boot. Furthermore you can control various PaX features
92248 + at runtime via the entries in /proc/sys/kernel/pax.
92249 +
92250 +config PAX_EI_PAX
92251 + bool 'Use legacy ELF header marking'
92252 + default y if GRKERNSEC_CONFIG_AUTO
92253 + help
92254 + Enabling this option will allow you to control PaX features on
92255 + a per executable basis via the 'chpax' utility available at
92256 + http://pax.grsecurity.net/. The control flags will be read from
92257 + an otherwise reserved part of the ELF header. This marking has
92258 + numerous drawbacks (no support for soft-mode, toolchain does not
92259 + know about the non-standard use of the ELF header) therefore it
92260 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
92261 + support.
92262 +
92263 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
92264 + support as well, they will override the legacy EI_PAX marks.
92265 +
92266 + If you enable none of the marking options then all applications
92267 + will run with PaX enabled on them by default.
92268 +
92269 +config PAX_PT_PAX_FLAGS
92270 + bool 'Use ELF program header marking'
92271 + default y if GRKERNSEC_CONFIG_AUTO
92272 + help
92273 + Enabling this option will allow you to control PaX features on
92274 + a per executable basis via the 'paxctl' utility available at
92275 + http://pax.grsecurity.net/. The control flags will be read from
92276 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
92277 + has the benefits of supporting both soft mode and being fully
92278 + integrated into the toolchain (the binutils patch is available
92279 + from http://pax.grsecurity.net).
92280 +
92281 + Note that if you enable the legacy EI_PAX marking support as well,
92282 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
92283 +
92284 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92285 + must make sure that the marks are the same if a binary has both marks.
92286 +
92287 + If you enable none of the marking options then all applications
92288 + will run with PaX enabled on them by default.
92289 +
92290 +config PAX_XATTR_PAX_FLAGS
92291 + bool 'Use filesystem extended attributes marking'
92292 + default y if GRKERNSEC_CONFIG_AUTO
92293 + select CIFS_XATTR if CIFS
92294 + select EXT2_FS_XATTR if EXT2_FS
92295 + select EXT3_FS_XATTR if EXT3_FS
92296 + select EXT4_FS_XATTR if EXT4_FS
92297 + select JFFS2_FS_XATTR if JFFS2_FS
92298 + select REISERFS_FS_XATTR if REISERFS_FS
92299 + select SQUASHFS_XATTR if SQUASHFS
92300 + select TMPFS_XATTR if TMPFS
92301 + select UBIFS_FS_XATTR if UBIFS_FS
92302 + help
92303 + Enabling this option will allow you to control PaX features on
92304 + a per executable basis via the 'setfattr' utility. The control
92305 + flags will be read from the user.pax.flags extended attribute of
92306 + the file. This marking has the benefit of supporting binary-only
92307 + applications that self-check themselves (e.g., skype) and would
92308 + not tolerate chpax/paxctl changes. The main drawback is that
92309 + extended attributes are not supported by some filesystems (e.g.,
92310 + isofs, udf, vfat) so copying files through such filesystems will
92311 + lose the extended attributes and these PaX markings.
92312 +
92313 + Note that if you enable the legacy EI_PAX marking support as well,
92314 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
92315 +
92316 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92317 + must make sure that the marks are the same if a binary has both marks.
92318 +
92319 + If you enable none of the marking options then all applications
92320 + will run with PaX enabled on them by default.
92321 +
92322 +choice
92323 + prompt 'MAC system integration'
92324 + default PAX_HAVE_ACL_FLAGS
92325 + help
92326 + Mandatory Access Control systems have the option of controlling
92327 + PaX flags on a per executable basis, choose the method supported
92328 + by your particular system.
92329 +
92330 + - "none": if your MAC system does not interact with PaX,
92331 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
92332 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
92333 +
92334 + NOTE: this option is for developers/integrators only.
92335 +
92336 + config PAX_NO_ACL_FLAGS
92337 + bool 'none'
92338 +
92339 + config PAX_HAVE_ACL_FLAGS
92340 + bool 'direct'
92341 +
92342 + config PAX_HOOK_ACL_FLAGS
92343 + bool 'hook'
92344 +endchoice
92345 +
92346 +endmenu
92347 +
92348 +menu "Non-executable pages"
92349 + depends on PAX
92350 +
92351 +config PAX_NOEXEC
92352 + bool "Enforce non-executable pages"
92353 + default y if GRKERNSEC_CONFIG_AUTO
92354 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
92355 + help
92356 + By design some architectures do not allow for protecting memory
92357 + pages against execution or even if they do, Linux does not make
92358 + use of this feature. In practice this means that if a page is
92359 + readable (such as the stack or heap) it is also executable.
92360 +
92361 + There is a well known exploit technique that makes use of this
92362 + fact and a common programming mistake where an attacker can
92363 + introduce code of his choice somewhere in the attacked program's
92364 + memory (typically the stack or the heap) and then execute it.
92365 +
92366 + If the attacked program was running with different (typically
92367 + higher) privileges than that of the attacker, then he can elevate
92368 + his own privilege level (e.g. get a root shell, write to files for
92369 + which he does not have write access to, etc).
92370 +
92371 + Enabling this option will let you choose from various features
92372 + that prevent the injection and execution of 'foreign' code in
92373 + a program.
92374 +
92375 + This will also break programs that rely on the old behaviour and
92376 + expect that dynamically allocated memory via the malloc() family
92377 + of functions is executable (which it is not). Notable examples
92378 + are the XFree86 4.x server, the java runtime and wine.
92379 +
92380 +config PAX_PAGEEXEC
92381 + bool "Paging based non-executable pages"
92382 + default y if GRKERNSEC_CONFIG_AUTO
92383 + 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)
92384 + select S390_SWITCH_AMODE if S390
92385 + select S390_EXEC_PROTECT if S390
92386 + select ARCH_TRACK_EXEC_LIMIT if X86_32
92387 + help
92388 + This implementation is based on the paging feature of the CPU.
92389 + On i386 without hardware non-executable bit support there is a
92390 + variable but usually low performance impact, however on Intel's
92391 + P4 core based CPUs it is very high so you should not enable this
92392 + for kernels meant to be used on such CPUs.
92393 +
92394 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
92395 + with hardware non-executable bit support there is no performance
92396 + impact, on ppc the impact is negligible.
92397 +
92398 + Note that several architectures require various emulations due to
92399 + badly designed userland ABIs, this will cause a performance impact
92400 + but will disappear as soon as userland is fixed. For example, ppc
92401 + userland MUST have been built with secure-plt by a recent toolchain.
92402 +
92403 +config PAX_SEGMEXEC
92404 + bool "Segmentation based non-executable pages"
92405 + default y if GRKERNSEC_CONFIG_AUTO
92406 + depends on PAX_NOEXEC && X86_32
92407 + help
92408 + This implementation is based on the segmentation feature of the
92409 + CPU and has a very small performance impact, however applications
92410 + will be limited to a 1.5 GB address space instead of the normal
92411 + 3 GB.
92412 +
92413 +config PAX_EMUTRAMP
92414 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
92415 + default y if PARISC
92416 + help
92417 + There are some programs and libraries that for one reason or
92418 + another attempt to execute special small code snippets from
92419 + non-executable memory pages. Most notable examples are the
92420 + signal handler return code generated by the kernel itself and
92421 + the GCC trampolines.
92422 +
92423 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
92424 + such programs will no longer work under your kernel.
92425 +
92426 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
92427 + utilities to enable trampoline emulation for the affected programs
92428 + yet still have the protection provided by the non-executable pages.
92429 +
92430 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
92431 + your system will not even boot.
92432 +
92433 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
92434 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
92435 + for the affected files.
92436 +
92437 + NOTE: enabling this feature *may* open up a loophole in the
92438 + protection provided by non-executable pages that an attacker
92439 + could abuse. Therefore the best solution is to not have any
92440 + files on your system that would require this option. This can
92441 + be achieved by not using libc5 (which relies on the kernel
92442 + signal handler return code) and not using or rewriting programs
92443 + that make use of the nested function implementation of GCC.
92444 + Skilled users can just fix GCC itself so that it implements
92445 + nested function calls in a way that does not interfere with PaX.
92446 +
92447 +config PAX_EMUSIGRT
92448 + bool "Automatically emulate sigreturn trampolines"
92449 + depends on PAX_EMUTRAMP && PARISC
92450 + default y
92451 + help
92452 + Enabling this option will have the kernel automatically detect
92453 + and emulate signal return trampolines executing on the stack
92454 + that would otherwise lead to task termination.
92455 +
92456 + This solution is intended as a temporary one for users with
92457 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
92458 + Modula-3 runtime, etc) or executables linked to such, basically
92459 + everything that does not specify its own SA_RESTORER function in
92460 + normal executable memory like glibc 2.1+ does.
92461 +
92462 + On parisc you MUST enable this option, otherwise your system will
92463 + not even boot.
92464 +
92465 + NOTE: this feature cannot be disabled on a per executable basis
92466 + and since it *does* open up a loophole in the protection provided
92467 + by non-executable pages, the best solution is to not have any
92468 + files on your system that would require this option.
92469 +
92470 +config PAX_MPROTECT
92471 + bool "Restrict mprotect()"
92472 + default y if GRKERNSEC_CONFIG_AUTO
92473 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
92474 + help
92475 + Enabling this option will prevent programs from
92476 + - changing the executable status of memory pages that were
92477 + not originally created as executable,
92478 + - making read-only executable pages writable again,
92479 + - creating executable pages from anonymous memory,
92480 + - making read-only-after-relocations (RELRO) data pages writable again.
92481 +
92482 + You should say Y here to complete the protection provided by
92483 + the enforcement of non-executable pages.
92484 +
92485 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92486 + this feature on a per file basis.
92487 +
92488 +config PAX_MPROTECT_COMPAT
92489 + bool "Use legacy/compat protection demoting (read help)"
92490 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92491 + depends on PAX_MPROTECT
92492 + help
92493 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
92494 + by sending the proper error code to the application. For some broken
92495 + userland, this can cause problems with Python or other applications. The
92496 + current implementation however allows for applications like clamav to
92497 + detect if JIT compilation/execution is allowed and to fall back gracefully
92498 + to an interpreter-based mode if it does not. While we encourage everyone
92499 + to use the current implementation as-is and push upstream to fix broken
92500 + userland (note that the RWX logging option can assist with this), in some
92501 + environments this may not be possible. Having to disable MPROTECT
92502 + completely on certain binaries reduces the security benefit of PaX,
92503 + so this option is provided for those environments to revert to the old
92504 + behavior.
92505 +
92506 +config PAX_ELFRELOCS
92507 + bool "Allow ELF text relocations (read help)"
92508 + depends on PAX_MPROTECT
92509 + default n
92510 + help
92511 + Non-executable pages and mprotect() restrictions are effective
92512 + in preventing the introduction of new executable code into an
92513 + attacked task's address space. There remain only two venues
92514 + for this kind of attack: if the attacker can execute already
92515 + existing code in the attacked task then he can either have it
92516 + create and mmap() a file containing his code or have it mmap()
92517 + an already existing ELF library that does not have position
92518 + independent code in it and use mprotect() on it to make it
92519 + writable and copy his code there. While protecting against
92520 + the former approach is beyond PaX, the latter can be prevented
92521 + by having only PIC ELF libraries on one's system (which do not
92522 + need to relocate their code). If you are sure this is your case,
92523 + as is the case with all modern Linux distributions, then leave
92524 + this option disabled. You should say 'n' here.
92525 +
92526 +config PAX_ETEXECRELOCS
92527 + bool "Allow ELF ET_EXEC text relocations"
92528 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
92529 + select PAX_ELFRELOCS
92530 + default y
92531 + help
92532 + On some architectures there are incorrectly created applications
92533 + that require text relocations and would not work without enabling
92534 + this option. If you are an alpha, ia64 or parisc user, you should
92535 + enable this option and disable it once you have made sure that
92536 + none of your applications need it.
92537 +
92538 +config PAX_EMUPLT
92539 + bool "Automatically emulate ELF PLT"
92540 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
92541 + default y
92542 + help
92543 + Enabling this option will have the kernel automatically detect
92544 + and emulate the Procedure Linkage Table entries in ELF files.
92545 + On some architectures such entries are in writable memory, and
92546 + become non-executable leading to task termination. Therefore
92547 + it is mandatory that you enable this option on alpha, parisc,
92548 + sparc and sparc64, otherwise your system would not even boot.
92549 +
92550 + NOTE: this feature *does* open up a loophole in the protection
92551 + provided by the non-executable pages, therefore the proper
92552 + solution is to modify the toolchain to produce a PLT that does
92553 + not need to be writable.
92554 +
92555 +config PAX_DLRESOLVE
92556 + bool 'Emulate old glibc resolver stub'
92557 + depends on PAX_EMUPLT && SPARC
92558 + default n
92559 + help
92560 + This option is needed if userland has an old glibc (before 2.4)
92561 + that puts a 'save' instruction into the runtime generated resolver
92562 + stub that needs special emulation.
92563 +
92564 +config PAX_KERNEXEC
92565 + bool "Enforce non-executable kernel pages"
92566 + 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))
92567 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92568 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92569 + select PAX_KERNEXEC_PLUGIN if X86_64
92570 + help
92571 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92572 + that is, enabling this option will make it harder to inject
92573 + and execute 'foreign' code in kernel memory itself.
92574 +
92575 +choice
92576 + prompt "Return Address Instrumentation Method"
92577 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92578 + depends on PAX_KERNEXEC_PLUGIN
92579 + help
92580 + Select the method used to instrument function pointer dereferences.
92581 + Note that binary modules cannot be instrumented by this approach.
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 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92588 + bool "bts"
92589 + help
92590 + This method is compatible with binary only modules but has
92591 + a higher runtime overhead.
92592 +
92593 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92594 + bool "or"
92595 + depends on !PARAVIRT
92596 + help
92597 + This method is incompatible with binary only modules but has
92598 + a lower runtime overhead.
92599 +endchoice
92600 +
92601 +config PAX_KERNEXEC_PLUGIN_METHOD
92602 + string
92603 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92604 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92605 + default ""
92606 +
92607 +config PAX_KERNEXEC_MODULE_TEXT
92608 + int "Minimum amount of memory reserved for module code"
92609 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92610 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92611 + depends on PAX_KERNEXEC && X86_32
92612 + help
92613 + Due to implementation details the kernel must reserve a fixed
92614 + amount of memory for runtime allocated code (such as modules)
92615 + at compile time that cannot be changed at runtime. Here you
92616 + can specify the minimum amount in MB that will be reserved.
92617 + Due to the same implementation details this size will always
92618 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
92619 + the actually available memory for runtime allocated code will
92620 + usually be more than this minimum.
92621 +
92622 + The default 4 MB should be enough for most users but if you have
92623 + an excessive number of modules (e.g., most distribution configs
92624 + compile many drivers as modules) or use huge modules such as
92625 + nvidia's kernel driver, you will need to adjust this amount.
92626 + A good rule of thumb is to look at your currently loaded kernel
92627 + modules and add up their sizes.
92628 +
92629 +endmenu
92630 +
92631 +menu "Address Space Layout Randomization"
92632 + depends on PAX
92633 +
92634 +config PAX_ASLR
92635 + bool "Address Space Layout Randomization"
92636 + default y if GRKERNSEC_CONFIG_AUTO
92637 + help
92638 + Many if not most exploit techniques rely on the knowledge of
92639 + certain addresses in the attacked program. The following options
92640 + will allow the kernel to apply a certain amount of randomization
92641 + to specific parts of the program thereby forcing an attacker to
92642 + guess them in most cases. Any failed guess will most likely crash
92643 + the attacked program which allows the kernel to detect such attempts
92644 + and react on them. PaX itself provides no reaction mechanisms,
92645 + instead it is strongly encouraged that you make use of Nergal's
92646 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92647 + (http://www.grsecurity.net/) built-in crash detection features or
92648 + develop one yourself.
92649 +
92650 + By saying Y here you can choose to randomize the following areas:
92651 + - top of the task's kernel stack
92652 + - top of the task's userland stack
92653 + - base address for mmap() requests that do not specify one
92654 + (this includes all libraries)
92655 + - base address of the main executable
92656 +
92657 + It is strongly recommended to say Y here as address space layout
92658 + randomization has negligible impact on performance yet it provides
92659 + a very effective protection.
92660 +
92661 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92662 + this feature on a per file basis.
92663 +
92664 +config PAX_RANDKSTACK
92665 + bool "Randomize kernel stack base"
92666 + default y if GRKERNSEC_CONFIG_AUTO
92667 + depends on X86_TSC && X86
92668 + help
92669 + By saying Y here the kernel will randomize every task's kernel
92670 + stack on every system call. This will not only force an attacker
92671 + to guess it but also prevent him from making use of possible
92672 + leaked information about it.
92673 +
92674 + Since the kernel stack is a rather scarce resource, randomization
92675 + may cause unexpected stack overflows, therefore you should very
92676 + carefully test your system. Note that once enabled in the kernel
92677 + configuration, this feature cannot be disabled on a per file basis.
92678 +
92679 +config PAX_RANDUSTACK
92680 + bool "Randomize user stack base"
92681 + default y if GRKERNSEC_CONFIG_AUTO
92682 + depends on PAX_ASLR
92683 + help
92684 + By saying Y here the kernel will randomize every task's userland
92685 + stack. The randomization is done in two steps where the second
92686 + one may apply a big amount of shift to the top of the stack and
92687 + cause problems for programs that want to use lots of memory (more
92688 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92689 + For this reason the second step can be controlled by 'chpax' or
92690 + 'paxctl' on a per file basis.
92691 +
92692 +config PAX_RANDMMAP
92693 + bool "Randomize mmap() base"
92694 + default y if GRKERNSEC_CONFIG_AUTO
92695 + depends on PAX_ASLR
92696 + help
92697 + By saying Y here the kernel will use a randomized base address for
92698 + mmap() requests that do not specify one themselves. As a result
92699 + all dynamically loaded libraries will appear at random addresses
92700 + and therefore be harder to exploit by a technique where an attacker
92701 + attempts to execute library code for his purposes (e.g. spawn a
92702 + shell from an exploited program that is running at an elevated
92703 + privilege level).
92704 +
92705 + Furthermore, if a program is relinked as a dynamic ELF file, its
92706 + base address will be randomized as well, completing the full
92707 + randomization of the address space layout. Attacking such programs
92708 + becomes a guess game. You can find an example of doing this at
92709 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92710 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92711 +
92712 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92713 + feature on a per file basis.
92714 +
92715 +endmenu
92716 +
92717 +menu "Miscellaneous hardening features"
92718 +
92719 +config PAX_MEMORY_SANITIZE
92720 + bool "Sanitize all freed memory"
92721 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92722 + depends on !HIBERNATION
92723 + help
92724 + By saying Y here the kernel will erase memory pages as soon as they
92725 + are freed. This in turn reduces the lifetime of data stored in the
92726 + pages, making it less likely that sensitive information such as
92727 + passwords, cryptographic secrets, etc stay in memory for too long.
92728 +
92729 + This is especially useful for programs whose runtime is short, long
92730 + lived processes and the kernel itself benefit from this as long as
92731 + they operate on whole memory pages and ensure timely freeing of pages
92732 + that may hold sensitive information.
92733 +
92734 + The tradeoff is performance impact, on a single CPU system kernel
92735 + compilation sees a 3% slowdown, other systems and workloads may vary
92736 + and you are advised to test this feature on your expected workload
92737 + before deploying it.
92738 +
92739 + Note that this feature does not protect data stored in live pages,
92740 + e.g., process memory swapped to disk may stay there for a long time.
92741 +
92742 +config PAX_MEMORY_STACKLEAK
92743 + bool "Sanitize kernel stack"
92744 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92745 + depends on X86
92746 + help
92747 + By saying Y here the kernel will erase the kernel stack before it
92748 + returns from a system call. This in turn reduces the information
92749 + that a kernel stack leak bug can reveal.
92750 +
92751 + Note that such a bug can still leak information that was put on
92752 + the stack by the current system call (the one eventually triggering
92753 + the bug) but traces of earlier system calls on the kernel stack
92754 + cannot leak anymore.
92755 +
92756 + The tradeoff is performance impact: on a single CPU system kernel
92757 + compilation sees a 1% slowdown, other systems and workloads may vary
92758 + and you are advised to test this feature on your expected workload
92759 + before deploying it.
92760 +
92761 + Note that the full feature requires a gcc with plugin support,
92762 + i.e., gcc 4.5 or newer. You may need to install the supporting
92763 + headers explicitly in addition to the normal gcc package. Using
92764 + older gcc versions means that functions with large enough stack
92765 + frames may leave uninitialized memory behind that may be exposed
92766 + to a later syscall leaking the stack.
92767 +
92768 +config PAX_MEMORY_STRUCTLEAK
92769 + bool "Forcibly initialize local variables copied to userland"
92770 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92771 + help
92772 + By saying Y here the kernel will zero initialize some local
92773 + variables that are going to be copied to userland. This in
92774 + turn prevents unintended information leakage from the kernel
92775 + stack should later code forget to explicitly set all parts of
92776 + the copied variable.
92777 +
92778 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92779 + at a much smaller coverage.
92780 +
92781 + Note that the implementation requires a gcc with plugin support,
92782 + i.e., gcc 4.5 or newer. You may need to install the supporting
92783 + headers explicitly in addition to the normal gcc package.
92784 +
92785 +config PAX_MEMORY_UDEREF
92786 + bool "Prevent invalid userland pointer dereference"
92787 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92788 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92789 + select PAX_PER_CPU_PGD if X86_64
92790 + help
92791 + By saying Y here the kernel will be prevented from dereferencing
92792 + userland pointers in contexts where the kernel expects only kernel
92793 + pointers. This is both a useful runtime debugging feature and a
92794 + security measure that prevents exploiting a class of kernel bugs.
92795 +
92796 + The tradeoff is that some virtualization solutions may experience
92797 + a huge slowdown and therefore you should not enable this feature
92798 + for kernels meant to run in such environments. Whether a given VM
92799 + solution is affected or not is best determined by simply trying it
92800 + out, the performance impact will be obvious right on boot as this
92801 + mechanism engages from very early on. A good rule of thumb is that
92802 + VMs running on CPUs without hardware virtualization support (i.e.,
92803 + the majority of IA-32 CPUs) will likely experience the slowdown.
92804 +
92805 +config PAX_REFCOUNT
92806 + bool "Prevent various kernel object reference counter overflows"
92807 + default y if GRKERNSEC_CONFIG_AUTO
92808 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92809 + help
92810 + By saying Y here the kernel will detect and prevent overflowing
92811 + various (but not all) kinds of object reference counters. Such
92812 + overflows can normally occur due to bugs only and are often, if
92813 + not always, exploitable.
92814 +
92815 + The tradeoff is that data structures protected by an overflowed
92816 + refcount will never be freed and therefore will leak memory. Note
92817 + that this leak also happens even without this protection but in
92818 + that case the overflow can eventually trigger the freeing of the
92819 + data structure while it is still being used elsewhere, resulting
92820 + in the exploitable situation that this feature prevents.
92821 +
92822 + Since this has a negligible performance impact, you should enable
92823 + this feature.
92824 +
92825 +config PAX_CONSTIFY_PLUGIN
92826 + bool "Automatically constify eligible structures"
92827 + default y
92828 + depends on !UML && PAX_KERNEXEC
92829 + help
92830 + By saying Y here the compiler will automatically constify a class
92831 + of types that contain only function pointers. This reduces the
92832 + kernel's attack surface and also produces a better memory layout.
92833 +
92834 + Note that the implementation requires a gcc with plugin support,
92835 + i.e., gcc 4.5 or newer. You may need to install the supporting
92836 + headers explicitly in addition to the normal gcc package.
92837 +
92838 + Note that if some code really has to modify constified variables
92839 + then the source code will have to be patched to allow it. Examples
92840 + can be found in PaX itself (the no_const attribute) and for some
92841 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92842 +
92843 +config PAX_USERCOPY
92844 + bool "Harden heap object copies between kernel and userland"
92845 + default y if GRKERNSEC_CONFIG_AUTO
92846 + depends on ARM || IA64 || PPC || SPARC || X86
92847 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92848 + select PAX_USERCOPY_SLABS
92849 + help
92850 + By saying Y here the kernel will enforce the size of heap objects
92851 + when they are copied in either direction between the kernel and
92852 + userland, even if only a part of the heap object is copied.
92853 +
92854 + Specifically, this checking prevents information leaking from the
92855 + kernel heap during kernel to userland copies (if the kernel heap
92856 + object is otherwise fully initialized) and prevents kernel heap
92857 + overflows during userland to kernel copies.
92858 +
92859 + Note that the current implementation provides the strictest bounds
92860 + checks for the SLUB allocator.
92861 +
92862 + Enabling this option also enables per-slab cache protection against
92863 + data in a given cache being copied into/out of via userland
92864 + accessors. Though the whitelist of regions will be reduced over
92865 + time, it notably protects important data structures like task structs.
92866 +
92867 + If frame pointers are enabled on x86, this option will also restrict
92868 + copies into and out of the kernel stack to local variables within a
92869 + single frame.
92870 +
92871 + Since this has a negligible performance impact, you should enable
92872 + this feature.
92873 +
92874 +config PAX_USERCOPY_DEBUG
92875 + bool
92876 + depends on X86 && PAX_USERCOPY
92877 + default n
92878 +
92879 +config PAX_SIZE_OVERFLOW
92880 + bool "Prevent various integer overflows in function size parameters"
92881 + default y if GRKERNSEC_CONFIG_AUTO
92882 + depends on X86
92883 + help
92884 + By saying Y here the kernel recomputes expressions of function
92885 + arguments marked by a size_overflow attribute with double integer
92886 + precision (DImode/TImode for 32/64 bit integer types).
92887 +
92888 + The recomputed argument is checked against TYPE_MAX and an event
92889 + is logged on overflow and the triggering process is killed.
92890 +
92891 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92892 +
92893 + Note that the implementation requires a gcc with plugin support,
92894 + i.e., gcc 4.5 or newer. You may need to install the supporting
92895 + headers explicitly in addition to the normal gcc package.
92896 +
92897 +config PAX_LATENT_ENTROPY
92898 + bool "Generate some entropy during boot"
92899 + default y if GRKERNSEC_CONFIG_AUTO
92900 + help
92901 + By saying Y here the kernel will instrument early boot code to
92902 + extract some entropy from both original and artificially created
92903 + program state. This will help especially embedded systems where
92904 + there is little 'natural' source of entropy normally. The cost
92905 + is some slowdown of the boot process.
92906 +
92907 + When pax_extra_latent_entropy is passed on the kernel command line,
92908 + entropy will be extracted from up to the first 4GB of RAM while the
92909 + runtime memory allocator is being initialized. This costs even more
92910 + slowdown of the boot process.
92911 +
92912 + Note that the implementation requires a gcc with plugin support,
92913 + i.e., gcc 4.5 or newer. You may need to install the supporting
92914 + headers explicitly in addition to the normal gcc package.
92915 +
92916 + Note that entropy extracted this way is not cryptographically
92917 + secure!
92918 +
92919 +endmenu
92920 +
92921 +endmenu
92922 +
92923 +source grsecurity/Kconfig
92924 +
92925 +endmenu
92926 +
92927 +endmenu
92928 +
92929 source security/keys/Kconfig
92930
92931 config SECURITY_DMESG_RESTRICT
92932 @@ -103,7 +1042,7 @@ config INTEL_TXT
92933 config LSM_MMAP_MIN_ADDR
92934 int "Low address space for LSM to protect from user allocation"
92935 depends on SECURITY && SECURITY_SELINUX
92936 - default 32768 if ARM
92937 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92938 default 65536
92939 help
92940 This is the portion of low virtual memory which should be protected
92941 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
92942 index 9b9013b..51ebf96 100644
92943 --- a/security/apparmor/Kconfig
92944 +++ b/security/apparmor/Kconfig
92945 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
92946 boot.
92947
92948 If you are unsure how to answer this question, answer 1.
92949 +
92950 +config SECURITY_APPARMOR_COMPAT_24
92951 + bool "Enable AppArmor 2.4 compatability"
92952 + depends on SECURITY_APPARMOR
92953 + default y
92954 + help
92955 + This option enables compatability with AppArmor 2.4. It is
92956 + recommended if compatability with older versions of AppArmor
92957 + is desired.
92958 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
92959 index 16c15ec..42b7c9f 100644
92960 --- a/security/apparmor/apparmorfs.c
92961 +++ b/security/apparmor/apparmorfs.c
92962 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
92963 .release = single_release,
92964 };
92965
92966 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
92967 +/**
92968 + * __next_namespace - find the next namespace to list
92969 + * @root: root namespace to stop search at (NOT NULL)
92970 + * @ns: current ns position (NOT NULL)
92971 + *
92972 + * Find the next namespace from @ns under @root and handle all locking needed
92973 + * while switching current namespace.
92974 + *
92975 + * Returns: next namespace or NULL if at last namespace under @root
92976 + * NOTE: will not unlock root->lock
92977 + */
92978 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
92979 + struct aa_namespace *ns)
92980 +{
92981 + struct aa_namespace *parent;
92982 +
92983 + /* is next namespace a child */
92984 + if (!list_empty(&ns->sub_ns)) {
92985 + struct aa_namespace *next;
92986 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
92987 + read_lock(&next->lock);
92988 + return next;
92989 + }
92990 +
92991 + /* check if the next ns is a sibling, parent, gp, .. */
92992 + parent = ns->parent;
92993 + while (parent) {
92994 + read_unlock(&ns->lock);
92995 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
92996 + read_lock(&ns->lock);
92997 + return ns;
92998 + }
92999 + if (parent == root)
93000 + return NULL;
93001 + ns = parent;
93002 + parent = parent->parent;
93003 + }
93004 +
93005 + return NULL;
93006 +}
93007 +
93008 +/**
93009 + * __first_profile - find the first profile in a namespace
93010 + * @root: namespace that is root of profiles being displayed (NOT NULL)
93011 + * @ns: namespace to start in (NOT NULL)
93012 + *
93013 + * Returns: unrefcounted profile or NULL if no profile
93014 + */
93015 +static struct aa_profile *__first_profile(struct aa_namespace *root,
93016 + struct aa_namespace *ns)
93017 +{
93018 + for ( ; ns; ns = __next_namespace(root, ns)) {
93019 + if (!list_empty(&ns->base.profiles))
93020 + return list_first_entry(&ns->base.profiles,
93021 + struct aa_profile, base.list);
93022 + }
93023 + return NULL;
93024 +}
93025 +
93026 +/**
93027 + * __next_profile - step to the next profile in a profile tree
93028 + * @profile: current profile in tree (NOT NULL)
93029 + *
93030 + * Perform a depth first taversal on the profile tree in a namespace
93031 + *
93032 + * Returns: next profile or NULL if done
93033 + * Requires: profile->ns.lock to be held
93034 + */
93035 +static struct aa_profile *__next_profile(struct aa_profile *p)
93036 +{
93037 + struct aa_profile *parent;
93038 + struct aa_namespace *ns = p->ns;
93039 +
93040 + /* is next profile a child */
93041 + if (!list_empty(&p->base.profiles))
93042 + return list_first_entry(&p->base.profiles, typeof(*p),
93043 + base.list);
93044 +
93045 + /* is next profile a sibling, parent sibling, gp, subling, .. */
93046 + parent = p->parent;
93047 + while (parent) {
93048 + list_for_each_entry_continue(p, &parent->base.profiles,
93049 + base.list)
93050 + return p;
93051 + p = parent;
93052 + parent = parent->parent;
93053 + }
93054 +
93055 + /* is next another profile in the namespace */
93056 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
93057 + return p;
93058 +
93059 + return NULL;
93060 +}
93061 +
93062 +/**
93063 + * next_profile - step to the next profile in where ever it may be
93064 + * @root: root namespace (NOT NULL)
93065 + * @profile: current profile (NOT NULL)
93066 + *
93067 + * Returns: next profile or NULL if there isn't one
93068 + */
93069 +static struct aa_profile *next_profile(struct aa_namespace *root,
93070 + struct aa_profile *profile)
93071 +{
93072 + struct aa_profile *next = __next_profile(profile);
93073 + if (next)
93074 + return next;
93075 +
93076 + /* finished all profiles in namespace move to next namespace */
93077 + return __first_profile(root, __next_namespace(root, profile->ns));
93078 +}
93079 +
93080 +/**
93081 + * p_start - start a depth first traversal of profile tree
93082 + * @f: seq_file to fill
93083 + * @pos: current position
93084 + *
93085 + * Returns: first profile under current namespace or NULL if none found
93086 + *
93087 + * acquires first ns->lock
93088 + */
93089 +static void *p_start(struct seq_file *f, loff_t *pos)
93090 + __acquires(root->lock)
93091 +{
93092 + struct aa_profile *profile = NULL;
93093 + struct aa_namespace *root = aa_current_profile()->ns;
93094 + loff_t l = *pos;
93095 + f->private = aa_get_namespace(root);
93096 +
93097 +
93098 + /* find the first profile */
93099 + read_lock(&root->lock);
93100 + profile = __first_profile(root, root);
93101 +
93102 + /* skip to position */
93103 + for (; profile && l > 0; l--)
93104 + profile = next_profile(root, profile);
93105 +
93106 + return profile;
93107 +}
93108 +
93109 +/**
93110 + * p_next - read the next profile entry
93111 + * @f: seq_file to fill
93112 + * @p: profile previously returned
93113 + * @pos: current position
93114 + *
93115 + * Returns: next profile after @p or NULL if none
93116 + *
93117 + * may acquire/release locks in namespace tree as necessary
93118 + */
93119 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
93120 +{
93121 + struct aa_profile *profile = p;
93122 + struct aa_namespace *root = f->private;
93123 + (*pos)++;
93124 +
93125 + return next_profile(root, profile);
93126 +}
93127 +
93128 +/**
93129 + * p_stop - stop depth first traversal
93130 + * @f: seq_file we are filling
93131 + * @p: the last profile writen
93132 + *
93133 + * Release all locking done by p_start/p_next on namespace tree
93134 + */
93135 +static void p_stop(struct seq_file *f, void *p)
93136 + __releases(root->lock)
93137 +{
93138 + struct aa_profile *profile = p;
93139 + struct aa_namespace *root = f->private, *ns;
93140 +
93141 + if (profile) {
93142 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
93143 + read_unlock(&ns->lock);
93144 + }
93145 + read_unlock(&root->lock);
93146 + aa_put_namespace(root);
93147 +}
93148 +
93149 +/**
93150 + * seq_show_profile - show a profile entry
93151 + * @f: seq_file to file
93152 + * @p: current position (profile) (NOT NULL)
93153 + *
93154 + * Returns: error on failure
93155 + */
93156 +static int seq_show_profile(struct seq_file *f, void *p)
93157 +{
93158 + struct aa_profile *profile = (struct aa_profile *)p;
93159 + struct aa_namespace *root = f->private;
93160 +
93161 + if (profile->ns != root)
93162 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
93163 + seq_printf(f, "%s (%s)\n", profile->base.hname,
93164 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
93165 +
93166 + return 0;
93167 +}
93168 +
93169 +static const struct seq_operations aa_fs_profiles_op = {
93170 + .start = p_start,
93171 + .next = p_next,
93172 + .stop = p_stop,
93173 + .show = seq_show_profile,
93174 +};
93175 +
93176 +static int profiles_open(struct inode *inode, struct file *file)
93177 +{
93178 + return seq_open(file, &aa_fs_profiles_op);
93179 +}
93180 +
93181 +static int profiles_release(struct inode *inode, struct file *file)
93182 +{
93183 + return seq_release(inode, file);
93184 +}
93185 +
93186 +const struct file_operations aa_fs_profiles_fops = {
93187 + .open = profiles_open,
93188 + .read = seq_read,
93189 + .llseek = seq_lseek,
93190 + .release = profiles_release,
93191 +};
93192 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
93193 +
93194 /** Base file system setup **/
93195
93196 static struct aa_fs_entry aa_fs_entry_file[] = {
93197 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
93198 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
93199 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
93200 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
93201 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
93202 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
93203 +#endif
93204 AA_FS_DIR("features", aa_fs_entry_features),
93205 { }
93206 };
93207 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
93208 index b21830e..a7d1a17 100644
93209 --- a/security/apparmor/lsm.c
93210 +++ b/security/apparmor/lsm.c
93211 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
93212 return error;
93213 }
93214
93215 -static struct security_operations apparmor_ops = {
93216 +static struct security_operations apparmor_ops __read_only = {
93217 .name = "apparmor",
93218
93219 .ptrace_access_check = apparmor_ptrace_access_check,
93220 diff --git a/security/commoncap.c b/security/commoncap.c
93221 index c44b6fe..932df30 100644
93222 --- a/security/commoncap.c
93223 +++ b/security/commoncap.c
93224 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
93225 return 0;
93226 }
93227
93228 +/* returns:
93229 + 1 for suid privilege
93230 + 2 for sgid privilege
93231 + 3 for fscap privilege
93232 +*/
93233 +int is_privileged_binary(const struct dentry *dentry)
93234 +{
93235 + struct cpu_vfs_cap_data capdata;
93236 + struct inode *inode = dentry->d_inode;
93237 +
93238 + if (!inode || S_ISDIR(inode->i_mode))
93239 + return 0;
93240 +
93241 + if (inode->i_mode & S_ISUID)
93242 + return 1;
93243 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
93244 + return 2;
93245 +
93246 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
93247 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
93248 + return 3;
93249 + }
93250 +
93251 + return 0;
93252 +}
93253 +
93254 /*
93255 * Attempt to get the on-exec apply capability sets for an executable file from
93256 * its xattrs and, if present, apply them to the proposed credentials being
93257 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
93258 const struct cred *cred = current_cred();
93259 kuid_t root_uid = make_kuid(cred->user_ns, 0);
93260
93261 + if (gr_acl_enable_at_secure())
93262 + return 1;
93263 +
93264 if (!uid_eq(cred->uid, root_uid)) {
93265 if (bprm->cap_effective)
93266 return 1;
93267 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
93268 index a41c9c1..83da6dd 100644
93269 --- a/security/integrity/ima/ima.h
93270 +++ b/security/integrity/ima/ima.h
93271 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
93272 extern spinlock_t ima_queue_lock;
93273
93274 struct ima_h_table {
93275 - atomic_long_t len; /* number of stored measurements in the list */
93276 - atomic_long_t violations;
93277 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
93278 + atomic_long_unchecked_t violations;
93279 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
93280 };
93281 extern struct ima_h_table ima_htable;
93282 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
93283 index 1c03e8f1..398a941 100644
93284 --- a/security/integrity/ima/ima_api.c
93285 +++ b/security/integrity/ima/ima_api.c
93286 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
93287 int result;
93288
93289 /* can overflow, only indicator */
93290 - atomic_long_inc(&ima_htable.violations);
93291 + atomic_long_inc_unchecked(&ima_htable.violations);
93292
93293 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
93294 if (!entry) {
93295 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
93296 index 38477c9..87a60c7 100644
93297 --- a/security/integrity/ima/ima_fs.c
93298 +++ b/security/integrity/ima/ima_fs.c
93299 @@ -28,12 +28,12 @@
93300 static int valid_policy = 1;
93301 #define TMPBUFLEN 12
93302 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
93303 - loff_t *ppos, atomic_long_t *val)
93304 + loff_t *ppos, atomic_long_unchecked_t *val)
93305 {
93306 char tmpbuf[TMPBUFLEN];
93307 ssize_t len;
93308
93309 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
93310 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
93311 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
93312 }
93313
93314 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
93315 index ff63fe0..809cd96 100644
93316 --- a/security/integrity/ima/ima_queue.c
93317 +++ b/security/integrity/ima/ima_queue.c
93318 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
93319 INIT_LIST_HEAD(&qe->later);
93320 list_add_tail_rcu(&qe->later, &ima_measurements);
93321
93322 - atomic_long_inc(&ima_htable.len);
93323 + atomic_long_inc_unchecked(&ima_htable.len);
93324 key = ima_hash_key(entry->digest);
93325 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
93326 return 0;
93327 diff --git a/security/keys/compat.c b/security/keys/compat.c
93328 index d65fa7f..cbfe366 100644
93329 --- a/security/keys/compat.c
93330 +++ b/security/keys/compat.c
93331 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
93332 if (ret == 0)
93333 goto no_payload_free;
93334
93335 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93336 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93337 err:
93338 if (iov != iovstack)
93339 kfree(iov);
93340 diff --git a/security/keys/internal.h b/security/keys/internal.h
93341 index 8bbefc3..299d03f 100644
93342 --- a/security/keys/internal.h
93343 +++ b/security/keys/internal.h
93344 @@ -240,7 +240,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
93345 extern long keyctl_invalidate_key(key_serial_t);
93346
93347 extern long keyctl_instantiate_key_common(key_serial_t,
93348 - const struct iovec *,
93349 + const struct iovec __user *,
93350 unsigned, size_t, key_serial_t);
93351
93352 /*
93353 diff --git a/security/keys/key.c b/security/keys/key.c
93354 index 8fb7c7b..ba3610d 100644
93355 --- a/security/keys/key.c
93356 +++ b/security/keys/key.c
93357 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
93358
93359 atomic_set(&key->usage, 1);
93360 init_rwsem(&key->sem);
93361 - lockdep_set_class(&key->sem, &type->lock_class);
93362 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
93363 key->type = type;
93364 key->user = user;
93365 key->quotalen = quotalen;
93366 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
93367 struct key_type *p;
93368 int ret;
93369
93370 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
93371 + pax_open_kernel();
93372 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
93373 + pax_close_kernel();
93374
93375 ret = -EEXIST;
93376 down_write(&key_types_sem);
93377 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
93378 }
93379
93380 /* store the type */
93381 - list_add(&ktype->link, &key_types_list);
93382 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
93383
93384 pr_notice("Key type %s registered\n", ktype->name);
93385 ret = 0;
93386 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
93387 void unregister_key_type(struct key_type *ktype)
93388 {
93389 down_write(&key_types_sem);
93390 - list_del_init(&ktype->link);
93391 + pax_list_del_init((struct list_head *)&ktype->link);
93392 downgrade_write(&key_types_sem);
93393 key_gc_keytype(ktype);
93394 pr_notice("Key type %s unregistered\n", ktype->name);
93395 @@ -1084,10 +1086,10 @@ void __init key_init(void)
93396 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
93397
93398 /* add the special key types */
93399 - list_add_tail(&key_type_keyring.link, &key_types_list);
93400 - list_add_tail(&key_type_dead.link, &key_types_list);
93401 - list_add_tail(&key_type_user.link, &key_types_list);
93402 - list_add_tail(&key_type_logon.link, &key_types_list);
93403 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
93404 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
93405 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
93406 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
93407
93408 /* record the root user tracking */
93409 rb_link_node(&root_key_user.node,
93410 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
93411 index 4b5c948..2054dc1 100644
93412 --- a/security/keys/keyctl.c
93413 +++ b/security/keys/keyctl.c
93414 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
93415 /*
93416 * Copy the iovec data from userspace
93417 */
93418 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93419 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
93420 unsigned ioc)
93421 {
93422 for (; ioc > 0; ioc--) {
93423 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93424 * If successful, 0 will be returned.
93425 */
93426 long keyctl_instantiate_key_common(key_serial_t id,
93427 - const struct iovec *payload_iov,
93428 + const struct iovec __user *payload_iov,
93429 unsigned ioc,
93430 size_t plen,
93431 key_serial_t ringid)
93432 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
93433 [0].iov_len = plen
93434 };
93435
93436 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
93437 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
93438 }
93439
93440 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
93441 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
93442 if (ret == 0)
93443 goto no_payload_free;
93444
93445 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93446 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93447 err:
93448 if (iov != iovstack)
93449 kfree(iov);
93450 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
93451 index 6ece7f2..ecdb55c 100644
93452 --- a/security/keys/keyring.c
93453 +++ b/security/keys/keyring.c
93454 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
93455 ret = -EFAULT;
93456
93457 for (loop = 0; loop < klist->nkeys; loop++) {
93458 + key_serial_t serial;
93459 key = rcu_deref_link_locked(klist, loop,
93460 keyring);
93461 + serial = key->serial;
93462
93463 tmp = sizeof(key_serial_t);
93464 if (tmp > buflen)
93465 tmp = buflen;
93466
93467 - if (copy_to_user(buffer,
93468 - &key->serial,
93469 - tmp) != 0)
93470 + if (copy_to_user(buffer, &serial, tmp))
93471 goto error;
93472
93473 buflen -= tmp;
93474 diff --git a/security/min_addr.c b/security/min_addr.c
93475 index f728728..6457a0c 100644
93476 --- a/security/min_addr.c
93477 +++ b/security/min_addr.c
93478 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
93479 */
93480 static void update_mmap_min_addr(void)
93481 {
93482 +#ifndef SPARC
93483 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
93484 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
93485 mmap_min_addr = dac_mmap_min_addr;
93486 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
93487 #else
93488 mmap_min_addr = dac_mmap_min_addr;
93489 #endif
93490 +#endif
93491 }
93492
93493 /*
93494 diff --git a/security/security.c b/security/security.c
93495 index 03f248b..5710c33 100644
93496 --- a/security/security.c
93497 +++ b/security/security.c
93498 @@ -20,6 +20,7 @@
93499 #include <linux/ima.h>
93500 #include <linux/evm.h>
93501 #include <linux/fsnotify.h>
93502 +#include <linux/mm.h>
93503 #include <linux/mman.h>
93504 #include <linux/mount.h>
93505 #include <linux/personality.h>
93506 @@ -32,8 +33,8 @@
93507 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
93508 CONFIG_DEFAULT_SECURITY;
93509
93510 -static struct security_operations *security_ops;
93511 -static struct security_operations default_security_ops = {
93512 +static struct security_operations *security_ops __read_only;
93513 +static struct security_operations default_security_ops __read_only = {
93514 .name = "default",
93515 };
93516
93517 @@ -74,7 +75,9 @@ int __init security_init(void)
93518
93519 void reset_security_ops(void)
93520 {
93521 + pax_open_kernel();
93522 security_ops = &default_security_ops;
93523 + pax_close_kernel();
93524 }
93525
93526 /* Save user chosen LSM */
93527 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
93528 index 7171a95..c35e879 100644
93529 --- a/security/selinux/hooks.c
93530 +++ b/security/selinux/hooks.c
93531 @@ -96,8 +96,6 @@
93532
93533 #define NUM_SEL_MNT_OPTS 5
93534
93535 -extern struct security_operations *security_ops;
93536 -
93537 /* SECMARK reference count */
93538 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
93539
93540 @@ -5498,7 +5496,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
93541
93542 #endif
93543
93544 -static struct security_operations selinux_ops = {
93545 +static struct security_operations selinux_ops __read_only = {
93546 .name = "selinux",
93547
93548 .ptrace_access_check = selinux_ptrace_access_check,
93549 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
93550 index 65f67cb..3f141ef 100644
93551 --- a/security/selinux/include/xfrm.h
93552 +++ b/security/selinux/include/xfrm.h
93553 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
93554
93555 static inline void selinux_xfrm_notify_policyload(void)
93556 {
93557 - atomic_inc(&flow_cache_genid);
93558 + atomic_inc_unchecked(&flow_cache_genid);
93559 rt_genid_bump(&init_net);
93560 }
93561 #else
93562 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
93563 index fa64740..bc95b74 100644
93564 --- a/security/smack/smack_lsm.c
93565 +++ b/security/smack/smack_lsm.c
93566 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
93567 return 0;
93568 }
93569
93570 -struct security_operations smack_ops = {
93571 +struct security_operations smack_ops __read_only = {
93572 .name = "smack",
93573
93574 .ptrace_access_check = smack_ptrace_access_check,
93575 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
93576 index 390c646..f2f8db3 100644
93577 --- a/security/tomoyo/mount.c
93578 +++ b/security/tomoyo/mount.c
93579 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
93580 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
93581 need_dev = -1; /* dev_name is a directory */
93582 } else {
93583 + if (!capable(CAP_SYS_ADMIN)) {
93584 + error = -EPERM;
93585 + goto out;
93586 + }
93587 fstype = get_fs_type(type);
93588 if (!fstype) {
93589 error = -ENODEV;
93590 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
93591 index a2ee362..5754f34 100644
93592 --- a/security/tomoyo/tomoyo.c
93593 +++ b/security/tomoyo/tomoyo.c
93594 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
93595 * tomoyo_security_ops is a "struct security_operations" which is used for
93596 * registering TOMOYO.
93597 */
93598 -static struct security_operations tomoyo_security_ops = {
93599 +static struct security_operations tomoyo_security_ops __read_only = {
93600 .name = "tomoyo",
93601 .cred_alloc_blank = tomoyo_cred_alloc_blank,
93602 .cred_prepare = tomoyo_cred_prepare,
93603 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
93604 index 20ef514..4182bed 100644
93605 --- a/security/yama/Kconfig
93606 +++ b/security/yama/Kconfig
93607 @@ -1,6 +1,6 @@
93608 config SECURITY_YAMA
93609 bool "Yama support"
93610 - depends on SECURITY
93611 + depends on SECURITY && !GRKERNSEC
93612 select SECURITYFS
93613 select SECURITY_PATH
93614 default n
93615 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
93616 index 13c88fbc..f8c115e 100644
93617 --- a/security/yama/yama_lsm.c
93618 +++ b/security/yama/yama_lsm.c
93619 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
93620 }
93621
93622 #ifndef CONFIG_SECURITY_YAMA_STACKED
93623 -static struct security_operations yama_ops = {
93624 +static struct security_operations yama_ops __read_only = {
93625 .name = "yama",
93626
93627 .ptrace_access_check = yama_ptrace_access_check,
93628 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
93629 #endif
93630
93631 #ifdef CONFIG_SYSCTL
93632 +static int zero __read_only;
93633 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
93634 +
93635 static int yama_dointvec_minmax(struct ctl_table *table, int write,
93636 void __user *buffer, size_t *lenp, loff_t *ppos)
93637 {
93638 - int rc;
93639 + ctl_table_no_const yama_table;
93640
93641 if (write && !capable(CAP_SYS_PTRACE))
93642 return -EPERM;
93643
93644 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
93645 - if (rc)
93646 - return rc;
93647 -
93648 + yama_table = *table;
93649 /* Lock the max value if it ever gets set. */
93650 - if (write && *(int *)table->data == *(int *)table->extra2)
93651 - table->extra1 = table->extra2;
93652 -
93653 - return rc;
93654 + if (ptrace_scope == max_scope)
93655 + yama_table.extra1 = &max_scope;
93656 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
93657 }
93658
93659 -static int zero;
93660 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
93661 -
93662 struct ctl_path yama_sysctl_path[] = {
93663 { .procname = "kernel", },
93664 { .procname = "yama", },
93665 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
93666 index 4cedc69..e59d8a3 100644
93667 --- a/sound/aoa/codecs/onyx.c
93668 +++ b/sound/aoa/codecs/onyx.c
93669 @@ -54,7 +54,7 @@ struct onyx {
93670 spdif_locked:1,
93671 analog_locked:1,
93672 original_mute:2;
93673 - int open_count;
93674 + local_t open_count;
93675 struct codec_info *codec_info;
93676
93677 /* mutex serializes concurrent access to the device
93678 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
93679 struct onyx *onyx = cii->codec_data;
93680
93681 mutex_lock(&onyx->mutex);
93682 - onyx->open_count++;
93683 + local_inc(&onyx->open_count);
93684 mutex_unlock(&onyx->mutex);
93685
93686 return 0;
93687 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
93688 struct onyx *onyx = cii->codec_data;
93689
93690 mutex_lock(&onyx->mutex);
93691 - onyx->open_count--;
93692 - if (!onyx->open_count)
93693 + if (local_dec_and_test(&onyx->open_count))
93694 onyx->spdif_locked = onyx->analog_locked = 0;
93695 mutex_unlock(&onyx->mutex);
93696
93697 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
93698 index ffd2025..df062c9 100644
93699 --- a/sound/aoa/codecs/onyx.h
93700 +++ b/sound/aoa/codecs/onyx.h
93701 @@ -11,6 +11,7 @@
93702 #include <linux/i2c.h>
93703 #include <asm/pmac_low_i2c.h>
93704 #include <asm/prom.h>
93705 +#include <asm/local.h>
93706
93707 /* PCM3052 register definitions */
93708
93709 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
93710 index 4c1cc51..16040040 100644
93711 --- a/sound/core/oss/pcm_oss.c
93712 +++ b/sound/core/oss/pcm_oss.c
93713 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
93714 if (in_kernel) {
93715 mm_segment_t fs;
93716 fs = snd_enter_user();
93717 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93718 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93719 snd_leave_user(fs);
93720 } else {
93721 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93722 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93723 }
93724 if (ret != -EPIPE && ret != -ESTRPIPE)
93725 break;
93726 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
93727 if (in_kernel) {
93728 mm_segment_t fs;
93729 fs = snd_enter_user();
93730 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93731 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93732 snd_leave_user(fs);
93733 } else {
93734 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93735 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93736 }
93737 if (ret == -EPIPE) {
93738 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
93739 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
93740 struct snd_pcm_plugin_channel *channels;
93741 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
93742 if (!in_kernel) {
93743 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
93744 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
93745 return -EFAULT;
93746 buf = runtime->oss.buffer;
93747 }
93748 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
93749 }
93750 } else {
93751 tmp = snd_pcm_oss_write2(substream,
93752 - (const char __force *)buf,
93753 + (const char __force_kernel *)buf,
93754 runtime->oss.period_bytes, 0);
93755 if (tmp <= 0)
93756 goto err;
93757 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
93758 struct snd_pcm_runtime *runtime = substream->runtime;
93759 snd_pcm_sframes_t frames, frames1;
93760 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
93761 - char __user *final_dst = (char __force __user *)buf;
93762 + char __user *final_dst = (char __force_user *)buf;
93763 if (runtime->oss.plugin_first) {
93764 struct snd_pcm_plugin_channel *channels;
93765 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
93766 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
93767 xfer += tmp;
93768 runtime->oss.buffer_used -= tmp;
93769 } else {
93770 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
93771 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
93772 runtime->oss.period_bytes, 0);
93773 if (tmp <= 0)
93774 goto err;
93775 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
93776 size1);
93777 size1 /= runtime->channels; /* frames */
93778 fs = snd_enter_user();
93779 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
93780 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
93781 snd_leave_user(fs);
93782 }
93783 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
93784 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
93785 index af49721..e85058e 100644
93786 --- a/sound/core/pcm_compat.c
93787 +++ b/sound/core/pcm_compat.c
93788 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
93789 int err;
93790
93791 fs = snd_enter_user();
93792 - err = snd_pcm_delay(substream, &delay);
93793 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
93794 snd_leave_user(fs);
93795 if (err < 0)
93796 return err;
93797 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
93798 index eb560fa..69a4995 100644
93799 --- a/sound/core/pcm_native.c
93800 +++ b/sound/core/pcm_native.c
93801 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
93802 switch (substream->stream) {
93803 case SNDRV_PCM_STREAM_PLAYBACK:
93804 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
93805 - (void __user *)arg);
93806 + (void __force_user *)arg);
93807 break;
93808 case SNDRV_PCM_STREAM_CAPTURE:
93809 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
93810 - (void __user *)arg);
93811 + (void __force_user *)arg);
93812 break;
93813 default:
93814 result = -EINVAL;
93815 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
93816 index 040c60e..989a19a 100644
93817 --- a/sound/core/seq/seq_device.c
93818 +++ b/sound/core/seq/seq_device.c
93819 @@ -64,7 +64,7 @@ struct ops_list {
93820 int argsize; /* argument size */
93821
93822 /* operators */
93823 - struct snd_seq_dev_ops ops;
93824 + struct snd_seq_dev_ops *ops;
93825
93826 /* registered devices */
93827 struct list_head dev_list; /* list of devices */
93828 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
93829
93830 mutex_lock(&ops->reg_mutex);
93831 /* copy driver operators */
93832 - ops->ops = *entry;
93833 + ops->ops = entry;
93834 ops->driver |= DRIVER_LOADED;
93835 ops->argsize = argsize;
93836
93837 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
93838 dev->name, ops->id, ops->argsize, dev->argsize);
93839 return -EINVAL;
93840 }
93841 - if (ops->ops.init_device(dev) >= 0) {
93842 + if (ops->ops->init_device(dev) >= 0) {
93843 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
93844 ops->num_init_devices++;
93845 } else {
93846 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
93847 dev->name, ops->id, ops->argsize, dev->argsize);
93848 return -EINVAL;
93849 }
93850 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
93851 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
93852 dev->status = SNDRV_SEQ_DEVICE_FREE;
93853 dev->driver_data = NULL;
93854 ops->num_init_devices--;
93855 diff --git a/sound/core/sound.c b/sound/core/sound.c
93856 index 70ccdab..50f2e10 100644
93857 --- a/sound/core/sound.c
93858 +++ b/sound/core/sound.c
93859 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
93860 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
93861 default: return;
93862 }
93863 - request_module(str);
93864 + request_module("%s", str);
93865 }
93866
93867 #endif /* modular kernel */
93868 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
93869 index 4e0dd22..7a1f32c 100644
93870 --- a/sound/drivers/mts64.c
93871 +++ b/sound/drivers/mts64.c
93872 @@ -29,6 +29,7 @@
93873 #include <sound/initval.h>
93874 #include <sound/rawmidi.h>
93875 #include <sound/control.h>
93876 +#include <asm/local.h>
93877
93878 #define CARD_NAME "Miditerminal 4140"
93879 #define DRIVER_NAME "MTS64"
93880 @@ -67,7 +68,7 @@ struct mts64 {
93881 struct pardevice *pardev;
93882 int pardev_claimed;
93883
93884 - int open_count;
93885 + local_t open_count;
93886 int current_midi_output_port;
93887 int current_midi_input_port;
93888 u8 mode[MTS64_NUM_INPUT_PORTS];
93889 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93890 {
93891 struct mts64 *mts = substream->rmidi->private_data;
93892
93893 - if (mts->open_count == 0) {
93894 + if (local_read(&mts->open_count) == 0) {
93895 /* We don't need a spinlock here, because this is just called
93896 if the device has not been opened before.
93897 So there aren't any IRQs from the device */
93898 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93899
93900 msleep(50);
93901 }
93902 - ++(mts->open_count);
93903 + local_inc(&mts->open_count);
93904
93905 return 0;
93906 }
93907 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93908 struct mts64 *mts = substream->rmidi->private_data;
93909 unsigned long flags;
93910
93911 - --(mts->open_count);
93912 - if (mts->open_count == 0) {
93913 + if (local_dec_return(&mts->open_count) == 0) {
93914 /* We need the spinlock_irqsave here because we can still
93915 have IRQs at this point */
93916 spin_lock_irqsave(&mts->lock, flags);
93917 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93918
93919 msleep(500);
93920
93921 - } else if (mts->open_count < 0)
93922 - mts->open_count = 0;
93923 + } else if (local_read(&mts->open_count) < 0)
93924 + local_set(&mts->open_count, 0);
93925
93926 return 0;
93927 }
93928 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93929 index b953fb4..1999c01 100644
93930 --- a/sound/drivers/opl4/opl4_lib.c
93931 +++ b/sound/drivers/opl4/opl4_lib.c
93932 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93933 MODULE_DESCRIPTION("OPL4 driver");
93934 MODULE_LICENSE("GPL");
93935
93936 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93937 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93938 {
93939 int timeout = 10;
93940 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93941 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93942 index 991018d..8984740 100644
93943 --- a/sound/drivers/portman2x4.c
93944 +++ b/sound/drivers/portman2x4.c
93945 @@ -48,6 +48,7 @@
93946 #include <sound/initval.h>
93947 #include <sound/rawmidi.h>
93948 #include <sound/control.h>
93949 +#include <asm/local.h>
93950
93951 #define CARD_NAME "Portman 2x4"
93952 #define DRIVER_NAME "portman"
93953 @@ -85,7 +86,7 @@ struct portman {
93954 struct pardevice *pardev;
93955 int pardev_claimed;
93956
93957 - int open_count;
93958 + local_t open_count;
93959 int mode[PORTMAN_NUM_INPUT_PORTS];
93960 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93961 };
93962 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93963 index ea995af..f1bfa37 100644
93964 --- a/sound/firewire/amdtp.c
93965 +++ b/sound/firewire/amdtp.c
93966 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93967 ptr = s->pcm_buffer_pointer + data_blocks;
93968 if (ptr >= pcm->runtime->buffer_size)
93969 ptr -= pcm->runtime->buffer_size;
93970 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93971 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93972
93973 s->pcm_period_pointer += data_blocks;
93974 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93975 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93976 */
93977 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93978 {
93979 - ACCESS_ONCE(s->source_node_id_field) =
93980 + ACCESS_ONCE_RW(s->source_node_id_field) =
93981 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93982 }
93983 EXPORT_SYMBOL(amdtp_out_stream_update);
93984 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93985 index b680c5e..061b7a0 100644
93986 --- a/sound/firewire/amdtp.h
93987 +++ b/sound/firewire/amdtp.h
93988 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93989 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93990 struct snd_pcm_substream *pcm)
93991 {
93992 - ACCESS_ONCE(s->pcm) = pcm;
93993 + ACCESS_ONCE_RW(s->pcm) = pcm;
93994 }
93995
93996 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93997 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93998 index d428ffe..751ef78 100644
93999 --- a/sound/firewire/isight.c
94000 +++ b/sound/firewire/isight.c
94001 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
94002 ptr += count;
94003 if (ptr >= runtime->buffer_size)
94004 ptr -= runtime->buffer_size;
94005 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
94006 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
94007
94008 isight->period_counter += count;
94009 if (isight->period_counter >= runtime->period_size) {
94010 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
94011 if (err < 0)
94012 return err;
94013
94014 - ACCESS_ONCE(isight->pcm_active) = true;
94015 + ACCESS_ONCE_RW(isight->pcm_active) = true;
94016
94017 return 0;
94018 }
94019 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
94020 {
94021 struct isight *isight = substream->private_data;
94022
94023 - ACCESS_ONCE(isight->pcm_active) = false;
94024 + ACCESS_ONCE_RW(isight->pcm_active) = false;
94025
94026 mutex_lock(&isight->mutex);
94027 isight_stop_streaming(isight);
94028 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
94029
94030 switch (cmd) {
94031 case SNDRV_PCM_TRIGGER_START:
94032 - ACCESS_ONCE(isight->pcm_running) = true;
94033 + ACCESS_ONCE_RW(isight->pcm_running) = true;
94034 break;
94035 case SNDRV_PCM_TRIGGER_STOP:
94036 - ACCESS_ONCE(isight->pcm_running) = false;
94037 + ACCESS_ONCE_RW(isight->pcm_running) = false;
94038 break;
94039 default:
94040 return -EINVAL;
94041 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
94042 index 844a555..985ab83 100644
94043 --- a/sound/firewire/scs1x.c
94044 +++ b/sound/firewire/scs1x.c
94045 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
94046 {
94047 struct scs *scs = stream->rmidi->private_data;
94048
94049 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
94050 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
94051 if (up) {
94052 scs->output_idle = false;
94053 tasklet_schedule(&scs->tasklet);
94054 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
94055 {
94056 struct scs *scs = stream->rmidi->private_data;
94057
94058 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
94059 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
94060 }
94061
94062 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
94063 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
94064
94065 snd_card_disconnect(scs->card);
94066
94067 - ACCESS_ONCE(scs->output) = NULL;
94068 - ACCESS_ONCE(scs->input) = NULL;
94069 + ACCESS_ONCE_RW(scs->output) = NULL;
94070 + ACCESS_ONCE_RW(scs->input) = NULL;
94071
94072 wait_event(scs->idle_wait, scs->output_idle);
94073
94074 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
94075 index 048439a..3be9f6f 100644
94076 --- a/sound/oss/sb_audio.c
94077 +++ b/sound/oss/sb_audio.c
94078 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
94079 buf16 = (signed short *)(localbuf + localoffs);
94080 while (c)
94081 {
94082 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
94083 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
94084 if (copy_from_user(lbuf8,
94085 userbuf+useroffs + p,
94086 locallen))
94087 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
94088 index 7d8803a..559f8d0 100644
94089 --- a/sound/oss/swarm_cs4297a.c
94090 +++ b/sound/oss/swarm_cs4297a.c
94091 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
94092 {
94093 struct cs4297a_state *s;
94094 u32 pwr, id;
94095 - mm_segment_t fs;
94096 int rval;
94097 #ifndef CONFIG_BCM_CS4297A_CSWARM
94098 u64 cfg;
94099 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
94100 if (!rval) {
94101 char *sb1250_duart_present;
94102
94103 +#if 0
94104 + mm_segment_t fs;
94105 fs = get_fs();
94106 set_fs(KERNEL_DS);
94107 -#if 0
94108 val = SOUND_MASK_LINE;
94109 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
94110 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
94111 val = initvol[i].vol;
94112 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
94113 }
94114 + set_fs(fs);
94115 // cs4297a_write_ac97(s, 0x18, 0x0808);
94116 #else
94117 // cs4297a_write_ac97(s, 0x5e, 0x180);
94118 cs4297a_write_ac97(s, 0x02, 0x0808);
94119 cs4297a_write_ac97(s, 0x18, 0x0808);
94120 #endif
94121 - set_fs(fs);
94122
94123 list_add(&s->list, &cs4297a_devs);
94124
94125 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
94126 index 4631a23..001ae57 100644
94127 --- a/sound/pci/ymfpci/ymfpci.h
94128 +++ b/sound/pci/ymfpci/ymfpci.h
94129 @@ -358,7 +358,7 @@ struct snd_ymfpci {
94130 spinlock_t reg_lock;
94131 spinlock_t voice_lock;
94132 wait_queue_head_t interrupt_sleep;
94133 - atomic_t interrupt_sleep_count;
94134 + atomic_unchecked_t interrupt_sleep_count;
94135 struct snd_info_entry *proc_entry;
94136 const struct firmware *dsp_microcode;
94137 const struct firmware *controller_microcode;
94138 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
94139 index 22056c5..25d3244 100644
94140 --- a/sound/pci/ymfpci/ymfpci_main.c
94141 +++ b/sound/pci/ymfpci/ymfpci_main.c
94142 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
94143 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
94144 break;
94145 }
94146 - if (atomic_read(&chip->interrupt_sleep_count)) {
94147 - atomic_set(&chip->interrupt_sleep_count, 0);
94148 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
94149 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
94150 wake_up(&chip->interrupt_sleep);
94151 }
94152 __end:
94153 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
94154 continue;
94155 init_waitqueue_entry(&wait, current);
94156 add_wait_queue(&chip->interrupt_sleep, &wait);
94157 - atomic_inc(&chip->interrupt_sleep_count);
94158 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
94159 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
94160 remove_wait_queue(&chip->interrupt_sleep, &wait);
94161 }
94162 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
94163 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
94164 spin_unlock(&chip->reg_lock);
94165
94166 - if (atomic_read(&chip->interrupt_sleep_count)) {
94167 - atomic_set(&chip->interrupt_sleep_count, 0);
94168 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
94169 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
94170 wake_up(&chip->interrupt_sleep);
94171 }
94172 }
94173 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
94174 spin_lock_init(&chip->reg_lock);
94175 spin_lock_init(&chip->voice_lock);
94176 init_waitqueue_head(&chip->interrupt_sleep);
94177 - atomic_set(&chip->interrupt_sleep_count, 0);
94178 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
94179 chip->card = card;
94180 chip->pci = pci;
94181 chip->irq = -1;
94182 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
94183 index 7decbd9..d17d9d0 100644
94184 --- a/sound/soc/fsl/fsl_ssi.c
94185 +++ b/sound/soc/fsl/fsl_ssi.c
94186 @@ -643,7 +643,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
94187 {
94188 struct fsl_ssi_private *ssi_private;
94189 int ret = 0;
94190 - struct device_attribute *dev_attr = NULL;
94191 + device_attribute_no_const *dev_attr = NULL;
94192 struct device_node *np = pdev->dev.of_node;
94193 const char *p, *sprop;
94194 const uint32_t *iprop;
94195 diff --git a/sound/sound_core.c b/sound/sound_core.c
94196 index bb23009..db346c2 100644
94197 --- a/sound/sound_core.c
94198 +++ b/sound/sound_core.c
94199 @@ -292,7 +292,7 @@ retry:
94200 }
94201
94202 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
94203 - NULL, s->name+6);
94204 + NULL, "%s", s->name+6);
94205 return s->unit_minor;
94206
94207 fail:
94208 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
94209 new file mode 100644
94210 index 0000000..50f2f2f
94211 --- /dev/null
94212 +++ b/tools/gcc/.gitignore
94213 @@ -0,0 +1 @@
94214 +size_overflow_hash.h
94215 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
94216 new file mode 100644
94217 index 0000000..144dbee
94218 --- /dev/null
94219 +++ b/tools/gcc/Makefile
94220 @@ -0,0 +1,45 @@
94221 +#CC := gcc
94222 +#PLUGIN_SOURCE_FILES := pax_plugin.c
94223 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
94224 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
94225 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
94226 +
94227 +ifeq ($(PLUGINCC),$(HOSTCC))
94228 +HOSTLIBS := hostlibs
94229 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
94230 +else
94231 +HOSTLIBS := hostcxxlibs
94232 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
94233 +endif
94234 +
94235 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
94236 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
94237 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
94238 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
94239 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
94240 +$(HOSTLIBS)-y += colorize_plugin.so
94241 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
94242 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
94243 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
94244 +
94245 +always := $($(HOSTLIBS)-y)
94246 +
94247 +constify_plugin-objs := constify_plugin.o
94248 +stackleak_plugin-objs := stackleak_plugin.o
94249 +kallocstat_plugin-objs := kallocstat_plugin.o
94250 +kernexec_plugin-objs := kernexec_plugin.o
94251 +checker_plugin-objs := checker_plugin.o
94252 +colorize_plugin-objs := colorize_plugin.o
94253 +size_overflow_plugin-objs := size_overflow_plugin.o
94254 +latent_entropy_plugin-objs := latent_entropy_plugin.o
94255 +structleak_plugin-objs := structleak_plugin.o
94256 +
94257 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
94258 +
94259 +quiet_cmd_build_size_overflow_hash = GENHASH $@
94260 + cmd_build_size_overflow_hash = \
94261 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
94262 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
94263 + $(call if_changed,build_size_overflow_hash)
94264 +
94265 +targets += size_overflow_hash.h
94266 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
94267 new file mode 100644
94268 index 0000000..22f03c0
94269 --- /dev/null
94270 +++ b/tools/gcc/checker_plugin.c
94271 @@ -0,0 +1,172 @@
94272 +/*
94273 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
94274 + * Licensed under the GPL v2
94275 + *
94276 + * Note: the choice of the license means that the compilation process is
94277 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94278 + * but for the kernel it doesn't matter since it doesn't link against
94279 + * any of the gcc libraries
94280 + *
94281 + * gcc plugin to implement various sparse (source code checker) features
94282 + *
94283 + * TODO:
94284 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
94285 + *
94286 + * BUGS:
94287 + * - none known
94288 + */
94289 +#include "gcc-plugin.h"
94290 +#include "config.h"
94291 +#include "system.h"
94292 +#include "coretypes.h"
94293 +#include "tree.h"
94294 +#include "tree-pass.h"
94295 +#include "flags.h"
94296 +#include "intl.h"
94297 +#include "toplev.h"
94298 +#include "plugin.h"
94299 +//#include "expr.h" where are you...
94300 +#include "diagnostic.h"
94301 +#include "plugin-version.h"
94302 +#include "tm.h"
94303 +#include "function.h"
94304 +#include "basic-block.h"
94305 +#include "gimple.h"
94306 +#include "rtl.h"
94307 +#include "emit-rtl.h"
94308 +#include "tree-flow.h"
94309 +#include "target.h"
94310 +
94311 +extern void c_register_addr_space (const char *str, addr_space_t as);
94312 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
94313 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
94314 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
94315 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
94316 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
94317 +
94318 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94319 +extern rtx emit_move_insn(rtx x, rtx y);
94320 +
94321 +int plugin_is_GPL_compatible;
94322 +
94323 +static struct plugin_info checker_plugin_info = {
94324 + .version = "201111150100",
94325 + .help = NULL,
94326 +};
94327 +
94328 +#define ADDR_SPACE_KERNEL 0
94329 +#define ADDR_SPACE_FORCE_KERNEL 1
94330 +#define ADDR_SPACE_USER 2
94331 +#define ADDR_SPACE_FORCE_USER 3
94332 +#define ADDR_SPACE_IOMEM 0
94333 +#define ADDR_SPACE_FORCE_IOMEM 0
94334 +#define ADDR_SPACE_PERCPU 0
94335 +#define ADDR_SPACE_FORCE_PERCPU 0
94336 +#define ADDR_SPACE_RCU 0
94337 +#define ADDR_SPACE_FORCE_RCU 0
94338 +
94339 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
94340 +{
94341 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
94342 +}
94343 +
94344 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
94345 +{
94346 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
94347 +}
94348 +
94349 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
94350 +{
94351 + return default_addr_space_valid_pointer_mode(mode, as);
94352 +}
94353 +
94354 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
94355 +{
94356 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
94357 +}
94358 +
94359 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
94360 +{
94361 + return default_addr_space_legitimize_address(x, oldx, mode, as);
94362 +}
94363 +
94364 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
94365 +{
94366 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
94367 + return true;
94368 +
94369 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
94370 + return true;
94371 +
94372 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
94373 + return true;
94374 +
94375 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
94376 + return true;
94377 +
94378 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
94379 + return true;
94380 +
94381 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
94382 + return true;
94383 +
94384 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
94385 + return true;
94386 +
94387 + return subset == superset;
94388 +}
94389 +
94390 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
94391 +{
94392 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
94393 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
94394 +
94395 + return op;
94396 +}
94397 +
94398 +static void register_checker_address_spaces(void *event_data, void *data)
94399 +{
94400 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
94401 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
94402 + c_register_addr_space("__user", ADDR_SPACE_USER);
94403 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
94404 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
94405 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
94406 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
94407 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
94408 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
94409 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
94410 +
94411 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
94412 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
94413 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
94414 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
94415 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
94416 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
94417 + targetm.addr_space.convert = checker_addr_space_convert;
94418 +}
94419 +
94420 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94421 +{
94422 + const char * const plugin_name = plugin_info->base_name;
94423 + const int argc = plugin_info->argc;
94424 + const struct plugin_argument * const argv = plugin_info->argv;
94425 + int i;
94426 +
94427 + if (!plugin_default_version_check(version, &gcc_version)) {
94428 + error(G_("incompatible gcc/plugin versions"));
94429 + return 1;
94430 + }
94431 +
94432 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
94433 +
94434 + for (i = 0; i < argc; ++i)
94435 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94436 +
94437 + if (TARGET_64BIT == 0)
94438 + return 0;
94439 +
94440 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
94441 +
94442 + return 0;
94443 +}
94444 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
94445 new file mode 100644
94446 index 0000000..414fe5e
94447 --- /dev/null
94448 +++ b/tools/gcc/colorize_plugin.c
94449 @@ -0,0 +1,151 @@
94450 +/*
94451 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
94452 + * Licensed under the GPL v2
94453 + *
94454 + * Note: the choice of the license means that the compilation process is
94455 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94456 + * but for the kernel it doesn't matter since it doesn't link against
94457 + * any of the gcc libraries
94458 + *
94459 + * gcc plugin to colorize diagnostic output
94460 + *
94461 + */
94462 +
94463 +#include "gcc-plugin.h"
94464 +#include "config.h"
94465 +#include "system.h"
94466 +#include "coretypes.h"
94467 +#include "tree.h"
94468 +#include "tree-pass.h"
94469 +#include "flags.h"
94470 +#include "intl.h"
94471 +#include "toplev.h"
94472 +#include "plugin.h"
94473 +#include "diagnostic.h"
94474 +#include "plugin-version.h"
94475 +#include "tm.h"
94476 +
94477 +int plugin_is_GPL_compatible;
94478 +
94479 +static struct plugin_info colorize_plugin_info = {
94480 + .version = "201302112000",
94481 + .help = NULL,
94482 +};
94483 +
94484 +#define GREEN "\033[32m\033[2m"
94485 +#define LIGHTGREEN "\033[32m\033[1m"
94486 +#define YELLOW "\033[33m\033[2m"
94487 +#define LIGHTYELLOW "\033[33m\033[1m"
94488 +#define RED "\033[31m\033[2m"
94489 +#define LIGHTRED "\033[31m\033[1m"
94490 +#define BLUE "\033[34m\033[2m"
94491 +#define LIGHTBLUE "\033[34m\033[1m"
94492 +#define BRIGHT "\033[m\033[1m"
94493 +#define NORMAL "\033[m"
94494 +
94495 +static diagnostic_starter_fn old_starter;
94496 +static diagnostic_finalizer_fn old_finalizer;
94497 +
94498 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94499 +{
94500 + const char *color;
94501 + char *newprefix;
94502 +
94503 + switch (diagnostic->kind) {
94504 + case DK_NOTE:
94505 + color = LIGHTBLUE;
94506 + break;
94507 +
94508 + case DK_PEDWARN:
94509 + case DK_WARNING:
94510 + color = LIGHTYELLOW;
94511 + break;
94512 +
94513 + case DK_ERROR:
94514 + case DK_FATAL:
94515 + case DK_ICE:
94516 + case DK_PERMERROR:
94517 + case DK_SORRY:
94518 + color = LIGHTRED;
94519 + break;
94520 +
94521 + default:
94522 + color = NORMAL;
94523 + }
94524 +
94525 + old_starter(context, diagnostic);
94526 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
94527 + return;
94528 + pp_destroy_prefix(context->printer);
94529 + pp_set_prefix(context->printer, newprefix);
94530 +}
94531 +
94532 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94533 +{
94534 + old_finalizer(context, diagnostic);
94535 +}
94536 +
94537 +static void colorize_arm(void)
94538 +{
94539 + old_starter = diagnostic_starter(global_dc);
94540 + old_finalizer = diagnostic_finalizer(global_dc);
94541 +
94542 + diagnostic_starter(global_dc) = start_colorize;
94543 + diagnostic_finalizer(global_dc) = finalize_colorize;
94544 +}
94545 +
94546 +static unsigned int execute_colorize_rearm(void)
94547 +{
94548 + if (diagnostic_starter(global_dc) == start_colorize)
94549 + return 0;
94550 +
94551 + colorize_arm();
94552 + return 0;
94553 +}
94554 +
94555 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
94556 + .pass = {
94557 + .type = SIMPLE_IPA_PASS,
94558 + .name = "colorize_rearm",
94559 +#if BUILDING_GCC_VERSION >= 4008
94560 + .optinfo_flags = OPTGROUP_NONE,
94561 +#endif
94562 + .gate = NULL,
94563 + .execute = execute_colorize_rearm,
94564 + .sub = NULL,
94565 + .next = NULL,
94566 + .static_pass_number = 0,
94567 + .tv_id = TV_NONE,
94568 + .properties_required = 0,
94569 + .properties_provided = 0,
94570 + .properties_destroyed = 0,
94571 + .todo_flags_start = 0,
94572 + .todo_flags_finish = 0
94573 + }
94574 +};
94575 +
94576 +static void colorize_start_unit(void *gcc_data, void *user_data)
94577 +{
94578 + colorize_arm();
94579 +}
94580 +
94581 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94582 +{
94583 + const char * const plugin_name = plugin_info->base_name;
94584 + struct register_pass_info colorize_rearm_pass_info = {
94585 + .pass = &pass_ipa_colorize_rearm.pass,
94586 + .reference_pass_name = "*free_lang_data",
94587 + .ref_pass_instance_number = 1,
94588 + .pos_op = PASS_POS_INSERT_AFTER
94589 + };
94590 +
94591 + if (!plugin_default_version_check(version, &gcc_version)) {
94592 + error(G_("incompatible gcc/plugin versions"));
94593 + return 1;
94594 + }
94595 +
94596 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
94597 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
94598 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
94599 + return 0;
94600 +}
94601 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
94602 new file mode 100644
94603 index 0000000..c17312d
94604 --- /dev/null
94605 +++ b/tools/gcc/constify_plugin.c
94606 @@ -0,0 +1,560 @@
94607 +/*
94608 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
94609 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
94610 + * Licensed under the GPL v2, or (at your option) v3
94611 + *
94612 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
94613 + *
94614 + * Homepage:
94615 + * http://www.grsecurity.net/~ephox/const_plugin/
94616 + *
94617 + * Usage:
94618 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
94619 + * $ gcc -fplugin=constify_plugin.so test.c -O2
94620 + */
94621 +
94622 +#include "gcc-plugin.h"
94623 +#include "config.h"
94624 +#include "system.h"
94625 +#include "coretypes.h"
94626 +#include "tree.h"
94627 +#include "tree-pass.h"
94628 +#include "flags.h"
94629 +#include "intl.h"
94630 +#include "toplev.h"
94631 +#include "plugin.h"
94632 +#include "diagnostic.h"
94633 +#include "plugin-version.h"
94634 +#include "tm.h"
94635 +#include "function.h"
94636 +#include "basic-block.h"
94637 +#include "gimple.h"
94638 +#include "rtl.h"
94639 +#include "emit-rtl.h"
94640 +#include "tree-flow.h"
94641 +#include "target.h"
94642 +#include "langhooks.h"
94643 +
94644 +// should come from c-tree.h if only it were installed for gcc 4.5...
94645 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
94646 +
94647 +// unused type flag in all versions 4.5-4.8
94648 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
94649 +
94650 +int plugin_is_GPL_compatible;
94651 +
94652 +static struct plugin_info const_plugin_info = {
94653 + .version = "201305231310",
94654 + .help = "no-constify\tturn off constification\n",
94655 +};
94656 +
94657 +typedef struct {
94658 + bool has_fptr_field;
94659 + bool has_writable_field;
94660 + bool has_do_const_field;
94661 + bool has_no_const_field;
94662 +} constify_info;
94663 +
94664 +static const_tree get_field_type(const_tree field)
94665 +{
94666 + return strip_array_types(TREE_TYPE(field));
94667 +}
94668 +
94669 +static bool is_fptr(const_tree field)
94670 +{
94671 + const_tree ptr = get_field_type(field);
94672 +
94673 + if (TREE_CODE(ptr) != POINTER_TYPE)
94674 + return false;
94675 +
94676 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
94677 +}
94678 +
94679 +/*
94680 + * determine whether the given structure type meets the requirements for automatic constification,
94681 + * including the constification attributes on nested structure types
94682 + */
94683 +static void constifiable(const_tree node, constify_info *cinfo)
94684 +{
94685 + const_tree field;
94686 +
94687 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94688 +
94689 + // e.g., pointer to structure fields while still constructing the structure type
94690 + if (TYPE_FIELDS(node) == NULL_TREE)
94691 + return;
94692 +
94693 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
94694 + const_tree type = get_field_type(field);
94695 + enum tree_code code = TREE_CODE(type);
94696 +
94697 + if (node == type)
94698 + continue;
94699 +
94700 + if (is_fptr(field))
94701 + cinfo->has_fptr_field = true;
94702 + else if (!TREE_READONLY(field))
94703 + cinfo->has_writable_field = true;
94704 +
94705 + if (code == RECORD_TYPE || code == UNION_TYPE) {
94706 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94707 + cinfo->has_do_const_field = true;
94708 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
94709 + cinfo->has_no_const_field = true;
94710 + else
94711 + constifiable(type, cinfo);
94712 + }
94713 + }
94714 +}
94715 +
94716 +static bool constified(const_tree node)
94717 +{
94718 + constify_info cinfo = {
94719 + .has_fptr_field = false,
94720 + .has_writable_field = false,
94721 + .has_do_const_field = false,
94722 + .has_no_const_field = false
94723 + };
94724 +
94725 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94726 +
94727 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
94728 + gcc_assert(!TYPE_READONLY(node));
94729 + return false;
94730 + }
94731 +
94732 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
94733 + gcc_assert(TYPE_READONLY(node));
94734 + return true;
94735 + }
94736 +
94737 + constifiable(node, &cinfo);
94738 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
94739 + return false;
94740 +
94741 + return TYPE_READONLY(node);
94742 +}
94743 +
94744 +static void deconstify_tree(tree node);
94745 +
94746 +static void deconstify_type(tree type)
94747 +{
94748 + tree field;
94749 +
94750 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
94751 +
94752 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
94753 + const_tree fieldtype = get_field_type(field);
94754 +
94755 + // special case handling of simple ptr-to-same-array-type members
94756 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
94757 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
94758 +
94759 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
94760 + continue;
94761 + if (TREE_TYPE(TREE_TYPE(field)) == type)
94762 + continue;
94763 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
94764 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
94765 + TREE_TYPE(TREE_TYPE(field)) = type;
94766 + }
94767 + continue;
94768 + }
94769 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
94770 + continue;
94771 + if (!constified(fieldtype))
94772 + continue;
94773 +
94774 + deconstify_tree(field);
94775 + TREE_READONLY(field) = 0;
94776 + }
94777 + TYPE_READONLY(type) = 0;
94778 + C_TYPE_FIELDS_READONLY(type) = 0;
94779 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94780 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
94781 +}
94782 +
94783 +static void deconstify_tree(tree node)
94784 +{
94785 + tree old_type, new_type, field;
94786 +
94787 + old_type = TREE_TYPE(node);
94788 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
94789 + node = TREE_TYPE(node) = copy_node(old_type);
94790 + old_type = TREE_TYPE(old_type);
94791 + }
94792 +
94793 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
94794 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
94795 +
94796 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
94797 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
94798 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
94799 + DECL_FIELD_CONTEXT(field) = new_type;
94800 +
94801 + deconstify_type(new_type);
94802 +
94803 + TREE_TYPE(node) = new_type;
94804 +}
94805 +
94806 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94807 +{
94808 + tree type;
94809 + constify_info cinfo = {
94810 + .has_fptr_field = false,
94811 + .has_writable_field = false,
94812 + .has_do_const_field = false,
94813 + .has_no_const_field = false
94814 + };
94815 +
94816 + *no_add_attrs = true;
94817 + if (TREE_CODE(*node) == FUNCTION_DECL) {
94818 + error("%qE attribute does not apply to functions", name);
94819 + return NULL_TREE;
94820 + }
94821 +
94822 + if (TREE_CODE(*node) == PARM_DECL) {
94823 + error("%qE attribute does not apply to function parameters", name);
94824 + return NULL_TREE;
94825 + }
94826 +
94827 + if (TREE_CODE(*node) == VAR_DECL) {
94828 + error("%qE attribute does not apply to variables", name);
94829 + return NULL_TREE;
94830 + }
94831 +
94832 + if (TYPE_P(*node)) {
94833 + *no_add_attrs = false;
94834 + type = *node;
94835 + } else {
94836 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
94837 + type = TREE_TYPE(*node);
94838 + }
94839 +
94840 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
94841 + error("%qE attribute applies to struct and union types only", name);
94842 + return NULL_TREE;
94843 + }
94844 +
94845 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
94846 + error("%qE attribute is already applied to the type", name);
94847 + return NULL_TREE;
94848 + }
94849 +
94850 + if (TYPE_P(*node)) {
94851 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94852 + error("%qE attribute is incompatible with 'do_const'", name);
94853 + return NULL_TREE;
94854 + }
94855 +
94856 + constifiable(type, &cinfo);
94857 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94858 + deconstify_tree(*node);
94859 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
94860 + return NULL_TREE;
94861 + }
94862 +
94863 + error("%qE attribute used on type that is not constified", name);
94864 + return NULL_TREE;
94865 +}
94866 +
94867 +static void constify_type(tree type)
94868 +{
94869 + TYPE_READONLY(type) = 1;
94870 + C_TYPE_FIELDS_READONLY(type) = 1;
94871 + TYPE_CONSTIFY_VISITED(type) = 1;
94872 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
94873 +}
94874 +
94875 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94876 +{
94877 + *no_add_attrs = true;
94878 + if (!TYPE_P(*node)) {
94879 + error("%qE attribute applies to types only", name);
94880 + return NULL_TREE;
94881 + }
94882 +
94883 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94884 + error("%qE attribute applies to struct and union types only", name);
94885 + return NULL_TREE;
94886 + }
94887 +
94888 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94889 + error("%qE attribute is already applied to the type", name);
94890 + return NULL_TREE;
94891 + }
94892 +
94893 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
94894 + error("%qE attribute is incompatible with 'no_const'", name);
94895 + return NULL_TREE;
94896 + }
94897 +
94898 + *no_add_attrs = false;
94899 + return NULL_TREE;
94900 +}
94901 +
94902 +static struct attribute_spec no_const_attr = {
94903 + .name = "no_const",
94904 + .min_length = 0,
94905 + .max_length = 0,
94906 + .decl_required = false,
94907 + .type_required = false,
94908 + .function_type_required = false,
94909 + .handler = handle_no_const_attribute,
94910 +#if BUILDING_GCC_VERSION >= 4007
94911 + .affects_type_identity = true
94912 +#endif
94913 +};
94914 +
94915 +static struct attribute_spec do_const_attr = {
94916 + .name = "do_const",
94917 + .min_length = 0,
94918 + .max_length = 0,
94919 + .decl_required = false,
94920 + .type_required = false,
94921 + .function_type_required = false,
94922 + .handler = handle_do_const_attribute,
94923 +#if BUILDING_GCC_VERSION >= 4007
94924 + .affects_type_identity = true
94925 +#endif
94926 +};
94927 +
94928 +static void register_attributes(void *event_data, void *data)
94929 +{
94930 + register_attribute(&no_const_attr);
94931 + register_attribute(&do_const_attr);
94932 +}
94933 +
94934 +static void finish_type(void *event_data, void *data)
94935 +{
94936 + tree type = (tree)event_data;
94937 + constify_info cinfo = {
94938 + .has_fptr_field = false,
94939 + .has_writable_field = false,
94940 + .has_do_const_field = false,
94941 + .has_no_const_field = false
94942 + };
94943 +
94944 + if (type == NULL_TREE || type == error_mark_node)
94945 + return;
94946 +
94947 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94948 + return;
94949 +
94950 + constifiable(type, &cinfo);
94951 +
94952 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94953 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94954 + return;
94955 + if (cinfo.has_writable_field)
94956 + return;
94957 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94958 + return;
94959 + }
94960 +
94961 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94962 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94963 + deconstify_type(type);
94964 + TYPE_CONSTIFY_VISITED(type) = 1;
94965 + } else
94966 + error("'no_const' attribute used on type that is not constified");
94967 + return;
94968 + }
94969 +
94970 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94971 + constify_type(type);
94972 + return;
94973 + }
94974 +
94975 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94976 + constify_type(type);
94977 + return;
94978 + }
94979 +
94980 + deconstify_type(type);
94981 + TYPE_CONSTIFY_VISITED(type) = 1;
94982 +}
94983 +
94984 +static void check_global_variables(void)
94985 +{
94986 + struct varpool_node *node;
94987 +
94988 +#if BUILDING_GCC_VERSION <= 4007
94989 + for (node = varpool_nodes; node; node = node->next) {
94990 + tree var = node->decl;
94991 +#else
94992 + FOR_EACH_VARIABLE(node) {
94993 + tree var = node->symbol.decl;
94994 +#endif
94995 + tree type = TREE_TYPE(var);
94996 +
94997 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94998 + continue;
94999 +
95000 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
95001 + continue;
95002 +
95003 + if (!TYPE_CONSTIFY_VISITED(type))
95004 + continue;
95005 +
95006 + if (DECL_EXTERNAL(var))
95007 + continue;
95008 +
95009 + if (DECL_INITIAL(var))
95010 + continue;
95011 +
95012 + // this works around a gcc bug/feature where uninitialized globals
95013 + // are moved into the .bss section regardless of any constification
95014 + DECL_INITIAL(var) = build_constructor(type, NULL);
95015 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
95016 + }
95017 +}
95018 +
95019 +static unsigned int check_local_variables(void)
95020 +{
95021 + unsigned int ret = 0;
95022 + tree var;
95023 +
95024 +#if BUILDING_GCC_VERSION == 4005
95025 + tree vars;
95026 +#else
95027 + unsigned int i;
95028 +#endif
95029 +
95030 +#if BUILDING_GCC_VERSION == 4005
95031 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
95032 + var = TREE_VALUE(vars);
95033 +#else
95034 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
95035 +#endif
95036 + tree type = TREE_TYPE(var);
95037 +
95038 + gcc_assert(DECL_P(var));
95039 + if (is_global_var(var))
95040 + continue;
95041 +
95042 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
95043 + continue;
95044 +
95045 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
95046 + continue;
95047 +
95048 + if (!TYPE_CONSTIFY_VISITED(type))
95049 + continue;
95050 +
95051 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
95052 + ret = 1;
95053 + }
95054 + return ret;
95055 +}
95056 +
95057 +static unsigned int check_variables(void)
95058 +{
95059 + check_global_variables();
95060 + return check_local_variables();
95061 +}
95062 +
95063 + unsigned int ret = 0;
95064 +static struct gimple_opt_pass pass_local_variable = {
95065 + {
95066 + .type = GIMPLE_PASS,
95067 + .name = "check_variables",
95068 +#if BUILDING_GCC_VERSION >= 4008
95069 + .optinfo_flags = OPTGROUP_NONE,
95070 +#endif
95071 + .gate = NULL,
95072 + .execute = check_variables,
95073 + .sub = NULL,
95074 + .next = NULL,
95075 + .static_pass_number = 0,
95076 + .tv_id = TV_NONE,
95077 + .properties_required = 0,
95078 + .properties_provided = 0,
95079 + .properties_destroyed = 0,
95080 + .todo_flags_start = 0,
95081 + .todo_flags_finish = 0
95082 + }
95083 +};
95084 +
95085 +static struct {
95086 + const char *name;
95087 + const char *asm_op;
95088 +} sections[] = {
95089 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
95090 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
95091 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
95092 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
95093 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
95094 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
95095 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
95096 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
95097 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
95098 +};
95099 +
95100 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
95101 +
95102 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
95103 +{
95104 + size_t i;
95105 +
95106 + for (i = 0; i < ARRAY_SIZE(sections); i++)
95107 + if (!strcmp(sections[i].name, name))
95108 + return 0;
95109 + return old_section_type_flags(decl, name, reloc);
95110 +}
95111 +
95112 +static void constify_start_unit(void *gcc_data, void *user_data)
95113 +{
95114 +// size_t i;
95115 +
95116 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
95117 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
95118 +// sections[i].section = get_section(sections[i].name, 0, NULL);
95119 +
95120 + old_section_type_flags = targetm.section_type_flags;
95121 + targetm.section_type_flags = constify_section_type_flags;
95122 +}
95123 +
95124 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95125 +{
95126 + const char * const plugin_name = plugin_info->base_name;
95127 + const int argc = plugin_info->argc;
95128 + const struct plugin_argument * const argv = plugin_info->argv;
95129 + int i;
95130 + bool constify = true;
95131 +
95132 + struct register_pass_info local_variable_pass_info = {
95133 + .pass = &pass_local_variable.pass,
95134 + .reference_pass_name = "ssa",
95135 + .ref_pass_instance_number = 1,
95136 + .pos_op = PASS_POS_INSERT_BEFORE
95137 + };
95138 +
95139 + if (!plugin_default_version_check(version, &gcc_version)) {
95140 + error(G_("incompatible gcc/plugin versions"));
95141 + return 1;
95142 + }
95143 +
95144 + for (i = 0; i < argc; ++i) {
95145 + if (!(strcmp(argv[i].key, "no-constify"))) {
95146 + constify = false;
95147 + continue;
95148 + }
95149 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95150 + }
95151 +
95152 + if (strcmp(lang_hooks.name, "GNU C")) {
95153 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
95154 + constify = false;
95155 + }
95156 +
95157 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
95158 + if (constify) {
95159 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
95160 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
95161 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
95162 + }
95163 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95164 +
95165 + return 0;
95166 +}
95167 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
95168 new file mode 100644
95169 index 0000000..e518932
95170 --- /dev/null
95171 +++ b/tools/gcc/generate_size_overflow_hash.sh
95172 @@ -0,0 +1,94 @@
95173 +#!/bin/bash
95174 +
95175 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
95176 +
95177 +header1="size_overflow_hash.h"
95178 +database="size_overflow_hash.data"
95179 +n=65536
95180 +
95181 +usage() {
95182 +cat <<EOF
95183 +usage: $0 options
95184 +OPTIONS:
95185 + -h|--help help
95186 + -o header file
95187 + -d database file
95188 + -n hash array size
95189 +EOF
95190 + return 0
95191 +}
95192 +
95193 +while true
95194 +do
95195 + case "$1" in
95196 + -h|--help) usage && exit 0;;
95197 + -n) n=$2; shift 2;;
95198 + -o) header1="$2"; shift 2;;
95199 + -d) database="$2"; shift 2;;
95200 + --) shift 1; break ;;
95201 + *) break ;;
95202 + esac
95203 +done
95204 +
95205 +create_defines() {
95206 + for i in `seq 0 31`
95207 + do
95208 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
95209 + done
95210 + echo >> "$header1"
95211 +}
95212 +
95213 +create_structs() {
95214 + rm -f "$header1"
95215 +
95216 + create_defines
95217 +
95218 + cat "$database" | while read data
95219 + do
95220 + data_array=($data)
95221 + struct_hash_name="${data_array[0]}"
95222 + funcn="${data_array[1]}"
95223 + params="${data_array[2]}"
95224 + next="${data_array[4]}"
95225 +
95226 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
95227 +
95228 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
95229 + echo -en "\t.param\t= " >> "$header1"
95230 + line=
95231 + for param_num in ${params//-/ };
95232 + do
95233 + line="${line}PARAM"$param_num"|"
95234 + done
95235 +
95236 + echo -e "${line%?},\n};\n" >> "$header1"
95237 + done
95238 +}
95239 +
95240 +create_headers() {
95241 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
95242 +}
95243 +
95244 +create_array_elements() {
95245 + index=0
95246 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
95247 + do
95248 + data_array=($data)
95249 + i="${data_array[3]}"
95250 + hash="${data_array[0]}"
95251 + while [[ $index -lt $i ]]
95252 + do
95253 + echo -e "\t["$index"]\t= NULL," >> "$header1"
95254 + index=$(($index + 1))
95255 + done
95256 + index=$(($index + 1))
95257 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
95258 + done
95259 + echo '};' >> $header1
95260 +}
95261 +
95262 +create_structs
95263 +create_headers
95264 +create_array_elements
95265 +
95266 +exit 0
95267 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
95268 new file mode 100644
95269 index 0000000..568b360
95270 --- /dev/null
95271 +++ b/tools/gcc/kallocstat_plugin.c
95272 @@ -0,0 +1,170 @@
95273 +/*
95274 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95275 + * Licensed under the GPL v2
95276 + *
95277 + * Note: the choice of the license means that the compilation process is
95278 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95279 + * but for the kernel it doesn't matter since it doesn't link against
95280 + * any of the gcc libraries
95281 + *
95282 + * gcc plugin to find the distribution of k*alloc sizes
95283 + *
95284 + * TODO:
95285 + *
95286 + * BUGS:
95287 + * - none known
95288 + */
95289 +#include "gcc-plugin.h"
95290 +#include "config.h"
95291 +#include "system.h"
95292 +#include "coretypes.h"
95293 +#include "tree.h"
95294 +#include "tree-pass.h"
95295 +#include "flags.h"
95296 +#include "intl.h"
95297 +#include "toplev.h"
95298 +#include "plugin.h"
95299 +//#include "expr.h" where are you...
95300 +#include "diagnostic.h"
95301 +#include "plugin-version.h"
95302 +#include "tm.h"
95303 +#include "function.h"
95304 +#include "basic-block.h"
95305 +#include "gimple.h"
95306 +#include "rtl.h"
95307 +#include "emit-rtl.h"
95308 +
95309 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95310 +
95311 +int plugin_is_GPL_compatible;
95312 +
95313 +static const char * const kalloc_functions[] = {
95314 + "__kmalloc",
95315 + "kmalloc",
95316 + "kmalloc_large",
95317 + "kmalloc_node",
95318 + "kmalloc_order",
95319 + "kmalloc_order_trace",
95320 + "kmalloc_slab",
95321 + "kzalloc",
95322 + "kzalloc_node",
95323 +};
95324 +
95325 +static struct plugin_info kallocstat_plugin_info = {
95326 + .version = "201302112000",
95327 +};
95328 +
95329 +static unsigned int execute_kallocstat(void);
95330 +
95331 +static struct gimple_opt_pass kallocstat_pass = {
95332 + .pass = {
95333 + .type = GIMPLE_PASS,
95334 + .name = "kallocstat",
95335 +#if BUILDING_GCC_VERSION >= 4008
95336 + .optinfo_flags = OPTGROUP_NONE,
95337 +#endif
95338 + .gate = NULL,
95339 + .execute = execute_kallocstat,
95340 + .sub = NULL,
95341 + .next = NULL,
95342 + .static_pass_number = 0,
95343 + .tv_id = TV_NONE,
95344 + .properties_required = 0,
95345 + .properties_provided = 0,
95346 + .properties_destroyed = 0,
95347 + .todo_flags_start = 0,
95348 + .todo_flags_finish = 0
95349 + }
95350 +};
95351 +
95352 +static bool is_kalloc(const char *fnname)
95353 +{
95354 + size_t i;
95355 +
95356 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
95357 + if (!strcmp(fnname, kalloc_functions[i]))
95358 + return true;
95359 + return false;
95360 +}
95361 +
95362 +static unsigned int execute_kallocstat(void)
95363 +{
95364 + basic_block bb;
95365 +
95366 + // 1. loop through BBs and GIMPLE statements
95367 + FOR_EACH_BB(bb) {
95368 + gimple_stmt_iterator gsi;
95369 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95370 + // gimple match:
95371 + tree fndecl, size;
95372 + gimple call_stmt;
95373 + const char *fnname;
95374 +
95375 + // is it a call
95376 + call_stmt = gsi_stmt(gsi);
95377 + if (!is_gimple_call(call_stmt))
95378 + continue;
95379 + fndecl = gimple_call_fndecl(call_stmt);
95380 + if (fndecl == NULL_TREE)
95381 + continue;
95382 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
95383 + continue;
95384 +
95385 + // is it a call to k*alloc
95386 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
95387 + if (!is_kalloc(fnname))
95388 + continue;
95389 +
95390 + // is the size arg the result of a simple const assignment
95391 + size = gimple_call_arg(call_stmt, 0);
95392 + while (true) {
95393 + gimple def_stmt;
95394 + expanded_location xloc;
95395 + size_t size_val;
95396 +
95397 + if (TREE_CODE(size) != SSA_NAME)
95398 + break;
95399 + def_stmt = SSA_NAME_DEF_STMT(size);
95400 + if (!def_stmt || !is_gimple_assign(def_stmt))
95401 + break;
95402 + if (gimple_num_ops(def_stmt) != 2)
95403 + break;
95404 + size = gimple_assign_rhs1(def_stmt);
95405 + if (!TREE_CONSTANT(size))
95406 + continue;
95407 + xloc = expand_location(gimple_location(def_stmt));
95408 + if (!xloc.file)
95409 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
95410 + size_val = TREE_INT_CST_LOW(size);
95411 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
95412 + break;
95413 + }
95414 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95415 +//debug_tree(gimple_call_fn(call_stmt));
95416 +//print_node(stderr, "pax", fndecl, 4);
95417 + }
95418 + }
95419 +
95420 + return 0;
95421 +}
95422 +
95423 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95424 +{
95425 + const char * const plugin_name = plugin_info->base_name;
95426 + struct register_pass_info kallocstat_pass_info = {
95427 + .pass = &kallocstat_pass.pass,
95428 + .reference_pass_name = "ssa",
95429 + .ref_pass_instance_number = 1,
95430 + .pos_op = PASS_POS_INSERT_AFTER
95431 + };
95432 +
95433 + if (!plugin_default_version_check(version, &gcc_version)) {
95434 + error(G_("incompatible gcc/plugin versions"));
95435 + return 1;
95436 + }
95437 +
95438 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
95439 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
95440 +
95441 + return 0;
95442 +}
95443 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
95444 new file mode 100644
95445 index 0000000..0408e06
95446 --- /dev/null
95447 +++ b/tools/gcc/kernexec_plugin.c
95448 @@ -0,0 +1,465 @@
95449 +/*
95450 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95451 + * Licensed under the GPL v2
95452 + *
95453 + * Note: the choice of the license means that the compilation process is
95454 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95455 + * but for the kernel it doesn't matter since it doesn't link against
95456 + * any of the gcc libraries
95457 + *
95458 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
95459 + *
95460 + * TODO:
95461 + *
95462 + * BUGS:
95463 + * - none known
95464 + */
95465 +#include "gcc-plugin.h"
95466 +#include "config.h"
95467 +#include "system.h"
95468 +#include "coretypes.h"
95469 +#include "tree.h"
95470 +#include "tree-pass.h"
95471 +#include "flags.h"
95472 +#include "intl.h"
95473 +#include "toplev.h"
95474 +#include "plugin.h"
95475 +//#include "expr.h" where are you...
95476 +#include "diagnostic.h"
95477 +#include "plugin-version.h"
95478 +#include "tm.h"
95479 +#include "function.h"
95480 +#include "basic-block.h"
95481 +#include "gimple.h"
95482 +#include "rtl.h"
95483 +#include "emit-rtl.h"
95484 +#include "tree-flow.h"
95485 +
95486 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95487 +extern rtx emit_move_insn(rtx x, rtx y);
95488 +
95489 +#if BUILDING_GCC_VERSION <= 4006
95490 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
95491 +#endif
95492 +
95493 +#if BUILDING_GCC_VERSION >= 4008
95494 +#define TODO_dump_func 0
95495 +#endif
95496 +
95497 +int plugin_is_GPL_compatible;
95498 +
95499 +static struct plugin_info kernexec_plugin_info = {
95500 + .version = "201302112000",
95501 + .help = "method=[bts|or]\tinstrumentation method\n"
95502 +};
95503 +
95504 +static unsigned int execute_kernexec_reload(void);
95505 +static unsigned int execute_kernexec_fptr(void);
95506 +static unsigned int execute_kernexec_retaddr(void);
95507 +static bool kernexec_cmodel_check(void);
95508 +
95509 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
95510 +static void (*kernexec_instrument_retaddr)(rtx);
95511 +
95512 +static struct gimple_opt_pass kernexec_reload_pass = {
95513 + .pass = {
95514 + .type = GIMPLE_PASS,
95515 + .name = "kernexec_reload",
95516 +#if BUILDING_GCC_VERSION >= 4008
95517 + .optinfo_flags = OPTGROUP_NONE,
95518 +#endif
95519 + .gate = kernexec_cmodel_check,
95520 + .execute = execute_kernexec_reload,
95521 + .sub = NULL,
95522 + .next = NULL,
95523 + .static_pass_number = 0,
95524 + .tv_id = TV_NONE,
95525 + .properties_required = 0,
95526 + .properties_provided = 0,
95527 + .properties_destroyed = 0,
95528 + .todo_flags_start = 0,
95529 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95530 + }
95531 +};
95532 +
95533 +static struct gimple_opt_pass kernexec_fptr_pass = {
95534 + .pass = {
95535 + .type = GIMPLE_PASS,
95536 + .name = "kernexec_fptr",
95537 +#if BUILDING_GCC_VERSION >= 4008
95538 + .optinfo_flags = OPTGROUP_NONE,
95539 +#endif
95540 + .gate = kernexec_cmodel_check,
95541 + .execute = execute_kernexec_fptr,
95542 + .sub = NULL,
95543 + .next = NULL,
95544 + .static_pass_number = 0,
95545 + .tv_id = TV_NONE,
95546 + .properties_required = 0,
95547 + .properties_provided = 0,
95548 + .properties_destroyed = 0,
95549 + .todo_flags_start = 0,
95550 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95551 + }
95552 +};
95553 +
95554 +static struct rtl_opt_pass kernexec_retaddr_pass = {
95555 + .pass = {
95556 + .type = RTL_PASS,
95557 + .name = "kernexec_retaddr",
95558 +#if BUILDING_GCC_VERSION >= 4008
95559 + .optinfo_flags = OPTGROUP_NONE,
95560 +#endif
95561 + .gate = kernexec_cmodel_check,
95562 + .execute = execute_kernexec_retaddr,
95563 + .sub = NULL,
95564 + .next = NULL,
95565 + .static_pass_number = 0,
95566 + .tv_id = TV_NONE,
95567 + .properties_required = 0,
95568 + .properties_provided = 0,
95569 + .properties_destroyed = 0,
95570 + .todo_flags_start = 0,
95571 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
95572 + }
95573 +};
95574 +
95575 +static bool kernexec_cmodel_check(void)
95576 +{
95577 + tree section;
95578 +
95579 + if (ix86_cmodel != CM_KERNEL)
95580 + return false;
95581 +
95582 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
95583 + if (!section || !TREE_VALUE(section))
95584 + return true;
95585 +
95586 + section = TREE_VALUE(TREE_VALUE(section));
95587 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
95588 + return true;
95589 +
95590 + return false;
95591 +}
95592 +
95593 +/*
95594 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
95595 + */
95596 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
95597 +{
95598 + gimple asm_movabs_stmt;
95599 +
95600 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
95601 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
95602 + gimple_asm_set_volatile(asm_movabs_stmt, true);
95603 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
95604 + update_stmt(asm_movabs_stmt);
95605 +}
95606 +
95607 +/*
95608 + * find all asm() stmts that clobber r10 and add a reload of r10
95609 + */
95610 +static unsigned int execute_kernexec_reload(void)
95611 +{
95612 + basic_block bb;
95613 +
95614 + // 1. loop through BBs and GIMPLE statements
95615 + FOR_EACH_BB(bb) {
95616 + gimple_stmt_iterator gsi;
95617 +
95618 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95619 + // gimple match: __asm__ ("" : : : "r10");
95620 + gimple asm_stmt;
95621 + size_t nclobbers;
95622 +
95623 + // is it an asm ...
95624 + asm_stmt = gsi_stmt(gsi);
95625 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
95626 + continue;
95627 +
95628 + // ... clobbering r10
95629 + nclobbers = gimple_asm_nclobbers(asm_stmt);
95630 + while (nclobbers--) {
95631 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
95632 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
95633 + continue;
95634 + kernexec_reload_fptr_mask(&gsi);
95635 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
95636 + break;
95637 + }
95638 + }
95639 + }
95640 +
95641 + return 0;
95642 +}
95643 +
95644 +/*
95645 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
95646 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
95647 + */
95648 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
95649 +{
95650 + gimple assign_intptr, assign_new_fptr, call_stmt;
95651 + tree intptr, old_fptr, new_fptr, kernexec_mask;
95652 +
95653 + call_stmt = gsi_stmt(*gsi);
95654 + old_fptr = gimple_call_fn(call_stmt);
95655 +
95656 + // create temporary unsigned long variable used for bitops and cast fptr to it
95657 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
95658 +#if BUILDING_GCC_VERSION <= 4007
95659 + add_referenced_var(intptr);
95660 + mark_sym_for_renaming(intptr);
95661 +#endif
95662 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
95663 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95664 + update_stmt(assign_intptr);
95665 +
95666 + // apply logical or to temporary unsigned long and bitmask
95667 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
95668 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
95669 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
95670 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95671 + update_stmt(assign_intptr);
95672 +
95673 + // cast temporary unsigned long back to a temporary fptr variable
95674 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
95675 +#if BUILDING_GCC_VERSION <= 4007
95676 + add_referenced_var(new_fptr);
95677 + mark_sym_for_renaming(new_fptr);
95678 +#endif
95679 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
95680 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
95681 + update_stmt(assign_new_fptr);
95682 +
95683 + // replace call stmt fn with the new fptr
95684 + gimple_call_set_fn(call_stmt, new_fptr);
95685 + update_stmt(call_stmt);
95686 +}
95687 +
95688 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
95689 +{
95690 + gimple asm_or_stmt, call_stmt;
95691 + tree old_fptr, new_fptr, input, output;
95692 +#if BUILDING_GCC_VERSION <= 4007
95693 + VEC(tree, gc) *inputs = NULL;
95694 + VEC(tree, gc) *outputs = NULL;
95695 +#else
95696 + vec<tree, va_gc> *inputs = NULL;
95697 + vec<tree, va_gc> *outputs = NULL;
95698 +#endif
95699 +
95700 + call_stmt = gsi_stmt(*gsi);
95701 + old_fptr = gimple_call_fn(call_stmt);
95702 +
95703 + // create temporary fptr variable
95704 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
95705 +#if BUILDING_GCC_VERSION <= 4007
95706 + add_referenced_var(new_fptr);
95707 + mark_sym_for_renaming(new_fptr);
95708 +#endif
95709 +
95710 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
95711 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
95712 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
95713 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
95714 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
95715 +#if BUILDING_GCC_VERSION <= 4007
95716 + VEC_safe_push(tree, gc, inputs, input);
95717 + VEC_safe_push(tree, gc, outputs, output);
95718 +#else
95719 + vec_safe_push(inputs, input);
95720 + vec_safe_push(outputs, output);
95721 +#endif
95722 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
95723 + gimple_asm_set_volatile(asm_or_stmt, true);
95724 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
95725 + update_stmt(asm_or_stmt);
95726 +
95727 + // replace call stmt fn with the new fptr
95728 + gimple_call_set_fn(call_stmt, new_fptr);
95729 + update_stmt(call_stmt);
95730 +}
95731 +
95732 +/*
95733 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
95734 + */
95735 +static unsigned int execute_kernexec_fptr(void)
95736 +{
95737 + basic_block bb;
95738 +
95739 + // 1. loop through BBs and GIMPLE statements
95740 + FOR_EACH_BB(bb) {
95741 + gimple_stmt_iterator gsi;
95742 +
95743 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95744 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
95745 + tree fn;
95746 + gimple call_stmt;
95747 +
95748 + // is it a call ...
95749 + call_stmt = gsi_stmt(gsi);
95750 + if (!is_gimple_call(call_stmt))
95751 + continue;
95752 + fn = gimple_call_fn(call_stmt);
95753 + if (TREE_CODE(fn) == ADDR_EXPR)
95754 + continue;
95755 + if (TREE_CODE(fn) != SSA_NAME)
95756 + gcc_unreachable();
95757 +
95758 + // ... through a function pointer
95759 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
95760 + fn = SSA_NAME_VAR(fn);
95761 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
95762 + debug_tree(fn);
95763 + gcc_unreachable();
95764 + }
95765 + }
95766 + fn = TREE_TYPE(fn);
95767 + if (TREE_CODE(fn) != POINTER_TYPE)
95768 + continue;
95769 + fn = TREE_TYPE(fn);
95770 + if (TREE_CODE(fn) != FUNCTION_TYPE)
95771 + continue;
95772 +
95773 + kernexec_instrument_fptr(&gsi);
95774 +
95775 +//debug_tree(gimple_call_fn(call_stmt));
95776 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95777 + }
95778 + }
95779 +
95780 + return 0;
95781 +}
95782 +
95783 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
95784 +static void kernexec_instrument_retaddr_bts(rtx insn)
95785 +{
95786 + rtx btsq;
95787 + rtvec argvec, constraintvec, labelvec;
95788 + int line;
95789 +
95790 + // create asm volatile("btsq $63,(%%rsp)":::)
95791 + argvec = rtvec_alloc(0);
95792 + constraintvec = rtvec_alloc(0);
95793 + labelvec = rtvec_alloc(0);
95794 + line = expand_location(RTL_LOCATION(insn)).line;
95795 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95796 + MEM_VOLATILE_P(btsq) = 1;
95797 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
95798 + emit_insn_before(btsq, insn);
95799 +}
95800 +
95801 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
95802 +static void kernexec_instrument_retaddr_or(rtx insn)
95803 +{
95804 + rtx orq;
95805 + rtvec argvec, constraintvec, labelvec;
95806 + int line;
95807 +
95808 + // create asm volatile("orq %%r10,(%%rsp)":::)
95809 + argvec = rtvec_alloc(0);
95810 + constraintvec = rtvec_alloc(0);
95811 + labelvec = rtvec_alloc(0);
95812 + line = expand_location(RTL_LOCATION(insn)).line;
95813 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95814 + MEM_VOLATILE_P(orq) = 1;
95815 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
95816 + emit_insn_before(orq, insn);
95817 +}
95818 +
95819 +/*
95820 + * find all asm level function returns and forcibly set the highest bit of the return address
95821 + */
95822 +static unsigned int execute_kernexec_retaddr(void)
95823 +{
95824 + rtx insn;
95825 +
95826 + // 1. find function returns
95827 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
95828 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
95829 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
95830 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
95831 + rtx body;
95832 +
95833 + // is it a retn
95834 + if (!JUMP_P(insn))
95835 + continue;
95836 + body = PATTERN(insn);
95837 + if (GET_CODE(body) == PARALLEL)
95838 + body = XVECEXP(body, 0, 0);
95839 + if (!ANY_RETURN_P(body))
95840 + continue;
95841 + kernexec_instrument_retaddr(insn);
95842 + }
95843 +
95844 +// print_simple_rtl(stderr, get_insns());
95845 +// print_rtl(stderr, get_insns());
95846 +
95847 + return 0;
95848 +}
95849 +
95850 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95851 +{
95852 + const char * const plugin_name = plugin_info->base_name;
95853 + const int argc = plugin_info->argc;
95854 + const struct plugin_argument * const argv = plugin_info->argv;
95855 + int i;
95856 + struct register_pass_info kernexec_reload_pass_info = {
95857 + .pass = &kernexec_reload_pass.pass,
95858 + .reference_pass_name = "ssa",
95859 + .ref_pass_instance_number = 1,
95860 + .pos_op = PASS_POS_INSERT_AFTER
95861 + };
95862 + struct register_pass_info kernexec_fptr_pass_info = {
95863 + .pass = &kernexec_fptr_pass.pass,
95864 + .reference_pass_name = "ssa",
95865 + .ref_pass_instance_number = 1,
95866 + .pos_op = PASS_POS_INSERT_AFTER
95867 + };
95868 + struct register_pass_info kernexec_retaddr_pass_info = {
95869 + .pass = &kernexec_retaddr_pass.pass,
95870 + .reference_pass_name = "pro_and_epilogue",
95871 + .ref_pass_instance_number = 1,
95872 + .pos_op = PASS_POS_INSERT_AFTER
95873 + };
95874 +
95875 + if (!plugin_default_version_check(version, &gcc_version)) {
95876 + error(G_("incompatible gcc/plugin versions"));
95877 + return 1;
95878 + }
95879 +
95880 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
95881 +
95882 + if (TARGET_64BIT == 0)
95883 + return 0;
95884 +
95885 + for (i = 0; i < argc; ++i) {
95886 + if (!strcmp(argv[i].key, "method")) {
95887 + if (!argv[i].value) {
95888 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95889 + continue;
95890 + }
95891 + if (!strcmp(argv[i].value, "bts")) {
95892 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
95893 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
95894 + } else if (!strcmp(argv[i].value, "or")) {
95895 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
95896 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
95897 + fix_register("r10", 1, 1);
95898 + } else
95899 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
95900 + continue;
95901 + }
95902 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95903 + }
95904 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
95905 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
95906 +
95907 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
95908 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
95909 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
95910 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
95911 +
95912 + return 0;
95913 +}
95914 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
95915 new file mode 100644
95916 index 0000000..b5395ba
95917 --- /dev/null
95918 +++ b/tools/gcc/latent_entropy_plugin.c
95919 @@ -0,0 +1,327 @@
95920 +/*
95921 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
95922 + * Licensed under the GPL v2
95923 + *
95924 + * Note: the choice of the license means that the compilation process is
95925 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95926 + * but for the kernel it doesn't matter since it doesn't link against
95927 + * any of the gcc libraries
95928 + *
95929 + * gcc plugin to help generate a little bit of entropy from program state,
95930 + * used during boot in the kernel
95931 + *
95932 + * TODO:
95933 + * - add ipa pass to identify not explicitly marked candidate functions
95934 + * - mix in more program state (function arguments/return values, loop variables, etc)
95935 + * - more instrumentation control via attribute parameters
95936 + *
95937 + * BUGS:
95938 + * - LTO needs -flto-partition=none for now
95939 + */
95940 +#include "gcc-plugin.h"
95941 +#include "config.h"
95942 +#include "system.h"
95943 +#include "coretypes.h"
95944 +#include "tree.h"
95945 +#include "tree-pass.h"
95946 +#include "flags.h"
95947 +#include "intl.h"
95948 +#include "toplev.h"
95949 +#include "plugin.h"
95950 +//#include "expr.h" where are you...
95951 +#include "diagnostic.h"
95952 +#include "plugin-version.h"
95953 +#include "tm.h"
95954 +#include "function.h"
95955 +#include "basic-block.h"
95956 +#include "gimple.h"
95957 +#include "rtl.h"
95958 +#include "emit-rtl.h"
95959 +#include "tree-flow.h"
95960 +#include "langhooks.h"
95961 +
95962 +#if BUILDING_GCC_VERSION >= 4008
95963 +#define TODO_dump_func 0
95964 +#endif
95965 +
95966 +int plugin_is_GPL_compatible;
95967 +
95968 +static tree latent_entropy_decl;
95969 +
95970 +static struct plugin_info latent_entropy_plugin_info = {
95971 + .version = "201303102320",
95972 + .help = NULL
95973 +};
95974 +
95975 +static unsigned int execute_latent_entropy(void);
95976 +static bool gate_latent_entropy(void);
95977 +
95978 +static struct gimple_opt_pass latent_entropy_pass = {
95979 + .pass = {
95980 + .type = GIMPLE_PASS,
95981 + .name = "latent_entropy",
95982 +#if BUILDING_GCC_VERSION >= 4008
95983 + .optinfo_flags = OPTGROUP_NONE,
95984 +#endif
95985 + .gate = gate_latent_entropy,
95986 + .execute = execute_latent_entropy,
95987 + .sub = NULL,
95988 + .next = NULL,
95989 + .static_pass_number = 0,
95990 + .tv_id = TV_NONE,
95991 + .properties_required = PROP_gimple_leh | PROP_cfg,
95992 + .properties_provided = 0,
95993 + .properties_destroyed = 0,
95994 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95995 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95996 + }
95997 +};
95998 +
95999 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
96000 +{
96001 + if (TREE_CODE(*node) != FUNCTION_DECL) {
96002 + *no_add_attrs = true;
96003 + error("%qE attribute only applies to functions", name);
96004 + }
96005 + return NULL_TREE;
96006 +}
96007 +
96008 +static struct attribute_spec latent_entropy_attr = {
96009 + .name = "latent_entropy",
96010 + .min_length = 0,
96011 + .max_length = 0,
96012 + .decl_required = true,
96013 + .type_required = false,
96014 + .function_type_required = false,
96015 + .handler = handle_latent_entropy_attribute,
96016 +#if BUILDING_GCC_VERSION >= 4007
96017 + .affects_type_identity = false
96018 +#endif
96019 +};
96020 +
96021 +static void register_attributes(void *event_data, void *data)
96022 +{
96023 + register_attribute(&latent_entropy_attr);
96024 +}
96025 +
96026 +static bool gate_latent_entropy(void)
96027 +{
96028 + tree latent_entropy_attr;
96029 +
96030 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
96031 + return latent_entropy_attr != NULL_TREE;
96032 +}
96033 +
96034 +static unsigned HOST_WIDE_INT seed;
96035 +static unsigned HOST_WIDE_INT get_random_const(void)
96036 +{
96037 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
96038 + return seed;
96039 +}
96040 +
96041 +static enum tree_code get_op(tree *rhs)
96042 +{
96043 + static enum tree_code op;
96044 + unsigned HOST_WIDE_INT random_const;
96045 +
96046 + random_const = get_random_const();
96047 +
96048 + switch (op) {
96049 + case BIT_XOR_EXPR:
96050 + op = PLUS_EXPR;
96051 + break;
96052 +
96053 + case PLUS_EXPR:
96054 + if (rhs) {
96055 + op = LROTATE_EXPR;
96056 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
96057 + break;
96058 + }
96059 +
96060 + case LROTATE_EXPR:
96061 + default:
96062 + op = BIT_XOR_EXPR;
96063 + break;
96064 + }
96065 + if (rhs)
96066 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
96067 + return op;
96068 +}
96069 +
96070 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
96071 +{
96072 + gimple_stmt_iterator gsi;
96073 + gimple assign;
96074 + tree addxorrol, rhs;
96075 + enum tree_code op;
96076 +
96077 + op = get_op(&rhs);
96078 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
96079 + assign = gimple_build_assign(local_entropy, addxorrol);
96080 +#if BUILDING_GCC_VERSION <= 4007
96081 + find_referenced_vars_in(assign);
96082 +#endif
96083 +//debug_bb(bb);
96084 + gsi = gsi_after_labels(bb);
96085 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
96086 + update_stmt(assign);
96087 +}
96088 +
96089 +static void perturb_latent_entropy(basic_block bb, tree rhs)
96090 +{
96091 + gimple_stmt_iterator gsi;
96092 + gimple assign;
96093 + tree addxorrol, temp;
96094 +
96095 + // 1. create temporary copy of latent_entropy
96096 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
96097 +#if BUILDING_GCC_VERSION <= 4007
96098 + add_referenced_var(temp);
96099 + mark_sym_for_renaming(temp);
96100 +#endif
96101 +
96102 + // 2. read...
96103 + assign = gimple_build_assign(temp, latent_entropy_decl);
96104 +#if BUILDING_GCC_VERSION <= 4007
96105 + find_referenced_vars_in(assign);
96106 +#endif
96107 + gsi = gsi_after_labels(bb);
96108 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96109 + update_stmt(assign);
96110 +
96111 + // 3. ...modify...
96112 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
96113 + assign = gimple_build_assign(temp, addxorrol);
96114 +#if BUILDING_GCC_VERSION <= 4007
96115 + find_referenced_vars_in(assign);
96116 +#endif
96117 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96118 + update_stmt(assign);
96119 +
96120 + // 4. ...write latent_entropy
96121 + assign = gimple_build_assign(latent_entropy_decl, temp);
96122 +#if BUILDING_GCC_VERSION <= 4007
96123 + find_referenced_vars_in(assign);
96124 +#endif
96125 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96126 + update_stmt(assign);
96127 +}
96128 +
96129 +static unsigned int execute_latent_entropy(void)
96130 +{
96131 + basic_block bb;
96132 + gimple assign;
96133 + gimple_stmt_iterator gsi;
96134 + tree local_entropy;
96135 +
96136 + if (!latent_entropy_decl) {
96137 + struct varpool_node *node;
96138 +
96139 +#if BUILDING_GCC_VERSION <= 4007
96140 + for (node = varpool_nodes; node; node = node->next) {
96141 + tree var = node->decl;
96142 +#else
96143 + FOR_EACH_VARIABLE(node) {
96144 + tree var = node->symbol.decl;
96145 +#endif
96146 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
96147 + continue;
96148 + latent_entropy_decl = var;
96149 +// debug_tree(var);
96150 + break;
96151 + }
96152 + if (!latent_entropy_decl) {
96153 +// debug_tree(current_function_decl);
96154 + return 0;
96155 + }
96156 + }
96157 +
96158 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
96159 +
96160 + // 1. create local entropy variable
96161 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
96162 +#if BUILDING_GCC_VERSION <= 4007
96163 + add_referenced_var(local_entropy);
96164 + mark_sym_for_renaming(local_entropy);
96165 +#endif
96166 +
96167 + // 2. initialize local entropy variable
96168 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
96169 + if (dom_info_available_p(CDI_DOMINATORS))
96170 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
96171 + gsi = gsi_start_bb(bb);
96172 +
96173 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
96174 +// gimple_set_location(assign, loc);
96175 +#if BUILDING_GCC_VERSION <= 4007
96176 + find_referenced_vars_in(assign);
96177 +#endif
96178 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
96179 + update_stmt(assign);
96180 + bb = bb->next_bb;
96181 +
96182 + // 3. instrument each BB with an operation on the local entropy variable
96183 + while (bb != EXIT_BLOCK_PTR) {
96184 + perturb_local_entropy(bb, local_entropy);
96185 + bb = bb->next_bb;
96186 + };
96187 +
96188 + // 4. mix local entropy into the global entropy variable
96189 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
96190 + return 0;
96191 +}
96192 +
96193 +static void start_unit_callback(void *gcc_data, void *user_data)
96194 +{
96195 + tree latent_entropy_type;
96196 +
96197 +#if BUILDING_GCC_VERSION >= 4007
96198 + seed = get_random_seed(false);
96199 +#else
96200 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
96201 + seed *= seed;
96202 +#endif
96203 +
96204 + if (in_lto_p)
96205 + return;
96206 +
96207 + // extern volatile u64 latent_entropy
96208 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
96209 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
96210 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
96211 +
96212 + TREE_STATIC(latent_entropy_decl) = 1;
96213 + TREE_PUBLIC(latent_entropy_decl) = 1;
96214 + TREE_USED(latent_entropy_decl) = 1;
96215 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
96216 + DECL_EXTERNAL(latent_entropy_decl) = 1;
96217 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
96218 + DECL_INITIAL(latent_entropy_decl) = NULL;
96219 + lang_hooks.decls.pushdecl(latent_entropy_decl);
96220 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
96221 +// varpool_finalize_decl(latent_entropy_decl);
96222 +// varpool_mark_needed_node(latent_entropy_decl);
96223 +}
96224 +
96225 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96226 +{
96227 + const char * const plugin_name = plugin_info->base_name;
96228 + struct register_pass_info latent_entropy_pass_info = {
96229 + .pass = &latent_entropy_pass.pass,
96230 + .reference_pass_name = "optimized",
96231 + .ref_pass_instance_number = 1,
96232 + .pos_op = PASS_POS_INSERT_BEFORE
96233 + };
96234 +
96235 + if (!plugin_default_version_check(version, &gcc_version)) {
96236 + error(G_("incompatible gcc/plugin versions"));
96237 + return 1;
96238 + }
96239 +
96240 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
96241 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
96242 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
96243 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
96244 +
96245 + return 0;
96246 +}
96247 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
96248 new file mode 100644
96249 index 0000000..7982a0c
96250 --- /dev/null
96251 +++ b/tools/gcc/size_overflow_hash.data
96252 @@ -0,0 +1,5893 @@
96253 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
96254 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
96255 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
96256 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
96257 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
96258 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
96259 +padzero_55 padzero 1 55 &sel_read_policyvers_55
96260 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
96261 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
96262 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
96263 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
96264 +load_msg_95 load_msg 2 95 NULL
96265 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
96266 +init_q_132 init_q 4 132 NULL
96267 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
96268 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
96269 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
96270 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
96271 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
96272 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
96273 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
96274 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
96275 +br_port_info_size_268 br_port_info_size 0 268 NULL
96276 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
96277 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
96278 +syslog_print_307 syslog_print 2 307 NULL
96279 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
96280 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
96281 +next_node_allowed_318 next_node_allowed 1 318 NULL
96282 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
96283 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
96284 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
96285 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
96286 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
96287 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
96288 +pidlist_resize_496 pidlist_resize 2 496 NULL
96289 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
96290 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
96291 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
96292 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
96293 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
96294 +dle_count_543 dle_count 0 543 NULL
96295 +devres_alloc_551 devres_alloc 2 551 NULL
96296 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
96297 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
96298 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
96299 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
96300 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
96301 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
96302 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
96303 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
96304 +isp1760_register_628 isp1760_register 1-2 628 NULL
96305 +clone_split_bio_633 clone_split_bio 6 633 NULL
96306 +remap_to_cache_640 remap_to_cache 3 640 NULL
96307 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
96308 +unlink_queued_645 unlink_queued 3-4 645 NULL
96309 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
96310 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
96311 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
96312 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
96313 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
96314 +disk_max_parts_719 disk_max_parts 0 719 NULL
96315 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
96316 +dvb_video_write_754 dvb_video_write 3 754 NULL
96317 +if_writecmd_815 if_writecmd 2 815 NULL
96318 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
96319 +read_fifo_826 read_fifo 3 826 NULL
96320 +um_idi_read_850 um_idi_read 3 850 NULL
96321 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
96322 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
96323 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
96324 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
96325 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
96326 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
96327 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
96328 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
96329 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
96330 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
96331 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
96332 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
96333 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
96334 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
96335 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
96336 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
96337 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
96338 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
96339 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
96340 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
96341 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
96342 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
96343 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
96344 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
96345 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
96346 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
96347 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
96348 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
96349 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
96350 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
96351 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
96352 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
96353 +nested_get_page_1252 nested_get_page 2 1252 NULL
96354 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
96355 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
96356 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
96357 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
96358 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
96359 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
96360 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
96361 +ffs_1322 ffs 0 1322 NULL
96362 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
96363 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
96364 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
96365 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
96366 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
96367 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
96368 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
96369 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
96370 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
96371 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
96372 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
96373 +zone_page_state_1393 zone_page_state 0 1393 NULL
96374 +file_read_actor_1401 file_read_actor 4 1401 NULL
96375 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
96376 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
96377 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
96378 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
96379 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
96380 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
96381 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
96382 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
96383 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
96384 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
96385 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
96386 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
96387 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
96388 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
96389 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
96390 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
96391 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
96392 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
96393 +rmap_add_1677 rmap_add 3 1677 NULL
96394 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
96395 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
96396 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
96397 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
96398 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
96399 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
96400 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
96401 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
96402 +cosa_write_1774 cosa_write 3 1774 NULL
96403 +update_macheader_1775 update_macheader 7 1775 NULL
96404 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
96405 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
96406 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
96407 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
96408 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
96409 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
96410 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
96411 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
96412 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
96413 +read_swap_header_1957 read_swap_header 0 1957 NULL
96414 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
96415 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
96416 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
96417 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
96418 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
96419 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
96420 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
96421 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
96422 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
96423 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
96424 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
96425 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
96426 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
96427 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
96428 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
96429 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
96430 +audit_expand_2098 audit_expand 2 2098 NULL
96431 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
96432 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
96433 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
96434 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
96435 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
96436 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
96437 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
96438 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
96439 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
96440 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
96441 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
96442 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
96443 +u32_array_read_2219 u32_array_read 3 2219 NULL
96444 +vhci_write_2224 vhci_write 3 2224 NULL
96445 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
96446 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
96447 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
96448 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
96449 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
96450 +do_update_counters_2259 do_update_counters 4 2259 NULL
96451 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
96452 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
96453 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
96454 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
96455 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
96456 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
96457 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
96458 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
96459 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
96460 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
96461 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
96462 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
96463 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
96464 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
96465 +raid1_size_2419 raid1_size 0-2 2419 NULL
96466 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
96467 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
96468 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
96469 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
96470 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
96471 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
96472 +update_pmkid_2481 update_pmkid 4 2481 NULL
96473 +wiphy_new_2482 wiphy_new 2 2482 NULL
96474 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
96475 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
96476 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
96477 +dm_write_2513 dm_write 3 2513 NULL
96478 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
96479 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
96480 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
96481 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
96482 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
96483 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
96484 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
96485 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
96486 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
96487 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
96488 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
96489 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
96490 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
96491 +__next_cpu_2782 __next_cpu 1 2782 NULL
96492 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
96493 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
96494 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
96495 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
96496 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
96497 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
96498 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
96499 +mq_map_2871 mq_map 2 2871 NULL
96500 +nla_padlen_2883 nla_padlen 1 2883 NULL
96501 +cmm_write_2896 cmm_write 3 2896 NULL
96502 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
96503 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
96504 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
96505 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
96506 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
96507 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
96508 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
96509 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
96510 +depth_write_3021 depth_write 3 3021 NULL
96511 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
96512 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
96513 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
96514 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
96515 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
96516 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
96517 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
96518 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
96519 +free_coherent_3082 free_coherent 4-2 3082 NULL
96520 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
96521 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
96522 +rb_alloc_3102 rb_alloc 1 3102 NULL
96523 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
96524 +print_time_3132 print_time 0 3132 NULL
96525 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
96526 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
96527 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
96528 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
96529 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
96530 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
96531 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
96532 +alloc_context_3194 alloc_context 1 3194 NULL
96533 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
96534 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
96535 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
96536 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
96537 +key_key_read_3241 key_key_read 3 3241 NULL
96538 +number_3243 number 0 3243 NULL
96539 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
96540 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
96541 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
96542 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
96543 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
96544 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
96545 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
96546 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
96547 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
96548 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
96549 +scnprintf_3360 scnprintf 0-2 3360 NULL
96550 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
96551 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
96552 +send_stream_3397 send_stream 4 3397 NULL
96553 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
96554 +msix_map_region_3411 msix_map_region 3 3411 NULL
96555 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
96556 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
96557 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
96558 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
96559 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
96560 +map_single_3449 map_single 0-2 3449 NULL
96561 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
96562 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
96563 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
96564 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
96565 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
96566 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
96567 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
96568 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
96569 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
96570 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
96571 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
96572 +evtchn_read_3569 evtchn_read 3 3569 NULL
96573 +vc_resize_3585 vc_resize 2-3 3585 NULL
96574 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
96575 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
96576 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
96577 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
96578 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
96579 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 NULL
96580 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
96581 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
96582 +create_irq_3703 create_irq 0 3703 NULL nohasharray
96583 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
96584 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
96585 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
96586 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
96587 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
96588 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
96589 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
96590 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
96591 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
96592 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
96593 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
96594 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
96595 +get_fd_set_3866 get_fd_set 1 3866 NULL
96596 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
96597 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
96598 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
96599 +nvram_write_3894 nvram_write 3 3894 NULL
96600 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
96601 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
96602 +vcs_write_3910 vcs_write 3 3910 NULL
96603 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
96604 +do_add_counters_3992 do_add_counters 3 3992 NULL
96605 +userspace_status_4004 userspace_status 4 4004 NULL
96606 +mei_write_4005 mei_write 3 4005 NULL nohasharray
96607 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
96608 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
96609 +mm_populate_4016 mm_populate 1 4016 NULL
96610 +blk_end_request_4024 blk_end_request 3 4024 NULL
96611 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
96612 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
96613 +read_file_queues_4078 read_file_queues 3 4078 NULL
96614 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
96615 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
96616 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
96617 +tm6000_read_4151 tm6000_read 3 4151 NULL
96618 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
96619 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
96620 +get_alua_req_4166 get_alua_req 3 4166 NULL
96621 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
96622 +read_file_bool_4180 read_file_bool 3 4180 NULL
96623 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
96624 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
96625 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
96626 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
96627 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
96628 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
96629 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
96630 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
96631 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
96632 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
96633 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
96634 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
96635 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
96636 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
96637 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
96638 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
96639 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
96640 +memparse_4444 memparse 0 4444 NULL
96641 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
96642 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
96643 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
96644 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
96645 +set_link_security_4502 set_link_security 4 4502 NULL
96646 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
96647 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
96648 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
96649 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
96650 +tty_register_device_4544 tty_register_device 2 4544 NULL
96651 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
96652 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
96653 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
96654 +bch_alloc_4593 bch_alloc 1 4593 NULL
96655 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
96656 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
96657 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
96658 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
96659 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
96660 +kone_receive_4690 kone_receive 4 4690 NULL
96661 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
96662 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
96663 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
96664 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
96665 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
96666 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
96667 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
96668 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
96669 +create_subvol_4791 create_subvol 4 4791 NULL
96670 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
96671 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
96672 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
96673 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
96674 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
96675 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
96676 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
96677 +sys_ipc_4889 sys_ipc 3 4889 NULL
96678 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
96679 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
96680 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
96681 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
96682 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
96683 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
96684 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
96685 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
96686 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
96687 +do_mincore_5018 do_mincore 0-1 5018 NULL
96688 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
96689 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
96690 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
96691 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
96692 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
96693 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
96694 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
96695 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
96696 +sound_write_5102 sound_write 3 5102 NULL
96697 +clear_dirty_5105 clear_dirty 3 5105 NULL
96698 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
96699 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
96700 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
96701 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
96702 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
96703 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
96704 +skb_network_header_5203 skb_network_header 0 5203 NULL
96705 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
96706 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
96707 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
96708 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
96709 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
96710 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
96711 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
96712 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
96713 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
96714 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
96715 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
96716 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
96717 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
96718 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
96719 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
96720 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
96721 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
96722 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
96723 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
96724 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
96725 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
96726 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
96727 +tty_write_5494 tty_write 3 5494 NULL
96728 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
96729 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
96730 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
96731 +spidev_message_5518 spidev_message 3 5518 NULL
96732 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
96733 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
96734 +le_readq_5557 le_readq 0 5557 NULL
96735 +inw_5558 inw 0 5558 NULL
96736 +fir16_create_5574 fir16_create 3 5574 NULL
96737 +bioset_create_5580 bioset_create 1 5580 NULL
96738 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
96739 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
96740 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
96741 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
96742 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
96743 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
96744 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
96745 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
96746 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
96747 +get_arg_5694 get_arg 3 5694 NULL
96748 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
96749 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
96750 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
96751 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
96752 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
96753 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
96754 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
96755 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
96756 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
96757 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
96758 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
96759 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
96760 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
96761 +setup_req_5848 setup_req 3 5848 NULL
96762 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
96763 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
96764 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
96765 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
96766 +port_show_regs_5904 port_show_regs 3 5904 NULL
96767 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
96768 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
96769 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
96770 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
96771 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
96772 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
96773 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
96774 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
96775 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
96776 +native_pte_val_5978 native_pte_val 0 5978 NULL
96777 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
96778 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
96779 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
96780 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
96781 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
96782 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
96783 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
96784 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
96785 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
96786 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
96787 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
96788 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
96789 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
96790 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
96791 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
96792 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
96793 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
96794 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
96795 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
96796 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
96797 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
96798 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
96799 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
96800 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
96801 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
96802 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
96803 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
96804 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
96805 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
96806 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
96807 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
96808 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
96809 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
96810 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
96811 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
96812 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
96813 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
96814 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
96815 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
96816 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
96817 +mei_read_6507 mei_read 3 6507 NULL
96818 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
96819 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
96820 +wdm_read_6549 wdm_read 3 6549 NULL
96821 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
96822 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
96823 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
96824 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
96825 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
96826 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
96827 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
96828 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
96829 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
96830 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
96831 +mpeg_read_6708 mpeg_read 3 6708 NULL
96832 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
96833 +video_proc_write_6724 video_proc_write 3 6724 NULL
96834 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
96835 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
96836 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
96837 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
96838 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
96839 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
96840 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
96841 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
96842 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
96843 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
96844 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
96845 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
96846 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
96847 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
96848 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
96849 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
96850 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
96851 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
96852 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
96853 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
96854 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
96855 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
96856 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
96857 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
96858 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
96859 +request_key_async_6990 request_key_async 4 6990 NULL
96860 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
96861 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
96862 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
96863 +wimax_msg_7030 wimax_msg 4 7030 NULL
96864 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
96865 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
96866 +event_enable_read_7074 event_enable_read 3 7074 NULL
96867 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
96868 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
96869 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
96870 +check_header_7108 check_header 0 7108 NULL
96871 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
96872 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
96873 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
96874 +get_param_h_7247 get_param_h 0 7247 NULL
96875 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
96876 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
96877 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
96878 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
96879 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
96880 +mgmt_control_7349 mgmt_control 3 7349 NULL
96881 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
96882 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
96883 +hweight_long_7388 hweight_long 0-1 7388 NULL
96884 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
96885 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
96886 +readb_7401 readb 0 7401 NULL
96887 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
96888 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
96889 +numa_emulation_7466 numa_emulation 2 7466 NULL
96890 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
96891 +garp_request_join_7471 garp_request_join 4 7471 NULL
96892 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
96893 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
96894 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
96895 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
96896 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
96897 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
96898 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
96899 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
96900 +groups_alloc_7614 groups_alloc 1 7614 NULL
96901 +sg_virt_7616 sg_virt 0 7616 NULL
96902 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
96903 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
96904 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
96905 +dev_write_7708 dev_write 3 7708 NULL
96906 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
96907 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
96908 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
96909 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
96910 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
96911 +ioread32be_7773 ioread32be 0 7773 NULL
96912 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
96913 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
96914 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
96915 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
96916 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
96917 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
96918 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
96919 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
96920 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
96921 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
96922 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
96923 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
96924 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
96925 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
96926 +sys_mbind_7990 sys_mbind 5 7990 NULL
96927 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
96928 +vcs_read_8017 vcs_read 3 8017 NULL
96929 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
96930 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
96931 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
96932 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
96933 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
96934 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
96935 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
96936 +venus_lookup_8121 venus_lookup 4 8121 NULL
96937 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
96938 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
96939 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
96940 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
96941 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
96942 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
96943 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
96944 +play_iframe_8219 play_iframe 3 8219 NULL
96945 +create_log_8225 create_log 2 8225 NULL nohasharray
96946 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
96947 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
96948 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
96949 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
96950 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
96951 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
96952 +init_cdev_8274 init_cdev 1 8274 NULL
96953 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
96954 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
96955 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
96956 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
96957 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
96958 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
96959 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
96960 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
96961 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
96962 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
96963 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
96964 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
96965 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
96966 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96967 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96968 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96969 +dev_config_8506 dev_config 3 8506 NULL
96970 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96971 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96972 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96973 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96974 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96975 +profile_remove_8556 profile_remove 3 8556 NULL
96976 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96977 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96978 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96979 +tower_write_8580 tower_write 3 8580 NULL
96980 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96981 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96982 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96983 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96984 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96985 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96986 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96987 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96988 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96989 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96990 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96991 +arcfb_write_8702 arcfb_write 3 8702 NULL
96992 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96993 +init_header_8703 init_header 0 8703 &i_size_read_8703
96994 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96995 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
96996 +f_dupfd_8730 f_dupfd 1 8730 NULL
96997 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
96998 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
96999 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
97000 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
97001 +sys_prctl_8766 sys_prctl 4 8766 NULL
97002 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
97003 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
97004 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
97005 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
97006 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
97007 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
97008 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
97009 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
97010 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
97011 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
97012 +clear_bitset_8840 clear_bitset 2 8840 NULL
97013 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
97014 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
97015 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
97016 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
97017 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
97018 +layout_commit_8926 layout_commit 3 8926 NULL
97019 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
97020 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
97021 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
97022 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
97023 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
97024 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
97025 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
97026 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
97027 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
97028 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
97029 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
97030 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
97031 +nla_put_9042 nla_put 3 9042 NULL
97032 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
97033 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
97034 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
97035 +string_9080 string 0 9080 NULL
97036 +create_queues_9088 create_queues 2-3 9088 NULL
97037 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
97038 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
97039 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
97040 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
97041 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
97042 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
97043 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
97044 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
97045 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
97046 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
97047 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
97048 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
97049 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
97050 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
97051 +get_pfn_9207 get_pfn 1 9207 NULL
97052 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
97053 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
97054 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
97055 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
97056 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
97057 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
97058 +flakey_status_9274 flakey_status 5 9274 NULL
97059 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
97060 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
97061 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
97062 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
97063 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
97064 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
97065 +read_9397 read 3 9397 NULL
97066 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
97067 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
97068 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
97069 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
97070 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
97071 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
97072 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
97073 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
97074 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
97075 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
97076 +lp_write_9511 lp_write 3 9511 NULL
97077 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
97078 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
97079 +read_file_dma_9530 read_file_dma 3 9530 NULL
97080 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
97081 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
97082 +fw_node_create_9559 fw_node_create 2 9559 NULL
97083 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
97084 +kobj_map_9566 kobj_map 2-3 9566 NULL
97085 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
97086 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
97087 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
97088 +do_sync_9604 do_sync 1 9604 NULL
97089 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
97090 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
97091 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
97092 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
97093 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
97094 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
97095 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
97096 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
97097 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
97098 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
97099 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
97100 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
97101 +is_hole_9694 is_hole 2 9694 NULL nohasharray
97102 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
97103 +fnb_9703 fnb 2-3 9703 NULL
97104 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
97105 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
97106 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
97107 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
97108 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
97109 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
97110 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
97111 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
97112 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
97113 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
97114 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
97115 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
97116 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
97117 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
97118 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
97119 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
97120 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
97121 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
97122 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
97123 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
97124 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
97125 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
97126 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
97127 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
97128 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
97129 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
97130 +read_file_misc_9948 read_file_misc 3 9948 NULL
97131 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
97132 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
97133 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
97134 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
97135 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
97136 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
97137 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
97138 +handle_request_10024 handle_request 9 10024 NULL
97139 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
97140 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
97141 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
97142 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
97143 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
97144 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
97145 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
97146 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
97147 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
97148 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
97149 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
97150 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
97151 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
97152 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
97153 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
97154 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
97155 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
97156 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
97157 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
97158 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
97159 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
97160 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
97161 +read_emulate_10310 read_emulate 2-4 10310 NULL
97162 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
97163 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
97164 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
97165 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
97166 +get_dump_page_10338 get_dump_page 1 10338 NULL
97167 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
97168 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
97169 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
97170 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
97171 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
97172 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
97173 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
97174 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
97175 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
97176 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
97177 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
97178 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
97179 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
97180 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
97181 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
97182 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
97183 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
97184 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
97185 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
97186 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
97187 +otp_read_10594 otp_read 2-4-5 10594 NULL
97188 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
97189 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
97190 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
97191 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
97192 +parport_write_10669 parport_write 0 10669 NULL
97193 +inl_10708 inl 0 10708 NULL nohasharray
97194 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
97195 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
97196 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
97197 +spi_sync_10731 spi_sync 0 10731 NULL
97198 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
97199 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
97200 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
97201 +sys_syslog_10746 sys_syslog 3 10746 NULL
97202 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
97203 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
97204 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
97205 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
97206 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
97207 +sys_bind_10799 sys_bind 3 10799 NULL
97208 +compat_put_int_10828 compat_put_int 1 10828 NULL
97209 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
97210 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
97211 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
97212 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
97213 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
97214 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
97215 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
97216 +get_scq_10897 get_scq 2 10897 NULL
97217 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
97218 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
97219 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
97220 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
97221 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
97222 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
97223 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
97224 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
97225 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
97226 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
97227 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
97228 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
97229 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
97230 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
97231 +count_argc_11083 count_argc 0 11083 NULL
97232 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
97233 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
97234 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
97235 +page_offset_11120 page_offset 0 11120 NULL
97236 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
97237 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
97238 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
97239 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
97240 +__swab16p_11220 __swab16p 0 11220 NULL
97241 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
97242 +mmap_region_11247 mmap_region 0-2 11247 NULL
97243 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
97244 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
97245 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
97246 +cru_detect_11272 cru_detect 1 11272 NULL
97247 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
97248 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
97249 +construct_key_11329 construct_key 3 11329 NULL nohasharray
97250 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
97251 +next_segment_11330 next_segment 0-2-1 11330 NULL
97252 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
97253 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
97254 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
97255 +sel_write_create_11353 sel_write_create 3 11353 NULL
97256 +handle_unit_11355 handle_unit 0-1 11355 NULL
97257 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
97258 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
97259 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
97260 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
97261 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
97262 +str_to_user_11411 str_to_user 2 11411 NULL
97263 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
97264 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
97265 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
97266 +trace_options_read_11419 trace_options_read 3 11419 NULL
97267 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
97268 +prepare_image_11424 prepare_image 0 11424 NULL
97269 +vring_size_11426 vring_size 0-1-2 11426 NULL
97270 +bttv_read_11432 bttv_read 3 11432 NULL
97271 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
97272 +swp_offset_11475 swp_offset 0 11475 NULL
97273 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
97274 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
97275 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
97276 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
97277 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
97278 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
97279 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
97280 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
97281 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
97282 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
97283 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
97284 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
97285 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
97286 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
97287 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
97288 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
97289 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
97290 +split_11691 split 2 11691 NULL
97291 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
97292 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
97293 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
97294 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
97295 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
97296 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
97297 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
97298 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
97299 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
97300 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
97301 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
97302 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
97303 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
97304 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
97305 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
97306 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
97307 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
97308 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
97309 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
97310 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
97311 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
97312 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
97313 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
97314 +atmel_read16_11981 atmel_read16 0 11981 NULL
97315 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
97316 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
97317 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
97318 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
97319 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
97320 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
97321 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
97322 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
97323 +set_powered_12129 set_powered 4 12129 NULL
97324 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
97325 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
97326 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
97327 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
97328 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
97329 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
97330 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
97331 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
97332 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
97333 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
97334 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
97335 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
97336 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
97337 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
97338 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
97339 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
97340 +receive_copy_12216 receive_copy 3 12216 NULL
97341 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
97342 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
97343 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
97344 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
97345 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
97346 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
97347 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
97348 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
97349 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
97350 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
97351 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
97352 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
97353 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
97354 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
97355 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
97356 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
97357 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
97358 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
97359 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
97360 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
97361 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
97362 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
97363 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
97364 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
97365 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
97366 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
97367 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
97368 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
97369 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
97370 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
97371 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
97372 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
97373 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
97374 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
97375 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
97376 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
97377 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
97378 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
97379 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
97380 +wb_create_12651 wb_create 1 12651 NULL
97381 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
97382 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
97383 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
97384 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
97385 +ivtv_write_12721 ivtv_write 3 12721 NULL
97386 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
97387 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
97388 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
97389 +listxattr_12769 listxattr 3 12769 NULL
97390 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
97391 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
97392 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
97393 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
97394 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
97395 +readq_12825 readq 0 12825 NULL
97396 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
97397 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
97398 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
97399 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
97400 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
97401 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
97402 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
97403 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
97404 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
97405 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
97406 +bm_status_write_12964 bm_status_write 3 12964 NULL
97407 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
97408 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
97409 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
97410 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
97411 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
97412 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
97413 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
97414 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
97415 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
97416 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
97417 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
97418 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
97419 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
97420 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
97421 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
97422 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
97423 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
97424 +blk_update_request_13146 blk_update_request 3 13146 NULL
97425 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
97426 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
97427 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
97428 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
97429 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
97430 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
97431 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
97432 +comedi_read_13199 comedi_read 3 13199 NULL
97433 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
97434 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
97435 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
97436 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
97437 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
97438 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
97439 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
97440 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
97441 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
97442 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
97443 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
97444 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
97445 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
97446 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
97447 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
97448 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
97449 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
97450 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
97451 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
97452 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
97453 +cache_ctr_13364 cache_ctr 2 13364 NULL
97454 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
97455 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
97456 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
97457 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
97458 +sky2_receive_13407 sky2_receive 2 13407 NULL
97459 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
97460 +keyring_read_13438 keyring_read 3 13438 NULL
97461 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
97462 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
97463 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
97464 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
97465 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
97466 +core_status_13515 core_status 4 13515 NULL
97467 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
97468 +bm_init_13529 bm_init 2 13529 NULL
97469 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL
97470 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
97471 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
97472 +sys_madvise_13569 sys_madvise 1 13569 NULL
97473 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
97474 +cache_write_13589 cache_write 3 13589 NULL
97475 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
97476 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
97477 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
97478 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
97479 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
97480 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
97481 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
97482 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
97483 +packet_snd_13634 packet_snd 3 13634 NULL
97484 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
97485 +cache_downcall_13666 cache_downcall 3 13666 NULL
97486 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
97487 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
97488 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
97489 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
97490 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
97491 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
97492 +random_read_13815 random_read 3 13815 NULL
97493 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
97494 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
97495 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
97496 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
97497 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
97498 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
97499 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
97500 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
97501 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
97502 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
97503 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
97504 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
97505 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
97506 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
97507 +com90xx_found_13974 com90xx_found 3 13974 NULL
97508 +qcam_read_13977 qcam_read 3 13977 NULL
97509 +dsp_read_13980 dsp_read 2 13980 NULL
97510 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
97511 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
97512 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
97513 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
97514 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
97515 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
97516 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
97517 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
97518 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
97519 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
97520 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
97521 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
97522 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
97523 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
97524 +em_canid_change_14150 em_canid_change 3 14150 NULL
97525 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
97526 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
97527 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
97528 +alloc_async_14208 alloc_async 1 14208 NULL
97529 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
97530 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
97531 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
97532 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
97533 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
97534 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
97535 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
97536 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
97537 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
97538 +rr_status_14293 rr_status 5 14293 NULL
97539 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
97540 +oo_objects_14319 oo_objects 0 14319 NULL
97541 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
97542 +scsi2int_14358 scsi2int 0 14358 NULL
97543 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
97544 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
97545 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
97546 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
97547 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
97548 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
97549 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
97550 +block_size_14443 block_size 0 14443 NULL
97551 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
97552 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
97553 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
97554 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
97555 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
97556 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
97557 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
97558 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
97559 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
97560 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
97561 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
97562 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
97563 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
97564 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
97565 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
97566 +dbJoin_14644 dbJoin 0 14644 NULL
97567 +profile_replace_14652 profile_replace 3 14652 NULL
97568 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
97569 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
97570 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
97571 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
97572 +get_bio_block_14714 get_bio_block 0 14714 NULL
97573 +vfd_write_14717 vfd_write 3 14717 NULL
97574 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
97575 +raid1_resize_14740 raid1_resize 2 14740 NULL
97576 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
97577 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
97578 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
97579 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
97580 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
97581 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
97582 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
97583 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
97584 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
97585 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
97586 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
97587 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
97588 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
97589 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
97590 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
97591 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
97592 +unifi_read_14899 unifi_read 3 14899 NULL
97593 +krealloc_14908 krealloc 2 14908 NULL
97594 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
97595 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
97596 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
97597 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
97598 +queue_cnt_14951 queue_cnt 0 14951 NULL
97599 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
97600 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
97601 +setkey_14987 setkey 3 14987 NULL nohasharray
97602 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
97603 +vmap_15025 vmap 2 15025 NULL
97604 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
97605 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
97606 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
97607 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
97608 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
97609 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
97610 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
97611 +start_port_15124 start_port 0 15124 NULL
97612 +memchr_15126 memchr 0 15126 NULL
97613 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
97614 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
97615 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
97616 +reserve_resources_15194 reserve_resources 3 15194 NULL
97617 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
97618 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
97619 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
97620 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
97621 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
97622 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
97623 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
97624 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
97625 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
97626 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
97627 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
97628 +ioread16_15342 ioread16 0 15342 NULL
97629 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
97630 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
97631 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
97632 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
97633 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
97634 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
97635 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
97636 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
97637 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
97638 +get_modalias_15406 get_modalias 2 15406 NULL
97639 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
97640 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
97641 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
97642 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
97643 +memweight_15450 memweight 2 15450 NULL
97644 +vmalloc_15464 vmalloc 1 15464 NULL
97645 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
97646 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
97647 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
97648 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
97649 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
97650 +persistent_status_15574 persistent_status 4 15574 NULL
97651 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
97652 +vme_user_write_15587 vme_user_write 3 15587 NULL
97653 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
97654 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
97655 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
97656 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
97657 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
97658 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
97659 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
97660 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
97661 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
97662 +fs_path_add_15648 fs_path_add 3 15648 NULL
97663 +xsd_read_15653 xsd_read 3 15653 NULL
97664 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
97665 +unix_bind_15668 unix_bind 3 15668 NULL
97666 +dm_read_15674 dm_read 3 15674 NULL
97667 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
97668 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
97669 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
97670 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
97671 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
97672 +do_test_15766 do_test 1 15766 NULL
97673 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
97674 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
97675 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
97676 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
97677 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
97678 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
97679 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
97680 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
97681 +table_size_15851 table_size 0-1-2 15851 NULL
97682 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
97683 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
97684 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
97685 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
97686 +native_read_msr_15905 native_read_msr 0 15905 NULL
97687 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
97688 +power_read_15939 power_read 3 15939 NULL
97689 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
97690 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
97691 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
97692 +frame_alloc_15981 frame_alloc 4 15981 NULL
97693 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
97694 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
97695 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
97696 +got_frame_16028 got_frame 2 16028 NULL
97697 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
97698 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
97699 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
97700 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
97701 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
97702 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
97703 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
97704 +fsm_init_16134 fsm_init 2 16134 NULL
97705 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
97706 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
97707 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
97708 +mapping_level_16188 mapping_level 2 16188 NULL
97709 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
97710 +create_table_16213 create_table 2 16213 NULL
97711 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
97712 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
97713 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
97714 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
97715 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
97716 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
97717 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
97718 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
97719 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
97720 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
97721 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
97722 +account_16283 account 0-2-4 16283 NULL nohasharray
97723 +mirror_status_16283 mirror_status 5 16283 &account_16283
97724 +retry_instruction_16285 retry_instruction 2 16285 NULL
97725 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
97726 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
97727 +wb_map_16301 wb_map 2 16301 NULL
97728 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
97729 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
97730 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
97731 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
97732 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
97733 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
97734 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
97735 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
97736 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
97737 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
97738 +raid10_resize_16537 raid10_resize 2 16537 NULL
97739 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
97740 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
97741 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
97742 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
97743 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
97744 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
97745 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
97746 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
97747 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
97748 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
97749 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
97750 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
97751 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
97752 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
97753 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
97754 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
97755 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
97756 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
97757 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
97758 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
97759 +st_write_16874 st_write 3 16874 NULL
97760 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
97761 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
97762 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
97763 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
97764 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
97765 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
97766 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
97767 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
97768 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
97769 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
97770 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
97771 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
97772 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
97773 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
97774 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
97775 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
97776 +mac_address_string_17091 mac_address_string 0 17091 NULL
97777 +entry_length_17093 entry_length 0 17093 NULL
97778 +sys_preadv_17100 sys_preadv 3 17100 NULL
97779 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
97780 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
97781 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
97782 +sep_read_17161 sep_read 3 17161 NULL
97783 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
97784 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
97785 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
97786 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
97787 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
97788 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
97789 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
97790 +to_oblock_17254 to_oblock 0-1 17254 NULL
97791 +unpack_value_17259 unpack_value 1 17259 NULL
97792 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
97793 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
97794 +alloc_ep_17269 alloc_ep 1 17269 NULL
97795 +pg_read_17276 pg_read 3 17276 NULL
97796 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
97797 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
97798 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
97799 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
97800 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
97801 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
97802 +skb_pad_17302 skb_pad 2 17302 NULL
97803 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
97804 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
97805 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
97806 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
97807 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
97808 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
97809 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
97810 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
97811 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
97812 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
97813 +compat_cmd_17465 compat_cmd 2 17465 NULL
97814 +probe_bios_17467 probe_bios 1 17467 NULL
97815 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
97816 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
97817 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
97818 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
97819 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
97820 +copy_from_user_17559 copy_from_user 3 17559 NULL
97821 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
97822 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
97823 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
97824 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
97825 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
97826 +osst_execute_17607 osst_execute 7-6 17607 NULL
97827 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
97828 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
97829 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
97830 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
97831 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
97832 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
97833 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
97834 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
97835 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
97836 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
97837 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
97838 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
97839 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
97840 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
97841 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
97842 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
97843 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
97844 +count_leafs_17842 count_leafs 0 17842 NULL
97845 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
97846 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
97847 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
97848 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
97849 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
97850 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
97851 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
97852 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
97853 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
97854 +recover_head_17904 recover_head 3 17904 NULL
97855 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
97856 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
97857 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
97858 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
97859 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
97860 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
97861 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
97862 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
97863 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
97864 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
97865 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
97866 +fill_read_18019 fill_read 0 18019 NULL
97867 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
97868 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
97869 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
97870 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
97871 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
97872 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
97873 +packet_came_18072 packet_came 3 18072 NULL
97874 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
97875 +get_vm_area_18080 get_vm_area 1 18080 NULL
97876 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
97877 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
97878 +svc_getnl_18120 svc_getnl 0 18120 NULL
97879 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
97880 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
97881 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
97882 +_has_tag_18169 _has_tag 2 18169 NULL
97883 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
97884 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
97885 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
97886 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
97887 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
97888 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
97889 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
97890 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
97891 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
97892 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
97893 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
97894 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
97895 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
97896 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
97897 +um_idi_write_18293 um_idi_write 3 18293 NULL
97898 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
97899 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
97900 +vga_r_18310 vga_r 0 18310 NULL
97901 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
97902 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
97903 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
97904 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
97905 +ep_io_18367 ep_io 0 18367 NULL
97906 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
97907 +__video_register_device_18399 __video_register_device 3 18399 NULL
97908 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
97909 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
97910 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
97911 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
97912 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
97913 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
97914 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
97915 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
97916 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
97917 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
97918 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
97919 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
97920 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
97921 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
97922 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
97923 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
97924 +debug_output_18575 debug_output 3 18575 NULL
97925 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
97926 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
97927 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL
97928 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
97929 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
97930 +from_buffer_18625 from_buffer 3 18625 NULL
97931 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
97932 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
97933 +unmap_page_18665 unmap_page 2-3 18665 NULL
97934 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
97935 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
97936 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
97937 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
97938 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
97939 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
97940 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
97941 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
97942 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
97943 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
97944 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
97945 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
97946 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
97947 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
97948 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
97949 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
97950 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
97951 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
97952 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
97953 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
97954 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
97955 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
97956 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
97957 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97958 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
97959 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97960 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97961 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97962 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97963 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97964 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
97965 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97966 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97967 +huge_page_size_19008 huge_page_size 0 19008 NULL
97968 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97969 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97970 +revalidate_19043 revalidate 2 19043 NULL
97971 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97972 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97973 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97974 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97975 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97976 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97977 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97978 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97979 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97980 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97981 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97982 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97983 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97984 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97985 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97986 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97987 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97988 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97989 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97990 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97991 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97992 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97993 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97994 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97995 +qc_capture_19298 qc_capture 3 19298 NULL
97996 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97997 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97998 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
97999 +debug_read_19322 debug_read 3 19322 NULL
98000 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
98001 +read_zero_19366 read_zero 3 19366 NULL
98002 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
98003 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
98004 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
98005 +__phys_addr_19434 __phys_addr 0 19434 NULL
98006 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
98007 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
98008 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
98009 +sky2_read16_19475 sky2_read16 0 19475 NULL
98010 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
98011 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
98012 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
98013 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
98014 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
98015 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
98016 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
98017 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
98018 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
98019 +nfsd_read_19568 nfsd_read 5 19568 NULL
98020 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
98021 +bm_status_read_19583 bm_status_read 3 19583 NULL
98022 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
98023 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
98024 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
98025 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
98026 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
98027 +bio_detain_19690 bio_detain 2 19690 NULL
98028 +read_reg_19723 read_reg 0 19723 NULL
98029 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
98030 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
98031 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
98032 +p9_client_read_19750 p9_client_read 5 19750 NULL
98033 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
98034 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
98035 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
98036 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
98037 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
98038 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
98039 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
98040 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
98041 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
98042 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
98043 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
98044 +__nla_put_19857 __nla_put 3 19857 NULL
98045 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
98046 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
98047 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
98048 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
98049 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
98050 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
98051 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
98052 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
98053 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
98054 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
98055 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
98056 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
98057 +team_options_register_20091 team_options_register 3 20091 NULL
98058 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
98059 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
98060 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
98061 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
98062 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
98063 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
98064 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
98065 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
98066 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
98067 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
98068 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
98069 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
98070 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
98071 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
98072 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
98073 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
98074 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
98075 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
98076 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
98077 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
98078 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
98079 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
98080 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
98081 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
98082 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
98083 +read_buf_20469 read_buf 2 20469 NULL
98084 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
98085 +fast_user_write_20494 fast_user_write 5 20494 NULL
98086 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
98087 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
98088 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
98089 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
98090 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
98091 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
98092 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
98093 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
98094 +venus_create_20555 venus_create 4 20555 NULL
98095 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
98096 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
98097 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
98098 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
98099 +lirc_write_20604 lirc_write 3 20604 NULL
98100 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
98101 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
98102 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
98103 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
98104 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
98105 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
98106 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
98107 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
98108 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
98109 +cpumask_size_20683 cpumask_size 0 20683 NULL
98110 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
98111 +gru_vtop_20689 gru_vtop 2 20689 NULL
98112 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
98113 +__maestro_read_20700 __maestro_read 0 20700 NULL
98114 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
98115 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
98116 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
98117 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
98118 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
98119 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
98120 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
98121 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
98122 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
98123 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
98124 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
98125 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
98126 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
98127 +sys_sendto_20809 sys_sendto 6 20809 NULL
98128 +strndup_user_20819 strndup_user 2 20819 NULL
98129 +calc_layout_20829 calc_layout 3 20829 NULL
98130 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
98131 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
98132 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
98133 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
98134 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
98135 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
98136 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
98137 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
98138 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
98139 +htable_bits_20933 htable_bits 0 20933 NULL
98140 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
98141 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
98142 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
98143 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
98144 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
98145 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
98146 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
98147 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
98148 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
98149 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
98150 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
98151 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
98152 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
98153 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
98154 +multipath_status_21094 multipath_status 5 21094 NULL
98155 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
98156 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
98157 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
98158 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
98159 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
98160 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
98161 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
98162 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
98163 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
98164 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
98165 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
98166 +input_ff_create_21240 input_ff_create 2 21240 NULL
98167 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
98168 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
98169 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
98170 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
98171 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
98172 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
98173 +add_res_range_21310 add_res_range 4 21310 NULL
98174 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
98175 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
98176 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
98177 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
98178 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
98179 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
98180 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
98181 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
98182 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
98183 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
98184 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
98185 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
98186 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
98187 +concat_writev_21451 concat_writev 3 21451 NULL
98188 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
98189 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
98190 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
98191 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
98192 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
98193 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
98194 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
98195 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
98196 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
98197 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
98198 +validate_nnode_21638 validate_nnode 0 21638 NULL
98199 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
98200 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
98201 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
98202 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
98203 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
98204 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
98205 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
98206 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
98207 +vm_brk_21739 vm_brk 1 21739 NULL
98208 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
98209 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
98210 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
98211 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
98212 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
98213 +min_odd_21802 min_odd 0 21802 NULL
98214 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
98215 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
98216 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
98217 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
98218 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
98219 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
98220 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
98221 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
98222 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
98223 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
98224 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
98225 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
98226 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
98227 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
98228 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
98229 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
98230 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
98231 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
98232 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
98233 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
98234 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
98235 +write_opcode_22082 write_opcode 2 22082 NULL
98236 +mem_rw_22085 mem_rw 3 22085 NULL
98237 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
98238 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
98239 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
98240 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
98241 +compat_insn_22142 compat_insn 2 22142 NULL
98242 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
98243 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
98244 +fls_22210 fls 0 22210 NULL
98245 +mem_write_22232 mem_write 3 22232 NULL
98246 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
98247 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
98248 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
98249 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
98250 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
98251 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
98252 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
98253 +extend_brk_22301 extend_brk 0 22301 NULL
98254 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
98255 +get_segment_base_22324 get_segment_base 0 22324 NULL
98256 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
98257 +atomic_read_22342 atomic_read 0 22342 NULL
98258 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
98259 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
98260 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
98261 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
98262 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
98263 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
98264 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
98265 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
98266 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
98267 +zoran_write_22404 zoran_write 3 22404 NULL
98268 +queue_reply_22416 queue_reply 3 22416 NULL
98269 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
98270 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
98271 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
98272 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
98273 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
98274 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
98275 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
98276 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
98277 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
98278 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
98279 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
98280 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
98281 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
98282 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
98283 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
98284 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
98285 +snapshot_read_22601 snapshot_read 3 22601 NULL
98286 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
98287 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
98288 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
98289 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
98290 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
98291 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
98292 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
98293 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
98294 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
98295 +map_22700 map 2 22700 NULL
98296 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
98297 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
98298 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
98299 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
98300 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
98301 +print_frame_22769 print_frame 0 22769 NULL
98302 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
98303 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
98304 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
98305 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
98306 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
98307 +create_attr_set_22861 create_attr_set 1 22861 NULL
98308 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
98309 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
98310 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
98311 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
98312 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
98313 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
98314 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
98315 +vme_get_size_22964 vme_get_size 0 22964 NULL
98316 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
98317 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
98318 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
98319 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
98320 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
98321 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
98322 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
98323 +st_status_23032 st_status 5 23032 NULL
98324 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
98325 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
98326 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
98327 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
98328 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
98329 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
98330 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
98331 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
98332 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
98333 +fls_long_23096 fls_long 0 23096 NULL
98334 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
98335 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
98336 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
98337 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
98338 +__clear_user_23118 __clear_user 0 23118 NULL
98339 +dm_write_async_23120 dm_write_async 3 23120 NULL
98340 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
98341 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
98342 +read_file_ani_23161 read_file_ani 3 23161 NULL
98343 +ioremap_23172 ioremap 1-2 23172 NULL
98344 +usblp_write_23178 usblp_write 3 23178 NULL
98345 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
98346 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
98347 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
98348 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
98349 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
98350 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
98351 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
98352 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
98353 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
98354 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
98355 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
98356 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
98357 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
98358 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
98359 +doc_probe_23285 doc_probe 1 23285 NULL
98360 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
98361 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
98362 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
98363 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
98364 +page_readlink_23346 page_readlink 3 23346 NULL
98365 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
98366 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
98367 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
98368 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
98369 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
98370 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
98371 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
98372 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
98373 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
98374 +event_filter_read_23494 event_filter_read 3 23494 NULL
98375 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
98376 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
98377 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
98378 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
98379 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
98380 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
98381 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
98382 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
98383 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
98384 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
98385 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
98386 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
98387 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
98388 +sInW_23663 sInW 0 23663 NULL
98389 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
98390 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
98391 +cx18_read_23699 cx18_read 3 23699 NULL
98392 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
98393 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
98394 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
98395 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
98396 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
98397 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
98398 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
98399 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
98400 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
98401 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
98402 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
98403 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
98404 +p54_init_common_23850 p54_init_common 1 23850 NULL
98405 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
98406 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
98407 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
98408 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
98409 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
98410 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
98411 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
98412 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
98413 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
98414 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
98415 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
98416 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
98417 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
98418 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
98419 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
98420 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
98421 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
98422 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
98423 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
98424 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
98425 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
98426 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
98427 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
98428 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
98429 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
98430 +mpu401_read_24126 mpu401_read 3 24126 NULL
98431 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
98432 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
98433 +set_discard_24162 set_discard 2 24162 NULL
98434 +adu_read_24177 adu_read 3 24177 NULL
98435 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
98436 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
98437 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
98438 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
98439 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
98440 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
98441 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
98442 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
98443 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
98444 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
98445 +thin_status_24278 thin_status 5 24278 NULL
98446 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
98447 +msg_size_24288 msg_size 0 24288 NULL
98448 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
98449 +map_page_24298 map_page 3-4 24298 NULL
98450 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
98451 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
98452 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
98453 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
98454 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
98455 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
98456 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
98457 +igetword_24373 igetword 0 24373 NULL
98458 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
98459 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
98460 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
98461 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
98462 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
98463 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
98464 +smk_user_access_24440 smk_user_access 3 24440 NULL
98465 +page_address_24444 page_address 0 24444 NULL
98466 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
98467 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
98468 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
98469 +pd_video_read_24510 pd_video_read 3 24510 NULL
98470 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
98471 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
98472 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
98473 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
98474 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
98475 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
98476 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
98477 +count_preds_24600 count_preds 0 24600 NULL
98478 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
98479 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
98480 +context_alloc_24645 context_alloc 3 24645 NULL
98481 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
98482 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
98483 +read_fs_24717 read_fs 0 24717 NULL
98484 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
98485 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
98486 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
98487 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
98488 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
98489 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
98490 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
98491 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
98492 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
98493 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
98494 +cache_read_24790 cache_read 3 24790 NULL
98495 +unpack_str_24798 unpack_str 0 24798 NULL
98496 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
98497 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
98498 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
98499 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
98500 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
98501 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
98502 +setup_buffering_24872 setup_buffering 3 24872 NULL
98503 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
98504 +queues_read_24877 queues_read 3 24877 NULL
98505 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
98506 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
98507 +next_token_24929 next_token 0 24929 NULL
98508 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
98509 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
98510 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
98511 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
98512 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
98513 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
98514 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
98515 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
98516 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
98517 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
98518 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
98519 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
98520 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
98521 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
98522 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
98523 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
98524 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
98525 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
98526 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
98527 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
98528 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
98529 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
98530 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
98531 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
98532 +stripe_status_25259 stripe_status 5 25259 NULL
98533 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
98534 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
98535 +vfs_writev_25278 vfs_writev 3 25278 NULL
98536 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
98537 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
98538 +help_25316 help 5 25316 NULL nohasharray
98539 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
98540 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
98541 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
98542 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
98543 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
98544 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
98545 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
98546 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
98547 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
98548 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
98549 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
98550 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
98551 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
98552 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
98553 +sb_permission_25523 sb_permission 0 25523 NULL
98554 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
98555 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
98556 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
98557 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
98558 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
98559 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
98560 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
98561 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
98562 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
98563 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
98564 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
98565 +__direct_map_25647 __direct_map 5-6 25647 NULL
98566 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
98567 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
98568 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
98569 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
98570 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
98571 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
98572 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
98573 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
98574 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
98575 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
98576 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
98577 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
98578 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
98579 +sg_read_25799 sg_read 3 25799 NULL
98580 +system_enable_read_25815 system_enable_read 3 25815 NULL
98581 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
98582 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
98583 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
98584 +parport_read_25855 parport_read 0 25855 NULL
98585 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
98586 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
98587 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
98588 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
98589 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
98590 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
98591 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
98592 +rcname_read_25919 rcname_read 3 25919 NULL
98593 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
98594 +key_flags_read_25931 key_flags_read 3 25931 NULL
98595 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
98596 +flush_25957 flush 2 25957 NULL
98597 +video_register_device_25971 video_register_device 3 25971 NULL
98598 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
98599 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
98600 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
98601 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
98602 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
98603 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
98604 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
98605 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
98606 +tun_do_read_26047 tun_do_read 5 26047 NULL
98607 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
98608 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
98609 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
98610 +skb_cow_26138 skb_cow 2 26138 NULL
98611 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
98612 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
98613 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
98614 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
98615 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
98616 +disk_devt_26180 disk_devt 0 26180 NULL
98617 +get_registers_26187 get_registers 3 26187 NULL
98618 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
98619 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
98620 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
98621 +mce_write_26201 mce_write 3 26201 NULL
98622 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
98623 +bio_split_26235 bio_split 2 26235 NULL
98624 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
98625 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
98626 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
98627 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
98628 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
98629 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
98630 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
98631 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
98632 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
98633 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
98634 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
98635 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
98636 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
98637 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
98638 +read_vmcore_26501 read_vmcore 3 26501 NULL
98639 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
98640 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
98641 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
98642 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
98643 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
98644 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
98645 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
98646 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
98647 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
98648 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
98649 +pack_value_26625 pack_value 1 26625 NULL
98650 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
98651 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
98652 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
98653 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
98654 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
98655 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
98656 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
98657 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
98658 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
98659 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
98660 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
98661 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
98662 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
98663 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
98664 +smk_write_load_26829 smk_write_load 3 26829 NULL
98665 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
98666 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
98667 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
98668 +scnprint_id_26842 scnprint_id 3 26842 NULL
98669 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
98670 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
98671 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
98672 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
98673 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
98674 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
98675 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
98676 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
98677 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
98678 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
98679 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
98680 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
98681 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
98682 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
98683 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
98684 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
98685 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
98686 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
98687 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
98688 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
98689 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
98690 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
98691 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
98692 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
98693 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
98694 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
98695 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
98696 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
98697 +pms_capture_27142 pms_capture 4 27142 NULL
98698 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
98699 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
98700 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
98701 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
98702 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
98703 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
98704 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
98705 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
98706 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
98707 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
98708 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
98709 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
98710 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
98711 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
98712 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
98713 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
98714 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
98715 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
98716 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
98717 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
98718 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
98719 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
98720 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
98721 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
98722 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
98723 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
98724 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
98725 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
98726 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
98727 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
98728 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
98729 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
98730 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
98731 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
98732 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
98733 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
98734 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
98735 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
98736 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
98737 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
98738 +qword_get_27670 qword_get 0 27670 NULL
98739 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
98740 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
98741 +evm_write_key_27715 evm_write_key 3 27715 NULL
98742 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
98743 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
98744 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
98745 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
98746 +kcalloc_27770 kcalloc 1-2 27770 NULL
98747 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
98748 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
98749 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
98750 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
98751 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
98752 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
98753 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
98754 +read_profile_27859 read_profile 3 27859 NULL
98755 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
98756 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
98757 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
98758 +gluebi_write_27905 gluebi_write 3 27905 NULL
98759 +bm_find_next_27929 bm_find_next 2 27929 NULL
98760 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
98761 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
98762 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
98763 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
98764 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
98765 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
98766 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
98767 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
98768 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
98769 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
98770 +pool_status_28055 pool_status 5 28055 NULL
98771 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
98772 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
98773 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
98774 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
98775 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
98776 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
98777 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
98778 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
98779 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
98780 +video_read_28148 video_read 3 28148 NULL
98781 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
98782 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
98783 +vread_28173 vread 0 28173 NULL
98784 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
98785 +d_path_28198 d_path 0 28198 NULL
98786 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
98787 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
98788 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
98789 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
98790 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
98791 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
98792 +usemap_size_28281 usemap_size 0 28281 NULL
98793 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
98794 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
98795 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
98796 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
98797 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
98798 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
98799 +snapshot_write_28351 snapshot_write 3 28351 NULL
98800 +sys_writev_28384 sys_writev 3 28384 NULL
98801 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
98802 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
98803 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
98804 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
98805 +__split_large_page_28429 __split_large_page 2 28429 NULL
98806 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
98807 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
98808 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
98809 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
98810 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
98811 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
98812 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
98813 +max_response_pages_28492 max_response_pages 0 28492 NULL
98814 +clear_discard_28494 clear_discard 2 28494 NULL
98815 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
98816 +__next_node_28521 __next_node 1 28521 NULL
98817 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
98818 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
98819 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
98820 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
98821 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
98822 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
98823 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
98824 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
98825 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
98826 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
98827 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
98828 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
98829 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
98830 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
98831 +_set_range_28627 _set_range 3 28627 NULL
98832 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
98833 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
98834 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
98835 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
98836 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
98837 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
98838 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
98839 +spi_execute_28736 spi_execute 5 28736 NULL
98840 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
98841 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
98842 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
98843 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
98844 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
98845 +sel_write_member_28800 sel_write_member 3 28800 NULL
98846 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
98847 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
98848 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
98849 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
98850 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
98851 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
98852 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
98853 +to_cblock_28899 to_cblock 0-1 28899 NULL
98854 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
98855 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
98856 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
98857 +push_rx_28939 push_rx 3 28939 NULL
98858 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
98859 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
98860 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
98861 +bin_uuid_28999 bin_uuid 3 28999 NULL
98862 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
98863 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
98864 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
98865 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
98866 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
98867 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
98868 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
98869 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
98870 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
98871 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
98872 +snprintf_29125 snprintf 0 29125 NULL
98873 +iov_shorten_29130 iov_shorten 0 29130 NULL
98874 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
98875 +reshape_ring_29147 reshape_ring 2 29147 NULL
98876 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
98877 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
98878 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
98879 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
98880 +__mm_populate_29204 __mm_populate 1 29204 NULL
98881 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
98882 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
98883 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
98884 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
98885 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
98886 +recover_peb_29238 recover_peb 6-7 29238 NULL
98887 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
98888 +block_div_29268 block_div 0-1-2 29268 NULL
98889 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
98890 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
98891 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
98892 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
98893 +tun_put_user_29337 tun_put_user 5 29337 NULL
98894 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
98895 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
98896 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
98897 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
98898 +mempool_create_29437 mempool_create 1 29437 NULL
98899 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
98900 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
98901 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
98902 +do_register_entry_29478 do_register_entry 4 29478 NULL
98903 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
98904 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
98905 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
98906 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
98907 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
98908 +set_brk_29551 set_brk 1 29551 NULL nohasharray
98909 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
98910 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
98911 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
98912 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
98913 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
98914 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
98915 +slots_per_page_29601 slots_per_page 0 29601 NULL
98916 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
98917 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
98918 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
98919 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
98920 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
98921 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
98922 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
98923 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
98924 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
98925 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
98926 +probes_write_29711 probes_write 3 29711 NULL
98927 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
98928 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
98929 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
98930 +dbAlloc_29794 dbAlloc 0 29794 NULL
98931 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
98932 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
98933 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
98934 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
98935 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
98936 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
98937 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
98938 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
98939 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
98940 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
98941 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
98942 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
98943 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
98944 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
98945 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
98946 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
98947 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
98948 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
98949 +drp_wmove_30043 drp_wmove 4 30043 NULL
98950 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
98951 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
98952 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
98953 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
98954 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
98955 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98956 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98957 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98958 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98959 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98960 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98961 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98962 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98963 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98964 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98965 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98966 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98967 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
98968 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98969 +compat_readv_30273 compat_readv 3 30273 NULL
98970 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98971 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98972 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98973 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98974 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98975 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98976 +resource_from_user_30341 resource_from_user 3 30341 NULL
98977 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98978 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
98979 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98980 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98981 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98982 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98983 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98984 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98985 +mq_create_30425 mq_create 1 30425 NULL
98986 +enable_write_30456 enable_write 3 30456 NULL
98987 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98988 +urandom_read_30462 urandom_read 3 30462 NULL
98989 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98990 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
98991 +write_head_30481 write_head 4 30481 NULL
98992 +adu_write_30487 adu_write 3 30487 NULL
98993 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98994 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98995 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98996 +set_le_30581 set_le 4 30581 NULL
98997 +from_cblock_30582 from_cblock 0-1 30582 NULL
98998 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98999 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
99000 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
99001 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
99002 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
99003 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
99004 +agp_remap_30665 agp_remap 2 30665 NULL
99005 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
99006 +il_free_pages_30692 il_free_pages 2 30692 NULL
99007 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
99008 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
99009 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
99010 +snapshot_status_30744 snapshot_status 5 30744 NULL
99011 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
99012 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
99013 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
99014 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
99015 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
99016 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
99017 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
99018 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
99019 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
99020 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
99021 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
99022 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
99023 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
99024 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
99025 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
99026 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
99027 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
99028 +sys_mincore_31079 sys_mincore 1 31079 NULL
99029 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
99030 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
99031 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
99032 +depth_read_31112 depth_read 3 31112 NULL
99033 +ssb_read16_31139 ssb_read16 0 31139 NULL
99034 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
99035 +size_inside_page_31141 size_inside_page 0 31141 NULL
99036 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
99037 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
99038 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
99039 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
99040 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
99041 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
99042 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
99043 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
99044 +__read_reg_31216 __read_reg 0 31216 NULL
99045 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
99046 +cyy_readb_31240 cyy_readb 0 31240 NULL
99047 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
99048 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
99049 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
99050 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
99051 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
99052 +command_file_write_31318 command_file_write 3 31318 NULL
99053 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
99054 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
99055 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
99056 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
99057 +inb_31388 inb 0 31388 NULL
99058 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
99059 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
99060 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
99061 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
99062 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
99063 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
99064 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
99065 +do_fcntl_31468 do_fcntl 3 31468 NULL
99066 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
99067 +alg_setkey_31485 alg_setkey 3 31485 NULL
99068 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
99069 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
99070 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
99071 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
99072 +hidraw_write_31536 hidraw_write 3 31536 NULL
99073 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
99074 +usbvision_read_31555 usbvision_read 3 31555 NULL
99075 +normalize_31566 normalize 0-1-2 31566 NULL
99076 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
99077 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
99078 +osst_write_31581 osst_write 3 31581 NULL
99079 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
99080 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
99081 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
99082 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
99083 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
99084 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
99085 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
99086 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
99087 +__lgread_31668 __lgread 4 31668 NULL
99088 +symbol_string_31670 symbol_string 0 31670 NULL
99089 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
99090 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
99091 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
99092 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
99093 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
99094 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
99095 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
99096 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
99097 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
99098 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
99099 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
99100 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
99101 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
99102 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
99103 +get_count_order_31800 get_count_order 0 31800 NULL
99104 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
99105 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
99106 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
99107 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
99108 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
99109 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
99110 +xattr_permission_31907 xattr_permission 0 31907 NULL
99111 +new_dir_31919 new_dir 3 31919 NULL
99112 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
99113 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
99114 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
99115 +vb2_write_31948 vb2_write 3 31948 NULL
99116 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
99117 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
99118 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
99119 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
99120 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
99121 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
99122 +calc_hmac_32010 calc_hmac 3 32010 NULL
99123 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
99124 +aead_len_32021 aead_len 0 32021 NULL
99125 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
99126 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
99127 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
99128 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
99129 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
99130 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
99131 +bio_alloc_32095 bio_alloc 2 32095 NULL
99132 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
99133 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
99134 +disk_status_32120 disk_status 4 32120 NULL
99135 +venus_link_32165 venus_link 5 32165 NULL
99136 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
99137 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
99138 +load_header_32183 load_header 0 32183 NULL
99139 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
99140 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
99141 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
99142 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
99143 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
99144 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
99145 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
99146 +hex_string_32310 hex_string 0 32310 NULL
99147 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
99148 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
99149 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
99150 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
99151 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
99152 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
99153 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
99154 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
99155 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
99156 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
99157 +log_text_32428 log_text 0 32428 NULL
99158 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
99159 +hid_input_report_32458 hid_input_report 4 32458 NULL
99160 +cache_status_32462 cache_status 5 32462 NULL
99161 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
99162 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
99163 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
99164 +disconnect_32521 disconnect 4 32521 NULL
99165 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
99166 +ilo_read_32531 ilo_read 3 32531 NULL
99167 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
99168 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
99169 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
99170 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
99171 +__first_node_32558 __first_node 0 32558 NULL
99172 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
99173 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
99174 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
99175 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
99176 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
99177 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
99178 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
99179 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
99180 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
99181 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
99182 +kvmalloc_32646 kvmalloc 1 32646 NULL
99183 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
99184 +generic_readlink_32654 generic_readlink 3 32654 NULL
99185 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
99186 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
99187 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
99188 +get_arg_page_32746 get_arg_page 2 32746 NULL
99189 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
99190 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
99191 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
99192 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
99193 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
99194 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
99195 +vga_rseq_32848 vga_rseq 0 32848 NULL
99196 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
99197 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
99198 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
99199 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
99200 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
99201 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
99202 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
99203 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
99204 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
99205 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
99206 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
99207 +compat_filldir_32999 compat_filldir 3 32999 NULL
99208 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
99209 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
99210 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
99211 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
99212 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
99213 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
99214 +alloc_tio_33077 alloc_tio 3 33077 NULL
99215 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
99216 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
99217 +write_node_33121 write_node 4 33121 NULL
99218 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
99219 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
99220 +__len_within_target_33132 __len_within_target 0 33132 NULL
99221 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
99222 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
99223 +pp_read_33210 pp_read 3 33210 NULL
99224 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
99225 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
99226 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
99227 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
99228 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
99229 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
99230 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
99231 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
99232 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
99233 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
99234 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
99235 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
99236 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
99237 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
99238 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
99239 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
99240 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
99241 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
99242 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
99243 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
99244 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
99245 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
99246 +create_entry_33479 create_entry 2 33479 NULL
99247 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
99248 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
99249 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
99250 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
99251 +res_counter_read_33499 res_counter_read 4 33499 NULL
99252 +fb_read_33506 fb_read 3 33506 NULL
99253 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
99254 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
99255 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
99256 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
99257 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
99258 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
99259 +dup_array_33551 dup_array 3 33551 NULL
99260 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
99261 +count_subheaders_33591 count_subheaders 0 33591 NULL
99262 +scsi_execute_33596 scsi_execute 5 33596 NULL
99263 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
99264 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
99265 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
99266 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
99267 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
99268 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
99269 +inw_p_33668 inw_p 0 33668 NULL
99270 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
99271 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
99272 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
99273 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
99274 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
99275 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
99276 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
99277 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
99278 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
99279 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
99280 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
99281 +Read_hfc_33755 Read_hfc 0 33755 NULL
99282 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
99283 +hashtab_create_33769 hashtab_create 3 33769 NULL
99284 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
99285 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
99286 +find_next_offset_33804 find_next_offset 3 33804 NULL
99287 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
99288 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
99289 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
99290 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
99291 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
99292 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
99293 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
99294 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
99295 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
99296 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
99297 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
99298 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
99299 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
99300 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
99301 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
99302 +ppp_write_34034 ppp_write 3 34034 NULL
99303 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
99304 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
99305 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
99306 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
99307 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
99308 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
99309 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
99310 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
99311 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
99312 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
99313 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
99314 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
99315 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
99316 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
99317 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
99318 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
99319 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
99320 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
99321 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
99322 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
99323 +__insert_34349 __insert 2-3 34349 NULL
99324 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
99325 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
99326 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
99327 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
99328 +ea_read_34378 ea_read 0 34378 NULL
99329 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
99330 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
99331 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
99332 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
99333 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
99334 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
99335 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
99336 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
99337 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
99338 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
99339 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
99340 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
99341 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
99342 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
99343 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
99344 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
99345 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
99346 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
99347 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
99348 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
99349 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
99350 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
99351 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
99352 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
99353 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
99354 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
99355 +port_print_34704 port_print 3 34704 NULL
99356 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
99357 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
99358 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
99359 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
99360 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
99361 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
99362 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
99363 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
99364 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
99365 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
99366 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
99367 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
99368 +msg_print_text_34889 msg_print_text 0 34889 NULL
99369 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
99370 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
99371 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
99372 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
99373 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
99374 +Realloc_34961 Realloc 2 34961 NULL
99375 +mq_lookup_34990 mq_lookup 2 34990 NULL
99376 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
99377 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
99378 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
99379 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
99380 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
99381 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
99382 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
99383 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
99384 +store_ifalias_35088 store_ifalias 4 35088 NULL
99385 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
99386 +capi_write_35104 capi_write 3 35104 NULL nohasharray
99387 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
99388 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
99389 +pointer_35138 pointer 0 35138 NULL
99390 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
99391 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
99392 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
99393 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
99394 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
99395 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
99396 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
99397 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
99398 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
99399 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
99400 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
99401 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
99402 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
99403 +set_fd_set_35249 set_fd_set 1 35249 NULL
99404 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
99405 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
99406 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
99407 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
99408 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
99409 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
99410 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
99411 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
99412 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
99413 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
99414 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
99415 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
99416 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
99417 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
99418 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
99419 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
99420 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
99421 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
99422 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
99423 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
99424 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
99425 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
99426 +async_setkey_35521 async_setkey 3 35521 NULL
99427 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
99428 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
99429 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
99430 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
99431 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
99432 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
99433 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
99434 +ReadZReg_35604 ReadZReg 0 35604 NULL
99435 +kernel_readv_35617 kernel_readv 3 35617 NULL
99436 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
99437 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
99438 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
99439 +store_debug_level_35652 store_debug_level 3 35652 NULL
99440 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
99441 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
99442 +dm_table_create_35687 dm_table_create 3 35687 NULL
99443 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
99444 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
99445 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
99446 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
99447 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
99448 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
99449 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
99450 +fls64_35862 fls64 0 35862 NULL
99451 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
99452 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
99453 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
99454 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
99455 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
99456 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
99457 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
99458 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
99459 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
99460 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
99461 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
99462 +acl_alloc_35979 acl_alloc 1 35979 NULL
99463 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
99464 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
99465 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
99466 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
99467 +account_shadowed_36048 account_shadowed 2 36048 NULL
99468 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
99469 +write_emulate_36065 write_emulate 2-4 36065 NULL
99470 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
99471 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
99472 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
99473 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
99474 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
99475 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
99476 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
99477 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
99478 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
99479 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
99480 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
99481 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
99482 +twl_set_36154 twl_set 2 36154 NULL
99483 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
99484 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
99485 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
99486 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
99487 +is_dirty_36223 is_dirty 2 36223 NULL
99488 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
99489 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
99490 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
99491 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
99492 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
99493 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
99494 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
99495 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
99496 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
99497 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
99498 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
99499 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
99500 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
99501 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
99502 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
99503 +lc_create_36332 lc_create 4 36332 NULL
99504 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
99505 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
99506 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
99507 +to_sector_36361 to_sector 0-1 36361 NULL
99508 +tunables_read_36385 tunables_read 3 36385 NULL
99509 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
99510 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
99511 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
99512 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
99513 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
99514 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
99515 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
99516 +get_param_l_36518 get_param_l 0 36518 NULL
99517 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
99518 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
99519 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
99520 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
99521 +get_entry_len_36549 get_entry_len 0 36549 NULL
99522 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
99523 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
99524 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
99525 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
99526 +__erst_read_36579 __erst_read 0 36579 NULL
99527 +put_cmsg_36589 put_cmsg 4 36589 NULL
99528 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
99529 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
99530 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
99531 +format_decode_36638 format_decode 0 36638 NULL
99532 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
99533 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
99534 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
99535 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
99536 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
99537 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
99538 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
99539 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
99540 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
99541 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
99542 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
99543 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
99544 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
99545 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
99546 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
99547 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
99548 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
99549 +cm_write_36858 cm_write 3 36858 NULL
99550 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
99551 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
99552 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
99553 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
99554 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
99555 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
99556 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
99557 +build_key_36931 build_key 1 36931 NULL
99558 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
99559 +write_leb_36957 write_leb 5 36957 NULL
99560 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
99561 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
99562 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
99563 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
99564 +setxattr_37006 setxattr 4 37006 NULL
99565 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
99566 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
99567 +parse_command_37079 parse_command 2 37079 NULL
99568 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
99569 +tun_get_user_37094 tun_get_user 5 37094 NULL
99570 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
99571 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
99572 +msg_word_37164 msg_word 0 37164 NULL
99573 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
99574 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
99575 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
99576 +__do_replace_37227 __do_replace 5 37227 NULL
99577 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
99578 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
99579 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
99580 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
99581 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
99582 +c101_run_37279 c101_run 2 37279 NULL
99583 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
99584 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
99585 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
99586 +send_msg_37323 send_msg 4 37323 NULL
99587 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
99588 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
99589 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
99590 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
99591 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
99592 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
99593 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
99594 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
99595 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
99596 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
99597 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
99598 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
99599 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
99600 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
99601 +__remove_37457 __remove 2 37457 NULL
99602 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
99603 +get_est_timing_37484 get_est_timing 0 37484 NULL
99604 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
99605 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
99606 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
99607 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
99608 +hdr_size_37536 hdr_size 0 37536 NULL
99609 +a2p_37544 a2p 0-1 37544 NULL
99610 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
99611 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
99612 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
99613 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
99614 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
99615 +policy_residency_37629 policy_residency 0 37629 NULL
99616 +check_pt_base_37635 check_pt_base 3 37635 NULL
99617 +alloc_fd_37637 alloc_fd 1 37637 NULL
99618 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
99619 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
99620 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
99621 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
99622 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
99623 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
99624 +nametbl_header_37698 nametbl_header 2 37698 NULL
99625 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
99626 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
99627 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
99628 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
99629 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
99630 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
99631 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
99632 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
99633 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
99634 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
99635 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
99636 +deny_write_access_37813 deny_write_access 0 37813 NULL
99637 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
99638 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
99639 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
99640 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
99641 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
99642 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
99643 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
99644 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
99645 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
99646 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
99647 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
99648 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
99649 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
99650 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
99651 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
99652 +vfs_readv_38011 vfs_readv 3 38011 NULL
99653 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
99654 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
99655 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
99656 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
99657 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
99658 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
99659 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
99660 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
99661 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
99662 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
99663 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
99664 +ep0_read_38095 ep0_read 3 38095 NULL
99665 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
99666 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
99667 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
99668 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
99669 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
99670 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
99671 +cdev_add_38176 cdev_add 2-3 38176 NULL
99672 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
99673 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
99674 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
99675 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
99676 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
99677 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
99678 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
99679 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
99680 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
99681 +from_dblock_38256 from_dblock 0-1 38256 NULL
99682 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
99683 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
99684 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
99685 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
99686 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
99687 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
99688 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
99689 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
99690 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
99691 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
99692 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
99693 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
99694 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
99695 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
99696 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
99697 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
99698 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
99699 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
99700 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
99701 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
99702 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
99703 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
99704 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
99705 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
99706 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
99707 +dev_names_read_38509 dev_names_read 3 38509 NULL
99708 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
99709 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
99710 +set_queue_count_38519 set_queue_count 0 38519 NULL
99711 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
99712 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
99713 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
99714 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
99715 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
99716 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
99717 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
99718 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
99719 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
99720 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
99721 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
99722 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
99723 +cma_create_area_38642 cma_create_area 2 38642 NULL
99724 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
99725 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
99726 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
99727 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
99728 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
99729 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
99730 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
99731 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
99732 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
99733 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
99734 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
99735 +udf_readpages_38761 udf_readpages 4 38761 NULL
99736 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
99737 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
99738 +err_decode_38804 err_decode 2 38804 NULL
99739 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
99740 +sys_select_38827 sys_select 1 38827 NULL
99741 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
99742 +direct_entry_38836 direct_entry 3 38836 NULL
99743 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
99744 +interfaces_38859 interfaces 2 38859 NULL
99745 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
99746 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
99747 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
99748 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
99749 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
99750 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
99751 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
99752 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
99753 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
99754 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
99755 +udf_new_block_38999 udf_new_block 4 38999 NULL
99756 +get_nodes_39012 get_nodes 3 39012 NULL
99757 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
99758 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
99759 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
99760 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
99761 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
99762 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
99763 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
99764 +ea_foreach_39133 ea_foreach 0 39133 NULL
99765 +generic_permission_39150 generic_permission 0 39150 NULL
99766 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
99767 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
99768 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
99769 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
99770 +init_list_set_39188 init_list_set 2-3 39188 NULL
99771 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
99772 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
99773 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
99774 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
99775 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
99776 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
99777 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
99778 +drm_order_39244 drm_order 0 39244 NULL
99779 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
99780 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
99781 +__skb_cow_39254 __skb_cow 2 39254 NULL
99782 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
99783 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
99784 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
99785 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
99786 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
99787 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
99788 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
99789 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
99790 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
99791 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
99792 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
99793 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
99794 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
99795 +__send_to_port_39386 __send_to_port 3 39386 NULL
99796 +user_power_read_39414 user_power_read 3 39414 NULL
99797 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
99798 +sys_semop_39457 sys_semop 3 39457 NULL
99799 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
99800 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
99801 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
99802 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
99803 +int_proc_write_39542 int_proc_write 3 39542 NULL
99804 +pp_write_39554 pp_write 3 39554 NULL
99805 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
99806 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
99807 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
99808 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
99809 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
99810 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
99811 +ext_depth_39607 ext_depth 0 39607 NULL
99812 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
99813 +sdio_readb_39618 sdio_readb 0 39618 NULL
99814 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
99815 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
99816 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
99817 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
99818 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
99819 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
99820 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
99821 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
99822 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
99823 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
99824 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
99825 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
99826 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
99827 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
99828 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
99829 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
99830 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
99831 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
99832 +pkt_add_39897 pkt_add 3 39897 NULL
99833 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
99834 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
99835 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
99836 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
99837 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
99838 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
99839 +__spi_async_39932 __spi_async 0 39932 NULL
99840 +__get_order_39935 __get_order 0 39935 NULL
99841 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
99842 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
99843 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
99844 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
99845 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
99846 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
99847 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
99848 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
99849 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
99850 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
99851 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
99852 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
99853 +add_tty_40055 add_tty 1 40055 NULL nohasharray
99854 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
99855 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
99856 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
99857 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
99858 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
99859 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
99860 +pt_write_40159 pt_write 3 40159 NULL
99861 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
99862 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
99863 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
99864 +allocate_probes_40204 allocate_probes 1 40204 NULL
99865 +compat_put_long_40214 compat_put_long 1 40214 NULL
99866 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
99867 +osst_read_40237 osst_read 3 40237 NULL
99868 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
99869 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
99870 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
99871 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
99872 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
99873 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
99874 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
99875 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
99876 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
99877 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
99878 +mmio_read_40348 mmio_read 4 40348 NULL
99879 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
99880 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
99881 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
99882 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
99883 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
99884 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
99885 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
99886 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
99887 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
99888 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
99889 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
99890 +tty_write_room_40495 tty_write_room 0 40495 NULL
99891 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
99892 +sg_phys_40507 sg_phys 0 40507 NULL
99893 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
99894 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
99895 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
99896 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
99897 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
99898 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
99899 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
99900 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
99901 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
99902 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
99903 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
99904 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
99905 +fops_read_40672 fops_read 3 40672 NULL
99906 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
99907 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
99908 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
99909 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
99910 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
99911 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
99912 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
99913 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
99914 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
99915 +card_send_command_40757 card_send_command 3 40757 NULL
99916 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
99917 +pg_write_40766 pg_write 3 40766 NULL
99918 +show_list_40775 show_list 3 40775 NULL
99919 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
99920 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
99921 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
99922 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
99923 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
99924 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
99925 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
99926 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
99927 +read_file_queue_40895 read_file_queue 3 40895 NULL
99928 +waiters_read_40902 waiters_read 3 40902 NULL
99929 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
99930 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
99931 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
99932 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
99933 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
99934 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
99935 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
99936 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
99937 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
99938 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
99939 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
99940 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
99941 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
99942 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
99943 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
99944 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
99945 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
99946 +dma_attach_41094 dma_attach 5-6 41094 NULL
99947 +provide_user_output_41105 provide_user_output 3 41105 NULL
99948 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
99949 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
99950 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
99951 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
99952 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
99953 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
99954 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
99955 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
99956 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
99957 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
99958 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99959 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99960 +erst_read_41260 erst_read 0 41260 NULL
99961 +__fprog_create_41263 __fprog_create 2 41263 NULL
99962 +alloc_context_41283 alloc_context 1 41283 NULL
99963 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99964 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99965 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99966 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99967 +kmp_init_41373 kmp_init 2 41373 NULL
99968 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99969 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
99970 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99971 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99972 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99973 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
99974 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99975 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99976 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99977 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99978 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99979 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99980 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99981 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99982 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99983 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99984 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99985 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99986 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99987 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99988 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99989 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99990 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99991 +vga_io_r_41609 vga_io_r 0 41609 NULL
99992 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
99993 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99994 +a2mp_send_41615 a2mp_send 4 41615 NULL
99995 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99996 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99997 +get_std_timing_41654 get_std_timing 0 41654 NULL
99998 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99999 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
100000 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
100001 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
100002 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
100003 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
100004 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
100005 +fillonedir_41746 fillonedir 3 41746 NULL
100006 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
100007 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
100008 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
100009 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
100010 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
100011 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
100012 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
100013 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
100014 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
100015 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
100016 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
100017 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
100018 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
100019 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
100020 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
100021 +portnames_read_41958 portnames_read 3 41958 NULL
100022 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
100023 +dst_mtu_41969 dst_mtu 0 41969 NULL
100024 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
100025 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
100026 +lguest_map_42008 lguest_map 1-2 42008 NULL
100027 +pool_allocate_42012 pool_allocate 3 42012 NULL
100028 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
100029 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
100030 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
100031 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
100032 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
100033 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
100034 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
100035 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
100036 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
100037 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
100038 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
100039 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
100040 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
100041 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
100042 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
100043 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
100044 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
100045 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
100046 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
100047 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
100048 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
100049 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
100050 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
100051 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
100052 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
100053 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
100054 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
100055 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
100056 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
100057 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
100058 +free_cblock_42318 free_cblock 2 42318 NULL
100059 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
100060 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
100061 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
100062 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
100063 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
100064 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
100065 +krng_get_random_42420 krng_get_random 3 42420 NULL
100066 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
100067 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
100068 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
100069 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
100070 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
100071 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
100072 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
100073 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
100074 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
100075 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
100076 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
100077 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
100078 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
100079 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
100080 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
100081 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
100082 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
100083 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
100084 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
100085 +map_state_42602 map_state 1 42602 NULL nohasharray
100086 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
100087 +nd_get_link_42603 nd_get_link 0 42603 NULL
100088 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
100089 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
100090 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
100091 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
100092 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
100093 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
100094 +vb2_read_42703 vb2_read 3 42703 NULL
100095 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
100096 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
100097 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
100098 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
100099 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
100100 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
100101 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
100102 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
100103 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
100104 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
100105 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
100106 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
100107 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
100108 +set_arg_42824 set_arg 3 42824 NULL
100109 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
100110 +prandom_u32_42853 prandom_u32 0 42853 NULL
100111 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
100112 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
100113 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
100114 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
100115 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
100116 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
100117 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
100118 +hd_end_request_42904 hd_end_request 2 42904 NULL
100119 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
100120 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
100121 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
100122 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
100123 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
100124 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
100125 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
100126 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
100127 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
100128 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
100129 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
100130 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
100131 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
100132 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
100133 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
100134 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
100135 +uuid_string_43154 uuid_string 0 43154 NULL
100136 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
100137 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
100138 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
100139 +process_measurement_43190 process_measurement 0 43190 NULL
100140 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
100141 +uio_write_43202 uio_write 3 43202 NULL
100142 +iso_callback_43208 iso_callback 3 43208 NULL
100143 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
100144 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
100145 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
100146 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
100147 +fixup_leb_43256 fixup_leb 3 43256 NULL
100148 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
100149 +evtchn_write_43278 evtchn_write 3 43278 NULL
100150 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
100151 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
100152 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
100153 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
100154 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
100155 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
100156 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
100157 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
100158 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
100159 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
100160 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
100161 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
100162 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
100163 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
100164 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
100165 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
100166 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
100167 +do_readlink_43518 do_readlink 2 43518 NULL
100168 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
100169 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
100170 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
100171 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
100172 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
100173 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
100174 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
100175 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
100176 +proc_read_43614 proc_read 3 43614 NULL
100177 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
100178 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
100179 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
100180 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
100181 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
100182 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
100183 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
100184 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
100185 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
100186 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
100187 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
100188 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
100189 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
100190 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
100191 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
100192 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
100193 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
100194 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
100195 +read_flush_43851 read_flush 3 43851 NULL
100196 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
100197 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
100198 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
100199 +SendString_43928 SendString 3 43928 NULL
100200 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
100201 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
100202 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
100203 +nla_reserve_43984 nla_reserve 3 43984 NULL
100204 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
100205 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
100206 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
100207 +emit_flags_44006 emit_flags 4-3 44006 NULL
100208 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
100209 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
100210 +load_discard_44083 load_discard 3 44083 NULL
100211 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
100212 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
100213 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
100214 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
100215 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
100216 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
100217 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
100218 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
100219 +__set_free_44211 __set_free 2 44211 NULL
100220 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
100221 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
100222 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
100223 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
100224 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
100225 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
100226 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
100227 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
100228 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
100229 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
100230 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
100231 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
100232 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
100233 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
100234 +__is_discarded_44359 __is_discarded 2 44359 NULL
100235 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
100236 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
100237 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
100238 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
100239 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
100240 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
100241 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
100242 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
100243 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
100244 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
100245 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
100246 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
100247 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
100248 +spidev_write_44510 spidev_write 3 44510 NULL
100249 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
100250 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
100251 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
100252 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
100253 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
100254 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
100255 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
100256 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
100257 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
100258 +mpi_resize_44674 mpi_resize 2 44674 NULL
100259 +ts_read_44687 ts_read 3 44687 NULL
100260 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
100261 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
100262 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
100263 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
100264 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
100265 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
100266 +set_brk_44749 set_brk 1 44749 NULL
100267 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
100268 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
100269 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
100270 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
100271 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
100272 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
100273 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
100274 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
100275 +sisusb_write_44834 sisusb_write 3 44834 NULL
100276 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
100277 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
100278 +skb_availroom_44883 skb_availroom 0 44883 NULL
100279 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
100280 +do_tty_write_44896 do_tty_write 5 44896 NULL
100281 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
100282 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
100283 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
100284 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
100285 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
100286 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
100287 +sel_write_user_45060 sel_write_user 3 45060 NULL
100288 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
100289 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
100290 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
100291 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
100292 +usbdev_read_45114 usbdev_read 3 45114 NULL
100293 +send_to_tty_45141 send_to_tty 3 45141 NULL
100294 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
100295 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
100296 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
100297 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
100298 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
100299 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
100300 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
100301 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
100302 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
100303 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
100304 +add_child_45201 add_child 4 45201 NULL
100305 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
100306 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
100307 +__dirty_45228 __dirty 2 45228 NULL
100308 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
100309 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
100310 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
100311 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
100312 +pte_val_45313 pte_val 0 45313 NULL
100313 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
100314 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
100315 +keymap_store_45406 keymap_store 4 45406 NULL
100316 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
100317 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
100318 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
100319 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
100320 +__node_remap_45458 __node_remap 4 45458 NULL
100321 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
100322 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
100323 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
100324 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
100325 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
100326 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
100327 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
100328 +copy_macs_45534 copy_macs 4 45534 NULL
100329 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
100330 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
100331 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
100332 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
100333 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
100334 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
100335 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
100336 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
100337 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
100338 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
100339 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
100340 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
100341 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
100342 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
100343 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
100344 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
100345 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
100346 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
100347 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
100348 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
100349 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
100350 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
100351 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
100352 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
100353 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
100354 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
100355 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
100356 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
100357 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
100358 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
100359 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
100360 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
100361 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
100362 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
100363 +isdn_write_45863 isdn_write 3 45863 NULL
100364 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
100365 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
100366 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
100367 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
100368 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
100369 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
100370 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
100371 +alloc_mr_45935 alloc_mr 1 45935 NULL
100372 +split_large_page_45941 split_large_page 2 45941 NULL
100373 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
100374 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
100375 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
100376 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
100377 +get_free_entries_46030 get_free_entries 1 46030 NULL
100378 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
100379 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
100380 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
100381 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
100382 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
100383 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
100384 +slhc_toss_46066 slhc_toss 0 46066 NULL
100385 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
100386 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
100387 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
100388 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
100389 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
100390 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
100391 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
100392 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
100393 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
100394 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
100395 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
100396 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
100397 +add_conn_list_46197 add_conn_list 3 46197 NULL
100398 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
100399 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
100400 +dsp_write_46218 dsp_write 2 46218 NULL
100401 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
100402 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
100403 +ReadReg_46277 ReadReg 0 46277 NULL
100404 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
100405 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
100406 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
100407 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
100408 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
100409 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
100410 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
100411 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
100412 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
100413 +filldir64_46469 filldir64 3 46469 NULL
100414 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
100415 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
100416 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
100417 +kmsg_read_46514 kmsg_read 3 46514 NULL
100418 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
100419 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
100420 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
100421 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
100422 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
100423 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
100424 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
100425 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
100426 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
100427 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
100428 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
100429 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
100430 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
100431 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
100432 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
100433 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
100434 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
100435 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
100436 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
100437 +prepare_copy_46725 prepare_copy 2 46725 NULL
100438 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
100439 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
100440 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
100441 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
100442 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
100443 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
100444 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
100445 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
100446 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
100447 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
100448 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
100449 +spi_async_46857 spi_async 0 46857 NULL
100450 +vsnprintf_46863 vsnprintf 0 46863 NULL
100451 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
100452 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
100453 +rvmalloc_46873 rvmalloc 1 46873 NULL
100454 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
100455 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
100456 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
100457 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
100458 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
100459 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
100460 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
100461 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
100462 +fb_write_46924 fb_write 3 46924 NULL
100463 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
100464 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
100465 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
100466 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
100467 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
100468 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
100469 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
100470 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
100471 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
100472 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
100473 +__map_single_47020 __map_single 3-4-7 47020 NULL
100474 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
100475 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
100476 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
100477 +fs_path_len_47060 fs_path_len 0 47060 NULL
100478 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
100479 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
100480 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
100481 +mousedev_read_47123 mousedev_read 3 47123 NULL
100482 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
100483 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
100484 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
100485 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
100486 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
100487 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
100488 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
100489 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
100490 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
100491 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
100492 +l2headersize_47238 l2headersize 0 47238 NULL
100493 +options_write_47243 options_write 3 47243 NULL
100494 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
100495 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
100496 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
100497 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
100498 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
100499 +vsnprintf_47291 vsnprintf 0 47291 NULL
100500 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
100501 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
100502 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
100503 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
100504 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
100505 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
100506 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
100507 +nametbl_list_47391 nametbl_list 2 47391 NULL
100508 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
100509 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
100510 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
100511 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
100512 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
100513 +vzalloc_47421 vzalloc 1 47421 NULL
100514 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
100515 +__load_mapping_47460 __load_mapping 2 47460 NULL
100516 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
100517 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
100518 +core_sys_select_47494 core_sys_select 1 47494 NULL
100519 +unlink_simple_47506 unlink_simple 3 47506 NULL
100520 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
100521 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
100522 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
100523 +oz_events_read_47535 oz_events_read 3 47535 NULL
100524 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
100525 +read_ldt_47570 read_ldt 2 47570 NULL
100526 +pci_iomap_47575 pci_iomap 3 47575 NULL
100527 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
100528 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
100529 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
100530 +uea_request_47613 uea_request 4 47613 NULL
100531 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
100532 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
100533 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
100534 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
100535 +save_microcode_47717 save_microcode 3 47717 NULL
100536 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
100537 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
100538 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
100539 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
100540 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
100541 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
100542 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
100543 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
100544 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
100545 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
100546 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
100547 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
100548 +vhci_read_47878 vhci_read 3 47878 NULL
100549 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
100550 +load_mapping_47904 load_mapping 3 47904 NULL
100551 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
100552 +comedi_write_47926 comedi_write 3 47926 NULL
100553 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
100554 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
100555 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
100556 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
100557 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
100558 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
100559 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
100560 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
100561 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
100562 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
100563 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
100564 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
100565 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
100566 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
100567 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
100568 +set_discoverable_48141 set_discoverable 4 48141 NULL
100569 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
100570 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
100571 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
100572 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
100573 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
100574 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
100575 +init_ipath_48187 init_ipath 1 48187 NULL
100576 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
100577 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
100578 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
100579 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
100580 +read_file_recv_48232 read_file_recv 3 48232 NULL
100581 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
100582 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
100583 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
100584 +send_set_info_48288 send_set_info 7 48288 NULL
100585 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
100586 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
100587 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
100588 +hash_setkey_48310 hash_setkey 3 48310 NULL
100589 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
100590 +skb_add_data_48363 skb_add_data 3 48363 NULL
100591 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
100592 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
100593 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
100594 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
100595 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
100596 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
100597 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
100598 +send_control_msg_48498 send_control_msg 6 48498 NULL
100599 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
100600 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
100601 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
100602 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
100603 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
100604 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
100605 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
100606 +named_distribute_48544 named_distribute 4 48544 NULL
100607 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
100608 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
100609 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
100610 +mtd_read_48655 mtd_read 0 48655 NULL
100611 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
100612 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
100613 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
100614 +altera_drscan_48698 altera_drscan 2 48698 NULL
100615 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
100616 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
100617 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
100618 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
100619 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
100620 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
100621 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
100622 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
100623 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
100624 +azx_get_position_48841 azx_get_position 0 48841 NULL
100625 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
100626 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
100627 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
100628 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
100629 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
100630 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
100631 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
100632 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
100633 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
100634 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
100635 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
100636 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
100637 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
100638 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
100639 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
100640 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
100641 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
100642 +transient_status_49027 transient_status 4 49027 NULL
100643 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
100644 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
100645 +ubi_read_49061 ubi_read 0 49061 NULL
100646 +scsi_register_49094 scsi_register 2 49094 NULL
100647 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
100648 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
100649 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
100650 +pt_read_49136 pt_read 3 49136 NULL
100651 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
100652 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
100653 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
100654 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
100655 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
100656 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
100657 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
100658 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
100659 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
100660 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
100661 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
100662 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
100663 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
100664 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
100665 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
100666 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
100667 +uio_read_49300 uio_read 3 49300 NULL
100668 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
100669 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
100670 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
100671 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
100672 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
100673 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
100674 +px_raw_event_49371 px_raw_event 4 49371 NULL
100675 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
100676 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
100677 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
100678 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
100679 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
100680 +md_domain_init_49432 md_domain_init 2 49432 NULL
100681 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
100682 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
100683 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
100684 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
100685 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
100686 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
100687 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
100688 +smk_write_access_49561 smk_write_access 3 49561 NULL
100689 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
100690 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
100691 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
100692 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
100693 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
100694 +heap_init_49617 heap_init 2 49617 NULL
100695 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
100696 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
100697 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
100698 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
100699 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
100700 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
100701 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
100702 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
100703 +check_frame_49741 check_frame 0 49741 NULL
100704 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
100705 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
100706 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
100707 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
100708 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
100709 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
100710 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
100711 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
100712 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
100713 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
100714 +add_uuid_49831 add_uuid 4 49831 NULL
100715 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
100716 +twl4030_write_49846 twl4030_write 2 49846 NULL
100717 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
100718 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
100719 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
100720 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
100721 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
100722 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
100723 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
100724 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
100725 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
100726 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
100727 +__module_alloc_50004 __module_alloc 1 50004 NULL
100728 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
100729 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
100730 +isdn_read_50021 isdn_read 3 50021 NULL
100731 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
100732 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
100733 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
100734 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
100735 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
100736 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
100737 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
100738 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
100739 +read_file_slot_50111 read_file_slot 3 50111 NULL
100740 +copy_items_50140 copy_items 6 50140 NULL
100741 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
100742 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
100743 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
100744 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
100745 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
100746 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
100747 +odev_update_50169 odev_update 2 50169 NULL
100748 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
100749 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
100750 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
100751 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
100752 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
100753 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
100754 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
100755 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
100756 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
100757 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
100758 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
100759 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
100760 +do_launder_page_50329 do_launder_page 0 50329 NULL
100761 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
100762 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
100763 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
100764 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
100765 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
100766 +tpm_read_50344 tpm_read 3 50344 NULL
100767 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
100768 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
100769 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
100770 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
100771 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
100772 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
100773 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
100774 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
100775 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
100776 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
100777 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
100778 +force_mapping_50464 force_mapping 2 50464 NULL
100779 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
100780 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
100781 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
100782 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
100783 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
100784 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
100785 +fat_readpages_50582 fat_readpages 4 50582 NULL
100786 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
100787 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
100788 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
100789 +__ffs_50625 __ffs 0 50625 NULL
100790 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
100791 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
100792 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
100793 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
100794 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
100795 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
100796 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
100797 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
100798 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
100799 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
100800 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
100801 +skb_padto_50759 skb_padto 2 50759 NULL
100802 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
100803 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
100804 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
100805 +tpm_write_50798 tpm_write 3 50798 NULL
100806 +write_flush_50803 write_flush 3 50803 NULL
100807 +dvb_play_50814 dvb_play 3 50814 NULL
100808 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
100809 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
100810 +SetArea_50835 SetArea 4 50835 NULL nohasharray
100811 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
100812 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
100813 +self_check_write_50856 self_check_write 5 50856 NULL
100814 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
100815 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
100816 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
100817 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
100818 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
100819 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
100820 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
100821 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
100822 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
100823 +timeout_write_50991 timeout_write 3 50991 NULL
100824 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
100825 +proc_write_51003 proc_write 3 51003 NULL
100826 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
100827 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
100828 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
100829 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
100830 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
100831 +dump_midi_51040 dump_midi 3 51040 NULL
100832 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
100833 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
100834 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
100835 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
100836 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
100837 +ti_recv_51110 ti_recv 3 51110 NULL
100838 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
100839 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
100840 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
100841 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
100842 +set_dirty_51144 set_dirty 3 51144 NULL
100843 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
100844 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
100845 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
100846 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
100847 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
100848 +tipc_send_51238 tipc_send 4 51238 NULL
100849 +drm_property_create_51239 drm_property_create 4 51239 NULL
100850 +st_read_51251 st_read 3 51251 NULL
100851 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
100852 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
100853 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
100854 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
100855 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
100856 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
100857 +get_cell_51316 get_cell 2 51316 NULL
100858 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
100859 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
100860 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
100861 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
100862 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
100863 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
100864 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
100865 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
100866 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
100867 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
100868 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
100869 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
100870 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
100871 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
100872 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
100873 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
100874 +vaddr_51480 vaddr 0 51480 NULL
100875 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
100876 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
100877 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
100878 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
100879 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
100880 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
100881 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
100882 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
100883 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
100884 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
100885 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
100886 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
100887 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
100888 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
100889 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
100890 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
100891 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
100892 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
100893 +sel_write_access_51704 sel_write_access 3 51704 NULL
100894 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
100895 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
100896 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
100897 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
100898 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
100899 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
100900 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
100901 +if_write_51756 if_write 3 51756 NULL
100902 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
100903 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
100904 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
100905 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
100906 +ioread32_51847 ioread32 0 51847 NULL nohasharray
100907 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
100908 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
100909 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
100910 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
100911 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
100912 +user_read_51881 user_read 3 51881 NULL
100913 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
100914 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
100915 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
100916 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
100917 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
100918 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
100919 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
100920 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
100921 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
100922 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
100923 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
100924 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
100925 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
100926 +rdmalt_52022 rdmalt 0 52022 NULL
100927 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
100928 +override_release_52032 override_release 2 52032 NULL
100929 +end_port_52042 end_port 0 52042 NULL
100930 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
100931 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
100932 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
100933 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
100934 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
100935 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
100936 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
100937 +retry_count_read_52129 retry_count_read 3 52129 NULL
100938 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
100939 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
100940 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
100941 +htable_size_52148 htable_size 0-1 52148 NULL
100942 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
100943 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
100944 +alix_present_52165 alix_present 1 52165 NULL
100945 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
100946 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
100947 +print_prefix_52176 print_prefix 0 52176 NULL
100948 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
100949 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
100950 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
100951 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
100952 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
100953 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
100954 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
100955 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
100956 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
100957 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100958 +read_file_reset_52310 read_file_reset 3 52310 NULL
100959 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100960 +hwflags_read_52318 hwflags_read 3 52318 NULL
100961 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100962 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100963 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100964 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100965 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
100966 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100967 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100968 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100969 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100970 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100971 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100972 +delay_status_52431 delay_status 5 52431 NULL
100973 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100974 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100975 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100976 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100977 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100978 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100979 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
100980 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100981 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100982 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
100983 +from_oblock_52546 from_oblock 0-1 52546 NULL
100984 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100985 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100986 +emit_code_52583 emit_code 0-3 52583 NULL
100987 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
100988 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100989 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100990 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100991 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100992 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100993 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100994 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100995 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
100996 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100997 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100998 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100999 +twlreg_write_52880 twlreg_write 3 52880 NULL
101000 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
101001 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
101002 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
101003 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
101004 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
101005 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
101006 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
101007 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
101008 +send_packet_52960 send_packet 4 52960 NULL
101009 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
101010 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
101011 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
101012 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
101013 +num_node_state_52989 num_node_state 0 52989 NULL
101014 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
101015 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
101016 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
101017 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
101018 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
101019 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
101020 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
101021 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
101022 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
101023 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
101024 +verity_status_53120 verity_status 5 53120 NULL
101025 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
101026 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
101027 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
101028 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
101029 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
101030 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
101031 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
101032 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
101033 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
101034 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
101035 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
101036 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
101037 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
101038 +vm_mmap_53339 vm_mmap 0 53339 NULL
101039 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
101040 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
101041 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
101042 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
101043 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
101044 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
101045 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
101046 +n2_run_53459 n2_run 3 53459 NULL
101047 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
101048 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
101049 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
101050 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
101051 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
101052 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
101053 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
101054 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
101055 +check_acl_53512 check_acl 0 53512 NULL
101056 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
101057 +set_registers_53582 set_registers 3 53582 NULL
101058 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
101059 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
101060 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
101061 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
101062 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
101063 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
101064 +_preload_range_53676 _preload_range 2-3 53676 NULL
101065 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
101066 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
101067 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
101068 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
101069 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
101070 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
101071 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
101072 +wdm_write_53735 wdm_write 3 53735 NULL
101073 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
101074 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
101075 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
101076 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
101077 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
101078 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
101079 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
101080 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
101081 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
101082 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
101083 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
101084 +pms_read_53873 pms_read 3 53873 NULL
101085 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
101086 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
101087 +proc_file_read_53905 proc_file_read 3 53905 NULL
101088 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
101089 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
101090 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
101091 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
101092 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
101093 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
101094 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
101095 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
101096 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
101097 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
101098 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
101099 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
101100 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
101101 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
101102 +_malloc_54077 _malloc 1 54077 NULL
101103 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
101104 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
101105 +create_xattr_54106 create_xattr 5 54106 NULL
101106 +strn_len_54122 strn_len 0 54122 NULL
101107 +isku_receive_54130 isku_receive 4 54130 NULL
101108 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
101109 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
101110 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
101111 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
101112 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
101113 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
101114 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
101115 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
101116 +reada_add_block_54247 reada_add_block 2 54247 NULL
101117 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
101118 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
101119 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
101120 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
101121 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
101122 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
101123 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
101124 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
101125 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
101126 +sprintf_54306 sprintf 0 54306 NULL
101127 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
101128 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
101129 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
101130 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
101131 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
101132 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
101133 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
101134 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
101135 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
101136 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
101137 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
101138 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
101139 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
101140 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
101141 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
101142 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
101143 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
101144 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
101145 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
101146 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
101147 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
101148 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
101149 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
101150 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
101151 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
101152 +viacam_read_54526 viacam_read 3 54526 NULL
101153 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
101154 +setsockopt_54539 setsockopt 5 54539 NULL
101155 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
101156 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
101157 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
101158 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
101159 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
101160 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
101161 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
101162 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
101163 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
101164 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
101165 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
101166 +evm_read_key_54674 evm_read_key 3 54674 NULL
101167 +resource_string_54699 resource_string 0 54699 NULL
101168 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
101169 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
101170 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
101171 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
101172 +kzalloc_54740 kzalloc 1 54740 NULL
101173 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
101174 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
101175 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
101176 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
101177 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
101178 +domain_init_54797 domain_init 2 54797 NULL
101179 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
101180 +get_dev_size_54807 get_dev_size 0 54807 NULL
101181 +nfsd_write_54809 nfsd_write 6 54809 NULL
101182 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
101183 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
101184 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
101185 +write_rio_54837 write_rio 3 54837 NULL
101186 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
101187 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
101188 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
101189 +printer_read_54851 printer_read 3 54851 NULL
101190 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
101191 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
101192 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
101193 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
101194 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
101195 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
101196 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
101197 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
101198 +add_port_54941 add_port 2 54941 NULL
101199 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
101200 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
101201 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
101202 +c4_add_card_54968 c4_add_card 3 54968 NULL
101203 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
101204 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
101205 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
101206 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
101207 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
101208 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
101209 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
101210 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
101211 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
101212 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
101213 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
101214 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
101215 +corrupt_data_55120 corrupt_data 0 55120 NULL
101216 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
101217 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
101218 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
101219 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
101220 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
101221 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
101222 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
101223 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
101224 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
101225 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
101226 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
101227 +dump_command_55220 dump_command 1 55220 NULL
101228 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
101229 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
101230 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
101231 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
101232 +ptrace_request_55288 ptrace_request 3 55288 NULL
101233 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
101234 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
101235 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
101236 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
101237 +do_shmat_55336 do_shmat 5 55336 NULL
101238 +vme_user_read_55338 vme_user_read 3 55338 NULL
101239 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
101240 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
101241 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
101242 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
101243 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
101244 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
101245 +alloc_skb_55439 alloc_skb 1 55439 NULL
101246 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
101247 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
101248 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
101249 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
101250 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
101251 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
101252 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
101253 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
101254 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
101255 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
101256 +ea_get_55522 ea_get 0 55522 NULL
101257 +buffer_size_55534 buffer_size 0 55534 NULL
101258 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
101259 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
101260 +add_partition_55588 add_partition 2 55588 NULL
101261 +free_pages_55603 free_pages 1 55603 NULL
101262 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
101263 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
101264 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
101265 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
101266 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
101267 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
101268 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
101269 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
101270 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
101271 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
101272 +read_oldmem_55658 read_oldmem 3 55658 NULL
101273 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
101274 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
101275 +get_info_55681 get_info 3 55681 NULL
101276 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
101277 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
101278 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
101279 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
101280 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
101281 +set_local_name_55757 set_local_name 4 55757 NULL
101282 +strlen_55778 strlen 0 55778 NULL
101283 +set_spte_55783 set_spte 5-4 55783 NULL
101284 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
101285 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
101286 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
101287 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
101288 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
101289 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
101290 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
101291 +hsc_write_55875 hsc_write 3 55875 NULL
101292 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
101293 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
101294 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
101295 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
101296 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
101297 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
101298 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
101299 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
101300 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
101301 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
101302 +__set_discard_56081 __set_discard 2 56081 NULL
101303 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
101304 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
101305 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
101306 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
101307 +map_addr_56144 map_addr 7 56144 NULL
101308 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
101309 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
101310 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
101311 +skb_headroom_56200 skb_headroom 0 56200 NULL
101312 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
101313 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
101314 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
101315 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
101316 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
101317 +fd_copyin_56247 fd_copyin 3 56247 NULL
101318 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
101319 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
101320 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
101321 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
101322 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
101323 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
101324 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
101325 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
101326 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
101327 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
101328 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
101329 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
101330 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
101331 +dev_read_56369 dev_read 3 56369 NULL
101332 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
101333 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
101334 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
101335 +store_msg_56417 store_msg 3 56417 NULL
101336 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
101337 +fl_create_56435 fl_create 5 56435 NULL
101338 +gnttab_map_56439 gnttab_map 2 56439 NULL
101339 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
101340 +set_connectable_56458 set_connectable 4 56458 NULL
101341 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
101342 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
101343 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
101344 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
101345 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
101346 +ip_options_get_56538 ip_options_get 4 56538 NULL
101347 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
101348 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
101349 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
101350 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
101351 +event_filter_write_56609 event_filter_write 3 56609 NULL
101352 +gather_array_56641 gather_array 3 56641 NULL
101353 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
101354 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
101355 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
101356 +build_map_info_56696 build_map_info 2 56696 NULL
101357 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
101358 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
101359 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
101360 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
101361 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
101362 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
101363 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
101364 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
101365 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
101366 +hash_lookup_56792 hash_lookup 2 56792 NULL
101367 +do_syslog_56807 do_syslog 3 56807 NULL
101368 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
101369 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
101370 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
101371 +wb_lookup_56858 wb_lookup 2 56858 NULL
101372 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
101373 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
101374 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
101375 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
101376 +strcspn_56913 strcspn 0 56913 NULL
101377 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
101378 +check_header_56930 check_header 2 56930 NULL
101379 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
101380 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
101381 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
101382 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
101383 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
101384 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
101385 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
101386 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
101387 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
101388 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
101389 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
101390 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
101391 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
101392 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
101393 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
101394 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
101395 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
101396 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
101397 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
101398 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
101399 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
101400 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
101401 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
101402 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
101403 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
101404 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
101405 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
101406 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
101407 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
101408 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
101409 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
101410 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
101411 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
101412 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
101413 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
101414 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
101415 +fw_file_size_57307 fw_file_size 0 57307 NULL
101416 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
101417 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
101418 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
101419 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
101420 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
101421 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
101422 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
101423 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
101424 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
101425 +read_file_blob_57406 read_file_blob 3 57406 NULL
101426 +enclosure_register_57412 enclosure_register 3 57412 NULL
101427 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
101428 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
101429 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
101430 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
101431 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
101432 +ReadReg_57453 ReadReg 0 57453 NULL
101433 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
101434 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
101435 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
101436 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
101437 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
101438 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
101439 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
101440 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
101441 +skb_headlen_57501 skb_headlen 0 57501 NULL
101442 +copy_in_user_57502 copy_in_user 3 57502 NULL
101443 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
101444 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
101445 +init_tag_map_57515 init_tag_map 3 57515 NULL
101446 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
101447 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
101448 +inode_permission_57531 inode_permission 0 57531 NULL
101449 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
101450 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
101451 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
101452 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
101453 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
101454 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
101455 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
101456 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
101457 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
101458 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
101459 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
101460 +mem_read_57631 mem_read 3 57631 NULL
101461 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
101462 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
101463 +r3964_write_57662 r3964_write 4 57662 NULL
101464 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
101465 +__lgwrite_57669 __lgwrite 4 57669 NULL
101466 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
101467 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
101468 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
101469 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
101470 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
101471 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
101472 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
101473 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
101474 +ld2_57794 ld2 0 57794 NULL
101475 +ivtv_read_57796 ivtv_read 3 57796 NULL
101476 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
101477 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
101478 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
101479 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
101480 +copy_to_user_57835 copy_to_user 3 57835 NULL
101481 +flash_read_57843 flash_read 3 57843 NULL
101482 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
101483 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
101484 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
101485 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
101486 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
101487 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
101488 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
101489 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
101490 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
101491 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
101492 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
101493 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
101494 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
101495 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
101496 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
101497 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
101498 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
101499 +mce_async_out_58056 mce_async_out 3 58056 NULL
101500 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
101501 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
101502 +cm4040_write_58079 cm4040_write 3 58079 NULL
101503 +udi_log_event_58105 udi_log_event 3 58105 NULL
101504 +savemem_58129 savemem 3 58129 NULL
101505 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
101506 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
101507 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
101508 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
101509 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
101510 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
101511 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
101512 +read_file_debug_58256 read_file_debug 3 58256 NULL
101513 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
101514 +profile_load_58267 profile_load 3 58267 NULL
101515 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
101516 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
101517 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
101518 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
101519 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
101520 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
101521 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
101522 +next_pidmap_58347 next_pidmap 2 58347 NULL
101523 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
101524 +save_hint_58359 save_hint 2 58359 NULL
101525 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
101526 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
101527 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
101528 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
101529 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
101530 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
101531 +capabilities_read_58457 capabilities_read 3 58457 NULL
101532 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
101533 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
101534 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
101535 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
101536 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
101537 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
101538 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
101539 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
101540 +__clear_discard_58546 __clear_discard 2 58546 NULL
101541 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
101542 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
101543 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
101544 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
101545 +xip_file_read_58592 xip_file_read 3 58592 NULL
101546 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
101547 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
101548 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
101549 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
101550 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
101551 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
101552 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
101553 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
101554 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
101555 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
101556 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
101557 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
101558 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
101559 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
101560 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
101561 +acpi_map_58725 acpi_map 1-2 58725 NULL
101562 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
101563 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
101564 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
101565 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
101566 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
101567 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
101568 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
101569 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
101570 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
101571 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
101572 +ep_read_58813 ep_read 3 58813 NULL
101573 +command_write_58841 command_write 3 58841 NULL
101574 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
101575 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
101576 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
101577 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
101578 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
101579 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
101580 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
101581 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
101582 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
101583 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
101584 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
101585 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
101586 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
101587 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
101588 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
101589 +ep_write_59008 ep_write 3 59008 NULL
101590 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
101591 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
101592 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
101593 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
101594 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
101595 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
101596 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
101597 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
101598 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
101599 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
101600 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
101601 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
101602 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
101603 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
101604 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
101605 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
101606 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
101607 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
101608 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
101609 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
101610 +dt3155_read_59226 dt3155_read 3 59226 NULL
101611 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
101612 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
101613 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
101614 +nla_len_59258 nla_len 0 59258 NULL
101615 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
101616 +fd_copyout_59323 fd_copyout 3 59323 NULL
101617 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
101618 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
101619 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
101620 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
101621 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
101622 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
101623 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
101624 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
101625 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
101626 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
101627 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
101628 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
101629 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
101630 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
101631 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
101632 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
101633 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
101634 +tunables_write_59563 tunables_write 3 59563 NULL
101635 +memdup_user_59590 memdup_user 2 59590 NULL
101636 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
101637 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
101638 +mtrr_write_59622 mtrr_write 3 59622 NULL
101639 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
101640 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
101641 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
101642 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
101643 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
101644 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
101645 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
101646 +sriov_enable_59689 sriov_enable 2 59689 NULL
101647 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
101648 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
101649 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
101650 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
101651 +strnlen_59746 strnlen 0 59746 NULL
101652 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
101653 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
101654 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
101655 +venus_remove_59781 venus_remove 4 59781 NULL
101656 +ipw_write_59807 ipw_write 3 59807 NULL
101657 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
101658 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
101659 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
101660 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
101661 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
101662 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
101663 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
101664 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
101665 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
101666 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
101667 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
101668 +lookup_node_59953 lookup_node 2 59953 NULL
101669 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
101670 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
101671 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
101672 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
101673 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
101674 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
101675 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
101676 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
101677 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
101678 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
101679 +register_device_60015 register_device 2-3 60015 NULL
101680 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
101681 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
101682 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
101683 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
101684 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
101685 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
101686 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
101687 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
101688 +compat_writev_60063 compat_writev 3 60063 NULL
101689 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
101690 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
101691 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
101692 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
101693 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
101694 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
101695 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
101696 +init_state_60165 init_state 2 60165 NULL
101697 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
101698 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
101699 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
101700 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
101701 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
101702 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
101703 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
101704 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
101705 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
101706 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
101707 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
101708 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
101709 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
101710 +printer_write_60276 printer_write 3 60276 NULL
101711 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
101712 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
101713 +getDataLength_60301 getDataLength 0 60301 NULL
101714 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
101715 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
101716 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
101717 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
101718 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
101719 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
101720 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
101721 +driver_names_read_60399 driver_names_read 3 60399 NULL
101722 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
101723 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
101724 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
101725 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
101726 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
101727 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
101728 +rx_data_60442 rx_data 4 60442 NULL
101729 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
101730 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
101731 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
101732 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
101733 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
101734 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
101735 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
101736 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
101737 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
101738 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
101739 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
101740 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
101741 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
101742 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
101743 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
101744 +init_data_container_60709 init_data_container 1 60709 NULL
101745 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
101746 +raid_status_60755 raid_status 5 60755 NULL
101747 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
101748 +opticon_write_60775 opticon_write 4 60775 NULL
101749 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
101750 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
101751 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
101752 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
101753 +generic_writepages_60871 generic_writepages 0 60871 NULL
101754 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
101755 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
101756 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
101757 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
101758 +sys_mlock_60932 sys_mlock 1 60932 NULL
101759 +pti_char_write_60960 pti_char_write 3 60960 NULL
101760 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
101761 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
101762 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
101763 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
101764 +symtab_init_61050 symtab_init 2 61050 NULL
101765 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
101766 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
101767 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
101768 +get_derived_key_61100 get_derived_key 4 61100 NULL
101769 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
101770 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
101771 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
101772 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
101773 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
101774 +__vmalloc_61168 __vmalloc 1 61168 NULL
101775 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
101776 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
101777 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
101778 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
101779 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
101780 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
101781 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
101782 +sys_add_key_61288 sys_add_key 4 61288 NULL
101783 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
101784 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
101785 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
101786 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
101787 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
101788 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
101789 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
101790 +change_xattr_61390 change_xattr 5 61390 NULL
101791 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
101792 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
101793 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
101794 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
101795 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
101796 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
101797 +erst_errno_61526 erst_errno 0 61526 NULL
101798 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
101799 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
101800 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
101801 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
101802 +seq_open_private_61589 seq_open_private 3 61589 NULL
101803 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
101804 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
101805 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
101806 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
101807 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
101808 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
101809 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
101810 +resize_stripes_61650 resize_stripes 2 61650 NULL
101811 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
101812 +insert_one_name_61668 insert_one_name 7 61668 NULL
101813 +lock_loop_61681 lock_loop 1 61681 NULL
101814 +filter_read_61692 filter_read 3 61692 NULL
101815 +iov_length_61716 iov_length 0 61716 NULL
101816 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
101817 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
101818 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
101819 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
101820 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
101821 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
101822 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
101823 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
101824 +get_fw_name_61874 get_fw_name 3 61874 NULL
101825 +free_init_pages_61875 free_init_pages 2 61875 NULL
101826 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
101827 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
101828 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
101829 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
101830 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
101831 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
101832 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
101833 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
101834 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
101835 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
101836 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
101837 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
101838 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
101839 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
101840 +cow_file_range_61979 cow_file_range 3 61979 NULL
101841 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
101842 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
101843 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
101844 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
101845 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
101846 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
101847 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
101848 +do_pselect_62061 do_pselect 1 62061 NULL
101849 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
101850 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
101851 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
101852 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
101853 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
101854 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
101855 +ql_status_62135 ql_status 5 62135 NULL
101856 +video_usercopy_62151 video_usercopy 2 62151 NULL
101857 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
101858 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
101859 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
101860 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
101861 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
101862 +allocate_partition_62245 allocate_partition 4 62245 NULL
101863 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
101864 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
101865 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
101866 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
101867 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
101868 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
101869 +subseq_list_62332 subseq_list 3-0 62332 NULL
101870 +flash_write_62354 flash_write 3 62354 NULL
101871 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
101872 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
101873 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
101874 +altera_irscan_62396 altera_irscan 2 62396 NULL
101875 +set_ssp_62411 set_ssp 4 62411 NULL
101876 +unmap_single_62423 unmap_single 2 62423 NULL
101877 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
101878 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
101879 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
101880 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
101881 +remove_mapping_62491 remove_mapping 2 62491 NULL
101882 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
101883 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
101884 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
101885 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
101886 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
101887 +debugfs_read_62535 debugfs_read 3 62535 NULL
101888 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
101889 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
101890 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
101891 +get_subdir_62581 get_subdir 3 62581 NULL
101892 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
101893 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
101894 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
101895 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
101896 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
101897 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
101898 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
101899 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
101900 +write_62671 write 3 62671 NULL
101901 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
101902 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
101903 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
101904 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
101905 +rdm_62719 rdm 0 62719 NULL
101906 +key_replays_read_62746 key_replays_read 3 62746 NULL
101907 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
101908 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
101909 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
101910 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
101911 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
101912 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
101913 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
101914 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
101915 +set_swbp_62853 set_swbp 3 62853 NULL
101916 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
101917 +aoechr_write_62883 aoechr_write 3 62883 NULL
101918 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
101919 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
101920 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
101921 +getdqbuf_62908 getdqbuf 1 62908 NULL
101922 +try_async_pf_62914 try_async_pf 3 62914 NULL
101923 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
101924 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
101925 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
101926 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
101927 +unlink1_63059 unlink1 3 63059 NULL
101928 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
101929 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
101930 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
101931 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
101932 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
101933 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
101934 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
101935 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
101936 +vme_master_read_63221 vme_master_read 0 63221 NULL
101937 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
101938 +ptp_read_63251 ptp_read 4 63251 NULL
101939 +raid5_resize_63306 raid5_resize 2 63306 NULL
101940 +proc_info_read_63344 proc_info_read 3 63344 NULL
101941 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
101942 +idmouse_read_63374 idmouse_read 3 63374 NULL
101943 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
101944 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
101945 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
101946 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
101947 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
101948 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
101949 +kone_send_63435 kone_send 4 63435 NULL
101950 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
101951 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
101952 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
101953 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
101954 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
101955 +read_kcore_63488 read_kcore 3 63488 NULL
101956 +save_hint_63497 save_hint 2 63497 NULL
101957 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
101958 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
101959 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
101960 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
101961 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
101962 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
101963 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
101964 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
101965 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
101966 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101967 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101968 +module_alloc_63630 module_alloc 1 63630 NULL
101969 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101970 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101971 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101972 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101973 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101974 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101975 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101976 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101977 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101978 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101979 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101980 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101981 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101982 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101983 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101984 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101985 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101986 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101987 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101988 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101989 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101990 +sel_write_load_63830 sel_write_load 3 63830 NULL
101991 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101992 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101993 +divas_write_63901 divas_write 3 63901 NULL
101994 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101995 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101996 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101997 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101998 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101999 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
102000 +__team_options_register_63941 __team_options_register 3 63941 NULL
102001 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
102002 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
102003 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
102004 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
102005 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
102006 +kmemdup_64015 kmemdup 2 64015 NULL
102007 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
102008 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
102009 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
102010 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
102011 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
102012 +get_u8_64076 get_u8 0 64076 NULL
102013 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
102014 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
102015 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
102016 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
102017 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
102018 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
102019 +init_bch_64130 init_bch 1-2 64130 NULL
102020 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
102021 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
102022 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
102023 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
102024 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
102025 +read_pulse_64227 read_pulse 0-3 64227 NULL
102026 +header_len_64232 header_len 0 64232 NULL
102027 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
102028 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
102029 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
102030 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
102031 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
102032 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
102033 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
102034 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
102035 +ffz_64324 ffz 0 64324 NULL
102036 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
102037 +ts_write_64336 ts_write 3 64336 NULL
102038 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
102039 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
102040 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
102041 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
102042 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
102043 +ilo_write_64378 ilo_write 3 64378 NULL
102044 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
102045 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
102046 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
102047 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
102048 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
102049 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
102050 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
102051 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
102052 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
102053 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
102054 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
102055 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
102056 +cap_capable_64462 cap_capable 0 64462 NULL
102057 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
102058 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
102059 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
102060 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
102061 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
102062 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
102063 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
102064 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
102065 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
102066 +__spi_sync_64561 __spi_sync 0 64561 NULL
102067 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
102068 +fanotify_write_64623 fanotify_write 3 64623 NULL
102069 +to_dblock_64655 to_dblock 0-1 64655 NULL
102070 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
102071 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
102072 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
102073 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
102074 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
102075 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
102076 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
102077 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
102078 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
102079 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
102080 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
102081 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
102082 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
102083 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
102084 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
102085 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
102086 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
102087 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
102088 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
102089 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
102090 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
102091 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
102092 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
102093 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
102094 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
102095 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
102096 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
102097 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
102098 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
102099 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
102100 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
102101 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
102102 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
102103 +pskb_pull_65005 pskb_pull 2 65005 NULL
102104 +unifi_write_65012 unifi_write 3 65012 NULL
102105 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
102106 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
102107 +insert_dent_65034 insert_dent 7 65034 NULL
102108 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
102109 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
102110 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
102111 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
102112 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
102113 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
102114 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
102115 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
102116 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
102117 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
102118 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
102119 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
102120 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
102121 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
102122 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
102123 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
102124 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
102125 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
102126 +get_var_len_65304 get_var_len 0 65304 NULL
102127 +unpack_array_65318 unpack_array 0 65318 NULL
102128 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
102129 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
102130 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
102131 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
102132 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
102133 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
102134 +strchr_65372 strchr 0 65372 NULL
102135 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
102136 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
102137 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
102138 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
102139 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
102140 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
102141 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
102142 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
102143 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
102144 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
102145 +alloc_dr_65495 alloc_dr 2 65495 NULL
102146 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
102147 new file mode 100644
102148 index 0000000..9db0d0e
102149 --- /dev/null
102150 +++ b/tools/gcc/size_overflow_plugin.c
102151 @@ -0,0 +1,2114 @@
102152 +/*
102153 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
102154 + * Licensed under the GPL v2, or (at your option) v3
102155 + *
102156 + * Homepage:
102157 + * http://www.grsecurity.net/~ephox/overflow_plugin/
102158 + *
102159 + * Documentation:
102160 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
102161 + *
102162 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
102163 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
102164 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
102165 + *
102166 + * Usage:
102167 + * $ 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
102168 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
102169 + */
102170 +
102171 +#include "gcc-plugin.h"
102172 +#include "config.h"
102173 +#include "system.h"
102174 +#include "coretypes.h"
102175 +#include "tree.h"
102176 +#include "tree-pass.h"
102177 +#include "intl.h"
102178 +#include "plugin-version.h"
102179 +#include "tm.h"
102180 +#include "toplev.h"
102181 +#include "function.h"
102182 +#include "tree-flow.h"
102183 +#include "plugin.h"
102184 +#include "gimple.h"
102185 +#include "diagnostic.h"
102186 +#include "cfgloop.h"
102187 +
102188 +#if BUILDING_GCC_VERSION >= 4008
102189 +#define TODO_dump_func 0
102190 +#endif
102191 +
102192 +struct size_overflow_hash {
102193 + const struct size_overflow_hash * const next;
102194 + const char * const name;
102195 + const unsigned int param;
102196 +};
102197 +
102198 +#include "size_overflow_hash.h"
102199 +
102200 +enum mark {
102201 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
102202 +};
102203 +
102204 +enum err_code_conditions {
102205 + CAST_ONLY, FROM_CONST
102206 +};
102207 +
102208 +static unsigned int call_count = 0;
102209 +
102210 +#define __unused __attribute__((__unused__))
102211 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
102212 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
102213 +#define BEFORE_STMT true
102214 +#define AFTER_STMT false
102215 +#define CREATE_NEW_VAR NULL_TREE
102216 +#define CODES_LIMIT 32
102217 +#define MAX_PARAM 31
102218 +#define MY_STMT GF_PLF_1
102219 +#define NO_CAST_CHECK GF_PLF_2
102220 +#define FROM_ARG true
102221 +#define FROM_RET false
102222 +
102223 +#if BUILDING_GCC_VERSION == 4005
102224 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
102225 +#endif
102226 +
102227 +int plugin_is_GPL_compatible;
102228 +void debug_gimple_stmt(gimple gs);
102229 +
102230 +static tree expand(struct pointer_set_t *visited, tree lhs);
102231 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
102232 +static tree report_size_overflow_decl;
102233 +static const_tree const_char_ptr_type_node;
102234 +static unsigned int handle_function(void);
102235 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
102236 +static tree get_size_overflow_type(gimple stmt, const_tree node);
102237 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
102238 +static void print_missing_msg(tree func, unsigned int argnum);
102239 +
102240 +static struct plugin_info size_overflow_plugin_info = {
102241 + .version = "20130410beta",
102242 + .help = "no-size-overflow\tturn off size overflow checking\n",
102243 +};
102244 +
102245 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
102246 +{
102247 + unsigned int arg_count;
102248 + enum tree_code code = TREE_CODE(*node);
102249 +
102250 + switch (code) {
102251 + case FUNCTION_DECL:
102252 + arg_count = type_num_arguments(TREE_TYPE(*node));
102253 + break;
102254 + case FUNCTION_TYPE:
102255 + case METHOD_TYPE:
102256 + arg_count = type_num_arguments(*node);
102257 + break;
102258 + default:
102259 + *no_add_attrs = true;
102260 + error("%s: %qE attribute only applies to functions", __func__, name);
102261 + return NULL_TREE;
102262 + }
102263 +
102264 + for (; args; args = TREE_CHAIN(args)) {
102265 + tree position = TREE_VALUE(args);
102266 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102267 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102268 + *no_add_attrs = true;
102269 + }
102270 + }
102271 + return NULL_TREE;
102272 +}
102273 +
102274 +static const char* get_asm_name(tree node)
102275 +{
102276 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
102277 +}
102278 +
102279 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
102280 +{
102281 + unsigned int arg_count, arg_num;
102282 + enum tree_code code = TREE_CODE(*node);
102283 +
102284 + switch (code) {
102285 + case FUNCTION_DECL:
102286 + arg_count = type_num_arguments(TREE_TYPE(*node));
102287 + break;
102288 + case FUNCTION_TYPE:
102289 + case METHOD_TYPE:
102290 + arg_count = type_num_arguments(*node);
102291 + break;
102292 + case FIELD_DECL:
102293 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
102294 + if (arg_num != 0) {
102295 + *no_add_attrs = true;
102296 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
102297 + }
102298 + return NULL_TREE;
102299 + default:
102300 + *no_add_attrs = true;
102301 + error("%qE attribute only applies to functions", name);
102302 + return NULL_TREE;
102303 + }
102304 +
102305 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
102306 + return NULL_TREE;
102307 +
102308 + for (; args; args = TREE_CHAIN(args)) {
102309 + tree position = TREE_VALUE(args);
102310 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102311 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102312 + *no_add_attrs = true;
102313 + }
102314 + }
102315 + return NULL_TREE;
102316 +}
102317 +
102318 +static struct attribute_spec size_overflow_attr = {
102319 + .name = "size_overflow",
102320 + .min_length = 1,
102321 + .max_length = -1,
102322 + .decl_required = true,
102323 + .type_required = false,
102324 + .function_type_required = false,
102325 + .handler = handle_size_overflow_attribute,
102326 +#if BUILDING_GCC_VERSION >= 4007
102327 + .affects_type_identity = false
102328 +#endif
102329 +};
102330 +
102331 +static struct attribute_spec intentional_overflow_attr = {
102332 + .name = "intentional_overflow",
102333 + .min_length = 1,
102334 + .max_length = -1,
102335 + .decl_required = true,
102336 + .type_required = false,
102337 + .function_type_required = false,
102338 + .handler = handle_intentional_overflow_attribute,
102339 +#if BUILDING_GCC_VERSION >= 4007
102340 + .affects_type_identity = false
102341 +#endif
102342 +};
102343 +
102344 +static void register_attributes(void __unused *event_data, void __unused *data)
102345 +{
102346 + register_attribute(&size_overflow_attr);
102347 + register_attribute(&intentional_overflow_attr);
102348 +}
102349 +
102350 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
102351 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
102352 +{
102353 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
102354 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
102355 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
102356 +
102357 + unsigned int m = 0x57559429;
102358 + unsigned int n = 0x5052acdb;
102359 + const unsigned int *key4 = (const unsigned int *)key;
102360 + unsigned int h = len;
102361 + unsigned int k = len + seed + n;
102362 + unsigned long long p;
102363 +
102364 + while (len >= 8) {
102365 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
102366 + len -= 8;
102367 + }
102368 + if (len >= 4) {
102369 + cwmixb(key4[0]) key4 += 1;
102370 + len -= 4;
102371 + }
102372 + if (len)
102373 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
102374 + cwmixb(h ^ (k + n));
102375 + return k ^ h;
102376 +
102377 +#undef cwfold
102378 +#undef cwmixa
102379 +#undef cwmixb
102380 +}
102381 +
102382 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
102383 +{
102384 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
102385 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
102386 + return fn ^ codes;
102387 +}
102388 +
102389 +static inline tree get_original_function_decl(tree fndecl)
102390 +{
102391 + if (DECL_ABSTRACT_ORIGIN(fndecl))
102392 + return DECL_ABSTRACT_ORIGIN(fndecl);
102393 + return fndecl;
102394 +}
102395 +
102396 +static inline gimple get_def_stmt(const_tree node)
102397 +{
102398 + gcc_assert(node != NULL_TREE);
102399 + if (TREE_CODE(node) != SSA_NAME)
102400 + return NULL;
102401 + return SSA_NAME_DEF_STMT(node);
102402 +}
102403 +
102404 +static unsigned char get_tree_code(const_tree type)
102405 +{
102406 + switch (TREE_CODE(type)) {
102407 + case ARRAY_TYPE:
102408 + return 0;
102409 + case BOOLEAN_TYPE:
102410 + return 1;
102411 + case ENUMERAL_TYPE:
102412 + return 2;
102413 + case FUNCTION_TYPE:
102414 + return 3;
102415 + case INTEGER_TYPE:
102416 + return 4;
102417 + case POINTER_TYPE:
102418 + return 5;
102419 + case RECORD_TYPE:
102420 + return 6;
102421 + case UNION_TYPE:
102422 + return 7;
102423 + case VOID_TYPE:
102424 + return 8;
102425 + case REAL_TYPE:
102426 + return 9;
102427 + case VECTOR_TYPE:
102428 + return 10;
102429 + case REFERENCE_TYPE:
102430 + return 11;
102431 + case OFFSET_TYPE:
102432 + return 12;
102433 + case COMPLEX_TYPE:
102434 + return 13;
102435 + default:
102436 + debug_tree((tree)type);
102437 + gcc_unreachable();
102438 + }
102439 +}
102440 +
102441 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
102442 +{
102443 + gcc_assert(type != NULL_TREE);
102444 +
102445 + while (type && len < CODES_LIMIT) {
102446 + tree_codes[len] = get_tree_code(type);
102447 + len++;
102448 + type = TREE_TYPE(type);
102449 + }
102450 + return len;
102451 +}
102452 +
102453 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
102454 +{
102455 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
102456 + enum tree_code code = TREE_CODE(type);
102457 + size_t len = 0;
102458 +
102459 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
102460 +
102461 + arg = TYPE_ARG_TYPES(type);
102462 + // skip builtins __builtin_constant_p
102463 + if (!arg && DECL_BUILT_IN(fndecl))
102464 + return 0;
102465 +
102466 + if (TREE_CODE_CLASS(code) == tcc_type)
102467 + result = type;
102468 + else
102469 + result = DECL_RESULT(fndecl);
102470 +
102471 + gcc_assert(result != NULL_TREE);
102472 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
102473 +
102474 + if (arg == NULL_TREE) {
102475 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
102476 + arg_field = DECL_ARGUMENT_FLD(fndecl);
102477 + if (arg_field == NULL_TREE)
102478 + return 0;
102479 + arg = TREE_TYPE(arg_field);
102480 + len = add_type_codes(arg, tree_codes, len);
102481 + gcc_assert(len != 0);
102482 + return len;
102483 + }
102484 +
102485 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
102486 + while (arg && len < CODES_LIMIT) {
102487 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
102488 + arg = TREE_CHAIN(arg);
102489 + }
102490 +
102491 + gcc_assert(len != 0);
102492 + return len;
102493 +}
102494 +
102495 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
102496 +{
102497 + unsigned int hash;
102498 + const struct size_overflow_hash *entry;
102499 + unsigned char tree_codes[CODES_LIMIT];
102500 + size_t len;
102501 + const char *func_name;
102502 +
102503 + fndecl = get_original_function_decl(fndecl);
102504 + len = get_function_decl(fndecl, tree_codes);
102505 + if (len == 0)
102506 + return NULL;
102507 +
102508 + func_name = get_asm_name(fndecl);
102509 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
102510 +
102511 + entry = size_overflow_hash[hash];
102512 + while (entry) {
102513 + if (!strcmp(entry->name, func_name))
102514 + return entry;
102515 + entry = entry->next;
102516 + }
102517 +
102518 + return NULL;
102519 +}
102520 +
102521 +static bool is_bool(const_tree node)
102522 +{
102523 + const_tree type;
102524 +
102525 + if (node == NULL_TREE)
102526 + return false;
102527 +
102528 + type = TREE_TYPE(node);
102529 + if (!INTEGRAL_TYPE_P(type))
102530 + return false;
102531 + if (TREE_CODE(type) == BOOLEAN_TYPE)
102532 + return true;
102533 + if (TYPE_PRECISION(type) == 1)
102534 + return true;
102535 + return false;
102536 +}
102537 +
102538 +static bool skip_types(const_tree var)
102539 +{
102540 + tree type;
102541 +
102542 + if (is_gimple_constant(var))
102543 + return true;
102544 +
102545 + switch (TREE_CODE(var)) {
102546 + case ADDR_EXPR:
102547 +#if BUILDING_GCC_VERSION >= 4006
102548 + case MEM_REF:
102549 +#endif
102550 + case ARRAY_REF:
102551 + case BIT_FIELD_REF:
102552 + case INDIRECT_REF:
102553 + case TARGET_MEM_REF:
102554 + return true;
102555 + case PARM_DECL:
102556 + case VAR_DECL:
102557 + case COMPONENT_REF:
102558 + return false;
102559 + default:
102560 + break;
102561 + }
102562 +
102563 + gcc_assert(TREE_CODE(var) == SSA_NAME);
102564 +
102565 + type = TREE_TYPE(var);
102566 + switch (TREE_CODE(type)) {
102567 + case INTEGER_TYPE:
102568 + case ENUMERAL_TYPE:
102569 + return false;
102570 + case BOOLEAN_TYPE:
102571 + return is_bool(var);
102572 + default:
102573 + break;
102574 + }
102575 +
102576 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
102577 +
102578 + type = TREE_TYPE(type);
102579 + gcc_assert(type != NULL_TREE);
102580 + switch (TREE_CODE(type)) {
102581 + case RECORD_TYPE:
102582 + case POINTER_TYPE:
102583 + case ARRAY_TYPE:
102584 + return true;
102585 + case VOID_TYPE:
102586 + case INTEGER_TYPE:
102587 + case UNION_TYPE:
102588 + return false;
102589 + default:
102590 + break;
102591 + }
102592 +
102593 + debug_tree((tree)var);
102594 + gcc_unreachable();
102595 +}
102596 +
102597 +static unsigned int find_arg_number(const_tree arg, tree func)
102598 +{
102599 + tree var;
102600 + unsigned int argnum = 1;
102601 +
102602 + if (TREE_CODE(arg) == SSA_NAME)
102603 + arg = SSA_NAME_VAR(arg);
102604 +
102605 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
102606 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
102607 + continue;
102608 + if (!skip_types(var))
102609 + return argnum;
102610 + }
102611 +
102612 + return 0;
102613 +}
102614 +
102615 +static tree create_new_var(tree type)
102616 +{
102617 + tree new_var = create_tmp_var(type, "cicus");
102618 +
102619 +#if BUILDING_GCC_VERSION <= 4007
102620 + add_referenced_var(new_var);
102621 + mark_sym_for_renaming(new_var);
102622 +#endif
102623 + return new_var;
102624 +}
102625 +
102626 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
102627 +{
102628 + gimple assign;
102629 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102630 + tree type = TREE_TYPE(rhs1);
102631 + tree lhs = create_new_var(type);
102632 +
102633 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
102634 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
102635 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102636 +
102637 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102638 + update_stmt(assign);
102639 + gimple_set_plf(assign, MY_STMT, true);
102640 + return assign;
102641 +}
102642 +
102643 +static tree cast_a_tree(tree type, tree var)
102644 +{
102645 + gcc_assert(type != NULL_TREE);
102646 + gcc_assert(var != NULL_TREE);
102647 + gcc_assert(fold_convertible_p(type, var));
102648 +
102649 + return fold_convert(type, var);
102650 +}
102651 +
102652 +static tree get_lhs(const_gimple stmt)
102653 +{
102654 + switch (gimple_code(stmt)) {
102655 + case GIMPLE_ASSIGN:
102656 + return gimple_get_lhs(stmt);
102657 + case GIMPLE_PHI:
102658 + return gimple_phi_result(stmt);
102659 + case GIMPLE_CALL:
102660 + return gimple_call_lhs(stmt);
102661 + default:
102662 + return NULL_TREE;
102663 + }
102664 +}
102665 +
102666 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
102667 +{
102668 + const_gimple def_stmt = get_def_stmt(rhs);
102669 +
102670 + if (force)
102671 + return false;
102672 +
102673 + if (is_gimple_constant(rhs))
102674 + return false;
102675 +
102676 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102677 + return false;
102678 +
102679 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
102680 + return false;
102681 +
102682 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
102683 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102684 + return false;
102685 +
102686 + return true;
102687 +}
102688 +
102689 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
102690 +{
102691 + gimple assign, def_stmt;
102692 +
102693 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
102694 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
102695 + gcc_unreachable();
102696 +
102697 + def_stmt = get_def_stmt(rhs);
102698 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
102699 + return def_stmt;
102700 +
102701 + if (lhs == CREATE_NEW_VAR)
102702 + lhs = create_new_var(dst_type);
102703 +
102704 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
102705 +
102706 + if (!gsi_end_p(*gsi)) {
102707 + location_t loc = gimple_location(gsi_stmt(*gsi));
102708 + gimple_set_location(assign, loc);
102709 + }
102710 +
102711 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102712 +
102713 + if (before)
102714 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
102715 + else
102716 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
102717 + update_stmt(assign);
102718 + gimple_set_plf(assign, MY_STMT, true);
102719 +
102720 + return assign;
102721 +}
102722 +
102723 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
102724 +{
102725 + gimple_stmt_iterator gsi;
102726 + tree lhs;
102727 + const_gimple new_stmt;
102728 +
102729 + if (rhs == NULL_TREE)
102730 + return NULL_TREE;
102731 +
102732 + gsi = gsi_for_stmt(stmt);
102733 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
102734 +
102735 + lhs = get_lhs(new_stmt);
102736 + gcc_assert(lhs != NULL_TREE);
102737 + return lhs;
102738 +}
102739 +
102740 +static tree cast_to_TI_type(gimple stmt, tree node)
102741 +{
102742 + gimple_stmt_iterator gsi;
102743 + gimple cast_stmt;
102744 + tree type = TREE_TYPE(node);
102745 +
102746 + if (types_compatible_p(type, intTI_type_node))
102747 + return node;
102748 +
102749 + gsi = gsi_for_stmt(stmt);
102750 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102751 + return gimple_get_lhs(cast_stmt);
102752 +}
102753 +
102754 +static void check_function_hash(const_gimple stmt)
102755 +{
102756 + tree func;
102757 + const struct size_overflow_hash *hash;
102758 +
102759 + if (gimple_code(stmt) != GIMPLE_CALL)
102760 + return;
102761 +
102762 + func = gimple_call_fndecl(stmt);
102763 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
102764 + if (func == NULL_TREE)
102765 + return;
102766 +
102767 + hash = get_function_hash(func);
102768 + if (!hash)
102769 + print_missing_msg(func, 0);
102770 +}
102771 +
102772 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
102773 +{
102774 + tree lhs, new_lhs;
102775 + gimple_stmt_iterator gsi;
102776 +
102777 + if (rhs1 == NULL_TREE) {
102778 + debug_gimple_stmt(oldstmt);
102779 + error("%s: rhs1 is NULL_TREE", __func__);
102780 + gcc_unreachable();
102781 + }
102782 +
102783 + switch (gimple_code(oldstmt)) {
102784 + case GIMPLE_ASM:
102785 + lhs = rhs1;
102786 + break;
102787 + case GIMPLE_CALL:
102788 + lhs = gimple_call_lhs(oldstmt);
102789 + break;
102790 + case GIMPLE_ASSIGN:
102791 + lhs = gimple_get_lhs(oldstmt);
102792 + break;
102793 + default:
102794 + debug_gimple_stmt(oldstmt);
102795 + gcc_unreachable();
102796 + }
102797 +
102798 + gsi = gsi_for_stmt(oldstmt);
102799 + pointer_set_insert(visited, oldstmt);
102800 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
102801 + basic_block next_bb, cur_bb;
102802 + const_edge e;
102803 +
102804 + gcc_assert(before == false);
102805 + gcc_assert(stmt_can_throw_internal(oldstmt));
102806 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
102807 + gcc_assert(!gsi_end_p(gsi));
102808 +
102809 + cur_bb = gimple_bb(oldstmt);
102810 + next_bb = cur_bb->next_bb;
102811 + e = find_edge(cur_bb, next_bb);
102812 + gcc_assert(e != NULL);
102813 + gcc_assert(e->flags & EDGE_FALLTHRU);
102814 +
102815 + gsi = gsi_after_labels(next_bb);
102816 + gcc_assert(!gsi_end_p(gsi));
102817 +
102818 + before = true;
102819 + oldstmt = gsi_stmt(gsi);
102820 + }
102821 +
102822 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
102823 + return new_lhs;
102824 +}
102825 +
102826 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
102827 +{
102828 + gimple stmt;
102829 + gimple_stmt_iterator gsi;
102830 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
102831 +
102832 + if (gimple_plf(oldstmt, MY_STMT))
102833 + return lhs;
102834 +
102835 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
102836 + rhs1 = gimple_assign_rhs1(oldstmt);
102837 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
102838 + }
102839 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
102840 + rhs2 = gimple_assign_rhs2(oldstmt);
102841 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
102842 + }
102843 +
102844 + stmt = gimple_copy(oldstmt);
102845 + gimple_set_location(stmt, gimple_location(oldstmt));
102846 + gimple_set_plf(stmt, MY_STMT, true);
102847 +
102848 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
102849 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
102850 +
102851 + size_overflow_type = get_size_overflow_type(oldstmt, node);
102852 +
102853 + new_var = create_new_var(size_overflow_type);
102854 + new_var = make_ssa_name(new_var, stmt);
102855 + gimple_set_lhs(stmt, new_var);
102856 +
102857 + if (rhs1 != NULL_TREE)
102858 + gimple_assign_set_rhs1(stmt, rhs1);
102859 +
102860 + if (rhs2 != NULL_TREE)
102861 + gimple_assign_set_rhs2(stmt, rhs2);
102862 +#if BUILDING_GCC_VERSION >= 4007
102863 + if (rhs3 != NULL_TREE)
102864 + gimple_assign_set_rhs3(stmt, rhs3);
102865 +#endif
102866 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
102867 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
102868 +
102869 + gsi = gsi_for_stmt(oldstmt);
102870 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
102871 + update_stmt(stmt);
102872 + pointer_set_insert(visited, oldstmt);
102873 + return gimple_get_lhs(stmt);
102874 +}
102875 +
102876 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
102877 +{
102878 + basic_block first_bb;
102879 + gimple assign;
102880 + gimple_stmt_iterator gsi;
102881 +
102882 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102883 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102884 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
102885 +
102886 + gsi = gsi_start_bb(first_bb);
102887 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102888 + return gimple_get_lhs(assign);
102889 +}
102890 +
102891 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
102892 +{
102893 + gimple_stmt_iterator gsi;
102894 + const_gimple assign;
102895 + gimple def_stmt = get_def_stmt(new_arg);
102896 +
102897 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
102898 + gsi = gsi_after_labels(gimple_bb(def_stmt));
102899 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
102900 + } else {
102901 + gsi = gsi_for_stmt(def_stmt);
102902 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
102903 + }
102904 +
102905 + return gimple_get_lhs(assign);
102906 +}
102907 +
102908 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
102909 +{
102910 + basic_block bb;
102911 + gimple_stmt_iterator gsi;
102912 + const_gimple assign, def_stmt;
102913 +
102914 + def_stmt = get_def_stmt(arg);
102915 + bb = gimple_bb(def_stmt);
102916 + gcc_assert(bb->index != 0);
102917 + gsi = gsi_after_labels(bb);
102918 +
102919 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102920 + return gimple_get_lhs(assign);
102921 +}
102922 +
102923 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
102924 +{
102925 + tree size_overflow_type;
102926 + const_gimple def_stmt = get_def_stmt(arg);
102927 +
102928 + if (phi_ssa_name != NULL_TREE)
102929 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
102930 +
102931 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
102932 +
102933 + if (new_arg != NULL_TREE) {
102934 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
102935 + return use_phi_ssa_name(phi_ssa_name, new_arg);
102936 + }
102937 +
102938 + switch(gimple_code(def_stmt)) {
102939 + case GIMPLE_PHI:
102940 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
102941 + case GIMPLE_NOP:
102942 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
102943 + default:
102944 + debug_gimple_stmt((gimple)def_stmt);
102945 + gcc_unreachable();
102946 + }
102947 +}
102948 +
102949 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
102950 +{
102951 + basic_block bb;
102952 + gimple phi;
102953 + gimple_seq seq;
102954 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
102955 +
102956 + bb = gsi_bb(gsi);
102957 +
102958 + phi = create_phi_node(result, bb);
102959 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
102960 + seq = phi_nodes(bb);
102961 + gsi = gsi_last(seq);
102962 + gsi_remove(&gsi, false);
102963 +
102964 + gsi = gsi_for_stmt(oldstmt);
102965 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
102966 + gimple_set_bb(phi, bb);
102967 + gimple_set_plf(phi, MY_STMT, true);
102968 + return phi;
102969 +}
102970 +
102971 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102972 +{
102973 + gimple new_phi = NULL;
102974 + gimple oldstmt = get_def_stmt(orig_result);
102975 + tree phi_ssa_name = NULL_TREE;
102976 + unsigned int i;
102977 +
102978 + pointer_set_insert(visited, oldstmt);
102979 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102980 + tree arg, new_arg;
102981 +
102982 + arg = gimple_phi_arg_def(oldstmt, i);
102983 +
102984 + new_arg = expand(visited, arg);
102985 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102986 + if (i == 0) {
102987 + phi_ssa_name = new_arg;
102988 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102989 + }
102990 +
102991 + gcc_assert(new_phi != NULL);
102992 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102993 + }
102994 +
102995 + gcc_assert(new_phi != NULL);
102996 + update_stmt(new_phi);
102997 + return gimple_phi_result(new_phi);
102998 +}
102999 +
103000 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
103001 +{
103002 + const_gimple assign;
103003 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103004 + tree origtype = TREE_TYPE(orig_rhs);
103005 +
103006 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
103007 +
103008 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
103009 + return gimple_get_lhs(assign);
103010 +}
103011 +
103012 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
103013 +{
103014 + const_tree rhs1, lhs, rhs1_type, lhs_type;
103015 + enum machine_mode lhs_mode, rhs_mode;
103016 + gimple def_stmt = get_def_stmt(no_const_rhs);
103017 +
103018 + if (!gimple_assign_cast_p(def_stmt))
103019 + return false;
103020 +
103021 + rhs1 = gimple_assign_rhs1(def_stmt);
103022 + lhs = gimple_get_lhs(def_stmt);
103023 + rhs1_type = TREE_TYPE(rhs1);
103024 + lhs_type = TREE_TYPE(lhs);
103025 + rhs_mode = TYPE_MODE(rhs1_type);
103026 + lhs_mode = TYPE_MODE(lhs_type);
103027 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
103028 + return false;
103029 +
103030 + return true;
103031 +}
103032 +
103033 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
103034 +{
103035 + tree rhs1 = gimple_assign_rhs1(stmt);
103036 + tree lhs = gimple_get_lhs(stmt);
103037 + const_tree rhs1_type = TREE_TYPE(rhs1);
103038 + const_tree lhs_type = TREE_TYPE(lhs);
103039 +
103040 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
103041 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103042 +
103043 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
103044 +}
103045 +
103046 +static bool no_uses(tree node)
103047 +{
103048 + imm_use_iterator imm_iter;
103049 + use_operand_p use_p;
103050 +
103051 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
103052 + const_gimple use_stmt = USE_STMT(use_p);
103053 + if (use_stmt == NULL)
103054 + return true;
103055 + if (is_gimple_debug(use_stmt))
103056 + continue;
103057 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
103058 + continue;
103059 + return false;
103060 + }
103061 + return true;
103062 +}
103063 +
103064 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
103065 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
103066 +{
103067 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
103068 + gimple def_stmt = get_def_stmt(lhs);
103069 +
103070 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103071 + return false;
103072 +
103073 + rhs1 = gimple_assign_rhs1(def_stmt);
103074 + rhs_type = TREE_TYPE(rhs1);
103075 + lhs_type = TREE_TYPE(lhs);
103076 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
103077 + return false;
103078 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
103079 + return false;
103080 +
103081 + def_stmt = get_def_stmt(rhs1);
103082 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
103083 + return false;
103084 +
103085 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
103086 + return false;
103087 +
103088 + rhs1 = gimple_assign_rhs1(def_stmt);
103089 + rhs2 = gimple_assign_rhs2(def_stmt);
103090 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
103091 + return false;
103092 +
103093 + if (is_gimple_constant(rhs2))
103094 + not_const_rhs = rhs1;
103095 + else
103096 + not_const_rhs = rhs2;
103097 +
103098 + return no_uses(not_const_rhs);
103099 +}
103100 +
103101 +static bool skip_lhs_cast_check(const_gimple stmt)
103102 +{
103103 + const_tree rhs = gimple_assign_rhs1(stmt);
103104 + const_gimple def_stmt = get_def_stmt(rhs);
103105 +
103106 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
103107 + if (gimple_code(def_stmt) == GIMPLE_ASM)
103108 + return true;
103109 +
103110 + if (is_const_plus_unsigned_signed_truncation(rhs))
103111 + return true;
103112 +
103113 + return false;
103114 +}
103115 +
103116 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
103117 +{
103118 + bool cast_lhs, cast_rhs;
103119 + tree lhs = gimple_get_lhs(stmt);
103120 + tree rhs = gimple_assign_rhs1(stmt);
103121 + const_tree lhs_type = TREE_TYPE(lhs);
103122 + const_tree rhs_type = TREE_TYPE(rhs);
103123 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
103124 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
103125 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
103126 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
103127 +
103128 + static bool check_lhs[3][4] = {
103129 + // ss su us uu
103130 + { false, true, true, false }, // lhs > rhs
103131 + { false, false, false, false }, // lhs = rhs
103132 + { true, true, true, true }, // lhs < rhs
103133 + };
103134 +
103135 + static bool check_rhs[3][4] = {
103136 + // ss su us uu
103137 + { true, false, true, true }, // lhs > rhs
103138 + { true, false, true, true }, // lhs = rhs
103139 + { true, false, true, true }, // lhs < rhs
103140 + };
103141 +
103142 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
103143 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
103144 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103145 +
103146 + if (lhs_size > rhs_size) {
103147 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103148 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103149 + } else if (lhs_size == rhs_size) {
103150 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103151 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103152 + } else {
103153 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103154 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
103155 + }
103156 +
103157 + if (!cast_lhs && !cast_rhs)
103158 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103159 +
103160 + if (cast_lhs && !skip_lhs_cast_check(stmt))
103161 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
103162 +
103163 + if (cast_rhs)
103164 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
103165 +
103166 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103167 +}
103168 +
103169 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
103170 +{
103171 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
103172 +
103173 + if (gimple_plf(stmt, MY_STMT))
103174 + return lhs;
103175 +
103176 + rhs1 = gimple_assign_rhs1(stmt);
103177 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
103178 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103179 +
103180 + new_rhs1 = expand(visited, rhs1);
103181 +
103182 + if (new_rhs1 == NULL_TREE)
103183 + return create_cast_assign(visited, stmt);
103184 +
103185 + if (gimple_plf(stmt, NO_CAST_CHECK))
103186 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103187 +
103188 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
103189 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
103190 +
103191 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
103192 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
103193 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103194 + }
103195 +
103196 + if (!gimple_assign_cast_p(stmt))
103197 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
103198 +
103199 + return create_cast_overflow_check(visited, new_rhs1, stmt);
103200 +}
103201 +
103202 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
103203 +{
103204 + tree rhs1, lhs = gimple_get_lhs(stmt);
103205 + gimple def_stmt = get_def_stmt(lhs);
103206 +
103207 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
103208 + rhs1 = gimple_assign_rhs1(def_stmt);
103209 +
103210 + if (is_gimple_constant(rhs1))
103211 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103212 +
103213 + switch (TREE_CODE(rhs1)) {
103214 + case SSA_NAME:
103215 + return handle_unary_rhs(visited, def_stmt);
103216 + case ARRAY_REF:
103217 + case BIT_FIELD_REF:
103218 + case ADDR_EXPR:
103219 + case COMPONENT_REF:
103220 + case INDIRECT_REF:
103221 +#if BUILDING_GCC_VERSION >= 4006
103222 + case MEM_REF:
103223 +#endif
103224 + case TARGET_MEM_REF:
103225 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103226 + case PARM_DECL:
103227 + case VAR_DECL:
103228 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103229 +
103230 + default:
103231 + debug_gimple_stmt(def_stmt);
103232 + debug_tree(rhs1);
103233 + gcc_unreachable();
103234 + }
103235 +}
103236 +
103237 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
103238 +{
103239 + gimple cond_stmt;
103240 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
103241 +
103242 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
103243 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
103244 + update_stmt(cond_stmt);
103245 +}
103246 +
103247 +static tree create_string_param(tree string)
103248 +{
103249 + tree i_type, a_type;
103250 + const int length = TREE_STRING_LENGTH(string);
103251 +
103252 + gcc_assert(length > 0);
103253 +
103254 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
103255 + a_type = build_array_type(char_type_node, i_type);
103256 +
103257 + TREE_TYPE(string) = a_type;
103258 + TREE_CONSTANT(string) = 1;
103259 + TREE_READONLY(string) = 1;
103260 +
103261 + return build1(ADDR_EXPR, ptr_type_node, string);
103262 +}
103263 +
103264 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
103265 +{
103266 + gimple func_stmt;
103267 + const_gimple def_stmt;
103268 + const_tree loc_line;
103269 + tree loc_file, ssa_name, current_func;
103270 + expanded_location xloc;
103271 + char *ssa_name_buf;
103272 + int len;
103273 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
103274 +
103275 + def_stmt = get_def_stmt(arg);
103276 + xloc = expand_location(gimple_location(def_stmt));
103277 +
103278 + if (!gimple_has_location(def_stmt)) {
103279 + xloc = expand_location(gimple_location(stmt));
103280 + if (!gimple_has_location(stmt))
103281 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
103282 + }
103283 +
103284 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
103285 +
103286 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
103287 + loc_file = create_string_param(loc_file);
103288 +
103289 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
103290 + current_func = create_string_param(current_func);
103291 +
103292 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
103293 + call_count++;
103294 + 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);
103295 + gcc_assert(len > 0);
103296 + ssa_name = build_string(len + 1, ssa_name_buf);
103297 + free(ssa_name_buf);
103298 + ssa_name = create_string_param(ssa_name);
103299 +
103300 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
103301 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
103302 +
103303 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
103304 +}
103305 +
103306 +static void __unused print_the_code_insertions(const_gimple stmt)
103307 +{
103308 + location_t loc = gimple_location(stmt);
103309 +
103310 + inform(loc, "Integer size_overflow check applied here.");
103311 +}
103312 +
103313 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
103314 +{
103315 + basic_block cond_bb, join_bb, bb_true;
103316 + edge e;
103317 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103318 +
103319 + cond_bb = gimple_bb(stmt);
103320 + if (before)
103321 + gsi_prev(&gsi);
103322 + if (gsi_end_p(gsi))
103323 + e = split_block_after_labels(cond_bb);
103324 + else
103325 + e = split_block(cond_bb, gsi_stmt(gsi));
103326 + cond_bb = e->src;
103327 + join_bb = e->dest;
103328 + e->flags = EDGE_FALSE_VALUE;
103329 + e->probability = REG_BR_PROB_BASE;
103330 +
103331 + bb_true = create_empty_bb(cond_bb);
103332 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
103333 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
103334 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
103335 +
103336 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
103337 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
103338 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
103339 +
103340 + if (current_loops != NULL) {
103341 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
103342 + add_bb_to_loop(bb_true, cond_bb->loop_father);
103343 + }
103344 +
103345 + insert_cond(cond_bb, arg, cond_code, type_value);
103346 + insert_cond_result(bb_true, stmt, arg, min);
103347 +
103348 +// print_the_code_insertions(stmt);
103349 +}
103350 +
103351 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
103352 +{
103353 + const_tree rhs_type = TREE_TYPE(rhs);
103354 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
103355 +
103356 + gcc_assert(rhs_type != NULL_TREE);
103357 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
103358 + return;
103359 +
103360 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
103361 +
103362 + if (is_const_plus_unsigned_signed_truncation(rhs))
103363 + return;
103364 +
103365 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
103366 + // typemax (-1) < typemin (0)
103367 + if (TREE_OVERFLOW(type_max))
103368 + return;
103369 +
103370 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
103371 +
103372 + cast_rhs_type = TREE_TYPE(cast_rhs);
103373 + type_max_type = TREE_TYPE(type_max);
103374 + type_min_type = TREE_TYPE(type_min);
103375 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
103376 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
103377 +
103378 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
103379 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
103380 +}
103381 +
103382 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
103383 +{
103384 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
103385 + return false;
103386 + if (!is_gimple_constant(rhs))
103387 + return false;
103388 + return true;
103389 +}
103390 +
103391 +static tree get_def_stmt_rhs(const_tree var)
103392 +{
103393 + tree rhs1, def_stmt_rhs1;
103394 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
103395 +
103396 + def_stmt = get_def_stmt(var);
103397 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
103398 +
103399 + rhs1 = gimple_assign_rhs1(def_stmt);
103400 + rhs1_def_stmt = get_def_stmt(rhs1);
103401 + if (!gimple_assign_cast_p(rhs1_def_stmt))
103402 + return rhs1;
103403 +
103404 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103405 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
103406 +
103407 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
103408 + case GIMPLE_CALL:
103409 + case GIMPLE_NOP:
103410 + case GIMPLE_ASM:
103411 + case GIMPLE_PHI:
103412 + return def_stmt_rhs1;
103413 + case GIMPLE_ASSIGN:
103414 + return rhs1;
103415 + default:
103416 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
103417 + gcc_unreachable();
103418 + }
103419 +}
103420 +
103421 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
103422 +{
103423 + tree new_rhs, orig_rhs;
103424 + void (*gimple_assign_set_rhs)(gimple, tree);
103425 + tree rhs1 = gimple_assign_rhs1(stmt);
103426 + tree rhs2 = gimple_assign_rhs2(stmt);
103427 + tree lhs = gimple_get_lhs(stmt);
103428 +
103429 + if (!check_overflow)
103430 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103431 +
103432 + if (change_rhs == NULL_TREE)
103433 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103434 +
103435 + if (new_rhs2 == NULL_TREE) {
103436 + orig_rhs = rhs1;
103437 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
103438 + } else {
103439 + orig_rhs = rhs2;
103440 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
103441 + }
103442 +
103443 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
103444 +
103445 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
103446 + gimple_assign_set_rhs(stmt, new_rhs);
103447 + update_stmt(stmt);
103448 +
103449 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103450 +}
103451 +
103452 +static bool is_subtraction_special(const_gimple stmt)
103453 +{
103454 + gimple rhs1_def_stmt, rhs2_def_stmt;
103455 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
103456 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
103457 + const_tree rhs1 = gimple_assign_rhs1(stmt);
103458 + const_tree rhs2 = gimple_assign_rhs2(stmt);
103459 +
103460 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
103461 + return false;
103462 +
103463 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
103464 +
103465 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
103466 + return false;
103467 +
103468 + rhs1_def_stmt = get_def_stmt(rhs1);
103469 + rhs2_def_stmt = get_def_stmt(rhs2);
103470 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
103471 + return false;
103472 +
103473 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103474 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
103475 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
103476 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
103477 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
103478 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
103479 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
103480 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
103481 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
103482 + return false;
103483 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
103484 + return false;
103485 +
103486 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
103487 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
103488 + return true;
103489 +}
103490 +
103491 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
103492 +{
103493 + tree new_rhs1, new_rhs2;
103494 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
103495 + gimple assign, stmt = get_def_stmt(lhs);
103496 + tree rhs1 = gimple_assign_rhs1(stmt);
103497 + tree rhs2 = gimple_assign_rhs2(stmt);
103498 +
103499 + if (!is_subtraction_special(stmt))
103500 + return NULL_TREE;
103501 +
103502 + new_rhs1 = expand(visited, rhs1);
103503 + new_rhs2 = expand(visited, rhs2);
103504 +
103505 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
103506 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
103507 +
103508 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
103509 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
103510 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
103511 + }
103512 +
103513 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
103514 + new_lhs = gimple_get_lhs(assign);
103515 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
103516 +
103517 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103518 +}
103519 +
103520 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
103521 +{
103522 + const_gimple def_stmt;
103523 +
103524 + if (TREE_CODE(rhs) != SSA_NAME)
103525 + return false;
103526 +
103527 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
103528 + return false;
103529 +
103530 + def_stmt = get_def_stmt(rhs);
103531 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
103532 + return false;
103533 +
103534 + return true;
103535 +}
103536 +
103537 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
103538 +{
103539 + tree rhs1, rhs2, new_lhs;
103540 + gimple def_stmt = get_def_stmt(lhs);
103541 + tree new_rhs1 = NULL_TREE;
103542 + tree new_rhs2 = NULL_TREE;
103543 +
103544 + rhs1 = gimple_assign_rhs1(def_stmt);
103545 + rhs2 = gimple_assign_rhs2(def_stmt);
103546 +
103547 + /* no DImode/TImode division in the 32/64 bit kernel */
103548 + switch (gimple_assign_rhs_code(def_stmt)) {
103549 + case RDIV_EXPR:
103550 + case TRUNC_DIV_EXPR:
103551 + case CEIL_DIV_EXPR:
103552 + case FLOOR_DIV_EXPR:
103553 + case ROUND_DIV_EXPR:
103554 + case TRUNC_MOD_EXPR:
103555 + case CEIL_MOD_EXPR:
103556 + case FLOOR_MOD_EXPR:
103557 + case ROUND_MOD_EXPR:
103558 + case EXACT_DIV_EXPR:
103559 + case POINTER_PLUS_EXPR:
103560 + case BIT_AND_EXPR:
103561 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103562 + default:
103563 + break;
103564 + }
103565 +
103566 + new_lhs = handle_integer_truncation(visited, lhs);
103567 + if (new_lhs != NULL_TREE)
103568 + return new_lhs;
103569 +
103570 + if (TREE_CODE(rhs1) == SSA_NAME)
103571 + new_rhs1 = expand(visited, rhs1);
103572 + if (TREE_CODE(rhs2) == SSA_NAME)
103573 + new_rhs2 = expand(visited, rhs2);
103574 +
103575 + if (is_a_neg_overflow(def_stmt, rhs2))
103576 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
103577 + if (is_a_neg_overflow(def_stmt, rhs1))
103578 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
103579 +
103580 +
103581 + if (is_a_constant_overflow(def_stmt, rhs2))
103582 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
103583 + if (is_a_constant_overflow(def_stmt, rhs1))
103584 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
103585 +
103586 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103587 +}
103588 +
103589 +#if BUILDING_GCC_VERSION >= 4007
103590 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
103591 +{
103592 + if (is_gimple_constant(rhs))
103593 + return cast_a_tree(size_overflow_type, rhs);
103594 + if (TREE_CODE(rhs) != SSA_NAME)
103595 + return NULL_TREE;
103596 + return expand(visited, rhs);
103597 +}
103598 +
103599 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
103600 +{
103601 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
103602 + gimple def_stmt = get_def_stmt(lhs);
103603 +
103604 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
103605 +
103606 + rhs1 = gimple_assign_rhs1(def_stmt);
103607 + rhs2 = gimple_assign_rhs2(def_stmt);
103608 + rhs3 = gimple_assign_rhs3(def_stmt);
103609 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
103610 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
103611 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
103612 +
103613 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
103614 +}
103615 +#endif
103616 +
103617 +static tree get_size_overflow_type(gimple stmt, const_tree node)
103618 +{
103619 + const_tree type;
103620 + tree new_type;
103621 +
103622 + gcc_assert(node != NULL_TREE);
103623 +
103624 + type = TREE_TYPE(node);
103625 +
103626 + if (gimple_plf(stmt, MY_STMT))
103627 + return TREE_TYPE(node);
103628 +
103629 + switch (TYPE_MODE(type)) {
103630 + case QImode:
103631 + new_type = intHI_type_node;
103632 + break;
103633 + case HImode:
103634 + new_type = intSI_type_node;
103635 + break;
103636 + case SImode:
103637 + new_type = intDI_type_node;
103638 + break;
103639 + case DImode:
103640 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
103641 + new_type = intDI_type_node;
103642 + else
103643 + new_type = intTI_type_node;
103644 + break;
103645 + default:
103646 + debug_tree((tree)node);
103647 + error("%s: unsupported gcc configuration.", __func__);
103648 + gcc_unreachable();
103649 + }
103650 +
103651 + if (TYPE_QUALS(type) != 0)
103652 + return build_qualified_type(new_type, TYPE_QUALS(type));
103653 + return new_type;
103654 +}
103655 +
103656 +static tree expand_visited(gimple def_stmt)
103657 +{
103658 + const_gimple next_stmt;
103659 + gimple_stmt_iterator gsi;
103660 + enum gimple_code code = gimple_code(def_stmt);
103661 +
103662 + if (code == GIMPLE_ASM)
103663 + return NULL_TREE;
103664 +
103665 + gsi = gsi_for_stmt(def_stmt);
103666 + gsi_next(&gsi);
103667 +
103668 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
103669 + return NULL_TREE;
103670 + gcc_assert(!gsi_end_p(gsi));
103671 + next_stmt = gsi_stmt(gsi);
103672 +
103673 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
103674 + return NULL_TREE;
103675 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
103676 +
103677 + return get_lhs(next_stmt);
103678 +}
103679 +
103680 +static tree expand(struct pointer_set_t *visited, tree lhs)
103681 +{
103682 + gimple def_stmt;
103683 +
103684 + if (skip_types(lhs))
103685 + return NULL_TREE;
103686 +
103687 + def_stmt = get_def_stmt(lhs);
103688 +
103689 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
103690 + return NULL_TREE;
103691 +
103692 + if (gimple_plf(def_stmt, MY_STMT))
103693 + return lhs;
103694 +
103695 + if (pointer_set_contains(visited, def_stmt))
103696 + return expand_visited(def_stmt);
103697 +
103698 + switch (gimple_code(def_stmt)) {
103699 + case GIMPLE_PHI:
103700 + return handle_phi(visited, lhs);
103701 + case GIMPLE_CALL:
103702 + case GIMPLE_ASM:
103703 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103704 + case GIMPLE_ASSIGN:
103705 + switch (gimple_num_ops(def_stmt)) {
103706 + case 2:
103707 + return handle_unary_ops(visited, def_stmt);
103708 + case 3:
103709 + return handle_binary_ops(visited, lhs);
103710 +#if BUILDING_GCC_VERSION >= 4007
103711 + case 4:
103712 + return handle_ternary_ops(visited, lhs);
103713 +#endif
103714 + }
103715 + default:
103716 + debug_gimple_stmt(def_stmt);
103717 + error("%s: unknown gimple code", __func__);
103718 + gcc_unreachable();
103719 + }
103720 +}
103721 +
103722 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
103723 +{
103724 + const_gimple assign;
103725 + tree orig_type = TREE_TYPE(orig_node);
103726 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103727 +
103728 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
103729 + return gimple_get_lhs(assign);
103730 +}
103731 +
103732 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
103733 +{
103734 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
103735 + update_stmt(stmt);
103736 +}
103737 +
103738 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
103739 +{
103740 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
103741 + update_stmt(stmt);
103742 +}
103743 +
103744 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
103745 +{
103746 + tree arg;
103747 + const_tree origarg;
103748 +
103749 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
103750 + return true;
103751 +
103752 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
103753 + while (origarg && *argnum) {
103754 + (*argnum)--;
103755 + origarg = TREE_CHAIN(origarg);
103756 + }
103757 +
103758 + gcc_assert(*argnum == 0);
103759 +
103760 + gcc_assert(origarg != NULL_TREE);
103761 + *argnum = 0;
103762 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
103763 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
103764 + return true;
103765 + return false;
103766 +}
103767 +
103768 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
103769 +{
103770 + gimple phi = get_def_stmt(result);
103771 + unsigned int i, n = gimple_phi_num_args(phi);
103772 +
103773 + if (!phi)
103774 + return MARK_NO;
103775 +
103776 + pointer_set_insert(visited, phi);
103777 + for (i = 0; i < n; i++) {
103778 + enum mark marked;
103779 + const_tree arg = gimple_phi_arg_def(phi, i);
103780 + marked = pre_expand(visited, search_err_code, arg);
103781 + if (marked != MARK_NO)
103782 + return marked;
103783 + }
103784 + return MARK_NO;
103785 +}
103786 +
103787 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103788 +{
103789 + gimple def_stmt = get_def_stmt(lhs);
103790 + const_tree rhs;
103791 +
103792 + if (!def_stmt)
103793 + return MARK_NO;
103794 +
103795 + rhs = gimple_assign_rhs1(def_stmt);
103796 +
103797 + def_stmt = get_def_stmt(rhs);
103798 + if (is_gimple_constant(rhs))
103799 + search_err_code[FROM_CONST] = true;
103800 +
103801 + return pre_expand(visited, search_err_code, rhs);
103802 +}
103803 +
103804 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103805 +{
103806 + gimple def_stmt = get_def_stmt(lhs);
103807 + const_tree rhs1, rhs2;
103808 + enum mark marked;
103809 +
103810 + if (!def_stmt)
103811 + return MARK_NO;
103812 +
103813 + search_err_code[CAST_ONLY] = false;
103814 +
103815 + rhs1 = gimple_assign_rhs1(def_stmt);
103816 + rhs2 = gimple_assign_rhs2(def_stmt);
103817 + marked = pre_expand(visited, search_err_code, rhs1);
103818 + if (marked != MARK_NO)
103819 + return marked;
103820 + return pre_expand(visited, search_err_code, rhs2);
103821 +}
103822 +
103823 +static const_tree search_field_decl(const_tree comp_ref)
103824 +{
103825 + const_tree field = NULL_TREE;
103826 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
103827 +
103828 + for (i = 0; i < len; i++) {
103829 + field = TREE_OPERAND(comp_ref, i);
103830 + if (TREE_CODE(field) == FIELD_DECL)
103831 + break;
103832 + }
103833 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
103834 + return field;
103835 +}
103836 +
103837 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
103838 +{
103839 + const_tree attr, p;
103840 +
103841 + // 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);
103842 + if (fndecl == NULL_TREE)
103843 + return MARK_NO;
103844 +
103845 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
103846 + if (!attr || !TREE_VALUE(attr))
103847 + return MARK_NO;
103848 +
103849 + p = TREE_VALUE(attr);
103850 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
103851 + return MARK_TURN_OFF;
103852 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
103853 + return MARK_NOT_INTENTIONAL;
103854 + if (argnum == 0) {
103855 + gcc_assert(current_function_decl == fndecl);
103856 + return MARK_NO;
103857 + }
103858 +
103859 + do {
103860 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
103861 + return MARK_YES;
103862 + p = TREE_CHAIN(p);
103863 + } while (p);
103864 +
103865 + return MARK_NO;
103866 +}
103867 +
103868 +static void print_missing_msg(tree func, unsigned int argnum)
103869 +{
103870 + unsigned int new_hash;
103871 + size_t len;
103872 + unsigned char tree_codes[CODES_LIMIT];
103873 + location_t loc;
103874 + const char *curfunc;
103875 +
103876 + func = get_original_function_decl(func);
103877 + loc = DECL_SOURCE_LOCATION(func);
103878 + curfunc = get_asm_name(func);
103879 +
103880 + len = get_function_decl(func, tree_codes);
103881 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
103882 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
103883 +}
103884 +
103885 +static unsigned int search_missing_attribute(const_tree arg)
103886 +{
103887 + unsigned int argnum;
103888 + const struct size_overflow_hash *hash;
103889 + const_tree type = TREE_TYPE(arg);
103890 + tree func = get_original_function_decl(current_function_decl);
103891 +
103892 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
103893 +
103894 + if (TREE_CODE(type) == POINTER_TYPE)
103895 + return 0;
103896 +
103897 + argnum = find_arg_number(arg, func);
103898 + if (argnum == 0)
103899 + return 0;
103900 +
103901 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
103902 + return argnum;
103903 +
103904 + hash = get_function_hash(func);
103905 + if (!hash || !(hash->param & (1U << argnum))) {
103906 + print_missing_msg(func, argnum);
103907 + return 0;
103908 + }
103909 + return argnum;
103910 +}
103911 +
103912 +static enum mark is_already_marked(const_tree lhs)
103913 +{
103914 + unsigned int argnum;
103915 + const_tree fndecl;
103916 +
103917 + argnum = search_missing_attribute(lhs);
103918 + fndecl = get_original_function_decl(current_function_decl);
103919 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
103920 + return MARK_YES;
103921 + return MARK_NO;
103922 +}
103923 +
103924 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103925 +{
103926 + const_gimple def_stmt;
103927 +
103928 + if (skip_types(lhs))
103929 + return MARK_NO;
103930 +
103931 + if (TREE_CODE(lhs) == PARM_DECL)
103932 + return is_already_marked(lhs);
103933 +
103934 + if (TREE_CODE(lhs) == COMPONENT_REF) {
103935 + const_tree field, attr;
103936 +
103937 + field = search_field_decl(lhs);
103938 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
103939 + if (!attr || !TREE_VALUE(attr))
103940 + return MARK_NO;
103941 + return MARK_YES;
103942 + }
103943 +
103944 + def_stmt = get_def_stmt(lhs);
103945 +
103946 + if (!def_stmt)
103947 + return MARK_NO;
103948 +
103949 + if (pointer_set_contains(visited, def_stmt))
103950 + return MARK_NO;
103951 +
103952 + switch (gimple_code(def_stmt)) {
103953 + case GIMPLE_NOP:
103954 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
103955 + return is_already_marked(lhs);
103956 + return MARK_NO;
103957 + case GIMPLE_PHI:
103958 + return walk_phi(visited, search_err_code, lhs);
103959 + case GIMPLE_CALL:
103960 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
103961 + return MARK_TURN_OFF;
103962 + check_function_hash(def_stmt);
103963 + return MARK_NO;
103964 + case GIMPLE_ASM:
103965 + search_err_code[CAST_ONLY] = false;
103966 + return MARK_NO;
103967 + case GIMPLE_ASSIGN:
103968 + switch (gimple_num_ops(def_stmt)) {
103969 + case 2:
103970 + return walk_unary_ops(visited, search_err_code, lhs);
103971 + case 3:
103972 + return walk_binary_ops(visited, search_err_code, lhs);
103973 + }
103974 + default:
103975 + debug_gimple_stmt((gimple)def_stmt);
103976 + error("%s: unknown gimple code", __func__);
103977 + gcc_unreachable();
103978 + }
103979 +}
103980 +
103981 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103982 +static bool skip_asm(const_tree arg)
103983 +{
103984 + gimple def_stmt = get_def_stmt(arg);
103985 +
103986 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103987 + return false;
103988 +
103989 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103990 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103991 +}
103992 +
103993 +/*
103994 +0</MARK_YES: no dup, search attributes (so, int)
103995 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103996 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103997 +*/
103998 +
103999 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
104000 +{
104001 + struct pointer_set_t *visited;
104002 + enum mark is_marked, is_found;
104003 + location_t loc;
104004 + bool search_err_code[2] = {true, false};
104005 +
104006 + is_marked = mark_status(current_function_decl, 0);
104007 + if (is_marked == MARK_TURN_OFF)
104008 + return true;
104009 +
104010 + is_marked = mark_status(fndecl, argnum + 1);
104011 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
104012 + return true;
104013 +
104014 + visited = pointer_set_create();
104015 + is_found = pre_expand(visited, search_err_code, arg);
104016 + pointer_set_destroy(visited);
104017 +
104018 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
104019 + return true;
104020 +
104021 + if (where == FROM_ARG && skip_asm(arg))
104022 + return true;
104023 +
104024 + if (is_found == MARK_TURN_OFF)
104025 + return true;
104026 +
104027 + if ((is_found == MARK_YES && is_marked == MARK_YES))
104028 + return true;
104029 +
104030 + if (is_found == MARK_YES) {
104031 + loc = DECL_SOURCE_LOCATION(fndecl);
104032 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
104033 + return true;
104034 + }
104035 + return false;
104036 +}
104037 +
104038 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
104039 +{
104040 + struct pointer_set_t *visited;
104041 + tree arg, new_arg;
104042 + bool match;
104043 +
104044 + if (argnum == 0)
104045 + return;
104046 +
104047 + argnum--;
104048 +
104049 + match = get_function_arg(&argnum, fndecl);
104050 + if (!match)
104051 + return;
104052 + gcc_assert(gimple_call_num_args(stmt) > argnum);
104053 + arg = gimple_call_arg(stmt, argnum);
104054 + if (arg == NULL_TREE)
104055 + return;
104056 +
104057 + if (skip_types(arg))
104058 + return;
104059 +
104060 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
104061 + return;
104062 +
104063 + visited = pointer_set_create();
104064 + new_arg = expand(visited, arg);
104065 + pointer_set_destroy(visited);
104066 +
104067 + if (new_arg == NULL_TREE)
104068 + return;
104069 +
104070 + change_function_arg(stmt, arg, argnum, new_arg);
104071 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
104072 +}
104073 +
104074 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
104075 +{
104076 + tree p = TREE_VALUE(attr);
104077 + do {
104078 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
104079 + p = TREE_CHAIN(p);
104080 + } while (p);
104081 +}
104082 +
104083 +static void handle_function_by_hash(gimple stmt, tree fndecl)
104084 +{
104085 + unsigned int num;
104086 + const struct size_overflow_hash *hash;
104087 +
104088 + hash = get_function_hash(fndecl);
104089 + if (!hash)
104090 + return;
104091 +
104092 + for (num = 0; num <= MAX_PARAM; num++)
104093 + if (hash->param & (1U << num))
104094 + handle_function_arg(stmt, fndecl, num);
104095 +}
104096 +
104097 +static bool check_return_value(void)
104098 +{
104099 + const struct size_overflow_hash *hash;
104100 +
104101 + hash = get_function_hash(current_function_decl);
104102 + if (!hash || !(hash->param & 1U << 0))
104103 + return false;
104104 +
104105 + return true;
104106 +}
104107 +
104108 +static void handle_return_value(gimple ret_stmt)
104109 +{
104110 + struct pointer_set_t *visited;
104111 + tree ret, new_ret;
104112 +
104113 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
104114 + return;
104115 +
104116 + ret = gimple_return_retval(ret_stmt);
104117 +
104118 + if (skip_types(ret))
104119 + return;
104120 +
104121 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
104122 + return;
104123 +
104124 + visited = pointer_set_create();
104125 + new_ret = expand(visited, ret);
104126 + pointer_set_destroy(visited);
104127 +
104128 + change_function_return(ret_stmt, ret, new_ret);
104129 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
104130 +}
104131 +
104132 +static void set_plf_false(void)
104133 +{
104134 + basic_block bb;
104135 +
104136 + FOR_ALL_BB(bb) {
104137 + gimple_stmt_iterator si;
104138 +
104139 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
104140 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
104141 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
104142 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
104143 + }
104144 +}
104145 +
104146 +static unsigned int handle_function(void)
104147 +{
104148 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
104149 + bool check_ret;
104150 +
104151 + set_plf_false();
104152 +
104153 + check_ret = check_return_value();
104154 +
104155 + do {
104156 + gimple_stmt_iterator gsi;
104157 + next = bb->next_bb;
104158 +
104159 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104160 + tree fndecl, attr;
104161 + gimple stmt = gsi_stmt(gsi);
104162 +
104163 + if (check_ret)
104164 + handle_return_value(stmt);
104165 +
104166 + if (!(is_gimple_call(stmt)))
104167 + continue;
104168 + fndecl = gimple_call_fndecl(stmt);
104169 + if (fndecl == NULL_TREE)
104170 + continue;
104171 + if (gimple_call_num_args(stmt) == 0)
104172 + continue;
104173 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
104174 + if (!attr || !TREE_VALUE(attr))
104175 + handle_function_by_hash(stmt, fndecl);
104176 + else
104177 + handle_function_by_attribute(stmt, attr, fndecl);
104178 + gsi = gsi_for_stmt(stmt);
104179 + next = gimple_bb(stmt)->next_bb;
104180 + }
104181 + bb = next;
104182 + } while (bb);
104183 + return 0;
104184 +}
104185 +
104186 +static struct gimple_opt_pass size_overflow_pass = {
104187 + .pass = {
104188 + .type = GIMPLE_PASS,
104189 + .name = "size_overflow",
104190 +#if BUILDING_GCC_VERSION >= 4008
104191 + .optinfo_flags = OPTGROUP_NONE,
104192 +#endif
104193 + .gate = NULL,
104194 + .execute = handle_function,
104195 + .sub = NULL,
104196 + .next = NULL,
104197 + .static_pass_number = 0,
104198 + .tv_id = TV_NONE,
104199 + .properties_required = PROP_cfg,
104200 + .properties_provided = 0,
104201 + .properties_destroyed = 0,
104202 + .todo_flags_start = 0,
104203 + .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
104204 + }
104205 +};
104206 +
104207 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
104208 +{
104209 + tree fntype;
104210 +
104211 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
104212 +
104213 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
104214 + fntype = build_function_type_list(void_type_node,
104215 + const_char_ptr_type_node,
104216 + unsigned_type_node,
104217 + const_char_ptr_type_node,
104218 + const_char_ptr_type_node,
104219 + NULL_TREE);
104220 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
104221 +
104222 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
104223 + TREE_PUBLIC(report_size_overflow_decl) = 1;
104224 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
104225 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
104226 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
104227 +}
104228 +
104229 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104230 +{
104231 + int i;
104232 + const char * const plugin_name = plugin_info->base_name;
104233 + const int argc = plugin_info->argc;
104234 + const struct plugin_argument * const argv = plugin_info->argv;
104235 + bool enable = true;
104236 +
104237 + struct register_pass_info size_overflow_pass_info = {
104238 + .pass = &size_overflow_pass.pass,
104239 + .reference_pass_name = "ssa",
104240 + .ref_pass_instance_number = 1,
104241 + .pos_op = PASS_POS_INSERT_AFTER
104242 + };
104243 +
104244 + if (!plugin_default_version_check(version, &gcc_version)) {
104245 + error(G_("incompatible gcc/plugin versions"));
104246 + return 1;
104247 + }
104248 +
104249 + for (i = 0; i < argc; ++i) {
104250 + if (!strcmp(argv[i].key, "no-size-overflow")) {
104251 + enable = false;
104252 + continue;
104253 + }
104254 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104255 + }
104256 +
104257 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
104258 + if (enable) {
104259 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
104260 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
104261 + }
104262 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104263 +
104264 + return 0;
104265 +}
104266 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
104267 new file mode 100644
104268 index 0000000..ac2901e
104269 --- /dev/null
104270 +++ b/tools/gcc/stackleak_plugin.c
104271 @@ -0,0 +1,327 @@
104272 +/*
104273 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
104274 + * Licensed under the GPL v2
104275 + *
104276 + * Note: the choice of the license means that the compilation process is
104277 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104278 + * but for the kernel it doesn't matter since it doesn't link against
104279 + * any of the gcc libraries
104280 + *
104281 + * gcc plugin to help implement various PaX features
104282 + *
104283 + * - track lowest stack pointer
104284 + *
104285 + * TODO:
104286 + * - initialize all local variables
104287 + *
104288 + * BUGS:
104289 + * - none known
104290 + */
104291 +#include "gcc-plugin.h"
104292 +#include "config.h"
104293 +#include "system.h"
104294 +#include "coretypes.h"
104295 +#include "tree.h"
104296 +#include "tree-pass.h"
104297 +#include "flags.h"
104298 +#include "intl.h"
104299 +#include "toplev.h"
104300 +#include "plugin.h"
104301 +//#include "expr.h" where are you...
104302 +#include "diagnostic.h"
104303 +#include "plugin-version.h"
104304 +#include "tm.h"
104305 +#include "function.h"
104306 +#include "basic-block.h"
104307 +#include "gimple.h"
104308 +#include "rtl.h"
104309 +#include "emit-rtl.h"
104310 +
104311 +#if BUILDING_GCC_VERSION >= 4008
104312 +#define TODO_dump_func 0
104313 +#endif
104314 +
104315 +extern void print_gimple_stmt(FILE *, gimple, int, int);
104316 +
104317 +int plugin_is_GPL_compatible;
104318 +
104319 +static int track_frame_size = -1;
104320 +static const char track_function[] = "pax_track_stack";
104321 +static const char check_function[] = "pax_check_alloca";
104322 +static bool init_locals;
104323 +
104324 +static struct plugin_info stackleak_plugin_info = {
104325 + .version = "201302112000",
104326 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
104327 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
104328 +};
104329 +
104330 +static bool gate_stackleak_track_stack(void);
104331 +static unsigned int execute_stackleak_tree_instrument(void);
104332 +static unsigned int execute_stackleak_final(void);
104333 +
104334 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
104335 + .pass = {
104336 + .type = GIMPLE_PASS,
104337 + .name = "stackleak_tree_instrument",
104338 +#if BUILDING_GCC_VERSION >= 4008
104339 + .optinfo_flags = OPTGROUP_NONE,
104340 +#endif
104341 + .gate = gate_stackleak_track_stack,
104342 + .execute = execute_stackleak_tree_instrument,
104343 + .sub = NULL,
104344 + .next = NULL,
104345 + .static_pass_number = 0,
104346 + .tv_id = TV_NONE,
104347 + .properties_required = PROP_gimple_leh | PROP_cfg,
104348 + .properties_provided = 0,
104349 + .properties_destroyed = 0,
104350 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
104351 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
104352 + }
104353 +};
104354 +
104355 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
104356 + .pass = {
104357 + .type = RTL_PASS,
104358 + .name = "stackleak_final",
104359 +#if BUILDING_GCC_VERSION >= 4008
104360 + .optinfo_flags = OPTGROUP_NONE,
104361 +#endif
104362 + .gate = gate_stackleak_track_stack,
104363 + .execute = execute_stackleak_final,
104364 + .sub = NULL,
104365 + .next = NULL,
104366 + .static_pass_number = 0,
104367 + .tv_id = TV_NONE,
104368 + .properties_required = 0,
104369 + .properties_provided = 0,
104370 + .properties_destroyed = 0,
104371 + .todo_flags_start = 0,
104372 + .todo_flags_finish = TODO_dump_func
104373 + }
104374 +};
104375 +
104376 +static bool gate_stackleak_track_stack(void)
104377 +{
104378 + return track_frame_size >= 0;
104379 +}
104380 +
104381 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
104382 +{
104383 + gimple check_alloca;
104384 + tree fntype, fndecl, alloca_size;
104385 +
104386 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
104387 + fndecl = build_fn_decl(check_function, fntype);
104388 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104389 +
104390 + // insert call to void pax_check_alloca(unsigned long size)
104391 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
104392 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
104393 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
104394 +}
104395 +
104396 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
104397 +{
104398 + gimple track_stack;
104399 + tree fntype, fndecl;
104400 +
104401 + fntype = build_function_type_list(void_type_node, NULL_TREE);
104402 + fndecl = build_fn_decl(track_function, fntype);
104403 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104404 +
104405 + // insert call to void pax_track_stack(void)
104406 + track_stack = gimple_build_call(fndecl, 0);
104407 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
104408 +}
104409 +
104410 +#if BUILDING_GCC_VERSION == 4005
104411 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
104412 +{
104413 + tree fndecl;
104414 +
104415 + if (!is_gimple_call(stmt))
104416 + return false;
104417 + fndecl = gimple_call_fndecl(stmt);
104418 + if (!fndecl)
104419 + return false;
104420 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
104421 + return false;
104422 +// print_node(stderr, "pax", fndecl, 4);
104423 + return DECL_FUNCTION_CODE(fndecl) == code;
104424 +}
104425 +#endif
104426 +
104427 +static bool is_alloca(gimple stmt)
104428 +{
104429 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
104430 + return true;
104431 +
104432 +#if BUILDING_GCC_VERSION >= 4007
104433 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
104434 + return true;
104435 +#endif
104436 +
104437 + return false;
104438 +}
104439 +
104440 +static unsigned int execute_stackleak_tree_instrument(void)
104441 +{
104442 + basic_block bb, entry_bb;
104443 + bool prologue_instrumented = false, is_leaf = true;
104444 +
104445 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
104446 +
104447 + // 1. loop through BBs and GIMPLE statements
104448 + FOR_EACH_BB(bb) {
104449 + gimple_stmt_iterator gsi;
104450 +
104451 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104452 + gimple stmt;
104453 +
104454 + stmt = gsi_stmt(gsi);
104455 +
104456 + if (is_gimple_call(stmt))
104457 + is_leaf = false;
104458 +
104459 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
104460 + if (!is_alloca(stmt))
104461 + continue;
104462 +
104463 + // 2. insert stack overflow check before each __builtin_alloca call
104464 + stackleak_check_alloca(&gsi);
104465 +
104466 + // 3. insert track call after each __builtin_alloca call
104467 + stackleak_add_instrumentation(&gsi);
104468 + if (bb == entry_bb)
104469 + prologue_instrumented = true;
104470 + }
104471 + }
104472 +
104473 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
104474 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
104475 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
104476 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
104477 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
104478 + return 0;
104479 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
104480 + return 0;
104481 +
104482 + // 4. insert track call at the beginning
104483 + if (!prologue_instrumented) {
104484 + gimple_stmt_iterator gsi;
104485 +
104486 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104487 + if (dom_info_available_p(CDI_DOMINATORS))
104488 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104489 + gsi = gsi_start_bb(bb);
104490 + stackleak_add_instrumentation(&gsi);
104491 + }
104492 +
104493 + return 0;
104494 +}
104495 +
104496 +static unsigned int execute_stackleak_final(void)
104497 +{
104498 + rtx insn, next;
104499 +
104500 + if (cfun->calls_alloca)
104501 + return 0;
104502 +
104503 + // keep calls only if function frame is big enough
104504 + if (get_frame_size() >= track_frame_size)
104505 + return 0;
104506 +
104507 + // 1. find pax_track_stack calls
104508 + for (insn = get_insns(); insn; insn = next) {
104509 + // 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))
104510 + rtx body;
104511 +
104512 + next = NEXT_INSN(insn);
104513 + if (!CALL_P(insn))
104514 + continue;
104515 + body = PATTERN(insn);
104516 + if (GET_CODE(body) != CALL)
104517 + continue;
104518 + body = XEXP(body, 0);
104519 + if (GET_CODE(body) != MEM)
104520 + continue;
104521 + body = XEXP(body, 0);
104522 + if (GET_CODE(body) != SYMBOL_REF)
104523 + continue;
104524 + if (strcmp(XSTR(body, 0), track_function))
104525 + continue;
104526 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104527 + // 2. delete call
104528 + delete_insn_and_edges(insn);
104529 +#if BUILDING_GCC_VERSION >= 4007
104530 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
104531 + insn = next;
104532 + next = NEXT_INSN(insn);
104533 + delete_insn_and_edges(insn);
104534 + }
104535 +#endif
104536 + }
104537 +
104538 +// print_simple_rtl(stderr, get_insns());
104539 +// print_rtl(stderr, get_insns());
104540 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104541 +
104542 + return 0;
104543 +}
104544 +
104545 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104546 +{
104547 + const char * const plugin_name = plugin_info->base_name;
104548 + const int argc = plugin_info->argc;
104549 + const struct plugin_argument * const argv = plugin_info->argv;
104550 + int i;
104551 + struct register_pass_info stackleak_tree_instrument_pass_info = {
104552 + .pass = &stackleak_tree_instrument_pass.pass,
104553 +// .reference_pass_name = "tree_profile",
104554 + .reference_pass_name = "optimized",
104555 + .ref_pass_instance_number = 1,
104556 + .pos_op = PASS_POS_INSERT_BEFORE
104557 + };
104558 + struct register_pass_info stackleak_final_pass_info = {
104559 + .pass = &stackleak_final_rtl_opt_pass.pass,
104560 + .reference_pass_name = "final",
104561 + .ref_pass_instance_number = 1,
104562 + .pos_op = PASS_POS_INSERT_BEFORE
104563 + };
104564 +
104565 + if (!plugin_default_version_check(version, &gcc_version)) {
104566 + error(G_("incompatible gcc/plugin versions"));
104567 + return 1;
104568 + }
104569 +
104570 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
104571 +
104572 + for (i = 0; i < argc; ++i) {
104573 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
104574 + if (!argv[i].value) {
104575 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104576 + continue;
104577 + }
104578 + track_frame_size = atoi(argv[i].value);
104579 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
104580 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104581 + continue;
104582 + }
104583 + if (!strcmp(argv[i].key, "initialize-locals")) {
104584 + if (argv[i].value) {
104585 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104586 + continue;
104587 + }
104588 + init_locals = true;
104589 + continue;
104590 + }
104591 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104592 + }
104593 +
104594 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
104595 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
104596 +
104597 + return 0;
104598 +}
104599 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
104600 new file mode 100644
104601 index 0000000..4fae911
104602 --- /dev/null
104603 +++ b/tools/gcc/structleak_plugin.c
104604 @@ -0,0 +1,277 @@
104605 +/*
104606 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
104607 + * Licensed under the GPL v2
104608 + *
104609 + * Note: the choice of the license means that the compilation process is
104610 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104611 + * but for the kernel it doesn't matter since it doesn't link against
104612 + * any of the gcc libraries
104613 + *
104614 + * gcc plugin to forcibly initialize certain local variables that could
104615 + * otherwise leak kernel stack to userland if they aren't properly initialized
104616 + * by later code
104617 + *
104618 + * Homepage: http://pax.grsecurity.net/
104619 + *
104620 + * Usage:
104621 + * $ # for 4.5/4.6/C based 4.7
104622 + * $ 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
104623 + * $ # for C++ based 4.7/4.8+
104624 + * $ 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
104625 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
104626 + *
104627 + * TODO: eliminate redundant initializers
104628 + * increase type coverage
104629 + */
104630 +
104631 +#include "gcc-plugin.h"
104632 +#include "config.h"
104633 +#include "system.h"
104634 +#include "coretypes.h"
104635 +#include "tree.h"
104636 +#include "tree-pass.h"
104637 +#include "intl.h"
104638 +#include "plugin-version.h"
104639 +#include "tm.h"
104640 +#include "toplev.h"
104641 +#include "function.h"
104642 +#include "tree-flow.h"
104643 +#include "plugin.h"
104644 +#include "gimple.h"
104645 +#include "diagnostic.h"
104646 +#include "cfgloop.h"
104647 +#include "langhooks.h"
104648 +
104649 +#if BUILDING_GCC_VERSION >= 4008
104650 +#define TODO_dump_func 0
104651 +#endif
104652 +
104653 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
104654 +
104655 +// unused type flag in all versions 4.5-4.8
104656 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
104657 +
104658 +int plugin_is_GPL_compatible;
104659 +void debug_gimple_stmt(gimple gs);
104660 +
104661 +static struct plugin_info structleak_plugin_info = {
104662 + .version = "201304082245",
104663 + .help = "disable\tdo not activate plugin\n",
104664 +};
104665 +
104666 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
104667 +{
104668 + *no_add_attrs = true;
104669 +
104670 + // check for types? for now accept everything linux has to offer
104671 + if (TREE_CODE(*node) != FIELD_DECL)
104672 + return NULL_TREE;
104673 +
104674 + *no_add_attrs = false;
104675 + return NULL_TREE;
104676 +}
104677 +
104678 +static struct attribute_spec user_attr = {
104679 + .name = "user",
104680 + .min_length = 0,
104681 + .max_length = 0,
104682 + .decl_required = false,
104683 + .type_required = false,
104684 + .function_type_required = false,
104685 + .handler = handle_user_attribute,
104686 +#if BUILDING_GCC_VERSION >= 4007
104687 + .affects_type_identity = true
104688 +#endif
104689 +};
104690 +
104691 +static void register_attributes(void *event_data, void *data)
104692 +{
104693 + register_attribute(&user_attr);
104694 +// register_attribute(&force_attr);
104695 +}
104696 +
104697 +static tree get_field_type(tree field)
104698 +{
104699 + return strip_array_types(TREE_TYPE(field));
104700 +}
104701 +
104702 +static bool is_userspace_type(tree type)
104703 +{
104704 + tree field;
104705 +
104706 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
104707 + tree fieldtype = get_field_type(field);
104708 + enum tree_code code = TREE_CODE(fieldtype);
104709 +
104710 + if (code == RECORD_TYPE || code == UNION_TYPE)
104711 + if (is_userspace_type(fieldtype))
104712 + return true;
104713 +
104714 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
104715 + return true;
104716 + }
104717 + return false;
104718 +}
104719 +
104720 +static void finish_type(void *event_data, void *data)
104721 +{
104722 + tree type = (tree)event_data;
104723 +
104724 + if (TYPE_USERSPACE(type))
104725 + return;
104726 +
104727 + if (is_userspace_type(type))
104728 + TYPE_USERSPACE(type) = 1;
104729 +}
104730 +
104731 +static void initialize(tree var)
104732 +{
104733 + basic_block bb;
104734 + gimple_stmt_iterator gsi;
104735 + tree initializer;
104736 + gimple init_stmt;
104737 +
104738 + // this is the original entry bb before the forced split
104739 + // TODO: check further BBs in case more splits occured before us
104740 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
104741 +
104742 + // first check if the variable is already initialized, warn otherwise
104743 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104744 + gimple stmt = gsi_stmt(gsi);
104745 + tree rhs1;
104746 +
104747 + // we're looking for an assignment of a single rhs...
104748 + if (!gimple_assign_single_p(stmt))
104749 + continue;
104750 + rhs1 = gimple_assign_rhs1(stmt);
104751 +#if BUILDING_GCC_VERSION >= 4007
104752 + // ... of a non-clobbering expression...
104753 + if (TREE_CLOBBER_P(rhs1))
104754 + continue;
104755 +#endif
104756 + // ... to our variable...
104757 + if (gimple_get_lhs(stmt) != var)
104758 + continue;
104759 + // if it's an initializer then we're good
104760 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
104761 + return;
104762 + }
104763 +
104764 + // these aren't the 0days you're looking for
104765 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
104766 +
104767 + // build the initializer expression
104768 + initializer = build_constructor(TREE_TYPE(var), NULL);
104769 +
104770 + // build the initializer stmt
104771 + init_stmt = gimple_build_assign(var, initializer);
104772 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
104773 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
104774 + update_stmt(init_stmt);
104775 +}
104776 +
104777 +static unsigned int handle_function(void)
104778 +{
104779 + basic_block bb;
104780 + unsigned int ret = 0;
104781 + tree var;
104782 +
104783 +#if BUILDING_GCC_VERSION == 4005
104784 + tree vars;
104785 +#else
104786 + unsigned int i;
104787 +#endif
104788 +
104789 + // split the first bb where we can put the forced initializers
104790 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104791 + if (dom_info_available_p(CDI_DOMINATORS))
104792 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104793 +
104794 + // enumarate all local variables and forcibly initialize our targets
104795 +#if BUILDING_GCC_VERSION == 4005
104796 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
104797 + var = TREE_VALUE(vars);
104798 +#else
104799 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
104800 +#endif
104801 + tree type = TREE_TYPE(var);
104802 +
104803 + gcc_assert(DECL_P(var));
104804 + if (!auto_var_in_fn_p(var, current_function_decl))
104805 + continue;
104806 +
104807 + // only care about structure types
104808 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
104809 + continue;
104810 +
104811 + // if the type is of interest, examine the variable
104812 + if (TYPE_USERSPACE(type))
104813 + initialize(var);
104814 + }
104815 +
104816 + return ret;
104817 +}
104818 +
104819 +static struct gimple_opt_pass structleak_pass = {
104820 + .pass = {
104821 + .type = GIMPLE_PASS,
104822 + .name = "structleak",
104823 +#if BUILDING_GCC_VERSION >= 4008
104824 + .optinfo_flags = OPTGROUP_NONE,
104825 +#endif
104826 + .gate = NULL,
104827 + .execute = handle_function,
104828 + .sub = NULL,
104829 + .next = NULL,
104830 + .static_pass_number = 0,
104831 + .tv_id = TV_NONE,
104832 + .properties_required = PROP_cfg,
104833 + .properties_provided = 0,
104834 + .properties_destroyed = 0,
104835 + .todo_flags_start = 0,
104836 + .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
104837 + }
104838 +};
104839 +
104840 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104841 +{
104842 + int i;
104843 + const char * const plugin_name = plugin_info->base_name;
104844 + const int argc = plugin_info->argc;
104845 + const struct plugin_argument * const argv = plugin_info->argv;
104846 + bool enable = true;
104847 +
104848 + struct register_pass_info structleak_pass_info = {
104849 + .pass = &structleak_pass.pass,
104850 + .reference_pass_name = "ssa",
104851 + .ref_pass_instance_number = 1,
104852 + .pos_op = PASS_POS_INSERT_AFTER
104853 + };
104854 +
104855 + if (!plugin_default_version_check(version, &gcc_version)) {
104856 + error(G_("incompatible gcc/plugin versions"));
104857 + return 1;
104858 + }
104859 +
104860 + if (strcmp(lang_hooks.name, "GNU C")) {
104861 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
104862 + enable = false;
104863 + }
104864 +
104865 + for (i = 0; i < argc; ++i) {
104866 + if (!strcmp(argv[i].key, "disable")) {
104867 + enable = false;
104868 + continue;
104869 + }
104870 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104871 + }
104872 +
104873 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
104874 + if (enable) {
104875 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
104876 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
104877 + }
104878 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104879 +
104880 + return 0;
104881 +}
104882 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
104883 index 6789d78..4afd019e 100644
104884 --- a/tools/perf/util/include/asm/alternative-asm.h
104885 +++ b/tools/perf/util/include/asm/alternative-asm.h
104886 @@ -5,4 +5,7 @@
104887
104888 #define altinstruction_entry #
104889
104890 + .macro pax_force_retaddr rip=0, reload=0
104891 + .endm
104892 +
104893 #endif
104894 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
104895 index 96b919d..c49bb74 100644
104896 --- a/tools/perf/util/include/linux/compiler.h
104897 +++ b/tools/perf/util/include/linux/compiler.h
104898 @@ -18,4 +18,12 @@
104899 #define __force
104900 #endif
104901
104902 +#ifndef __size_overflow
104903 +# define __size_overflow(...)
104904 +#endif
104905 +
104906 +#ifndef __intentional_overflow
104907 +# define __intentional_overflow(...)
104908 +#endif
104909 +
104910 #endif
104911 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
104912 index f18013f..90421df 100644
104913 --- a/virt/kvm/kvm_main.c
104914 +++ b/virt/kvm/kvm_main.c
104915 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
104916
104917 static cpumask_var_t cpus_hardware_enabled;
104918 static int kvm_usage_count = 0;
104919 -static atomic_t hardware_enable_failed;
104920 +static atomic_unchecked_t hardware_enable_failed;
104921
104922 struct kmem_cache *kvm_vcpu_cache;
104923 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
104924
104925 -static __read_mostly struct preempt_ops kvm_preempt_ops;
104926 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
104927 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
104928 +static struct preempt_ops kvm_preempt_ops = {
104929 + .sched_in = kvm_sched_in,
104930 + .sched_out = kvm_sched_out,
104931 +};
104932
104933 struct dentry *kvm_debugfs_dir;
104934
104935 @@ -769,7 +774,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
104936 /* We can read the guest memory with __xxx_user() later on. */
104937 if (user_alloc &&
104938 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
104939 - !access_ok(VERIFY_WRITE,
104940 + !__access_ok(VERIFY_WRITE,
104941 (void __user *)(unsigned long)mem->userspace_addr,
104942 mem->memory_size)))
104943 goto out;
104944 @@ -1881,7 +1886,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
104945 return 0;
104946 }
104947
104948 -static struct file_operations kvm_vcpu_fops = {
104949 +static file_operations_no_const kvm_vcpu_fops __read_only = {
104950 .release = kvm_vcpu_release,
104951 .unlocked_ioctl = kvm_vcpu_ioctl,
104952 #ifdef CONFIG_COMPAT
104953 @@ -2402,7 +2407,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
104954 return 0;
104955 }
104956
104957 -static struct file_operations kvm_vm_fops = {
104958 +static file_operations_no_const kvm_vm_fops __read_only = {
104959 .release = kvm_vm_release,
104960 .unlocked_ioctl = kvm_vm_ioctl,
104961 #ifdef CONFIG_COMPAT
104962 @@ -2500,7 +2505,7 @@ out:
104963 return r;
104964 }
104965
104966 -static struct file_operations kvm_chardev_ops = {
104967 +static file_operations_no_const kvm_chardev_ops __read_only = {
104968 .unlocked_ioctl = kvm_dev_ioctl,
104969 .compat_ioctl = kvm_dev_ioctl,
104970 .llseek = noop_llseek,
104971 @@ -2526,7 +2531,7 @@ static void hardware_enable_nolock(void *junk)
104972
104973 if (r) {
104974 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104975 - atomic_inc(&hardware_enable_failed);
104976 + atomic_inc_unchecked(&hardware_enable_failed);
104977 printk(KERN_INFO "kvm: enabling virtualization on "
104978 "CPU%d failed\n", cpu);
104979 }
104980 @@ -2580,10 +2585,10 @@ static int hardware_enable_all(void)
104981
104982 kvm_usage_count++;
104983 if (kvm_usage_count == 1) {
104984 - atomic_set(&hardware_enable_failed, 0);
104985 + atomic_set_unchecked(&hardware_enable_failed, 0);
104986 on_each_cpu(hardware_enable_nolock, NULL, 1);
104987
104988 - if (atomic_read(&hardware_enable_failed)) {
104989 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104990 hardware_disable_all_nolock();
104991 r = -EBUSY;
104992 }
104993 @@ -2941,7 +2946,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104994 kvm_arch_vcpu_put(vcpu);
104995 }
104996
104997 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104998 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104999 struct module *module)
105000 {
105001 int r;
105002 @@ -2977,7 +2982,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105003 if (!vcpu_align)
105004 vcpu_align = __alignof__(struct kvm_vcpu);
105005 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
105006 - 0, NULL);
105007 + SLAB_USERCOPY, NULL);
105008 if (!kvm_vcpu_cache) {
105009 r = -ENOMEM;
105010 goto out_free_3;
105011 @@ -2987,9 +2992,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105012 if (r)
105013 goto out_free;
105014
105015 + pax_open_kernel();
105016 kvm_chardev_ops.owner = module;
105017 kvm_vm_fops.owner = module;
105018 kvm_vcpu_fops.owner = module;
105019 + pax_close_kernel();
105020
105021 r = misc_register(&kvm_dev);
105022 if (r) {
105023 @@ -2999,9 +3006,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
105024
105025 register_syscore_ops(&kvm_syscore_ops);
105026
105027 - kvm_preempt_ops.sched_in = kvm_sched_in;
105028 - kvm_preempt_ops.sched_out = kvm_sched_out;
105029 -
105030 r = kvm_init_debug();
105031 if (r) {
105032 printk(KERN_ERR "kvm: create debugfs files failed\n");